Skip to content

Commit

Permalink
Connect gasLimit from Config to CommonRef (#2946)
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko authored Dec 17, 2024
1 parent 0b70404 commit f748135
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 6 additions & 1 deletion nimbus/common/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion nimbus/core/tx_pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ proc assembleBlock*(
## tuning parameters. The following block header fields are left
## uninitialised:
##
## * *extraData*: Blob
## * *mixHash*: Hash32
## * *nonce*: BlockNonce
##
Expand Down
14 changes: 11 additions & 3 deletions nimbus/nimbus_execution_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand Down

0 comments on commit f748135

Please sign in to comment.