-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(flashblocks): Add async state root calculation and pre-warming flashblocks sequence execution to local execution cache #20566
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
base: main
Are you sure you want to change the base?
Conversation
mattsse
left a comment
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.
I'm a bit sceptical that this is always useful, because this can delay the latest flashblock for SR computation making it not available for rpc as fast as possible
at the very least I'd like to see some timings for base for this
also curious what @0x00101010 thinks here
| /// Message to insert a locally built executed block into the engine state tree. | ||
| InsertExecutedBlock { | ||
| /// The executed block to insert. | ||
| block: ExecutedBlock<<Payload::BuiltPayload as BuiltPayload>::Primitives>, | ||
| }, |
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.
hmm, a bit unsure about exposing this because this assumes the block is fully valid
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.
I see where youre coming from, I am unsure of an alternative safer approach to this - I have instead renamed this better to FlashblocksSequence instead so that we explicitly know this message is handled entirely only for flashblocks rpc layer (d35f59b).
| let expected_final_flashblock = block_time_ms / FLASHBLOCK_BLOCK_TIME; | ||
| let compute_state_root = self.compute_state_root && | ||
| last_flashblock.diff.state_root.is_zero() && | ||
| let compute_state_root = last_flashblock.diff.state_root.is_zero() && |
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 will now always compute the state root?
dont think this is what we want here?
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.
The state root calculation has since been switched to async in this PR, which allows us to quickly update the pending state after flashblock payload execution.
|
@mattsse makes sense. Actually this was on a todo for me but I thought it was better to split adding that into a separate PR - but I think we could resolve this by spawning an asnyc task to calculate state root after updating the pending FB state. This doesnt affect FB consensus though, since state root calculation happens by default on target FB number. |
|
@mattsse let me see how I can optimize this. Also theres a failing UT so I'll fix that too 👍 |
|
@mattsse @0x00101010 The PR has been updated to include async state root calcuations. The sync logic is now split into 2 parts on new flashblock payload:
|


Summary
This PR references the flashblocks RPC solution 1 mentioned in: #20491. It optimizes the sync for flashblocks RPC by inserting the executed flashblocks sequence to the engine state tree, to prevent re-execution and re-calculating of state root of the same payload on engine_newPayload engine api. This should optimize the RPC sync speed and improve latencies on the RPC node.
--flashblocks.consensusturned off), which this PR optimizes the sync speed of the CL sync as unsafe payload commits on the CL will skip payload re-validation on cache hits, which the flashblocks RPC has already executed and validated the sequence as the current pending block--flashblocks.consensusenabled, this optimizes the RPC node sync with the flashblocks builder source, as we cache hit locally executed blocks prevent re-execution of the same payload on the flashblocks RPC node