p2p refactor: state sync reactor#5671
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5671 +/- ##
==========================================
+ Coverage 60.50% 60.57% +0.06%
==========================================
Files 259 261 +2
Lines 23345 23618 +273
==========================================
+ Hits 14126 14306 +180
- Misses 7743 7829 +86
- Partials 1476 1483 +7
|
erikgrinaker
left a comment
There was a problem hiding this comment.
Shim looks great overall! Left a few minor comment.
We'll have to look closer at the details here later, but this is great for now. E.g. we need to look into blocking/buffering/dropping and such - the shim is now dropping messages while I think the current P2P stack assumes it will block. We may want to block for now too, to preserve the current system behavior, until we design the router. But let's do a pass later for stuff like this.
Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
|
Occurred to me that we'll need better panic handling here too. In this PR, a panic during message processing causes the entire channel processing goroutine to terminate. In the current P2P stack, a panic causes the peer to be disconnected. We should probably disconnect the peer but otherwise continue message processing, similarly to how a web-server doesn't terminate if a HTTP request panics. |
Agree, but this is dependent on the individual reactors. Specifically, for state-sync, we do not have any explicit |
Yeah, it follows from using channels that it's the consumer's responsibility to handle panics and other errors during processing. Since we're receiving messages from random people on the Internet here, we need to be resistant to adversarial inputs, and that includes panic recovery. There's a bunch of different options here, for example:
These are just a few ideas off the top of my head, there's probably other good options as well. I think this mostly depends on what's most convenient, understandable, and flexible so it's probably a good idea to experiment with a few approaches and see what works best. |
|
I went with something that is more like (1) because I do not want to make any premature abstractions or optimizations without knowing how all the reactors will look like. This is something we can cleanup in the future in, most likely, a non-breaking manner. So now we have a simple |
erikgrinaker
left a comment
There was a problem hiding this comment.
Looks great! A couple of nits, otherwise I think this is good to go. 🚀
As we've discussed, the reactor ergonomics with panic handling and such isn't optimal, let's revisit this later. Also, there are probably still potential deadlocks, halts, and impedance mismatches with the current P2P stack, but we've covered most things that I can think of -- we should be on the lookout for these sorts of issues as we do the remaining reactors.
Description
Prepares the state-sync reactor for the newly designed p2p changes per ADR 062.
Serviceimplementation for state-sync. It still fulfills theServiceinterface, but now using the p2pChannelsemantics.ref: #5670