Transaction: Skip balance & nonce updates option in `runComputation`
Add another flag to disable a processing step when a call doesn't come from a real transaction: - `noTransfer`: Don't update balances, nonces, code. This is to support VM fixtures tests which require account balances and nonces to be unchanged when running the account's code. These tests call `c.executeOpcodes()`, an internal function of the EVM, instead of the usual `c.execComputation()`. It goes direct to the bytecode dispatcher, skipping parts of `Computation` that are normally called. But we can't keep calling `c.executeOpcodes()` and have a single entry point to the VM, let alone an EVMC entry point. `noTransfer` provides similar enough behaviour to calling `c.executeOpcodes()` that these tests can use the new single entry point like everything else. Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
parent
deffa20b07
commit
5fb3c51e5e
|
@ -31,6 +31,7 @@ type
|
|||
noAccessList*: bool # Don't initialise EIP-2929 access list.
|
||||
noGasCharge*: bool # Don't charge sender account for gas.
|
||||
noRefund*: bool # Don't apply gas refund/burn rule.
|
||||
noTransfer*: bool # Don't update balances, nonces, code.
|
||||
|
||||
# Standard call result. (Some fields are beyond what EVMC can return,
|
||||
# and must only be used from tests because they will not always be set).
|
||||
|
@ -162,7 +163,14 @@ proc runComputation*(call: CallParams): CallResult =
|
|||
host.vmState.mutateStateDB:
|
||||
db.subBalance(call.sender, call.gasLimit.u256 * call.gasPrice.u256)
|
||||
|
||||
execComputation(c)
|
||||
if call.noTransfer:
|
||||
# TODO: This isn't doing `noTransfer` properly yet, just enough for
|
||||
# fixtures tests.
|
||||
executeOpcodes(c)
|
||||
doAssert c.continuation.isNil
|
||||
doAssert c.child.isNil
|
||||
else:
|
||||
execComputation(c)
|
||||
|
||||
# Calculated gas used, taking into account refund rules.
|
||||
var gasRemaining: GasInt = 0
|
||||
|
|
Loading…
Reference in New Issue