-
Notifications
You must be signed in to change notification settings - Fork 477
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
Checkpoint of the world state should be moved by FCU #8143
base: master
Are you sure you want to change the base?
Conversation
Run node after changes: https://github.com/NethermindEth/nethermind/actions/runs/13071441935 |
I think it is all not needed. What is really needed is in the ForkChoiceUpdate handler move main state provider state root to the root of the new head block |
Alternative I had in mind: #8154 |
@LukaszRozmej My take on it is that the global state provider should be updated only from a single thread. Having it updated from FCU handler may result in some funky behaviors. It' better to have FCU responsible for signaling where other components ( |
Good point, but NewPayload and FCU are always under single-threaded lock. That being said, you could potentially maybe have blocks queued in block processor? Added a fix for that. |
@LukaszRozmej I see that there's a lock, but notification-way of doing it (this PR) seems to me more preferred. We don't leak the global state elsewhere, we let FCU notfity the processor and make the processor notifiable if other components would like to move the checkpoint (for some reason, like another consensus mechanism or sth). |
I think the main purpose of the checkpoint is to revert when an exception happens. So my confusion is, why the |
First. This is not the change introduced in this PR, is it? Second, my understanding is that for options that do not contain |
Because it is FCU that moves head state and not NewPayload? We probably could move state root on NewPayload if we wanted? |
I'm not saying that this PR introduce that change. I'm saying that if that logic is removed, that might solve your problem. The |
My thought is, why does it need to move at all if it is always moved at start of block processing. |
So you are saying - just don't revert and keep as is? |
I did the same with verkle, as it also had a similar problem with flat db layout. |
Can you be more clear? |
I removed the |
As far as I understand, we could ditch the final reset as @asdacap is proposing. Then, if a branch is properly processed, we leave the root as is. If it's not we reset to what has been captured before execution. The crux is that we always reset the root of the branch if it's different from the one that branch should be executed on. Having this said, removing of the reset to the checkpoint after a proper execution, seems like a good candidate for ensuring the checkpoint progression? |
This PR changes the behavior of
MergePlugin.MergeEnabled
chains so that once a given block is considered final (FCU
comes in), the checkpoint of the main block processor is moved to the last finalized state root hash. This ensures that the root hash of the world state touched by the main processor always progresses according to FCU. The global world state should not reference any ancient blocks.Before
Currently, the pair of calls
.CreateCheckpoint
&.RestoreBranch
inBlockProcessor
never moves the current state forward. The state is captured and then rolled back to with each execution of theNewPayload
. This means, that after the state is set when a node is initialized, it will be switched between an old initial hash root and the current branch hash root. You can see it in enhanced (via 54865e4) logs below. No matter how far, the checkpoint is the same and will be continuously restored to.and 8 hours earlier
After
The checkpoint that StateRoot is reset to is properly updated. See the log outputs taken in different times
vs
Changes
MergePlugin
to inform the main block processor about the checkpointBlockProcessor
so that it takes into consideration the provided checkpoint instead always falling back to the checkpoint captured at the node startupTypes of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Probably we should test
MergeEnabled
and others as wellDocumentation
Requires documentation update
Requires explanation in Release Notes