From ea0d18424a16df7f7e2f4cb85360184fd3d08f69 Mon Sep 17 00:00:00 2001 From: Miran Date: Wed, 19 Jun 2024 03:27:54 +0200 Subject: [PATCH] use Nim 2.0.6 (#2384) * use Nim 2.0.6 * Fixes for nim 2.0.6 * Workaround nim 2.0 array indexing issue * Remove excess gcsafe pragma * Oops, fix recursive template * Fix imports * Fluffy nph linting --------- Co-authored-by: jangko Co-authored-by: tersec --- fluffy/eth_data/yaml_utils.nim | 2 +- .../history/beacon_chain_block_proof_bellatrix.nim | 8 ++++++++ fluffy/tests/state_network_tests/state_test_helpers.nim | 2 +- nimbus/db/aristo/aristo_profile.nim | 8 ++++---- nimbus/evm/computation.nim | 2 +- nimbus/evm/state.nim | 4 ++-- nimbus/graphql/ethapi.nim | 2 +- nimbus/sync/handlers/setup.nim | 2 +- vendor/nimbus-build-system | 2 +- 9 files changed, 20 insertions(+), 12 deletions(-) diff --git a/fluffy/eth_data/yaml_utils.nim b/fluffy/eth_data/yaml_utils.nim index 775e9ff8e..e5edd3b6f 100644 --- a/fluffy/eth_data/yaml_utils.nim +++ b/fluffy/eth_data/yaml_utils.nim @@ -7,7 +7,7 @@ {.push raises: [].} -import std/streams, yaml, results +import std/streams, yaml, results, yaml/parser, yaml/presenter export yaml diff --git a/fluffy/network/history/beacon_chain_block_proof_bellatrix.nim b/fluffy/network/history/beacon_chain_block_proof_bellatrix.nim index 436251db2..ccc1cdd47 100644 --- a/fluffy/network/history/beacon_chain_block_proof_bellatrix.nim +++ b/fluffy/network/history/beacon_chain_block_proof_bellatrix.nim @@ -101,6 +101,14 @@ func getHistoricalRootsIndex*(slot: Slot): uint64 = func getHistoricalRootsIndex*(blockHeader: BeaconBlockHeader): uint64 = getHistoricalRootsIndex(blockHeader.slot) +template `[]`(x: openArray[Eth2Digest], chunk: Limit): Eth2Digest = + # Nim 2.0 requires arrays to be indexed by the same type they're declared with. + # Both HistoricalBatch.block_roots and HistoricalBatch.state_roots + # are declared with uint64. But `Limit = int64`. + # Looks like this template can be used as a workaround. + # See https://github.com/status-im/nimbus-eth1/pull/2384 + x[chunk.uint64] + # Builds proof to be able to verify that a BeaconBlock root is part of the # HistoricalBatch for given root. func buildProof*( diff --git a/fluffy/tests/state_network_tests/state_test_helpers.nim b/fluffy/tests/state_network_tests/state_test_helpers.nim index 2e032a080..7ad039574 100644 --- a/fluffy/tests/state_network_tests/state_test_helpers.nim +++ b/fluffy/tests/state_network_tests/state_test_helpers.nim @@ -14,7 +14,7 @@ import eth/p2p/discoveryv5/protocol as discv5_protocol, eth/p2p/discoveryv5/routing_table, ../../network/wire/[portal_protocol, portal_stream, portal_protocol_config], - ../../nimbus/common/chain_config, + ../../../nimbus/common/chain_config, ../../network/history/[history_content, history_network], ../../network/state/[state_content, state_utils, state_network], ../../eth_data/yaml_utils, diff --git a/nimbus/db/aristo/aristo_profile.nim b/nimbus/db/aristo/aristo_profile.nim index 10ec9acd9..8d2851c32 100644 --- a/nimbus/db/aristo/aristo_profile.nim +++ b/nimbus/db/aristo/aristo_profile.nim @@ -61,7 +61,7 @@ proc updateTotal(t: AristoDbProfListRef; fnInx: uint) = # --------------------- -func ppUs(elapsed: Duration): string {.gcsafe, raises: [ValueError].} = +func ppUs(elapsed: Duration): string {.gcsafe, raises: [].} = result = $elapsed.inMicroseconds let ns = elapsed.inNanoseconds mod 1_000 # fraction of a micro second if ns != 0: @@ -70,7 +70,7 @@ func ppUs(elapsed: Duration): string {.gcsafe, raises: [ValueError].} = result &= &".{du:02}" result &= "us" -func ppMs(elapsed: Duration): string {.gcsafe, raises: [ValueError].} = +func ppMs(elapsed: Duration): string {.gcsafe, raises: [].} = result = $elapsed.inMilliseconds let ns = elapsed.inNanoseconds mod 1_000_000 # fraction of a milli second if ns != 0: @@ -79,7 +79,7 @@ func ppMs(elapsed: Duration): string {.gcsafe, raises: [ValueError].} = result &= &".{dm:02}" result &= "ms" -func ppSecs(elapsed: Duration): string {.gcsafe, raises: [ValueError].} = +func ppSecs(elapsed: Duration): string {.gcsafe, raises: [].} = result = $elapsed.inSeconds let ns = elapsed.inNanoseconds mod 1_000_000_000 # fraction of a second if ns != 0: @@ -88,7 +88,7 @@ func ppSecs(elapsed: Duration): string {.gcsafe, raises: [ValueError].} = result &= &".{ds:02}" result &= "s" -func ppMins(elapsed: Duration): string {.gcsafe, raises: [ValueError].} = +func ppMins(elapsed: Duration): string {.gcsafe, raises: [].} = result = $elapsed.inMinutes let ns = elapsed.inNanoseconds mod 60_000_000_000 # fraction of a minute if ns != 0: diff --git a/nimbus/evm/computation.nim b/nimbus/evm/computation.nim index e78270677..ac3451a04 100644 --- a/nimbus/evm/computation.nim +++ b/nimbus/evm/computation.nim @@ -139,7 +139,7 @@ template getBlobBaseFee*(c: Computation): UInt256 = else: c.vmState.txCtx.blobBaseFee -proc getBlockHash*(c: Computation, number: BlockNumber): Hash256 = +proc getBlockHash*(c: Computation, number: BlockNumber): Hash256 {.gcsafe, raises:[].} = when evmc_enabled: let blockNumber = BlockNumber c.host.getTxContext().block_number diff --git a/nimbus/evm/state.nim b/nimbus/evm/state.nim index 48a725dbd..af13eb416 100644 --- a/nimbus/evm/state.nim +++ b/nimbus/evm/state.nim @@ -52,7 +52,7 @@ func blockCtx(com: CommonRef, header: BlockHeader): # -------------- proc `$`*(vmState: BaseVMState): string - {.gcsafe, raises: [ValueError].} = + {.gcsafe, raises: [].} = if vmState.isNil: result = "nil" else: @@ -235,7 +235,7 @@ proc baseFeePerGas*(vmState: BaseVMState): UInt256 = vmState.blockCtx.baseFeePerGas.get(0.u256) method getAncestorHash*( - vmState: BaseVMState, blockNumber: BlockNumber): Hash256 {.base.} = + vmState: BaseVMState, blockNumber: BlockNumber): Hash256 {.gcsafe, base.} = let db = vmState.com.db try: var blockHash: Hash256 diff --git a/nimbus/graphql/ethapi.nim b/nimbus/graphql/ethapi.nim index 1035219b3..4437e202c 100644 --- a/nimbus/graphql/ethapi.nim +++ b/nimbus/graphql/ethapi.nim @@ -78,7 +78,7 @@ type {.push gcsafe, raises: [].} {.pragma: apiRaises, raises: [].} -{.pragma: apiPragma, cdecl, gcsafe, apiRaises, locks:0.} +{.pragma: apiPragma, cdecl, gcsafe, apiRaises.} proc toHash(n: Node): common.Hash256 {.gcsafe, raises: [ValueError].} = result.data = hexToByteArray[32](n.stringVal) diff --git a/nimbus/sync/handlers/setup.nim b/nimbus/sync/handlers/setup.nim index 1cb7a4702..c145dc4d9 100644 --- a/nimbus/sync/handlers/setup.nim +++ b/nimbus/sync/handlers/setup.nim @@ -25,7 +25,7 @@ proc setEthHandlerNewBlocksAndHashes*( blockHandler: NewBlockHandler; hashesHandler: NewBlockHashesHandler; arg: pointer; - ) {.gcsafe, raises: [CatchableError].} = + ) {.gcsafe, raises: [].} = let w = EthWireRef(node.protocolState protocol.eth) w.setNewBlockHandler(blockHandler, arg) w.setNewBlockHashesHandler(hashesHandler, arg) diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system index 8cdaec502..03bfa4c6a 160000 --- a/vendor/nimbus-build-system +++ b/vendor/nimbus-build-system @@ -1 +1 @@ -Subproject commit 8cdaec502b5a48f2514e11209f0d81a001d2a2b1 +Subproject commit 03bfa4c6acaf67e1e2e7c855ddd95b52de5a6cad