parent
c6f35142a8
commit
112a6f7d76
|
@ -70,9 +70,6 @@ proc validateSealer*(conf: NimbusConf, ctx: EthContext, chain: Chain): Result[vo
|
|||
|
||||
ok()
|
||||
|
||||
proc isLondon(c: ChainConfig, number: BlockNumber): bool {.inline.} =
|
||||
number >= c.londonBlock
|
||||
|
||||
proc prepareBlock(engine: SealingEngineRef,
|
||||
parent: BlockHeader,
|
||||
time: Time,
|
||||
|
@ -86,22 +83,6 @@ proc prepareBlock(engine: SealingEngineRef,
|
|||
|
||||
var blk = engine.txPool.ethBlock()
|
||||
|
||||
# TODO: fix txPool GasLimit to match this GasLimit
|
||||
let conf = engine.chain.db.config
|
||||
if isLondon(conf, blk.header.blockNumber):
|
||||
var parentGasLimit = parent.gasLimit
|
||||
if not isLondon(conf, parent.blockNumber):
|
||||
# Bump by 2x
|
||||
parentGasLimit = parent.gasLimit * EIP1559_ELASTICITY_MULTIPLIER
|
||||
# TODO: desiredLimit can be configured by user, gasCeil
|
||||
blk.header.gasLimit = calcGasLimit1559(parentGasLimit, desiredLimit = DEFAULT_GAS_LIMIT)
|
||||
else:
|
||||
blk.header.gasLimit = computeGasLimit(
|
||||
parent.gasUsed,
|
||||
parent.gasLimit,
|
||||
gasFloor = DEFAULT_GAS_LIMIT,
|
||||
gasCeil = DEFAULT_GAS_LIMIT)
|
||||
|
||||
if engine.chain.isBlockAfterTtd(blk.header):
|
||||
blk.header.difficulty = DifficultyInt.zero
|
||||
blk.header.mixDigest = prevRandao
|
||||
|
|
|
@ -719,7 +719,12 @@ proc `baseFee=`*(xp: TxPoolRef; val: GasPrice)
|
|||
proc `lwmTrgPercent=`*(xp: TxPoolRef; val: int) =
|
||||
## Setter, `val` arguments outside `0..100` are ignored
|
||||
if 0 <= val and val <= 100:
|
||||
xp.chain.lhwm = (lwmTrg: val, hwmMax: xp.chain.lhwm.hwmMax)
|
||||
xp.chain.lhwm = (
|
||||
lwmTrg: val,
|
||||
hwmMax: xp.chain.lhwm.hwmMax,
|
||||
gasFloor: xp.chain.lhwm.gasFloor,
|
||||
gasCeil: xp.chain.lhwm.gasCeil
|
||||
)
|
||||
|
||||
proc `flags=`*(xp: TxPoolRef; val: set[TxPoolFlags])
|
||||
{.gcsafe,raises: [Defect,CatchableError].} =
|
||||
|
@ -729,7 +734,12 @@ proc `flags=`*(xp: TxPoolRef; val: set[TxPoolFlags])
|
|||
proc `hwmMaxPercent=`*(xp: TxPoolRef; val: int) =
|
||||
## Setter, `val` arguments outside `0..100` are ignored
|
||||
if 0 <= val and val <= 100:
|
||||
xp.chain.lhwm = (lwmTrg: xp.chain.lhwm.lwmTrg, hwmMax: val)
|
||||
xp.chain.lhwm = (
|
||||
lwmTrg: xp.chain.lhwm.lwmTrg,
|
||||
hwmMax: val,
|
||||
gasFloor: xp.chain.lhwm.gasFloor,
|
||||
gasCeil: xp.chain.lhwm.gasCeil
|
||||
)
|
||||
|
||||
proc `maxRejects=`*(xp: TxPoolRef; val: int) =
|
||||
## Setter, the size of the waste basket. This setting becomes effective with
|
||||
|
|
|
@ -128,6 +128,8 @@ proc new*(T: type TxChainRef; db: BaseChainDB; miner: EthAddress): T
|
|||
result.miner = miner
|
||||
result.lhwm.lwmTrg = TRG_THRESHOLD_PER_CENT
|
||||
result.lhwm.hwmMax = MAX_THRESHOLD_PER_CENT
|
||||
result.lhwm.gasFloor = DEFAULT_GAS_LIMIT
|
||||
result.lhwm.gasCeil = DEFAULT_GAS_LIMIT
|
||||
result.calcDifficulty = proc(timeStamp: EthTime, parent: BlockHeader):
|
||||
DifficultyInt {.gcsafe, raises:[].} =
|
||||
try:
|
||||
|
|
|
@ -17,8 +17,8 @@ import
|
|||
../../../chain_config,
|
||||
../../../db/db_chain,
|
||||
../../../constants,
|
||||
../../../forks,
|
||||
eth/[common]
|
||||
../../../utils/header,
|
||||
eth/[common, eip1559]
|
||||
|
||||
{.push raises: [Defect].}
|
||||
|
||||
|
@ -30,6 +30,10 @@ type
|
|||
hwmMax: int ##\
|
||||
## VM executor may stop if this per centage of `maxLimit` has
|
||||
## been reached.
|
||||
gasFloor: GasInt
|
||||
## minimum desired gas limit
|
||||
gasCeil: GasInt
|
||||
## maximum desired gas limit
|
||||
|
||||
TxChainGasLimits* = tuple
|
||||
gasLimit: GasInt ## Parent gas limit, used as a base for others
|
||||
|
@ -83,6 +87,9 @@ proc setPreLondonLimits(gl: var TxChainGasLimits) =
|
|||
gl.minLimit = gl.gasLimit - delta
|
||||
gl.trgLimit = gl.gasLimit
|
||||
|
||||
proc isLondon(c: ChainConfig, number: BlockNumber): bool {.inline.} =
|
||||
number >= c.londonBlock
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Public functions
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -92,9 +99,7 @@ proc gasLimitsGet*(db: BaseChainDB; parent: BlockHeader; parentLimit: GasInt;
|
|||
## Calculate gas limits for the next block header.
|
||||
result.gasLimit = parentLimit
|
||||
|
||||
let nextFork = db.config.toFork(parent.blockNumber + 1)
|
||||
|
||||
if FkLondon <= nextFork:
|
||||
if isLondon(db.config, parent.blockNumber+1):
|
||||
result.setPostLondonLimits
|
||||
else:
|
||||
result.setPreLondonLimits
|
||||
|
@ -106,6 +111,19 @@ proc gasLimitsGet*(db: BaseChainDB; parent: BlockHeader; parentLimit: GasInt;
|
|||
result.hwmLimit = max(
|
||||
result.trgLimit, (result.maxLimit * pc.hwmMax + 50) div 100)
|
||||
|
||||
# override trgLimit, see https://github.com/status-im/nimbus-eth1/issues/1032
|
||||
if isLondon(db.config, parent.blockNumber+1):
|
||||
var parentGasLimit = parent.gasLimit
|
||||
if not isLondon(db.config, parent.blockNumber):
|
||||
# Bump by 2x
|
||||
parentGasLimit = parent.gasLimit * EIP1559_ELASTICITY_MULTIPLIER
|
||||
result.trgLimit = calcGasLimit1559(parentGasLimit, desiredLimit = pc.gasCeil)
|
||||
else:
|
||||
result.trgLimit = computeGasLimit(
|
||||
parent.gasUsed,
|
||||
parent.gasLimit,
|
||||
gasFloor = pc.gasFloor,
|
||||
gasCeil = pc.gasCeil)
|
||||
|
||||
proc gasLimitsGet*(db: BaseChainDB; parent: BlockHeader;
|
||||
pc: TxChainGasLimitsPc): TxChainGasLimits =
|
||||
|
|
Loading…
Reference in New Issue