From 1d5a48e1539a732a672df742d3faebf4b791aacc Mon Sep 17 00:00:00 2001 From: andri lim Date: Fri, 13 Dec 2024 10:47:35 +0700 Subject: [PATCH] Feature: configurable gas limit when building execution payload (#2931) * Feature: configurable gas limit when building execution payload * Raise default gas limit to 30M --- nimbus/common/common.nim | 12 +++++++++++- nimbus/config.nim | 9 ++++++++- nimbus/constants.nim | 2 +- nimbus/core/tx_pool/tx_desc.nim | 6 +++--- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/nimbus/common/common.nim b/nimbus/common/common.nim index 5b93bca7f..b80d398fd 100644 --- a/nimbus/common/common.nim +++ b/nimbus/common/common.nim @@ -95,7 +95,10 @@ type ## Must not not set for a full node, might go away some time extraData: string - ## Value of extraData field when building block + ## Value of extraData field when building a block + + gasLimit: uint64 + ## Desired gas limit when building a block # ------------------------------------------------------------------------------ # Forward declarations @@ -181,6 +184,7 @@ proc init(com : CommonRef, com.pruneHistory= pruneHistory com.pos = CasperRef.new com.extraData = ShortClientId + com.gasLimit = DEFAULT_GAS_LIMIT # com.forkIdCalculator and com.genesisHash are set # by setForkId @@ -419,6 +423,9 @@ func syncState*(com: CommonRef): SyncState = func extraData*(com: CommonRef): string = com.extraData +func gasLimit*(com: CommonRef): uint64 = + com.gasLimit + # ------------------------------------------------------------------------------ # Setters # ------------------------------------------------------------------------------ @@ -460,6 +467,9 @@ func `notifyBadBlock=`*(com: CommonRef; cb: NotifyBadBlockCB) = func `extraData=`*(com: CommonRef, val: string) = com.extraData = val +func `gasLimit=`*(com: CommonRef, val: uint64) = + com.gasLimit = val + # ------------------------------------------------------------------------------ # End # ------------------------------------------------------------------------------ diff --git a/nimbus/config.nim b/nimbus/config.nim index 270069e40..004c2462e 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -179,11 +179,18 @@ type name: "trusted-setup-file" .}: Option[string] extraData* {. - desc: "Value of extraData field when assemble a block(max 32 bytes)" + separator: "\pPAYLOAD BUILDING OPTIONS:" + desc: "Value of extraData field when building an execution payload(max 32 bytes)" defaultValue: ShortClientId defaultValueDesc: $ShortClientId name: "extra-data" .}: string + gasLimit* {. + desc: "Desired gas limit when building an execution payload" + defaultValue: DEFAULT_GAS_LIMIT + defaultValueDesc: $DEFAULT_GAS_LIMIT + name: "gas-limit" .}: uint64 + network {. separator: "\pETHEREUM NETWORK OPTIONS:" desc: "Name or id number of Ethereum network(mainnet(1), sepolia(11155111), holesky(17000), other=custom)" diff --git a/nimbus/constants.nim b/nimbus/constants.nim index 1006cfc29..269b8876a 100644 --- a/nimbus/constants.nim +++ b/nimbus/constants.nim @@ -49,7 +49,7 @@ const GENESIS_EXTRA_DATA* = "" GAS_LIMIT_MINIMUM* = 5000 GAS_LIMIT_MAXIMUM* = int64.high.GasInt # Maximum the gas limit (2^63-1). - DEFAULT_GAS_LIMIT* = 8_000_000 + DEFAULT_GAS_LIMIT* = 30_000_000 EMPTY_SHA3* = hash32"c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" diff --git a/nimbus/core/tx_pool/tx_desc.nim b/nimbus/core/tx_pool/tx_desc.nim index 5e981b517..1a9e4bfdc 100644 --- a/nimbus/core/tx_pool/tx_desc.nim +++ b/nimbus/core/tx_pool/tx_desc.nim @@ -100,13 +100,13 @@ proc gasLimitsGet(com: CommonRef; parent: Header): GasInt = if not com.isLondonOrLater(parent.number): # Bump by 2x parentGasLimit = parent.gasLimit * EIP1559_ELASTICITY_MULTIPLIER - calcGasLimit1559(parentGasLimit, desiredLimit = DEFAULT_GAS_LIMIT) + calcGasLimit1559(parentGasLimit, desiredLimit = com.gasLimit) else: computeGasLimit( parent.gasUsed, parent.gasLimit, - gasFloor = DEFAULT_GAS_LIMIT, - gasCeil = DEFAULT_GAS_LIMIT) + gasFloor = com.gasLimit, + gasCeil = com.gasLimit) proc setupVMState(com: CommonRef; parent: Header): BaseVMState = # do hardfork transition before