diff --git a/ncli/e2store.nim b/ncli/e2store.nim index bfc8adc80..df823966b 100644 --- a/ncli/e2store.nim +++ b/ncli/e2store.nim @@ -67,7 +67,7 @@ proc open*(T: type E2Store, path: string, name: string, firstSlot: Slot): Result ok(E2Store(data: data, index: index, slot: firstSlot)) -proc close*(store: var E2Store) = +func close*(store: var E2Store) = store.data.close() store.index.close() diff --git a/ncli/ncli_db.nim b/ncli/ncli_db.nim index 142fc5b4c..beb38d8c5 100644 --- a/ncli/ncli_db.nim +++ b/ncli/ncli_db.nim @@ -128,7 +128,7 @@ type name: "perfect" desc: "Include perfect records (full rewards)".}: bool -proc getSlotRange(dag: ChainDAGRef, startSlot: int64, count: uint64): (Slot, Slot) = +func getSlotRange(dag: ChainDAGRef, startSlot: int64, count: uint64): (Slot, Slot) = let start = if startSlot >= 0: Slot(startSlot) @@ -139,7 +139,7 @@ proc getSlotRange(dag: ChainDAGRef, startSlot: int64, count: uint64): (Slot, Slo else: start + count (start, ends) -proc getBlockRange(dag: ChainDAGRef, start, ends: Slot): seq[BlockRef] = +func getBlockRange(dag: ChainDAGRef, start, ends: Slot): seq[BlockRef] = # Range of block in reverse order var blockRefs: seq[BlockRef] @@ -372,7 +372,7 @@ proc cmdRewindState(conf: DbConf, cfg: RuntimeConfig) = echo "Writing state..." dump("./", stateData.data.hbsPhase0, blck) -proc atCanonicalSlot(blck: BlockRef, slot: Slot): BlockSlot = +func atCanonicalSlot(blck: BlockRef, slot: Slot): BlockSlot = if slot == 0: blck.atSlot(slot) else: @@ -470,7 +470,7 @@ proc cmdValidatorPerf(conf: DbConf, cfg: RuntimeConfig) = dag.updateStateData( state[], blockRefs[^1].atSlot(blockRefs[^1].slot - 1), false, cache) - proc processEpoch() = + func processEpoch() = let prev_epoch_target_slot = state[].data.get_previous_epoch().compute_start_slot_at_epoch() diff --git a/research/simutils.nim b/research/simutils.nim index d5d666872..d74a42fb5 100644 --- a/research/simutils.nim +++ b/research/simutils.nim @@ -121,7 +121,7 @@ proc printTimers*[Timers: enum]( validate: bool, timers: array[Timers, RunningStat] ) = - proc fmtTime(t: float): string = &"{t * 1000 :>12.3f}, " + func fmtTime(t: float): string = &"{t * 1000 :>12.3f}, " echo "All time are ms" echo &"{\"Average\" :>12}, {\"StdDev\" :>12}, {\"Min\" :>12}, " & diff --git a/research/state_sim.nim b/research/state_sim.nim index f29db961c..d79987ffd 100644 --- a/research/state_sim.nim +++ b/research/state_sim.nim @@ -24,7 +24,7 @@ type Timers = enum tShuffle = "Retrieve committee once using get_beacon_committee" tAttest = "Combine committee attestations" -proc jsonName(prefix, slot: auto): string = +func jsonName(prefix, slot: auto): string = fmt"{prefix:04}-{shortLog(slot):08}.json" proc writeJson*(fn, v: auto) = diff --git a/tests/fork_choice/scenarios/ffg_01.nim b/tests/fork_choice/scenarios/ffg_01.nim index ef19150a0..df8336cd2 100644 --- a/tests/fork_choice/scenarios/ffg_01.nim +++ b/tests/fork_choice/scenarios/ffg_01.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -7,7 +7,7 @@ # import ../interpreter # included to be able to use "suite" -proc setup_finality_01(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] = +func setup_finality_01(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] = var balances = @[Gwei(1), Gwei(1)] let GenesisRoot = fakeHash(0) diff --git a/tests/fork_choice/scenarios/ffg_02.nim b/tests/fork_choice/scenarios/ffg_02.nim index e09bd5e8c..47a882361 100644 --- a/tests/fork_choice/scenarios/ffg_02.nim +++ b/tests/fork_choice/scenarios/ffg_02.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -7,7 +7,7 @@ # import ../interpreter # included to be able to use "suite" -proc setup_finality_02(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] = +func setup_finality_02(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] = var balances = @[Gwei(1), Gwei(1)] let GenesisRoot = fakeHash(0) diff --git a/tests/fork_choice/scenarios/no_votes.nim b/tests/fork_choice/scenarios/no_votes.nim index a10bed3d3..051f8368b 100644 --- a/tests/fork_choice/scenarios/no_votes.nim +++ b/tests/fork_choice/scenarios/no_votes.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -7,7 +7,7 @@ # import ../interpreter # included to be able to use "suite" -proc setup_no_votes(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] = +func setup_no_votes(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] = let balances = newSeq[Gwei](16) let GenesisRoot = fakeHash(0) diff --git a/tests/fork_choice/scenarios/votes.nim b/tests/fork_choice/scenarios/votes.nim index eb7ed7434..7e822c9d4 100644 --- a/tests/fork_choice/scenarios/votes.nim +++ b/tests/fork_choice/scenarios/votes.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -7,7 +7,7 @@ # import ../interpreter # included to be able to use "suite" -proc setup_votes(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] = +func setup_votes(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] = var balances = @[Gwei(1), Gwei(1)] let GenesisRoot = fakeHash(0) diff --git a/tests/helpers/debug_state.nim b/tests/helpers/debug_state.nim index 08909928f..7821d2764 100644 --- a/tests/helpers/debug_state.nim +++ b/tests/helpers/debug_state.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2019 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -56,7 +56,7 @@ proc compareContainerStmt(xSubField, ySubField: NimNode, stmts: var NimNode) = "and " & `yStr` & "[" & $idx & "] = " & $`ySubField`[idx] & "\n" ) -proc inspectType(tImpl, xSubField, ySubField: NimNode, stmts: var NimNode) = +func inspectType(tImpl, xSubField, ySubField: NimNode, stmts: var NimNode) = # echo "kind: " & $tImpl.kind # echo " -- field: " & $xSubField.toStrLit case tImpl.kind diff --git a/tests/helpers/digest_helpers.nim b/tests/helpers/digest_helpers.nim index b9504caba..1db36fd23 100644 --- a/tests/helpers/digest_helpers.nim +++ b/tests/helpers/digest_helpers.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2019 Status Research & Development GmbH +# Copyright (c) 2018-2021 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). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -8,7 +8,7 @@ import ../../beacon_chain/spec/digest -proc `*`*(a: static array[1, byte], n: static int): static Eth2Digest = +func `*`*(a: static array[1, byte], n: static int): static Eth2Digest = doAssert n == 32 for mbyte in result.data.mitems: mbyte = a[0] diff --git a/tests/mocking/mock_validator_keys.nim b/tests/mocking/mock_validator_keys.nim index 7a0b7a02d..22d064485 100644 --- a/tests/mocking/mock_validator_keys.nim +++ b/tests/mocking/mock_validator_keys.nim @@ -13,7 +13,7 @@ import blscurve, ../../beacon_chain/spec/datatypes/base -proc newKeyPair(rng: var BrHmacDrbgContext): BlsResult[tuple[pub: ValidatorPubKey, priv: ValidatorPrivKey]] = +func newKeyPair(rng: var BrHmacDrbgContext): BlsResult[tuple[pub: ValidatorPubKey, priv: ValidatorPrivKey]] = ## Generates a new public-private keypair ## This requires entropy on the system # The input-keying-material requires 32 bytes at least for security diff --git a/tests/official/test_fixture_bls.nim b/tests/official/test_fixture_bls.nim index 31b7c8a4f..1b4e67dcf 100644 --- a/tests/official/test_fixture_bls.nim +++ b/tests/official/test_fixture_bls.nim @@ -40,7 +40,7 @@ type input: seq[ValidatorPubKey] output: ValidatorPubKey -proc readValue(r: var JsonReader, a: var Eth2Domain) = +func readValue(r: var JsonReader, a: var Eth2Domain) = ## Custom deserializer for Eth2Domain # Furthermore Nim parseHex doesn't support uint # until https://github.com/nim-lang/Nim/pull/11067 diff --git a/tests/slashing_protection/test_migration.nim b/tests/slashing_protection/test_migration.nim index 6b8a9be69..c3f4eddaf 100644 --- a/tests/slashing_protection/test_migration.nim +++ b/tests/slashing_protection/test_migration.nim @@ -26,7 +26,7 @@ import ../testutil func hexToDigest(hex: string): Eth2Digest = - result = Eth2Digest.fromHex(hex) + Eth2Digest.fromHex(hex) proc sqlite3db_delete(basepath, dbname: string) = removeFile(basepath / dbname&".sqlite3-shm") diff --git a/tests/slashing_protection/test_slashing_interchange.nim b/tests/slashing_protection/test_slashing_interchange.nim index 95516aa5e..0cf427d49 100644 --- a/tests/slashing_protection/test_slashing_interchange.nim +++ b/tests/slashing_protection/test_slashing_interchange.nim @@ -27,7 +27,7 @@ func fakeRoot(index: SomeInteger): Eth2Digest = result.data[0 ..< 8] = (1'u64 shl 32 + index.uint64).toBytesBE() func hexToDigest(hex: string): Eth2Digest = - result = Eth2Digest.fromHex(hex) + Eth2Digest.fromHex(hex) proc sqlite3db_delete(basepath, dbname: string) = removeFile(basepath / dbname&".sqlite3-shm") diff --git a/tests/spec_epoch_processing/justification_finalization_helpers.nim b/tests/spec_epoch_processing/justification_finalization_helpers.nim index 0c0d0a055..d94a1aca4 100644 --- a/tests/spec_epoch_processing/justification_finalization_helpers.nim +++ b/tests/spec_epoch_processing/justification_finalization_helpers.nim @@ -17,7 +17,7 @@ import # Justification and finalization utils # --------------------------------------------------------------- -proc addMockAttestations*( +func addMockAttestations*( state: var phase0.BeaconState, epoch: Epoch, source, target: Checkpoint, sufficient_support = false @@ -78,14 +78,14 @@ proc addMockAttestations*( inclusion_delay: 1 ) -proc getCheckpoints*(epoch: Epoch): tuple[c1, c2, c3, c4, c5: Checkpoint] = +func getCheckpoints*(epoch: Epoch): tuple[c1, c2, c3, c4, c5: Checkpoint] = if epoch >= 1: result.c1 = Checkpoint(epoch: epoch - 1, root: [byte 0xAA] * 32) if epoch >= 2: result.c2 = Checkpoint(epoch: epoch - 2, root: [byte 0xBB] * 32) if epoch >= 3: result.c3 = Checkpoint(epoch: epoch - 3, root: [byte 0xCC] * 32) if epoch >= 4: result.c4 = Checkpoint(epoch: epoch - 4, root: [byte 0xDD] * 32) if epoch >= 5: result.c5 = Checkpoint(epoch: epoch - 5, root: [byte 0xEE] * 32) -proc putCheckpointsInBlockRoots*( +func putCheckpointsInBlockRoots*( state: var phase0.BeaconState, checkpoints: openArray[Checkpoint]) = for c in checkpoints: diff --git a/tests/ssz/test_ssz_serialization.nim b/tests/ssz/test_ssz_serialization.nim index 7fd95d6dc..2e1a7f453 100644 --- a/tests/ssz/test_ssz_serialization.nim +++ b/tests/ssz/test_ssz_serialization.nim @@ -68,7 +68,7 @@ type Baz = object i: uint64 -proc toDigest[N: static int](x: array[N, byte]): Eth2Digest = +func toDigest[N: static int](x: array[N, byte]): Eth2Digest = result.data[0 .. N-1] = x suite "SSZ navigator": diff --git a/tests/test_block_pool.nim b/tests/test_block_pool.nim index 77aada456..2abb792ee 100644 --- a/tests/test_block_pool.nim +++ b/tests/test_block_pool.nim @@ -21,7 +21,7 @@ import blockchain_dag, block_quarantine, block_clearance], ./testutil, ./testdbutil, ./testblockutil -proc `$`(x: BlockRef): string = +func `$`(x: BlockRef): string = $x.root proc pruneAtFinalization(dag: ChainDAGRef) = diff --git a/tests/test_peer_pool.nim b/tests/test_peer_pool.nim index 41babfbf9..3cbe93f01 100644 --- a/tests/test_peer_pool.nim +++ b/tests/test_peer_pool.nim @@ -589,7 +589,7 @@ suite "PeerPool testing suite": test "Score check test": var pool = newPeerPool[PeerTest, PeerTestID]() - proc scoreCheck(peer: PeerTest): bool = + func scoreCheck(peer: PeerTest): bool = if peer.weight >= 0: result = true else: @@ -651,7 +651,7 @@ suite "PeerPool testing suite": test "Delete peer on release text": proc testDeleteOnRelease(): Future[bool] {.async.} = - proc scoreCheck(peer: PeerTest): bool = + func scoreCheck(peer: PeerTest): bool = if peer.weight >= 0: result = true else: