small cleanups (#2598)

* small cleanups

* stop hiding ConvFromXtoItselfNotNeeded hints

* lowmem optimization flag is no-op
This commit is contained in:
tersec 2024-09-10 05:24:45 +00:00 committed by GitHub
parent 0869a27462
commit 1b173d420d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 9 additions and 56 deletions

View File

@ -191,11 +191,6 @@ ifneq ($(ENABLE_EVMC), 0)
T8N_PARAMS := -d:chronicles_enabled=off
endif
# disabled by default, enable with ENABLE_VMLOWMEM=1
ifneq ($(if $(ENABLE_VMLOWMEM),$(ENABLE_VMLOWMEM),0),0)
NIM_PARAMS += -d:lowmem:1
endif
# eth protocol settings, rules from "nimbus/sync/protocol/eth/variables.mk"
NIM_PARAMS := $(NIM_PARAMS) $(NIM_ETH_PARAMS)

View File

@ -211,11 +211,6 @@ available.)
* ENABLE_EVMC=1<br>
Enable mostly EVMC compliant wrapper around the native Nim VM
* ENABLE_VMLOWMEM=1<br>
Enable low-memory version of the native Nim VM. This version is not
optimised and coded in a way so that low memory compilers can handle it
(observed on 32 bit windows 7.)
For these variables, using &lt;variable&gt;=0 is ignored and &lt;variable&gt;=2
has the same effect as &lt;variable&gt;=1 (ditto for other numbers.)

View File

@ -16,5 +16,4 @@
--styleCheck:usages
--styleCheck:error
--hint[ConvFromXtoItselfNotNeeded]:off
--hint[Processing]:off

View File

@ -154,7 +154,7 @@ proc initializeDb(com: CommonRef) =
finalized =
try:
com.db.finalizedHeader()
except BlockNotFound as exc:
except BlockNotFound:
debug "No finalized block stored in database, reverting to base"
base
head =

View File

@ -117,7 +117,7 @@ proc partUntwigGeneric*(
try:
let nibbles = NibblesBuf.fromBytes path
return chain.trackRlpNodes(root.to(HashKey), nibbles, start=true)
except RlpError as e:
except RlpError:
return err(PartTrkRlpError)
proc partUntwigPath*(

View File

@ -124,7 +124,7 @@ func toNodesTab*(
# Decode blob `w`
let nd = block:
try: rlp.decode(w, PrfNode)
except RlpError as e:
except RlpError:
return err(PartRlpNodeException)
case nd.prfType:
@ -142,7 +142,7 @@ func toNodesTab*(
var pyl: PrfPayload
try:
pyl = rlp.decode(nd.lData.rawBlob, PrfPayload)
except RlpError as e:
except RlpError:
pyl = PrfPayload(prfType: isError, error: PartRlpPayloadException)
case pyl.prfType:

View File

@ -8,10 +8,7 @@
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
const
# help with low memory when compiling selectVM() function
lowmem {.intdefine.}: int = 0
lowMemoryCompileTime {.used.} = lowmem > 0
{.push raises: [].}
import
std/[macros, strformat],
@ -19,9 +16,7 @@ import
".."/[constants, db/ledger],
"."/[code_stream, computation, evm_errors],
"."/[message, precompiles, state, types],
./interpreter/[op_dispatcher, gas_costs]
{.push raises: [].}
./interpreter/op_dispatcher
logScope:
topics = "vm opcode"
@ -30,14 +25,6 @@ logScope:
# Private functions
# ------------------------------------------------------------------------------
const
supportedOS = defined(windows) or defined(linux) or defined(macosx)
optimizationCondition = not lowMemoryCompileTime and defined(release) and supportedOS
when optimizationCondition:
# this is a top level pragma since nim 1.6.16
{.optimization: speed.}
proc runVM(
c: VmCpt,
shouldPrepareTracer: bool,

View File

@ -60,7 +60,7 @@ proc ledgerFromTag(api: ServerAPIRef, blockTag: BlockTag): Result[LedgerRef, str
# TODO: Replay state?
err("Block state not ready")
proc blockFromTag(api: ServerAPIRef, blockTag: BlockTag): Result[EthBlock, string] =
func blockFromTag(api: ServerAPIRef, blockTag: BlockTag): Result[EthBlock, string] =
if blockTag.kind == bidAlias:
let tag = blockTag.alias.toLowerAscii
case tag
@ -71,12 +71,7 @@ proc blockFromTag(api: ServerAPIRef, blockTag: BlockTag): Result[EthBlock, strin
let blockNum = common.BlockNumber blockTag.number
return api.chain.blockByNumber(blockNum)
proc blockFromTag(api: ServerAPIRef, blockTag: Opt[BlockTag]): Result[EthBlock, string] =
let blockId = blockTag.get(defaultTag)
api.blockFromTag(blockId)
proc setupServerAPI*(api: ServerAPIRef, server: RpcServer) =
server.rpc("eth_getBalance") do(data: Web3Address, blockTag: BlockTag) -> UInt256:
## Returns the balance of the account of given address.
let

View File

@ -63,8 +63,7 @@ proc init(
T: type CaptCtxRef;
com: CommonRef;
root: common.Hash256;
): T
{.raises: [CatchableError].} =
): T =
let ctx = block:
let rc = com.db.ctx.newCtxByKey(root)
if rc.isErr:

View File

@ -19,5 +19,4 @@
--styleCheck:usages
--styleCheck:error
--hint[ConvFromXtoItselfNotNeeded]:off
--hint[Processing]:off

View File

@ -17,7 +17,7 @@ import
../nimbus/core/chain,
../nimbus/common,
../nimbus/db/opts,
../nimbus/db/[core_db/persistent, storage_types],
../nimbus/db/core_db/persistent,
configuration # must be late (compilation annoyance)
when defined(graphql):
@ -25,18 +25,6 @@ when defined(graphql):
else:
import downloader
# `lmdb` is not used, anymore
#
# const
# manualCommit = nimbus_db_backend == "lmdb"
#
# template persistToDb(db: ChainDB, body: untyped) =
# when manualCommit:
# if not db.txBegin(): doAssert(false)
# body
# when manualCommit:
# if not db.txCommit(): doAssert(false)
template persistToDb(db: CoreDbRef, body: untyped) =
block: body

View File

@ -125,10 +125,6 @@ proc testMergeProofAndKvpList*(
# Update root
rootKey = w.root
let
db = ps.db
testId = idPfx & "#" & $w.id & "." & $n
if 0 < w.proof.len:
let rc = ps.partPut(w.proof, ForceGenericPayload)
xCheckRc rc.error == 0