2022-01-18 14:40:02 +00:00
|
|
|
# Nimbus
|
2024-02-16 09:08:07 +00:00
|
|
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
2022-01-18 14:40:02 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2024-06-07 21:39:58 +00:00
|
|
|
{.push raises: [].}
|
|
|
|
|
2022-01-18 14:40:02 +00:00
|
|
|
## Transaction Pool Block Chain Packer Environment
|
|
|
|
## ===============================================
|
|
|
|
##
|
|
|
|
|
|
|
|
import
|
2024-06-07 21:39:58 +00:00
|
|
|
results,
|
2022-12-02 04:35:41 +00:00
|
|
|
../../common/common,
|
2022-01-18 14:40:02 +00:00
|
|
|
../../constants,
|
2023-12-12 19:12:56 +00:00
|
|
|
../../db/ledger,
|
2022-12-02 04:35:41 +00:00
|
|
|
../../utils/utils,
|
2024-06-17 07:56:39 +00:00
|
|
|
../../evm/state,
|
|
|
|
../../evm/types,
|
2024-04-24 00:50:50 +00:00
|
|
|
../eip4844,
|
2022-12-06 05:55:40 +00:00
|
|
|
../pow/difficulty,
|
|
|
|
../executor,
|
|
|
|
../casper,
|
2022-01-18 14:40:02 +00:00
|
|
|
./tx_chain/[tx_basefee, tx_gaslimits],
|
2022-12-02 04:35:41 +00:00
|
|
|
./tx_item
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
export
|
|
|
|
TxChainGasLimits,
|
|
|
|
TxChainGasLimitsPc
|
|
|
|
|
|
|
|
const
|
|
|
|
TRG_THRESHOLD_PER_CENT = ##\
|
|
|
|
## VM executor may stop if this per centage of `trgLimit` has
|
|
|
|
## been reached.
|
|
|
|
90
|
|
|
|
|
|
|
|
MAX_THRESHOLD_PER_CENT = ##\
|
|
|
|
## VM executor may stop if this per centage of `maxLimit` has
|
|
|
|
## been reached.
|
|
|
|
90
|
|
|
|
|
|
|
|
type
|
|
|
|
TxChainPackerEnv = tuple
|
|
|
|
vmState: BaseVMState ## current tx/packer environment
|
|
|
|
receipts: seq[Receipt] ## `vmState.receipts` after packing
|
2022-04-08 04:54:11 +00:00
|
|
|
reward: UInt256 ## Miner balance difference after packing
|
|
|
|
profit: UInt256 ## Net reward (w/o PoW specific block rewards)
|
2022-01-18 14:40:02 +00:00
|
|
|
txRoot: Hash256 ## `rootHash` after packing
|
|
|
|
stateRoot: Hash256 ## `stateRoot` after packing
|
2023-08-04 12:43:30 +00:00
|
|
|
blobGasUsed:
|
2024-06-14 07:31:08 +00:00
|
|
|
Opt[uint64] ## EIP-4844 block blobGasUsed
|
2023-08-04 12:43:30 +00:00
|
|
|
excessBlobGas:
|
2024-06-14 07:31:08 +00:00
|
|
|
Opt[uint64] ## EIP-4844 block excessBlobGas
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
TxChainRef* = ref object ##\
|
|
|
|
## State cache of the transaction environment for creating a new\
|
|
|
|
## block. This state is typically synchrionised with the canonical\
|
|
|
|
## block chain head when updated.
|
2022-12-02 04:35:41 +00:00
|
|
|
com: CommonRef ## Block chain config
|
2022-01-18 14:40:02 +00:00
|
|
|
lhwm: TxChainGasLimitsPc ## Hwm/lwm gas limit percentage
|
|
|
|
|
|
|
|
maxMode: bool ## target or maximal limit for next block header
|
|
|
|
roAcc: ReadOnlyStateDB ## Accounts cache fixed on current sync header
|
|
|
|
limits: TxChainGasLimits ## Gas limits for packer and next header
|
|
|
|
txEnv: TxChainPackerEnv ## Assorted parameters, tx packer environment
|
2022-12-06 05:55:40 +00:00
|
|
|
prepHeader: BlockHeader ## Prepared Header from Consensus Engine
|
2022-06-14 06:01:51 +00:00
|
|
|
|
2022-01-18 14:40:02 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Private functions
|
|
|
|
# ------------------------------------------------------------------------------
|
2024-05-28 18:26:51 +00:00
|
|
|
func prepareHeader(dh: TxChainRef; parent: BlockHeader, timestamp: EthTime)
|
|
|
|
{.raises: [].} =
|
|
|
|
dh.com.pos.prepare(dh.prepHeader)
|
|
|
|
|
|
|
|
func prepareForSeal(dh: TxChainRef; header: var BlockHeader) {.raises: [].} =
|
|
|
|
dh.com.pos.prepareForSeal(header)
|
|
|
|
|
|
|
|
func getTimestamp(dh: TxChainRef, parent: BlockHeader): EthTime =
|
|
|
|
dh.com.pos.timestamp
|
|
|
|
|
|
|
|
func feeRecipient*(dh: TxChainRef): EthAddress
|
2023-07-02 12:23:01 +00:00
|
|
|
|
2024-06-14 07:31:08 +00:00
|
|
|
proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; baseFeePerGas: Opt[UInt256])
|
2024-05-28 18:26:51 +00:00
|
|
|
{.gcsafe,raises: [].} =
|
2022-01-18 14:40:02 +00:00
|
|
|
dh.txEnv.reset
|
|
|
|
|
2022-12-05 11:25:44 +00:00
|
|
|
# do hardfork transition before
|
|
|
|
# BaseVMState querying any hardfork/consensus from CommonRef
|
2023-05-23 05:25:42 +00:00
|
|
|
|
|
|
|
let timestamp = dh.getTimestamp(parent)
|
2024-06-07 21:39:58 +00:00
|
|
|
dh.com.hardForkTransition(
|
2024-06-14 07:31:08 +00:00
|
|
|
parent.blockHash, parent.number+1, Opt.some(timestamp))
|
2023-05-23 05:25:42 +00:00
|
|
|
dh.prepareHeader(parent, timestamp)
|
2022-12-05 11:25:44 +00:00
|
|
|
|
2022-06-14 06:01:51 +00:00
|
|
|
# we don't consider PoS difficulty here
|
|
|
|
# because that is handled in vmState
|
2023-09-24 15:25:41 +00:00
|
|
|
let blockCtx = BlockContext(
|
2024-04-24 00:50:50 +00:00
|
|
|
timestamp : dh.prepHeader.timestamp,
|
|
|
|
gasLimit : (if dh.maxMode: dh.limits.maxLimit else: dh.limits.trgLimit),
|
2024-06-14 07:31:08 +00:00
|
|
|
baseFeePerGas: baseFeePerGas,
|
2024-04-24 00:50:50 +00:00
|
|
|
prevRandao : dh.prepHeader.prevRandao,
|
|
|
|
difficulty : dh.prepHeader.difficulty,
|
|
|
|
coinbase : dh.feeRecipient,
|
|
|
|
excessBlobGas: calcExcessBlobGas(parent),
|
2023-09-24 15:25:41 +00:00
|
|
|
)
|
|
|
|
|
2022-01-18 14:40:02 +00:00
|
|
|
dh.txEnv.vmState = BaseVMState.new(
|
2023-09-24 15:25:41 +00:00
|
|
|
parent = parent,
|
|
|
|
blockCtx = blockCtx,
|
|
|
|
com = dh.com)
|
2022-01-18 14:40:02 +00:00
|
|
|
|
2022-09-03 18:15:35 +00:00
|
|
|
dh.txEnv.txRoot = EMPTY_ROOT_HASH
|
2022-01-18 14:40:02 +00:00
|
|
|
dh.txEnv.stateRoot = dh.txEnv.vmState.parent.stateRoot
|
2024-06-14 07:31:08 +00:00
|
|
|
dh.txEnv.blobGasUsed = Opt.none(uint64)
|
|
|
|
dh.txEnv.excessBlobGas = Opt.none(uint64)
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
proc update(dh: TxChainRef; parent: BlockHeader)
|
2024-05-28 18:26:51 +00:00
|
|
|
{.gcsafe,raises: [].} =
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
let
|
2022-12-02 04:35:41 +00:00
|
|
|
db = dh.com.db
|
2024-05-29 11:06:49 +00:00
|
|
|
acc = LedgerRef.init(db, parent.stateRoot)
|
2024-06-27 05:54:36 +00:00
|
|
|
fee = baseFeeGet(dh.com, parent)
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
# Keep a separate accounts descriptor positioned at the sync point
|
|
|
|
dh.roAcc = ReadOnlyStateDB(acc)
|
|
|
|
|
2022-12-02 04:35:41 +00:00
|
|
|
dh.limits = dh.com.gasLimitsGet(parent, dh.lhwm)
|
2022-01-18 14:40:02 +00:00
|
|
|
dh.resetTxEnv(parent, fee)
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public functions, constructor
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
proc new*(T: type TxChainRef; com: CommonRef): T
|
|
|
|
{.gcsafe, raises: [EVMError].} =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Constructor
|
|
|
|
new result
|
|
|
|
|
2022-12-02 04:35:41 +00:00
|
|
|
result.com = com
|
2022-01-18 14:40:02 +00:00
|
|
|
result.lhwm.lwmTrg = TRG_THRESHOLD_PER_CENT
|
|
|
|
result.lhwm.hwmMax = MAX_THRESHOLD_PER_CENT
|
2022-08-29 09:54:59 +00:00
|
|
|
result.lhwm.gasFloor = DEFAULT_GAS_LIMIT
|
|
|
|
result.lhwm.gasCeil = DEFAULT_GAS_LIMIT
|
2022-12-02 04:35:41 +00:00
|
|
|
result.update(com.db.getCanonicalHead)
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public functions
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2023-01-30 22:10:23 +00:00
|
|
|
proc getBalance*(dh: TxChainRef; account: EthAddress): UInt256 =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Wrapper around `vmState.readOnlyStateDB.getBalance()` for a `vmState`
|
|
|
|
## descriptor positioned at the `dh.head`. This might differ from the
|
|
|
|
## `dh.vmState.readOnlyStateDB.getBalance()` which returnes the current
|
|
|
|
## balance relative to what has been accumulated by the current packing
|
|
|
|
## procedure.
|
|
|
|
dh.roAcc.getBalance(account)
|
|
|
|
|
2023-01-30 22:10:23 +00:00
|
|
|
proc getNonce*(dh: TxChainRef; account: EthAddress): AccountNonce =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Wrapper around `vmState.readOnlyStateDB.getNonce()` for a `vmState`
|
|
|
|
## descriptor positioned at the `dh.head`. This might differ from the
|
|
|
|
## `dh.vmState.readOnlyStateDB.getNonce()` which returnes the current balance
|
|
|
|
## relative to what has been accumulated by the current packing procedure.
|
|
|
|
dh.roAcc.getNonce(account)
|
|
|
|
|
|
|
|
proc getHeader*(dh: TxChainRef): BlockHeader
|
2024-02-16 09:08:07 +00:00
|
|
|
{.gcsafe,raises: [].} =
|
2022-12-09 08:17:33 +00:00
|
|
|
## Generate a new header, a child of the cached `head`
|
2022-01-18 14:40:02 +00:00
|
|
|
let gasUsed = if dh.txEnv.receipts.len == 0: 0.GasInt
|
|
|
|
else: dh.txEnv.receipts[^1].cumulativeGasUsed
|
|
|
|
|
2022-12-06 05:55:40 +00:00
|
|
|
result = BlockHeader(
|
2024-06-14 07:31:08 +00:00
|
|
|
parentHash: dh.txEnv.vmState.parent.blockHash,
|
|
|
|
ommersHash: EMPTY_UNCLE_HASH,
|
|
|
|
coinbase: dh.prepHeader.coinbase,
|
|
|
|
stateRoot: dh.txEnv.stateRoot,
|
|
|
|
txRoot: dh.txEnv.txRoot,
|
|
|
|
receiptsRoot: dh.txEnv.receipts.calcReceiptsRoot,
|
|
|
|
logsBloom: dh.txEnv.receipts.createBloom,
|
|
|
|
difficulty: dh.prepHeader.difficulty,
|
|
|
|
number: dh.txEnv.vmState.blockNumber,
|
|
|
|
gasLimit: dh.txEnv.vmState.blockCtx.gasLimit,
|
|
|
|
gasUsed: gasUsed,
|
|
|
|
timestamp: dh.prepHeader.timestamp,
|
|
|
|
# extraData: Blob # signing data
|
|
|
|
# mixHash: Hash256 # mining hash for given difficulty
|
|
|
|
# nonce: BlockNonce # mining free vaiable
|
|
|
|
baseFeePerGas: dh.txEnv.vmState.blockCtx.baseFeePerGas,
|
|
|
|
blobGasUsed: dh.txEnv.blobGasUsed,
|
2023-08-04 12:43:30 +00:00
|
|
|
excessBlobGas: dh.txEnv.excessBlobGas)
|
2022-01-18 14:40:02 +00:00
|
|
|
|
2023-05-22 10:55:19 +00:00
|
|
|
if dh.com.forkGTE(Shanghai):
|
2024-06-14 07:31:08 +00:00
|
|
|
result.withdrawalsRoot = Opt.some(calcWithdrawalsRoot(dh.com.pos.withdrawals))
|
2023-05-22 10:55:19 +00:00
|
|
|
|
2023-08-30 16:29:48 +00:00
|
|
|
if dh.com.forkGTE(Cancun):
|
2024-06-14 07:31:08 +00:00
|
|
|
result.parentBeaconBlockRoot = Opt.some(dh.com.pos.parentBeaconBlockRoot)
|
2023-08-30 16:29:48 +00:00
|
|
|
|
2022-12-06 05:55:40 +00:00
|
|
|
dh.prepareForSeal(result)
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
proc clearAccounts*(dh: TxChainRef)
|
2024-05-28 18:26:51 +00:00
|
|
|
{.gcsafe,raises: [].} =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Reset transaction environment, e.g. before packing a new block
|
2024-06-14 07:31:08 +00:00
|
|
|
dh.resetTxEnv(dh.txEnv.vmState.parent, dh.txEnv.vmState.blockCtx.baseFeePerGas)
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public functions, getters
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func com*(dh: TxChainRef): CommonRef =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter
|
2022-12-02 04:35:41 +00:00
|
|
|
dh.com
|
2022-01-18 14:40:02 +00:00
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func head*(dh: TxChainRef): BlockHeader =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter
|
|
|
|
dh.txEnv.vmState.parent
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func limits*(dh: TxChainRef): TxChainGasLimits =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter
|
|
|
|
dh.limits
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func lhwm*(dh: TxChainRef): TxChainGasLimitsPc =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter
|
|
|
|
dh.lhwm
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func maxMode*(dh: TxChainRef): bool =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter
|
|
|
|
dh.maxMode
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func feeRecipient*(dh: TxChainRef): EthAddress =
|
2022-12-06 05:55:40 +00:00
|
|
|
## Getter
|
2024-05-28 18:26:51 +00:00
|
|
|
dh.com.pos.feeRecipient
|
2022-01-18 14:40:02 +00:00
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func baseFee*(dh: TxChainRef): GasPrice =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter, baseFee for the next bock header. This value is auto-generated
|
|
|
|
## when a new insertion point is set via `head=`.
|
2024-06-14 07:31:08 +00:00
|
|
|
if dh.txEnv.vmState.blockCtx.baseFeePerGas.isSome:
|
|
|
|
dh.txEnv.vmState.blockCtx.baseFeePerGas.get.truncate(uint64).GasPrice
|
2022-01-18 14:40:02 +00:00
|
|
|
else:
|
|
|
|
0.GasPrice
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func excessBlobGas*(dh: TxChainRef): uint64 =
|
2023-08-21 02:10:18 +00:00
|
|
|
## Getter, baseFee for the next bock header. This value is auto-generated
|
|
|
|
## when a new insertion point is set via `head=`.
|
2023-09-24 15:25:41 +00:00
|
|
|
dh.txEnv.excessBlobGas.get(0'u64)
|
2023-08-21 02:10:18 +00:00
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func nextFork*(dh: TxChainRef): EVMFork =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter, fork of next block
|
2024-07-04 13:48:36 +00:00
|
|
|
dh.txEnv.vmState.fork
|
2022-01-18 14:40:02 +00:00
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func gasUsed*(dh: TxChainRef): GasInt =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter, accumulated gas burned for collected blocks
|
|
|
|
if 0 < dh.txEnv.receipts.len:
|
|
|
|
return dh.txEnv.receipts[^1].cumulativeGasUsed
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func profit*(dh: TxChainRef): UInt256 =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter
|
|
|
|
dh.txEnv.profit
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func receipts*(dh: TxChainRef): seq[Receipt] =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter, receipts for collected blocks
|
|
|
|
dh.txEnv.receipts
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func reward*(dh: TxChainRef): UInt256 =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter, reward for collected blocks
|
|
|
|
dh.txEnv.reward
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func stateRoot*(dh: TxChainRef): Hash256 =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter, accounting DB state root hash for the next block header
|
|
|
|
dh.txEnv.stateRoot
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func txRoot*(dh: TxChainRef): Hash256 =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter, transaction state root hash for the next block header
|
|
|
|
dh.txEnv.txRoot
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func vmState*(dh: TxChainRef): BaseVMState =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter, `BaseVmState` descriptor based on the current insertion point.
|
|
|
|
dh.txEnv.vmState
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public functions, setters
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func `baseFee=`*(dh: TxChainRef; val: GasPrice) =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Setter, temorarily overwrites parameter until next `head=` update. This
|
|
|
|
## function would be called in exceptional cases only as this parameter is
|
|
|
|
## determined by the `head=` update.
|
2024-06-27 05:54:36 +00:00
|
|
|
if 0 < val or dh.com.isLondonOrLater(dh.txEnv.vmState.blockNumber):
|
2024-06-14 07:31:08 +00:00
|
|
|
dh.txEnv.vmState.blockCtx.baseFeePerGas = Opt.some(val.uint64.u256)
|
2022-01-18 14:40:02 +00:00
|
|
|
else:
|
2024-06-14 07:31:08 +00:00
|
|
|
dh.txEnv.vmState.blockCtx.baseFeePerGas = Opt.none UInt256
|
2022-01-18 14:40:02 +00:00
|
|
|
|
|
|
|
proc `head=`*(dh: TxChainRef; val: BlockHeader)
|
2024-05-28 18:26:51 +00:00
|
|
|
{.gcsafe,raises: [].} =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Setter, updates descriptor. This setter re-positions the `vmState` and
|
|
|
|
## account caches to a new insertion point on the block chain database.
|
|
|
|
dh.update(val)
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func `lhwm=`*(dh: TxChainRef; val: TxChainGasLimitsPc) =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Setter, tuple `(lwmTrg,hwmMax)` will allow the packer to continue
|
|
|
|
## up until the percentage level has been reached of the `trgLimit`, or
|
|
|
|
## `maxLimit` depending on what has been activated.
|
|
|
|
if dh.lhwm != val:
|
|
|
|
dh.lhwm = val
|
|
|
|
let parent = dh.txEnv.vmState.parent
|
2022-12-02 04:35:41 +00:00
|
|
|
dh.limits = dh.com.gasLimitsGet(parent, dh.limits.gasLimit, dh.lhwm)
|
2023-09-24 15:25:41 +00:00
|
|
|
dh.txEnv.vmState.blockCtx.gasLimit = if dh.maxMode: dh.limits.maxLimit
|
|
|
|
else: dh.limits.trgLimit
|
2022-01-18 14:40:02 +00:00
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func `maxMode=`*(dh: TxChainRef; val: bool) =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Setter, the packing mode (maximal or target limit) for the next block
|
|
|
|
## header
|
|
|
|
dh.maxMode = val
|
2023-09-24 15:25:41 +00:00
|
|
|
dh.txEnv.vmState.blockCtx.gasLimit = if dh.maxMode: dh.limits.maxLimit
|
|
|
|
else: dh.limits.trgLimit
|
2022-01-18 14:40:02 +00:00
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func `profit=`*(dh: TxChainRef; val: UInt256) =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Setter
|
|
|
|
dh.txEnv.profit = val
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func `receipts=`*(dh: TxChainRef; val: seq[Receipt]) =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Setter, implies `gasUsed`
|
|
|
|
dh.txEnv.receipts = val
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func `reward=`*(dh: TxChainRef; val: UInt256) =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Getter
|
|
|
|
dh.txEnv.reward = val
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func `stateRoot=`*(dh: TxChainRef; val: Hash256) =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Setter
|
|
|
|
dh.txEnv.stateRoot = val
|
|
|
|
|
2024-05-28 18:26:51 +00:00
|
|
|
func `txRoot=`*(dh: TxChainRef; val: Hash256) =
|
2022-01-18 14:40:02 +00:00
|
|
|
## Setter
|
|
|
|
dh.txEnv.txRoot = val
|
|
|
|
|
2024-06-14 07:31:08 +00:00
|
|
|
func `excessBlobGas=`*(dh: TxChainRef; val: Opt[uint64]) =
|
2023-06-24 13:56:44 +00:00
|
|
|
## Setter
|
2023-08-04 12:43:30 +00:00
|
|
|
dh.txEnv.excessBlobGas = val
|
2023-06-24 13:56:44 +00:00
|
|
|
|
2024-06-14 07:31:08 +00:00
|
|
|
func `blobGasUsed=`*(dh: TxChainRef; val: Opt[uint64]) =
|
2023-06-24 13:56:44 +00:00
|
|
|
## Setter
|
2023-08-04 12:43:30 +00:00
|
|
|
dh.txEnv.blobGasUsed = val
|
2023-06-24 13:56:44 +00:00
|
|
|
|
2022-01-18 14:40:02 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|