From 89fac051cdce15a3fbf3b49ae182e78bdc0f6a51 Mon Sep 17 00:00:00 2001 From: andri lim Date: Sun, 3 Nov 2024 07:11:24 +0700 Subject: [PATCH] Reduce declared but not used warnings (#2822) --- hive_integration/nodocker/engine/node.nim | 2 +- hive_integration/nodocker/pyspec/test_env.nim | 1 - hive_integration/nodocker/rpc/client.nim | 5 ----- nimbus/config.nim | 1 - nimbus/db/aristo/aristo_check/check_be.nim | 2 +- nimbus/db/aristo/aristo_fetch.nim | 13 ------------- nimbus/db/aristo/aristo_nearby.nim | 2 +- nimbus/db/aristo/aristo_part/part_chain_rlp.nim | 2 +- nimbus/db/core_db/backend/aristo_trace.nim | 15 --------------- nimbus/sync/beacon/worker.nim | 2 -- nimbus/sync/beacon/worker/db.nim | 2 +- nimbus/tracer.nim | 1 - tests/test_aristo/test_helpers.nim | 2 +- tests/test_ledger.nim | 5 ----- tests/test_rpc.nim | 10 +++++----- 15 files changed, 11 insertions(+), 54 deletions(-) diff --git a/hive_integration/nodocker/engine/node.nim b/hive_integration/nodocker/engine/node.nim index 8109ba90c..390f9fafa 100644 --- a/hive_integration/nodocker/engine/node.nim +++ b/hive_integration/nodocker/engine/node.nim @@ -99,7 +99,7 @@ proc setBlock*(c: ChainRef; blk: Block): Result[void, string] = let vmState = c.getVmState(header).valueOr: return err("no vmstate") - stateRootChpt = vmState.parent.stateRoot # Check point + _ = vmState.parent.stateRoot # Check point ? vmState.processBlock(blk) if not c.db.persistHeader( diff --git a/hive_integration/nodocker/pyspec/test_env.nim b/hive_integration/nodocker/pyspec/test_env.nim index 9e41881de..bced73a2d 100644 --- a/hive_integration/nodocker/pyspec/test_env.nim +++ b/hive_integration/nodocker/pyspec/test_env.nim @@ -13,7 +13,6 @@ import stew/[byteutils], json_rpc/[rpcserver, rpcclient], ../../../nimbus/[ - config, constants, transaction, db/ledger, diff --git a/hive_integration/nodocker/rpc/client.nim b/hive_integration/nodocker/rpc/client.nim index 44086ea2a..c8bf600dd 100644 --- a/hive_integration/nodocker/rpc/client.nim +++ b/hive_integration/nodocker/rpc/client.nim @@ -43,11 +43,6 @@ proc nonceAt*(client: RpcClient, address: Address): Future[AccountNonce] {.async let hex = await client.eth_getTransactionCount(address, blockId("latest")) result = hex.AccountNonce -func toTopics(list: openArray[Hash32]): seq[eth_types.Topic] = - result = newSeqOfCap[eth_types.Topic](list.len) - for x in list: - result.add eth_types.Topic(x) - func toLogs(list: openArray[LogObject]): seq[Log] = result = newSeqOfCap[Log](list.len) for x in list: diff --git a/nimbus/config.nim b/nimbus/config.nim index 76e1c2faf..716cdd590 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -11,7 +11,6 @@ import std/[ options, - strformat, strutils, times, os, diff --git a/nimbus/db/aristo/aristo_check/check_be.nim b/nimbus/db/aristo/aristo_check/check_be.nim index 6bee548d4..e7d98f229 100644 --- a/nimbus/db/aristo/aristo_check/check_be.nim +++ b/nimbus/db/aristo/aristo_check/check_be.nim @@ -52,7 +52,7 @@ proc checkBE*[T: RdbBackendRef|MemBackendRef|VoidBackendRef]( for (rvid,key) in T.walkKeyBe db: if topVidBe.vid < rvid.vid: topVidBe = rvid - let vtx = db.getVtxBE(rvid).valueOr: + let _ = db.getVtxBE(rvid).valueOr: return err((rvid.vid,CheckBeVtxMissing)) # Compare calculated `vTop` against database state diff --git a/nimbus/db/aristo/aristo_fetch.nim b/nimbus/db/aristo/aristo_fetch.nim index c1a9ae0c8..7e40adf62 100644 --- a/nimbus/db/aristo/aristo_fetch.nim +++ b/nimbus/db/aristo/aristo_fetch.nim @@ -96,19 +96,6 @@ proc retrieveMerkleHash( key ok key.to(Hash32) - -proc hasPayload( - db: AristoDbRef; - root: VertexID; - path: openArray[byte]; - ): Result[bool,AristoError] = - let error = db.retrieveLeaf(root, path).errorOr: - return ok(true) - - if error == FetchPathNotFound: - return ok(false) - err(error) - proc hasAccountPayload( db: AristoDbRef; accPath: Hash32; diff --git a/nimbus/db/aristo/aristo_nearby.nim b/nimbus/db/aristo/aristo_nearby.nim index f556dca52..cfc850e52 100644 --- a/nimbus/db/aristo/aristo_nearby.nim +++ b/nimbus/db/aristo/aristo_nearby.nim @@ -21,7 +21,7 @@ {.push raises: [].} import - std/[tables, typetraits], + std/[tables], eth/common, results, "."/[aristo_desc, aristo_fetch, aristo_get, aristo_hike, aristo_path] diff --git a/nimbus/db/aristo/aristo_part/part_chain_rlp.nim b/nimbus/db/aristo/aristo_part/part_chain_rlp.nim index 05760d55f..bb4cb6078 100644 --- a/nimbus/db/aristo/aristo_part/part_chain_rlp.nim +++ b/nimbus/db/aristo/aristo_part/part_chain_rlp.nim @@ -37,7 +37,7 @@ proc chainRlpNodes*( ): Result[void,AristoError] = ## Inspired by the `getBranchAux()` function from `hexary.nim` let - key = ? db.computeKey rvid + _ = ? db.computeKey rvid (vtx,_) = ? db.getVtxRc rvid node = vtx.toNode(rvid.root, db).valueOr: return err(PartChnNodeConvError) diff --git a/nimbus/db/core_db/backend/aristo_trace.nim b/nimbus/db/core_db/backend/aristo_trace.nim index 792fbdd4e..5322b57fe 100644 --- a/nimbus/db/core_db/backend/aristo_trace.nim +++ b/nimbus/db/core_db/backend/aristo_trace.nim @@ -230,21 +230,6 @@ proc jLogger( ) = tr.jLogger(EmptyBlob, ti) -proc jLogger( - tr: TraceRecorderRef; - root: VertexID; - path: openArray[byte]; - ti: TraceDataItemRef; - ) = - tr.jLogger(@[root.byte] & @path, ti) - -proc jLogger( - tr: TraceRecorderRef; - root: VertexID; - ti: TraceDataItemRef; - ) = - tr.jLogger(@[root.byte], ti) - proc jLogger( tr: TraceRecorderRef; accPath: Hash32; diff --git a/nimbus/sync/beacon/worker.nim b/nimbus/sync/beacon/worker.nim index a4c5aec1a..95ddc02cb 100644 --- a/nimbus/sync/beacon/worker.nim +++ b/nimbus/sync/beacon/worker.nim @@ -156,8 +156,6 @@ proc runPeer*(buddy: BeaconBuddyRef; info: static[string]) {.async.} = ## This peer worker method is repeatedly invoked (exactly one per peer) while ## the `buddy.ctrl.poolMode` flag is set `false`. ## - let peer = buddy.peer - if 0 < buddy.only.nMultiLoop: # statistics/debugging buddy.only.multiRunIdle = Moment.now() - buddy.only.stoppedMultiRun buddy.only.nMultiLoop.inc # statistics/debugging diff --git a/nimbus/sync/beacon/worker/db.nim b/nimbus/sync/beacon/worker/db.nim index d8ae4c2f0..feb53ea2f 100644 --- a/nimbus/sync/beacon/worker/db.nim +++ b/nimbus/sync/beacon/worker/db.nim @@ -224,7 +224,7 @@ proc dbPeekParentHash*(ctx: BeaconCtxRef; num: BlockNumber): Opt[Hash32] = proc dbUnstashHeader*(ctx: BeaconCtxRef; bn: BlockNumber) = ## Remove header from temporary DB list - ctx.stash.withValue(bn, val): + ctx.stash.withValue(bn, _): ctx.stash.del bn return discard ctx.db.ctx.getKvt().del(beaconHeaderKey(bn).toOpenArray) diff --git a/nimbus/tracer.nim b/nimbus/tracer.nim index 0cc7aa160..0704a4869 100644 --- a/nimbus/tracer.nim +++ b/nimbus/tracer.nim @@ -246,7 +246,6 @@ proc dumpBlockStateImpl( let cc = activate CaptCtxRef.init(com, header) - parent = com.db.getBlockHeader(header.parentHash) # only need a stack dump when scanning for internal transaction address captureFlags = {DisableMemory, DisableStorage, EnableAccount} diff --git a/tests/test_aristo/test_helpers.nim b/tests/test_aristo/test_helpers.nim index d65ef6ae9..c2a7e830a 100644 --- a/tests/test_aristo/test_helpers.nim +++ b/tests/test_aristo/test_helpers.nim @@ -13,7 +13,7 @@ import eth/common, stew/endians2, ../../nimbus/db/aristo/[ - aristo_debug, aristo_desc, aristo_hike, aristo_layers, aristo_merge, + aristo_debug, aristo_desc, aristo_hike, aristo_layers, aristo_tx], ../replay/pp, "."/[undump_accounts, undump_desc, undump_storages, test_samples_xx] diff --git a/tests/test_ledger.nim b/tests/test_ledger.nim index 06586d7de..2edea1be0 100644 --- a/tests/test_ledger.nim +++ b/tests/test_ledger.nim @@ -348,7 +348,6 @@ proc runLedgerTransactionTests(noisy = true) = env.txi.add n test &"Run {env.txi.len} two-step trials with rollback": - let head = env.xdb.getCanonicalHead() for n in env.txi: let dbTx = env.xdb.ctx.newTransaction() defer: dbTx.dispose() @@ -356,7 +355,6 @@ proc runLedgerTransactionTests(noisy = true) = env.runTrial2ok(ledger, n) test &"Run {env.txi.len} three-step trials with rollback": - let head = env.xdb.getCanonicalHead() for n in env.txi: let dbTx = env.xdb.ctx.newTransaction() defer: dbTx.dispose() @@ -365,7 +363,6 @@ proc runLedgerTransactionTests(noisy = true) = test &"Run {env.txi.len} three-step trials with extra db frame rollback" & " throwing Exceptions": - let head = env.xdb.getCanonicalHead() for n in env.txi: let dbTx = env.xdb.ctx.newTransaction() defer: dbTx.dispose() @@ -373,7 +370,6 @@ proc runLedgerTransactionTests(noisy = true) = env.runTrial3Survive(ledger, n, noisy) test &"Run {env.txi.len} tree-step trials without rollback": - let head = env.xdb.getCanonicalHead() for n in env.txi: let dbTx = env.xdb.ctx.newTransaction() defer: dbTx.dispose() @@ -381,7 +377,6 @@ proc runLedgerTransactionTests(noisy = true) = env.runTrial3(ledger, n, rollback = false) test &"Run {env.txi.len} four-step trials with rollback and db frames": - let head = env.xdb.getCanonicalHead() for n in env.txi: let dbTx = env.xdb.ctx.newTransaction() defer: dbTx.dispose() diff --git a/tests/test_rpc.nim b/tests/test_rpc.nim index bbca1d1fb..d3f9b81e1 100644 --- a/tests/test_rpc.nim +++ b/tests/test_rpc.nim @@ -93,7 +93,7 @@ proc close(client: RpcHttpClient, server: RpcHttpServer) = # unless the base distance is reached. This is not the case for the tests, so we # have to manually persist the blocks to the db. # Main goal of the tests to check the RPC calls, can serve data persisted in the db -# as data from memory blocks are easily tested via kurtosis or other tests +# as data from memory blocks are easily tested via kurtosis or other tests proc setupEnv(signer, ks2: Address, ctx: EthContext, com: CommonRef): TestEnv = var acc = ctx.am.getAccount(signer).tryGet() @@ -201,7 +201,7 @@ proc setupEnv(signer, ks2: Address, ctx: EthContext, com: CommonRef): TestEnv = doAssert com.db.persistHeader(header, com.pos.isNil, com.startOfHistory) - + com.db.persistFixtureBlock() com.db.persistent(header.number).isOkOr: @@ -212,7 +212,7 @@ proc setupEnv(signer, ks2: Address, ctx: EthContext, com: CommonRef): TestEnv = txHash: signedTx1.rlpHash, blockHash: header.blockHash ) - + proc rpcMain*() = suite "Remote Procedure Calls": @@ -242,7 +242,7 @@ proc rpcMain*() = debugEcho unlock.error doAssert(unlock.isOk) - let + let env = setupEnv(signer, ks2, ctx, com) chain = ForkedChainRef.init(com) txPool = TxPoolRef.new(com) @@ -370,7 +370,7 @@ proc rpcMain*() = let msgData = "\x19Ethereum Signed Message:\n" & $msg.len & msg let msgDataBytes = @(msgData.toOpenArrayByte(0, msgData.len-1)) let msgHash = await client.web3_sha3(msgDataBytes) - let pubkey = recover(sig, SkMessage(msgHash.bytes)).tryGet() + let pubkey = recover(sig, SkMessage(msgHash.data)).tryGet() let recoveredAddr = pubkey.toCanonicalAddress() check recoveredAddr == signer # verified