remove expicit PoW support from tx pool; tighten tx pool exceptions specs (#2235)
This commit is contained in:
parent
3a62250d04
commit
709200f62a
|
@ -91,7 +91,7 @@ proc newEngineEnv*(conf: var NimbusConf, chainFile: string, enableAuth: bool): E
|
||||||
chain = newChain(com)
|
chain = newChain(com)
|
||||||
|
|
||||||
com.initializeEmptyDb()
|
com.initializeEmptyDb()
|
||||||
let txPool = TxPoolRef.new(com, ZERO_ADDRESS)
|
let txPool = TxPoolRef.new(com)
|
||||||
|
|
||||||
node.addEthHandlerCapability(
|
node.addEthHandlerCapability(
|
||||||
node.peerPool,
|
node.peerPool,
|
||||||
|
|
|
@ -84,7 +84,7 @@ proc main() =
|
||||||
)
|
)
|
||||||
|
|
||||||
com.initializeEmptyDb()
|
com.initializeEmptyDb()
|
||||||
let txPool = TxPoolRef.new(com, ZERO_ADDRESS)
|
let txPool = TxPoolRef.new(com)
|
||||||
discard importRlpBlock(blocksFile, com)
|
discard importRlpBlock(blocksFile, com)
|
||||||
let ctx = setupGraphqlContext(com, ethNode, txPool)
|
let ctx = setupGraphqlContext(com, ethNode, txPool)
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,6 @@ type
|
||||||
rpcServer: RpcHttpServer
|
rpcServer: RpcHttpServer
|
||||||
rpcClient*: RpcHttpClient
|
rpcClient*: RpcHttpClient
|
||||||
|
|
||||||
const
|
|
||||||
engineSigner = hexToByteArray[20]("0x658bdf435d810c91414ec09147daa6db62406379")
|
|
||||||
|
|
||||||
proc genesisHeader(node: JsonNode): BlockHeader =
|
proc genesisHeader(node: JsonNode): BlockHeader =
|
||||||
let genesisRLP = hexToSeqByte(node["genesisRLP"].getStr)
|
let genesisRLP = hexToSeqByte(node["genesisRLP"].getStr)
|
||||||
rlp.decode(genesisRLP, EthBlock).header
|
rlp.decode(genesisRLP, EthBlock).header
|
||||||
|
@ -68,7 +65,7 @@ proc setupELClient*(t: TestEnv, conf: ChainConfig, node: JsonNode) =
|
||||||
t.com.consensus == ConsensusType.POS)
|
t.com.consensus == ConsensusType.POS)
|
||||||
doAssert(t.com.db.getCanonicalHead().blockHash == genesisHeader.blockHash)
|
doAssert(t.com.db.getCanonicalHead().blockHash == genesisHeader.blockHash)
|
||||||
|
|
||||||
let txPool = TxPoolRef.new(t.com, engineSigner)
|
let txPool = TxPoolRef.new(t.com)
|
||||||
t.rpcServer = newRpcHttpServer(["127.0.0.1:8545"])
|
t.rpcServer = newRpcHttpServer(["127.0.0.1:8545"])
|
||||||
|
|
||||||
let beaconEngine = BeaconEngineRef.new(txPool, t.chainRef)
|
let beaconEngine = BeaconEngineRef.new(txPool, t.chainRef)
|
||||||
|
|
|
@ -84,7 +84,7 @@ proc setupEnv*(): TestEnv =
|
||||||
com.initializeEmptyDb()
|
com.initializeEmptyDb()
|
||||||
|
|
||||||
let chainRef = newChain(com)
|
let chainRef = newChain(com)
|
||||||
let txPool = TxPoolRef.new(com, ZERO_ADDRESS)
|
let txPool = TxPoolRef.new(com)
|
||||||
|
|
||||||
# txPool must be informed of active head
|
# txPool must be informed of active head
|
||||||
# so it can know the latest account state
|
# so it can know the latest account state
|
||||||
|
|
|
@ -504,12 +504,11 @@ proc setHead(xp: TxPoolRef; val: BlockHeader)
|
||||||
# Public constructor/destructor
|
# Public constructor/destructor
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc new*(T: type TxPoolRef; com: CommonRef; miner: EthAddress): T
|
proc new*(T: type TxPoolRef; com: CommonRef): T
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [CatchableError].} =
|
||||||
## Constructor, returns a new tx-pool descriptor. The `miner` argument is
|
## Constructor, returns a new tx-pool descriptor.
|
||||||
## the fee beneficiary for informational purposes only.
|
|
||||||
new result
|
new result
|
||||||
result.init(com, miner)
|
result.init(com)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public functions, task manager, pool actions serialiser
|
# Public functions, task manager, pool actions serialiser
|
||||||
|
@ -594,15 +593,15 @@ proc triggerReorg*(xp: TxPoolRef)
|
||||||
# Public functions, getters
|
# Public functions, getters
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc com*(xp: TxPoolRef): CommonRef =
|
func com*(xp: TxPoolRef): CommonRef =
|
||||||
## Getter
|
## Getter
|
||||||
xp.chain.com
|
xp.chain.com
|
||||||
|
|
||||||
proc baseFee*(xp: TxPoolRef): GasPrice =
|
func baseFee*(xp: TxPoolRef): GasPrice =
|
||||||
## Getter, this parameter modifies/determines the expected gain when packing
|
## Getter, this parameter modifies/determines the expected gain when packing
|
||||||
xp.chain.baseFee
|
xp.chain.baseFee
|
||||||
|
|
||||||
proc dirtyBuckets*(xp: TxPoolRef): bool =
|
func dirtyBuckets*(xp: TxPoolRef): bool =
|
||||||
## Getter, bucket database is ready for re-org if the `autoUpdateBucketsDB`
|
## Getter, bucket database is ready for re-org if the `autoUpdateBucketsDB`
|
||||||
## flag is also set.
|
## flag is also set.
|
||||||
xp.pDirtyBuckets
|
xp.pDirtyBuckets
|
||||||
|
@ -669,52 +668,52 @@ proc assembleBlock*(
|
||||||
blk: blk,
|
blk: blk,
|
||||||
blobsBundle: blobsBundleOpt)
|
blobsBundle: blobsBundleOpt)
|
||||||
|
|
||||||
proc gasCumulative*(xp: TxPoolRef): GasInt =
|
func gasCumulative*(xp: TxPoolRef): GasInt =
|
||||||
## Getter, retrieves the gas that will be burned in the block after
|
## Getter, retrieves the gas that will be burned in the block after
|
||||||
## retrieving it via `ethBlock`.
|
## retrieving it via `ethBlock`.
|
||||||
xp.chain.gasUsed
|
xp.chain.gasUsed
|
||||||
|
|
||||||
proc gasTotals*(xp: TxPoolRef): TxTabsGasTotals =
|
func gasTotals*(xp: TxPoolRef): TxTabsGasTotals =
|
||||||
## Getter, retrieves the current gas limit totals per bucket.
|
## Getter, retrieves the current gas limit totals per bucket.
|
||||||
xp.txDB.gasTotals
|
xp.txDB.gasTotals
|
||||||
|
|
||||||
proc lwmTrgPercent*(xp: TxPoolRef): int =
|
func lwmTrgPercent*(xp: TxPoolRef): int =
|
||||||
## Getter, `trgGasLimit` percentage for `lwmGasLimit` which is
|
## Getter, `trgGasLimit` percentage for `lwmGasLimit` which is
|
||||||
## `max(minGasLimit, trgGasLimit * lwmTrgPercent / 100)`
|
## `max(minGasLimit, trgGasLimit * lwmTrgPercent / 100)`
|
||||||
xp.chain.lhwm.lwmTrg
|
xp.chain.lhwm.lwmTrg
|
||||||
|
|
||||||
proc flags*(xp: TxPoolRef): set[TxPoolFlags] =
|
func flags*(xp: TxPoolRef): set[TxPoolFlags] =
|
||||||
## Getter, retrieves strategy symbols for how to process items and buckets.
|
## Getter, retrieves strategy symbols for how to process items and buckets.
|
||||||
xp.pFlags
|
xp.pFlags
|
||||||
|
|
||||||
proc head*(xp: TxPoolRef): BlockHeader =
|
func head*(xp: TxPoolRef): BlockHeader =
|
||||||
## Getter, cached block chain insertion point. Typocally, this should be the
|
## Getter, cached block chain insertion point. Typocally, this should be the
|
||||||
## the same header as retrieved by the `getCanonicalHead()` (unless in the
|
## the same header as retrieved by the `getCanonicalHead()` (unless in the
|
||||||
## middle of a mining update.)
|
## middle of a mining update.)
|
||||||
xp.chain.head
|
xp.chain.head
|
||||||
|
|
||||||
proc hwmMaxPercent*(xp: TxPoolRef): int =
|
func hwmMaxPercent*(xp: TxPoolRef): int =
|
||||||
## Getter, `maxGasLimit` percentage for `hwmGasLimit` which is
|
## Getter, `maxGasLimit` percentage for `hwmGasLimit` which is
|
||||||
## `max(trgGasLimit, maxGasLimit * hwmMaxPercent / 100)`
|
## `max(trgGasLimit, maxGasLimit * hwmMaxPercent / 100)`
|
||||||
xp.chain.lhwm.hwmMax
|
xp.chain.lhwm.hwmMax
|
||||||
|
|
||||||
proc maxGasLimit*(xp: TxPoolRef): GasInt =
|
func maxGasLimit*(xp: TxPoolRef): GasInt =
|
||||||
## Getter, hard size limit when packing blocks (see also `trgGasLimit`.)
|
## Getter, hard size limit when packing blocks (see also `trgGasLimit`.)
|
||||||
xp.chain.limits.maxLimit
|
xp.chain.limits.maxLimit
|
||||||
|
|
||||||
# core/tx_pool.go(435): func (pool *TxPool) GasPrice() *big.Int {
|
# core/tx_pool.go(435): func (pool *TxPool) GasPrice() *big.Int {
|
||||||
proc minFeePrice*(xp: TxPoolRef): GasPrice =
|
func minFeePrice*(xp: TxPoolRef): GasPrice =
|
||||||
## Getter, retrieves minimum for the current gas fee enforced by the
|
## Getter, retrieves minimum for the current gas fee enforced by the
|
||||||
## transaction pool for txs to be packed. This is an EIP-1559 only
|
## transaction pool for txs to be packed. This is an EIP-1559 only
|
||||||
## parameter (see `stage1559MinFee` strategy.)
|
## parameter (see `stage1559MinFee` strategy.)
|
||||||
xp.pMinFeePrice
|
xp.pMinFeePrice
|
||||||
|
|
||||||
proc minPreLondonGasPrice*(xp: TxPoolRef): GasPrice =
|
func minPreLondonGasPrice*(xp: TxPoolRef): GasPrice =
|
||||||
## Getter. retrieves, the current gas price enforced by the transaction
|
## Getter. retrieves, the current gas price enforced by the transaction
|
||||||
## pool. This is a pre-London parameter (see `packedPlMinPrice` strategy.)
|
## pool. This is a pre-London parameter (see `packedPlMinPrice` strategy.)
|
||||||
xp.pMinPlGasPrice
|
xp.pMinPlGasPrice
|
||||||
|
|
||||||
proc minTipPrice*(xp: TxPoolRef): GasPrice =
|
func minTipPrice*(xp: TxPoolRef): GasPrice =
|
||||||
## Getter, retrieves minimum for the current gas tip (or priority fee)
|
## Getter, retrieves minimum for the current gas tip (or priority fee)
|
||||||
## enforced by the transaction pool. This is an EIP-1559 parameter but it
|
## enforced by the transaction pool. This is an EIP-1559 parameter but it
|
||||||
## comes with a fall back interpretation (see `stage1559MinTip` strategy.)
|
## comes with a fall back interpretation (see `stage1559MinTip` strategy.)
|
||||||
|
@ -725,12 +724,12 @@ proc minTipPrice*(xp: TxPoolRef): GasPrice =
|
||||||
# core/tx_pool.go(1728): func (t *txLookup) Count() int {
|
# core/tx_pool.go(1728): func (t *txLookup) Count() int {
|
||||||
# core/tx_pool.go(1737): func (t *txLookup) LocalCount() int {
|
# core/tx_pool.go(1737): func (t *txLookup) LocalCount() int {
|
||||||
# core/tx_pool.go(1745): func (t *txLookup) RemoteCount() int {
|
# core/tx_pool.go(1745): func (t *txLookup) RemoteCount() int {
|
||||||
proc nItems*(xp: TxPoolRef): TxTabsItemsCount =
|
func nItems*(xp: TxPoolRef): TxTabsItemsCount =
|
||||||
## Getter, retrieves the current number of items per bucket and
|
## Getter, retrieves the current number of items per bucket and
|
||||||
## some totals.
|
## some totals.
|
||||||
xp.txDB.nItems
|
xp.txDB.nItems
|
||||||
|
|
||||||
proc profitability*(xp: TxPoolRef): GasPrice =
|
func profitability*(xp: TxPoolRef): GasPrice =
|
||||||
## Getter, a calculation of the average *price* per gas to be rewarded after
|
## Getter, a calculation of the average *price* per gas to be rewarded after
|
||||||
## packing the last block (see `ethBlock`). This *price* is only based on
|
## packing the last block (see `ethBlock`). This *price* is only based on
|
||||||
## execution transaction in the VM without *PoW* specific rewards. The net
|
## execution transaction in the VM without *PoW* specific rewards. The net
|
||||||
|
@ -741,7 +740,7 @@ proc profitability*(xp: TxPoolRef): GasPrice =
|
||||||
else:
|
else:
|
||||||
0.GasPrice
|
0.GasPrice
|
||||||
|
|
||||||
proc trgGasLimit*(xp: TxPoolRef): GasInt =
|
func trgGasLimit*(xp: TxPoolRef): GasInt =
|
||||||
## Getter, soft size limit when packing blocks (might be extended to
|
## Getter, soft size limit when packing blocks (might be extended to
|
||||||
## `maxGasLimit`)
|
## `maxGasLimit`)
|
||||||
xp.chain.limits.trgLimit
|
xp.chain.limits.trgLimit
|
||||||
|
@ -750,8 +749,7 @@ proc trgGasLimit*(xp: TxPoolRef): GasInt =
|
||||||
# Public functions, setters
|
# Public functions, setters
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc `baseFee=`*(xp: TxPoolRef; val: GasPrice)
|
func `baseFee=`*(xp: TxPoolRef; val: GasPrice) {.raises: [KeyError].} =
|
||||||
{.gcsafe,raises: [KeyError].} =
|
|
||||||
## Setter, sets `baseFee` explicitely witout triggering a packer update.
|
## Setter, sets `baseFee` explicitely witout triggering a packer update.
|
||||||
## Stil a database update might take place when updating account ranks.
|
## Stil a database update might take place when updating account ranks.
|
||||||
##
|
##
|
||||||
|
@ -761,7 +759,7 @@ proc `baseFee=`*(xp: TxPoolRef; val: GasPrice)
|
||||||
xp.txDB.baseFee = val
|
xp.txDB.baseFee = val
|
||||||
xp.chain.baseFee = val
|
xp.chain.baseFee = val
|
||||||
|
|
||||||
proc `lwmTrgPercent=`*(xp: TxPoolRef; val: int) =
|
func `lwmTrgPercent=`*(xp: TxPoolRef; val: int) =
|
||||||
## Setter, `val` arguments outside `0..100` are ignored
|
## Setter, `val` arguments outside `0..100` are ignored
|
||||||
if 0 <= val and val <= 100:
|
if 0 <= val and val <= 100:
|
||||||
xp.chain.lhwm = (
|
xp.chain.lhwm = (
|
||||||
|
@ -771,11 +769,11 @@ proc `lwmTrgPercent=`*(xp: TxPoolRef; val: int) =
|
||||||
gasCeil: xp.chain.lhwm.gasCeil
|
gasCeil: xp.chain.lhwm.gasCeil
|
||||||
)
|
)
|
||||||
|
|
||||||
proc `flags=`*(xp: TxPoolRef; val: set[TxPoolFlags]) =
|
func `flags=`*(xp: TxPoolRef; val: set[TxPoolFlags]) =
|
||||||
## Setter, strategy symbols for how to process items and buckets.
|
## Setter, strategy symbols for how to process items and buckets.
|
||||||
xp.pFlags = val
|
xp.pFlags = val
|
||||||
|
|
||||||
proc `hwmMaxPercent=`*(xp: TxPoolRef; val: int) =
|
func `hwmMaxPercent=`*(xp: TxPoolRef; val: int) =
|
||||||
## Setter, `val` arguments outside `0..100` are ignored
|
## Setter, `val` arguments outside `0..100` are ignored
|
||||||
if 0 <= val and val <= 100:
|
if 0 <= val and val <= 100:
|
||||||
xp.chain.lhwm = (
|
xp.chain.lhwm = (
|
||||||
|
@ -785,13 +783,13 @@ proc `hwmMaxPercent=`*(xp: TxPoolRef; val: int) =
|
||||||
gasCeil: xp.chain.lhwm.gasCeil
|
gasCeil: xp.chain.lhwm.gasCeil
|
||||||
)
|
)
|
||||||
|
|
||||||
proc `maxRejects=`*(xp: TxPoolRef; val: int) =
|
func `maxRejects=`*(xp: TxPoolRef; val: int) =
|
||||||
## Setter, the size of the waste basket. This setting becomes effective with
|
## Setter, the size of the waste basket. This setting becomes effective with
|
||||||
## the next move of an item into the waste basket.
|
## the next move of an item into the waste basket.
|
||||||
xp.txDB.maxRejects = val
|
xp.txDB.maxRejects = val
|
||||||
|
|
||||||
# core/tx_pool.go(444): func (pool *TxPool) SetGasPrice(price *big.Int) {
|
# core/tx_pool.go(444): func (pool *TxPool) SetGasPrice(price *big.Int) {
|
||||||
proc `minFeePrice=`*(xp: TxPoolRef; val: GasPrice) =
|
func `minFeePrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
## Setter for `minFeePrice`. If there was a value change, this function
|
## Setter for `minFeePrice`. If there was a value change, this function
|
||||||
## implies `triggerReorg()`.
|
## implies `triggerReorg()`.
|
||||||
if xp.pMinFeePrice != val:
|
if xp.pMinFeePrice != val:
|
||||||
|
@ -799,7 +797,7 @@ proc `minFeePrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
xp.pDirtyBuckets = true
|
xp.pDirtyBuckets = true
|
||||||
|
|
||||||
# core/tx_pool.go(444): func (pool *TxPool) SetGasPrice(price *big.Int) {
|
# core/tx_pool.go(444): func (pool *TxPool) SetGasPrice(price *big.Int) {
|
||||||
proc `minPreLondonGasPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
func `minPreLondonGasPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
## Setter for `minPlGasPrice`. If there was a value change, this function
|
## Setter for `minPlGasPrice`. If there was a value change, this function
|
||||||
## implies `triggerReorg()`.
|
## implies `triggerReorg()`.
|
||||||
if xp.pMinPlGasPrice != val:
|
if xp.pMinPlGasPrice != val:
|
||||||
|
@ -807,7 +805,7 @@ proc `minPreLondonGasPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
xp.pDirtyBuckets = true
|
xp.pDirtyBuckets = true
|
||||||
|
|
||||||
# core/tx_pool.go(444): func (pool *TxPool) SetGasPrice(price *big.Int) {
|
# core/tx_pool.go(444): func (pool *TxPool) SetGasPrice(price *big.Int) {
|
||||||
proc `minTipPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
func `minTipPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
## Setter for `minTipPrice`. If there was a value change, this function
|
## Setter for `minTipPrice`. If there was a value change, this function
|
||||||
## implies `triggerReorg()`.
|
## implies `triggerReorg()`.
|
||||||
if xp.pMinTipPrice != val:
|
if xp.pMinTipPrice != val:
|
||||||
|
@ -820,11 +818,11 @@ proc `minTipPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
|
|
||||||
# core/tx_pool.go(979): func (pool *TxPool) Get(hash common.Hash) ..
|
# core/tx_pool.go(979): func (pool *TxPool) Get(hash common.Hash) ..
|
||||||
# core/tx_pool.go(985): func (pool *TxPool) Has(hash common.Hash) bool {
|
# core/tx_pool.go(985): func (pool *TxPool) Has(hash common.Hash) bool {
|
||||||
proc getItem*(xp: TxPoolRef; hash: Hash256): Result[TxItemRef,void] =
|
func getItem*(xp: TxPoolRef; hash: Hash256): Result[TxItemRef,void] =
|
||||||
## Returns a transaction if it is contained in the pool.
|
## Returns a transaction if it is contained in the pool.
|
||||||
xp.txDB.byItemID.eq(hash)
|
xp.txDB.byItemID.eq(hash)
|
||||||
|
|
||||||
proc disposeItems*(xp: TxPoolRef; item: TxItemRef;
|
func disposeItems*(xp: TxPoolRef; item: TxItemRef;
|
||||||
reason = txInfoExplicitDisposal;
|
reason = txInfoExplicitDisposal;
|
||||||
otherReason = txInfoImpliedDisposal): int
|
otherReason = txInfoImpliedDisposal): int
|
||||||
{.discardable,gcsafe,raises: [CatchableError].} =
|
{.discardable,gcsafe,raises: [CatchableError].} =
|
||||||
|
@ -842,10 +840,10 @@ iterator okPairs*(xp: TxPoolRef): (Hash256, TxItemRef) =
|
||||||
if x.data.reject == txInfoOk:
|
if x.data.reject == txInfoOk:
|
||||||
yield (x.key, x.data)
|
yield (x.key, x.data)
|
||||||
|
|
||||||
proc numTxs*(xp: TxPoolRef): int =
|
func numTxs*(xp: TxPoolRef): int =
|
||||||
xp.txDB.byItemID.len
|
xp.txDB.byItemID.len
|
||||||
|
|
||||||
proc disposeAll*(xp: TxPoolRef) {.gcsafe,raises: [CatchableError].} =
|
func disposeAll*(xp: TxPoolRef) {.raises: [CatchableError].} =
|
||||||
let numTx = xp.numTxs
|
let numTx = xp.numTxs
|
||||||
var list = newSeqOfCap[TxItemRef](numTx)
|
var list = newSeqOfCap[TxItemRef](numTx)
|
||||||
for x in nextPairs(xp.txDB.byItemID):
|
for x in nextPairs(xp.txDB.byItemID):
|
||||||
|
@ -857,27 +855,27 @@ proc disposeAll*(xp: TxPoolRef) {.gcsafe,raises: [CatchableError].} =
|
||||||
# Public functions, local/remote accounts
|
# Public functions, local/remote accounts
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc isLocal*(xp: TxPoolRef; account: EthAddress): bool =
|
func isLocal*(xp: TxPoolRef; account: EthAddress): bool =
|
||||||
## This function returns `true` if argument `account` is tagged local.
|
## This function returns `true` if argument `account` is tagged local.
|
||||||
xp.txDB.isLocal(account)
|
xp.txDB.isLocal(account)
|
||||||
|
|
||||||
proc setLocal*(xp: TxPoolRef; account: EthAddress) =
|
func setLocal*(xp: TxPoolRef; account: EthAddress) =
|
||||||
## Tag argument `account` local which means that the transactions from this
|
## Tag argument `account` local which means that the transactions from this
|
||||||
## account -- together with all other local accounts -- will be considered
|
## account -- together with all other local accounts -- will be considered
|
||||||
## first for packing.
|
## first for packing.
|
||||||
xp.txDB.setLocal(account)
|
xp.txDB.setLocal(account)
|
||||||
|
|
||||||
proc resLocal*(xp: TxPoolRef; account: EthAddress) =
|
func resLocal*(xp: TxPoolRef; account: EthAddress) =
|
||||||
## Untag argument `account` as local which means that the transactions from
|
## Untag argument `account` as local which means that the transactions from
|
||||||
## this account -- together with all other untagged accounts -- will be
|
## this account -- together with all other untagged accounts -- will be
|
||||||
## considered for packing after the locally tagged accounts.
|
## considered for packing after the locally tagged accounts.
|
||||||
xp.txDB.resLocal(account)
|
xp.txDB.resLocal(account)
|
||||||
|
|
||||||
proc flushLocals*(xp: TxPoolRef) =
|
func flushLocals*(xp: TxPoolRef) =
|
||||||
## Untag all *local* addresses on the system.
|
## Untag all *local* addresses on the system.
|
||||||
xp.txDB.flushLocals
|
xp.txDB.flushLocals
|
||||||
|
|
||||||
proc accountRanks*(xp: TxPoolRef): TxTabsLocality =
|
func accountRanks*(xp: TxPoolRef): TxTabsLocality =
|
||||||
## Returns two lists, one for local and the other for non-local accounts.
|
## Returns two lists, one for local and the other for non-local accounts.
|
||||||
## Any of these lists is sorted by the highest rank first. This sorting
|
## Any of these lists is sorted by the highest rank first. This sorting
|
||||||
## means that the order may be out-dated after adding transactions.
|
## means that the order may be out-dated after adding transactions.
|
||||||
|
@ -951,12 +949,12 @@ proc addLocal*(xp: TxPoolRef;
|
||||||
xp.add(tx, "local tx")
|
xp.add(tx, "local tx")
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
proc inPoolAndOk*(xp: TxPoolRef; txHash: Hash256): bool =
|
func inPoolAndOk*(xp: TxPoolRef; txHash: Hash256): bool =
|
||||||
let res = xp.getItem(txHash)
|
let res = xp.getItem(txHash)
|
||||||
if res.isErr: return false
|
if res.isErr: return false
|
||||||
res.get().reject == txInfoOk
|
res.get().reject == txInfoOk
|
||||||
|
|
||||||
proc inPoolAndReason*(xp: TxPoolRef; txHash: Hash256): Result[void, string] =
|
func inPoolAndReason*(xp: TxPoolRef; txHash: Hash256): Result[void, string] =
|
||||||
let res = xp.getItem(txHash)
|
let res = xp.getItem(txHash)
|
||||||
if res.isErr:
|
if res.isErr:
|
||||||
# try to look in rejecteds
|
# try to look in rejecteds
|
||||||
|
|
|
@ -61,7 +61,6 @@ type
|
||||||
## block. This state is typically synchrionised with the canonical\
|
## block. This state is typically synchrionised with the canonical\
|
||||||
## block chain head when updated.
|
## block chain head when updated.
|
||||||
com: CommonRef ## Block chain config
|
com: CommonRef ## Block chain config
|
||||||
miner: EthAddress ## Address of fee beneficiary
|
|
||||||
lhwm: TxChainGasLimitsPc ## Hwm/lwm gas limit percentage
|
lhwm: TxChainGasLimitsPc ## Hwm/lwm gas limit percentage
|
||||||
|
|
||||||
maxMode: bool ## target or maximal limit for next block header
|
maxMode: bool ## target or maximal limit for next block header
|
||||||
|
@ -73,38 +72,20 @@ type
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Private functions
|
# Private functions
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
proc prepareHeader(dh: TxChainRef; parent: BlockHeader, timestamp: EthTime)
|
func prepareHeader(dh: TxChainRef; parent: BlockHeader, timestamp: EthTime)
|
||||||
{.gcsafe, raises: [CatchableError].} =
|
{.raises: [].} =
|
||||||
|
|
||||||
case dh.com.consensus
|
|
||||||
of ConsensusType.POW:
|
|
||||||
dh.prepHeader.timestamp = timestamp
|
|
||||||
dh.prepHeader.difficulty = dh.com.calcDifficulty(
|
|
||||||
dh.prepHeader.timestamp, parent)
|
|
||||||
dh.prepHeader.coinbase = dh.miner
|
|
||||||
dh.prepHeader.mixDigest.reset
|
|
||||||
of ConsensusType.POS:
|
|
||||||
dh.com.pos.prepare(dh.prepHeader)
|
dh.com.pos.prepare(dh.prepHeader)
|
||||||
|
|
||||||
proc prepareForSeal(dh: TxChainRef; header: var BlockHeader) {.gcsafe, raises: [].} =
|
func prepareForSeal(dh: TxChainRef; header: var BlockHeader) {.raises: [].} =
|
||||||
case dh.com.consensus
|
|
||||||
of ConsensusType.POW:
|
|
||||||
# do nothing, tx pool was designed with POW in mind
|
|
||||||
discard
|
|
||||||
of ConsensusType.POS:
|
|
||||||
dh.com.pos.prepareForSeal(header)
|
dh.com.pos.prepareForSeal(header)
|
||||||
|
|
||||||
proc getTimestamp(dh: TxChainRef, parent: BlockHeader): EthTime =
|
func getTimestamp(dh: TxChainRef, parent: BlockHeader): EthTime =
|
||||||
case dh.com.consensus
|
|
||||||
of ConsensusType.POW:
|
|
||||||
EthTime.now()
|
|
||||||
of ConsensusType.POS:
|
|
||||||
dh.com.pos.timestamp
|
dh.com.pos.timestamp
|
||||||
|
|
||||||
proc feeRecipient*(dh: TxChainRef): EthAddress {.gcsafe.}
|
func feeRecipient*(dh: TxChainRef): EthAddress
|
||||||
|
|
||||||
proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256])
|
proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256])
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [].} =
|
||||||
dh.txEnv.reset
|
dh.txEnv.reset
|
||||||
|
|
||||||
# do hardfork transition before
|
# do hardfork transition before
|
||||||
|
@ -137,7 +118,7 @@ proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256])
|
||||||
dh.txEnv.excessBlobGas = none(uint64)
|
dh.txEnv.excessBlobGas = none(uint64)
|
||||||
|
|
||||||
proc update(dh: TxChainRef; parent: BlockHeader)
|
proc update(dh: TxChainRef; parent: BlockHeader)
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [].} =
|
||||||
|
|
||||||
let
|
let
|
||||||
timestamp = dh.getTimestamp(parent)
|
timestamp = dh.getTimestamp(parent)
|
||||||
|
@ -158,13 +139,12 @@ proc update(dh: TxChainRef; parent: BlockHeader)
|
||||||
# Public functions, constructor
|
# Public functions, constructor
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc new*(T: type TxChainRef; com: CommonRef; miner: EthAddress): T
|
proc new*(T: type TxChainRef; com: CommonRef): T
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe, raises: [EVMError].} =
|
||||||
## Constructor
|
## Constructor
|
||||||
new result
|
new result
|
||||||
|
|
||||||
result.com = com
|
result.com = com
|
||||||
result.miner = miner
|
|
||||||
result.lhwm.lwmTrg = TRG_THRESHOLD_PER_CENT
|
result.lhwm.lwmTrg = TRG_THRESHOLD_PER_CENT
|
||||||
result.lhwm.hwmMax = MAX_THRESHOLD_PER_CENT
|
result.lhwm.hwmMax = MAX_THRESHOLD_PER_CENT
|
||||||
result.lhwm.gasFloor = DEFAULT_GAS_LIMIT
|
result.lhwm.gasFloor = DEFAULT_GAS_LIMIT
|
||||||
|
@ -225,7 +205,7 @@ proc getHeader*(dh: TxChainRef): BlockHeader
|
||||||
dh.prepareForSeal(result)
|
dh.prepareForSeal(result)
|
||||||
|
|
||||||
proc clearAccounts*(dh: TxChainRef)
|
proc clearAccounts*(dh: TxChainRef)
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [].} =
|
||||||
## Reset transaction environment, e.g. before packing a new block
|
## Reset transaction environment, e.g. before packing a new block
|
||||||
dh.resetTxEnv(dh.txEnv.vmState.parent, dh.txEnv.vmState.blockCtx.fee)
|
dh.resetTxEnv(dh.txEnv.vmState.parent, dh.txEnv.vmState.blockCtx.fee)
|
||||||
|
|
||||||
|
@ -233,34 +213,31 @@ proc clearAccounts*(dh: TxChainRef)
|
||||||
# Public functions, getters
|
# Public functions, getters
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc com*(dh: TxChainRef): CommonRef =
|
func com*(dh: TxChainRef): CommonRef =
|
||||||
## Getter
|
## Getter
|
||||||
dh.com
|
dh.com
|
||||||
|
|
||||||
proc head*(dh: TxChainRef): BlockHeader =
|
func head*(dh: TxChainRef): BlockHeader =
|
||||||
## Getter
|
## Getter
|
||||||
dh.txEnv.vmState.parent
|
dh.txEnv.vmState.parent
|
||||||
|
|
||||||
proc limits*(dh: TxChainRef): TxChainGasLimits =
|
func limits*(dh: TxChainRef): TxChainGasLimits =
|
||||||
## Getter
|
## Getter
|
||||||
dh.limits
|
dh.limits
|
||||||
|
|
||||||
proc lhwm*(dh: TxChainRef): TxChainGasLimitsPc =
|
func lhwm*(dh: TxChainRef): TxChainGasLimitsPc =
|
||||||
## Getter
|
## Getter
|
||||||
dh.lhwm
|
dh.lhwm
|
||||||
|
|
||||||
proc maxMode*(dh: TxChainRef): bool =
|
func maxMode*(dh: TxChainRef): bool =
|
||||||
## Getter
|
## Getter
|
||||||
dh.maxMode
|
dh.maxMode
|
||||||
|
|
||||||
proc feeRecipient*(dh: TxChainRef): EthAddress {.gcsafe.} =
|
func feeRecipient*(dh: TxChainRef): EthAddress =
|
||||||
## Getter
|
## Getter
|
||||||
if dh.com.consensus == ConsensusType.POS:
|
|
||||||
dh.com.pos.feeRecipient
|
dh.com.pos.feeRecipient
|
||||||
else:
|
|
||||||
dh.miner
|
|
||||||
|
|
||||||
proc baseFee*(dh: TxChainRef): GasPrice =
|
func baseFee*(dh: TxChainRef): GasPrice =
|
||||||
## Getter, baseFee for the next bock header. This value is auto-generated
|
## Getter, baseFee for the next bock header. This value is auto-generated
|
||||||
## when a new insertion point is set via `head=`.
|
## when a new insertion point is set via `head=`.
|
||||||
if dh.txEnv.vmState.blockCtx.fee.isSome:
|
if dh.txEnv.vmState.blockCtx.fee.isSome:
|
||||||
|
@ -268,41 +245,41 @@ proc baseFee*(dh: TxChainRef): GasPrice =
|
||||||
else:
|
else:
|
||||||
0.GasPrice
|
0.GasPrice
|
||||||
|
|
||||||
proc excessBlobGas*(dh: TxChainRef): uint64 =
|
func excessBlobGas*(dh: TxChainRef): uint64 =
|
||||||
## Getter, baseFee for the next bock header. This value is auto-generated
|
## Getter, baseFee for the next bock header. This value is auto-generated
|
||||||
## when a new insertion point is set via `head=`.
|
## when a new insertion point is set via `head=`.
|
||||||
dh.txEnv.excessBlobGas.get(0'u64)
|
dh.txEnv.excessBlobGas.get(0'u64)
|
||||||
|
|
||||||
proc nextFork*(dh: TxChainRef): EVMFork =
|
func nextFork*(dh: TxChainRef): EVMFork =
|
||||||
## Getter, fork of next block
|
## Getter, fork of next block
|
||||||
dh.com.toEVMFork(dh.txEnv.vmState.forkDeterminationInfoForVMState)
|
dh.com.toEVMFork(dh.txEnv.vmState.forkDeterminationInfoForVMState)
|
||||||
|
|
||||||
proc gasUsed*(dh: TxChainRef): GasInt =
|
func gasUsed*(dh: TxChainRef): GasInt =
|
||||||
## Getter, accumulated gas burned for collected blocks
|
## Getter, accumulated gas burned for collected blocks
|
||||||
if 0 < dh.txEnv.receipts.len:
|
if 0 < dh.txEnv.receipts.len:
|
||||||
return dh.txEnv.receipts[^1].cumulativeGasUsed
|
return dh.txEnv.receipts[^1].cumulativeGasUsed
|
||||||
|
|
||||||
proc profit*(dh: TxChainRef): UInt256 =
|
func profit*(dh: TxChainRef): UInt256 =
|
||||||
## Getter
|
## Getter
|
||||||
dh.txEnv.profit
|
dh.txEnv.profit
|
||||||
|
|
||||||
proc receipts*(dh: TxChainRef): seq[Receipt] =
|
func receipts*(dh: TxChainRef): seq[Receipt] =
|
||||||
## Getter, receipts for collected blocks
|
## Getter, receipts for collected blocks
|
||||||
dh.txEnv.receipts
|
dh.txEnv.receipts
|
||||||
|
|
||||||
proc reward*(dh: TxChainRef): UInt256 =
|
func reward*(dh: TxChainRef): UInt256 =
|
||||||
## Getter, reward for collected blocks
|
## Getter, reward for collected blocks
|
||||||
dh.txEnv.reward
|
dh.txEnv.reward
|
||||||
|
|
||||||
proc stateRoot*(dh: TxChainRef): Hash256 =
|
func stateRoot*(dh: TxChainRef): Hash256 =
|
||||||
## Getter, accounting DB state root hash for the next block header
|
## Getter, accounting DB state root hash for the next block header
|
||||||
dh.txEnv.stateRoot
|
dh.txEnv.stateRoot
|
||||||
|
|
||||||
proc txRoot*(dh: TxChainRef): Hash256 =
|
func txRoot*(dh: TxChainRef): Hash256 =
|
||||||
## Getter, transaction state root hash for the next block header
|
## Getter, transaction state root hash for the next block header
|
||||||
dh.txEnv.txRoot
|
dh.txEnv.txRoot
|
||||||
|
|
||||||
proc vmState*(dh: TxChainRef): BaseVMState =
|
func vmState*(dh: TxChainRef): BaseVMState =
|
||||||
## Getter, `BaseVmState` descriptor based on the current insertion point.
|
## Getter, `BaseVmState` descriptor based on the current insertion point.
|
||||||
dh.txEnv.vmState
|
dh.txEnv.vmState
|
||||||
|
|
||||||
|
@ -310,7 +287,7 @@ proc vmState*(dh: TxChainRef): BaseVMState =
|
||||||
# Public functions, setters
|
# Public functions, setters
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc `baseFee=`*(dh: TxChainRef; val: GasPrice) =
|
func `baseFee=`*(dh: TxChainRef; val: GasPrice) =
|
||||||
## Setter, temorarily overwrites parameter until next `head=` update. This
|
## Setter, temorarily overwrites parameter until next `head=` update. This
|
||||||
## function would be called in exceptional cases only as this parameter is
|
## function would be called in exceptional cases only as this parameter is
|
||||||
## determined by the `head=` update.
|
## determined by the `head=` update.
|
||||||
|
@ -320,12 +297,12 @@ proc `baseFee=`*(dh: TxChainRef; val: GasPrice) =
|
||||||
dh.txEnv.vmState.blockCtx.fee = UInt256.none()
|
dh.txEnv.vmState.blockCtx.fee = UInt256.none()
|
||||||
|
|
||||||
proc `head=`*(dh: TxChainRef; val: BlockHeader)
|
proc `head=`*(dh: TxChainRef; val: BlockHeader)
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [].} =
|
||||||
## Setter, updates descriptor. This setter re-positions the `vmState` and
|
## Setter, updates descriptor. This setter re-positions the `vmState` and
|
||||||
## account caches to a new insertion point on the block chain database.
|
## account caches to a new insertion point on the block chain database.
|
||||||
dh.update(val)
|
dh.update(val)
|
||||||
|
|
||||||
proc `lhwm=`*(dh: TxChainRef; val: TxChainGasLimitsPc) =
|
func `lhwm=`*(dh: TxChainRef; val: TxChainGasLimitsPc) =
|
||||||
## Setter, tuple `(lwmTrg,hwmMax)` will allow the packer to continue
|
## Setter, tuple `(lwmTrg,hwmMax)` will allow the packer to continue
|
||||||
## up until the percentage level has been reached of the `trgLimit`, or
|
## up until the percentage level has been reached of the `trgLimit`, or
|
||||||
## `maxLimit` depending on what has been activated.
|
## `maxLimit` depending on what has been activated.
|
||||||
|
@ -336,43 +313,38 @@ proc `lhwm=`*(dh: TxChainRef; val: TxChainGasLimitsPc) =
|
||||||
dh.txEnv.vmState.blockCtx.gasLimit = if dh.maxMode: dh.limits.maxLimit
|
dh.txEnv.vmState.blockCtx.gasLimit = if dh.maxMode: dh.limits.maxLimit
|
||||||
else: dh.limits.trgLimit
|
else: dh.limits.trgLimit
|
||||||
|
|
||||||
proc `maxMode=`*(dh: TxChainRef; val: bool) =
|
func `maxMode=`*(dh: TxChainRef; val: bool) =
|
||||||
## Setter, the packing mode (maximal or target limit) for the next block
|
## Setter, the packing mode (maximal or target limit) for the next block
|
||||||
## header
|
## header
|
||||||
dh.maxMode = val
|
dh.maxMode = val
|
||||||
dh.txEnv.vmState.blockCtx.gasLimit = if dh.maxMode: dh.limits.maxLimit
|
dh.txEnv.vmState.blockCtx.gasLimit = if dh.maxMode: dh.limits.maxLimit
|
||||||
else: dh.limits.trgLimit
|
else: dh.limits.trgLimit
|
||||||
|
|
||||||
proc `miner=`*(dh: TxChainRef; val: EthAddress) =
|
func `profit=`*(dh: TxChainRef; val: UInt256) =
|
||||||
## Setter
|
|
||||||
dh.miner = val
|
|
||||||
dh.txEnv.vmState.blockCtx.coinbase = val
|
|
||||||
|
|
||||||
proc `profit=`*(dh: TxChainRef; val: UInt256) =
|
|
||||||
## Setter
|
## Setter
|
||||||
dh.txEnv.profit = val
|
dh.txEnv.profit = val
|
||||||
|
|
||||||
proc `receipts=`*(dh: TxChainRef; val: seq[Receipt]) =
|
func `receipts=`*(dh: TxChainRef; val: seq[Receipt]) =
|
||||||
## Setter, implies `gasUsed`
|
## Setter, implies `gasUsed`
|
||||||
dh.txEnv.receipts = val
|
dh.txEnv.receipts = val
|
||||||
|
|
||||||
proc `reward=`*(dh: TxChainRef; val: UInt256) =
|
func `reward=`*(dh: TxChainRef; val: UInt256) =
|
||||||
## Getter
|
## Getter
|
||||||
dh.txEnv.reward = val
|
dh.txEnv.reward = val
|
||||||
|
|
||||||
proc `stateRoot=`*(dh: TxChainRef; val: Hash256) =
|
func `stateRoot=`*(dh: TxChainRef; val: Hash256) =
|
||||||
## Setter
|
## Setter
|
||||||
dh.txEnv.stateRoot = val
|
dh.txEnv.stateRoot = val
|
||||||
|
|
||||||
proc `txRoot=`*(dh: TxChainRef; val: Hash256) =
|
func `txRoot=`*(dh: TxChainRef; val: Hash256) =
|
||||||
## Setter
|
## Setter
|
||||||
dh.txEnv.txRoot = val
|
dh.txEnv.txRoot = val
|
||||||
|
|
||||||
proc `excessBlobGas=`*(dh: TxChainRef; val: Option[uint64]) =
|
func `excessBlobGas=`*(dh: TxChainRef; val: Option[uint64]) =
|
||||||
## Setter
|
## Setter
|
||||||
dh.txEnv.excessBlobGas = val
|
dh.txEnv.excessBlobGas = val
|
||||||
|
|
||||||
proc `blobGasUsed=`*(dh: TxChainRef; val: Option[uint64]) =
|
func `blobGasUsed=`*(dh: TxChainRef; val: Option[uint64]) =
|
||||||
## Setter
|
## Setter
|
||||||
dh.txEnv.blobGasUsed = val
|
dh.txEnv.blobGasUsed = val
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2018 Status Research & Development GmbH
|
# Copyright (c) 2018-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
@ -127,13 +127,12 @@ const
|
||||||
# Public functions, constructor
|
# Public functions, constructor
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc init*(xp: TxPoolRef; com: CommonRef; miner: EthAddress)
|
proc init*(xp: TxPoolRef; com: CommonRef)
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [CatchableError].} =
|
||||||
## Constructor, returns new tx-pool descriptor. The `miner` argument is
|
## Constructor, returns new tx-pool descriptor.
|
||||||
## the fee beneficiary for informational purposes only.
|
|
||||||
xp.startDate = getTime().utc.toTime
|
xp.startDate = getTime().utc.toTime
|
||||||
|
|
||||||
xp.chain = TxChainRef.new(com, miner)
|
xp.chain = TxChainRef.new(com)
|
||||||
xp.txDB = TxTabsRef.new
|
xp.txDB = TxTabsRef.new
|
||||||
|
|
||||||
xp.lifeTime = txItemLifeTime
|
xp.lifeTime = txItemLifeTime
|
||||||
|
@ -148,40 +147,40 @@ proc init*(xp: TxPoolRef; com: CommonRef; miner: EthAddress)
|
||||||
# Public functions, getters
|
# Public functions, getters
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc chain*(xp: TxPoolRef): TxChainRef =
|
func chain*(xp: TxPoolRef): TxChainRef =
|
||||||
## Getter, block chain DB
|
## Getter, block chain DB
|
||||||
xp.chain
|
xp.chain
|
||||||
|
|
||||||
proc pFlags*(xp: TxPoolRef): set[TxPoolFlags] =
|
func pFlags*(xp: TxPoolRef): set[TxPoolFlags] =
|
||||||
## Returns the set of algorithm strategy symbols for labelling items
|
## Returns the set of algorithm strategy symbols for labelling items
|
||||||
## as`packed`
|
## as`packed`
|
||||||
xp.param.flags
|
xp.param.flags
|
||||||
|
|
||||||
proc pDirtyBuckets*(xp: TxPoolRef): bool =
|
func pDirtyBuckets*(xp: TxPoolRef): bool =
|
||||||
## Getter, buckets need update
|
## Getter, buckets need update
|
||||||
xp.param.dirtyBuckets
|
xp.param.dirtyBuckets
|
||||||
|
|
||||||
proc pDoubleCheck*(xp: TxPoolRef): seq[TxItemRef] =
|
func pDoubleCheck*(xp: TxPoolRef): seq[TxItemRef] =
|
||||||
## Getter, cached block chain head was moved back
|
## Getter, cached block chain head was moved back
|
||||||
xp.param.doubleCheck
|
xp.param.doubleCheck
|
||||||
|
|
||||||
proc pMinFeePrice*(xp: TxPoolRef): GasPrice =
|
func pMinFeePrice*(xp: TxPoolRef): GasPrice =
|
||||||
## Getter
|
## Getter
|
||||||
xp.param.minFeePrice
|
xp.param.minFeePrice
|
||||||
|
|
||||||
proc pMinTipPrice*(xp: TxPoolRef): GasPrice =
|
func pMinTipPrice*(xp: TxPoolRef): GasPrice =
|
||||||
## Getter
|
## Getter
|
||||||
xp.param.minTipPrice
|
xp.param.minTipPrice
|
||||||
|
|
||||||
proc pMinPlGasPrice*(xp: TxPoolRef): GasPrice =
|
func pMinPlGasPrice*(xp: TxPoolRef): GasPrice =
|
||||||
## Getter
|
## Getter
|
||||||
xp.param.minPlGasPrice
|
xp.param.minPlGasPrice
|
||||||
|
|
||||||
proc startDate*(xp: TxPoolRef): Time =
|
func startDate*(xp: TxPoolRef): Time =
|
||||||
## Getter
|
## Getter
|
||||||
xp.startDate
|
xp.startDate
|
||||||
|
|
||||||
proc txDB*(xp: TxPoolRef): TxTabsRef =
|
func txDB*(xp: TxPoolRef): TxTabsRef =
|
||||||
## Getter, pool database
|
## Getter, pool database
|
||||||
xp.txDB
|
xp.txDB
|
||||||
|
|
||||||
|
@ -189,31 +188,31 @@ proc txDB*(xp: TxPoolRef): TxTabsRef =
|
||||||
# Public functions, setters
|
# Public functions, setters
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc `pDirtyBuckets=`*(xp: TxPoolRef; val: bool) =
|
func `pDirtyBuckets=`*(xp: TxPoolRef; val: bool) =
|
||||||
## Setter
|
## Setter
|
||||||
xp.param.dirtyBuckets = val
|
xp.param.dirtyBuckets = val
|
||||||
|
|
||||||
proc pDoubleCheckAdd*(xp: TxPoolRef; val: seq[TxItemRef]) =
|
func pDoubleCheckAdd*(xp: TxPoolRef; val: seq[TxItemRef]) =
|
||||||
## Pseudo setter
|
## Pseudo setter
|
||||||
xp.param.doubleCheck.add val
|
xp.param.doubleCheck.add val
|
||||||
|
|
||||||
proc pDoubleCheckFlush*(xp: TxPoolRef) =
|
func pDoubleCheckFlush*(xp: TxPoolRef) =
|
||||||
## Pseudo setter
|
## Pseudo setter
|
||||||
xp.param.doubleCheck.setLen(0)
|
xp.param.doubleCheck.setLen(0)
|
||||||
|
|
||||||
proc `pFlags=`*(xp: TxPoolRef; val: set[TxPoolFlags]) =
|
func `pFlags=`*(xp: TxPoolRef; val: set[TxPoolFlags]) =
|
||||||
## Install a set of algorithm strategy symbols for labelling items as`packed`
|
## Install a set of algorithm strategy symbols for labelling items as`packed`
|
||||||
xp.param.flags = val
|
xp.param.flags = val
|
||||||
|
|
||||||
proc `pMinFeePrice=`*(xp: TxPoolRef; val: GasPrice) =
|
func `pMinFeePrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
## Setter
|
## Setter
|
||||||
xp.param.minFeePrice = val
|
xp.param.minFeePrice = val
|
||||||
|
|
||||||
proc `pMinTipPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
func `pMinTipPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
## Setter
|
## Setter
|
||||||
xp.param.minTipPrice = val
|
xp.param.minTipPrice = val
|
||||||
|
|
||||||
proc `pMinPlGasPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
func `pMinPlGasPrice=`*(xp: TxPoolRef; val: GasPrice) =
|
||||||
## Setter
|
## Setter
|
||||||
xp.param.minPlGasPrice = val
|
xp.param.minPlGasPrice = val
|
||||||
|
|
||||||
|
|
|
@ -249,13 +249,6 @@ proc vmExecCommit(pst: TxPackerStateRef)
|
||||||
for withdrawal in xp.chain.com.pos.withdrawals:
|
for withdrawal in xp.chain.com.pos.withdrawals:
|
||||||
vmState.stateDB.addBalance(withdrawal.address, withdrawal.weiAmount)
|
vmState.stateDB.addBalance(withdrawal.address, withdrawal.weiAmount)
|
||||||
|
|
||||||
# EIP-3675: no reward for miner in POA/POS
|
|
||||||
if vmState.com.consensus == ConsensusType.POW:
|
|
||||||
let
|
|
||||||
number = xp.chain.head.blockNumber + 1
|
|
||||||
uncles: seq[BlockHeader] = @[] # no uncles yet
|
|
||||||
vmState.calculateReward(xp.chain.feeRecipient, number + 1, uncles)
|
|
||||||
|
|
||||||
# Reward beneficiary
|
# Reward beneficiary
|
||||||
vmState.mutateStateDB:
|
vmState.mutateStateDB:
|
||||||
if vmState.generateWitness:
|
if vmState.generateWitness:
|
||||||
|
|
|
@ -47,7 +47,7 @@ proc importBlocks(conf: NimbusConf, com: CommonRef) =
|
||||||
proc basicServices(nimbus: NimbusNode,
|
proc basicServices(nimbus: NimbusNode,
|
||||||
conf: NimbusConf,
|
conf: NimbusConf,
|
||||||
com: CommonRef) =
|
com: CommonRef) =
|
||||||
nimbus.txPool = TxPoolRef.new(com, ZERO_ADDRESS)
|
nimbus.txPool = TxPoolRef.new(com)
|
||||||
|
|
||||||
# txPool must be informed of active head
|
# txPool must be informed of active head
|
||||||
# so it can know the latest account state
|
# so it can know the latest account state
|
||||||
|
|
Loading…
Reference in New Issue