fix: Parity state diff when creating SC with balance #172
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.
Problem
The inconsistent problem in analysing the Parity state difference of a transaction
which includes creating a smart contract that already has a balance.
Reproducible Example
With the latest version reth v1.0.3, using
trace_replayTransaction()
andstateDiff
to tracethe transaction
0x40926f14808e7217827e8ff9492d15d68d84edae76f71db5ab8c70a5664f4720
The state difference of the newly created smart contract
0xc2d517963c616ee780e833a5318413242a790f08
From Reth
From Etherscan and QuickNode
Reason
The smart contract 0xc2d517963c616ee780e833a5318413242a790f08 is created in Tx#1 in Block 15,305,803;
however, it received around 0.056 ETH in Tx#0 in Block 15,305,797. Therefore, it has a balance when it is created.
Solution
Additionally check whether the account has a balance or not when it is created during the transaction.