-
Notifications
You must be signed in to change notification settings - Fork 929
Fix for world state root mismatch after parallel preprocessing with zero block reward #8353
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
Fix for world state root mismatch after parallel preprocessing with zero block reward #8353
Conversation
…ero block reward Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
will take a look thanks |
Thans for that it's really a good catch and I think it can clearly explain some issues I noticed that the call to the constructor of ParallelTransactionPreprocessing was moved to the constructor of MainnetParallelBlockProcessor. This change creates the instance only once when the node starts for each specific fork, rather than per block. Why I created a new one for each block before it"s because of the This map is saving the result of each background transaction execution of the block but if you have the same instance for each block you can have some transaction execution for the block before and it can create inconsistency For example, consider block 5 with transactions tx0, tx1, and tx2:
It is an important modification ?
It will be nice to manage it if we want to do a fullsync or if we have a configuration that take care of that. |
…utor in ParallelTransactionPreprocessing, simplify Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
…ionProcessor Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
@matkt Good point regarding |
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
…ockProcessor Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
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 haven't finished the review, as I need to double check some GC overhead.
...c/test/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessorIntegrationTest.java
Outdated
Show resolved
Hide resolved
...ava/org/hyperledger/besu/ethereum/mainnet/parallelization/MainnetParallelBlockProcessor.java
Outdated
Show resolved
Hide resolved
…ckProcessingConsistency to testProcessBlockZeroReward Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
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.
LGTM 🚀 , @matkt could you take a last look on your side ?
This PR fixes a bug in the implementation of the parallel block processor, leading to frequent world state root mismatches during block persistence, similar to #7844.
When the block reward is zero and the mining beneficiary account doesn't exist yet, if the parallel preprocessing finishes in time to be applied, the resulting world state differs from the one produced by the sequential transaction processing, because, during application of the transaction processing result, parallel transaction processor creates the mining beneficiary address, whereas plain sequential processing, at least with
clearEmptyAccounts
on, does not, leading to mismatch between world states computed during block creation and parallelized block processing.This PR also contains an integration test covering this scenario. The test fails without the fix and passes with it.
A complete fix would probably account for the value of
clearEmptyAccounts
in parallel transaction processor, but this flag seems to be in place for legacy purposes, so I am not sure it is worth further code change.It is quite possible that this is not the only discrepancy between parallel and sequential processing leading to world state root mismatches.
This PR has been contributed on behalf of Absa Group Ltd.