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

Block diffusion pipelining #3688

Merged
merged 13 commits into from
Apr 20, 2022
Merged

Conversation

nfrisby
Copy link
Contributor

@nfrisby nfrisby commented Apr 4, 2022

This PR adds block diffusion pipelining, primarily by finally introducing the long-existing concept of the tentative chain into the code.

Main changes:

  • add the tentative chain header to the ChainDB state.

  • have the Followers for the Node-To-Node ChainSync server follow the tentative chain instead of only the selected chain, thus sending the tentative header before the underlying block has been validated

  • this now means some honest nodes will send us an invalid block, when the block is tentative, so we adjust ChainSync and BlockFetch clients to allow that in limited number of scenarios necessary for the common pipelining scenarios

@nfrisby nfrisby added the consensus issues related to ouroboros-consensus label Apr 4, 2022
@nfrisby nfrisby requested review from dcoutts and amesgen April 4, 2022 13:38
@nfrisby nfrisby force-pushed the feature/CAD-4011-pipelining-via-tentative branch from 63b8012 to 4cc618f Compare April 4, 2022 13:48
@nfrisby
Copy link
Contributor Author

nfrisby commented Apr 4, 2022

Esgen thinks the CI failure on 4cc618f is spurious. He's going to write an explanation here soon.

I'm going to rerun Hydra right now -- this comment is just a placemarker since the CI failure he will reference is likely to no longer be apparent.

@amesgen
Copy link
Member

amesgen commented Apr 4, 2022

Esgen thinks the CI failure on 4cc618f is spurious. He's going to write an explanation here soon.

See #3689 (which reproduces the issue on current master).

Copy link
Member

@amesgen amesgen left a comment

Choose a reason for hiding this comment

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

The GH Windows failure is unrelated (see #3678), (EDIT: now fixed) so LGTM from my side 🎉

@nfrisby nfrisby force-pushed the feature/CAD-4011-pipelining-via-tentative branch from 4cc618f to bb78cfc Compare April 5, 2022 18:50
@nfrisby
Copy link
Contributor Author

nfrisby commented Apr 11, 2022

Status update: the first benchmarking run showed that we're not actually pipelining. We believe we've fixed it and are now awaiting a second benchmarking run. We'll be pushing those commits here soon.

@amesgen amesgen force-pushed the feature/CAD-4011-pipelining-via-tentative branch from 9da1886 to 34086e3 Compare April 12, 2022 17:16
@nfrisby
Copy link
Contributor Author

nfrisby commented Apr 12, 2022

An (optional) idea: split 4fa8cda into a commit that just undoes/reverts changes and a second commit that adds the new behavior.

@nfrisby
Copy link
Contributor Author

nfrisby commented Apr 12, 2022

Minor: 4fa8cda has some extra layer of do in the clearTentativeHeader definition. I'm guessing the tracer commit puts that to use, but it looks a little odd isolated in the previous commit

@amesgen
Copy link
Member

amesgen commented Apr 12, 2022

An (optional) idea: split 4fa8cda into a commit that just undoes/reverts changes and a second commit that adds the new behavior.

I can do that if it is helpful for reviewing 👍. In the end, we want to squash 4fa8cda into aa43e5d, so it won't matter there.

Minor: 4fa8cda has some extra layer of do in the clearTentativeHeader definition. I'm guessing the tracer commit puts that to use, but it looks a little odd isolated in the previous commit

Ah yes, that happend while I swapped the two commits (such that the squashing becomes trivial), will change that (EDIT: done).

@amesgen amesgen force-pushed the feature/CAD-4011-pipelining-via-tentative branch 3 times, most recently from 8dae7a9 to a50c3f5 Compare April 19, 2022 08:34
@nfrisby nfrisby force-pushed the feature/CAD-4011-pipelining-via-tentative branch from d5af480 to 60f0771 Compare April 19, 2022 19:18
Copy link
Contributor Author

@nfrisby nfrisby left a comment

Choose a reason for hiding this comment

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

I rebased onto origin/master and did one last pass. I found a tvar with a Maybe and a stale comment.

@amesgen would you fix that (preferably squash the fix) and then merge?

@nfrisby nfrisby force-pushed the feature/CAD-4011-pipelining-via-tentative branch from 60f0771 to 20df233 Compare April 19, 2022 19:45
@amesgen amesgen force-pushed the feature/CAD-4011-pipelining-via-tentative branch from 20df233 to fef1c47 Compare April 20, 2022 08:32
nfrisby and others added 6 commits April 20, 2022 13:49
…l duplex connections

Also, bump the default max version to V_8, to include pipelining.
We want to store the `SelectView` of the last invalid tentative header
in an `StrictTVar`.
Disconnect if either the block itself is invalid or one of the blocks on its
prefix is.
nfrisby and others added 7 commits April 20, 2022 13:49
The idea is to change the instruction-emitting parts of the `Follower`
abstraction to be aware of the tentative chain. Concretely, we now use
`getCurrentChainByType` instead of `readTVar cdbChain` in two
occasions:

  1. When we are rolling forward from an in-memory point, which is the
     most relevant case for pipelining (as pipelining is only relevant
     when the follower is at the tip of our chain).

     This change is crucial: If we erroneously would use the selected
     chain in a tentative follower, rolling forward from the tentative
     point would result in us jumping back to the immutable DB as the
     tentative header is never part of the selected chain, which would
     then trigger an error as the tentative header is never in the
     immutable DB.

  2. When rolling forward from a point in the immutable DB, when we
     are about to switch to the in-memory fragment. In most cases, the
     choice will be irrelevant here, except for this rare
     scenario (data loss in the VolDB): `cdbChain` could be empty, and
     the tentative header could be set, in which case we can roll
     forward tentative followers which are at the tip of the immutable
     DB.

We leave follower forwarding (triggered via `MsgFindInteresct`)
untouched as pipelining is only concerned with up-to-date peers.
@nfrisby nfrisby force-pushed the feature/CAD-4011-pipelining-via-tentative branch from fef1c47 to e140bb4 Compare April 20, 2022 20:49
@nfrisby
Copy link
Contributor Author

nfrisby commented Apr 20, 2022

bors merge

@nfrisby
Copy link
Contributor Author

nfrisby commented Apr 20, 2022

Thank @amesgen for preparing this one with me! The benchmarking results show improvement, so we're good to merge. We still have some room for improvement in the benchmarks and new tests, but this PR is a solid first step.

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Apr 20, 2022

@iohk-bors iohk-bors bot merged commit 1f6433d into master Apr 20, 2022
@iohk-bors iohk-bors bot deleted the feature/CAD-4011-pipelining-via-tentative branch April 20, 2022 22:42
coot pushed a commit that referenced this pull request May 16, 2022
3688: Block diffusion pipelining r=nfrisby a=nfrisby

This PR adds block diffusion pipelining, primarily by finally introducing the long-existing concept of _the tentative chain_ into the code.

Main changes:

- add the tentative chain header to the ChainDB state.

- have the `Follower`s for the Node-To-Node ChainSync server follow the tentative chain instead of only the selected chain, thus sending the tentative header before the underlying block has been validated

- this now means some honest nodes will send us an invalid block, when the block is tentative, so we adjust ChainSync and BlockFetch clients to allow that in limited number of scenarios necessary for the common pipelining scenarios

Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
Co-authored-by: Alexander Esgen <alexander.esgen@iohk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants