fix(geth_state_diffs): use pre value as to_value when post is absent#251
Open
AuburyEssentian wants to merge 1 commit intoparadigmxyz:mainfrom
Open
fix(geth_state_diffs): use pre value as to_value when post is absent#251AuburyEssentian wants to merge 1 commit intoparadigmxyz:mainfrom
AuburyEssentian wants to merge 1 commit intoparadigmxyz:mainfrom
Conversation
The geth prestate tracer only records post-state when a value actually changes. When post is None but pre is Some, the value was accessed but not modified — so to_value should equal from_value (pre), not zero. The current code passes U256::ZERO / 0u64 / Bytes::new() as the default for the (Some(pre), None) arm, producing incorrect to_value output for balances, nonces, and code when the geth trace omits post. Fix both affected sites: - parse_pre_post(): used by add_balances and add_nonces - add_codes(): has its own inline match with the same pattern Storage diffs use a separate BTreeMap-based approach and are unaffected. Fixes paradigmxyz#245.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Closes #245.
The geth prestate tracer only writes a
postentry when a value actually changes. WhenpostisNoneandpreisSome, the value was accessed but not modified —to_valueshould equalfrom_value(pre).The current code returns a zero default in this case (
U256::ZEROfor balance,0u64for nonce,Bytes::new()for code), so any touched-but-unchanged account produces a diff record claiming the value dropped to zero. This is reproducible with block 16983180 as described in the issue.Root cause
Two code sites share the same pattern:
parse_pre_post()(used byadd_balancesandadd_nonces):add_codes()(inline match):Fix
Return
(pre, pre)in both(Some(pre), None)arms so an unchanged value is correctly reflected as from == to.Storage diffs use a separate
BTreeMap-based approach and are unaffected (as noted in the issue).