Assembler: Rearrange logic where assembler tests call EVM

Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
Jamie Lokier 2021-05-17 10:45:32 +01:00
parent 2fe2f23e70
commit c655d59b5f
No known key found for this signature in database
GPG Key ID: CBC25C68435C30A2
1 changed files with 7 additions and 6 deletions

View File

@ -266,17 +266,21 @@ proc txCallEvm*(tx: Transaction, sender: EthAddress, vmState: BaseVMState, fork:
proc asmSetupComputation(tx: Transaction, sender: EthAddress, vmState: BaseVMState, proc asmSetupComputation(tx: Transaction, sender: EthAddress, vmState: BaseVMState,
data: seq[byte], forkOverride = none(Fork)): Computation = data: seq[byte], forkOverride = none(Fork)): Computation =
doAssert tx.isContractCreation
let gasUsed = 0 #tx.payload.intrinsicGas.GasInt + gasFees[fork][GasTXCreate] let gasUsed = 0 #tx.payload.intrinsicGas.GasInt + gasFees[fork][GasTXCreate]
# For these tests, create the new contract like `CREATE`,
# but then execute it like it's `CALL`.
doAssert tx.isContractCreation
let contractAddress = generateAddress(sender, vmState.readOnlyStateDB.getNonce(sender))
vmState.mutateStateDB:
db.setCode(contractAddress, tx.payload)
vmState.setupTxContext( vmState.setupTxContext(
origin = sender, origin = sender,
gasPrice = tx.gasPrice, gasPrice = tx.gasPrice,
forkOverride = forkOverride, forkOverride = forkOverride,
) )
let contractAddress = generateAddress(sender, tx.nonce)
let msg = Message( let msg = Message(
kind: evmcCall, kind: evmcCall,
depth: 0, depth: 0,
@ -288,9 +292,6 @@ proc asmSetupComputation(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
data: data data: data
) )
vmState.mutateStateDb:
db.setCode(contractAddress, tx.payload)
return newComputation(vmState, msg) return newComputation(vmState, msg)
proc asmSetupComputation(blockNumber: Uint256, chainDB: BaseChainDB, code, proc asmSetupComputation(blockNumber: Uint256, chainDB: BaseChainDB, code,