-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/#9 test dvoting #16
Conversation
XioZ
commented
May 30, 2024
- Closing Test D-Voting with New Mino P2P #9
- Rewrote Stream() to:
-
- have an orchestrator that relays messages among participants (participants can send/receive messages to/from the orchestrator as well as to/from other participants)
-
- wrap orchestrator's address to pass equality check by callers against protocol initiator's participant address
- Passed integration check with d-voting (all actions from Initialize Nodes to See Results completed successfully)
- Improved benchmark performance to slightly outperform gRPC



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.
Great work - I'm happy that it all fits together now. For the final report, please be sure to:
- comment what you changed to improve the benchmark
- describe what in the current API description is wrong / confusing
There are too many closures in the code, and it's not clear which closures capture which local variables. This is why I propose to create them as methods on the structure, and then call them like that. If we would have more time, it would also be easier to test them like that.
mino/minows/address.go
Outdated
} else { | ||
addr, err = newOrchestratorAddr(location, identity) |
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.
Unreachable code path: on line 128 you return if len(parts) < 2
, and here you check if it equals 2.
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 reachable. it handles 3 cases: < 2, = 2 and > 2
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.
Now I see the light. It's /(.*?):(.*?)(:o)?/
. So either add that as a comment to FromText
, or check for parts[2] == 'o'
in the else
branch to make this explicit.
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.
added check
"default listen address)", | ||
Required: false, | ||
Value: "", | ||
}, | ||
) | ||
|
||
cmd := builder.SetCommand("list") | ||
sub := cmd.SetSubCommand("address") |
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.
No need to change, only my comment: this could be a command only, w/o a subcommand.
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.
address doesn't work as a command in dvoting. it seems to conflict with commands from another controller when i was testing
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 could be addresses
, listp2p
, listAddresses
, dumpAddresses
, or any other command.
As I said - no change needed, just a random idea.
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 keeping as-is then :)
mino/minows/rpc.go
Outdated
in: make(chan Packet, MaxUnreadAllowed), | ||
} | ||
|
||
fetch := func(decoder *gob.Decoder) (Packet, mino.Address, error) { |
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.
Refactor: add this as a method to orchestrator
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.
are you sure? closure is the more idiomatic way to write single-use functions in Go, as it avoids unnecessarily long argument list through variable capture, which makes the code cleaner, shorter and easier to read without having to scroll to another 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.
As far as I can see, there would be no additional arguments, as all captured variables are available in the orchestrator
.
And while I can see the argument for one (short) closure, I wouldn't call three closures in a row cleaner, shorter, and easier to read...
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.
changed
mino/minows/rpc.go
Outdated
|
||
reply, err := h.Process(mino.Request{Address: from, Message: req}) | ||
relay := func(packet Packet, dest address) error { |
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.
Refactor: add this as a method to orchestrator
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.
changed
mino/minows/rpc.go
Outdated
if err != nil { | ||
r.logger.Error().Err(err).Msg("could not reply to call") | ||
return | ||
receive := func(decoder *gob.Decoder) (Packet, error) { |
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.
Refactor: add this as a method to orchestrator
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.
changed
mino/minows/rpc.go
Outdated
encoder := gob.NewEncoder(stream) | ||
decoder := gob.NewDecoder(stream) | ||
|
||
receive := func() (Packet, error) { |
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.
Refactor: add this as a method to participant
(and add decoder
to its structure)
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.
changed
mino/minows/session.go
Outdated
// Send is asynchronous and returns immediately an error channel that | ||
// closes when the message has either been sent or errored to each address. | ||
func (s session) Send(msg serde.Message, addrs ...mino.Address) <-chan error { | ||
func (o orchestrator) Send(msg serde.Message, addrs ...mino.Address) <-chan error { | ||
send := func(addr mino.Address) error { |
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.
- Make this a method of
orchestrator
- else it's capturingo
here, which is confusing. If it's part oforchestrator
, it's clear that it will use the fields oforchestrator
- Take
msg
as parameter, else the capturedmsg
will be used both in this closure and be passed todoSend
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.
changed
mino/minows/session.go
Outdated
} | ||
|
||
func (p participant) Send(msg serde.Message, addrs ...mino.Address) <-chan error { | ||
send := func(addr mino.Address) error { |
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.
- Make this a method of
participant
- else it's capturingp
here, which is confusing. If it's part ofparticipant
, it's clear that it will use the fields ofparticipant
- Take
msg
as parameter, else the capturedmsg
will be used both in this closure and be passed todoSend
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.
changed
227235b
to
2a1cc78
Compare