Skip to content

Commit

Permalink
Reduce declared but not used warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Nov 2, 2024
1 parent 4ffe056 commit 32194d1
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 54 deletions.
2 changes: 1 addition & 1 deletion hive_integration/nodocker/engine/node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion hive_integration/nodocker/pyspec/test_env.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import
stew/[byteutils],
json_rpc/[rpcserver, rpcclient],
../../../nimbus/[
config,
constants,
transaction,
db/ledger,
Expand Down
5 changes: 0 additions & 5 deletions hive_integration/nodocker/rpc/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion nimbus/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import
std/[
options,
strformat,
strutils,
times,
os,
Expand Down
2 changes: 1 addition & 1 deletion nimbus/db/aristo/aristo_check/check_be.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions nimbus/db/aristo/aristo_fetch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion nimbus/db/aristo/aristo_nearby.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion nimbus/db/aristo/aristo_part/part_chain_rlp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 0 additions & 15 deletions nimbus/db/core_db/backend/aristo_trace.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions nimbus/sync/beacon/worker.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nimbus/sync/beacon/worker/db.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion nimbus/tracer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_aristo/test_helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 0 additions & 5 deletions tests/test_ledger.nim
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,13 @@ 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()
let ledger = env.com.getLedger()
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()
Expand All @@ -365,23 +363,20 @@ 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()
let ledger = env.com.getLedger()
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()
let ledger = env.com.getLedger()
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()
Expand Down
10 changes: 5 additions & 5 deletions tests/test_rpc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand All @@ -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":
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 32194d1

Please sign in to comment.