From f74813520aec38231563b538c0560e1edea1b1db Mon Sep 17 00:00:00 2001 From: andri lim Date: Tue, 17 Dec 2024 17:48:31 +0700 Subject: [PATCH] Connect gasLimit from Config to CommonRef (#2946) --- nimbus/common/common.nim | 7 ++++++- nimbus/core/tx_pool.nim | 1 - nimbus/nimbus_execution_client.nim | 14 +++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/nimbus/common/common.nim b/nimbus/common/common.nim index ffbca004ec..d16fefa4a5 100644 --- a/nimbus/common/common.nim +++ b/nimbus/common/common.nim @@ -476,7 +476,12 @@ func `extraData=`*(com: CommonRef, val: string) = com.extraData = val func `gasLimit=`*(com: CommonRef, val: uint64) = - com.gasLimit = val + if val < GAS_LIMIT_MINIMUM: + com.gasLimit = GAS_LIMIT_MINIMUM + elif val > GAS_LIMIT_MAXIMUM: + com.gasLimit = GAS_LIMIT_MAXIMUM + else: + com.gasLimit = val # ------------------------------------------------------------------------------ # End diff --git a/nimbus/core/tx_pool.nim b/nimbus/core/tx_pool.nim index abd264ff5b..30bda40395 100644 --- a/nimbus/core/tx_pool.nim +++ b/nimbus/core/tx_pool.nim @@ -468,7 +468,6 @@ proc assembleBlock*( ## tuning parameters. The following block header fields are left ## uninitialised: ## - ## * *extraData*: Blob ## * *mixHash*: Hash32 ## * *nonce*: BlockNonce ## diff --git a/nimbus/nimbus_execution_client.nim b/nimbus/nimbus_execution_client.nim index 478f696333..959125b881 100644 --- a/nimbus/nimbus_execution_client.nim +++ b/nimbus/nimbus_execution_client.nim @@ -44,7 +44,7 @@ proc basicServices(nimbus: NimbusNode, conf: NimbusConf, com: CommonRef) = nimbus.chainRef = ForkedChainRef.init(com) - + # txPool must be informed of active head # so it can know the latest account state # e.g. sender nonce, etc @@ -221,14 +221,14 @@ proc run(nimbus: NimbusNode, conf: NimbusConf) = try: if conf.numThreads < 0: fatal "The number of threads --num-threads cannot be negative." - quit 1 + quit QuitFailure elif conf.numThreads == 0: Taskpool.new(numThreads = min(countProcessors(), 16)) else: Taskpool.new(numThreads = conf.numThreads) except CatchableError as e: fatal "Cannot start taskpool", err = e.msg - quit 1 + quit QuitFailure info "Threadpool started", numThreads = taskpool.numThreads @@ -244,7 +244,15 @@ proc run(nimbus: NimbusNode, conf: NimbusConf) = extraData=conf.extraData, len=conf.extraData.len + if conf.gasLimit > GAS_LIMIT_MAXIMUM or + conf.gasLimit < GAS_LIMIT_MINIMUM: + warn "GasLimit not in expected range, truncate", + min=GAS_LIMIT_MINIMUM, + max=GAS_LIMIT_MAXIMUM, + get=conf.gasLimit + com.extraData = conf.extraData + com.gasLimit = conf.gasLimit defer: com.db.finish()