Assembler: Change assembler tests to go through unified EVM runner
Simplify how assembler tests are run to use `runComputation`; drop other code. Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
parent
9211a15c0a
commit
bf6569bdeb
|
@ -168,8 +168,17 @@ proc txCallEvm*(tx: Transaction, sender: EthAddress, vmState: BaseVMState, fork:
|
||||||
txRefundGas(tx, sender, c)
|
txRefundGas(tx, sender, c)
|
||||||
return tx.gasLimit - c.gasMeter.gasRemaining
|
return tx.gasLimit - c.gasMeter.gasRemaining
|
||||||
|
|
||||||
proc asmSetupComputation(blockNumber: Uint256, chainDB: BaseChainDB, code,
|
type
|
||||||
data: seq[byte], forkOverride = none(Fork)): Computation =
|
AsmResult* = object
|
||||||
|
isSuccess*: bool
|
||||||
|
gasUsed*: GasInt
|
||||||
|
output*: seq[byte]
|
||||||
|
stack*: Stack
|
||||||
|
memory*: Memory
|
||||||
|
vmState*: BaseVMState
|
||||||
|
contractAddress*: EthAddress
|
||||||
|
|
||||||
|
proc asmCallEvm*(blockNumber: Uint256, chainDB: BaseChainDB, code, data: seq[byte], fork: Fork): AsmResult =
|
||||||
let
|
let
|
||||||
parentNumber = blockNumber - 1
|
parentNumber = blockNumber - 1
|
||||||
parent = chainDB.getBlockHeader(parentNumber)
|
parent = chainDB.getBlockHeader(parentNumber)
|
||||||
|
@ -192,42 +201,31 @@ proc asmSetupComputation(blockNumber: Uint256, chainDB: BaseChainDB, code,
|
||||||
vmState.mutateStateDB:
|
vmState.mutateStateDB:
|
||||||
db.setCode(contractAddress, code)
|
db.setCode(contractAddress, code)
|
||||||
|
|
||||||
return setupComputation(CallParams(
|
let callResult = runComputation(CallParams(
|
||||||
vmState: vmState,
|
vmState: vmState,
|
||||||
forkOverride: forkOverride,
|
forkOverride: some(fork),
|
||||||
gasPrice: tx.gasPrice,
|
gasPrice: tx.gasPrice,
|
||||||
gasLimit: gasLimit - gasUsed,
|
gasLimit: gasLimit - gasUsed,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
to: contractAddress,
|
to: contractAddress,
|
||||||
isCreate: false,
|
isCreate: false,
|
||||||
value: tx.value,
|
value: tx.value,
|
||||||
input: data
|
input: data,
|
||||||
|
noIntrinsic: true, # Don't charge intrinsic gas.
|
||||||
|
noAccessList: true, # Don't initialise EIP-2929 access list.
|
||||||
|
noGasCharge: true, # Don't charge sender account for gas.
|
||||||
|
noRefund: true # Don't apply gas refund/burn rule.
|
||||||
))
|
))
|
||||||
|
|
||||||
type
|
|
||||||
AsmResult* = object
|
|
||||||
isSuccess*: bool
|
|
||||||
gasUsed*: GasInt
|
|
||||||
output*: seq[byte]
|
|
||||||
stack*: Stack
|
|
||||||
memory*: Memory
|
|
||||||
vmState*: BaseVMState
|
|
||||||
contractAddress*: EthAddress
|
|
||||||
|
|
||||||
proc asmCallEvm*(blockNumber: Uint256, chainDB: BaseChainDB, code, data: seq[byte], fork: Fork): AsmResult =
|
|
||||||
var c = asmSetupComputation(blockNumber, chainDB, code, data, some(fork))
|
|
||||||
let gas = c.gasMeter.gasRemaining
|
|
||||||
c.execComputation()
|
|
||||||
|
|
||||||
# Some of these are extra returned state, for testing, that a normal EVMC API
|
# Some of these are extra returned state, for testing, that a normal EVMC API
|
||||||
# computation doesn't return. We'll have to obtain them outside EVMC.
|
# computation doesn't return. We'll have to obtain them outside EVMC.
|
||||||
result.isSuccess = c.isSuccess
|
result.isSuccess = not callResult.isError
|
||||||
result.gasUsed = gas - c.gasMeter.gasRemaining
|
result.gasUsed = callResult.gasUsed
|
||||||
result.output = c.output
|
result.output = callResult.output
|
||||||
result.stack = c.stack
|
result.stack = callResult.stack
|
||||||
result.memory = c.memory
|
result.memory = callResult.memory
|
||||||
result.vmState = c.vmState
|
result.vmState = vmState
|
||||||
result.contractAddress = c.msg.contractAddress
|
result.contractAddress = contractAddress
|
||||||
|
|
||||||
type
|
type
|
||||||
FixtureResult* = object
|
FixtureResult* = object
|
||||||
|
|
Loading…
Reference in New Issue