mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 13:24:21 +00:00
Transaction: Change tx validation to use shared setupComputation
Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
parent
45da426bb8
commit
0d3117344a
@ -212,26 +212,17 @@ proc rpcEstimateGas*(call: RpcCallData, header: BlockHeader, chain: BaseChainDB,
|
|||||||
proc txSetupComputation(tx: Transaction, sender: EthAddress, vmState: BaseVMState, fork: Fork): Computation =
|
proc txSetupComputation(tx: Transaction, sender: EthAddress, vmState: BaseVMState, fork: Fork): Computation =
|
||||||
var gas = tx.gasLimit - tx.intrinsicGas(fork)
|
var gas = tx.gasLimit - tx.intrinsicGas(fork)
|
||||||
assert gas >= 0
|
assert gas >= 0
|
||||||
|
return setupComputation(CallParams(
|
||||||
vmState.setupTxContext(
|
vmState: vmState,
|
||||||
origin = sender,
|
forkOverride: some(fork),
|
||||||
gasPrice = tx.gasPrice,
|
gasPrice: tx.gasPrice,
|
||||||
forkOverride = some(fork)
|
gasLimit: gas,
|
||||||
)
|
|
||||||
|
|
||||||
let msg = Message(
|
|
||||||
kind: if tx.isContractCreation: evmcCreate else: evmcCall,
|
|
||||||
depth: 0,
|
|
||||||
gas: gas,
|
|
||||||
sender: sender,
|
sender: sender,
|
||||||
contractAddress: tx.to,
|
to: tx.to,
|
||||||
codeAddress: tx.to,
|
isCreate: tx.isContractCreation,
|
||||||
value: tx.value,
|
value: tx.value,
|
||||||
data: tx.payload
|
input: tx.payload
|
||||||
)
|
))
|
||||||
|
|
||||||
result = newComputation(vmState, msg)
|
|
||||||
doAssert result.isOriginComputation
|
|
||||||
|
|
||||||
proc txRefundgas(tx: Transaction, sender: EthAddress, c: Computation) =
|
proc txRefundgas(tx: Transaction, sender: EthAddress, c: Computation) =
|
||||||
let maxRefund = (tx.gasLimit - c.gasMeter.gasRemaining) div 2
|
let maxRefund = (tx.gasLimit - c.gasMeter.gasRemaining) div 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user