mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-11 12:54:13 +00:00
EIP-3198: add baseFee op code in nim-evm2
This commit is contained in:
parent
05e9b891f0
commit
b51fad5fa7
@ -61,6 +61,9 @@ template getDifficulty*(c: Computation): DifficultyInt =
|
||||
template getGasLimit*(c: Computation): GasInt =
|
||||
c.vmState.gasLimit
|
||||
|
||||
template getBaseFee*(c: Computation): Uint256 =
|
||||
c.vmState.baseFee
|
||||
|
||||
template getChainId*(c: Computation): uint =
|
||||
c.vmState.chaindb.config.chainId.uint
|
||||
|
||||
|
@ -507,6 +507,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
|
||||
GasLimit: fixed GasBase,
|
||||
ChainIdOp: fixed GasBase,
|
||||
SelfBalance: fixed GasLow,
|
||||
BaseFee: fixed GasBase,
|
||||
|
||||
# 50s: Stack, Memory, Storage and Flow Operations
|
||||
Pop: fixed GasBase,
|
||||
|
@ -103,8 +103,9 @@ type
|
||||
|
||||
ChainIdOp = 0x46, ## Get current chain’s EIP-155 unique identifier.
|
||||
SelfBalance = 0x47, ## Get current contract's balance.
|
||||
BaseFee = 0x48, ## Get block’s base fee. EIP-3198
|
||||
|
||||
Nop0x48, Nop0x49, Nop0x4A, Nop0x4B, Nop0x4C, Nop0x4D,
|
||||
Nop0x49, Nop0x4A, Nop0x4B, Nop0x4C, Nop0x4D,
|
||||
Nop0x4E, Nop0x4F, ## ..
|
||||
|
||||
# 50s: Stack, Memory, Storage and Flow Operations
|
||||
|
@ -68,6 +68,11 @@ const
|
||||
k.cpt.stack.push:
|
||||
k.cpt.getBalance(k.cpt.msg.contractAddress)
|
||||
|
||||
baseFeeOp: Vm2OpFn = proc (k: var Vm2Ctx) =
|
||||
## 0x48, Get the block's base fee.
|
||||
k.cpt.stack.push:
|
||||
k.cpt.getBaseFee
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Public, op exec table entries
|
||||
# ------------------------------------------------------------------------------
|
||||
@ -137,6 +142,14 @@ const
|
||||
info: "Get current contract's balance",
|
||||
exec: (prep: vm2OpIgnore,
|
||||
run: selfBalanceOp,
|
||||
post: vm2OpIgnore)),
|
||||
|
||||
(opCode: BaseFee, ## 0x48, EIP-1559 Block base fee.
|
||||
forks: Vm2OpLondonAndLater,
|
||||
name: "baseFee",
|
||||
info: "Get current block's EIP-1559 base fee",
|
||||
exec: (prep: vm2OpIgnore,
|
||||
run: baseFeeOp,
|
||||
post: vm2OpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -129,6 +129,9 @@ method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
|
||||
method gasLimit*(vmState: BaseVMState): GasInt {.base, gcsafe.} =
|
||||
vmState.blockHeader.gasLimit
|
||||
|
||||
method baseFee*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
|
||||
vmState.blockHeader.baseFee
|
||||
|
||||
when defined(geth):
|
||||
import db/geth_db
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user