From c228505c59c65fc18c5b4858758bd6321ff3c450 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 21 Jun 2024 16:09:18 +0200 Subject: [PATCH 1/7] ensure that rarely ran files are compiled on PR Add some missing files to `isMainModule` developer internal builds CI. --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8aa3aebbda..5ab986fbf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -227,8 +227,14 @@ jobs: - name: Build files with isMainModule run: | source env.sh + nim c beacon_chain/el/deposit_contract + nim c beacon_chain/fork_choice/fork_choice + nim c beacon_chain/fork_choice/proto_array + nim c beacon_chain/networking/network_metadata_downloads nim c beacon_chain/era_db nim c beacon_chain/trusted_node_sync + nim c benchmarks/rest_api_benchmark + nim c tests/mocking/mock_genesis lint: name: "Lint" From 7e5ac5c366e7078f02febc2fea112464e833070a Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 21 Jun 2024 17:06:40 +0200 Subject: [PATCH 2/7] fix fork choice compilation --- beacon_chain/fork_choice/fork_choice.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beacon_chain/fork_choice/fork_choice.nim b/beacon_chain/fork_choice/fork_choice.nim index 0156a2b3d0..6b638ce585 100644 --- a/beacon_chain/fork_choice/fork_choice.nim +++ b/beacon_chain/fork_choice/fork_choice.nim @@ -502,8 +502,8 @@ when isMainModule: for i in 0 ..< validator_count: indices.add fakeHash(i), i votes.add default(VoteTracker) - old_balances.add 0 - new_balances.add 0 + old_balances.add 0.Gwei + new_balances.add 0.Gwei let err = deltas.compute_deltas( indices, indices_offset = 0, votes, old_balances, new_balances From c4c45ee8336d1ea179585997cc62660a5dacbbc2 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sat, 22 Jun 2024 10:43:04 +0200 Subject: [PATCH 3/7] fix `rest_api_benchmark` compilation --- benchmarks/rest_api_benchmark.nim | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/benchmarks/rest_api_benchmark.nim b/benchmarks/rest_api_benchmark.nim index 00050e3ab2..c496ef62f7 100644 --- a/benchmarks/rest_api_benchmark.nim +++ b/benchmarks/rest_api_benchmark.nim @@ -1,3 +1,12 @@ +# beacon_chain +# Copyright (c) 2022-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). +# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + import chronicles, chronicles/[topics_registry, timings], confutils, confutils/std/net, @@ -6,11 +15,11 @@ import type Config = object serverIpAddress {. - defaultValue: ValidIpAddress.init("127.0.0.1") + defaultValue: static(parseIpAddress("127.0.0.1")) defaultValueDesc: "127.0.0.1" desc: "IP address of the beacon node's REST server" abbr: "a" - name: "address" }: ValidIpAddress + name: "address" }: IpAddress serverPort {. defaultValue: 5052 @@ -29,7 +38,7 @@ type abbr: "n" name: "count" }: uint -proc main = +proc main() {.raises: [ConfigurationError, HttpError, OSError].} = let config = Config.load let serverAddress = initTAddress(config.serverIpAddress, config.serverPort) let client = RestClientRef.new(serverAddress) @@ -43,10 +52,10 @@ proc main = info.logTime(apiName): for slot in config.startSlot ..< (config.startSlot + config.requestsCount): let ident = StateIdent(kind: StateQueryKind.Slot, slot: slot.Slot) - discard waitFor client.`apiNameIdent`(ident) + discard waitFor noCancel client.`apiNameIdent`(ident) benchmark(getStateRoot) - benchmark(getStateFork) + benchmark(getStateForkPlain) benchmark(getStateFinalityCheckpoints) benchmark(getStateValidatorBalances) From a5df71a304de4f4c4daed227fb7556c7c0999834 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sat, 22 Jun 2024 10:43:11 +0200 Subject: [PATCH 4/7] skip linking --- .github/workflows/ci.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ab986fbf3..ac286d841f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -226,15 +226,19 @@ jobs: - name: Build files with isMainModule run: | + executables=( + "beacon_chain/el/deposit_contract" + "beacon_chain/fork_choice/fork_choice" + "beacon_chain/fork_choice/proto_array" + "beacon_chain/networking/network_metadata_downloads" + "beacon_chain/era_db" + "beacon_chain/trusted_node_sync" + "benchmarks/rest_api_benchmark" + "tests/mocking/mock_genesis" + ) source env.sh - nim c beacon_chain/el/deposit_contract - nim c beacon_chain/fork_choice/fork_choice - nim c beacon_chain/fork_choice/proto_array - nim c beacon_chain/networking/network_metadata_downloads - nim c beacon_chain/era_db - nim c beacon_chain/trusted_node_sync - nim c benchmarks/rest_api_benchmark - nim c tests/mocking/mock_genesis + for executable in executables; do + nim c --passC:-fsyntax-only --noLinking:on -d:chronicles_log_level=TRACE "${executable}" lint: name: "Lint" From 0790f8fc4358ee75ef98cf75bbd2e743540e998c Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sat, 22 Jun 2024 13:45:16 +0200 Subject: [PATCH 5/7] fix loop --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac286d841f..19bbff1eec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -237,8 +237,9 @@ jobs: "tests/mocking/mock_genesis" ) source env.sh - for executable in executables; do + for executable in "${executables[@]}"; do nim c --passC:-fsyntax-only --noLinking:on -d:chronicles_log_level=TRACE "${executable}" + done lint: name: "Lint" From 2bc71957872d912f440b6be723d89e10b3ecdb46 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sun, 23 Jun 2024 12:29:47 +0200 Subject: [PATCH 6/7] fix `mock_genesis` --- tests/mocking/mock_genesis.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mocking/mock_genesis.nim b/tests/mocking/mock_genesis.nim index 0e0b74c9f2..a06964f7c9 100644 --- a/tests/mocking/mock_genesis.nim +++ b/tests/mocking/mock_genesis.nim @@ -39,4 +39,4 @@ proc initGenesisState*( when isMainModule: # Smoke test let state = initGenesisState(num_validators = SLOTS_PER_EPOCH) - doAssert state.validators.len == SLOTS_PER_EPOCH \ No newline at end of file + doAssert getStateField(state[], validators).len == SLOTS_PER_EPOCH From 3d72a9ed6c44d40fe60fef4097affb5b42cb3efa Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sun, 23 Jun 2024 15:06:24 +0200 Subject: [PATCH 7/7] fix signedness --- tests/mocking/mock_genesis.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mocking/mock_genesis.nim b/tests/mocking/mock_genesis.nim index a06964f7c9..66bb6ace20 100644 --- a/tests/mocking/mock_genesis.nim +++ b/tests/mocking/mock_genesis.nim @@ -39,4 +39,4 @@ proc initGenesisState*( when isMainModule: # Smoke test let state = initGenesisState(num_validators = SLOTS_PER_EPOCH) - doAssert getStateField(state[], validators).len == SLOTS_PER_EPOCH + doAssert getStateField(state[], validators).lenu64 == SLOTS_PER_EPOCH