-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minows #22
Conversation
e977b67
to
2885f13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed half-way, in particular low-hanging fruits.
More reviewing to follow... time permitting.
|
||
import ( | ||
"context" | ||
"encoding/gob" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we using gob encoding everywhere instead of serde
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, the serde
implementation used json
, and as the first benchmarks were slow, it has been changed to a binary format. But in the end it turned out that the slowdown was due to another part of the implementation. So I think we can revert that, if you prefer to have serde
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact he gob
encodes the following structure:
type Packet struct {
Source []byte
Payload []byte
}
And then uses serde
to encode the payload.
Is it worth creating a serde
abstraction for the Packet
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep everything uniform, I'd say yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I looked at it, and I propose to keep the Packet
as a gob-encoded structure, with the following reasoning:
- to me it corresponds to the grpc-encoding found here, which is encoded using protobuf (if I got that right): overlayClient.Call
- as it needs to interface with the
Stream
interface, I'll have to add a packet-size manually, so that the receiver knows how many bytes to receive
So, I would be implementing part of the gob
interface myself. Which is why I propose to accept this as-is.
@pierluca what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed 9/21 files, coming back later to it
dela is now based on go 1.21. Is it possible to upgrade this PR to align it to 1.21 as well ? |
Good point. I'll try to rebase our dela fork on the dedis dela, and see if things break too hard :) |
Co-authored-by: Zach Xion XioZ@users.noreply.github.com
Co-authored-by: Zach Xion XioZ@users.noreply.github.com This commit implements a new Mino handler using libp2p with websockets. Contrary to MinoGRPC it doesn't use any locks and uses a 1-level tree to handle messages. It is at least as performant as the MinoGRPC implementation, and works with d-voting.
Co-authored-by: Zach Xion XioZ@users.noreply.github.com
2e19446
to
eb6b928
Compare
057263b
to
85617df
Compare
Great - 1.21 or the updates of the libp2p library triggers a Heisenbug. I hate it. And it doesn't even tell me where the bug is. Just something breaks. |
3eaef28
to
6653054
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally finished the review.
I think some parts will be massively simplified by adopting serde
.
@ineiti do you have any spare cycles for this or should DEDIS look into it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well I'd try to get rid of gob
and use serde, which can be easily injected wherever needed.
mino/minows/session.go
Outdated
src, err := p.myAddr.MarshalText() | ||
if err != nil { | ||
return xerrors.Errorf("could not marshal address: %v", err) | ||
} | ||
payload, err := msg.Serialize(p.rpc.context) | ||
if err != nil { | ||
return xerrors.Errorf("could not serialize message: %v", err) | ||
} | ||
dest, err := addr.MarshalText() | ||
if err != nil { | ||
return xerrors.Errorf("could not marshal address: %v", err) | ||
} | ||
|
||
// Send to orchestrator to relay to the destination participant | ||
forward := Forward{ | ||
Packet: Packet{Source: src, Payload: payload}, | ||
Destination: dest, | ||
} | ||
err = p.out.Encode(&forward) | ||
if err != nil { | ||
return xerrors.Errorf("could not encode packet: %v", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be so much simpler with serde, and not mixed with the session
code.
mino/minows/session.go
Outdated
encoder, ok := o.outs[unwrapped.identity] | ||
if !ok { | ||
return xerrors.Errorf("%v: %v", ErrNotPlayer, addr) | ||
} | ||
src, err := o.myAddr.MarshalText() | ||
if err != nil { | ||
return xerrors.Errorf("could not marshal address: %v", err) | ||
} | ||
payload, err := msg.Serialize(o.rpc.context) | ||
if err != nil { | ||
return xerrors.Errorf("could not serialize message: %v", err) | ||
} | ||
|
||
err = encoder.Encode(&Packet{Source: src, Payload: payload}) | ||
if err != nil { | ||
return xerrors.Errorf("could not encode packet: %v", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be so much simpler with serde, and not mixed with the session
code.
OK, all should be good now, libp2p had a bug - will test this: |
Auto-congratulation: this actually did the trick... |
8054787
to
16eadf9
Compare
OK, this is my proposal for answering (most) of @pierluca 's comments:
The current PR has been added with some commits for the different things I did. For the final PR I'll merge them all into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better to me.
I'm not 100% sure I follow why gob
is necessary, but at this point it's highly maintainable and that's what matters ! 👍
At one point you need to encode the size of the message, so you know at the other end how many packets you need to read. In the minogrpc code, this is done by Google's grpc module. So the best one could do is to reduce the Here I cheat a bit by adding two other fields (one optional), so I don't have to wrap my head around how to implement the json-encoder/decoder. |
- Adding new version of libp2p - Re-enabling failing test and remove goverall - Use peer.ID.Validate - Don't export Packet and Forward - Merging participant and orchestrator
This is the final PR for the 2024 Spring semester project from Zhe Xion working with the DEDIS lab at EPFL.
It adds a websocket implementation for mino using libp2p, which allows a simple change from websockets to other communication protocols.
The code has been benchmarked against the old minogrpc and tested in d-voting tests.