-
Notifications
You must be signed in to change notification settings - Fork 1
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 *uint256 reuse issue #17
Conversation
Looks like no only when zero, even if non-zero , |
I feel like this behavior is intentional in geth - I guess that it is good for performance, and it is the caller's responsibility to not reuse the object. |
Gotcha, maybe we should follow geth's convention and change all places that reuse balance to create a new value instead of clone? |
The simple fix will always return a new *uint256 in |
It’s really hard to find the root cause. I’m curious - what tool are you using to dump and diff the entire state? Is there any documentation or instruction for it? |
|
This fixes a weird issue that was found in fault proof.
The key problem is that the returned
balance
is a pointer that can be modified by callers. In most cases, thebalance
is not reused. However, in some cases thatbalances
is zero, statedb returns a cached zero uint256 (seeop-geth/core/state/statedb.go
Line 330 in e40be92
Test:
Before
1, fault proof will fail after verifying a SGT tx
2, dump the state, and find an account
0xfffffffffffffffffffffffffffffffffffffffe
has a negative balance.After
1, pass fault proof via
make verify-devnet
2,
0xfffffffffffffffffffffffffffffffffffffffe
has zero balance