chore(sequencer): avoid hashing proposal data in execution state #2044
+495
−418
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This changes the new
ExecutionState
in sequencer to not use hashed info, but rather keep the same information in an unhashed form.Background
ExecutionState
was recently introduced under time pressure to fix an issue. This PR fixes a few nitpicks in that code, as well as changing the approach to not use a fingerprint.Encoding and hashing the data does not seem necessary since the sequencer only handles a single
ExecutionState
at any given time. The maximum size of the unhashed data will be roughly the same size as a block, and so there is no concern that this will cause resource issues.Using unhashed data is significantly more performant. The results of quick benchmarking show that by avoiding encoding then hashing the data, performance for checking the execution state (calling
check_if_prepared_proposal
) improves by ~10x for empty blocks (no txs), ~50x for full blocks (1MB of txs) and ~10,000x for full blocks where the proposal data doesn't match the cached data.The changes in this PR do not change the high-level logic around handling block execution - the state machine's states retain the same meaning and transition in the same way as before. This is only changing internal implementation details of the state machine.
Changes
CachedProposal
pub(super)
Testing
Existing tests updated. No further tests required.
Changelogs
No updates required - this is essentially invisible to consumers.