-
Notifications
You must be signed in to change notification settings - Fork 14
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
Implements a simple tree networking topology #38
Conversation
As discussed, each node gets the list of addresses and computes in a deterministic manner the tree topology.
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.
Very nice!
We can have a student project next semester to implement a more resilient tree. |
Yes, that would be a well-defined and interesting project. In that sense I replaced the treeRouting by an interface. I also updated the test to check if the mesh is fully connected. For the record, here is the complete ordered traffic when 9 nodes relay a packet in a ring fashion with the following sequence |
@Gilthoniel ready for a second review. I still have some deadlocks when I play with >15 nodes with DKG, but I'm waiting to merge this PR and will continue investigating in #41 . But maybe you'll already discover something suspicious there. Another thing: can you have a particular look at how contexts are used? I realised I was misusing them but I don't know if its 100% ok now. |
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.
It's hard to say what's wrong from that PR. I'll need at some point to make a in-depth review of the whole package. The only suspicious thing is the wait on the ctx.Done() which looks wrong to me.
mino/minogrpc/mod_test.go
Outdated
&OverlayMsg{}, | ||
&Envelope{}, |
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.
Can you remind me why you use two kinds of messages ?
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 is something I should merge, but right now it would just add a new layer of uncertainty. I'm adding it to my dodo list
mino/minogrpc/overlay.go
Outdated
|
||
addrs := make([]mino.Address, len(routingMsg.Addrs)) | ||
for i, addrStr := range routingMsg.Addrs { | ||
addrs[i] = address{addrStr} |
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.
That's a good place to use an address factory: If you change the structure, you won't have to come back here.
mino/minogrpc/overlay.go
Outdated
} | ||
|
||
routing, err := o.routingFactory.FromAddrs(addrs, map[string]interface{}{ | ||
TreeRoutingOpts.Addr: o.addr, "treeHeight": treeHeight, |
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.
new line
mino/minogrpc/overlay.go
Outdated
}) | ||
if err != nil { | ||
return xerrors.Errorf("failed to create routing struct: %v", err) | ||
} | ||
|
||
// For the moment this sender can only receive messages to itself | ||
// TODO: find a way to know the other nodes. |
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.
That's probably done ;)
mino/minogrpc/routing.go
Outdated
Childs []*treeNode | ||
} | ||
|
||
func (n treeNode) String() string { |
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.
One line for the string function for the logs, Display
for more complex text.
mino/minogrpc/server.go
Outdated
|
||
// warning: this call will shuffle addrs | ||
|
||
routing, err := rpc.routingFactory.FromAddrs(addrs, map[string]interface{}{ |
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.
You could add a FromIterator
function to make use of the iterator.
if err == io.EOF { | ||
<-ctx.Done() |
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.
same remark as above
|
||
// Sleep random | ||
|
||
func rsleep() { |
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.
I'm not a big fan of the random sleep. You expect from a unit test to make sure a particular scenario will end as expected. You manually send messages in different order to test that they will be handled as expected. Random sleep only provokes random errors on Travis.
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.
Yes I agree. I would however find interesting at some point to have some sort of fuzzing tests with different timing to stress the system. But of course not in this context.
"go.dedis.ch/fabric/mino" | ||
) | ||
|
||
var eachLine = regexp.MustCompile(`(?m)^(.+)$`) | ||
|
||
var counter = atomicCounter{} | ||
|
||
// traffic is used to keep track of packets traffic in a server | ||
type traffic struct { |
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.
Can you either test this file, or move it to an internal/testing package ?
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.
Yes testing is planed. Added in the TODO because for now this is still very prone to change.
and addresses Gaylor's comments
Thanks @Gilthoniel for the review. I addressed your comments. The only thing that would need a second pass would be the refactor of the routing interface, which is now in |
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.
Small comment otherwise it looks good!
mino/minogrpc/routing/routing.go
Outdated
sort.Stable(&addrsBuf) | ||
|
||
// We will use the hash of the addresses to set the random seed. | ||
hash := sha256.New() |
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.
the two functions have a lot of code repetition that could into a private function.
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.
done 👍
Implements a simple tree networking topology
As discussed, each node gets the list of addresses and computes in a deterministic manner the tree topology.
Tests will follow.