Connect gasLimit from Config to CommonRef (#2946)

This commit is contained in:
andri lim 2024-12-17 17:48:31 +07:00 committed by GitHub
parent 0b704040e3
commit f74813520a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 5 deletions

View File

@ -476,7 +476,12 @@ func `extraData=`*(com: CommonRef, val: string) =
com.extraData = val com.extraData = val
func `gasLimit=`*(com: CommonRef, val: uint64) = 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 # End

View File

@ -468,7 +468,6 @@ proc assembleBlock*(
## tuning parameters. The following block header fields are left ## tuning parameters. The following block header fields are left
## uninitialised: ## uninitialised:
## ##
## * *extraData*: Blob
## * *mixHash*: Hash32 ## * *mixHash*: Hash32
## * *nonce*: BlockNonce ## * *nonce*: BlockNonce
## ##

View File

@ -221,14 +221,14 @@ proc run(nimbus: NimbusNode, conf: NimbusConf) =
try: try:
if conf.numThreads < 0: if conf.numThreads < 0:
fatal "The number of threads --num-threads cannot be negative." fatal "The number of threads --num-threads cannot be negative."
quit 1 quit QuitFailure
elif conf.numThreads == 0: elif conf.numThreads == 0:
Taskpool.new(numThreads = min(countProcessors(), 16)) Taskpool.new(numThreads = min(countProcessors(), 16))
else: else:
Taskpool.new(numThreads = conf.numThreads) Taskpool.new(numThreads = conf.numThreads)
except CatchableError as e: except CatchableError as e:
fatal "Cannot start taskpool", err = e.msg fatal "Cannot start taskpool", err = e.msg
quit 1 quit QuitFailure
info "Threadpool started", numThreads = taskpool.numThreads info "Threadpool started", numThreads = taskpool.numThreads
@ -244,7 +244,15 @@ proc run(nimbus: NimbusNode, conf: NimbusConf) =
extraData=conf.extraData, extraData=conf.extraData,
len=conf.extraData.len 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.extraData = conf.extraData
com.gasLimit = conf.gasLimit
defer: defer:
com.db.finish() com.db.finish()