From 7c1af9a78f33adc0f856b8e4278692520cde6c2e Mon Sep 17 00:00:00 2001 From: andri lim Date: Tue, 20 Feb 2024 10:07:38 +0700 Subject: [PATCH] Add style check to config.nims and fix styles in source code (#2038) * Add style check to config.nims and fix styles in source code * Fix copyright year --- config.nims | 2 ++ nimbus/beacon/beacon_engine.nim | 4 ++-- nimbus/beacon/payload_conv.nim | 8 ++++---- nimbus/common/common.nim | 4 ++-- nimbus/core/eip4844.nim | 8 ++++---- nimbus/core/tx_pool.nim | 8 ++++---- nimbus/core/tx_pool/tx_tasks/tx_classify.nim | 2 +- nimbus/core/validate.nim | 6 +++--- nimbus/db/aristo/aristo_blobify.nim | 16 ++++++++-------- nimbus/db/aristo/aristo_desc/desc_structural.nim | 4 ++-- nimbus/db/aristo/aristo_path.nim | 2 +- nimbus/db/aristo/aristo_utils.nim | 4 ++-- nimbus/db/core_db/backend/legacy_db.nim | 2 +- nimbus/db/ledger/distinct_ledgers.nim | 12 ++++++------ nimbus/evm/computation.nim | 4 ++-- nimbus/evm/interpreter_dispatch.nim | 14 +++++++------- nimbus/evm/modexp.nim | 5 +++-- nimbus/graphql/ethapi.nim | 4 ++-- nimbus/rpc/rpc_utils.nim | 4 ++-- nimbus/sync/beacon/skeleton_algo.nim | 10 +++++----- nimbus/sync/beacon/skeleton_desc.nim | 4 ++-- nimbus/sync/snap/worker/db/hexary_nearby.nim | 4 ++-- .../sync/snap/worker/db/hexary_nodes_helper.nim | 6 +++--- nimbus/sync/snap/worker/db/snapdb_persistent.nim | 6 +++--- nimbus/sync/snap/worker/get/get_trie_nodes.nim | 4 ++-- nimbus/transaction/call_common.nim | 4 ++-- 26 files changed, 77 insertions(+), 74 deletions(-) diff --git a/config.nims b/config.nims index 595b317bf..3d9268e87 100644 --- a/config.nims +++ b/config.nims @@ -105,6 +105,8 @@ if not defined(windows): --define:metrics # for heap-usage-by-instance-type metrics and object base-type strings --define:nimTypeNames +--styleCheck:usages +--styleCheck:hint switch("define", "withoutPCRE") diff --git a/nimbus/beacon/beacon_engine.nim b/nimbus/beacon/beacon_engine.nim index b8e372e49..2f445436f 100644 --- a/nimbus/beacon/beacon_engine.nim +++ b/nimbus/beacon/beacon_engine.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2023 Status Research & Development GmbH +# Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) # * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -73,7 +73,7 @@ proc reachTTD*(ben: BeaconEngineRef) = proc finalizePoS*(ben: BeaconEngineRef) = ## FinalizePoS is called whenever the first FinalisedBlock message received ## from the consensus-layer. - ben.merge.finalizePos() + ben.merge.finalizePoS() proc put*(ben: BeaconEngineRef, hash: common.Hash256, header: common.BlockHeader) = diff --git a/nimbus/beacon/payload_conv.nim b/nimbus/beacon/payload_conv.nim index a80b2b9bf..34cadc55f 100644 --- a/nimbus/beacon/payload_conv.nim +++ b/nimbus/beacon/payload_conv.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2023 Status Research & Development GmbH +# Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) # * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -19,18 +19,18 @@ import func wdRoot(list: openArray[WithdrawalV1]): common.Hash256 {.gcsafe, raises:[].} = - {.nosideEffect.}: + {.noSideEffect.}: calcWithdrawalsRoot(ethWithdrawals list) func wdRoot(x: Option[seq[WithdrawalV1]]): Option[common.Hash256] {.gcsafe, raises:[].} = - {.nosideEffect.}: + {.noSideEffect.}: if x.isNone: none(common.Hash256) else: some(wdRoot x.get) func txRoot(list: openArray[Web3Tx]): common.Hash256 {.gcsafe, raises:[RlpError].} = - {.nosideEffect.}: + {.noSideEffect.}: calcTxRoot(ethTxs(list, removeBlobs = true)) # ------------------------------------------------------------------------------ diff --git a/nimbus/common/common.nim b/nimbus/common/common.nim index 0ab15e3f4..b13616e4e 100644 --- a/nimbus/common/common.nim +++ b/nimbus/common/common.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2022-2023 Status Research & Development GmbH +# Copyright (c) 2022-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) # * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -533,7 +533,7 @@ proc setTTD*(com: CommonRef, ttd: Option[DifficultyInt]) = # rebuild the MergeFork piece of the forkTransitionTable com.forkTransitionTable.mergeForkTransitionThreshold = com.config.mergeForkTransitionThreshold -proc setFork*(com: CommonRef, fork: HardFork): Hardfork = +proc setFork*(com: CommonRef, fork: HardFork): HardFork = ## useful for testing result = com.currentFork com.currentFork = fork diff --git a/nimbus/core/eip4844.nim b/nimbus/core/eip4844.nim index d4ba1ee1a..bd2007415 100644 --- a/nimbus/core/eip4844.nim +++ b/nimbus/core/eip4844.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2023 Status Research & Development GmbH +# Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -111,10 +111,10 @@ proc getTotalBlobGas*(tx: Transaction): uint64 = GAS_PER_BLOB * tx.versionedHashes.len.uint64 proc getTotalBlobGas*(versionedHashesLen: int): uint64 = - GAS_PER_BLOB * versionedHasheslen.uint64 + GAS_PER_BLOB * versionedHashesLen.uint64 # getBlobGasPrice implements get_data_gas_price from EIP-4844 -func getBlobGasprice*(excessBlobGas: uint64): UInt256 = +func getBlobGasPrice*(excessBlobGas: uint64): UInt256 = fakeExponential( MIN_BLOB_GASPRICE.u256, excessBlobGas.u256, @@ -124,7 +124,7 @@ func getBlobGasprice*(excessBlobGas: uint64): UInt256 = proc calcDataFee*(versionedHashesLen: int, excessBlobGas: uint64): UInt256 = getTotalBlobGas(versionedHashesLen).u256 * - getBlobGasprice(excessBlobGas) + getBlobGasPrice(excessBlobGas) func blobGasUsed(txs: openArray[Transaction]): uint64 = for tx in txs: diff --git a/nimbus/core/tx_pool.nim b/nimbus/core/tx_pool.nim index e83378dd4..ed5ff0eac 100644 --- a/nimbus/core/tx_pool.nim +++ b/nimbus/core/tx_pool.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2023 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -554,7 +554,7 @@ proc smartHead*(xp: TxPoolRef; pos: BlockHeader; blindMode = false): bool ## simply set ignoring all changes. This mode makes sense only in very ## particular circumstances. if blindMode: - xp.sethead(pos) + xp.setHead(pos) return true let rcDiff = xp.headDiff(pos) @@ -563,7 +563,7 @@ proc smartHead*(xp: TxPoolRef; pos: BlockHeader; blindMode = false): bool # Need to move head before adding txs which may rightly be rejected in # `addTxs()` otherwise. - xp.sethead(pos) + xp.setHead(pos) # Re-inject transactions, do that via job queue if 0 < changes.addTxs.len: @@ -817,7 +817,7 @@ iterator okPairs*(xp: TxPoolRef): (Hash256, TxItemRef) = proc numTxs*(xp: TxPoolRef): int = xp.txDB.byItemID.len -proc disposeAll*(xp: TxpoolRef) {.gcsafe,raises: [CatchableError].} = +proc disposeAll*(xp: TxPoolRef) {.gcsafe,raises: [CatchableError].} = let numTx = xp.numTxs var list = newSeqOfCap[TxItemRef](numTx) for x in nextPairs(xp.txDB.byItemID): diff --git a/nimbus/core/tx_pool/tx_tasks/tx_classify.nim b/nimbus/core/tx_pool/tx_tasks/tx_classify.nim index 6a5bb6872..aca01642f 100644 --- a/nimbus/core/tx_pool/tx_tasks/tx_classify.nim +++ b/nimbus/core/tx_pool/tx_tasks/tx_classify.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) diff --git a/nimbus/core/validate.nim b/nimbus/core/validate.nim index f9b3b80d8..29b4e4d85 100644 --- a/nimbus/core/validate.nim +++ b/nimbus/core/validate.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2023 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -232,10 +232,10 @@ proc validateTxBasic*( if validateFork: if tx.txType == TxEip2930 and fork < FkBerlin: return err("invalid tx: Eip2930 Tx type detected before Berlin") - + if tx.txType == TxEip1559 and fork < FkLondon: return err("invalid tx: Eip1559 Tx type detected before London") - + if tx.txType == TxEip4844 and fork < FkCancun: return err("invalid tx: Eip4844 Tx type detected before Cancun") diff --git a/nimbus/db/aristo/aristo_blobify.nim b/nimbus/db/aristo/aristo_blobify.nim index c7ac8e436..8cb0040bf 100644 --- a/nimbus/db/aristo/aristo_blobify.nim +++ b/nimbus/db/aristo/aristo_blobify.nim @@ -1,5 +1,5 @@ # nimbus-eth1 -# Copyright (c) 2023 Status Research & Development GmbH +# Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -114,7 +114,7 @@ proc blobify*(vtx: VertexRef; data: var Blob): Result[void,AristoError] = let pSegm = vtx.ePfx.hexPrefixEncode(isleaf = false) psLen = pSegm.len.byte - if psLen == 0 or 33 < pslen: + if psLen == 0 or 33 < psLen: return err(BlobifyExtPathOverflow) if not vtx.eVid.isValid: return err(BlobifyExtMissingRefs) @@ -325,7 +325,7 @@ proc deblobify(data: Blob; pyl: var PayloadRef): Result[void,AristoError] = else: return err(DeblobCodeLenUnsupported) - pyl = pacc + pyl = pAcc ok() proc deblobify*(record: Blob; vtx: var VertexRef): Result[void,AristoError] = @@ -365,10 +365,10 @@ proc deblobify*(record: Blob; vtx: var VertexRef): Result[void,AristoError] = of 2: # `Extension` vertex let sLen = record[^1].int and 0x3f # length of path segment - rlen = record.len - 1 # `vertexID` + path segm + rLen = record.len - 1 # `vertexID` + path segm if record.len < 10: return err(DeblobExtTooShort) - if 8 + sLen != rlen: # => slen is at least 1 + if 8 + sLen != rLen: # => slen is at least 1 return err(DeblobExtSizeGarbled) let (isLeaf, pathSegment) = hexPrefixDecode record[8 ..< rLen] if isLeaf: @@ -381,15 +381,15 @@ proc deblobify*(record: Blob; vtx: var VertexRef): Result[void,AristoError] = of 3: # `Leaf` vertex let sLen = record[^1].int and 0x3f # length of path segment - rlen = record.len - 1 # payload + path segment + rLen = record.len - 1 # payload + path segment pLen = rLen - sLen # payload length - if rlen < sLen: + if rLen < sLen: return err(DeblobLeafSizeGarbled) let (isLeaf, pathSegment) = hexPrefixDecode record[pLen ..< rLen] if not isLeaf: return err(DeblobLeafGotExtPrefix) var pyl: PayloadRef - ? record[0 ..< plen].deblobify(pyl) + ? record[0 ..< pLen].deblobify(pyl) vtx = VertexRef( vType: Leaf, lPfx: pathSegment, diff --git a/nimbus/db/aristo/aristo_desc/desc_structural.nim b/nimbus/db/aristo/aristo_desc/desc_structural.nim index 5077955ef..a161043d4 100644 --- a/nimbus/db/aristo/aristo_desc/desc_structural.nim +++ b/nimbus/db/aristo/aristo_desc/desc_structural.nim @@ -266,7 +266,7 @@ func dup*(vtx: VertexRef): VertexRef = VertexRef( vType: Leaf, lPfx: vtx.lPfx, - lData: vtx.ldata.dup) + lData: vtx.lData.dup) of Extension: VertexRef( vType: Extension, @@ -288,7 +288,7 @@ func dup*(node: NodeRef): NodeRef = NodeRef( vType: Leaf, lPfx: node.lPfx, - lData: node.ldata.dup, + lData: node.lData.dup, key: node.key) of Extension: NodeRef( diff --git a/nimbus/db/aristo/aristo_path.nim b/nimbus/db/aristo/aristo_path.nim index ae648aad1..3e50b805d 100644 --- a/nimbus/db/aristo/aristo_path.nim +++ b/nimbus/db/aristo/aristo_path.nim @@ -95,7 +95,7 @@ func pathPfxPad*(pfx: NibblesSeq; dblNibble: static[byte]): NibblesSeq = let padLen = 64 - pfx.len if 0 <= padLen: - result = pfx & dblNibble.repeat(padlen div 2).mapIt(it.byte).initNibbleRange + result = pfx & dblNibble.repeat(padLen div 2).mapIt(it.byte).initNibbleRange if (padLen and 1) == 1: result = result & @[dblNibble.byte].initNibbleRange.slice(1) else: diff --git a/nimbus/db/aristo/aristo_utils.nim b/nimbus/db/aristo/aristo_utils.nim index 73f374ea0..5c4cbe985 100644 --- a/nimbus/db/aristo/aristo_utils.nim +++ b/nimbus/db/aristo/aristo_utils.nim @@ -40,7 +40,7 @@ proc toAccount*( var acc = Account( nonce: payload.account.nonce, balance: payload.account.balance, - codeHash: payload.account.codehash, + codeHash: payload.account.codeHash, storageRoot: EMPTY_ROOT_HASH) if payload.account.storageID.isValid: acc.storageRoot = (? db.getKeyRc payload.account.storageID).to(Hash256) @@ -75,7 +75,7 @@ proc toAccount*( var acc = Account( nonce: node.lData.account.nonce, balance: node.lData.account.balance, - codeHash: node.lData.account.codehash, + codeHash: node.lData.account.codeHash, storageRoot: EMPTY_ROOT_HASH) if node.lData.account.storageID.isValid: if not node.key[0].isValid: diff --git a/nimbus/db/core_db/backend/legacy_db.nim b/nimbus/db/core_db/backend/legacy_db.nim index 75f87c02d..dd314cf2a 100644 --- a/nimbus/db/core_db/backend/legacy_db.nim +++ b/nimbus/db/core_db/backend/legacy_db.nim @@ -514,7 +514,7 @@ proc baseMethods( ok(db.bless db.top), captureFn: proc(flgs: set[CoreDbCaptFlags]): CoreDbRc[CoreDxCaptRef] = - let fns = newRecorderRef(tdb, dbtype, flgs).cptMethods + let fns = newRecorderRef(tdb, dbType, flgs).cptMethods ok(db.bless CoreDxCaptRef(methods: fns))) # ------------------------------------------------------------------------------ diff --git a/nimbus/db/ledger/distinct_ledgers.nim b/nimbus/db/ledger/distinct_ledgers.nim index 5143e1328..1030ae6d8 100644 --- a/nimbus/db/ledger/distinct_ledgers.nim +++ b/nimbus/db/ledger/distinct_ledgers.nim @@ -67,18 +67,18 @@ proc toStr*(w: seq[(UInt256,UInt256)]): string = # Public helpers # ------------------------------------------------------------------------------ -proc db*(t: SomeLedger): CoreDbRef = - t.distinctBase.parent +proc db*(led: SomeLedger): CoreDbRef = + led.distinctBase.parent -proc rootHash*(t: SomeLedger): Hash256 = +proc rootHash*(led: SomeLedger): Hash256 = const info = "SomeLedger/rootHash(): " - let rc = t.distinctBase.getTrie().rootHash() + let rc = led.distinctBase.getTrie().rootHash() if rc.isErr: raiseAssert info & $$rc.error rc.value -proc getTrie*(t: SomeLedger): CoreDbTrieRef = - t.distinctBase.getTrie() +proc getTrie*(led: SomeLedger): CoreDbTrieRef = + led.distinctBase.getTrie() # ------------------------------------------------------------------------------ # Public functions: accounts ledger diff --git a/nimbus/evm/computation.nim b/nimbus/evm/computation.nim index 2afdf78b0..1fbe7d98c 100644 --- a/nimbus/evm/computation.nim +++ b/nimbus/evm/computation.nim @@ -73,7 +73,7 @@ template getTimestamp*(c: Computation): uint64 = template getBlockNumber*(c: Computation): UInt256 = when evmc_enabled: - c.host.getTxContext().block_number.u256 + c.host.getTxContext().blockNumber.u256 else: c.vmState.blockNumber.blockNumberToVmWord @@ -97,7 +97,7 @@ template getBaseFee*(c: Computation): UInt256 = template getChainId*(c: Computation): uint = when evmc_enabled: - UInt256.fromEvmc(c.host.getTxContext().chain_id).truncate(uint) + UInt256.fromEvmc(c.host.getTxContext().chainId).truncate(uint) else: c.vmState.com.chainId.uint diff --git a/nimbus/evm/interpreter_dispatch.nim b/nimbus/evm/interpreter_dispatch.nim index 07cf65ec5..24770f6cb 100644 --- a/nimbus/evm/interpreter_dispatch.nim +++ b/nimbus/evm/interpreter_dispatch.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2023 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -182,16 +182,16 @@ proc afterExecCreate(c: Computation) const MsgKindToOp: array[CallKind, Op] = [ - CALL, - DELEGATECALL, - CALLCODE, - CREATE, - CREATE2 + Call, + DelegateCall, + CallCode, + Create, + Create2 ] func msgToOp(msg: Message): Op = if EVMC_STATIC in msg.flags: - return STATICCALL + return StaticCall MsgKindToOp[msg.kind] proc beforeExec(c: Computation): bool diff --git a/nimbus/evm/modexp.nim b/nimbus/evm/modexp.nim index a91bb7902..b66cddc01 100644 --- a/nimbus/evm/modexp.nim +++ b/nimbus/evm/modexp.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2023 Status Research & Development GmbH +# Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -152,7 +152,8 @@ template getPtr(z: untyped): untyped = proc mp_init_multi(mp: mp_int): mp_err {.mp_abi, varargs.} # free a bignum -proc mp_clear(a: mp_int) {.mp_abi.} +when false: + proc mp_clear(a: mp_int) {.mp_abi.} # clear multiple mp_ints, terminated with nil proc mp_clear_multi(mp: mp_int) {.mp_abi, varargs.} diff --git a/nimbus/graphql/ethapi.nim b/nimbus/graphql/ethapi.nim index 0dbc45d2e..b03e17e58 100644 --- a/nimbus/graphql/ethapi.nim +++ b/nimbus/graphql/ethapi.nim @@ -832,7 +832,7 @@ const txProcs = { "maxPriorityFeePerGas": txMaxPriorityFeePerGas, "effectiveGasPrice": txEffectiveGasPrice, "chainID": txChainId, - "maxFeePerBlobGas": txmaxFeePerBlobGas, + "maxFeePerBlobGas": txMaxFeePerBlobGas, "versionedHashes": txVersionedHashes, "raw": txRaw, "rawReceipt": txRawReceipt @@ -1113,7 +1113,7 @@ proc blockBlobGasUsed(ud: RootRef, params: Args, parent: Node): RespResult {.api else: ok(respNull()) -proc blockexcessBlobGas(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = +proc blockExcessBlobGas(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} = let h = HeaderNode(parent) if h.header.excessBlobGas.isSome: longNode(h.header.excessBlobGas.get) diff --git a/nimbus/rpc/rpc_utils.nim b/nimbus/rpc/rpc_utils.nim index 4e60e6c6b..839848e14 100644 --- a/nimbus/rpc/rpc_utils.nim +++ b/nimbus/rpc/rpc_utils.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2023 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) # * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -300,4 +300,4 @@ proc populateReceipt*(receipt: Receipt, gasUsed: GasInt, tx: Transaction, if tx.txType == TxEip4844: result.blobGasUsed = some(w3Qty(tx.versionedHashes.len.uint64 * GAS_PER_BLOB.uint64)) - result.blobGasPrice = some(getBlobGasprice(header.excessBlobGas.get(0'u64))) + result.blobGasPrice = some(getBlobGasPrice(header.excessBlobGas.get(0'u64))) diff --git a/nimbus/sync/beacon/skeleton_algo.nim b/nimbus/sync/beacon/skeleton_algo.nim index 3ae58cffb..b108aac05 100644 --- a/nimbus/sync/beacon/skeleton_algo.nim +++ b/nimbus/sync/beacon/skeleton_algo.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2023 Status Research & Development GmbH +# Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at # https://opensource.org/licenses/MIT). @@ -425,11 +425,11 @@ proc processNewHead*(sk: SkeletonRef, head: BlockHeader, elif last.head >= number: # Check if its duplicate announcement, if not trim the head and # let the match run after this if block - let mayBeDupBlock = sk.getHeader(number).valueOr: + let maybeDupBlock = sk.getHeader(number).valueOr: return err(error) - let maybeDupHash = mayBeDupBlock.blockHash - if mayBeDupBlock.isSome and mayBeDupHash == headHash: + let maybeDupHash = maybeDupBlock.blockHash + if maybeDupBlock.isSome and maybeDupHash == headHash: debug "Skeleton duplicate announcement", tail=last.tail, head=last.head, number, hash=headHash.short return ok(false) @@ -441,7 +441,7 @@ proc processNewHead*(sk: SkeletonRef, head: BlockHeader, tail=last.tail, head=last.head, number=number, - expected=mayBeDupHash.short, + expected=maybeDupHash.short, actual=headHash.short else: debug "Skeleton stale announcement", diff --git a/nimbus/sync/beacon/skeleton_desc.nim b/nimbus/sync/beacon/skeleton_desc.nim index 466e8aecf..14a36d8da 100644 --- a/nimbus/sync/beacon/skeleton_desc.nim +++ b/nimbus/sync/beacon/skeleton_desc.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2023 Status Research & Development GmbH +# Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at # https://opensource.org/licenses/MIT). @@ -61,7 +61,7 @@ type filling* : bool # Whether we are actively filling the canonical chain started* : Time # Timestamp when the skeleton syncer was created logged* : Time # Timestamp when progress was last logged to user - db* : CoreDBRef + db* : CoreDbRef chain* : ChainRef conf* : SkeletonConfig fillLogIndex*: uint64 diff --git a/nimbus/sync/snap/worker/db/hexary_nearby.nim b/nimbus/sync/snap/worker/db/hexary_nearby.nim index fbc0fb087..af793fbf1 100644 --- a/nimbus/sync/snap/worker/db/hexary_nearby.nim +++ b/nimbus/sync/snap/worker/db/hexary_nearby.nim @@ -1,5 +1,5 @@ # nimbus-eth1 -# Copyright (c) 2021 Status Research & Development GmbH +# Copyright (c) 2021-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -71,7 +71,7 @@ proc complete( of Extension: let newKey = node.eLink - if not newkey.isZeroLink: + if not newKey.isZeroLink: let newNode = newKey.getNode(db) if newNode.isOK: uPath.path.add typeof(path.path[0])(key: key, node: node, nibble: -1) diff --git a/nimbus/sync/snap/worker/db/hexary_nodes_helper.nim b/nimbus/sync/snap/worker/db/hexary_nodes_helper.nim index a93d7c003..5571de05f 100644 --- a/nimbus/sync/snap/worker/db/hexary_nodes_helper.nim +++ b/nimbus/sync/snap/worker/db/hexary_nodes_helper.nim @@ -1,5 +1,5 @@ # nimbus-eth1 -# Copyright (c) 2021 Status Research & Development GmbH +# Copyright (c) 2021-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -90,7 +90,7 @@ proc getNode*( return ok(nodeRlp.toBranchNode) of 2: let (isLeaf,pfx) = hexPrefixDecode nodeRlp.listElem(0).toBytes - if isleaf: + if isLeaf: return ok(nodeRlp.toLeafNode pfx) else: return ok(nodeRlp.toExtensionNode pfx) @@ -138,7 +138,7 @@ proc padPartialPath*(pfx: NibblesSeq; dblNibble: byte): NodeKey = let padLen = 64 - pfx.len if 0 <= padLen: - padded = pfx & dblNibble.repeat(padlen div 2).initNibbleRange + padded = pfx & dblNibble.repeat(padLen div 2).initNibbleRange if (padLen and 1) == 1: padded = padded & @[dblNibble].initNibbleRange.slice(1) else: diff --git a/nimbus/sync/snap/worker/db/snapdb_persistent.nim b/nimbus/sync/snap/worker/db/snapdb_persistent.nim index f700d3f46..f35b52d32 100644 --- a/nimbus/sync/snap/worker/db/snapdb_persistent.nim +++ b/nimbus/sync/snap/worker/db/snapdb_persistent.nim @@ -86,7 +86,7 @@ proc toAccountsKey(a: RepairKey): auto = proc toStorageSlotsKey(a: RepairKey): auto = a.convertTo(NodeKey).toStorageSlotsKey -proc stateRootGet*(db: CoreDbRef; nodeKey: Nodekey): Blob = +proc stateRootGet*(db: CoreDbRef; nodeKey: NodeKey): Blob = if db.isLegacy: return db.kvt.backend.toLegacy.get(nodeKey.toStateRootKey.toOpenArray) @@ -196,7 +196,7 @@ proc persistentContractPut*( defer: dbTx.commit for (key,val) in data: - base.kvt.put(key.toContracthashKey.toOpenArray,val) + base.kvt.put(key.toContractHashKey.toOpenArray,val) ok() @@ -378,7 +378,7 @@ proc persistentContractPut*( let nodeKey = nodeTag.to(NodeKey) data = lookup[nodeKey] - if not bulker.add(nodeKey.toContracthashKey.toOpenArray, data): + if not bulker.add(nodeKey.toContractHashKey.toOpenArray, data): let error = AddBulkItemFailed when extraTraceMessages: trace logTxt "rocksdb bulk load failure", diff --git a/nimbus/sync/snap/worker/get/get_trie_nodes.nim b/nimbus/sync/snap/worker/get/get_trie_nodes.nim index a86ff9a35..7966523b8 100644 --- a/nimbus/sync/snap/worker/get/get_trie_nodes.nim +++ b/nimbus/sync/snap/worker/get/get_trie_nodes.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2021 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Licensed and distributed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -83,7 +83,7 @@ proc processReplyStep( maxLen = min(nSlotPaths, nodeBlobs.len - startInx) # Fill up nodes - for n in 0 ..< maxlen: + for n in 0 ..< maxLen: let nodeBlob = nodeBlobs[startInx + n] if 0 < nodeBlob.len: result.nodes.add NodeSpecs( diff --git a/nimbus/transaction/call_common.nim b/nimbus/transaction/call_common.nim index 8ffc531b0..5dc8e91e4 100644 --- a/nimbus/transaction/call_common.nim +++ b/nimbus/transaction/call_common.nim @@ -1,6 +1,6 @@ # Nimbus - Common entry point to the EVM from all different callers # -# Copyright (c) 2018-2023 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) # * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) @@ -134,7 +134,7 @@ proc setupHost(call: CallParams): TransactionHost = origin : call.origin.get(call.sender), gasPrice : call.gasPrice, versionedHashes: call.versionedHashes, - blobBaseFee : getBlobGasprice(vmState.blockCtx.excessBlobGas), + blobBaseFee : getBlobGasPrice(vmState.blockCtx.excessBlobGas), ), forkOverride = call.forkOverride )