-
Notifications
You must be signed in to change notification settings - Fork 86
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
ChainSync client test: model pipelining behavior #3742
ChainSync client test: model pipelining behavior #3742
Conversation
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 looks very nice. Thanks for the very well-organized commits!
Requesting Changes for a few more Haddock comments, mainly. I also ask one relatively-open-ended question about the design.
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Show resolved
Hide resolved
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Show resolved
Hide resolved
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.
All set. Approved! Thanks.
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus-test/test-consensus/Test/Consensus/MiniProtocol/ChainSync/Client.hs
Show resolved
Hide resolved
92d86eb
to
5d06588
Compare
In the context of diffusion pipelining, it is possible honest behavior for an upstream peer to send us a block we already know is invalid. In this case, we should not promptly disconnect them in ChainSync, as was the case pre-pipelining. This commit models the "learning process" of our local node that certain blocks are invalid by scheduling them in random order in the timeframe of scheduled ticks.
5d06588
to
50d8047
Compare
bors merge |
3742: ChainSync client test: model pipelining behavior r=amesgen a=amesgen Closes [CAD-4192](https://input-output.atlassian.net/browse/CAD-4192) Co-authored-by: Alexander Esgen <[email protected]>
Timed out. |
bors retry |
3734: ChainSync server: prevent duplicate `RollForward` messages r=amesgen a=amesgen Closes [CAD-4228](https://input-output.atlassian.net/browse/CAD-4228). #### Problem description Consider the following very common scenario prior to this PR: 1. Assume that the node is idle, having selected a chain with tip A 2. It receives a new block B that extends A 3. We set the tentative header to B 3. This wakes up the ChainSync server thread (in an `STM` transaction in `instructionHelper`) - The roll state is updated from `RollForwardFrom A` to `RollForwardFrom B`. - The chain update `AddBlock B` is emitted. 4. After successful validation, the node selects B which involves a call to `fhSwitchFork` with intersection point A. - Because the intersection point is now behind the roll state point, the roll state is set to `RollBackTo A`. - Hence, the follower emits/the ChainSync server sends a `RollBack A`, immediately followed by another `AddBlock B`. These extra messages are redundant, and will be no longer sent with this PR. #### Diagnosis The arguments to `fhSwitchFork` are unaware of the tentative header, so for a *tentative* follower it looks like a rollback is necessary. Before pipelining, the call to `fhSwitchFork` was a no-op when rolling forward by a block because the passed intersection point did not precede (in fact, was equal to) the roll state point. #### Possible solutions (note that these are not mutually exclusive) 1. Make the call to `fhSwitchFork` with arguments aware of the tentative header. 2. Don't call `fhSwitchFork` when selecting our tentative header. 3. Don't call `fhSwitchFork` when extending our chain. We went with the third, as it stresses that `fhSwitchFork` is only necessary when actually switching to a fork, and it is most straightforward to implement. 3742: ChainSync client test: model pipelining behavior r=amesgen a=amesgen Closes [CAD-4192](https://input-output.atlassian.net/browse/CAD-4192) Co-authored-by: Alexander Esgen <[email protected]>
Build failed (retrying...): |
Closes CAD-4192