mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 05:14:14 +00:00
EIP-2930: optional access list
the new AccessListTx contains address and storage keys that will go into global access list. and this come with prices.... in ether
This commit is contained in:
parent
a2712c5c7a
commit
01a27ff328
@ -45,7 +45,7 @@ func intrinsicGas*(data: openarray[byte], fork: Fork): GasInt =
|
||||
else:
|
||||
result += gasFees[fork][GasTXDataNonZero]
|
||||
|
||||
proc intrinsicGas*(tx: TxTypes, fork: Fork): GasInt =
|
||||
proc intrinsicGas*(tx: LegacyTx, fork: Fork): GasInt =
|
||||
# Compute the baseline gas cost for this transaction. This is the amount
|
||||
# of gas needed to send this transaction (but that is not actually used
|
||||
# for computation)
|
||||
@ -54,6 +54,25 @@ proc intrinsicGas*(tx: TxTypes, fork: Fork): GasInt =
|
||||
if tx.isContractCreation:
|
||||
result = result + gasFees[fork][GasTXCreate]
|
||||
|
||||
proc intrinsicGas*(tx: AccessListTx, fork: Fork): GasInt =
|
||||
const
|
||||
ADDRESS_COST = 2400
|
||||
STORAGE_KEY_COST = 1900
|
||||
|
||||
# Compute the baseline gas cost for this transaction. This is the amount
|
||||
# of gas needed to send this transaction (but that is not actually used
|
||||
# for computation)
|
||||
result = tx.payload.intrinsicGas(fork)
|
||||
|
||||
result = result + tx.accessList.len * ADDRESS_COST
|
||||
var numKeys = 0
|
||||
for n in tx.accessList:
|
||||
inc(numKeys, n.storageKeys.len)
|
||||
|
||||
result = result + numKeys * STORAGE_KEY_COST
|
||||
if tx.isContractCreation:
|
||||
result = result + gasFees[fork][GasTXCreate]
|
||||
|
||||
proc intrinsicGas*(tx: Transaction, fork: Fork): GasInt =
|
||||
txc(intrinsicGas, fork)
|
||||
|
||||
|
@ -191,6 +191,13 @@ proc txInitialAccessListEIP2929(tx: Transaction, sender: EthAddress, vmState: Ba
|
||||
for c in activePrecompiles():
|
||||
db.accessList(c)
|
||||
|
||||
# EIP2930 optional access list
|
||||
if tx.txType == AccessListTxType:
|
||||
for n in tx.accessListTx.accessList:
|
||||
db.accessList(n.address)
|
||||
for x in n.storageKeys:
|
||||
db.accessList(n.address, UInt256.fromBytesBE(x))
|
||||
|
||||
proc txCallEvm*(tx: Transaction, sender: EthAddress, vmState: BaseVMState, fork: Fork): GasInt =
|
||||
txInitialAccessListEIP2929(tx, sender, vmState, fork)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user