fix: merge state diffs when overriding accounts, improve eth_call tests #153
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.
This PR fixes a bug affecting
eth_callandeth_simulateV1that caused incorrect state overrides to happen when the same address had distinct storage slots modified intra-block but across flashblock boundariese.g. consider a contract with two storage slots -
AandB. Initially, sayA= 1 andB= 1Flashblock 1:
A= 2Flashblock 2:
B= 2The way the old logic worked, due to a misunderstanding of how Reth applies state diff overrides, setting an
AccountOverrideforB = 2in the pending state would actually cause us to lose the account override forA = 2Therefore, an
eth_calloreth_simulateV1that depended on reading the value ofAwould end up returning an incorrect valueThis was never caught in our tests for two reasons:
Countercontract test had only a single storage slot that could be modified, so we never tested behaviour across multiple storage slotsCountercontract's storage was also initialized to0at the beginning, so we couldn't differentiate between an "initial result" vs. a "this got reset" resultThis PR does two things:
Countercontract tests with aDoubleCounter. It has two storage slots -count1andcount2that can both be incremented and tested separately. It also initializes those values to1instead of default0- so a 0 result at any point is an error caused due to a state reset somewhere.This is partially related to #151. @steph-rs is continuing to work on an even more comprehensive test setup with ERC-20 contract tests.