Skip to content
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

Merged
merged 20 commits into from
May 7, 2020
Merged

Conversation

nkcr
Copy link
Contributor

@nkcr nkcr commented Apr 22, 2020

As discussed, each node gets the list of addresses and computes in a deterministic manner the tree topology.

Tests will follow.

As discussed, each node gets the list of addresses and computes in a deterministic manner the tree topology.
@nkcr nkcr added enhancement New feature or request mod/mino About the Mino module labels Apr 22, 2020
@nkcr nkcr self-assigned this Apr 22, 2020
@nkcr nkcr requested a review from Gilthoniel April 22, 2020 14:25
Copy link
Contributor

@Gilthoniel Gilthoniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

mino/minogrpc/overlay.go Outdated Show resolved Hide resolved
mino/minogrpc/overlay_test.go Show resolved Hide resolved
mino/minogrpc/routing.go Outdated Show resolved Hide resolved
mino/minogrpc/routing.go Outdated Show resolved Hide resolved
@Gilthoniel
Copy link
Contributor

We can have a student project next semester to implement a more resilient tree.

@nkcr
Copy link
Contributor Author

nkcr commented Apr 29, 2020

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 client -> N1 -> N2 -> N3 ... N9 -> client

graphviz

@nkcr nkcr requested a review from Gilthoniel May 4, 2020 08:44
@nkcr
Copy link
Contributor Author

nkcr commented May 4, 2020

@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.

Copy link
Contributor

@Gilthoniel Gilthoniel left a 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.go Outdated Show resolved Hide resolved
Comment on lines 17 to 18
&OverlayMsg{},
&Envelope{},
Copy link
Contributor

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 ?

Copy link
Contributor Author

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


addrs := make([]mino.Address, len(routingMsg.Addrs))
for i, addrStr := range routingMsg.Addrs {
addrs[i] = address{addrStr}
Copy link
Contributor

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.

}

routing, err := o.routingFactory.FromAddrs(addrs, map[string]interface{}{
TreeRoutingOpts.Addr: o.addr, "treeHeight": treeHeight,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line

})
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably done ;)

Childs []*treeNode
}

func (n treeNode) String() string {
Copy link
Contributor

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.


// warning: this call will shuffle addrs

routing, err := rpc.routingFactory.FromAddrs(addrs, map[string]interface{}{
Copy link
Contributor

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()
Copy link
Contributor

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() {
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

@nkcr
Copy link
Contributor Author

nkcr commented May 5, 2020

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 minogrpc/routing. (Tests for this package will be added later.)

Copy link
Contributor

@Gilthoniel Gilthoniel left a 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!

sort.Stable(&addrsBuf)

// We will use the hash of the addresses to set the random seed.
hash := sha256.New()
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍

@nkcr nkcr requested a review from Gilthoniel May 7, 2020 08:41
@Gilthoniel Gilthoniel merged commit 5d4e608 into master May 7, 2020
@Gilthoniel Gilthoniel deleted the topology-passing branch May 7, 2020 08:59
bbjubjub2494 pushed a commit to bbjubjub2494/dela that referenced this pull request Aug 3, 2024
Implements a simple tree networking topology
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mod/mino About the Mino module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants