mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 13:24:21 +00:00
EIP-3198: add baseFee op code in nim-evm
This commit is contained in:
parent
1cdb30df90
commit
05e9b891f0
@ -63,6 +63,7 @@ proc setupTxContext(host: TransactionHost) =
|
||||
# vmState.difficulty now unused
|
||||
host.txContext.block_difficulty = vmState.blockHeader.difficulty.toEvmc
|
||||
host.txContext.chain_id = vmState.chaindb.config.chainId.uint.u256.toEvmc
|
||||
host.txContext.block_base_fee = vmState.blockHeader.baseFee.toEvmc
|
||||
|
||||
const use_evmc_glue = defined(evmc_enabled)
|
||||
|
||||
|
@ -57,6 +57,12 @@ template getGasLimit*(c: Computation): GasInt =
|
||||
else:
|
||||
c.vmState.gasLimit
|
||||
|
||||
template getBaseFee*(c: Computation): Uint256 =
|
||||
when evmc_enabled:
|
||||
Uint256.fromEvmc c.host.getTxContext().block_base_fee
|
||||
else:
|
||||
c.vmState.baseFee
|
||||
|
||||
template getChainId*(c: Computation): uint =
|
||||
when evmc_enabled:
|
||||
Uint256.fromEvmc(c.host.getTxContext().chain_id).truncate(uint)
|
||||
|
@ -537,6 +537,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,
|
||||
|
@ -81,6 +81,7 @@ fill_enum_holes:
|
||||
|
||||
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
|
||||
|
||||
# 50s: Stack, Memory, Storage and Flow Operations
|
||||
Pop = 0x50, # Remove item from stack.
|
||||
|
@ -384,6 +384,10 @@ op gasLimit, inline = true:
|
||||
## 0x45, Get the block's gas limit
|
||||
push: c.getGasLimit()
|
||||
|
||||
op baseFee, inline = true:
|
||||
## 0x45, Get the block's gas limit
|
||||
push: c.getBaseFee()
|
||||
|
||||
op chainId, inline = true:
|
||||
## 0x46, Get current chain’s EIP-155 unique identifier.
|
||||
push: c.getChainId()
|
||||
|
@ -251,6 +251,7 @@ let BerlinOpDispatch {.compileTime.}: array[Op, NimNode] = genBerlinJumpTable(Is
|
||||
proc genLondonJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.compileTime.} =
|
||||
result = ops
|
||||
# incoming EIP-3198 and EIP-3529
|
||||
result[BaseFee] = newIdentNode "baseFee"
|
||||
|
||||
let LondonOpDispatch {.compileTime.}: array[Op, NimNode] = genLondonJumpTable(BerlinOpDispatch)
|
||||
|
||||
|
@ -141,6 +141,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