mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-24 19:19:21 +00:00
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)
|
||||
return tx.gasLimit - c.gasMeter.gasRemaining
|
||||
|
||||
proc asmSetupComputation(blockNumber: Uint256, chainDB: BaseChainDB, code,
|
||||
data: seq[byte], forkOverride = none(Fork)): Computation =
|
||||
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 =
|
||||
let
|
||||
parentNumber = blockNumber - 1
|
||||
parent = chainDB.getBlockHeader(parentNumber)
|
||||
@ -192,42 +201,31 @@ proc asmSetupComputation(blockNumber: Uint256, chainDB: BaseChainDB, code,
|
||||
vmState.mutateStateDB:
|
||||
db.setCode(contractAddress, code)
|
||||
|
||||
return setupComputation(CallParams(
|
||||
let callResult = runComputation(CallParams(
|
||||
vmState: vmState,
|
||||
forkOverride: forkOverride,
|
||||
forkOverride: some(fork),
|
||||
gasPrice: tx.gasPrice,
|
||||
gasLimit: gasLimit - gasUsed,
|
||||
sender: sender,
|
||||
to: contractAddress,
|
||||
isCreate: false,
|
||||
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
|
||||
# computation doesn't return. We'll have to obtain them outside EVMC.
|
||||
result.isSuccess = c.isSuccess
|
||||
result.gasUsed = gas - c.gasMeter.gasRemaining
|
||||
result.output = c.output
|
||||
result.stack = c.stack
|
||||
result.memory = c.memory
|
||||
result.vmState = c.vmState
|
||||
result.contractAddress = c.msg.contractAddress
|
||||
result.isSuccess = not callResult.isError
|
||||
result.gasUsed = callResult.gasUsed
|
||||
result.output = callResult.output
|
||||
result.stack = callResult.stack
|
||||
result.memory = callResult.memory
|
||||
result.vmState = vmState
|
||||
result.contractAddress = contractAddress
|
||||
|
||||
type
|
||||
FixtureResult* = object
|
||||
|
Loading…
x
Reference in New Issue
Block a user