Transaction: EIP-2929 (Berlin): Initial access list
Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
parent
c6d50a0ef7
commit
76031ccbe4
|
@ -54,6 +54,22 @@ proc hostToComputationMessage(msg: EvmcMessage): Message =
|
||||||
flags: if msg.isStatic: emvcStatic else: emvcNoFlags
|
flags: if msg.isStatic: emvcStatic else: emvcNoFlags
|
||||||
)
|
)
|
||||||
|
|
||||||
|
proc initialAccessListEIP2929(call: CallParams) =
|
||||||
|
# EIP2929 initial access list.
|
||||||
|
let vmState = call.vmState
|
||||||
|
if vmState.fork < FkBerlin:
|
||||||
|
return
|
||||||
|
|
||||||
|
vmState.mutateStateDB:
|
||||||
|
db.accessList(call.sender)
|
||||||
|
# For contract creations the EVM will add the contract address to the
|
||||||
|
# access list itself, after calculating the new contract address.
|
||||||
|
if not call.isCreate:
|
||||||
|
db.accessList(call.to)
|
||||||
|
# TODO: Check this only adds the correct subset of precompiles.
|
||||||
|
for c in activePrecompiles():
|
||||||
|
db.accessList(c)
|
||||||
|
|
||||||
proc setupCall(call: CallParams, useIntrinsic: bool): TransactionHost =
|
proc setupCall(call: CallParams, useIntrinsic: bool): TransactionHost =
|
||||||
let vmState = call.vmState
|
let vmState = call.vmState
|
||||||
vmState.setupTxContext(
|
vmState.setupTxContext(
|
||||||
|
@ -100,6 +116,9 @@ proc runComputation*(call: CallParams): CallResult =
|
||||||
let host = setupCall(call, true)
|
let host = setupCall(call, true)
|
||||||
let c = host.computation
|
let c = host.computation
|
||||||
|
|
||||||
|
# Must come after `setupCall` for correct fork.
|
||||||
|
initialAccessListEIP2929(call)
|
||||||
|
|
||||||
# Charge for gas.
|
# Charge for gas.
|
||||||
host.vmState.mutateStateDB:
|
host.vmState.mutateStateDB:
|
||||||
db.subBalance(call.sender, call.gasLimit.u256 * call.gasPrice.u256)
|
db.subBalance(call.sender, call.gasLimit.u256 * call.gasPrice.u256)
|
||||||
|
|
Loading…
Reference in New Issue