You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The BALANCE Opcode must return a different balance for the origin account (a.k.a. tx signer), instead of returning the actual balance, it must return the worst case balance for this account, which is balance - (tx.gasPrice * tx.gasLimit), because the transaction is being processed, and we don't know the final the balance.
Example contract:
ORIGIN # or CALLER, once they are the same here
BALANCE
PUSH1 0x00
SSTORE
STOP
Expected Behavior:
before execute transaction: 0x47e512b02979c8b8
returned by BALANCE opcode: 0x47336ff3fab4c8b8 == balance - (gas_price * gas_limit)
after apply state changes: 0x47c014fbdbd794b8 == balance - (gas_price * gas_used)
Actual behavior:
before execute transaction: 0x47e512b02979c8b8
returned by BALANCE opcode: 0x47e512b02979c8b8
after apply state changes: 0x47c014fbdbd794b8
Workaround
Decrement the tx sender balance before execute the tx,and increment again after apply the state changes.
The text was updated successfully, but these errors were encountered:
Crate version: v0.41.0
Related: #222
While using this EVM to sync with ethereum mainnet, I've a found a sync mismatch when processing the transaction at block 165514:
https://etherscan.io/tx/0xe01fcce5f0fb0d04d253908ebadbada9308731a8bd0d1f1b37ad3af111e6a055
Issue
The BALANCE Opcode must return a different balance for the origin account (a.k.a. tx signer), instead of returning the actual balance, it must return the worst case balance for this account, which is
balance - (tx.gasPrice * tx.gasLimit)
, because the transaction is being processed, and we don't know the final the balance.Example contract:
Expected Behavior:
before execute transaction: 0x47e512b02979c8b8
returned by BALANCE opcode: 0x47336ff3fab4c8b8 ==
balance - (gas_price * gas_limit)
after apply state changes: 0x47c014fbdbd794b8 ==
balance - (gas_price * gas_used)
Actual behavior:
before execute transaction: 0x47e512b02979c8b8
returned by BALANCE opcode: 0x47e512b02979c8b8
after apply state changes: 0x47c014fbdbd794b8
Workaround
Decrement the tx sender balance before execute the tx,and increment again after apply the state changes.
The text was updated successfully, but these errors were encountered: