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

feat(sync): add BufferStage #2066

Closed
wants to merge 4 commits into from
Closed

Conversation

Mirko-von-Leipzig
Copy link
Contributor

This PR adds the BufferStage trait to the sync stages framework.

This trait and its associated SyncReceiver::buffer method abstracts over the common pattern of taking a p2p element stream and transforming it into a stream of block data.

The abstraction is not entirely perfect; but I think this will help simplify things.

As a demonstration I've implemented this (somewhat hackily) for the transaction checkpoint sync (without connecting it to anything yet). For tracking sync, we would implement something similar that simply receives these counts from the header fanout.

Transaction source from p2p then becomes a normal transaction stream, which is then connected to one the above stages.

@Mirko-von-Leipzig Mirko-von-Leipzig requested a review from a team as a code owner June 10, 2024 09:32
@Mirko-von-Leipzig
Copy link
Contributor Author

This also doesn't really account for something weird like StateDiff counting - though I think one can handle this with an additional method in the trait.

@sistemd
Copy link
Contributor

sistemd commented Jun 10, 2024

It remains to be seen how well this will fit with all of the use cases, but looks promising 👍

Mirko-von-Leipzig and others added 4 commits June 10, 2024 16:07
Abstracts over the common scenario of buffering a stream of items
into a stream of blocks.
This stage is used to split a stream of transactions into a stream
of block's of transactions.
Remove BufferStage::T since it wasn't linked to usage directly.
Reword BufferStage::Meta -> AdditionalData

Co-authored-by: Nikša Sporin <niksa@equilibrium.co>
@Mirko-von-Leipzig
Copy link
Contributor Author

Sounded great; has a pretty fatal flaw in practice.

A source cannot be separate from the process of transforming the input item stream into a stream of block data (which is what BufferStage was doing).

As it stands, if the origin p2p stream fails, or ends early there is no way for the source to know at which block number it should re-attempt from - only the buffer stage knows how many blocks of data were actually processed.

This implies that the source stream and the transformation stage should instead be a single unified system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants