-
Notifications
You must be signed in to change notification settings - Fork 39
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(block-producer): refactor batch graph to use dependency graph #533
feat(block-producer): refactor batch graph to use dependency graph #533
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.
Looks good! Thank you! I left some comments inline - but most are minor.
if self.pending.contains(&key) { | ||
return; | ||
} |
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.
Why is it not an error to try to make a pending node into a root?
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 method is private and called from a few locations. Effectively either callers have to perform this check, or this method could enforce it. I thought it safer to do it here in one place.
More specifically, this is called when
- A pending node is promoted (so this check isn't necessary)
- A root node is processed, so we check all of its children. We would have to filter children here.
- Subgraphs are reverted, where we have to check and filter a bunch of nodes
) `BatchGraph` now uses `DependencyGraph<BatchJobId, TransactionBatch` internally. This allows us to focus test energy on a single graph type instead of replicating tests and edge cases with more specific implementations. This requires adjusting `DependencyGraph` to separate the `insert` method into `insert_pending` and `promote_pending` to support inserting a batch into the graph while still waiting on its proof.
This PR ports
BatchGraph
to useDependencyGraph
as its foundation.I implemented this by extending
DependencyGraph
to have a newpending
stage, where the node exists but does not yet have an associated value. For batches this value is its proof i.e.TransactionBatch
.Effectively nodes now have a pending state, and must be promoted by passing in a value for it. I'm not 100% happy with the naming of things. Pending, promotions, processed, committed.
This model does not quite match the
TransactionGraph
lifecycle, however this was easy to adjust by havingTransacionGraph::insert
invoke both actions.The main benefit of this is reducing the test surface.