diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06159ceff..5fe68a76c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,8 @@ jobs: cpu: amd64 - os: macos cpu: amd64 - #- os: windows - # cpu: amd64 + - os: windows + cpu: amd64 branch: [~, upstream/version-1-6, upstream/version-2-0] exclude: - target: @@ -46,7 +46,7 @@ jobs: branch: upstream/version-1-6 - target: os: windows - branch: upstream/version-2-0 + branch: ~ include: - branch: upstream/version-1-6 branch-short: version-1-6 @@ -61,10 +61,10 @@ jobs: os: macos builder: macos-11 shell: bash - #- target: - # os: windows - # builder: windows-2019 - # shell: msys2 {0} + - target: + os: windows + builder: windows-2019 + shell: msys2 {0} defaults: run: @@ -215,7 +215,7 @@ jobs: if: ${{ !cancelled() }} && github.event_name == 'pull_request' run: | excluded_files="config.yaml" - excluded_extensions="ans|json|md|png|ssz|txt" + excluded_extensions="ans|json|md|png|service|ssz|txt" current_year=$(date +"%Y") outdated_files=() diff --git a/.gitmodules b/.gitmodules index 5b662e2b1..71d512a1c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -24,7 +24,7 @@ path = vendor/nim-libp2p url = https://github.com/status-im/nim-libp2p.git ignore = untracked - branch = nimbus + branch = unstable [submodule "vendor/nimbus-build-system"] path = vendor/nimbus-build-system url = https://github.com/status-im/nimbus-build-system.git @@ -59,7 +59,7 @@ path = vendor/nim-chronos url = https://github.com/status-im/nim-chronos.git ignore = untracked - branch = nimbus-v23.9.0 + branch = master [submodule "vendor/nim-chronicles"] path = vendor/nim-chronicles url = https://github.com/status-im/nim-chronicles.git @@ -222,6 +222,6 @@ branch = master [submodule "vendor/holesky"] path = vendor/holesky - url = https://github.com/eth-clients/holesky - ignore = untracked - branch = main + url = https://github.com/eth-clients/holesky + ignore = untracked + branch = main diff --git a/AllTests-mainnet.md b/AllTests-mainnet.md index c098ec3f5..5db2973e1 100644 --- a/AllTests-mainnet.md +++ b/AllTests-mainnet.md @@ -252,11 +252,12 @@ OK: 1/1 Fail: 0/1 Skip: 0/1 + validateAttestation OK ``` OK: 2/2 Fail: 0/2 Skip: 0/2 -## Gossip validation - Extra +## Gossip validation - Altair ```diff -+ validateSyncCommitteeMessage OK ++ Period boundary OK ++ validateSyncCommitteeMessage - Duplicate pubkey OK ``` -OK: 1/1 Fail: 0/1 Skip: 0/1 +OK: 2/2 Fail: 0/2 Skip: 0/2 ## Honest validator ```diff + General pubsub topics OK @@ -703,4 +704,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2 OK: 9/9 Fail: 0/9 Skip: 0/9 ---TOTAL--- -OK: 396/401 Fail: 0/401 Skip: 5/401 +OK: 397/402 Fail: 0/402 Skip: 5/402 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a100e756..d0b0848bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -2023-09-08 v23.9.0 +2023-09-12 v23.9.0 ================== Nimbus `v23.9.0` is a `low-urgency` upgrade providing full support for the upcoming [Holešky testnet](https://github.com/eth-clients/holesky) and simplifying the required configuration for using [remote signers](https://nimbus.guide/web3signer.html). @@ -16,6 +16,7 @@ We've been hard at work researching and developing a GossipSub protocol upgrade, https://github.com/status-im/nimbus-eth2/pull/5389 * Nimbus now supports the upcoming Holešky testnet: + https://nimbus.guide/holesky.html https://github.com/status-im/nimbus-eth2/pull/5337 * Faster validator registry processing reduces the time spent by Nimbus in state transitions and replays: diff --git a/ConsensusSpecPreset-mainnet.md b/ConsensusSpecPreset-mainnet.md index 30f8f660b..0bf299910 100644 --- a/ConsensusSpecPreset-mainnet.md +++ b/ConsensusSpecPreset-mainnet.md @@ -2829,6 +2829,7 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - mainnet/altair/fork_choice/on_block/pyspec_tests/on_block_bad_parent_root OK ForkChoice - mainnet/altair/fork_choice/on_block/pyspec_tests/on_block_future_block Skip + ForkChoice - mainnet/altair/fork_choice/on_block/pyspec_tests/proposer_boost OK ++ ForkChoice - mainnet/altair/fork_choice/on_block/pyspec_tests/proposer_boost_is_first_bloc OK + ForkChoice - mainnet/altair/fork_choice/on_block/pyspec_tests/proposer_boost_root_same_slo OK + ForkChoice - mainnet/bellatrix/fork_choice/ex_ante/pyspec_tests/ex_ante_attestations_is_gr OK + ForkChoice - mainnet/bellatrix/fork_choice/ex_ante/pyspec_tests/ex_ante_sandwich_with_boos OK @@ -2845,6 +2846,7 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - mainnet/bellatrix/fork_choice/on_block/pyspec_tests/on_block_bad_parent_root OK ForkChoice - mainnet/bellatrix/fork_choice/on_block/pyspec_tests/on_block_future_block Skip + ForkChoice - mainnet/bellatrix/fork_choice/on_block/pyspec_tests/proposer_boost OK ++ ForkChoice - mainnet/bellatrix/fork_choice/on_block/pyspec_tests/proposer_boost_is_first_b OK + ForkChoice - mainnet/bellatrix/fork_choice/on_block/pyspec_tests/proposer_boost_root_same_ OK ForkChoice - mainnet/bellatrix/fork_choice/on_merge_block/pyspec_tests/all_valid Skip ForkChoice - mainnet/bellatrix/fork_choice/on_merge_block/pyspec_tests/block_lookup_failed Skip @@ -2865,6 +2867,7 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - mainnet/capella/fork_choice/on_block/pyspec_tests/on_block_bad_parent_root OK ForkChoice - mainnet/capella/fork_choice/on_block/pyspec_tests/on_block_future_block Skip + ForkChoice - mainnet/capella/fork_choice/on_block/pyspec_tests/proposer_boost OK ++ ForkChoice - mainnet/capella/fork_choice/on_block/pyspec_tests/proposer_boost_is_first_blo OK + ForkChoice - mainnet/capella/fork_choice/on_block/pyspec_tests/proposer_boost_root_same_sl OK + ForkChoice - mainnet/deneb/fork_choice/ex_ante/pyspec_tests/ex_ante_attestations_is_greate OK + ForkChoice - mainnet/deneb/fork_choice/ex_ante/pyspec_tests/ex_ante_sandwich_with_boost_no OK @@ -2878,12 +2881,18 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - mainnet/deneb/fork_choice/get_head/pyspec_tests/shorter_chain_but_heavier_wei OK + ForkChoice - mainnet/deneb/fork_choice/get_head/pyspec_tests/split_tie_breaker_no_attestat OK + ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/basic OK ++ ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/invalid_data_unavailable OK ++ ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/invalid_incorrect_proof OK ++ ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/invalid_wrong_blobs_length OK ++ ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/invalid_wrong_proofs_length OK + ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/on_block_bad_parent_root OK ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/on_block_future_block Skip + ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/proposer_boost OK ++ ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/proposer_boost_is_first_block OK + ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/proposer_boost_root_same_slot OK ++ ForkChoice - mainnet/deneb/fork_choice/on_block/pyspec_tests/simple_blob_data OK ``` -OK: 60/68 Fail: 0/68 Skip: 8/68 +OK: 69/77 Fail: 0/77 Skip: 8/77 ## Sync ```diff + Sync - mainnet/bellatrix/sync/optimistic/pyspec_tests/from_syncing_to_invalid OK @@ -2893,4 +2902,4 @@ OK: 60/68 Fail: 0/68 Skip: 8/68 OK: 3/3 Fail: 0/3 Skip: 0/3 ---TOTAL--- -OK: 2327/2335 Fail: 0/2335 Skip: 8/2335 +OK: 2336/2344 Fail: 0/2344 Skip: 8/2344 diff --git a/ConsensusSpecPreset-minimal.md b/ConsensusSpecPreset-minimal.md index 0544b3b4f..c6fbf0a8f 100644 --- a/ConsensusSpecPreset-minimal.md +++ b/ConsensusSpecPreset-minimal.md @@ -1873,6 +1873,9 @@ OK: 12/12 Fail: 0/12 Skip: 0/12 OK: 1/1 Fail: 0/1 Skip: 0/1 ## EF - Deneb - Epoch Processing - Registry updates [Preset: minimal] ```diff ++ Registry updates - activation_churn_limit__equal_to_activation_limit [Preset: minimal] OK ++ Registry updates - activation_churn_limit__greater_than_activation_limit [Preset: minimal] OK ++ Registry updates - activation_churn_limit__less_than_activation_limit [Preset: minimal] OK + Registry updates - activation_queue_activation_and_ejection__1 [Preset: minimal] OK + Registry updates - activation_queue_activation_and_ejection__churn_limit [Preset: minimal] OK + Registry updates - activation_queue_activation_and_ejection__exceed_churn_limit [Preset: m OK @@ -1889,7 +1892,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1 + Registry updates - ejection_past_churn_limit_scaled [Preset: minimal] OK + Registry updates - invalid_large_withdrawable_epoch [Preset: minimal] OK ``` -OK: 15/15 Fail: 0/15 Skip: 0/15 +OK: 18/18 Fail: 0/18 Skip: 0/18 ## EF - Deneb - Epoch Processing - Rewards and penalties [Preset: minimal] ```diff + Rewards and penalties - almost_empty_attestations [Preset: minimal] OK @@ -2993,6 +2996,7 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - minimal/altair/fork_choice/on_block/pyspec_tests/on_block_finalized_skip_slot OK ForkChoice - minimal/altair/fork_choice/on_block/pyspec_tests/on_block_future_block Skip + ForkChoice - minimal/altair/fork_choice/on_block/pyspec_tests/proposer_boost OK ++ ForkChoice - minimal/altair/fork_choice/on_block/pyspec_tests/proposer_boost_is_first_bloc OK + ForkChoice - minimal/altair/fork_choice/on_block/pyspec_tests/proposer_boost_root_same_slo OK + ForkChoice - minimal/altair/fork_choice/on_block/pyspec_tests/pull_up_on_tick OK + ForkChoice - minimal/altair/fork_choice/on_block/pyspec_tests/pull_up_past_epoch_block OK @@ -3038,6 +3042,7 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - minimal/bellatrix/fork_choice/on_block/pyspec_tests/on_block_finalized_skip_s OK ForkChoice - minimal/bellatrix/fork_choice/on_block/pyspec_tests/on_block_future_block Skip + ForkChoice - minimal/bellatrix/fork_choice/on_block/pyspec_tests/proposer_boost OK ++ ForkChoice - minimal/bellatrix/fork_choice/on_block/pyspec_tests/proposer_boost_is_first_b OK + ForkChoice - minimal/bellatrix/fork_choice/on_block/pyspec_tests/proposer_boost_root_same_ OK + ForkChoice - minimal/bellatrix/fork_choice/on_block/pyspec_tests/pull_up_on_tick OK + ForkChoice - minimal/bellatrix/fork_choice/on_block/pyspec_tests/pull_up_past_epoch_block OK @@ -3087,6 +3092,7 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - minimal/capella/fork_choice/on_block/pyspec_tests/on_block_finalized_skip_slo OK ForkChoice - minimal/capella/fork_choice/on_block/pyspec_tests/on_block_future_block Skip + ForkChoice - minimal/capella/fork_choice/on_block/pyspec_tests/proposer_boost OK ++ ForkChoice - minimal/capella/fork_choice/on_block/pyspec_tests/proposer_boost_is_first_blo OK + ForkChoice - minimal/capella/fork_choice/on_block/pyspec_tests/proposer_boost_root_same_sl OK + ForkChoice - minimal/capella/fork_choice/on_block/pyspec_tests/pull_up_on_tick OK + ForkChoice - minimal/capella/fork_choice/on_block/pyspec_tests/pull_up_past_epoch_block OK @@ -3116,6 +3122,10 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/basic OK + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/incompatible_justification_up OK + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/incompatible_justification_up OK ++ ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/invalid_data_unavailable OK ++ ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/invalid_incorrect_proof OK ++ ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/invalid_wrong_blobs_length OK ++ ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/invalid_wrong_proofs_length OK + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/justification_update_beginnin OK + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/justification_update_end_of_e OK + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/justification_withholding OK @@ -3132,9 +3142,11 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/on_block_finalized_skip_slots OK ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/on_block_future_block Skip + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/proposer_boost OK ++ ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/proposer_boost_is_first_block OK + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/proposer_boost_root_same_slot OK + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/pull_up_on_tick OK + ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/pull_up_past_epoch_block OK ++ ForkChoice - minimal/deneb/fork_choice/on_block/pyspec_tests/simple_blob_data OK + ForkChoice - minimal/deneb/fork_choice/reorg/pyspec_tests/delayed_justification_current_ep OK + ForkChoice - minimal/deneb/fork_choice/reorg/pyspec_tests/delayed_justification_previous_e OK + ForkChoice - minimal/deneb/fork_choice/reorg/pyspec_tests/include_votes_another_empty_chai OK @@ -3146,7 +3158,7 @@ OK: 6/6 Fail: 0/6 Skip: 0/6 + ForkChoice - minimal/deneb/fork_choice/withholding/pyspec_tests/withholding_attack OK + ForkChoice - minimal/deneb/fork_choice/withholding/pyspec_tests/withholding_attack_unviabl OK ``` -OK: 176/184 Fail: 0/184 Skip: 8/184 +OK: 185/193 Fail: 0/193 Skip: 8/193 ## Sync ```diff + Sync - minimal/bellatrix/sync/optimistic/pyspec_tests/from_syncing_to_invalid OK @@ -3156,4 +3168,4 @@ OK: 176/184 Fail: 0/184 Skip: 8/184 OK: 3/3 Fail: 0/3 Skip: 0/3 ---TOTAL--- -OK: 2566/2574 Fail: 0/2574 Skip: 8/2574 +OK: 2578/2586 Fail: 0/2586 Skip: 8/2586 diff --git a/Makefile b/Makefile index b6ebac4f5..94cb0e9a7 100644 --- a/Makefile +++ b/Makefile @@ -118,17 +118,31 @@ ifneq ($(OS), Windows_NT) PLATFORM_SPECIFIC_TARGETS += gnosis-build endif +# We don't need the `vendor/holesky/public-keys/all.txt` file but fetching it +# may trigger 'This repository is over its data quota' from GitHub +GIT_SUBMODULE_CONFIG := -c lfs.fetchexclude=/public-keys/all.txt + ifeq ($(NIM_PARAMS),) # "variables.mk" was not included, so we update the submodules. # # The `git reset ...` will try to fix a `make update` that was interrupted # with Ctrl+C after deleting the working copy and before getting a chance to # restore it in $(BUILD_SYSTEM_DIR). -GIT_SUBMODULE_UPDATE := git submodule update --init --recursive + +# `vendor/holesky` requires Git LFS +ifeq (, $(shell which git-lfs)) +ifeq ($(shell uname), Darwin) +$(error Git LFS not installed. Run 'brew install git-lfs' to set up) +else +$(error Git LFS not installed) +endif +endif + +GIT_SUBMODULE_UPDATE := git $(GIT_SUBMODULE_CONFIG) submodule update --init --recursive .DEFAULT: +@ echo -e "Git submodules not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \ $(GIT_SUBMODULE_UPDATE) && \ - git submodule foreach --quiet 'git reset --quiet --hard' && \ + git submodule foreach --quiet 'git $(GIT_SUBMODULE_CONFIG) reset --quiet --hard' && \ echo # Now that the included *.mk files appeared, and are newer than this file, Make will restart itself: # https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles @@ -307,7 +321,7 @@ consensus_spec_tests_minimal: | build deps MAKE="$(MAKE)" V="$(V)" $(ENV_SCRIPT) scripts/compile_nim_program.sh \ $@ \ "tests/consensus_spec/consensus_spec_tests_preset.nim" \ - $(NIM_PARAMS) -d:const_preset=minimal $(TEST_MODULES_FLAGS) && \ + $(NIM_PARAMS) -d:const_preset=minimal -d:FIELD_ELEMENTS_PER_BLOB=4 $(TEST_MODULES_FLAGS) && \ echo -e $(BUILD_END_MSG) "build/$@" # Tests we only run for the default preset diff --git a/beacon_chain/beacon_chain_db_immutable.nim b/beacon_chain/beacon_chain_db_immutable.nim index e3fd2108d..f3052d7c5 100644 --- a/beacon_chain/beacon_chain_db_immutable.nim +++ b/beacon_chain/beacon_chain_db_immutable.nim @@ -16,7 +16,7 @@ from ./spec/datatypes/capella import from ./spec/datatypes/deneb import ExecutionPayloadHeader type - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconstate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconstate # Memory-representation-equivalent to a phase0 BeaconState for in-place SSZ # reading and writing Phase0BeaconStateNoImmutableValidators* = object @@ -69,7 +69,7 @@ type current_justified_checkpoint*: Checkpoint finalized_checkpoint*: Checkpoint - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#beaconstate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#beaconstate # Memory-representation-equivalent to an Altair BeaconState for in-place SSZ # reading and writing AltairBeaconStateNoImmutableValidators* = object @@ -186,7 +186,7 @@ type # Execution latest_execution_payload_header*: bellatrix.ExecutionPayloadHeader # [New in Bellatrix] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#beaconstate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#beaconstate # with indirect changes via ExecutionPayload # Memory-representation-equivalent to a Capella BeaconState for in-place SSZ # reading and writing @@ -258,7 +258,7 @@ type HashList[HistoricalSummary, Limit HISTORICAL_ROOTS_LIMIT] # [New in Capella] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#beaconstate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#beaconstate # with indirect changes via ExecutionPayloadHeader # Memory-representation-equivalent to a Deneb BeaconState for in-place SSZ # reading and writing diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index ac3a87300..133446192 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -122,23 +122,26 @@ func getPayloadBuilderAddress*(config: BeaconNodeConf): Opt[string] = else: Opt.none(string) +proc getPayloadBuilderAddress*( + node: BeaconNode, pubkey: ValidatorPubKey): Opt[string] = + let defaultPayloadBuilderAddress = node.config.getPayloadBuilderAddress + if node.keymanagerHost.isNil: + defaultPayloadBuilderAddress + else: + node.keymanagerHost[].getBuilderConfig(pubkey).valueOr: + defaultPayloadBuilderAddress + proc getPayloadBuilderClient*( node: BeaconNode, validator_index: uint64): RestResult[RestClientRef] = if not node.config.payloadBuilderEnable: return err "Payload builder globally disabled" let - defaultPayloadBuilderAddress = node.config.getPayloadBuilderAddress pubkey = withState(node.dag.headState): if validator_index >= forkyState.data.validators.lenu64: return err "Validator index too high" forkyState.data.validators.item(validator_index).pubkey - payloadBuilderAddress = - if node.keymanagerHost.isNil: - defaultPayloadBuilderAddress - else: - node.keymanagerHost[].getBuilderConfig(pubkey).valueOr: - defaultPayloadBuilderAddress + payloadBuilderAddress = node.getPayloadBuilderAddress(pubkey) if payloadBuilderAddress.isNone: return err "Payload builder disabled" diff --git a/beacon_chain/beacon_node_light_client.nim b/beacon_chain/beacon_node_light_client.nim index a1539479d..3aad3e68f 100644 --- a/beacon_chain/beacon_node_light_client.nim +++ b/beacon_chain/beacon_node_light_client.nim @@ -46,12 +46,14 @@ proc initLightClient*( wallSlot = node.currentSlot withBlck(signedBlock): when consensusFork >= ConsensusFork.Bellatrix: - if blck.message.is_execution_block: - template blckPayload(): auto = blck.message.body.execution_payload + if forkyBlck.message.is_execution_block: + template blckPayload(): auto = + forkyBlck.message.body.execution_payload if not blckPayload.block_hash.isZero: # engine_newPayloadV1 - discard await node.elManager.newExecutionPayload(blck.message) + discard await node.elManager.newExecutionPayload( + forkyBlck.message) # Retain optimistic head for other `forkchoiceUpdated` callers. # May temporarily block `forkchoiceUpdatedV1` calls, e.g., Geth: @@ -60,7 +62,7 @@ proc initLightClient*( # Once DAG sync catches up or as new optimistic heads are fetched # the situation recovers node.consensusManager[].setOptimisticHead( - blck.toBlockId(), blckPayload.block_hash) + forkyBlck.toBlockId(), blckPayload.block_hash) # engine_forkchoiceUpdatedV1 or engine_forkchoiceUpdatedV2, # depending on pre or post-Shapella @@ -73,7 +75,8 @@ proc initLightClient*( finalizedBlockHash = beaconHead.finalizedExecutionPayloadHash, payloadAttributes = none attributes) - case node.dag.cfg.consensusForkAtEpoch(blck.message.slot.epoch) + case node.dag.cfg.consensusForkAtEpoch( + forkyBlck.message.slot.epoch) of ConsensusFork.Deneb: callForkchoiceUpdated(PayloadAttributesV3) of ConsensusFork.Capella: @@ -173,7 +176,7 @@ proc updateLightClientFromDag*(node: BeaconNode) = const lcDataFork = lcDataForkAtConsensusFork(consensusFork) when lcDataFork > LightClientDataFork.None: header = ForkedLightClientHeader(kind: lcDataFork) - header.forky(lcDataFork) = blck.toLightClientHeader(lcDataFork) + header.forky(lcDataFork) = forkyBlck.toLightClientHeader(lcDataFork) else: raiseAssert "Unreachable" let current_sync_committee = block: let tmpState = assignClone(node.dag.headState) diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index ec1d0c063..bb09a967c 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -29,6 +29,8 @@ import ./el/el_conf, ./filepath +from fork_choice/fork_choice_types + import ForkChoiceVersion from consensus_object_pools/block_pools_types_light_client import LightClientDataImportMode @@ -549,7 +551,7 @@ type name: "dump" .}: bool directPeers* {. - desc: "The list of privileged, secure and known peers to connect and maintain the connection to, this requires a not random netkey-file. In the complete multiaddress format like: /ip4/
/tcp//p2p/. Peering agreements are established out of band and must be reciprocal." + desc: "The list of privileged, secure and known peers to connect and maintain the connection to. This requires a not random netkey-file. In the multiaddress format like: /ip4/
/tcp//p2p/, or enr format (enr:-xx). Peering agreements are established out of band and must be reciprocal" name: "direct-peer" .}: seq[string] doppelgangerDetection* {. @@ -641,6 +643,12 @@ type desc: "Bandwidth estimate for the node (bits per second)" name: "debug-bandwidth-estimate" .}: Option[Natural] + forkChoiceVersion* {. + hidden + desc: "Forkchoice version to use. " & + "Must be one of: stable" + name: "debug-forkchoice-version" .}: Option[ForkChoiceVersion] + of BNStartUpCmd.wallets: case walletsCmd* {.command.}: WalletsCmd of WalletsCmd.create: diff --git a/beacon_chain/consensus_object_pools/README.md b/beacon_chain/consensus_object_pools/README.md index ea2e32c99..cfaf1a514 100644 --- a/beacon_chain/consensus_object_pools/README.md +++ b/beacon_chain/consensus_object_pools/README.md @@ -7,8 +7,8 @@ to specs: - blocks: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_block - aggregate attestations: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof - unaggregated attestation: https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id -- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.1/specs/phase0/p2p-interface.md#voluntary_exit -- Attester slashings: https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#attester_slashing +- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#voluntary_exit +- Attester slashings: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#attester_slashing - Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#proposer_slashing After "gossip validation" the consensus objects can be rebroadcasted as they are optimistically good, however for internal processing further verification is needed. diff --git a/beacon_chain/consensus_object_pools/attestation_pool.nim b/beacon_chain/consensus_object_pools/attestation_pool.nim index efa4fc40d..e2a6a45c8 100644 --- a/beacon_chain/consensus_object_pools/attestation_pool.nim +++ b/beacon_chain/consensus_object_pools/attestation_pool.nim @@ -90,6 +90,7 @@ declareGauge attestation_pool_block_attestation_packing_time, proc init*(T: type AttestationPool, dag: ChainDAGRef, quarantine: ref Quarantine, + forkChoiceVersion = ForkChoiceVersion.Stable, onAttestation: OnAttestationCallback = nil): T = ## Initialize an AttestationPool from the dag `headState` ## The `finalized_root` works around the finalized_checkpoint of the genesis block @@ -97,7 +98,7 @@ proc init*(T: type AttestationPool, dag: ChainDAGRef, let finalizedEpochRef = dag.getFinalizedEpochRef() var forkChoice = ForkChoice.init( - finalizedEpochRef, dag.finalizedHead.blck) + finalizedEpochRef, dag.finalizedHead.blck, forkChoiceVersion) # Feed fork choice with unfinalized history - during startup, block pool only # keeps track of a single history so we just need to follow it @@ -152,7 +153,7 @@ proc init*(T: type AttestationPool, dag: ChainDAGRef, default(FinalityCheckpoints) withBlck(blck): forkChoice.process_block( - dag, epochRef, blckRef, unrealized, blck.message, + dag, epochRef, blckRef, unrealized, forkyBlck.message, blckRef.slot.start_beacon_time) doAssert status.isOk(), "Error in preloading the fork choice: " & $status.error @@ -559,7 +560,7 @@ proc getAttestationsForBlock*(pool: var AttestationPool, cache: var StateCache): seq[Attestation] = ## Retrieve attestations that may be added to a new block at the slot of the ## given state - ## https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#attestations + ## https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/validator.md#attestations let newBlockSlot = state.data.slot.uint64 if newBlockSlot < MIN_ATTESTATION_INCLUSION_DELAY: @@ -742,7 +743,7 @@ func getAggregatedAttestation*(pool: var AttestationPool, index: CommitteeIndex): Opt[Attestation] = ## Select the attestation that has the most votes going for it in the given ## slot/index - ## https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#construct-aggregate + ## https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/validator.md#construct-aggregate let candidateIdx = pool.candidateIdx(slot) if candidateIdx.isNone: return Opt.none(Attestation) @@ -772,7 +773,7 @@ proc getBeaconHead*( finalizedExecutionPayloadHash = pool.dag.loadExecutionBlockHash(pool.dag.finalizedHead.blck) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/fork_choice/safe-block.md#get_safe_execution_payload_hash + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/fork_choice/safe-block.md#get_safe_execution_payload_hash safeBlockRoot = pool.forkChoice.get_safe_beacon_block_root() safeBlock = pool.dag.getBlockRef(safeBlockRoot) safeExecutionPayloadHash = diff --git a/beacon_chain/consensus_object_pools/block_pools_types.nim b/beacon_chain/consensus_object_pools/block_pools_types.nim index b21ea8db2..1082754d6 100644 --- a/beacon_chain/consensus_object_pools/block_pools_types.nim +++ b/beacon_chain/consensus_object_pools/block_pools_types.nim @@ -279,7 +279,7 @@ type # balances, as used in fork choice effective_balances_bytes*: seq[byte] - OnBlockAdded[T] = proc( + OnBlockAdded[T: ForkyTrustedSignedBeaconBlock] = proc( blckRef: BlockRef, blck: T, epochRef: EpochRef, unrealized: FinalityCheckpoints) {.gcsafe, raises: [].} OnPhase0BlockAdded* = OnBlockAdded[phase0.TrustedSignedBeaconBlock] @@ -321,6 +321,20 @@ type block_root* {.serializedFieldName: "block".}: Eth2Digest optimistic* {.serializedFieldName: "execution_optimistic".}: Option[bool] +template OnBlockAddedCallback*(kind: static ConsensusFork): auto = + when kind == ConsensusFork.Deneb: + typedesc[OnDenebBlockAdded] + elif kind == ConsensusFork.Capella: + typedesc[OnCapellaBlockAdded] + elif kind == ConsensusFork.Bellatrix: + typedesc[OnBellatrixBlockAdded] + elif kind == ConsensusFork.Altair: + typedesc[OnAltairBlockAdded] + elif kind == ConsensusFork.Phase0: + typedesc[OnPhase0BlockAdded] + else: + static: raiseAssert "Unreachable" + func proposer_dependent_slot*(epochRef: EpochRef): Slot = epochRef.key.epoch.proposer_dependent_slot() @@ -434,7 +448,7 @@ func init*(t: typedesc[EventBeaconBlockObject], optimistic: Option[bool]): EventBeaconBlockObject = withBlck(v): EventBeaconBlockObject( - slot: blck.message.slot, - block_root: blck.root, + slot: forkyBlck.message.slot, + block_root: forkyBlck.root, optimistic: optimistic ) diff --git a/beacon_chain/consensus_object_pools/blockchain_dag.nim b/beacon_chain/consensus_object_pools/blockchain_dag.nim index 51d7cdd38..9abbbaca5 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag.nim @@ -286,8 +286,8 @@ proc getForkedBlock*( let fork = dag.cfg.consensusForkAtEpoch(bid.slot.epoch) result.ok(ForkedTrustedSignedBeaconBlock(kind: fork)) withBlck(result.get()): - type T = type(blck) - blck = getBlock(dag, bid, T).valueOr: + type T = type(forkyBlck) + forkyBlck = getBlock(dag, bid, T).valueOr: getBlock( dag.era, getStateField(dag.headState, historical_roots).asSeq, dag.headState.historical_summaries().asSeq, @@ -310,7 +310,7 @@ proc getBlockId*(db: BeaconChainDB, root: Eth2Digest): Opt[BlockId] = # Shouldn't happen too often but.. let blck = forked.get() - summary = withBlck(blck): blck.message.toBeaconBlockSummary() + summary = withBlck(blck): forkyBlck.message.toBeaconBlockSummary() debug "Writing summary", blck = shortLog(blck) db.putBeaconBlockSummary(root, summary) return ok(BlockId(root: root, slot: summary.slot)) @@ -1129,7 +1129,7 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB, # should have `previous_version` set to `current_version` while # this doesn't happen to be the case in network that go through # regular hard-fork upgrades. See for example: - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#testing + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#testing if stateFork.current_version != configFork.current_version: error "State from database does not match network, check --network parameter", tail = dag.tail, headRef, stateFork, configFork @@ -1393,9 +1393,9 @@ proc computeRandaoMix( ## Compute the requested RANDAO mix for `bdata` without `state`, if possible. withBlck(bdata): when consensusFork >= ConsensusFork.Bellatrix: - if blck.message.is_execution_block: - var mix = eth2digest(blck.message.body.randao_reveal.toRaw()) - mix.data.mxor blck.message.body.execution_payload.prev_randao.data + if forkyBlck.message.is_execution_block: + var mix = eth2digest(forkyBlck.message.body.randao_reveal.toRaw()) + mix.data.mxor forkyBlck.message.body.execution_payload.prev_randao.data return ok mix Opt.none(Eth2Digest) @@ -1424,14 +1424,15 @@ proc computeRandaoMix*( while bid.slot > ancestorSlot: let bdata = ? dag.getForkedBlock(bid) withBlck(bdata): # See `process_randao` / `process_randao_mixes_reset` - mix.data.mxor eth2digest(blck.message.body.randao_reveal.toRaw()).data + mix.data.mxor eth2digest( + forkyBlck.message.body.randao_reveal.toRaw()).data bid = ? dag.parent(bid) ok() # Mix in RANDAO from `bid` if ancestorSlot < bid.slot: withBlck(bdata): - mix = eth2digest(blck.message.body.randao_reveal.toRaw()) + mix = eth2digest(forkyBlck.message.body.randao_reveal.toRaw()) ? mixToAncestor(? dag.parent(bid)) else: mix.reset() @@ -1931,7 +1932,7 @@ proc pruneBlocksDAG(dag: ChainDAGRef) = prunedHeads = hlen - dag.heads.len, dagPruneDur = Moment.now() - startTick -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/sync/optimistic.md#helpers +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/sync/optimistic.md#helpers template is_optimistic*(dag: ChainDAGRef, bid: BlockId): bool = let blck = if bid.slot <= dag.finalizedHead.slot: @@ -2251,7 +2252,7 @@ proc loadExecutionBlockHash*(dag: ChainDAGRef, bid: BlockId): Eth2Digest = withBlck(blockData): when consensusFork >= ConsensusFork.Bellatrix: - blck.message.body.execution_payload.block_hash + forkyBlck.message.body.execution_payload.block_hash else: ZERO_HASH diff --git a/beacon_chain/consensus_object_pools/blockchain_dag_light_client.nim b/beacon_chain/consensus_object_pools/blockchain_dag_light_client.nim index d6fb09e5f..68e64a5c0 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag_light_client.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag_light_client.nim @@ -218,7 +218,8 @@ proc initLightClientBootstrapForPeriod( if not dag.lcDataStore.db.hasSyncCommittee(period): dag.lcDataStore.db.putSyncCommittee( period, forkyState.data.current_sync_committee) - dag.lcDataStore.db.putHeader(blck.toLightClientHeader(lcDataFork)) + dag.lcDataStore.db.putHeader( + forkyBlck.toLightClientHeader(lcDataFork)) dag.lcDataStore.db.putCurrentSyncCommitteeBranch( bid.slot, forkyState.data.build_proof( altair.CURRENT_SYNC_COMMITTEE_INDEX).get) @@ -275,7 +276,7 @@ proc initLightClientUpdateForPeriod( numParticipants = withBlck(bdata): when consensusFork >= ConsensusFork.Altair: - blck.message.body.sync_aggregate.num_active_participants + forkyBlck.message.body.sync_aggregate.num_active_participants else: raiseAssert "Unreachable" if numParticipants >= maxParticipants: maxParticipants = numParticipants @@ -368,7 +369,7 @@ proc initLightClientUpdateForPeriod( const lcDataFork = lcDataForkAtConsensusFork(consensusFork) update = ForkedLightClientUpdate(kind: lcDataFork) template forkyUpdate: untyped = update.forky(lcDataFork) - forkyUpdate.attested_header = blck.toLightClientHeader(lcDataFork) + forkyUpdate.attested_header = forkyBlck.toLightClientHeader(lcDataFork) forkyUpdate.next_sync_committee = forkyState.data.next_sync_committee forkyUpdate.next_sync_committee_branch = forkyState.data.build_proof(altair.NEXT_SYNC_COMMITTEE_INDEX).get @@ -387,7 +388,8 @@ proc initLightClientUpdateForPeriod( withForkyUpdate(update): when lcDataFork > LightClientDataFork.None: when lcDataFork >= lcDataForkAtConsensusFork(consensusFork): - forkyUpdate.finalized_header = blck.toLightClientHeader(lcDataFork) + forkyUpdate.finalized_header = + forkyBlck.toLightClientHeader(lcDataFork) else: raiseAssert "Unreachable" let bdata = dag.getExistingForkedBlock(signatureBid).valueOr: dag.handleUnexpectedLightClientError(signatureBid.slot) @@ -397,7 +399,7 @@ proc initLightClientUpdateForPeriod( withForkyUpdate(update): when lcDataFork > LightClientDataFork.None: forkyUpdate.sync_aggregate = - blck.asSigned().message.body.sync_aggregate + forkyBlck.asSigned().message.body.sync_aggregate else: raiseAssert "Unreachable" withForkyUpdate(update): when lcDataFork > LightClientDataFork.None: @@ -478,7 +480,7 @@ template lazy_header(name: untyped): untyped {.dirty.} = else: withBlck(bdata.get): when data_fork >= lcDataForkAtConsensusFork(consensusFork): - obj.name = blck.toLightClientHeader(data_fork) + obj.name = forkyBlck.toLightClientHeader(data_fork) else: raiseAssert "Unreachable" `name _ ptr` = addr obj.name `name _ ok` @@ -496,7 +498,7 @@ template lazy_header(name: untyped): untyped {.dirty.} = obj.migrateToDataFork(data_fork) withBlck(bdata.get): when data_fork >= lcDataForkAtConsensusFork(consensusFork): - obj.forky(data_fork).name = blck.toLightClientHeader(data_fork) + obj.forky(data_fork).name = forkyBlck.toLightClientHeader(data_fork) else: raiseAssert "Unreachable" `name _ ptr` = addr obj.forky(data_fork).name `name _ ok` @@ -745,7 +747,7 @@ proc initLightClientDataCache*(dag: ChainDAGRef) = # Create `LightClientUpdate` instances if i < blocks.high: dag.createLightClientUpdates( - forkyState, blck, parentBid = blocks[i + 1]) + forkyState, forkyBlck, parentBid = blocks[i + 1]) else: raiseAssert "Unreachable" let lightClientEndTick = Moment.now() @@ -882,7 +884,8 @@ proc processFinalizationForLightClient*( withBlck(bdata): when consensusFork >= ConsensusFork.Altair: const lcDataFork = lcDataForkAtConsensusFork(consensusFork) - dag.lcDataStore.db.putHeader(blck.toLightClientHeader(lcDataFork)) + dag.lcDataStore.db.putHeader( + forkyBlck.toLightClientHeader(lcDataFork)) else: raiseAssert "Unreachable" dag.lcDataStore.db.putCurrentSyncCommitteeBranch( bid.slot, dag.getLightClientData(bid).current_sync_committee_branch) @@ -1006,7 +1009,7 @@ proc getLightClientBootstrap*( when consensusFork >= ConsensusFork.Altair: const lcDataFork = lcDataForkAtConsensusFork(consensusFork) let - header = blck.toLightClientHeader(lcDataFork) + header = forkyBlck.toLightClientHeader(lcDataFork) bootstrap = dag.getLightClientBootstrap(header) if bootstrap.kind > LightClientDataFork.None: dag.lcDataStore.db.putHeader(header) diff --git a/beacon_chain/consensus_object_pools/spec_cache.nim b/beacon_chain/consensus_object_pools/spec_cache.nim index 2d82b6d81..2f7844065 100644 --- a/beacon_chain/consensus_object_pools/spec_cache.nim +++ b/beacon_chain/consensus_object_pools/spec_cache.nim @@ -25,7 +25,7 @@ logScope: topics = "spec_cache" func count_active_validators*(shufflingRef: ShufflingRef): uint64 = shufflingRef.shuffled_active_validator_indices.lenu64 -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_committee_count_per_slot +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_committee_count_per_slot func get_committee_count_per_slot*(shufflingRef: ShufflingRef): uint64 = get_committee_count_per_slot(count_active_validators(shufflingRef)) @@ -38,7 +38,7 @@ func get_committee_index*(shufflingRef: ShufflingRef, index: uint64): Result[CommitteeIndex, cstring] = check_attestation_index(index, get_committee_count_per_slot(shufflingRef)) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_beacon_committee +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_beacon_committee iterator get_beacon_committee*( shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex): (int, ValidatorIndex) = @@ -51,7 +51,7 @@ iterator get_beacon_committee*( committees_per_slot * SLOTS_PER_EPOCH ): yield (index_in_committee, idx) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_beacon_committee +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_beacon_committee func get_beacon_committee*( shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex): seq[ValidatorIndex] = @@ -64,7 +64,7 @@ func get_beacon_committee*( committees_per_slot * SLOTS_PER_EPOCH ) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_beacon_committee +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_beacon_committee func get_beacon_committee_len*( shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex): uint64 = ## Return the number of members in the beacon committee at ``slot`` for ``index``. @@ -76,7 +76,7 @@ func get_beacon_committee_len*( committees_per_slot * SLOTS_PER_EPOCH ) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_attesting_indices +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_attesting_indices iterator get_attesting_indices*(shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex, @@ -155,7 +155,7 @@ func get_attesting_indices_one*(shufflingRef: ShufflingRef, res = some(validator_index) res -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_attesting_indices +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_attesting_indices func get_attesting_indices*(shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex, diff --git a/beacon_chain/deposits.nim b/beacon_chain/deposits.nim index 63d194894..01f4bd1c9 100644 --- a/beacon_chain/deposits.nim +++ b/beacon_chain/deposits.nim @@ -228,7 +228,7 @@ proc restValidatorExit(config: BeaconNodeConf) {.async.} = block: let s = spec.getOrDefault("DENEB_FORK_EPOCH", $FAR_FUTURE_EPOCH) Epoch(Base10.decode(uint64, s).get(uint64(FAR_FUTURE_EPOCH))) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#voluntary-exits + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#voluntary-exits # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#modified-process_voluntary_exit if currentEpoch >= denebForkEpoch: let capellaForkVersion = diff --git a/beacon_chain/el/el_manager.nim b/beacon_chain/el/el_manager.nim index 9cec29915..df7f2564d 100644 --- a/beacon_chain/el/el_manager.nim +++ b/beacon_chain/el/el_manager.nim @@ -10,11 +10,11 @@ import std/[deques, strformat, strutils, sequtils, tables, typetraits, uri, json], # Nimble packages: - chronos, metrics, chronicles/timings, stint/endians2, + chronos, metrics, chronicles/timings, json_rpc/[client, errors], web3, web3/ethhexstrings, web3/engine_api, eth/common/[eth_types, transaction], - eth/async_utils, stew/[assign2, byteutils, objects, results, shims/hashes], + eth/async_utils, stew/[assign2, byteutils, objects, results, shims/hashes, endians2], # Local modules: ../spec/[deposit_snapshots, eth2_merkleization, forks, helpers], ../spec/datatypes/[base, phase0, bellatrix, deneb], @@ -353,7 +353,7 @@ proc trackEngineApiRequest(connection: ELConnection, deadline.addCallback do (udata: pointer) {.gcsafe, raises: [].}: if not request.finished: - request.cancel() + request.cancelSoon() engine_api_timeouts.inc(1, [connection.engineUrl.url, requestName]) if not failureAllowed: connection.setDegradedState(requestName, 0, "Request timed out") @@ -944,7 +944,7 @@ proc getPayload*(m: ELManager, var bestPayloadIdx = none int for idx, req in requests: if not req.finished: - req.cancel() + req.cancelSoon() elif req.failed: error "Failed to get execution payload from EL", url = m.elConnections[idx].engineUrl.url, @@ -1059,12 +1059,12 @@ proc selectConnectionForChainSyncing(m: ELManager): Future[ELConnection] {.async await firstCompletedFuture(connectionsFuts) except CancelledError as err: for future in connectionsFuts: - future.cancel() + future.cancelSoon() raise err for future in connectionsFuts: if future != firstConnected: - future.cancel() + future.cancelSoon() return m.elConnections[find(connectionsFuts, firstConnected)] @@ -1447,7 +1447,7 @@ proc exchangeTransitionConfiguration*(m: ELManager) {.async.} = var cancelled = 0 for idx, req in requests: if not req.finished: - req.cancel() + req.cancelSoon() inc cancelled if cancelled == requests.len: @@ -1871,7 +1871,7 @@ proc new*(T: type ELManager, proc safeCancel(fut: var Future[void]) = if not fut.isNil and not fut.finished: - fut.cancel() + fut.cancelSoon() fut = nil func clear(chain: var Eth1Chain) = diff --git a/beacon_chain/el/merkle_minimal.nim b/beacon_chain/el/merkle_minimal.nim index d943e0c43..f5c735ec7 100644 --- a/beacon_chain/el/merkle_minimal.nim +++ b/beacon_chain/el/merkle_minimal.nim @@ -7,7 +7,7 @@ {.push raises: [].} -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/tests/core/pyspec/eth2spec/utils/merkle_minimal.py +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/tests/core/pyspec/eth2spec/utils/merkle_minimal.py # Merkle tree helpers # --------------------------------------------------------------- diff --git a/beacon_chain/fork_choice/README.md b/beacon_chain/fork_choice/README.md index 09e01c8c1..ea1142edd 100644 --- a/beacon_chain/fork_choice/README.md +++ b/beacon_chain/fork_choice/README.md @@ -1,5 +1,5 @@ # Fork choice implementations References: -- https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/fork-choice.md +- https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/fork-choice.md - https://github.com/protolambda/lmd-ghost diff --git a/beacon_chain/fork_choice/fork_choice.nim b/beacon_chain/fork_choice/fork_choice.nim index 2311f0f39..bb92f584e 100644 --- a/beacon_chain/fork_choice/fork_choice.nim +++ b/beacon_chain/fork_choice/fork_choice.nim @@ -49,11 +49,13 @@ func compute_deltas( logScope: topics = "fork_choice" func init*( - T: type ForkChoiceBackend, checkpoints: FinalityCheckpoints): T = - T(proto_array: ProtoArray.init(checkpoints)) + T: type ForkChoiceBackend, checkpoints: FinalityCheckpoints, + version: ForkChoiceVersion): T = + T(proto_array: ProtoArray.init(checkpoints, version)) proc init*( - T: type ForkChoice, epochRef: EpochRef, blck: BlockRef): T = + T: type ForkChoice, epochRef: EpochRef, blck: BlockRef, + version: ForkChoiceVersion): T = ## Initialize a fork choice context for a finalized state - in the finalized ## state, the justified and finalized checkpoints are the same, so only one ## is used here @@ -65,10 +67,13 @@ proc init*( backend: ForkChoiceBackend.init( FinalityCheckpoints( justified: checkpoint, - finalized: checkpoint)), + finalized: checkpoint), + version), checkpoints: Checkpoints( + version: version, justified: BalanceCheckpoint( checkpoint: checkpoint, + total_active_balance: epochRef.total_active_balance, balances: epochRef.effective_balances), finalized: checkpoint, best_justified: checkpoint)) @@ -94,6 +99,7 @@ proc update_justified( store = self.justified.checkpoint, state = justified self.justified = BalanceCheckpoint( checkpoint: Checkpoint(root: blck.root, epoch: epochRef.epoch), + total_active_balance: epochRef.total_active_balance, balances: epochRef.effective_balances) proc update_justified( @@ -287,7 +293,9 @@ proc process_block*(self: var ForkChoice, # Add proposer score boost if the block is timely let slot = self.checkpoints.time.slotOrZero - if slot == blck.slot and self.checkpoints.time < slot.attestation_deadline: + if slot == blck.slot and + self.checkpoints.time < slot.attestation_deadline and + self.checkpoints.proposer_boost_root == ZERO_HASH: self.checkpoints.proposer_boost_root = blckRef.root # Update checkpoints in store if necessary @@ -315,10 +323,11 @@ proc process_block*(self: var ForkChoice, ok() -func find_head*( +func find_head( self: var ForkChoiceBackend, current_epoch: Epoch, checkpoints: FinalityCheckpoints, + justified_total_active_balance: Gwei, justified_state_balances: seq[Gwei], proposer_boost_root: Eth2Digest ): FcResult[Eth2Digest] = @@ -337,7 +346,7 @@ func find_head*( # Apply score changes ? self.proto_array.applyScoreChanges( deltas, current_epoch, checkpoints, - justified_state_balances, proposer_boost_root) + justified_total_active_balance, proposer_boost_root) self.balances = justified_state_balances @@ -361,10 +370,11 @@ proc get_head*(self: var ForkChoice, FinalityCheckpoints( justified: self.checkpoints.justified.checkpoint, finalized: self.checkpoints.finalized), + self.checkpoints.justified.total_active_balance, self.checkpoints.justified.balances, self.checkpoints.proposer_boost_root) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/fork_choice/safe-block.md#get_safe_beacon_block_root +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/fork_choice/safe-block.md#get_safe_beacon_block_root func get_safe_beacon_block_root*(self: ForkChoice): Eth2Digest = # Use most recent justified block as a stopgap self.checkpoints.justified.checkpoint.root diff --git a/beacon_chain/fork_choice/fork_choice_types.nim b/beacon_chain/fork_choice/fork_choice_types.nim index 593167259..50cc63c5d 100644 --- a/beacon_chain/fork_choice/fork_choice_types.nim +++ b/beacon_chain/fork_choice/fork_choice_types.nim @@ -29,6 +29,14 @@ import # ---------------------------------------------------------------------- type + ForkChoiceVersion* {.pure.} = enum + ## Controls which version of fork choice to run. + Stable = "stable" + ## Use current version from stable Ethereum consensus specifications + Pr3431 = "pr3431" + ## https://github.com/ethereum/consensus-specs/pull/3431 + ## https://github.com/ethereum/consensus-specs/issues/3466 + fcKind* = enum ## Fork Choice Error Kinds fcFinalizedNodeUnknown @@ -88,6 +96,7 @@ type ## Subtracted from logical index to get the physical index ProtoArray* = object + version*: ForkChoiceVersion currentEpoch*: Epoch checkpoints*: FinalityCheckpoints nodes*: ProtoNodes @@ -107,9 +116,11 @@ type BalanceCheckpoint* = object checkpoint*: Checkpoint + total_active_balance*: Gwei balances*: seq[Gwei] Checkpoints* = object + version*: ForkChoiceVersion time*: BeaconTime justified*: BalanceCheckpoint finalized*: Checkpoint diff --git a/beacon_chain/fork_choice/proto_array.nim b/beacon_chain/fork_choice/proto_array.nim index 558b985d1..02075ea0b 100644 --- a/beacon_chain/fork_choice/proto_array.nim +++ b/beacon_chain/fork_choice/proto_array.nim @@ -90,7 +90,8 @@ func nodeLeadsToViableHead( # ---------------------------------------------------------------------- func init*( - T: type ProtoArray, checkpoints: FinalityCheckpoints): T = + T: type ProtoArray, checkpoints: FinalityCheckpoints, + version: ForkChoiceVersion): T = let node = ProtoNode( bid: BlockId( slot: checkpoints.finalized.epoch.start_slot, @@ -102,7 +103,8 @@ func init*( bestChild: none(int), bestDescendant: none(int)) - T(checkpoints: checkpoints, + T(version: version, + checkpoints: checkpoints, nodes: ProtoNodes(buf: @[node], offset: 0), indices: {node.bid.root: 0}.toTable()) @@ -124,18 +126,15 @@ iterator realizePendingCheckpoints*( self.currentEpochTips.clear() # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/fork-choice.md#get_weight -func calculateProposerBoost(validatorBalances: openArray[Gwei]): uint64 = - var total_balance: uint64 - for balance in validatorBalances: - total_balance += balance - let committee_weight = total_balance div SLOTS_PER_EPOCH +func calculateProposerBoost(justifiedTotalActiveBalance: Gwei): Gwei = + let committee_weight = justifiedTotalActiveBalance div SLOTS_PER_EPOCH (committee_weight * PROPOSER_SCORE_BOOST) div 100 func applyScoreChanges*(self: var ProtoArray, deltas: var openArray[Delta], currentEpoch: Epoch, checkpoints: FinalityCheckpoints, - newBalances: openArray[Gwei], + justifiedTotalActiveBalance: Gwei, proposerBoostRoot: Eth2Digest): FcResult[void] = ## Iterate backwards through the array, touching all nodes and their parents ## and potentially the best-child of each parent. @@ -167,7 +166,7 @@ func applyScoreChanges*(self: var ProtoArray, self.nodes.buf[nodePhysicalIdx] # Default value, if not otherwise set in first node loop - var proposerBoostScore: uint64 + var proposerBoostScore: Gwei # Iterate backwards through all the indices in `self.nodes` for nodePhysicalIdx in countdown(self.nodes.len - 1, 0): @@ -192,7 +191,7 @@ func applyScoreChanges*(self: var ProtoArray, # # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/fork-choice.md#get_weight if (not proposerBoostRoot.isZero) and proposerBoostRoot == node.bid.root: - proposerBoostScore = calculateProposerBoost(newBalances) + proposerBoostScore = calculateProposerBoost(justifiedTotalActiveBalance) if nodeDelta >= 0 and high(Delta) - nodeDelta < proposerBoostScore.int64: return err ForkChoiceError( @@ -531,17 +530,25 @@ func nodeIsViableForHead( self.checkpoints.justified.epoch == GENESIS_EPOCH or node.checkpoints.justified.epoch == self.checkpoints.justified.epoch - # If the previous epoch is justified, the block should be pulled-up. - # In this case, check that unrealized justification is higher than the store - # and that the voting source is not more than two epochs ago - if not correctJustified and self.isPreviousEpochJustified and - node.bid.slot.epoch == self.currentEpoch: - let unrealized = - self.currentEpochTips.getOrDefault(nodeIdx, node.checkpoints) - correctJustified = - unrealized.justified.epoch >= self.checkpoints.justified.epoch and - node.checkpoints.justified.epoch + 2 >= self.currentEpoch - + if not correctJustified: + case self.version + of ForkChoiceVersion.Stable: + # If the previous epoch is justified, the block should be pulled-up. + # In this case, check that unrealized justification is higher than the + # store and that the voting source is not more than two epochs ago + if self.isPreviousEpochJustified and + node.bid.slot.epoch == self.currentEpoch: + let unrealized = + self.currentEpochTips.getOrDefault(nodeIdx, node.checkpoints) + correctJustified = + unrealized.justified.epoch >= self.checkpoints.justified.epoch and + node.checkpoints.justified.epoch + 2 >= self.currentEpoch + of ForkChoiceVersion.Pr3431: + # The voting source should be either at the same height as the store's + # justified checkpoint or not more than two epochs ago + correctJustified = + node.checkpoints.justified.epoch + 2 >= self.currentEpoch + return if not correctJustified: false diff --git a/beacon_chain/future_combinators.nim b/beacon_chain/future_combinators.nim index 7c0d7c5d9..5a22a5a92 100644 --- a/beacon_chain/future_combinators.nim +++ b/beacon_chain/future_combinators.nim @@ -102,4 +102,4 @@ proc firstCompleted*[T](futs: varargs[Future[T]]): Future[T] = subFuture.addCallback(cb, cast[pointer](subFuture)) retFuture.cancelCallback = proc (udata: pointer) = - subFuture.cancel() + subFuture.cancelSoon() diff --git a/beacon_chain/gossip_processing/README.md b/beacon_chain/gossip_processing/README.md index 5c05470eb..83f6eccba 100644 --- a/beacon_chain/gossip_processing/README.md +++ b/beacon_chain/gossip_processing/README.md @@ -9,11 +9,11 @@ This folder holds a collection of modules to: Gossip validation is different from consensus verification in particular for blocks. -- Blocks: https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_block +- Blocks: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_block - Attestations (aggregated): https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof - Attestations (unaggregated): https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#attestation-subnets - Voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#voluntary_exit -- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md#proposer_slashing +- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#proposer_slashing - Attester slashing: https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md#attester_slashing There are multiple consumers of validated consensus objects: diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim index f75bea5fe..df8d80a88 100644 --- a/beacon_chain/gossip_processing/block_processor.nim +++ b/beacon_chain/gossip_processing/block_processor.nim @@ -388,10 +388,10 @@ proc enqueueBlock*( maybeFinalized = false, validationDur = Duration()) = withBlck(blck): - if blck.message.slot <= self.consensusManager.dag.finalizedHead.slot: + if forkyBlck.message.slot <= self.consensusManager.dag.finalizedHead.slot: # let backfill blocks skip the queue - these are always "fast" to process # because there are no state rewinds to deal with - let res = self.storeBackfillBlock(blck, blobs) + let res = self.storeBackfillBlock(forkyBlck, blobs) resfut.complete(res) return @@ -732,25 +732,25 @@ proc storeBlock( quarantined = shortLog(quarantined.root) withBlck(quarantined): - when typeof(blck).toFork() < ConsensusFork.Deneb: + when typeof(forkyBlck).toFork() < ConsensusFork.Deneb: self[].enqueueBlock( MsgSource.gossip, quarantined, Opt.none(BlobSidecars)) else: - if len(blck.message.body.blob_kzg_commitments) == 0: + if len(forkyBlck.message.body.blob_kzg_commitments) == 0: self[].enqueueBlock( MsgSource.gossip, quarantined, Opt.some(BlobSidecars @[])) else: - if (let res = checkBloblessSignature(self[], blck); res.isErr): + if (let res = checkBloblessSignature(self[], forkyBlck); res.isErr): warn "Failed to verify signature of unorphaned blobless block", - blck = shortLog(blck), + blck = shortLog(forkyBlck), error = res.error() continue - if self.blobQuarantine[].hasBlobs(blck): - let blobs = self.blobQuarantine[].popBlobs(blck.root) + if self.blobQuarantine[].hasBlobs(forkyBlck): + let blobs = self.blobQuarantine[].popBlobs(forkyBlck.root) self[].enqueueBlock(MsgSource.gossip, quarantined, Opt.some(blobs)) else: if not self.consensusManager.quarantine[].addBlobless( - dag.finalizedHead.slot, blck): + dag.finalizedHead.slot, forkyBlck): notice "Block quarantine full (blobless)", blockRoot = shortLog(quarantined.root), signature = shortLog(quarantined.signature) @@ -795,7 +795,7 @@ proc processBlock( let res = withBlck(entry.blck): await self.storeBlock( - entry.src, wallTime, blck, entry.blobs, entry.maybeFinalized, + entry.src, wallTime, forkyBlck, entry.blobs, entry.maybeFinalized, entry.queueTick, entry.validationDur) if res.isErr and res.error[1] == ProcessingStatus.notCompleted: @@ -804,7 +804,7 @@ proc processBlock( # - MUST NOT optimistically import the block. # - MUST NOT apply the block to the fork choice store. # - MAY queue the block for later processing. - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/sync/optimistic.md#execution-engine-errors + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/sync/optimistic.md#execution-engine-errors await sleepAsync(chronos.seconds(1)) self[].enqueueBlock( entry.src, entry.blck, entry.blobs, entry.resfut, entry.maybeFinalized, diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index a7f80ccc0..e9a7e7836 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -658,7 +658,7 @@ proc processSignedContributionAndProof*( err(v.error()) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update proc processLightClientFinalityUpdate*( self: var Eth2Processor, src: MsgSource, finality_update: ForkedLightClientFinalityUpdate @@ -674,7 +674,7 @@ proc processLightClientFinalityUpdate*( beacon_light_client_finality_update_dropped.inc(1, [$v.error[0]]) v -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#process_light_client_optimistic_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#process_light_client_optimistic_update proc processLightClientOptimisticUpdate*( self: var Eth2Processor, src: MsgSource, optimistic_update: ForkedLightClientOptimisticUpdate diff --git a/beacon_chain/gossip_processing/gossip_validation.nim b/beacon_chain/gossip_processing/gossip_validation.nim index d2cc4f5d6..db7e3a26f 100644 --- a/beacon_chain/gossip_processing/gossip_validation.nim +++ b/beacon_chain/gossip_processing/gossip_validation.nim @@ -99,18 +99,19 @@ func check_propagation_slot_range( # The spec value of ATTESTATION_PROPAGATION_SLOT_RANGE is 32, but it can # retransmit attestations on the cusp of being out of spec, and which by # the time they reach their destination might be out of spec. - const ATTESTATION_PROPAGATION_SLOT_RANGE = 28 - - if msgSlot + ATTESTATION_PROPAGATION_SLOT_RANGE < pastSlot.slot: + const TIME_IN_FLIGHT_BUFFER = 4 + static: doAssert ATTESTATION_PROPAGATION_SLOT_RANGE > TIME_IN_FLIGHT_BUFFER + if msgSlot + (ATTESTATION_PROPAGATION_SLOT_RANGE - TIME_IN_FLIGHT_BUFFER) < + pastSlot.slot: return errIgnore("Attestation slot in the past") else: - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#beacon_attestation_subnet_id + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#beacon_attestation_subnet_id # "[IGNORE] the epoch of attestation.data.slot is either the current or # previous epoch (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) -- i.e. # compute_epoch_at_slot(attestation.data.slot) in # (get_previous_epoch(state), get_current_epoch(state))" # - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof # "[IGNORE] the epoch of aggregate.data.slot is either the current or # previous epoch (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) -- i.e. # compute_epoch_at_slot(aggregate.data.slot) in @@ -301,7 +302,7 @@ template validateBeaconBlockBellatrix( # cannot occur here, because Nimbus's optimistic sync waits for either # `ACCEPTED` or `SYNCING` from the EL to get this far. -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#blob_sidecar_subnet_id +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#blob_sidecar_subnet_id proc validateBlobSidecar*( dag: ChainDAGRef, quarantine: ref Quarantine, blobQuarantine: ref BlobQuarantine,sbs: SignedBlobSidecar, @@ -560,7 +561,7 @@ proc validateBeaconBlock*( ok() # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof proc validateAttestation*( pool: ref AttestationPool, batchCrypto: ref BatchCrypto, @@ -590,7 +591,7 @@ proc validateAttestation*( # >= attestation.data.slot (a client MAY queue future attestations for # processing at the appropriate slot). # - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#beacon_attestation_subnet_id + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#beacon_attestation_subnet_id # modifies this for Deneb and newer forks. block: let v = check_propagation_slot_range( @@ -731,7 +732,7 @@ proc validateAttestation*( return ok((validator_index, sig)) # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof proc validateAggregate*( pool: ref AttestationPool, batchCrypto: ref BatchCrypto, @@ -762,7 +763,7 @@ proc validateAggregate*( # MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) -- i.e. aggregate.data.slot + # ATTESTATION_PROPAGATION_SLOT_RANGE >= current_slot >= aggregate.data.slot # - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof # modifies this for Deneb and newer forks. block: let v = check_propagation_slot_range( @@ -1170,14 +1171,11 @@ proc validateContribution*( checkSignature: bool ): Future[Result[ (BlockId, CookedSig, seq[ValidatorIndex]), ValidationError]] {.async.} = - let - syncCommitteeSlot = msg.message.contribution.slot - - # [IGNORE] The contribution's slot is for the current slot - # (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) - # i.e. contribution.slot == current_slot. block: - let v = check_slot_exact(syncCommitteeSlot, wallTime) + # [IGNORE] The contribution's slot is for the current slot + # (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) + # i.e. contribution.slot == current_slot. + let v = check_slot_exact(msg.message.contribution.slot, wallTime) if v.isErr(): # [IGNORE] return err(v.error()) @@ -1220,7 +1218,7 @@ proc validateContribution*( # between validation and use - nonetheless, a design that avoids it and # stays safe would be nice participants = dag.syncCommitteeParticipants( - msg.message.contribution.slot, subcommitteeIdx) + msg.message.contribution.slot + 1, subcommitteeIdx) if aggregator_index notin participants: return dag.checkedReject("Contribution: aggregator not in subcommittee") @@ -1307,7 +1305,7 @@ proc validateContribution*( return ok((blck.bid, sig, participants)) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#light_client_finality_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#light_client_finality_update proc validateLightClientFinalityUpdate*( pool: var LightClientPool, dag: ChainDAGRef, finality_update: ForkedLightClientFinalityUpdate, @@ -1343,7 +1341,7 @@ proc validateLightClientFinalityUpdate*( pool.latestForwardedFinalitySlot = finalized_slot ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update proc validateLightClientOptimisticUpdate*( pool: var LightClientPool, dag: ChainDAGRef, optimistic_update: ForkedLightClientOptimisticUpdate, diff --git a/beacon_chain/gossip_processing/light_client_processor.nim b/beacon_chain/gossip_processing/light_client_processor.nim index be5aadd8a..b51d75063 100644 --- a/beacon_chain/gossip_processing/light_client_processor.nim +++ b/beacon_chain/gossip_processing/light_client_processor.nim @@ -528,7 +528,7 @@ func toValidationError( # previously forwarded `optimistic_update`s errIgnore($r.error) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update proc processLightClientFinalityUpdate*( self: var LightClientProcessor, src: MsgSource, finality_update: ForkedLightClientFinalityUpdate @@ -543,7 +543,7 @@ proc processLightClientFinalityUpdate*( self.latestFinalityUpdate = finality_update.toOptimistic v -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update proc processLightClientOptimisticUpdate*( self: var LightClientProcessor, src: MsgSource, optimistic_update: ForkedLightClientOptimisticUpdate diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.h b/beacon_chain/libnimbus_lc/libnimbus_lc.h index bd6019367..9041f976f 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.h +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.h @@ -94,7 +94,7 @@ typedef struct ETHConsensusConfig ETHConsensusConfig; * based on the given `config.yaml` file content - If successful. * @return `NULL` - If the given `config.yaml` is malformed or incompatible. * - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/configs/README.md + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/configs/README.md */ ETH_RESULT_USE_CHECK ETHConsensusConfig *ETHConsensusConfigCreateFromYaml(const char *configFileContent); @@ -152,8 +152,8 @@ typedef struct ETHBeaconState ETHBeaconState; * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconstate * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#beaconstate * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#beaconstate - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/capella/beacon-chain.md#beaconstate - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/configs/README.md + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#beaconstate + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/configs/README.md */ ETH_RESULT_USE_CHECK ETHBeaconState *ETHBeaconStateCreateFromSsz( @@ -198,7 +198,7 @@ ETHRoot *ETHBeaconStateCopyGenesisValidatorsRoot(const ETHBeaconState *state); * * @param root Merkle root. * - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/phase0/beacon-chain.md#custom-types + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#custom-types */ void ETHRootDestroy(ETHRoot *root); @@ -576,7 +576,7 @@ typedef struct ETHLightClientHeader ETHLightClientHeader; * * @return Latest finalized header. * - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/capella/light-client/sync-protocol.md#modified-lightclientheader + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#modified-lightclientheader */ ETH_RESULT_USE_CHECK const ETHLightClientHeader *ETHLightClientStoreGetFinalizedHeader( @@ -595,7 +595,7 @@ const ETHLightClientHeader *ETHLightClientStoreGetFinalizedHeader( * @return Whether or not the next sync committee is currently known. * * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/altair/light-client/light-client.md + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/light-client.md */ ETH_RESULT_USE_CHECK bool ETHLightClientStoreIsNextSyncCommitteeKnown(const ETHLightClientStore *store); @@ -669,7 +669,7 @@ void ETHLightClientHeaderDestroy(ETHLightClientHeader *header); * * @return Pointer to a copy of the given header's beacon block root. * - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/phase0/beacon-chain.md#hash_tree_root + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#hash_tree_root */ ETH_RESULT_USE_CHECK ETHRoot *ETHLightClientHeaderCopyBeaconRoot( @@ -692,7 +692,7 @@ typedef struct ETHBeaconBlockHeader ETHBeaconBlockHeader; * * @return Beacon block header. * - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/phase0/beacon-chain.md#beaconblockheader + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconblockheader */ ETH_RESULT_USE_CHECK const ETHBeaconBlockHeader *ETHLightClientHeaderGetBeacon( @@ -795,7 +795,7 @@ typedef struct ETHExecutionPayloadHeader ETHExecutionPayloadHeader; * * @return Execution payload header. * - * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#executionpayloadheader + * @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#executionpayloadheader */ ETH_RESULT_USE_CHECK const ETHExecutionPayloadHeader *ETHLightClientHeaderGetExecution( diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index d8dbb42be..a37a07cac 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -79,7 +79,7 @@ proc ETHConsensusConfigCreateFromYaml( ## * `NULL` - If the given `config.yaml` is malformed or incompatible. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/configs/README.md + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/configs/README.md let cfg = RuntimeConfig.new() try: cfg[] = readRuntimeConfig($configFileContent, "config.yaml")[0] @@ -143,11 +143,11 @@ proc ETHBeaconStateCreateFromSsz( ## * `NULL` - If the given `sszBytes` is malformed. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconstate - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#beaconstate - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#beaconstate - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#beaconstate - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/configs/README.md + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconstate + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#beaconstate + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#beaconstate + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#beaconstate + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/configs/README.md let consensusFork = decodeEthConsensusVersion($consensusVersion).valueOr: return nil @@ -196,7 +196,7 @@ proc ETHRootDestroy(root: ptr Eth2Digest) {.exported.} = ## * `root` - Merkle root. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#custom-types + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#custom-types root.destroy() proc ETHForkDigestsCreateFromState( @@ -215,7 +215,7 @@ proc ETHForkDigestsCreateFromState( ## * Pointer to an initialized fork digests cache based on the beacon state. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_fork_digest + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_fork_digest let forkDigests = ForkDigests.new() forkDigests[] = ForkDigests.init( cfg[], getStateField(state[], genesis_validators_root)) @@ -266,7 +266,7 @@ proc ETHBeaconClockGetSlot(beaconClock: ptr BeaconClock): cint {.exported.} = ## * `0` - If genesis is still pending. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#custom-types + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#custom-types beaconClock[].now().slotOrZero().cint const lcDataFork = LightClientDataFork.high @@ -325,8 +325,8 @@ proc ETHLightClientStoreCreateFromBootstrap( ## See: ## * https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.1#/Beacon/getLightClientBootstrap ## * https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.1#/Events/eventstream - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/light-client.md - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/weak-subjectivity.md#weak-subjectivity-period + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/light-client.md + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/weak-subjectivity.md#weak-subjectivity-period let mediaType = MediaType.init($mediaType) consensusFork = decodeEthConsensusVersion($consensusVersion).valueOr: @@ -732,7 +732,7 @@ func ETHLightClientStoreGetFinalizedHeader( ## * Latest finalized header. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#modified-lightclientheader + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/sync-protocol.md#modified-lightclientheader addr store[].finalized_header func ETHLightClientStoreIsNextSyncCommitteeKnown( @@ -751,8 +751,8 @@ func ETHLightClientStoreIsNextSyncCommitteeKnown( ## * Whether or not the next sync committee is currently known. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/light-client.md + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/light-client.md store[].is_next_sync_committee_known func ETHLightClientStoreGetOptimisticHeader( @@ -771,7 +771,7 @@ func ETHLightClientStoreGetOptimisticHeader( ## * Latest optimistic header. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#modified-lightclientheader + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/sync-protocol.md#modified-lightclientheader addr store[].optimistic_header func ETHLightClientStoreGetSafetyThreshold( @@ -792,7 +792,7 @@ func ETHLightClientStoreGetSafetyThreshold( ## * Light client store safety threshold. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#get_safety_threshold + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#get_safety_threshold store[].get_safety_threshold.cint proc ETHLightClientHeaderCreateCopy( @@ -838,7 +838,7 @@ proc ETHLightClientHeaderCopyBeaconRoot( ## * Pointer to a copy of the given header's beacon block root. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#hash_tree_root + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#hash_tree_root discard cfg # Future-proof against new fields, see `get_lc_execution_root`. let root = Eth2Digest.new() root[] = header[].beacon.hash_tree_root() @@ -860,7 +860,7 @@ func ETHLightClientHeaderGetBeacon( ## * Beacon block header. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconblockheader + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconblockheader addr header[].beacon func ETHBeaconBlockHeaderGetSlot( @@ -948,7 +948,7 @@ proc ETHLightClientHeaderCopyExecutionHash( ## * Pointer to a copy of the given header's execution block hash. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#executionpayloadheader + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#executionpayloadheader discard cfg # Future-proof against SSZ execution block header, EIP-6404ff. let root = Eth2Digest.new() root[] = header[].execution.block_hash @@ -973,7 +973,7 @@ func ETHLightClientHeaderGetExecution( ## * Execution payload header. ## ## See: - ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#executionpayloadheader + ## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#executionpayloadheader addr header[].execution func ETHExecutionPayloadHeaderGetParentHash( @@ -1564,6 +1564,9 @@ proc ETHTransactionsCreateFromJson( if data.hash.asEth2Digest != hash: return nil + template isEven(x: int64): bool = + (x and 1) == 0 + # Compute from execution address var rawSig {.noinit.}: array[65, byte] rawSig[0 ..< 32] = tx.R.toBytesBE() diff --git a/beacon_chain/light_client.nim b/beacon_chain/light_client.nim index d7c7f151a..2c7439fa6 100644 --- a/beacon_chain/light_client.nim +++ b/beacon_chain/light_client.nim @@ -353,7 +353,7 @@ proc installMessageValidators*( digest = forkDigests[].atConsensusFork(contextFork) # light_client_optimistic_update - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#light_client_finality_update + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#light_client_finality_update lightClient.network.addValidator( getLightClientFinalityUpdateTopic(digest), proc ( msg: lcDataFork.LightClientFinalityUpdate @@ -361,7 +361,7 @@ proc installMessageValidators*( validate(msg, contextFork, processLightClientFinalityUpdate)) # light_client_optimistic_update - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update lightClient.network.addValidator( getLightClientOptimisticUpdateTopic(digest), proc ( msg: lcDataFork.LightClientOptimisticUpdate diff --git a/beacon_chain/networking/eth2_network.nim b/beacon_chain/networking/eth2_network.nim index 6b9a498cd..ed376d9ae 100644 --- a/beacon_chain/networking/eth2_network.nim +++ b/beacon_chain/networking/eth2_network.nim @@ -48,6 +48,8 @@ type ErrorMsg = List[byte, 256] SendResult* = Result[void, cstring] + DirectPeers = Table[PeerId, seq[MultiAddress]] + # TODO: This is here only to eradicate a compiler # warning about unused import (rpc/messages). GossipMsg = messages.Message @@ -77,6 +79,7 @@ type forkDigests*: ref ForkDigests rng*: ref HmacDrbgContext peers*: Table[PeerId, Peer] + directPeers*: DirectPeers validTopics: HashSet[string] peerPingerHeartbeatFut: Future[void] peerTrimmerHeartbeatFut: Future[void] @@ -1314,7 +1317,7 @@ proc dialPeer(node: Eth2Node, peerAddr: PeerAddr, index = 0) {.async.} = await workfut or deadline if workfut.finished(): if not deadline.finished(): - deadline.cancel() + deadline.cancelSoon() inc nbc_successful_dials else: debug "Connection to remote peer timed out" @@ -1509,6 +1512,7 @@ proc trimConnections(node: Eth2Node, count: int) = var toKick = count for peerId in scores.keys: + if peerId in node.directPeers: continue debug "kicking peer", peerId, score=scores[peerId] asyncSpawn node.getPeer(peerId).disconnect(PeerScoreLow) dec toKick @@ -1793,6 +1797,7 @@ proc new(T: type Eth2Node, switch: Switch, pubsub: GossipSub, ip: Option[ValidIpAddress], tcpPort, udpPort: Option[Port], privKey: keys.PrivateKey, discovery: bool, + directPeers: DirectPeers, rng: ref HmacDrbgContext): T {.raises: [CatchableError].} = when not defined(local_testnet): let @@ -1835,6 +1840,7 @@ proc new(T: type Eth2Node, rng: rng, connectTimeout: connectTimeout, seenThreshold: seenThreshold, + directPeers: directPeers, quota: TokenBucket.new(maxGlobalQuota, fullReplenishTime) ) @@ -2258,9 +2264,7 @@ func gossipId( data: openArray[byte], phase0Prefix, topic: string): seq[byte] = # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#topics-and-messages # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/p2p-interface.md#topics-and-messages - const - MESSAGE_DOMAIN_INVALID_SNAPPY = [0x00'u8, 0x00, 0x00, 0x00] - MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00] + const MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00] let messageDigest = withEth2Hash: h.update(MESSAGE_DOMAIN_VALID_SNAPPY) @@ -2315,6 +2319,24 @@ proc createEth2Node*(rng: ref HmacDrbgContext, except CatchableError as exc: raise exc except Exception as exc: raiseAssert exc.msg + directPeers = block: + var res: DirectPeers + for s in config.directPeers: + let (peerId, address) = + if s.startsWith("enr:"): + let + typedEnr = parseBootstrapAddress(s).get().toTypedRecord().get() + peerAddress = toPeerAddr(typedEnr, tcpProtocol).get() + (peerAddress.peerId, peerAddress.addrs[0]) + elif s.startsWith("/"): + parseFullAddress(s).tryGet() + else: + fatal "direct peers address should start with / (multiaddress) or enr:", conf=s + quit 1 + res.mgetOrPut(peerId, @[]).add(address) + info "Adding privileged direct peer", peerId, address + res + hostAddress = tcpEndPoint(config.listenAddress, config.tcpPort) announcedAddresses = if extIp.isNone() or extTcpPort.isNone(): @[] else: @[tcpEndPoint(extIp.get(), extTcpPort.get())] @@ -2373,19 +2395,7 @@ proc createEth2Node*(rng: ref HmacDrbgContext, behaviourPenaltyWeight: -15.9, behaviourPenaltyDecay: 0.986, disconnectBadPeers: true, - directPeers: - block: - var res = initTable[PeerId, seq[MultiAddress]]() - if config.directPeers.len > 0: - for s in config.directPeers: - let - maddress = MultiAddress.init(s).tryGet() - mpeerId = maddress[multiCodec("p2p")].tryGet() - peerId = PeerId.init(mpeerId.protoAddress().tryGet()).tryGet() - res.mgetOrPut(peerId, @[]).add(maddress) - info "Adding priviledged direct peer", peerId, address = maddress - res - , + directPeers: directPeers, bandwidthEstimatebps: config.bandwidthEstimate.get(100_000_000) ) pubsub = GossipSub.init( @@ -2404,7 +2414,7 @@ proc createEth2Node*(rng: ref HmacDrbgContext, let node = Eth2Node.new( config, cfg, enrForkId, discoveryForkId, forkDigests, getBeaconTime, switch, pubsub, extIp, extTcpPort, extUdpPort, netKeys.seckey.asEthKey, - discovery = config.discv5Enabled, rng = rng) + discovery = config.discv5Enabled, directPeers, rng = rng) node.pubsub.subscriptionValidator = proc(topic: string): bool {.gcsafe, raises: [].} = diff --git a/beacon_chain/networking/peer_pool.nim b/beacon_chain/networking/peer_pool.nim index 36c7dd158..d928aa6f3 100644 --- a/beacon_chain/networking/peer_pool.nim +++ b/beacon_chain/networking/peer_pool.nim @@ -114,19 +114,21 @@ proc waitForEvent[A, B](pool: PeerPool[A, B], eventType: EventType, var fut2 = outgoingEvent(eventType).wait() try: discard await one(fut1, fut2) - if fut1.finished: - if not(fut2.finished): - fut2.cancel() + if fut1.finished(): + if not(fut2.finished()): + await fut2.cancelAndWait() incomingEvent(eventType).clear() else: - if not(fut1.finished): - fut1.cancel() + if not(fut1.finished()): + await fut1.cancelAndWait() outgoingEvent(eventType).clear() except CancelledError as exc: - if not(fut1.finished): - fut1.cancel() - if not(fut2.finished): - fut2.cancel() + var pending: seq[FutureBase] + if not(fut1.finished()): + pending.add(fut1.cancelAndWait()) + if not(fut2.finished()): + pending.add(fut2.cancelAndWait()) + await noCancel allFutures(pending) raise exc elif PeerType.Incoming in filter: await incomingEvent(eventType).wait() diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 1d1d6d217..d95ae4959 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -313,8 +313,8 @@ proc initFullNode( let quarantine = newClone( Quarantine.init()) - attestationPool = newClone( - AttestationPool.init(dag, quarantine, onAttestationReceived)) + attestationPool = newClone(AttestationPool.init( + dag, quarantine, config.forkChoiceVersion.get, onAttestationReceived)) syncCommitteeMsgPool = newClone( SyncCommitteeMsgPool.init(rng, dag.cfg, onSyncContribution)) lightClientPool = newClone( @@ -344,11 +344,11 @@ proc initFullNode( maybeFinalized: bool): Future[Result[void, VerifierError]] = withBlck(signedBlock): - when typeof(blck).toFork() >= ConsensusFork.Deneb: - if not blobQuarantine[].hasBlobs(blck): + when typeof(forkyBlck).toFork() >= ConsensusFork.Deneb: + if not blobQuarantine[].hasBlobs(forkyBlck): # We don't have all the blobs for this block, so we have # to put it in blobless quarantine. - if not quarantine[].addBlobless(dag.finalizedHead.slot, blck): + if not quarantine[].addBlobless(dag.finalizedHead.slot, forkyBlck): Future.completed( Result[void, VerifierError].err(VerifierError.UnviableFork), "rmanBlockVerifier") @@ -357,7 +357,7 @@ proc initFullNode( Result[void, VerifierError].err(VerifierError.MissingParent), "rmanBlockVerifier") else: - let blobs = blobQuarantine[].popBlobs(blck.root) + let blobs = blobQuarantine[].popBlobs(forkyBlck.root) blockProcessor[].addBlock(MsgSource.gossip, signedBlock, Opt.some(blobs), maybeFinalized = maybeFinalized) @@ -700,6 +700,7 @@ proc init*(T: type BeaconNode, getStateField(dag.headState, genesis_validators_root) let + keystoreCache = KeystoreCacheRef.init() slashingProtectionDB = SlashingProtectionDB.init( getStateField(dag.headState, genesis_validators_root), @@ -711,6 +712,7 @@ proc init*(T: type BeaconNode, keymanagerHost = if keymanagerInitResult.server != nil: newClone KeymanagerHost.init( validatorPool, + keystoreCache, rng, keymanagerInitResult.token, config.validatorsDir, @@ -749,7 +751,7 @@ proc init*(T: type BeaconNode, restServer: restServer, keymanagerHost: keymanagerHost, keymanagerServer: keymanagerInitResult.server, - keystoreCache: KeystoreCacheRef.init(), + keystoreCache: keystoreCache, eventBus: eventBus, gossipState: {}, blocksGossipState: {}, @@ -1188,9 +1190,9 @@ proc pruneBlobs(node: BeaconNode, slot: Slot) = for i in startIndex..= ConsensusFork.Capella: - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/p2p-interface.md#bls_to_execution_change + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/p2p-interface.md#bls_to_execution_change node.network.addAsyncValidator( getBlsToExecutionChangeTopic(digest), proc ( msg: SignedBLSToExecutionChange @@ -1579,7 +1581,7 @@ proc installMessageValidators(node: BeaconNode) = when consensusFork >= ConsensusFork.Deneb: # blob_sidecar_{index} - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#blob_sidecar_subnet_id + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#blob_sidecar_subnet_id for i in 0 ..< BLOB_SIDECAR_SUBNET_COUNT: closureScope: # Needed for inner `proc`; don't lift it out of loop. let idx = i @@ -1902,6 +1904,13 @@ proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.rai # works for node in metadata.bootstrapNodes: config.bootstrapNodes.add node + if config.forkChoiceVersion.isNone: + config.forkChoiceVersion = + if metadata.cfg.DENEB_FORK_EPOCH != FAR_FUTURE_EPOCH: + # https://github.com/ethereum/pm/issues/844#issuecomment-1673359012 + some(ForkChoiceVersion.Pr3431) + else: + some(ForkChoiceVersion.Stable) ## Ctrl+C handling proc controlCHandler() {.noconv.} = @@ -2164,6 +2173,7 @@ programMain: # permissions are insecure. quit QuitFailure + setupFileLimits() setupLogging(config.logLevel, config.logStdout, config.logFile) ## This Ctrl+C handler exits the program in non-graceful way. diff --git a/beacon_chain/nimbus_binary_common.nim b/beacon_chain/nimbus_binary_common.nim index 2a019ba7f..82995e99f 100644 --- a/beacon_chain/nimbus_binary_common.nim +++ b/beacon_chain/nimbus_binary_common.nim @@ -106,6 +106,17 @@ when defaultChroniclesStream.outputs.type.arity == 2: from std/os import splitFile from "."/filepath import secureCreatePath +proc setupFileLimits*() = + when not defined(windows): + # In addition to databases and sockets, we need a file descriptor for every + # validator - setting it to 16k should provide sufficient margin + let + limit = getMaxOpenFiles2().valueOr(16384) + + if limit < 16384: + setMaxOpenFiles2(16384).isOkOr: + warn "Cannot increase open file limit", err = osErrorMsg(error) + proc setupLogging*( logLevel: string, stdoutKind: StdoutLogKind, logFile: Option[OutFile]) = # In the cfg file for nimbus, we create two formats: textlines and json. diff --git a/beacon_chain/nimbus_light_client.nim b/beacon_chain/nimbus_light_client.nim index 18d50c6d4..0cfc7fbe8 100644 --- a/beacon_chain/nimbus_light_client.nim +++ b/beacon_chain/nimbus_light_client.nim @@ -115,22 +115,22 @@ programMain: # `engine_forkchoiceUpdatedV1` under any of the following conditions: # `headBlockHash` references a block which `timestamp` is greater or # equal to the Shanghai timestamp - if blck.message.is_execution_block: - template payload(): auto = blck.message.body.execution_payload + if forkyBlck.message.is_execution_block: + template payload(): auto = forkyBlck.message.body.execution_payload if elManager != nil and not payload.block_hash.isZero: - discard await elManager.newExecutionPayload(blck.message) + discard await elManager.newExecutionPayload(forkyBlck.message) discard await elManager.forkchoiceUpdated( headBlockHash = payload.block_hash, safeBlockHash = payload.block_hash, # stub value finalizedBlockHash = ZERO_HASH, payloadAttributes = none PayloadAttributesV2) elif consensusFork >= ConsensusFork.Bellatrix: - if blck.message.is_execution_block: - template payload(): auto = blck.message.body.execution_payload + if forkyBlck.message.is_execution_block: + template payload(): auto = forkyBlck.message.body.execution_payload if elManager != nil and not payload.block_hash.isZero: - discard await elManager.newExecutionPayload(blck.message) + discard await elManager.newExecutionPayload(forkyBlck.message) discard await elManager.forkchoiceUpdated( headBlockHash = payload.block_hash, safeBlockHash = payload.block_hash, # stub value diff --git a/beacon_chain/nimbus_signing_node.nim b/beacon_chain/nimbus_signing_node.nim index 7b8c52bab..1b1e5b7d7 100644 --- a/beacon_chain/nimbus_signing_node.nim +++ b/beacon_chain/nimbus_signing_node.nim @@ -420,7 +420,7 @@ proc asyncRun*(sn: SigningNodeRef) {.async.} = pending.add(cancelAndWait(sn.runKeystoreCachePruningLoopFut)) pending.add(sn.stop()) pending.add(sn.close()) - await allFutures(pending) + await noCancel allFutures(pending) template runWithSignals(sn: SigningNodeRef, body: untyped): bool = let future = body @@ -434,7 +434,7 @@ template runWithSignals(sn: SigningNodeRef, body: untyped): bool = pending.add(cancelAndWait(sn.sigintHandleFut)) if not(sn.sigtermHandleFut.finished()): pending.add(cancelAndWait(sn.sigtermHandleFut)) - await allFutures(pending) + await noCancel allFutures(pending) false else: true @@ -446,7 +446,7 @@ template runWithSignals(sn: SigningNodeRef, body: untyped): bool = pending.add(cancelAndWait(sn.sigintHandleFut)) if not(sn.sigtermHandleFut.finished()): pending.add(cancelAndWait(sn.sigtermHandleFut)) - await allFutures(pending) + await noCancel allFutures(pending) false proc runSigningNode(config: SigningNodeConf) {.async.} = diff --git a/beacon_chain/nimbus_validator_client.nim b/beacon_chain/nimbus_validator_client.nim index 2e19c89f3..7e5da53d8 100644 --- a/beacon_chain/nimbus_validator_client.nim +++ b/beacon_chain/nimbus_validator_client.nim @@ -19,8 +19,21 @@ proc initGenesis(vc: ValidatorClientRef): Future[RestGenesis] {.async.} = var nodes = vc.beaconNodes while true: var pendingRequests: seq[Future[RestResponse[GetGenesisResponse]]] - for node in nodes: - debug "Requesting genesis information", endpoint = node + let offlineNodes = vc.offlineNodes() + if len(offlineNodes) == 0: + let sleepDuration = 2.seconds + info "Could not resolve beacon nodes, repeating", + sleep_time = sleepDuration + await sleepAsync(sleepDuration) + for node in vc.nonameNodes(): + let status = checkName(node) + node.updateStatus(status, ApiNodeFailure()) + if status == RestBeaconNodeStatus.Noname: + warn "Cannot initialize beacon node", node = node, status = status + continue + + for node in offlineNodes: + debug "Requesting genesis information", node = node pendingRequests.add(node.client.getGenesis()) try: @@ -240,7 +253,8 @@ proc new*(T: type ValidatorClientRef, warn "Unable to initialize remote beacon node", url = $url, error = res.error() else: - debug "Beacon node was initialized", node = res.get() + if res.get().status != RestBeaconNodeStatus.Noname: + debug "Beacon node was initialized", node = res.get() servers.add(res.get()) let missingRoles = getMissingRoles(servers) if len(missingRoles) != 0: @@ -296,7 +310,10 @@ proc asyncInit(vc: ValidatorClientRef): Future[ValidatorClientRef] {.async.} = beacon_nodes_count = len(vc.beaconNodes) for node in vc.beaconNodes: - notice "Beacon node initialized", node = node + if node.status == RestBeaconNodeStatus.Offline: + notice "Beacon node initialized", node = node + else: + notice "Cannot initialize beacon node", node = node, status = node.status vc.beaconGenesis = await vc.initGenesis() info "Genesis information", genesis_time = vc.beaconGenesis.genesis_time, @@ -347,9 +364,10 @@ proc asyncInit(vc: ValidatorClientRef): Future[ValidatorClientRef] {.async.} = vc.blockService = await BlockServiceRef.init(vc) vc.syncCommitteeService = await SyncCommitteeServiceRef.init(vc) vc.keymanagerServer = keymanagerInitResult.server - if vc.keymanagerServer != nil: + if not(isNil(vc.keymanagerServer)): vc.keymanagerHost = newClone KeymanagerHost.init( validatorPool, + vc.keystoreCache, vc.rng, keymanagerInitResult.token, vc.config.validatorsDir, @@ -394,14 +412,16 @@ proc runPreGenesisWaitingLoop(vc: ValidatorClientRef) {.async.} = try: await sleepAsync(vc.beaconClock.durationToNextSlot()) false - except CancelledError: + except CancelledError as exc: debug "Pre-genesis waiting loop was interrupted" - true + raise exc except CatchableError as exc: error "Pre-genesis waiting loop failed with unexpected error", err_name = $exc.name, err_msg = $exc.msg true - vc.preGenesisEvent.fire() + + if not(breakLoop): + vc.preGenesisEvent.fire() proc runGenesisWaitingLoop(vc: ValidatorClientRef) {.async.} = var breakLoop = false @@ -419,14 +439,16 @@ proc runGenesisWaitingLoop(vc: ValidatorClientRef) {.async.} = try: await sleepAsync(vc.beaconClock.durationToNextSlot()) false - except CancelledError: + except CancelledError as exc: debug "Genesis waiting loop was interrupted" - true + raise exc except CatchableError as exc: error "Genesis waiting loop failed with unexpected error", err_name = $exc.name, err_msg = $exc.msg true - vc.genesisEvent.fire() + + if not(breakLoop): + vc.genesisEvent.fire() proc asyncRun*(vc: ValidatorClientRef) {.async.} = vc.fallbackService.start() @@ -437,8 +459,8 @@ proc asyncRun*(vc: ValidatorClientRef) {.async.} = vc.blockService.start() vc.syncCommitteeService.start() - if not isNil(vc.keymanagerServer): - doAssert vc.keymanagerHost != nil + if not(isNil(vc.keymanagerServer)): + doAssert not(isNil(vc.keymanagerHost)) vc.keymanagerServer.router.installKeymanagerHandlers(vc.keymanagerHost[]) vc.keymanagerServer.start() @@ -471,9 +493,10 @@ proc asyncRun*(vc: ValidatorClientRef) {.async.} = debug "Stopping main processing loop" var pending: seq[Future[void]] - if not(vc.runSlotLoopFut.finished()): + if not(isNil(vc.runSlotLoopFut)) and not(vc.runSlotLoopFut.finished()): pending.add(vc.runSlotLoopFut.cancelAndWait()) - if not(vc.runKeystoreCachePruningLoopFut.finished()): + if not(isNil(vc.runKeystoreCachePruningLoopFut)) and + not(vc.runKeystoreCachePruningLoopFut.finished()): pending.add(vc.runKeystoreCachePruningLoopFut.cancelAndWait()) if not(doppelEventFut.finished()): pending.add(doppelEventFut.cancelAndWait()) @@ -534,5 +557,6 @@ programMain: # and avoid using system resources (such as urandom) after that rng = HmacDrbgContext.new() + setupFileLimits() setupLogging(config.logLevel, config.logStdout, config.logFile) waitFor runValidatorClient(config, rng) diff --git a/beacon_chain/rpc/rest_beacon_api.nim b/beacon_chain/rpc/rest_beacon_api.nim index 72351cb4c..991a6fd89 100644 --- a/beacon_chain/rpc/rest_beacon_api.nim +++ b/beacon_chain/rpc/rest_beacon_api.nim @@ -799,12 +799,12 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = RestApiResponse.jsonResponseWOpt( [ ( - root: blck.root, + root: forkyBlck.root, canonical: node.dag.isCanonical( - BlockId(root: blck.root, slot: blck.message.slot)), + BlockId(root: forkyBlck.root, slot: forkyBlck.message.slot)), header: ( - message: blck.toBeaconBlockHeader, - signature: blck.signature + message: forkyBlck.toBeaconBlockHeader, + signature: forkyBlck.signature ) ) ], @@ -826,12 +826,12 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = withBlck(bdata): RestApiResponse.jsonResponseWOpt( ( - root: blck.root, + root: forkyBlck.root, canonical: node.dag.isCanonical( - BlockId(root: blck.root, slot: blck.message.slot)), + BlockId(root: forkyBlck.root, slot: forkyBlck.message.slot)), header: ( - message: blck.toBeaconBlockHeader, - signature: blck.signature + message: forkyBlck.toBeaconBlockHeader, + signature: forkyBlck.signature ) ), node.getBlockOptimistic(bdata) @@ -1024,8 +1024,8 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = return RestApiResponse.jsonError(Http400, InvalidBlockObjectError) let res = withBlck(forked): - blck.root = hash_tree_root(blck.message) - await node.router.routeSignedBeaconBlock(blck, + forkyBlck.root = hash_tree_root(forkyBlck.message) + await node.router.routeSignedBeaconBlock(forkyBlck, Opt.none(SignedBlobSidecars)) if res.isErr(): @@ -1115,7 +1115,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = return withBlck(bdata): RestApiResponse.jsonResponseWOpt( - blck.message.body.attestations.asSeq(), + forkyBlck.message.body.attestations.asSeq(), node.getBlockOptimistic(bdata) ) diff --git a/beacon_chain/rpc/rest_config_api.nim b/beacon_chain/rpc/rest_config_api.nim index c5957a03f..a2334f2a1 100644 --- a/beacon_chain/rpc/rest_config_api.nim +++ b/beacon_chain/rpc/rest_config_api.nim @@ -88,7 +88,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) = MAX_VOLUNTARY_EXITS: Base10.toString(MAX_VOLUNTARY_EXITS), - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/altair.yaml + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/altair.yaml INACTIVITY_PENALTY_QUOTIENT_ALTAIR: Base10.toString(INACTIVITY_PENALTY_QUOTIENT_ALTAIR), MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR: @@ -104,7 +104,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) = UPDATE_TIMEOUT: Base10.toString(UPDATE_TIMEOUT), - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/bellatrix.yaml + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/bellatrix.yaml INACTIVITY_PENALTY_QUOTIENT_BELLATRIX: Base10.toString(INACTIVITY_PENALTY_QUOTIENT_BELLATRIX), MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX: @@ -120,7 +120,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) = MAX_EXTRA_DATA_BYTES: Base10.toString(uint64(MAX_EXTRA_DATA_BYTES)), - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/capella.yaml + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/capella.yaml MAX_BLS_TO_EXECUTION_CHANGES: Base10.toString(uint64(MAX_BLS_TO_EXECUTION_CHANGES)), MAX_WITHDRAWALS_PER_PAYLOAD: @@ -183,6 +183,8 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) = Base10.toString(cfg.MIN_PER_EPOCH_CHURN_LIMIT), CHURN_LIMIT_QUOTIENT: Base10.toString(cfg.CHURN_LIMIT_QUOTIENT), + MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: + Base10.toString(cfg.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT), PROPOSER_SCORE_BOOST: Base10.toString(PROPOSER_SCORE_BOOST), DEPOSIT_CHAIN_ID: diff --git a/beacon_chain/rpc/rest_debug_api.nim b/beacon_chain/rpc/rest_debug_api.nim index 2a6f65a4e..fe52f2725 100644 --- a/beacon_chain/rpc/rest_debug_api.nim +++ b/beacon_chain/rpc/rest_debug_api.nim @@ -87,7 +87,9 @@ proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) = var response = GetForkChoiceResponse( justified_checkpoint: forkChoice.checkpoints.justified.checkpoint, - finalized_checkpoint: forkChoice.checkpoints.finalized) + finalized_checkpoint: forkChoice.checkpoints.finalized, + extra_data: RestExtraData( + version: some($forkChoice.backend.proto_array.version))) for item in forkChoice.backend.proto_array: let diff --git a/beacon_chain/rpc/rest_event_api.nim b/beacon_chain/rpc/rest_event_api.nim index 162aa6dbf..b27f2faed 100644 --- a/beacon_chain/rpc/rest_event_api.nim +++ b/beacon_chain/rpc/rest_event_api.nim @@ -8,6 +8,7 @@ {.push raises: [].} import + std/sequtils, stew/results, chronicles, ./rest_utils, @@ -160,12 +161,6 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) = # One of the handlers finished, it means that connection has been droped, so # we cancelling all other handlers. let pending = - block: - var res: seq[Future[void]] - for fut in handlers: - if not(fut.finished()): - fut.cancel() - res.add(fut) - res - await allFutures(pending) + handlers.filterIt(not(it.finished())).mapIt(it.cancelAndWait()) + await noCancel allFutures(pending) return diff --git a/beacon_chain/rpc/rest_key_management_api.nim b/beacon_chain/rpc/rest_key_management_api.nim index b6f9f5b99..90ec94005 100644 --- a/beacon_chain/rpc/rest_key_management_api.nim +++ b/beacon_chain/rpc/rest_key_management_api.nim @@ -185,7 +185,8 @@ proc installKeymanagerHandlers*(router: var RestRouter, host: KeymanagerHost) = for index, item in request.keystores: let res = importKeystore(host.validatorPool[], host.rng[], host.validatorsDir, host.secretsDir, - item, request.passwords[index]) + item, request.passwords[index], + host.keystoreCache) if res.isErr(): let failure = res.error() case failure.status diff --git a/beacon_chain/rpc/rest_validator_api.nim b/beacon_chain/rpc/rest_validator_api.nim index d98ab7f93..3678a0099 100644 --- a/beacon_chain/rpc/rest_validator_api.nim +++ b/beacon_chain/rpc/rest_validator_api.nim @@ -414,17 +414,17 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) = return withBlck(message.blck): let data = - when blck is deneb.BeaconBlock: + when forkyBlck is deneb.BeaconBlock: let bundle = message.blobsBundleOpt.get() - let blockRoot = hash_tree_root(blck) + let blockRoot = hash_tree_root(forkyBlck) var sidecars = newSeqOfCap[BlobSidecar](bundle.blobs.len) for i in 0..= maxEpoch: FAR_FUTURE_SLOT else: Slot(epoch * SLOTS_PER_EPOCH) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_previous_epoch +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_previous_epoch func get_previous_epoch*(current_epoch: Epoch): Epoch = ## Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``). if current_epoch == GENESIS_EPOCH: diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index 0d7a86a47..d8fe567b8 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -22,7 +22,7 @@ from ./datatypes/capella import BeaconState, ExecutionPayloadHeader, Withdrawal export extras, forks, validator, chronicles -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#increase_balance +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#increase_balance func increase_balance*(balance: var Gwei, delta: Gwei) = balance += delta @@ -32,7 +32,7 @@ func increase_balance*( if delta != 0: # avoid dirtying the balance cache if not needed increase_balance(state.balances.mitem(index), delta) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#decrease_balance +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#decrease_balance func decrease_balance*(balance: var Gwei, delta: Gwei) = balance = if delta > balance: @@ -66,13 +66,13 @@ func get_validator_from_deposit*(deposit: DepositData): effective_balance: effective_balance ) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_activation_exit_epoch +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_activation_exit_epoch func compute_activation_exit_epoch*(epoch: Epoch): Epoch = ## Return the epoch during which validator activations and exits initiated in ## ``epoch`` take effect. epoch + 1 + MAX_SEED_LOOKAHEAD -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_validator_churn_limit +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_validator_churn_limit func get_validator_churn_limit*( cfg: RuntimeConfig, state: ForkyBeaconState, cache: var StateCache): uint64 = @@ -82,7 +82,16 @@ func get_validator_churn_limit*( count_active_validators( state, state.get_current_epoch(), cache) div cfg.CHURN_LIMIT_QUOTIENT) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#initiate_validator_exit +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/beacon-chain.md#new-get_validator_activation_churn_limit +func get_validator_activation_churn_limit*( + cfg: RuntimeConfig, state: deneb.BeaconState, cache: var StateCache): + uint64 = + ## Return the validator activation churn limit for the current epoch. + min( + cfg.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT, + get_validator_churn_limit(cfg, state, cache)) + +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#initiate_validator_exit func initiate_validator_exit*( cfg: RuntimeConfig, state: var ForkyBeaconState, index: ValidatorIndex, cache: var StateCache): Result[void, cstring] = @@ -134,8 +143,8 @@ func initiate_validator_exit*( from ./datatypes/deneb import BeaconState # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#slash_validator -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#modified-slash_validator -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#modified-slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#modified-slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#modified-slash_validator func get_slashing_penalty*(state: ForkyBeaconState, validator_effective_balance: Gwei): Gwei = # TODO Consider whether this is better than splitting the functions apart; in @@ -150,15 +159,15 @@ func get_slashing_penalty*(state: ForkyBeaconState, else: {.fatal: "invalid BeaconState type".} -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#slash_validator -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#modified-slash_validator -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#modified-slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#modified-slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#modified-slash_validator func get_whistleblower_reward*(validator_effective_balance: Gwei): Gwei = validator_effective_balance div WHISTLEBLOWER_REWARD_QUOTIENT -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#slash_validator -# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#modified-slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#modified-slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#modified-slash_validator func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): Gwei = when state is phase0.BeaconState: whistleblower_reward div PROPOSER_REWARD_QUOTIENT @@ -168,9 +177,9 @@ func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): G else: {.fatal: "invalid BeaconState type".} -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#slash_validator -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#modified-slash_validator -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#modified-slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#modified-slash_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#modified-slash_validator proc slash_validator*( cfg: RuntimeConfig, state: var ForkyBeaconState, slashed_index: ValidatorIndex, cache: var StateCache): @@ -222,7 +231,7 @@ proc slash_validator*( func genesis_time_from_eth1_timestamp*(cfg: RuntimeConfig, eth1_timestamp: uint64): uint64 = eth1_timestamp + cfg.GENESIS_DELAY -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#genesis-block +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#genesis-block func get_initial_beacon_block*(state: phase0.HashedBeaconState): phase0.TrustedSignedBeaconBlock = # The genesis block is implicitly trusted @@ -246,7 +255,7 @@ func get_initial_beacon_block*(state: altair.HashedBeaconState): altair.TrustedSignedBeaconBlock( message: message, root: hash_tree_root(message)) -# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#testing +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#testing func get_initial_beacon_block*(state: bellatrix.HashedBeaconState): bellatrix.TrustedSignedBeaconBlock = # The genesis block is implicitly trusted @@ -287,7 +296,7 @@ func get_initial_beacon_block*(state: ForkedHashedBeaconState): withState(state): ForkedTrustedSignedBeaconBlock.init(get_initial_beacon_block(forkyState)) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_block_root_at_slot +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_block_root_at_slot func get_block_root_at_slot*(state: ForkyBeaconState, slot: Slot): Eth2Digest = ## Return the block root at a recent ``slot``. @@ -305,7 +314,7 @@ func get_block_root_at_slot*( withState(state): get_block_root_at_slot(forkyState.data, slot) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_block_root +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_block_root func get_block_root*(state: ForkyBeaconState, epoch: Epoch): Eth2Digest = ## Return the block root at the start of a recent ``epoch``. get_block_root_at_slot(state, epoch.start_slot()) @@ -380,7 +389,7 @@ proc is_valid_indexed_attestation*( ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_attesting_indices +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_attesting_indices iterator get_attesting_indices_iter*(state: ForkyBeaconState, data: AttestationData, bits: CommitteeValidatorsBits, @@ -401,7 +410,7 @@ iterator get_attesting_indices_iter*(state: ForkyBeaconState, if bits[index_in_committee]: yield validator_index -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_attesting_indices +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_attesting_indices func get_attesting_indices*(state: ForkyBeaconState, data: AttestationData, bits: CommitteeValidatorsBits, @@ -454,7 +463,7 @@ proc is_valid_indexed_attestation*( # Attestation validation # ------------------------------------------------------------------------------------------ -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#attestations +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#attestations # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id func check_attestation_slot_target*(data: AttestationData): Result[Slot, cstring] = @@ -471,8 +480,8 @@ func check_attestation_target_epoch( ok(data.target.epoch) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#attestations -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#modified-process_attestation +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#attestations +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#modified-process_attestation # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#modified-process_attestation func check_attestation_inclusion( consensusFork: static ConsensusFork, attestation_slot: Slot, @@ -502,7 +511,7 @@ func check_attestation_index*( Result[CommitteeIndex, cstring] = check_attestation_index(data.index, committees_per_slot) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#get_attestation_participation_flag_indices +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#get_attestation_participation_flag_indices func get_attestation_participation_flag_indices( state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState, data: AttestationData, inclusion_delay: uint64): set[TimelyFlag] = @@ -574,7 +583,7 @@ func get_attestation_participation_flag_indices( # TODO these duplicate some stuff in state_transition_epoch which uses TotalBalances # better to centralize around that if feasible -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_total_active_balance +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_total_active_balance func get_total_active_balance*(state: ForkyBeaconState, cache: var StateCache): Gwei = ## Return the combined effective balance of the active validators. ## Note: ``get_total_balance`` returns ``EFFECTIVE_BALANCE_INCREMENT`` Gwei @@ -590,7 +599,7 @@ func get_total_active_balance*(state: ForkyBeaconState, cache: var StateCache): cache.total_active_balance[epoch] = tab return tab -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#get_base_reward_per_increment +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#get_base_reward_per_increment func get_base_reward_per_increment_sqrt*( total_active_balance_sqrt: uint64): Gwei = EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR div total_active_balance_sqrt @@ -599,7 +608,7 @@ func get_base_reward_per_increment*( total_active_balance: Gwei): Gwei = get_base_reward_per_increment_sqrt(integer_squareroot(total_active_balance)) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#get_base_reward +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#get_base_reward func get_base_reward( state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState, @@ -610,7 +619,7 @@ func get_base_reward( state.validators[index].effective_balance div EFFECTIVE_BALANCE_INCREMENT increments * base_reward_per_increment -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#attestations +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#attestations proc check_attestation*( state: ForkyBeaconState, attestation: SomeAttestation, flags: UpdateFlags, cache: var StateCache): Result[void, cstring] = @@ -645,7 +654,7 @@ proc check_attestation*( ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#new-process_bls_to_execution_change +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#new-process_bls_to_execution_change proc check_bls_to_execution_change*( genesisFork: Fork, state: capella.BeaconState | deneb.BeaconState, signed_address_change: SignedBLSToExecutionChange, flags: UpdateFlags): @@ -751,7 +760,7 @@ proc process_attestation*( ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#get_next_sync_committee_indices +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#get_next_sync_committee_indices func get_next_sync_committee_keys( state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState): @@ -789,12 +798,12 @@ func get_next_sync_committee_keys( i += 1'u64 res -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#has_eth1_withdrawal_credential +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#has_eth1_withdrawal_credential func has_eth1_withdrawal_credential*(validator: Validator): bool = ## Check if ``validator`` has an 0x01 prefixed "eth1" withdrawal credential. validator.withdrawal_credentials.data[0] == ETH1_ADDRESS_WITHDRAWAL_PREFIX -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#is_fully_withdrawable_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#is_fully_withdrawable_validator func is_fully_withdrawable_validator( validator: Validator, balance: Gwei, epoch: Epoch): bool = ## Check if ``validator`` is fully withdrawable. @@ -812,7 +821,7 @@ func is_partially_withdrawable_validator( has_eth1_withdrawal_credential(validator) and has_max_effective_balance and has_excess_balance -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#new-get_expected_withdrawals +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#new-get_expected_withdrawals func get_expected_withdrawals*( state: capella.BeaconState | deneb.BeaconState): seq[Withdrawal] = let @@ -848,7 +857,7 @@ func get_expected_withdrawals*( validator_index = (validator_index + 1) mod num_validators withdrawals -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#get_next_sync_committee +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#get_next_sync_committee func get_next_sync_committee*( state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState): diff --git a/beacon_chain/spec/crypto.nim b/beacon_chain/spec/crypto.nim index 05c3334f1..acbb718d2 100644 --- a/beacon_chain/spec/crypto.nim +++ b/beacon_chain/spec/crypto.nim @@ -98,7 +98,7 @@ export # API # ---------------------------------------------------------------------- -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#bls-signatures +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#bls-signatures func toPubKey*(privkey: ValidatorPrivKey): CookedPubKey = ## Derive a public key from a private key @@ -206,7 +206,7 @@ func finish*(agg: AggregateSignature): CookedSig {.inline.} = sig.finish(agg) CookedSig(sig) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#bls-signatures +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#bls-signatures func blsVerify*( pubkey: CookedPubKey, message: openArray[byte], signature: CookedSig): bool = @@ -219,7 +219,7 @@ func blsVerify*( ## to enforce correct usage. PublicKey(pubkey).verify(message, blscurve.Signature(signature)) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#bls-signatures +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#bls-signatures proc blsVerify*( pubkey: ValidatorPubKey, message: openArray[byte], signature: CookedSig): bool = diff --git a/beacon_chain/spec/datatypes/altair.nim b/beacon_chain/spec/datatypes/altair.nim index ef5365c1b..9bec04248 100644 --- a/beacon_chain/spec/datatypes/altair.nim +++ b/beacon_chain/spec/datatypes/altair.nim @@ -40,7 +40,7 @@ static: doAssert ord(TIMELY_HEAD_FLAG_INDEX) == 2 const - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/altair/beacon-chain.md#incentivization-weights + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#incentivization-weights TIMELY_SOURCE_WEIGHT* = 14 TIMELY_TARGET_WEIGHT* = 26 TIMELY_HEAD_WEIGHT* = 14 @@ -55,17 +55,17 @@ const TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 16 SYNC_COMMITTEE_SUBNET_COUNT* = 4 - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#constants + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#constants # All of these indices are rooted in `BeaconState`. # The first member (`genesis_time`) is 32, subsequent members +1 each. # If there are ever more than 32 members in `BeaconState`, indices change! # `FINALIZED_ROOT_INDEX` is one layer deeper, i.e., `52 * 2 + 1`. - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/ssz/merkle-proofs.md + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/ssz/merkle-proofs.md FINALIZED_ROOT_INDEX* = 105.GeneralizedIndex # `finalized_checkpoint` > `root` CURRENT_SYNC_COMMITTEE_INDEX* = 54.GeneralizedIndex # `current_sync_committee` NEXT_SYNC_COMMITTEE_INDEX* = 55.GeneralizedIndex # `next_sync_committee` - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/altair/beacon-chain.md#inactivity-penalties + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#inactivity-penalties INACTIVITY_SCORE_BIAS* = 4 INACTIVITY_SCORE_RECOVERY_RATE* = 16 @@ -88,7 +88,7 @@ type ## effectively making the cost of clearing the cache higher than the typical ## gains - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#syncaggregate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#syncaggregate SyncAggregate* = object sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE] sync_committee_signature*: ValidatorSig @@ -97,7 +97,7 @@ type sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE] sync_committee_signature*: TrustedSig - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#synccommittee + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#synccommittee SyncCommittee* = object pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey] aggregate_pubkey*: ValidatorPubKey @@ -165,12 +165,12 @@ type NextSyncCommitteeBranch* = array[log2trunc(NEXT_SYNC_COMMITTEE_INDEX), Eth2Digest] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientheader + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientheader LightClientHeader* = object beacon*: BeaconBlockHeader ## Beacon block header - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientbootstrap + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientbootstrap LightClientBootstrap* = object header*: LightClientHeader ## Header matching the requested beacon block root @@ -179,7 +179,7 @@ type ## Current sync committee corresponding to `header.beacon.state_root` current_sync_committee_branch*: CurrentSyncCommitteeBranch - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientupdate LightClientUpdate* = object attested_header*: LightClientHeader ## Header attested to by the sync committee @@ -198,7 +198,7 @@ type signature_slot*: Slot ## Slot at which the aggregate signature was created (untrusted) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate LightClientFinalityUpdate* = object # Header attested to by the sync committee attested_header*: LightClientHeader @@ -212,7 +212,7 @@ type # Slot at which the aggregate signature was created (untrusted) signature_slot*: Slot - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate LightClientOptimisticUpdate* = object # Header attested to by the sync committee attested_header*: LightClientHeader @@ -238,7 +238,7 @@ type LightClientBootstrap | SomeLightClientUpdate - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientstore + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientstore LightClientStore* = object finalized_header*: LightClientHeader ## Header that is finalized @@ -347,7 +347,7 @@ type data*: BeaconState root*: Eth2Digest # hash_tree_root(data) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconblock BeaconBlock* = object ## For each slot, a proposer is chosen from the validator pool to propose ## a new block. Once the block as been proposed, it is transmitted to @@ -404,7 +404,7 @@ type state_root*: Eth2Digest body*: TrustedBeaconBlockBody - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#beaconblockbody + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#beaconblockbody BeaconBlockBody* = object randao_reveal*: ValidatorSig eth1_data*: Eth1Data @@ -481,7 +481,7 @@ type # [New in Altair] sync_aggregate*: TrustedSyncAggregate - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#signedbeaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#signedbeaconblock SignedBeaconBlock* = object message*: BeaconBlock signature*: ValidatorSig @@ -659,7 +659,7 @@ chronicles.formatIt SyncCommitteeContribution: shortLog(it) chronicles.formatIt ContributionAndProof: shortLog(it) chronicles.formatIt SignedContributionAndProof: shortLog(it) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#is_valid_light_client_header +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#is_valid_light_client_header func is_valid_light_client_header*( header: LightClientHeader, cfg: RuntimeConfig): bool = true diff --git a/beacon_chain/spec/datatypes/base.nim b/beacon_chain/spec/datatypes/base.nim index 46786670a..72a3953a0 100644 --- a/beacon_chain/spec/datatypes/base.nim +++ b/beacon_chain/spec/datatypes/base.nim @@ -74,7 +74,7 @@ export tables, results, json_serialization, timer, sszTypes, beacon_time, crypto, digest, presets -const SPEC_VERSION* = "1.4.0-beta.1" +const SPEC_VERSION* = "1.4.0-beta.2-hotfix" ## Spec version we're aiming to be compatible with, right now const @@ -146,7 +146,7 @@ template ethAmountUnit*(typ: type) {.dirty.} = ethAmountUnit Ether type - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#custom-types + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#custom-types Eth2Domain* = array[32, byte] ValidatorIndex* = distinct uint32 @@ -191,7 +191,7 @@ type # SSZ / hashing purposes JustificationBits* = distinct uint8 - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#proposerslashing + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#proposerslashing ProposerSlashing* = object signed_header_1*: SignedBeaconBlockHeader signed_header_2*: SignedBeaconBlockHeader @@ -203,7 +203,7 @@ type signed_header_1*: TrustedSignedBeaconBlockHeader signed_header_2*: TrustedSignedBeaconBlockHeader - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#attesterslashing + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#attesterslashing AttesterSlashing* = object attestation_1*: IndexedAttestation attestation_2*: IndexedAttestation @@ -215,7 +215,7 @@ type attestation_1*: TrustedIndexedAttestation attestation_2*: TrustedIndexedAttestation - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#indexedattestation + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#indexedattestation IndexedAttestation* = object attesting_indices*: List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE] data*: AttestationData @@ -231,7 +231,7 @@ type CommitteeValidatorsBits* = BitList[Limit MAX_VALIDATORS_PER_COMMITTEE] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#attestation + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#attestation Attestation* = object aggregation_bits*: CommitteeValidatorsBits data*: AttestationData @@ -247,17 +247,17 @@ type ForkDigest* = distinct array[4, byte] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#forkdata + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#forkdata ForkData* = object current_version*: Version genesis_validators_root*: Eth2Digest - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#checkpoint + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#checkpoint Checkpoint* = object epoch*: Epoch root*: Eth2Digest - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#AttestationData + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#AttestationData AttestationData* = object slot*: Slot @@ -270,20 +270,20 @@ type source*: Checkpoint target*: Checkpoint - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#deposit + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#deposit Deposit* = object proof*: array[DEPOSIT_CONTRACT_TREE_DEPTH + 1, Eth2Digest] ## Merkle path to deposit root data*: DepositData - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#depositmessage + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#depositmessage DepositMessage* = object pubkey*: ValidatorPubKey withdrawal_credentials*: Eth2Digest amount*: Gwei - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#depositdata + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#depositdata DepositData* = object pubkey*: ValidatorPubKey withdrawal_credentials*: Eth2Digest @@ -293,7 +293,7 @@ type signature*: ValidatorSig ## Signing over DepositMessage - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#voluntaryexit + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#voluntaryexit VoluntaryExit* = object epoch*: Epoch ## Earliest epoch when voluntary exit can be processed @@ -321,7 +321,7 @@ type pubkey*: CookedPubKey withdrawal_credentials*: Eth2Digest - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#validator + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#validator Validator* = object pubkey*: ValidatorPubKey @@ -352,12 +352,12 @@ type proposer_index*: uint64 # `ValidatorIndex` after validation - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#historicalbatch + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#historicalbatch HistoricalBatch* = object block_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest] state_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#fork + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#fork Fork* = object previous_version*: Version current_version*: Version @@ -365,13 +365,13 @@ type epoch*: Epoch ## Epoch of latest fork - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#eth1data + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#eth1data Eth1Data* = object deposit_root*: Eth2Digest deposit_count*: uint64 block_hash*: Eth2Digest - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#signedvoluntaryexit + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#signedvoluntaryexit SignedVoluntaryExit* = object message*: VoluntaryExit signature*: ValidatorSig @@ -380,7 +380,7 @@ type message*: VoluntaryExit signature*: TrustedSig - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconblockheader + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconblockheader BeaconBlockHeader* = object slot*: Slot proposer_index*: uint64 # `ValidatorIndex` after validation @@ -388,14 +388,14 @@ type state_root*: Eth2Digest body_root*: Eth2Digest - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#signingdata + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#signingdata SigningData* = object object_root*: Eth2Digest domain*: Eth2Domain GraffitiBytes* = distinct array[MAX_GRAFFITI_SIZE, byte] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#signedbeaconblockheader + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#signedbeaconblockheader SignedBeaconBlockHeader* = object message*: BeaconBlockHeader signature*: ValidatorSig @@ -428,12 +428,12 @@ type sync_committees*: Table[SyncCommitteePeriod, SyncCommitteeCache] # This matches the mutable state of the Solidity deposit contract - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/solidity_deposit_contract/deposit_contract.sol + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/solidity_deposit_contract/deposit_contract.sol DepositContractState* = object branch*: array[DEPOSIT_CONTRACT_TREE_DEPTH, Eth2Digest] deposit_count*: array[32, byte] # Uint256 - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#validator + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#validator ValidatorStatus* = object # This is a validator without the expensive, immutable, append-only parts # serialized. They're represented in memory to allow in-place SSZ reading @@ -459,7 +459,7 @@ type withdrawable_epoch*: Epoch ## When validator can withdraw funds - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#validator + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#validator ValidatorStatusCapella* = object # This is a validator without the expensive, immutable, append-only parts # serialized. They're represented in memory to allow in-place SSZ reading diff --git a/beacon_chain/spec/datatypes/bellatrix.nim b/beacon_chain/spec/datatypes/bellatrix.nim index 23847e44f..2faca60ca 100644 --- a/beacon_chain/spec/datatypes/bellatrix.nim +++ b/beacon_chain/spec/datatypes/bellatrix.nim @@ -34,7 +34,7 @@ const NEWPAYLOAD_TIMEOUT* = 8.seconds type - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#custom-types + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#custom-types Transaction* = List[byte, Limit MAX_BYTES_PER_TRANSACTION] ExecutionAddress* = object @@ -45,7 +45,7 @@ type PayloadID* = array[8, byte] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#executionpayload + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#executionpayload ExecutionPayload* = object # Execution block header fields parent_hash*: Eth2Digest @@ -73,7 +73,7 @@ type executionPayload*: ExecutionPayload blockValue*: Wei - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#executionpayloadheader + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#executionpayloadheader ExecutionPayloadHeader* = object # Execution block header fields parent_hash*: Eth2Digest @@ -103,7 +103,7 @@ type parent_hash*: Eth2Digest total_difficulty*: Eth2Digest # uint256 - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#beaconstate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#beaconstate BeaconState* = object # Versioning genesis_time*: uint64 @@ -171,7 +171,7 @@ type data*: BeaconState root*: Eth2Digest # hash_tree_root(data) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#beaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconblock BeaconBlock* = object ## For each slot, a proposer is chosen from the validator pool to propose ## a new block. Once the block as been proposed, it is transmitted to @@ -228,7 +228,7 @@ type state_root*: Eth2Digest body*: TrustedBeaconBlockBody - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#beaconblockbody + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#beaconblockbody BeaconBlockBody* = object randao_reveal*: ValidatorSig eth1_data*: Eth1Data @@ -306,7 +306,7 @@ type # Execution execution_payload*: ExecutionPayload # [New in Bellatrix] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#signedbeaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#signedbeaconblock SignedBeaconBlock* = object message*: BeaconBlock signature*: ValidatorSig diff --git a/beacon_chain/spec/datatypes/capella.nim b/beacon_chain/spec/datatypes/capella.nim index 1df56bff6..0518bf178 100644 --- a/beacon_chain/spec/datatypes/capella.nim +++ b/beacon_chain/spec/datatypes/capella.nim @@ -27,43 +27,43 @@ import export json_serialization, base const - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#constants + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/sync-protocol.md#constants # This index is rooted in `BeaconBlockBody`. # The first member (`randao_reveal`) is 16, subsequent members +1 each. # If there are ever more than 16 members in `BeaconBlockBody`, indices change! - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/ssz/merkle-proofs.md + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/ssz/merkle-proofs.md EXECUTION_PAYLOAD_INDEX* = 25.GeneralizedIndex # `execution_payload` type SignedBLSToExecutionChangeList* = List[SignedBLSToExecutionChange, Limit MAX_BLS_TO_EXECUTION_CHANGES] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#withdrawal + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#withdrawal Withdrawal* = object index*: WithdrawalIndex validator_index*: uint64 address*: ExecutionAddress amount*: Gwei - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#blstoexecutionchange + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#blstoexecutionchange BLSToExecutionChange* = object validator_index*: uint64 from_bls_pubkey*: ValidatorPubKey to_execution_address*: ExecutionAddress - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#signedblstoexecutionchange + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#signedblstoexecutionchange SignedBLSToExecutionChange* = object message*: BLSToExecutionChange signature*: ValidatorSig - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#historicalsummary + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#historicalsummary HistoricalSummary* = object # `HistoricalSummary` matches the components of the phase0 # `HistoricalBatch` making the two hash_tree_root-compatible. block_summary_root*: Eth2Digest state_summary_root*: Eth2Digest - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#executionpayload + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#executionpayload ExecutionPayload* = object # Execution block header fields parent_hash*: Eth2Digest @@ -93,7 +93,7 @@ type executionPayload*: ExecutionPayload blockValue*: Wei - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#executionpayloadheader + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#executionpayloadheader ExecutionPayloadHeader* = object # Execution block header fields parent_hash*: Eth2Digest @@ -122,7 +122,7 @@ type ExecutionBranch* = array[log2trunc(EXECUTION_PAYLOAD_INDEX), Eth2Digest] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#modified-lightclientheader + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/sync-protocol.md#modified-lightclientheader LightClientHeader* = object beacon*: BeaconBlockHeader ## Beacon block header @@ -131,7 +131,7 @@ type ## Execution payload header corresponding to `beacon.body_root` (from Capella onward) execution_branch*: ExecutionBranch - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientbootstrap + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientbootstrap LightClientBootstrap* = object header*: LightClientHeader ## Header matching the requested beacon block root @@ -140,7 +140,7 @@ type ## Current sync committee corresponding to `header.beacon.state_root` current_sync_committee_branch*: altair.CurrentSyncCommitteeBranch - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientupdate LightClientUpdate* = object attested_header*: LightClientHeader ## Header attested to by the sync committee @@ -159,7 +159,7 @@ type signature_slot*: Slot ## Slot at which the aggregate signature was created (untrusted) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate LightClientFinalityUpdate* = object # Header attested to by the sync committee attested_header*: LightClientHeader @@ -173,7 +173,7 @@ type # Slot at which the aggregate signature was created (untrusted) signature_slot*: Slot - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate LightClientOptimisticUpdate* = object # Header attested to by the sync committee attested_header*: LightClientHeader @@ -199,7 +199,7 @@ type LightClientBootstrap | SomeLightClientUpdate - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientstore + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientstore LightClientStore* = object finalized_header*: LightClientHeader ## Header that is finalized @@ -220,7 +220,7 @@ type ## (used to compute safety threshold) current_max_active_participants*: uint64 - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#beaconstate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#beaconstate BeaconState* = object # Versioning genesis_time*: uint64 @@ -299,7 +299,7 @@ type data*: BeaconState root*: Eth2Digest # hash_tree_root(data) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconblock BeaconBlock* = object ## For each slot, a proposer is chosen from the validator pool to propose ## a new block. Once the block as been proposed, it is transmitted to @@ -356,7 +356,7 @@ type state_root*: Eth2Digest body*: TrustedBeaconBlockBody - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#beaconblockbody + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#beaconblockbody BeaconBlockBody* = object randao_reveal*: ValidatorSig eth1_data*: Eth1Data @@ -650,7 +650,7 @@ func shortLog*(v: SignedBLSToExecutionChange): auto = signature: shortLog(v.signature) ) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#get_lc_execution_root +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/sync-protocol.md#get_lc_execution_root func get_lc_execution_root*( header: LightClientHeader, cfg: RuntimeConfig): Eth2Digest = let epoch = header.beacon.slot.epoch @@ -660,7 +660,7 @@ func get_lc_execution_root*( ZERO_HASH -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#modified-is_valid_light_client_header +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/sync-protocol.md#modified-is_valid_light_client_header func is_valid_light_client_header*( header: LightClientHeader, cfg: RuntimeConfig): bool = let epoch = header.beacon.slot.epoch @@ -677,13 +677,13 @@ func is_valid_light_client_header*( get_subtree_index(EXECUTION_PAYLOAD_INDEX), header.beacon.body_root) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/fork.md#upgrading-light-client-data func upgrade_lc_header_to_capella*( pre: altair.LightClientHeader): LightClientHeader = LightClientHeader( beacon: pre.beacon) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/fork.md#upgrading-light-client-data func upgrade_lc_bootstrap_to_capella*( pre: altair.LightClientBootstrap): LightClientBootstrap = LightClientBootstrap( @@ -691,7 +691,7 @@ func upgrade_lc_bootstrap_to_capella*( current_sync_committee: pre.current_sync_committee, current_sync_committee_branch: pre.current_sync_committee_branch) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/fork.md#upgrading-light-client-data func upgrade_lc_update_to_capella*( pre: altair.LightClientUpdate): LightClientUpdate = LightClientUpdate( @@ -703,7 +703,7 @@ func upgrade_lc_update_to_capella*( sync_aggregate: pre.sync_aggregate, signature_slot: pre.signature_slot) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/fork.md#upgrading-light-client-data func upgrade_lc_finality_update_to_capella*( pre: altair.LightClientFinalityUpdate): LightClientFinalityUpdate = LightClientFinalityUpdate( @@ -713,7 +713,7 @@ func upgrade_lc_finality_update_to_capella*( sync_aggregate: pre.sync_aggregate, signature_slot: pre.signature_slot) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/fork.md#upgrading-light-client-data func upgrade_lc_optimistic_update_to_capella*( pre: altair.LightClientOptimisticUpdate): LightClientOptimisticUpdate = LightClientOptimisticUpdate( @@ -764,7 +764,7 @@ chronicles.formatIt LightClientUpdate: shortLog(it) chronicles.formatIt LightClientFinalityUpdate: shortLog(it) chronicles.formatIt LightClientOptimisticUpdate: shortLog(it) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/fork.md#upgrading-the-store +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/fork.md#upgrading-the-store func upgrade_lc_store_to_capella*( pre: altair.LightClientStore): LightClientStore = let best_valid_update = diff --git a/beacon_chain/spec/datatypes/constants.nim b/beacon_chain/spec/datatypes/constants.nim index d0f6259af..f2114e1e8 100644 --- a/beacon_chain/spec/datatypes/constants.nim +++ b/beacon_chain/spec/datatypes/constants.nim @@ -36,7 +36,7 @@ const FAR_FUTURE_EPOCH* = Epoch(not 0'u64) FAR_FUTURE_PERIOD* = SyncCommitteePeriod(not 0'u64) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#domain-types + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#domain-types DOMAIN_BEACON_PROPOSER* = DomainType([byte 0x00, 0x00, 0x00, 0x00]) DOMAIN_BEACON_ATTESTER* = DomainType([byte 0x01, 0x00, 0x00, 0x00]) DOMAIN_RANDAO* = DomainType([byte 0x02, 0x00, 0x00, 0x00]) @@ -46,12 +46,12 @@ const DOMAIN_AGGREGATE_AND_PROOF* = DomainType([byte 0x06, 0x00, 0x00, 0x00]) DOMAIN_APPLICATION_MASK* = DomainType([byte 0x00, 0x00, 0x00, 0x01]) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/altair/beacon-chain.md#domain-types + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#domain-types DOMAIN_SYNC_COMMITTEE* = DomainType([byte 0x07, 0x00, 0x00, 0x00]) DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF* = DomainType([byte 0x08, 0x00, 0x00, 0x00]) DOMAIN_CONTRIBUTION_AND_PROOF* = DomainType([byte 0x09, 0x00, 0x00, 0x00]) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#domain-types + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#domain-types DOMAIN_BLS_TO_EXECUTION_CHANGE* = DomainType([byte 0x0a, 0x00, 0x00, 0x00]) # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#domain-types @@ -60,16 +60,18 @@ const # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/fork-choice.md#configuration PROPOSER_SCORE_BOOST*: uint64 = 40 - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#configuration + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#configuration BLOB_SIDECAR_SUBNET_COUNT*: uint64 = 6 - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#configuration + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#configuration MAX_REQUEST_BLOCKS* = 1024'u64 - RESP_TIMEOUT* = 10 + RESP_TIMEOUT* = 10'u64 + ATTESTATION_PROPAGATION_SLOT_RANGE*: uint64 = 32 # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#configuration GOSSIP_MAX_SIZE* = 10'u64 * 1024 * 1024 # bytes MAX_CHUNK_SIZE* = 10'u64 * 1024 * 1024 # bytes - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#configuration - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS* = 4096'u64 + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#configuration + MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS*: uint64 = 4096 + MAX_REQUEST_BLOCKS_DENEB*: uint64 = 128 # TODO Make use of in request code diff --git a/beacon_chain/spec/datatypes/deneb.nim b/beacon_chain/spec/datatypes/deneb.nim index 56f6c0070..d679bfb58 100644 --- a/beacon_chain/spec/datatypes/deneb.nim +++ b/beacon_chain/spec/datatypes/deneb.nim @@ -30,7 +30,7 @@ from kzg4844 import KzgCommitment, KzgProof export json_serialization, base, kzg4844 const - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/polynomial-commitments.md#constants + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/polynomial-commitments.md#constants BYTES_PER_FIELD_ELEMENT = 32 # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#blob @@ -50,7 +50,7 @@ type # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#custom-types BlobIndex* = uint64 - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/polynomial-commitments.md#custom-types + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/polynomial-commitments.md#custom-types Blob* = array[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB, byte] # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/p2p-interface.md#blobsidecar @@ -67,7 +67,7 @@ type kzg_proof*: KzgProof ## Allows for quick verification of kzg_commitment - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#signedblobsidecar + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#signedblobsidecar SignedBlobSidecar* = object message*: BlobSidecar signature*: ValidatorSig @@ -110,7 +110,7 @@ type proofs*:seq[KZGProof] blobs*: Blobs - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/beacon-chain.md#executionpayloadheader + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#executionpayloadheader ExecutionPayloadHeader* = object # Execution block header fields parent_hash*: Eth2Digest @@ -131,13 +131,13 @@ type ## Hash of execution block transactions_root*: Eth2Digest withdrawals_root*: Eth2Digest - blob_gas_used*: uint64 # [New in Deneb] - excess_blob_gas*: uint64 # [New in Deneb] + blob_gas_used*: uint64 # [New in Deneb:EIP4844] + excess_blob_gas*: uint64 # [New in Deneb:EIP4844] ExecutePayload* = proc( execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].} - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/sync-protocol.md#modified-lightclientheader + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/sync-protocol.md#modified-lightclientheader LightClientHeader* = object beacon*: BeaconBlockHeader ## Beacon block header @@ -146,7 +146,7 @@ type ## Execution payload header corresponding to `beacon.body_root` (from Capella onward) execution_branch*: capella.ExecutionBranch - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientbootstrap + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientbootstrap LightClientBootstrap* = object header*: LightClientHeader ## Header matching the requested beacon block root @@ -155,7 +155,7 @@ type ## Current sync committee corresponding to `header.beacon.state_root` current_sync_committee_branch*: altair.CurrentSyncCommitteeBranch - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientupdate LightClientUpdate* = object attested_header*: LightClientHeader ## Header attested to by the sync committee @@ -174,7 +174,7 @@ type signature_slot*: Slot ## Slot at which the aggregate signature was created (untrusted) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate LightClientFinalityUpdate* = object # Header attested to by the sync committee attested_header*: LightClientHeader @@ -188,7 +188,7 @@ type # Slot at which the aggregate signature was created (untrusted) signature_slot*: Slot - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate LightClientOptimisticUpdate* = object # Header attested to by the sync committee attested_header*: LightClientHeader @@ -214,7 +214,7 @@ type LightClientBootstrap | SomeLightClientUpdate - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#lightclientstore + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#lightclientstore LightClientStore* = object finalized_header*: LightClientHeader ## Header that is finalized @@ -235,7 +235,7 @@ type ## (used to compute safety threshold) current_max_active_participants*: uint64 - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#beaconstate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#beaconstate # changes indirectly via ExecutionPayloadHeader BeaconState* = object # Versioning @@ -313,7 +313,7 @@ type data*: BeaconState root*: Eth2Digest # hash_tree_root(data) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconblock BeaconBlock* = object ## For each slot, a proposer is chosen from the validator pool to propose ## a new block. Once the block as been proposed, it is transmitted to @@ -370,7 +370,7 @@ type state_root*: Eth2Digest body*: TrustedBeaconBlockBody - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.1/specs/deneb/beacon-chain.md#beaconblockbody + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#beaconblockbody BeaconBlockBody* = object randao_reveal*: ValidatorSig eth1_data*: Eth1Data @@ -451,7 +451,7 @@ type bls_to_execution_changes*: SignedBLSToExecutionChangeList blob_kzg_commitments*: KzgCommitments # [New in Deneb] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#signedbeaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#signedbeaconblock SignedBeaconBlock* = object message*: BeaconBlock signature*: ValidatorSig @@ -575,7 +575,7 @@ func shortLog*(v: ExecutionPayload): auto = func shortLog*(x: seq[BlobIdentifier]): string = "[" & x.mapIt(shortLog(it.block_root) & "/" & $it.index).join(", ") & "]" -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/light-client/sync-protocol.md#modified-get_lc_execution_root +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/light-client/sync-protocol.md#modified-get_lc_execution_root func get_lc_execution_root*( header: LightClientHeader, cfg: RuntimeConfig): Eth2Digest = let epoch = header.beacon.slot.epoch @@ -604,7 +604,7 @@ func get_lc_execution_root*( ZERO_HASH -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/light-client/sync-protocol.md#modified-is_valid_light_client_header +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/light-client/sync-protocol.md#modified-is_valid_light_client_header func is_valid_light_client_header*( header: LightClientHeader, cfg: RuntimeConfig): bool = let epoch = header.beacon.slot.epoch @@ -626,7 +626,7 @@ func is_valid_light_client_header*( get_subtree_index(EXECUTION_PAYLOAD_INDEX), header.beacon.body_root) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/light-client/fork.md#upgrading-light-client-data func upgrade_lc_header_to_deneb*( pre: capella.LightClientHeader): LightClientHeader = LightClientHeader( @@ -651,7 +651,7 @@ func upgrade_lc_header_to_deneb*( excess_blob_gas: 0), # [New in Deneb:EIP4844] execution_branch: pre.execution_branch) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/light-client/fork.md#upgrading-light-client-data func upgrade_lc_bootstrap_to_deneb*( pre: capella.LightClientBootstrap): LightClientBootstrap = LightClientBootstrap( @@ -659,7 +659,7 @@ func upgrade_lc_bootstrap_to_deneb*( current_sync_committee: pre.current_sync_committee, current_sync_committee_branch: pre.current_sync_committee_branch) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/light-client/fork.md#upgrading-light-client-data func upgrade_lc_update_to_deneb*( pre: capella.LightClientUpdate): LightClientUpdate = LightClientUpdate( @@ -671,7 +671,7 @@ func upgrade_lc_update_to_deneb*( sync_aggregate: pre.sync_aggregate, signature_slot: pre.signature_slot) -# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/light-client/fork.md#upgrading-light-client-data func upgrade_lc_finality_update_to_deneb*( pre: capella.LightClientFinalityUpdate): LightClientFinalityUpdate = LightClientFinalityUpdate( @@ -681,7 +681,7 @@ func upgrade_lc_finality_update_to_deneb*( sync_aggregate: pre.sync_aggregate, signature_slot: pre.signature_slot) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/light-client/fork.md#upgrading-light-client-data +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/light-client/fork.md#upgrading-light-client-data func upgrade_lc_optimistic_update_to_deneb*( pre: capella.LightClientOptimisticUpdate): LightClientOptimisticUpdate = LightClientOptimisticUpdate( @@ -732,7 +732,7 @@ chronicles.formatIt LightClientUpdate: shortLog(it) chronicles.formatIt LightClientFinalityUpdate: shortLog(it) chronicles.formatIt LightClientOptimisticUpdate: shortLog(it) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/light-client/fork.md#upgrading-the-store +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/light-client/fork.md#upgrading-the-store func upgrade_lc_store_to_deneb*( pre: capella.LightClientStore): LightClientStore = let best_valid_update = diff --git a/beacon_chain/spec/datatypes/phase0.nim b/beacon_chain/spec/datatypes/phase0.nim index 2b12ca6d6..c5d7da7ef 100644 --- a/beacon_chain/spec/datatypes/phase0.nim +++ b/beacon_chain/spec/datatypes/phase0.nim @@ -22,7 +22,7 @@ import export base type - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#beaconstate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconstate BeaconState* = object # Versioning genesis_time*: uint64 @@ -111,7 +111,7 @@ type data*: BeaconState root*: Eth2Digest # hash_tree_root(data) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconblock BeaconBlock* = object ## For each slot, a proposer is chosen from the validator pool to propose ## a new block. Once the block as been proposed, it is transmitted to @@ -167,7 +167,7 @@ type state_root*: Eth2Digest body*: TrustedBeaconBlockBody - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beaconblockbody + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beaconblockbody BeaconBlockBody* = object randao_reveal*: ValidatorSig eth1_data*: Eth1Data @@ -219,7 +219,7 @@ type deposits*: List[Deposit, Limit MAX_DEPOSITS] voluntary_exits*: List[TrustedSignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#signedbeaconblock + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#signedbeaconblock SignedBeaconBlock* = object message*: BeaconBlock signature*: ValidatorSig diff --git a/beacon_chain/spec/digest.nim b/beacon_chain/spec/digest.nim index 4c600638c..123227af5 100644 --- a/beacon_chain/spec/digest.nim +++ b/beacon_chain/spec/digest.nim @@ -7,7 +7,7 @@ # Consensus hash function / digest # -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#hash +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#hash # # In Phase 0 the beacon chain is deployed with SHA256 (SHA2-256). # Note that is is different from Keccak256 (often mistakenly called SHA3-256) diff --git a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim index aa9066643..4f76ae8da 100644 --- a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim +++ b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import std/[typetraits, strutils] -import stew/[assign2, results, base10, byteutils], presto/common, +import stew/[assign2, results, base10, byteutils, endians2], presto/common, libp2p/peerid, serialization, json_serialization, json_serialization/std/[options, net, sets], chronicles @@ -278,7 +278,7 @@ proc jsonResponseBlock*(t: typedesc[RestApiResponse], if execOpt.isSome(): writer.writeField("execution_optimistic", execOpt.get()) withBlck(data): - writer.writeField("data", blck) + writer.writeField("data", forkyBlck) writer.endRecord() stream.getOutput(seq[byte]) except SerializationError: @@ -1887,7 +1887,7 @@ proc readValue*(reader: var JsonReader[RestJson], reader.raiseUnexpectedValue("Incorrect deneb block format") value = ForkedSignedBeaconBlock.init(res.get()) withBlck(value): - blck.root = hash_tree_root(blck.message) + forkyBlck.root = hash_tree_root(forkyBlck.message) proc writeValue*( writer: var JsonWriter[RestJson], value: ForkedSignedBeaconBlock @@ -3320,10 +3320,10 @@ func readSszResBytes(T: typedesc[RestBlockTypes], try: readSszBytes(data, res) ok(res) - except MalformedSszError as exc: - err("Invalid SSZ object") except SszSizeMismatchError: err("Incorrect SSZ object's size") + except SszError: + err("Invalid SSZ object") proc decodeBytes*[T: DecodeConsensysTypes]( t: typedesc[T], diff --git a/beacon_chain/spec/eth2_apis/rest_light_client_calls.nim b/beacon_chain/spec/eth2_apis/rest_light_client_calls.nim index a164296fa..3fb504d6f 100644 --- a/beacon_chain/spec/eth2_apis/rest_light_client_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_light_client_calls.nim @@ -8,7 +8,7 @@ import chronos, - stew/results, + stew/[results, endians2], presto/client, ../helpers, "."/[rest_common, eth2_rest_serialization] diff --git a/beacon_chain/spec/eth2_apis/rest_types.nim b/beacon_chain/spec/eth2_apis/rest_types.nim index f5888330a..c5354b2e4 100644 --- a/beacon_chain/spec/eth2_apis/rest_types.nim +++ b/beacon_chain/spec/eth2_apis/rest_types.nim @@ -574,7 +574,7 @@ type extra_data*: Option[RestNodeExtraData] RestExtraData* = object - discard + version*: Option[string] GetForkChoiceResponse* = object justified_checkpoint*: Checkpoint @@ -627,7 +627,7 @@ func init*(t: typedesc[ValidatorIdent], v: ValidatorPubKey): ValidatorIdent = func init*(t: typedesc[RestBlockInfo], v: ForkedTrustedSignedBeaconBlock): RestBlockInfo = withBlck(v): - RestBlockInfo(slot: blck.message.slot, blck: blck.root) + RestBlockInfo(slot: forkyBlck.message.slot, blck: forkyBlck.root) func init*(t: typedesc[RestValidator], index: ValidatorIndex, balance: uint64, status: string, diff --git a/beacon_chain/spec/eth2_merkleization.nim b/beacon_chain/spec/eth2_merkleization.nim index 1858397e0..f01173f0d 100644 --- a/beacon_chain/spec/eth2_merkleization.nim +++ b/beacon_chain/spec/eth2_merkleization.nim @@ -10,6 +10,7 @@ # Import this module to get access to `hash_tree_root` for spec types import + stew/endians2, ssz_serialization/[merkleization, proofs], ./ssz_codec diff --git a/beacon_chain/spec/eth2_ssz_serialization.nim b/beacon_chain/spec/eth2_ssz_serialization.nim index 94cb9325f..7571f2d30 100644 --- a/beacon_chain/spec/eth2_ssz_serialization.nim +++ b/beacon_chain/spec/eth2_ssz_serialization.nim @@ -20,8 +20,9 @@ from ./datatypes/deneb import SignedBeaconBlock, TrustedSignedBeaconBlock export phase0, altair, ssz_codec, ssz_serialization, eth2_merkleization -proc readAndUpdateRoot(data: openArray[byte], val: var auto, updateRoot = true) {. - raises: [MalformedSszError, SszSizeMismatchError].} = +proc readAndUpdateRoot( + data: openArray[byte], val: var auto, updateRoot = true +) {.raises: [SszError].} = readSszValue(data, val) if updateRoot: val.root = hash_tree_root(val.message) @@ -64,8 +65,9 @@ template readSszBytes*( data: openArray[byte], val: var auto, updateRoot: bool) = readSszValue(data, val) -func readSszBytes(T: type, data: openArray[byte], updateRoot = true): T {. - raises: [MalformedSszError, SszSizeMismatchError].} = +func readSszBytes( + T: type, data: openArray[byte], updateRoot = true +): T {.raises: [SszError].} = var res: T readSszBytes(data, res, updateRoot) res diff --git a/beacon_chain/spec/forks.nim b/beacon_chain/spec/forks.nim index a5744202c..b21cce64a 100644 --- a/beacon_chain/spec/forks.nim +++ b/beacon_chain/spec/forks.nim @@ -766,30 +766,30 @@ template withBlck*( case x.kind of ConsensusFork.Phase0: const consensusFork {.inject, used.} = ConsensusFork.Phase0 - template blck: untyped {.inject.} = x.phase0Data + template forkyBlck: untyped {.inject.} = x.phase0Data body of ConsensusFork.Altair: const consensusFork {.inject, used.} = ConsensusFork.Altair - template blck: untyped {.inject.} = x.altairData + template forkyBlck: untyped {.inject.} = x.altairData body of ConsensusFork.Bellatrix: const consensusFork {.inject, used.} = ConsensusFork.Bellatrix - template blck: untyped {.inject.} = x.bellatrixData + template forkyBlck: untyped {.inject.} = x.bellatrixData body of ConsensusFork.Capella: const consensusFork {.inject, used.} = ConsensusFork.Capella - template blck: untyped {.inject.} = x.capellaData + template forkyBlck: untyped {.inject.} = x.capellaData body of ConsensusFork.Deneb: const consensusFork {.inject, used.} = ConsensusFork.Deneb - template blck: untyped {.inject.} = x.denebData + template forkyBlck: untyped {.inject.} = x.denebData body func proposer_index*(x: ForkedBeaconBlock): uint64 = - withBlck(x): blck.proposer_index + withBlck(x): forkyBlck.proposer_index func hash_tree_root*(x: ForkedBeaconBlock): Eth2Digest = - withBlck(x): hash_tree_root(blck) + withBlck(x): hash_tree_root(forkyBlck) func hash_tree_root*(x: Web3SignerForkedBeaconBlock): Eth2Digest = hash_tree_root(x.data) @@ -810,29 +810,29 @@ template getForkedBlockField*( template signature*(x: ForkedSignedBeaconBlock | ForkedMsgTrustedSignedBeaconBlock | ForkedSignedBlindedBeaconBlock): ValidatorSig = - withBlck(x): blck.signature + withBlck(x): forkyBlck.signature template signature*(x: ForkedTrustedSignedBeaconBlock): TrustedSig = - withBlck(x): blck.signature + withBlck(x): forkyBlck.signature template root*(x: ForkedSignedBeaconBlock | ForkedMsgTrustedSignedBeaconBlock | ForkedTrustedSignedBeaconBlock): Eth2Digest = - withBlck(x): blck.root + withBlck(x): forkyBlck.root template slot*(x: ForkedSignedBeaconBlock | ForkedMsgTrustedSignedBeaconBlock | ForkedTrustedSignedBeaconBlock): Slot = - withBlck(x): blck.message.slot + withBlck(x): forkyBlck.message.slot template shortLog*(x: ForkedBeaconBlock | ForkedBlindedBeaconBlock): auto = - withBlck(x): shortLog(blck) + withBlck(x): shortLog(forkyBlck) template shortLog*(x: ForkedSignedBeaconBlock | ForkedMsgTrustedSignedBeaconBlock | ForkedTrustedSignedBeaconBlock | ForkedSignedBlindedBeaconBlock): auto = - withBlck(x): shortLog(blck) + withBlck(x): shortLog(forkyBlck) chronicles.formatIt ForkedBeaconBlock: it.shortLog chronicles.formatIt ForkedSignedBeaconBlock: it.shortLog @@ -849,27 +849,27 @@ template withStateAndBlck*( of ConsensusFork.Deneb: const consensusFork {.inject.} = ConsensusFork.Deneb template forkyState: untyped {.inject.} = s.denebData - template blck: untyped {.inject.} = b.denebData + template forkyBlck: untyped {.inject.} = b.denebData body of ConsensusFork.Capella: const consensusFork {.inject.} = ConsensusFork.Capella template forkyState: untyped {.inject.} = s.capellaData - template blck: untyped {.inject.} = b.capellaData + template forkyBlck: untyped {.inject.} = b.capellaData body of ConsensusFork.Bellatrix: const consensusFork {.inject.} = ConsensusFork.Bellatrix template forkyState: untyped {.inject.} = s.bellatrixData - template blck: untyped {.inject.} = b.bellatrixData + template forkyBlck: untyped {.inject.} = b.bellatrixData body of ConsensusFork.Altair: const consensusFork {.inject.} = ConsensusFork.Altair template forkyState: untyped {.inject.} = s.altairData - template blck: untyped {.inject.} = b.altairData + template forkyBlck: untyped {.inject.} = b.altairData body of ConsensusFork.Phase0: const consensusFork {.inject.} = ConsensusFork.Phase0 template forkyState: untyped {.inject.} = s.phase0Data - template blck: untyped {.inject.} = b.phase0Data + template forkyBlck: untyped {.inject.} = b.phase0Data body func toBeaconBlockHeader*( @@ -893,7 +893,7 @@ template toBeaconBlockHeader*( blckParam: ForkedMsgTrustedSignedBeaconBlock | ForkedTrustedSignedBeaconBlock): BeaconBlockHeader = ## Reduce a given signed beacon block to its `BeaconBlockHeader`. - withBlck(blckParam): blck.toBeaconBlockHeader() + withBlck(blckParam): forkyBlck.toBeaconBlockHeader() func genesisFork*(cfg: RuntimeConfig): Fork = Fork( @@ -1036,9 +1036,9 @@ func readSszForkedSignedBeaconBlock*( kind: cfg.consensusForkAtEpoch(header.slot.epoch())) withBlck(result): - readSszBytes(data, blck) + readSszBytes(data, forkyBlck) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_fork_data_root +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_fork_data_root func compute_fork_data_root*(current_version: Version, genesis_validators_root: Eth2Digest): Eth2Digest = ## Return the 32-byte fork data root for the ``current_version`` and @@ -1050,7 +1050,7 @@ func compute_fork_data_root*(current_version: Version, genesis_validators_root: genesis_validators_root )) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_fork_digest +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_fork_digest func compute_fork_digest*(current_version: Version, genesis_validators_root: Eth2Digest): ForkDigest = ## Return the 4-byte fork digest for the ``current_version`` and @@ -1087,7 +1087,7 @@ func toBlockId*(blck: SomeForkySignedBeaconBlock): BlockId = func toBlockId*(blck: ForkedSignedBeaconBlock | ForkedMsgTrustedSignedBeaconBlock | ForkedTrustedSignedBeaconBlock): BlockId = - withBlck(blck): BlockId(root: blck.root, slot: blck.message.slot) + withBlck(blck): BlockId(root: forkyBlck.root, slot: forkyBlck.message.slot) func historical_summaries*(state: ForkedHashedBeaconState): HashList[HistoricalSummary, Limit HISTORICAL_ROOTS_LIMIT] = diff --git a/beacon_chain/spec/forks_light_client.nim b/beacon_chain/spec/forks_light_client.nim index 561b7597a..29fa063e7 100644 --- a/beacon_chain/spec/forks_light_client.nim +++ b/beacon_chain/spec/forks_light_client.nim @@ -816,7 +816,7 @@ func migratingToDataFork*[ upgradedObject.migrateToDataFork(newKind) upgradedObject -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/full-node.md#block_to_light_client_header +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/full-node.md#block_to_light_client_header func toAltairLightClientHeader( blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6) phase0.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock | @@ -826,7 +826,7 @@ func toAltairLightClientHeader( altair.LightClientHeader( beacon: blck.message.toBeaconBlockHeader()) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/light-client/full-node.md#modified-block_to_light_client_header +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/light-client/full-node.md#modified-block_to_light_client_header func toCapellaLightClientHeader( blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6) phase0.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock | diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index 423b52862..206348ab8 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -26,7 +26,7 @@ export eth2_merkleization, forks, rlp, ssz_codec func toEther*(gwei: Gwei): Ether = - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/weak-subjectivity.md#constants + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/weak-subjectivity.md#constants const ETH_TO_GWEI = 1_000_000_000 (gwei div ETH_TO_GWEI).Ether @@ -49,7 +49,7 @@ func shortLog*(v: FinalityCheckpoints): auto = chronicles.formatIt FinalityCheckpoints: it.shortLog -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#integer_squareroot +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#integer_squareroot func integer_squareroot*(n: SomeInteger): SomeInteger = ## Return the largest integer ``x`` such that ``x**2 <= n``. doAssert n >= 0'u64 @@ -62,7 +62,7 @@ func integer_squareroot*(n: SomeInteger): SomeInteger = y = (x + n div x) div 2 x -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#is_active_validator +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#is_active_validator func is_active_validator*(validator: Validator, epoch: Epoch): bool = ## Check if ``validator`` is active. validator.activation_epoch <= epoch and epoch < validator.exit_epoch @@ -100,23 +100,23 @@ func get_active_validator_indices_len*( withState(state): get_active_validator_indices_len(forkyState.data, epoch) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_current_epoch +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_current_epoch func get_current_epoch*(state: ForkyBeaconState): Epoch = ## Return the current epoch. state.slot.epoch -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_current_epoch +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_current_epoch func get_current_epoch*(state: ForkedHashedBeaconState): Epoch = ## Return the current epoch. withState(state): get_current_epoch(forkyState.data) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#get_previous_epoch +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_previous_epoch func get_previous_epoch*( state: ForkyBeaconState | ForkedHashedBeaconState): Epoch = ## Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``). get_previous_epoch(get_current_epoch(state)) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_randao_mix +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_randao_mix func get_randao_mix*(state: ForkyBeaconState, epoch: Epoch): Eth2Digest = ## Return the randao mix at a recent ``epoch``. state.randao_mixes[epoch mod EPOCHS_PER_HISTORICAL_VECTOR] @@ -138,7 +138,7 @@ func uint_to_bytes*(x: uint32): array[4, byte] = toBytesLE(x) func uint_to_bytes*(x: uint16): array[2, byte] = toBytesLE(x) func uint_to_bytes*(x: uint8): array[1, byte] = toBytesLE(x) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_domain +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_domain func compute_domain*( domain_type: DomainType, fork_version: Version, @@ -152,7 +152,7 @@ func compute_domain*( result[0..3] = domain_type.data result[4..31] = fork_data_root.data.toOpenArray(0, 27) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_domain +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_domain func get_domain*( fork: Fork, domain_type: DomainType, @@ -173,7 +173,7 @@ func get_domain*( ## of a message. get_domain(state.fork, domain_type, epoch, state.genesis_validators_root) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_signing_root +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_signing_root func compute_signing_root*(ssz_object: auto, domain: Eth2Domain): Eth2Digest = ## Return the signing root for the corresponding signing data. let domain_wrapped_object = SigningData( @@ -182,7 +182,7 @@ func compute_signing_root*(ssz_object: auto, domain: Eth2Domain): Eth2Digest = ) hash_tree_root(domain_wrapped_object) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#get_seed +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_seed func get_seed*( state: ForkyBeaconState, epoch: Epoch, domain_type: DomainType, mix: Eth2Digest): Eth2Digest = @@ -201,17 +201,17 @@ func get_seed*(state: ForkyBeaconState, epoch: Epoch, domain_type: DomainType): epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD - 1) state.get_seed(epoch, domain_type, mix) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#add_flag +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#add_flag func add_flag*(flags: ParticipationFlags, flag_index: TimelyFlag): ParticipationFlags = let flag = ParticipationFlags(1'u8 shl ord(flag_index)) flags or flag -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#has_flag +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#has_flag func has_flag*(flags: ParticipationFlags, flag_index: TimelyFlag): bool = let flag = ParticipationFlags(1'u8 shl ord(flag_index)) (flags and flag) == flag -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#is_sync_committee_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#is_sync_committee_update template is_sync_committee_update*(update: SomeForkyLightClientUpdate): bool = when update is SomeForkyLightClientUpdateWithSyncCommittee: update.next_sync_committee_branch != @@ -219,7 +219,7 @@ template is_sync_committee_update*(update: SomeForkyLightClientUpdate): bool = else: false -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#is_finality_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#is_finality_update template is_finality_update*(update: SomeForkyLightClientUpdate): bool = when update is SomeForkyLightClientUpdateWithFinality: update.finality_branch != @@ -227,19 +227,19 @@ template is_finality_update*(update: SomeForkyLightClientUpdate): bool = else: false -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known template is_next_sync_committee_known*(store: ForkyLightClientStore): bool = store.next_sync_committee != static(default(typeof(store.next_sync_committee))) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#get_safety_threshold +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#get_safety_threshold func get_safety_threshold*(store: ForkyLightClientStore): uint64 = max( store.previous_max_active_participants, store.current_max_active_participants ) div 2 -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#is_better_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#is_better_update type LightClientUpdateMetadata* = object attested_slot*, finalized_slot*, signature_slot*: Slot has_sync_committee*, has_finality*: bool @@ -330,24 +330,24 @@ template is_better_update*[ new_update: A, old_update: B): bool = is_better_data(toMeta(new_update), toMeta(old_update)) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap func contextEpoch*(bootstrap: ForkyLightClientBootstrap): Epoch = bootstrap.header.beacon.slot.epoch -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate func contextEpoch*(update: SomeForkyLightClientUpdate): Epoch = update.attested_header.beacon.slot.epoch -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#is_merge_transition_complete +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#is_merge_transition_complete func is_merge_transition_complete*( state: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState): bool = const defaultExecutionPayloadHeader = default(typeof(state.latest_execution_payload_header)) state.latest_execution_payload_header != defaultExecutionPayloadHeader -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/sync/optimistic.md#helpers +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/sync/optimistic.md#helpers func is_execution_block*(blck: SomeForkyBeaconBlock): bool = when typeof(blck).toFork >= ConsensusFork.Bellatrix: const defaultExecutionPayload = @@ -356,7 +356,7 @@ func is_execution_block*(blck: SomeForkyBeaconBlock): bool = else: false -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#is_merge_transition_block +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#is_merge_transition_block func is_merge_transition_block( state: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState, body: bellatrix.BeaconBlockBody | bellatrix.TrustedBeaconBlockBody | @@ -369,7 +369,7 @@ func is_merge_transition_block( not is_merge_transition_complete(state) and body.execution_payload != defaultExecutionPayload -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#is_execution_enabled +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#is_execution_enabled func is_execution_enabled*( state: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState, body: bellatrix.BeaconBlockBody | bellatrix.TrustedBeaconBlockBody | @@ -380,7 +380,7 @@ func is_execution_enabled*( deneb.SigVerifiedBeaconBlockBody): bool = is_merge_transition_block(state, body) or is_merge_transition_complete(state) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#compute_timestamp_at_slot +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#compute_timestamp_at_slot func compute_timestamp_at_slot*(state: ForkyBeaconState, slot: Slot): uint64 = # Note: This function is unsafe with respect to overflows and underflows. let slots_since_genesis = slot - GENESIS_SLOT diff --git a/beacon_chain/spec/keystore.nim b/beacon_chain/spec/keystore.nim index 1e075f9ca..e6ca7a0ae 100644 --- a/beacon_chain/spec/keystore.nim +++ b/beacon_chain/spec/keystore.nim @@ -1369,7 +1369,7 @@ func makeWithdrawalCredentials*(k: ValidatorPubKey): Eth2Digest = bytes.data[0] = BLS_WITHDRAWAL_PREFIX.uint8 bytes -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/deposit-contract.md#withdrawal-credentials +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/deposit-contract.md#withdrawal-credentials proc makeWithdrawalCredentials*(k: CookedPubKey): Eth2Digest = makeWithdrawalCredentials(k.toPubKey()) diff --git a/beacon_chain/spec/light_client_sync.nim b/beacon_chain/spec/light_client_sync.nim index 1446edf13..105e66367 100644 --- a/beacon_chain/spec/light_client_sync.nim +++ b/beacon_chain/spec/light_client_sync.nim @@ -15,7 +15,7 @@ import from ../consensus_object_pools/block_pools_types import VerifierError export block_pools_types.VerifierError -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#initialize_light_client_store +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#initialize_light_client_store func initialize_light_client_store*( trusted_block_root: Eth2Digest, bootstrap: ForkyLightClientBootstrap, @@ -42,7 +42,7 @@ func initialize_light_client_store*( current_sync_committee: bootstrap.current_sync_committee, optimistic_header: bootstrap.header)) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#validate_light_client_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#validate_light_client_update proc validate_light_client_update*( store: ForkyLightClientStore, update: SomeForkyLightClientUpdate, @@ -158,7 +158,7 @@ proc validate_light_client_update*( ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#apply_light_client_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#apply_light_client_update func apply_light_client_update( store: var ForkyLightClientStore, update: SomeForkyLightClientUpdate): bool = @@ -189,7 +189,7 @@ func apply_light_client_update( didProgress = true didProgress -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#process_light_client_store_force_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#process_light_client_store_force_update type ForceUpdateResult* = enum NoUpdate, @@ -222,7 +222,7 @@ func process_light_client_store_force_update*( store.best_valid_update.reset() res -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#process_light_client_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#process_light_client_update proc process_light_client_update*( store: var ForkyLightClientStore, update: SomeForkyLightClientUpdate, diff --git a/beacon_chain/spec/network.nim b/beacon_chain/spec/network.nim index a71f18ef0..11f7f6287 100644 --- a/beacon_chain/spec/network.nim +++ b/beacon_chain/spec/network.nim @@ -15,7 +15,7 @@ export base const # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#topics-and-messages - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/p2p-interface.md#topics-and-messages + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/p2p-interface.md#topics-and-messages topicBeaconBlocksSuffix* = "beacon_block/ssz_snappy" topicVoluntaryExitsSuffix* = "voluntary_exit/ssz_snappy" topicProposerSlashingsSuffix* = "proposer_slashing/ssz_snappy" @@ -23,16 +23,16 @@ const topicAggregateAndProofsSuffix* = "beacon_aggregate_and_proof/ssz_snappy" topicBlsToExecutionChangeSuffix* = "bls_to_execution_change/ssz_snappy" - # The spec now includes this as a bare integer as `RESP_TIMEOUT` - RESP_TIMEOUT_DUR* = RESP_TIMEOUT.seconds +const + # The spec now includes this as a bare uint64 as `RESP_TIMEOUT` + RESP_TIMEOUT_DUR* = RESP_TIMEOUT.int64.seconds - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#configuration + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#configuration MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128 - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#configuration - MAX_REQUEST_BLOCKS_DENEB* = 128 # TODO Make use of in request code - MAX_REQUEST_BLOB_SIDECARS* = MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK - # TODO MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#configuration + MAX_REQUEST_BLOB_SIDECARS*: uint64 = + MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK defaultEth2TcpPort* = 9000 defaultEth2TcpPortDesc* = $defaultEth2TcpPort @@ -63,11 +63,11 @@ func getAttesterSlashingsTopic*(forkDigest: ForkDigest): string = func getAggregateAndProofsTopic*(forkDigest: ForkDigest): string = eth2Prefix(forkDigest) & topicAggregateAndProofsSuffix -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/p2p-interface.md#topics-and-messages +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/p2p-interface.md#topics-and-messages func getBlsToExecutionChangeTopic*(forkDigest: ForkDigest): string = eth2Prefix(forkDigest) & topicBlsToExecutionChangeSuffix -# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#broadcast-attestation +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/validator.md#broadcast-attestation func compute_subnet_for_attestation*( committees_per_slot: uint64, slot: Slot, committee_index: CommitteeIndex): SubnetId = @@ -105,16 +105,16 @@ func getBlobSidecarTopic*(forkDigest: ForkDigest, subnet_id: SubnetId): string = eth2Prefix(forkDigest) & "blob_sidecar_" & $subnet_id & "/ssz_snappy" -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/validator.md#sidecar +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/validator.md#sidecar func compute_subnet_for_blob_sidecar*(blob_index: BlobIndex): SubnetId = SubnetId(blob_index mod BLOB_SIDECAR_SUBNET_COUNT) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#light_client_finality_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#light_client_finality_update func getLightClientFinalityUpdateTopic*(forkDigest: ForkDigest): string = ## For broadcasting or obtaining the latest `LightClientFinalityUpdate`. eth2Prefix(forkDigest) & "light_client_finality_update/ssz_snappy" -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update func getLightClientOptimisticUpdateTopic*(forkDigest: ForkDigest): string = ## For broadcasting or obtaining the latest `LightClientOptimisticUpdate`. eth2Prefix(forkDigest) & "light_client_optimistic_update/ssz_snappy" diff --git a/beacon_chain/spec/presets.nim b/beacon_chain/spec/presets.nim index eee033fcb..129612d5c 100644 --- a/beacon_chain/spec/presets.nim +++ b/beacon_chain/spec/presets.nim @@ -17,13 +17,17 @@ export constants export stint, ethtypes.toHex, ethtypes.`==` const - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#withdrawal-prefixes + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#withdrawal-prefixes BLS_WITHDRAWAL_PREFIX*: byte = 0 ETH1_ADDRESS_WITHDRAWAL_PREFIX*: byte = 1 # Constants from `validator.md` not covered by config/presets in the spec TARGET_AGGREGATORS_PER_COMMITTEE*: uint64 = 16 + + # Not used anywhere; only for network preset checking EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION: uint64 = 256 + MESSAGE_DOMAIN_INVALID_SNAPPY = 0'u64 + TTFB_TIMEOUT = 5'u64 type Version* = distinct array[4, byte] @@ -67,6 +71,7 @@ type EJECTION_BALANCE*: uint64 MIN_PER_EPOCH_CHURN_LIMIT*: uint64 CHURN_LIMIT_QUOTIENT*: uint64 + MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT*: uint64 # Fork choice # TODO PROPOSER_SCORE_BOOST*: uint64 @@ -190,7 +195,8 @@ when const_preset == "mainnet": MIN_PER_EPOCH_CHURN_LIMIT: 4, # 2**16 (= 65,536) CHURN_LIMIT_QUOTIENT: 65536, - + # [New in Deneb:EIP7514] 2**3 (= 8) + MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8, # Deposit contract # --------------------------------------------------------------- @@ -295,7 +301,8 @@ elif const_preset == "gnosis": MIN_PER_EPOCH_CHURN_LIMIT: 4, # 2**16 (= 65,536) CHURN_LIMIT_QUOTIENT: 4096, - + # [New in Deneb:EIP7514] 2**3 (= 8) + MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8, # Deposit contract # --------------------------------------------------------------- @@ -391,10 +398,12 @@ elif const_preset == "minimal": INACTIVITY_SCORE_RECOVERY_RATE: 16, # 2**4 * 10**9 (= 16,000,000,000) Gwei EJECTION_BALANCE: 16000000000'u64, - # 2**2 (= 4) - MIN_PER_EPOCH_CHURN_LIMIT: 4, + # [customized] more easily demonstrate the difference between this value and the activation churn limit + MIN_PER_EPOCH_CHURN_LIMIT: 2, # [customized] scale queue churn at much lower validator counts for testing CHURN_LIMIT_QUOTIENT: 32, + # [New in Deneb:EIP7514] [customized] + MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 4, # Deposit contract @@ -591,6 +600,11 @@ proc readRuntimeConfig*( checkCompatibility ATTESTATION_SUBNET_PREFIX_BITS checkCompatibility BLOB_SIDECAR_SUBNET_COUNT checkCompatibility MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS + checkCompatibility RESP_TIMEOUT + checkCompatibility TTFB_TIMEOUT + checkCompatibility MESSAGE_DOMAIN_INVALID_SNAPPY + checkCompatibility MAX_REQUEST_BLOCKS_DENEB + checkCompatibility ATTESTATION_PROPAGATION_SLOT_RANGE # Isn't being used as a preset in the usual way: at any time, there's one correct value checkCompatibility PROPOSER_SCORE_BOOST diff --git a/beacon_chain/spec/presets/gnosis/altair_preset.nim b/beacon_chain/spec/presets/gnosis/altair_preset.nim index c358de3cd..810dd8a5b 100644 --- a/beacon_chain/spec/presets/gnosis/altair_preset.nim +++ b/beacon_chain/spec/presets/gnosis/altair_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Mainnet preset - Altair -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/altair.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/altair.yaml const # Updated penalty values # --------------------------------------------------------------- diff --git a/beacon_chain/spec/presets/gnosis/bellatrix_preset.nim b/beacon_chain/spec/presets/gnosis/bellatrix_preset.nim index 2685b1cf3..9bc66e025 100644 --- a/beacon_chain/spec/presets/gnosis/bellatrix_preset.nim +++ b/beacon_chain/spec/presets/gnosis/bellatrix_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Gnosis preset - Bellatrix -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/bellatrix.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/bellatrix.yaml const # Updated penalty values # --------------------------------------------------------------- diff --git a/beacon_chain/spec/presets/mainnet/altair_preset.nim b/beacon_chain/spec/presets/mainnet/altair_preset.nim index 145f37ad4..dca648a80 100644 --- a/beacon_chain/spec/presets/mainnet/altair_preset.nim +++ b/beacon_chain/spec/presets/mainnet/altair_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Mainnet preset - Altair -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/altair.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/altair.yaml const # Updated penalty values # --------------------------------------------------------------- diff --git a/beacon_chain/spec/presets/mainnet/bellatrix_preset.nim b/beacon_chain/spec/presets/mainnet/bellatrix_preset.nim index a7a59ebff..251d8bd72 100644 --- a/beacon_chain/spec/presets/mainnet/bellatrix_preset.nim +++ b/beacon_chain/spec/presets/mainnet/bellatrix_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Mainnet preset - Bellatrix -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/bellatrix.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/bellatrix.yaml const # Updated penalty values # --------------------------------------------------------------- diff --git a/beacon_chain/spec/presets/mainnet/capella_preset.nim b/beacon_chain/spec/presets/mainnet/capella_preset.nim index f230fdd9d..36670a32a 100644 --- a/beacon_chain/spec/presets/mainnet/capella_preset.nim +++ b/beacon_chain/spec/presets/mainnet/capella_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Mainnet preset - Capella -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/capella.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/capella.yaml const # Max operations per block # --------------------------------------------------------------- diff --git a/beacon_chain/spec/presets/mainnet/deneb_preset.nim b/beacon_chain/spec/presets/mainnet/deneb_preset.nim index 26f84f008..738691bf3 100644 --- a/beacon_chain/spec/presets/mainnet/deneb_preset.nim +++ b/beacon_chain/spec/presets/mainnet/deneb_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Mainnet preset - Deneb -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/mainnet/deneb.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/mainnet/deneb.yaml const # `uint64(4096)` FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096 diff --git a/beacon_chain/spec/presets/minimal/altair_preset.nim b/beacon_chain/spec/presets/minimal/altair_preset.nim index f766f05a3..0a7e983dc 100644 --- a/beacon_chain/spec/presets/minimal/altair_preset.nim +++ b/beacon_chain/spec/presets/minimal/altair_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Minimal preset - Altair -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/minimal/altair.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/minimal/altair.yaml const # Updated penalty values # --------------------------------------------------------------- diff --git a/beacon_chain/spec/presets/minimal/bellatrix_preset.nim b/beacon_chain/spec/presets/minimal/bellatrix_preset.nim index fffb8a53a..ceeb7f509 100644 --- a/beacon_chain/spec/presets/minimal/bellatrix_preset.nim +++ b/beacon_chain/spec/presets/minimal/bellatrix_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Minimal preset - Bellatrix -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/minimal/bellatrix.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/minimal/bellatrix.yaml const # Updated penalty values # --------------------------------------------------------------- diff --git a/beacon_chain/spec/presets/minimal/capella_preset.nim b/beacon_chain/spec/presets/minimal/capella_preset.nim index 5c001aead..db086c3a0 100644 --- a/beacon_chain/spec/presets/minimal/capella_preset.nim +++ b/beacon_chain/spec/presets/minimal/capella_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Minimal preset - Capella -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/minimal/capella.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/minimal/capella.yaml const # Max operations per block # --------------------------------------------------------------- diff --git a/beacon_chain/spec/presets/minimal/deneb_preset.nim b/beacon_chain/spec/presets/minimal/deneb_preset.nim index 0a44f68eb..7bc8da7cc 100644 --- a/beacon_chain/spec/presets/minimal/deneb_preset.nim +++ b/beacon_chain/spec/presets/minimal/deneb_preset.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # Minimal preset - Deneb -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/presets/minimal/deneb.yaml +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/presets/minimal/deneb.yaml const # [customized] FIELD_ELEMENTS_PER_BLOB*: uint64 = 4 diff --git a/beacon_chain/spec/signatures.nim b/beacon_chain/spec/signatures.nim index 4887aa286..f25240b77 100644 --- a/beacon_chain/spec/signatures.nim +++ b/beacon_chain/spec/signatures.nim @@ -388,7 +388,7 @@ proc verify_builder_signature*( let signing_root = compute_builder_signing_root(fork, msg) blsVerify(pubkey, signing_root.data, signature) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#new-process_bls_to_execution_change +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#new-process_bls_to_execution_change func compute_bls_to_execution_change_signing_root*( genesisFork: Fork, genesis_validators_root: Eth2Digest, msg: BLSToExecutionChange): Eth2Digest = diff --git a/beacon_chain/spec/signatures_batch.nim b/beacon_chain/spec/signatures_batch.nim index 6bbd162da..a16d01004 100644 --- a/beacon_chain/spec/signatures_batch.nim +++ b/beacon_chain/spec/signatures_batch.nim @@ -82,7 +82,7 @@ func aggregateAttesters( # Aggregation spec requires non-empty collection # - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04 # Consensus specs require at least one attesting index in attestation - # - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#is_valid_indexed_attestation + # - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#is_valid_indexed_attestation return err("aggregateAttesters: no attesting indices") let @@ -108,7 +108,7 @@ func aggregateAttesters( # Aggregation spec requires non-empty collection # - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04 # Consensus specs require at least one attesting index in attestation - # - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#is_valid_indexed_attestation + # - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#is_valid_indexed_attestation return err("aggregateAttesters: no attesting indices") var attestersAgg{.noinit.}: AggregatePublicKey diff --git a/beacon_chain/spec/ssz_codec.nim b/beacon_chain/spec/ssz_codec.nim index e03f740f4..4a55a82e9 100644 --- a/beacon_chain/spec/ssz_codec.nim +++ b/beacon_chain/spec/ssz_codec.nim @@ -6,7 +6,6 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. {.push raises: [].} -{.pragma: raisesssz, raises: [MalformedSszError, SszSizeMismatchError].} import std/[typetraits], @@ -27,7 +26,8 @@ template toSszType*(v: Version): auto = distinctBase(v) template toSszType*(v: JustificationBits): auto = distinctBase(v) template toSszType*(v: EpochParticipationFlags): auto = asList v -func fromSszBytes*(T: type GraffitiBytes, data: openArray[byte]): T {.raisesssz.} = +func fromSszBytes*( + T: type GraffitiBytes, data: openArray[byte]): T {.raises: [SszError].} = if data.len != sizeof(result): raiseIncorrectSize T copyMem(result.addr, unsafeAddr data[0], sizeof(result)) @@ -41,22 +41,28 @@ template fromSszBytes*(T: type Epoch, bytes: openArray[byte]): T = template fromSszBytes*(T: type SyncCommitteePeriod, bytes: openArray[byte]): T = T fromSszBytes(uint64, bytes) -func fromSszBytes*(T: type ForkDigest, bytes: openArray[byte]): T {.raisesssz.} = +func fromSszBytes*( + T: type ForkDigest, bytes: openArray[byte]): T {.raises: [SszError].} = if bytes.len != sizeof(result): raiseIncorrectSize T copyMem(result.addr, unsafeAddr bytes[0], sizeof(result)) -func fromSszBytes*(T: type Version, bytes: openArray[byte]): T {.raisesssz.} = +func fromSszBytes*( + T: type Version, bytes: openArray[byte]): T {.raises: [SszError].} = if bytes.len != sizeof(result): raiseIncorrectSize T copyMem(result.addr, unsafeAddr bytes[0], sizeof(result)) -func fromSszBytes*(T: type JustificationBits, bytes: openArray[byte]): T {.raisesssz.} = +func fromSszBytes*( + T: type JustificationBits, bytes: openArray[byte] +): T {.raises: [SszError].} = if bytes.len != sizeof(result): raiseIncorrectSize T copyMem(result.addr, unsafeAddr bytes[0], sizeof(result)) -func fromSszBytes*(T: type EpochParticipationFlags, bytes: openArray[byte]): T {.raisesssz.} = +func fromSszBytes*( + T: type EpochParticipationFlags, bytes: openArray[byte] +): T {.raises: [SszError].} = # TODO https://github.com/nim-lang/Nim/issues/21123 let tmp = cast[ptr List[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]](addr result) readSszValue(bytes, tmp[]) diff --git a/beacon_chain/spec/state_transition.nim b/beacon_chain/spec/state_transition.nim index f98731daa..6775436fa 100644 --- a/beacon_chain/spec/state_transition.nim +++ b/beacon_chain/spec/state_transition.nim @@ -6,7 +6,7 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # State transition, as described in -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function # # The entry point is `state_transition` which is at the bottom of the file! # @@ -70,7 +70,7 @@ proc verify_block_signature( ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function func verifyStateRoot( state: ForkyBeaconState, blck: ForkyBeaconBlock | ForkySigVerifiedBeaconBlock): @@ -126,7 +126,7 @@ func clear_epoch_from_cache(cache: var StateCache, epoch: Epoch) = for slot in epoch.slots(): cache.beacon_proposer_indices.del slot -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function proc advance_slot( cfg: RuntimeConfig, state: var ForkyBeaconState, previous_slot_state_root: Eth2Digest, @@ -373,7 +373,7 @@ template partialBeaconBlock*( when consensusFork >= ConsensusFork.Bellatrix: res.body.execution_payload = execution_payload.executionPayload - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/validator.md#block-proposal + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/validator.md#block-proposal when consensusFork >= ConsensusFork.Capella: res.body.bls_to_execution_changes = validator_changes.bls_to_execution_changes @@ -438,7 +438,7 @@ proc makeBeaconBlock*( forkyState.data.latest_execution_payload_header.transactions_root = transactions_root.get - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#beaconblockbody + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#beaconblockbody # Effectively hash_tree_root(ExecutionPayload) with the beacon block # body, with the execution payload replaced by the execution payload # header. htr(payload) == htr(payload header), so substitute. @@ -456,7 +456,7 @@ proc makeBeaconBlock*( hash_tree_root(validator_changes.bls_to_execution_changes)]) elif consensusFork == ConsensusFork.Deneb: when executionPayload is deneb.ExecutionPayloadForSigning: - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#beaconblockbody + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#beaconblockbody forkyState.data.latest_block_header.body_root = hash_tree_root( [hash_tree_root(randao_reveal), hash_tree_root(eth1_data), diff --git a/beacon_chain/spec/state_transition_block.nim b/beacon_chain/spec/state_transition_block.nim index cea239a53..d09545ad1 100644 --- a/beacon_chain/spec/state_transition_block.nim +++ b/beacon_chain/spec/state_transition_block.nim @@ -6,10 +6,10 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. # State transition - block processing, as described in -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#block-processing +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#block-processing # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#block-processing # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#block-processing -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#block-processing +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#block-processing # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/beacon-chain.md#block-processing # # The entry point is `process_block` which is at the bottom of this file. @@ -38,7 +38,7 @@ from ./datatypes/capella import export extras, phase0, altair -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#block-header +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#block-header func process_block_header*( state: var ForkyBeaconState, blck: SomeForkyBeaconBlock, flags: UpdateFlags, cache: var StateCache): Result[void, cstring] = @@ -80,7 +80,7 @@ func `xor`[T: array](a, b: T): T = for i in 0..= ConsensusFork.Deneb: + get_validator_activation_churn_limit(cfg, state, cache) + else: + get_validator_churn_limit(cfg, state, cache) for vidx in state.validators.vindices: if is_eligible_for_activation_queue(state.validators.item(vidx)): state.validators.mitem(vidx).activation_eligibility_epoch = @@ -859,8 +863,8 @@ func process_registry_updates*( elif val_key > activation_queue[0]: discard activation_queue.replace val_key - ## Dequeued validators for activation up to churn limit (without resetting - ## activation epoch) + ## Dequeued validators for activation up to activation churn limit + ## (without resetting activation epoch) doAssert activation_queue.len.uint64 <= churn_limit for i in 0 ..< activation_queue.len: let (_, vidx_complement) = activation_queue[i] @@ -870,9 +874,9 @@ func process_registry_updates*( ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#slashings -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#slashings -# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#slashings func get_adjusted_total_slashing_balance*( state: ForkyBeaconState, total_balance: Gwei): Gwei = const multiplier = @@ -890,15 +894,15 @@ func get_adjusted_total_slashing_balance*( min(sum(state.slashings.data) * multiplier, total_balance) # https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#slashings -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#slashings -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#slashings func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool = validator.slashed and epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#slashings -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#slashings -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#slashings func get_slashing_penalty*(validator: Validator, adjusted_total_slashing_balance, total_balance: Gwei): Gwei = @@ -908,9 +912,9 @@ func get_slashing_penalty*(validator: Validator, adjusted_total_slashing_balance penalty_numerator div total_balance * increment -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#slashings -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#slashings -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/bellatrix/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#slashings +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/bellatrix/beacon-chain.md#slashings func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) = let epoch = get_current_epoch(state) @@ -924,7 +928,7 @@ func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) = validator[], adjusted_total_slashing_balance, total_balance) decrease_balance(state, vidx, penalty) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#eth1-data-votes-updates +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#eth1-data-votes-updates func process_eth1_data_reset*(state: var ForkyBeaconState) = let next_epoch = get_current_epoch(state) + 1 @@ -932,7 +936,7 @@ func process_eth1_data_reset*(state: var ForkyBeaconState) = if next_epoch mod EPOCHS_PER_ETH1_VOTING_PERIOD == 0: state.eth1_data_votes = default(type state.eth1_data_votes) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#effective-balances-updates +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#effective-balances-updates func process_effective_balance_updates*(state: var ForkyBeaconState) = # Update effective balances with hysteresis for vidx in state.validators.vindices: @@ -954,14 +958,14 @@ func process_effective_balance_updates*(state: var ForkyBeaconState) = if new_effective_balance != effective_balance: state.validators.mitem(vidx).effective_balance = new_effective_balance -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#slashings-balances-updates +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#slashings-balances-updates func process_slashings_reset*(state: var ForkyBeaconState) = let next_epoch = get_current_epoch(state) + 1 # Reset slashings state.slashings[int(next_epoch mod EPOCHS_PER_SLASHINGS_VECTOR)] = 0.Gwei -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#randao-mixes-updates +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#randao-mixes-updates func process_randao_mixes_reset*(state: var ForkyBeaconState) = let current_epoch = get_current_epoch(state) @@ -974,12 +978,12 @@ func process_randao_mixes_reset*(state: var ForkyBeaconState) = func compute_historical_root*(state: var ForkyBeaconState): Eth2Digest = # Equivalent to hash_tree_root(foo: HistoricalBatch), but without using # significant additional stack or heap. - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#historicalbatch + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#historicalbatch # In response to https://github.com/status-im/nimbus-eth2/issues/921 hash_tree_root([ hash_tree_root(state.block_roots), hash_tree_root(state.state_roots)]) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#historical-roots-updates +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#historical-roots-updates func process_historical_roots_update*(state: var ForkyBeaconState) = ## Set historical root accumulator let next_epoch = get_current_epoch(state) + 1 @@ -987,7 +991,7 @@ func process_historical_roots_update*(state: var ForkyBeaconState) = if next_epoch mod (SLOTS_PER_HISTORICAL_ROOT div SLOTS_PER_EPOCH) == 0: # Equivalent to hash_tree_root(foo: HistoricalBatch), but without using # significant additional stack or heap. - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#historicalbatch + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#historicalbatch # In response to https://github.com/status-im/nimbus-eth2/issues/921 if not state.historical_roots.add state.compute_historical_root(): raiseAssert "no more room for historical roots, so long and thanks for the fish!" @@ -999,7 +1003,7 @@ func process_participation_record_updates*(state: var phase0.BeaconState) = state.previous_epoch_attestations.clear() swap(state.previous_epoch_attestations, state.current_epoch_attestations) -# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#participation-flags-updates +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#participation-flags-updates func process_participation_flag_updates*( state: var (altair.BeaconState | bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState)) = @@ -1013,7 +1017,7 @@ func process_participation_flag_updates*( # grows. New elements are automatically initialized to 0, as required. doAssert state.current_epoch_participation.asList.setLen(state.validators.len) -# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#sync-committee-updates +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#sync-committee-updates func process_sync_committee_updates*( state: var (altair.BeaconState | bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState)) = @@ -1022,7 +1026,7 @@ func process_sync_committee_updates*( state.current_sync_committee = state.next_sync_committee state.next_sync_committee = get_next_sync_committee(state) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#inactivity-scores +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#inactivity-scores func process_inactivity_updates*( cfg: RuntimeConfig, state: var (altair.BeaconState | bellatrix.BeaconState | @@ -1059,7 +1063,7 @@ func process_inactivity_updates*( if pre_inactivity_score != inactivity_score: state.inactivity_scores[index] = inactivity_score -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#historical-summaries-updates +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#historical-summaries-updates func process_historical_summaries_update*( state: var (capella.BeaconState | deneb.BeaconState)): Result[void, cstring] = @@ -1075,7 +1079,7 @@ func process_historical_summaries_update*( ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#epoch-processing +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#epoch-processing proc process_epoch*( cfg: RuntimeConfig, state: var phase0.BeaconState, flags: UpdateFlags, cache: var StateCache, info: var phase0.EpochInfo): Result[void, cstring] = @@ -1163,10 +1167,10 @@ proc process_epoch*( # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#rewards-and-penalties process_rewards_and_penalties(cfg, state, info) # [Modified in Altair] - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#registry-updates + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#registry-updates ? process_registry_updates(cfg, state, cache) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#slashings + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#slashings process_slashings(state, info.balances.current_epoch) # [Modified in Altair] process_eth1_data_reset(state) @@ -1179,7 +1183,7 @@ proc process_epoch*( ok() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/capella/beacon-chain.md#epoch-processing +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/capella/beacon-chain.md#epoch-processing proc process_epoch*( cfg: RuntimeConfig, state: var (capella.BeaconState | deneb.BeaconState), @@ -1190,7 +1194,7 @@ proc process_epoch*( info.init(state) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#justification-and-finalization + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#justification-and-finalization process_justification_and_finalization(state, info.balances, flags) # state.slot hasn't been incremented yet. @@ -1209,10 +1213,10 @@ proc process_epoch*( # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#rewards-and-penalties process_rewards_and_penalties(cfg, state, info) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#registry-updates + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#registry-updates ? process_registry_updates(cfg, state, cache) - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/beacon-chain.md#slashings + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/beacon-chain.md#slashings process_slashings(state, info.balances.current_epoch) process_eth1_data_reset(state) diff --git a/beacon_chain/spec/validator.nim b/beacon_chain/spec/validator.nim index eab7c5930..4b8bf16cd 100644 --- a/beacon_chain/spec/validator.nim +++ b/beacon_chain/spec/validator.nim @@ -21,8 +21,8 @@ const PIVOT_VIEW_SIZE = SEED_SIZE + ROUND_SIZE TOTAL_SIZE = PIVOT_VIEW_SIZE + POSITION_WINDOW_SIZE -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_shuffled_index -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_committee +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_shuffled_index +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_committee # Port of https://github.com/protolambda/zrnt/blob/master/eth2/beacon/shuffle.go # Shuffles or unshuffles, depending on the `dir` (true for shuffling, false for unshuffling func shuffle_list*(input: var seq[ValidatorIndex], seed: Eth2Digest) = @@ -160,13 +160,13 @@ func get_shuffled_active_validator_indices*( withState(state): cache.get_shuffled_active_validator_indices(forkyState.data, epoch) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#get_active_validator_indices +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_active_validator_indices func count_active_validators*(state: ForkyBeaconState, epoch: Epoch, cache: var StateCache): uint64 = cache.get_shuffled_active_validator_indices(state, epoch).lenu64 -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#get_committee_count_per_slot +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_committee_count_per_slot func get_committee_count_per_slot*(num_active_validators: uint64): uint64 = clamp( num_active_validators div SLOTS_PER_EPOCH div TARGET_COMMITTEE_SIZE, @@ -191,7 +191,7 @@ iterator get_committee_indices*(committee_count_per_slot: uint64): CommitteeInde let committee_index = CommitteeIndex.init(idx).expect("value clamped") yield committee_index -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_committee +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_committee func compute_committee_slice*( active_validators, index, count: uint64): Slice[int] = doAssert active_validators <= ValidatorIndex.high.uint64 @@ -237,7 +237,7 @@ func compute_committee_len*( (slice.b - slice.a + 1).uint64 -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#get_beacon_committee +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_beacon_committee iterator get_beacon_committee*( state: ForkyBeaconState, slot: Slot, index: CommitteeIndex, cache: var StateCache): (int, ValidatorIndex) = @@ -277,7 +277,7 @@ func get_beacon_committee*( withState(state): get_beacon_committee(forkyState.data, slot, index, cache) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#get_beacon_committee +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_beacon_committee func get_beacon_committee_len*( state: ForkyBeaconState, slot: Slot, index: CommitteeIndex, cache: var StateCache): uint64 = @@ -301,7 +301,7 @@ func get_beacon_committee_len*( withState(state): get_beacon_committee_len(forkyState.data, slot, index, cache) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_shuffled_index +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_shuffled_index func compute_shuffled_index*( index: uint64, index_count: uint64, seed: Eth2Digest): uint64 = ## Return the shuffled index corresponding to ``seed`` (and ``index_count``). @@ -336,7 +336,7 @@ func compute_shuffled_index*( cur_idx_permuted -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#compute_proposer_index +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#compute_proposer_index func compute_proposer_index(state: ForkyBeaconState, indices: seq[ValidatorIndex], seed: Eth2Digest): Opt[ValidatorIndex] = ## Return from ``indices`` a random index sampled by effective balance. @@ -363,7 +363,7 @@ func compute_proposer_index(state: ForkyBeaconState, return Opt.some(candidate_index) i += 1 -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_beacon_proposer_index +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_beacon_proposer_index func get_beacon_proposer_index*( state: ForkyBeaconState, cache: var StateCache, slot: Slot): Opt[ValidatorIndex] = @@ -401,7 +401,7 @@ func get_beacon_proposer_index*( return res -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#get_beacon_proposer_index +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#get_beacon_proposer_index func get_beacon_proposer_index*(state: ForkyBeaconState, cache: var StateCache): Opt[ValidatorIndex] = ## Return the beacon proposer index at the current slot. diff --git a/beacon_chain/spec/weak_subjectivity.nim b/beacon_chain/spec/weak_subjectivity.nim index a100a2443..aa6180851 100644 --- a/beacon_chain/spec/weak_subjectivity.nim +++ b/beacon_chain/spec/weak_subjectivity.nim @@ -10,10 +10,10 @@ import ./datatypes/base, ./beaconstate, ./forks, ./helpers -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/weak-subjectivity.md#configuration +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/weak-subjectivity.md#configuration const SAFETY_DECAY* = 10'u64 -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/weak-subjectivity.md#compute_weak_subjectivity_period +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/weak-subjectivity.md#compute_weak_subjectivity_period func compute_weak_subjectivity_period( cfg: RuntimeConfig, state: ForkyBeaconState): uint64 = ## Returns the weak subjectivity period for the current ``state``. @@ -49,7 +49,7 @@ func compute_weak_subjectivity_period( ws_period -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/weak-subjectivity.md#is_within_weak_subjectivity_period +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/weak-subjectivity.md#is_within_weak_subjectivity_period func is_within_weak_subjectivity_period*(cfg: RuntimeConfig, current_slot: Slot, ws_state: ForkedHashedBeaconState, ws_checkpoint: Checkpoint): bool = diff --git a/beacon_chain/statediff.nim b/beacon_chain/statediff.nim index dc01d9fcd..caa50e1ca 100644 --- a/beacon_chain/statediff.nim +++ b/beacon_chain/statediff.nim @@ -187,7 +187,7 @@ func getBeaconStateDiffSummary*(state0: capella.BeaconState): if state0.eth1_data_votes.len > 0: # replaceOrAddEncodeEth1Votes will check whether it needs to replace or add # the votes. Which happens is a function of effectively external data, i.e. - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#eth1-data + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#eth1-data # notes it depends on things not deterministic, from a pure consensus-layer # perspective. It thus must distinguish between adding and replacing votes, # which it accomplishes by checking lengths and the most recent votes. This diff --git a/beacon_chain/sync/light_client_manager.nim b/beacon_chain/sync/light_client_manager.nim index e096d6a44..ea0060473 100644 --- a/beacon_chain/sync/light_client_manager.nim +++ b/beacon_chain/sync/light_client_manager.nim @@ -110,7 +110,7 @@ proc isGossipSupported*( finalizedPeriod = self.getFinalizedPeriod(), isNextSyncCommitteeKnown = self.isNextSyncCommitteeKnown()) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap proc doRequest( e: typedesc[Bootstrap], peer: Peer, @@ -119,7 +119,7 @@ proc doRequest( raises: [IOError].} = peer.lightClientBootstrap(blockRoot) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange type LightClientUpdatesByRangeResponse = NetRes[List[ForkedLightClientUpdate, MAX_REQUEST_LIGHT_CLIENT_UPDATES]] proc doRequest( @@ -138,7 +138,7 @@ proc doRequest( raise newException(ResponseError, e.error) return response -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate proc doRequest( e: typedesc[FinalityUpdate], peer: Peer @@ -146,7 +146,7 @@ proc doRequest( raises: [IOError].} = peer.lightClientFinalityUpdate() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate proc doRequest( e: typedesc[OptimisticUpdate], peer: Peer @@ -281,7 +281,7 @@ proc query[E]( progressFut.complete() except CancelledError as exc: if not progressFut.finished: - progressFut.cancel() + progressFut.cancelSoon() except CatchableError as exc: discard finally: @@ -311,7 +311,7 @@ proc query[E]( doneFut.complete() break if not workers[i].finished: - workers[i].cancel() + workers[i].cancelSoon() while true: try: await allFutures(workers[0 ..< maxCompleted]) @@ -326,7 +326,7 @@ proc query[E]( continue if not progressFut.finished: - progressFut.cancel() + progressFut.cancelSoon() return progressFut.completed template query[E]( @@ -335,7 +335,7 @@ template query[E]( ): Future[bool] = self.query(e, Nothing()) -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/light-client.md#light-client-sync-process +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/light-client.md#light-client-sync-process proc loop(self: LightClientManager) {.async.} = var nextSyncTaskTime = self.getBeaconTime() while true: diff --git a/beacon_chain/sync/request_manager.nim b/beacon_chain/sync/request_manager.nim index 85db76752..8fe3b3ff5 100644 --- a/beacon_chain/sync/request_manager.nim +++ b/beacon_chain/sync/request_manager.nim @@ -353,7 +353,7 @@ proc start*(rman: var RequestManager) = proc stop*(rman: RequestManager) = ## Stop Request Manager's loop. if not(isNil(rman.blockLoopFuture)): - rman.blockLoopFuture.cancel() + rman.blockLoopFuture.cancelSoon() if not(isNil(rman.blobLoopFuture)): - rman.blobLoopFuture.cancel() + rman.blobLoopFuture.cancelSoon() diff --git a/beacon_chain/sync/sync_manager.nim b/beacon_chain/sync/sync_manager.nim index 7248a7459..2bd07a20a 100644 --- a/beacon_chain/sync/sync_manager.nim +++ b/beacon_chain/sync/sync_manager.nim @@ -630,18 +630,15 @@ proc toTimeLeftString*(d: Duration): string = proc syncClose[A, B](man: SyncManager[A, B], guardTaskFut: Future[void], speedTaskFut: Future[void]) {.async.} = - guardTaskFut.cancel() - speedTaskFut.cancel() - await allFutures(guardTaskFut, speedTaskFut) - let pendingTasks = - block: - var res: seq[Future[void]] - for worker in man.workers: - doAssert(worker.status in {Sleeping, WaitingPeer}) - worker.future.cancel() - res.add(worker.future) - res - await allFutures(pendingTasks) + var pending: seq[FutureBase] + if not(guardTaskFut.finished()): + pending.add(guardTaskFut.cancelAndWait()) + if not(speedTaskFut.finished()): + pending.add(speedTaskFut.cancelAndWait()) + for worker in man.workers: + doAssert(worker.status in {Sleeping, WaitingPeer}) + pending.add(worker.future.cancelAndWait()) + await noCancel allFutures(pending) proc syncLoop[A, B](man: SyncManager[A, B]) {.async.} = logScope: diff --git a/beacon_chain/sync/sync_protocol.nim b/beacon_chain/sync/sync_protocol.nim index af9d8af32..079a8d4dc 100644 --- a/beacon_chain/sync/sync_protocol.nim +++ b/beacon_chain/sync/sync_protocol.nim @@ -283,7 +283,7 @@ p2pProtocol BeaconSync(version = 1, {.libp2pProtocol("ping", 1, isRequired = true).} = return peer.network.metadata.seq_number - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/p2p-interface.md#transitioning-from-v1-to-v2 + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/p2p-interface.md#transitioning-from-v1-to-v2 proc getMetaData(peer: Peer): uint64 {.libp2pProtocol("metadata", 1, isRequired = true).} = raise newException(InvalidInputsError, "GetMetaData v1 unsupported") @@ -548,7 +548,7 @@ p2pProtocol BeaconSync(version = 1, debug "BlobSidecar range request done", peer, startSlot, count = reqCount, found - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap proc lightClientBootstrap( peer: Peer, blockRoot: Eth2Digest, @@ -576,7 +576,7 @@ p2pProtocol BeaconSync(version = 1, debug "LC bootstrap request done", peer, blockRoot - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange proc lightClientUpdatesByRange( peer: Peer, startPeriod: SyncCommitteePeriod, @@ -621,7 +621,7 @@ p2pProtocol BeaconSync(version = 1, debug "LC updates by range request done", peer, startPeriod, count, found - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate proc lightClientFinalityUpdate( peer: Peer, response: SingleChunkResponse[ForkedLightClientFinalityUpdate]) @@ -648,7 +648,7 @@ p2pProtocol BeaconSync(version = 1, debug "LC finality update request done", peer - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate proc lightClientOptimisticUpdate( peer: Peer, response: SingleChunkResponse[ForkedLightClientOptimisticUpdate]) diff --git a/beacon_chain/trusted_node_sync.nim b/beacon_chain/trusted_node_sync.nim index b3d377c88..f25df9421 100644 --- a/beacon_chain/trusted_node_sync.nim +++ b/beacon_chain/trusted_node_sync.nim @@ -181,7 +181,7 @@ proc doTrustedNodeSync*( let stateId = case syncTarget.kind of TrustedNodeSyncKind.TrustedBlockRoot: - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/light-client.md#light-client-sync-process + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/light-client.md#light-client-sync-process const lcDataFork = LightClientDataFork.high var bestViableCheckpoint: Opt[tuple[slot: Slot, state_root: Eth2Digest]] func trackBestViableCheckpoint(store: lcDataFork.LightClientStore) = @@ -487,18 +487,18 @@ proc doTrustedNodeSync*( of TrustedNodeSyncKind.TrustedBlockRoot: # Trust-minimized sync: the server is only trusted for # data availability, responses must be verified - dag.addBackfillBlock(blck) + dag.addBackfillBlock(forkyBlck) of TrustedNodeSyncKind.StateId: # The server is fully trusted to provide accurate data; # it could have provided a malicious state - dag.addBackfillBlock(blck.asSigVerified()) + dag.addBackfillBlock(forkyBlck.asSigVerified()) if res.isErr(): case res.error() of VerifierError.Invalid, VerifierError.MissingParent, VerifierError.UnviableFork: error "Got invalid block from trusted node - is it on the right network?", - blck = shortLog(blck), err = res.error() + blck = shortLog(forkyBlck), err = res.error() quit 1 of VerifierError.Duplicate: discard diff --git a/beacon_chain/validator_client/block_service.nim b/beacon_chain/validator_client/block_service.nim index d5579e7fb..0cd889bbc 100644 --- a/beacon_chain/validator_client/block_service.nim +++ b/beacon_chain/validator_client/block_service.nim @@ -114,7 +114,7 @@ proc produceBlindedBlock( error "An unexpected error occurred while getting blinded block data", error_name = exc.name, error_msg = exc.msg return Opt.none(PreparedBlindedBeaconBlock) - blockRoot = withBlck(beaconBlock): hash_tree_root(blck) + blockRoot = withBlck(beaconBlock): hash_tree_root(forkyBlck) return Opt.some( PreparedBlindedBeaconBlock(blockRoot: blockRoot, data: beaconBlock)) @@ -734,7 +734,7 @@ proc runBlockPollMonitor(service: BlockServiceRef, proc runBlockMonitor(service: BlockServiceRef) {.async.} = let vc = service.client - blockNodes = vc.filterNodes(AllBeaconNodeStatuses, + blockNodes = vc.filterNodes(ResolvedBeaconNodeStatuses, {BeaconNodeRole.BlockProposalData}) let pendingTasks = case vc.config.monitoringType diff --git a/beacon_chain/validator_client/common.nim b/beacon_chain/validator_client/common.nim index ac49b1ea8..ea27720ef 100644 --- a/beacon_chain/validator_client/common.nim +++ b/beacon_chain/validator_client/common.nim @@ -118,6 +118,7 @@ type BeaconNodeServer* = object client*: RestClientRef + uri*: Uri endpoint*: string config*: VCRuntimeConfig ident*: Opt[string] @@ -146,6 +147,8 @@ type proofs*: Table[ValidatorPubKey, SyncCommitteeSelectionProof] RestBeaconNodeStatus* {.pure.} = enum + Invalid, ## BN address is invalid. + Noname, ## BN address could not be resolved yet. Offline, ## BN is offline. Online, ## BN is online, passed checkOnline() check. Incompatible, ## BN configuration is NOT compatible with VC. @@ -284,6 +287,22 @@ const ## are enabled by default. AllBeaconNodeStatuses* = { + RestBeaconNodeStatus.Invalid, + RestBeaconNodeStatus.Noname, + RestBeaconNodeStatus.Offline, + RestBeaconNodeStatus.Online, + RestBeaconNodeStatus.Incompatible, + RestBeaconNodeStatus.Compatible, + RestBeaconNodeStatus.NotSynced, + RestBeaconNodeStatus.OptSynced, + RestBeaconNodeStatus.Synced, + RestBeaconNodeStatus.UnexpectedCode, + RestBeaconNodeStatus.UnexpectedResponse, + RestBeaconNodeStatus.BrokenClock, + RestBeaconNodeStatus.InternalError + } + + ResolvedBeaconNodeStatuses* = { RestBeaconNodeStatus.Offline, RestBeaconNodeStatus.Online, RestBeaconNodeStatus.Incompatible, @@ -341,6 +360,8 @@ proc `$`*(roles: set[BeaconNodeRole]): string = proc `$`*(status: RestBeaconNodeStatus): string = case status + of RestBeaconNodeStatus.Invalid: "invalid-address" + of RestBeaconNodeStatus.Noname: "dns-error" of RestBeaconNodeStatus.Offline: "offline" of RestBeaconNodeStatus.Online: "online" of RestBeaconNodeStatus.Incompatible: "incompatible" @@ -548,11 +569,23 @@ proc updateStatus*(node: BeaconNodeServerRef, node = node case status + of RestBeaconNodeStatus.Invalid: + if node.status != status: + warn "Beacon node could not be used" + node.status = status + of RestBeaconNodeStatus.Noname: + if node.status != status: + warn "Beacon node address cannot be resolved" + node.status = status of RestBeaconNodeStatus.Offline: if node.status != status: - warn "Beacon node down", - reason = failure.getFailureReason() - node.status = status + if node.status in {RestBeaconNodeStatus.Invalid, + RestBeaconNodeStatus.Noname}: + notice "Beacon node address has been resolved" + node.status = status + else: + warn "Beacon node down", reason = failure.getFailureReason() + node.status = status of RestBeaconNodeStatus.Online: if node.status != status: let version = if node.ident.isSome(): node.ident.get() else: "" @@ -717,25 +750,38 @@ proc normalizeUri*(r: Uri): Result[Uri, cstring] = ok(normalized) +proc initClient*(uri: Uri): Result[RestClientRef, HttpAddressErrorType] = + let + flags = {RestClientFlag.CommaSeparatedArray} + socketFlags = {SocketFlags.TcpNoDelay} + address = ? getHttpAddress(uri) + client = RestClientRef.new(address, flags = flags, + socketFlags = socketFlags) + ok(client) + proc init*(t: typedesc[BeaconNodeServerRef], remote: Uri, index: int): Result[BeaconNodeServerRef, string] = doAssert(index >= 0) let - flags = {RestClientFlag.CommaSeparatedArray} - socketFlags = {SocketFlags.TcpNoDelay} remoteUri = normalizeUri(remote).valueOr: return err($error) - client = RestClientRef.new($remoteUri, flags = flags, - socketFlags = socketFlags).valueOr: - return err($error) roles = parseRoles(remoteUri.anchor).valueOr: return err($error) - - let server = BeaconNodeServerRef( - client: client, endpoint: $remoteUri, index: index, roles: roles, - logIdent: $client.address.getUri(), - status: RestBeaconNodeStatus.Offline - ) + server = + block: + let res = initClient(remoteUri) + if res.isOk(): + BeaconNodeServerRef( + client: res.get(), endpoint: $remoteUri, index: index, + roles: roles, logIdent: $(res.get().address.getUri()), + uri: remoteUri, status: RestBeaconNodeStatus.Offline) + else: + if res.error.isCriticalError(): + return err(res.error.toString()) + BeaconNodeServerRef( + client: nil, endpoint: $remoteUri, index: index, + roles: roles, logIdent: $remoteUri, uri: remoteUri, + status: RestBeaconNodeStatus.Noname) ok(server) proc getMissingRoles*(n: openArray[BeaconNodeServerRef]): set[BeaconNodeRole] = diff --git a/beacon_chain/validator_client/duties_service.nim b/beacon_chain/validator_client/duties_service.nim index 15b2743a9..f75888288 100644 --- a/beacon_chain/validator_client/duties_service.nim +++ b/beacon_chain/validator_client/duties_service.nim @@ -371,8 +371,19 @@ proc pollForSyncCommitteeDuties*(service: DutiesServiceRef) {.async.} = var counts: array[2, tuple[period: SyncCommitteePeriod, count: int]] counts[0] = (currentPeriod, await service.pollForSyncCommitteeDuties(currentPeriod)) - counts[1] = (nextPeriod, - await service.pollForSyncCommitteeDuties(nextPeriod)) + + const + numDelayEpochs = 4 # Chosen empirically + numLookaheadEpochs = + max(EPOCHS_PER_SYNC_COMMITTEE_PERIOD, numDelayEpochs) - + numDelayEpochs + 1 + if (currentEpoch + numLookaheadEpochs) >= nextPeriod.start_epoch: + counts[1] = (nextPeriod, + await service.pollForSyncCommitteeDuties(nextPeriod)) + else: + # Skip fetching `nextPeriod` until sync committees are likely known, + # as determined by `numDelayEpochs` from sync committee period start. + counts[1] = (nextPeriod, 0) if (counts[0].count == 0) and (counts[1].count == 0): debug "No new sync committee duties received", slot = currentSlot diff --git a/beacon_chain/validator_client/fallback_service.nim b/beacon_chain/validator_client/fallback_service.nim index 20d35d897..83f1690e3 100644 --- a/beacon_chain/validator_client/fallback_service.nim +++ b/beacon_chain/validator_client/fallback_service.nim @@ -45,6 +45,12 @@ proc filterNodes*(vc: ValidatorClientRef, statuses: set[RestBeaconNodeStatus], vc.beaconNodes.filterIt((it.roles * roles != {}) and (it.status in statuses)) +proc nonameNodes*(vc: ValidatorClientRef): seq[BeaconNodeServerRef] = + vc.beaconNodes.filterIt(it.status == RestBeaconNodeStatus.Noname) + +proc offlineNodes*(vc: ValidatorClientRef): seq[BeaconNodeServerRef] = + vc.beaconNodes.filterIt(it.status == RestBeaconNodeStatus.Offline) + proc otherNodes*(vc: ValidatorClientRef): seq[BeaconNodeServerRef] = vc.beaconNodes.filterIt(it.status != RestBeaconNodeStatus.Synced) @@ -91,6 +97,25 @@ proc waitNodes*(vc: ValidatorClientRef, timeoutFut: Future[void], inc(iterations) +proc checkName*( + node: BeaconNodeServerRef): RestBeaconNodeStatus {.raises: [].} = + ## Could return only {Invalid, Noname, Offline} + logScope: endpoint = node + let client = + block: + let res = initClient(node.uri) + if res.isErr(): + return + case res.error + of CriticalHttpAddressError: + RestBeaconNodeStatus.Invalid + of RecoverableHttpAddressError: + RestBeaconNodeStatus.Noname + res.get() + + node.client = client + RestBeaconNodeStatus.Offline + proc checkCompatible( vc: ValidatorClientRef, node: BeaconNodeServerRef @@ -225,6 +250,10 @@ proc checkOnline( func getReason(status: RestBeaconNodeStatus): string = case status + of RestBeaconNodeStatus.Invalid: + "Beacon node address invalid" + of RestBeaconNodeStatus.Noname: + "Beacon node address cannot be resolved" of RestBeaconNodeStatus.Offline: "Connection with node has been lost" of RestBeaconNodeStatus.Online: @@ -237,6 +266,15 @@ proc checkNode(vc: ValidatorClientRef, let nstatus = node.status debug "Checking beacon node", endpoint = node, status = node.status + if nstatus in {RestBeaconNodeStatus.Noname}: + let + status = node.checkName() + failure = ApiNodeFailure.init(ApiFailure.NoError, "checkName", + node, status.getReason()) + node.updateStatus(status, failure) + if status != RestBeaconNodeStatus.Offline: + return nstatus != status + if nstatus in {RestBeaconNodeStatus.Offline, RestBeaconNodeStatus.UnexpectedCode, RestBeaconNodeStatus.UnexpectedResponse, @@ -408,7 +446,8 @@ proc runTimeMonitor(service: FallbackServiceRef, proc processTimeMonitoring(service: FallbackServiceRef) {.async.} = let vc = service.client - blockNodes = vc.filterNodes(AllBeaconNodeStatuses, AllBeaconNodeRoles) + blockNodes = vc.filterNodes( + ResolvedBeaconNodeStatuses, AllBeaconNodeRoles) var pendingChecks: seq[Future[void]] diff --git a/beacon_chain/validators/beacon_validators.nim b/beacon_chain/validators/beacon_validators.nim index 8a8283f83..9633e1fda 100644 --- a/beacon_chain/validators/beacon_validators.nim +++ b/beacon_chain/validators/beacon_validators.nim @@ -409,16 +409,21 @@ proc getExecutionPayload( get_expected_withdrawals(forkyState.data) else: @[] - payload = await node.elManager.getPayload( - PayloadType, beaconHead.blck.bid.root, executionHead, latestSafe, - latestFinalized, timestamp, random, feeRecipient, withdrawals) - if payload.isNone: + info "Requesting engine payload", + beaconHead = shortLog(beaconHead.blck), + executionHead = shortLog(executionHead), + validatorIndex = validator_index, + feeRecipient = $feeRecipient + + let payload = (await node.elManager.getPayload( + PayloadType, beaconHead.blck.bid.root, executionHead, latestSafe, + latestFinalized, timestamp, random, feeRecipient, withdrawals)).valueOr: error "Failed to obtain execution payload from EL", executionHeadBlock = executionHead return Opt.none(PayloadType) - return Opt.some payload.get + return Opt.some payload except CatchableError as err: beacon_block_payload_errors.inc() error "Error creating non-empty execution payload", @@ -684,7 +689,8 @@ proc getUnsignedBlindedBeaconBlock[ consensusFork == ConsensusFork.Capella)): return err("getUnsignedBlindedBeaconBlock: mismatched block/payload types") else: - return ok constructSignableBlindedBlock[T](blck, executionPayloadHeader) + return ok constructSignableBlindedBlock[T]( + forkyBlck, executionPayloadHeader) else: return err("getUnsignedBlindedBeaconBlock: attempt to construct pre-Bellatrix blinded block") @@ -886,7 +892,7 @@ proc makeBlindedBeaconBlockForHeadAndSlot*[ (consensusFork == ConsensusFork.Capella and EPH is capella.ExecutionPayloadHeader)): return ok (constructPlainBlindedBlock[BBB, EPH]( - blck, executionPayloadHeader), bidValue) + forkyBlck, executionPayloadHeader), bidValue) else: return err("makeBlindedBeaconBlockForHeadAndSlot: mismatched block/payload types") else: @@ -1040,7 +1046,7 @@ proc proposeBlockAux( withBlck(forkedBlck): let - blockRoot = hash_tree_root(blck) + blockRoot = hash_tree_root(forkyBlck) signingRoot = compute_block_signing_root( fork, genesis_validators_root, slot, blockRoot) @@ -1049,7 +1055,7 @@ proc proposeBlockAux( .registerBlock(validator_index, validator.pubkey, slot, signingRoot) let blobSidecarsOpt = - when blck is deneb.BeaconBlock: + when forkyBlck is deneb.BeaconBlock: var sidecars: seq[BlobSidecar] let bundle = collectedBids.engineBlockFut.read.get().blobsBundleOpt.get let (blobs, kzgs, proofs) = (bundle.blobs, bundle.kzgs, bundle.proofs) @@ -1058,23 +1064,25 @@ proc proposeBlockAux( block_root: blockRoot, index: BlobIndex(i), slot: slot, - block_parent_root: blck.parent_root, - proposer_index: blck.proposer_index, + block_parent_root: forkyBlck.parent_root, + proposer_index: forkyBlck.proposer_index, blob: blobs[i], kzg_commitment: kzgs[i], kzg_proof: proofs[i] ) sidecars.add(sidecar) Opt.some(sidecars) - elif blck is phase0.BeaconBlock or blck is altair.BeaconBlock or - blck is bellatrix.BeaconBlock or blck is capella.BeaconBlock: + elif forkyBlck is phase0.BeaconBlock or + forkyBlck is altair.BeaconBlock or + forkyBlck is bellatrix.BeaconBlock or + forkyBlck is capella.BeaconBlock: Opt.none(seq[BlobSidecar]) else: static: doAssert "Unknown BeaconBlock type" if notSlashable.isErr: warn "Slashing protection activated for block proposal", - blockRoot = shortLog(blockRoot), blck = shortLog(blck), + blockRoot = shortLog(blockRoot), blck = shortLog(forkyBlck), signingRoot = shortLog(signingRoot), validator = validator.pubkey, slot = slot, @@ -1092,28 +1100,30 @@ proc proposeBlockAux( return head res.get() signedBlock = - when blck is phase0.BeaconBlock: + when forkyBlck is phase0.BeaconBlock: phase0.SignedBeaconBlock( - message: blck, signature: signature, root: blockRoot) - elif blck is altair.BeaconBlock: + message: forkyBlck, signature: signature, root: blockRoot) + elif forkyBlck is altair.BeaconBlock: altair.SignedBeaconBlock( - message: blck, signature: signature, root: blockRoot) - elif blck is bellatrix.BeaconBlock: + message: forkyBlck, signature: signature, root: blockRoot) + elif forkyBlck is bellatrix.BeaconBlock: bellatrix.SignedBeaconBlock( - message: blck, signature: signature, root: blockRoot) - elif blck is capella.BeaconBlock: + message: forkyBlck, signature: signature, root: blockRoot) + elif forkyBlck is capella.BeaconBlock: capella.SignedBeaconBlock( - message: blck, signature: signature, root: blockRoot) - elif blck is deneb.BeaconBlock: + message: forkyBlck, signature: signature, root: blockRoot) + elif forkyBlck is deneb.BeaconBlock: deneb.SignedBeaconBlock( - message: blck, signature: signature, root: blockRoot) + message: forkyBlck, signature: signature, root: blockRoot) else: static: doAssert "Unknown SignedBeaconBlock type" signedBlobs = - when blck is phase0.BeaconBlock or blck is altair.BeaconBlock or - blck is bellatrix.BeaconBlock or blck is capella.BeaconBlock: + when forkyBlck is phase0.BeaconBlock or + forkyBlck is altair.BeaconBlock or + forkyBlck is bellatrix.BeaconBlock or + forkyBlck is capella.BeaconBlock: Opt.none(SignedBlobSidecars) - elif blck is deneb.BeaconBlock: + elif forkyBlck is deneb.BeaconBlock: var signed: seq[SignedBlobSidecar] let blobSidecars = blobSidecarsOpt.get() for i in 0../dev/null \ + && apt-get -qq -y install build-essential git-lfs &>/dev/null \ && apt-get -qq clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/docker/dist/base_image/Dockerfile.arm b/docker/dist/base_image/Dockerfile.arm index 16721d408..e060e77f1 100644 --- a/docker/dist/base_image/Dockerfile.arm +++ b/docker/dist/base_image/Dockerfile.arm @@ -1,3 +1,10 @@ +# beacon_chain +# Copyright (c) 2021-2023 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. + # This Docker image can change from one build to another, because the upstream # Debian/Ubuntu package index is continuously updated and we have to run # `apt-get update` in here. @@ -12,7 +19,7 @@ SHELL ["/bin/bash", "-c"] ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" RUN apt-get -qq update \ - && apt-get -qq -y install build-essential git \ + && apt-get -qq -y install build-essential git-lfs \ libc6-armhf-armel-cross libc6-dev-armel-armhf-cross binutils-arm-linux-gnueabihf gcc-arm-linux-gnueabihf &>/dev/null \ && apt-get -qq clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/docker/dist/base_image/Dockerfile.arm64 b/docker/dist/base_image/Dockerfile.arm64 index 47981e77b..b92c318d4 100644 --- a/docker/dist/base_image/Dockerfile.arm64 +++ b/docker/dist/base_image/Dockerfile.arm64 @@ -1,3 +1,10 @@ +# beacon_chain +# Copyright (c) 2021-2023 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. + # This Docker image can change from one build to another, because the upstream # Debian/Ubuntu package index is continuously updated and we have to run # `apt-get update` in here. @@ -14,7 +21,7 @@ SHELL ["/bin/bash", "-c"] ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" RUN apt-get -qq update \ - && apt-get -qq -y install build-essential git \ + && apt-get -qq -y install build-essential git-lfs \ binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu &>/dev/null \ && apt-get -qq clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/docker/dist/base_image/Dockerfile.macos b/docker/dist/base_image/Dockerfile.macos index 8b606a547..5a195faa6 100644 --- a/docker/dist/base_image/Dockerfile.macos +++ b/docker/dist/base_image/Dockerfile.macos @@ -1,3 +1,10 @@ +# beacon_chain +# Copyright (c) 2021-2023 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. + # This Docker image can change from one build to another, because the upstream # Debian/Ubuntu package index is continuously updated and we have to run # `apt-get update` in here. @@ -12,7 +19,7 @@ SHELL ["/bin/bash", "-c"] ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" RUN apt-get -qq update \ - && apt-get -qq -y install build-essential git clang-11 llvm-11-dev cmake curl libssl-dev lzma-dev libxml2-dev &>/dev/null \ + && apt-get -qq -y install build-essential git-lfs clang-11 llvm-11-dev cmake curl libssl-dev lzma-dev libxml2-dev &>/dev/null \ && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-11 100 \ && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-11 100 \ && apt-get -qq clean \ diff --git a/docker/dist/base_image/Dockerfile.win64 b/docker/dist/base_image/Dockerfile.win64 index eb0b829d4..1ffdd22df 100644 --- a/docker/dist/base_image/Dockerfile.win64 +++ b/docker/dist/base_image/Dockerfile.win64 @@ -1,3 +1,10 @@ +# beacon_chain +# Copyright (c) 2021-2023 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. + # This Docker image can change from one build to another, because the upstream # Debian/Ubuntu package index is continuously updated and we have to run # `apt-get update` in here. @@ -13,7 +20,7 @@ SHELL ["/bin/bash", "-c"] ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" RUN \ apt-get -qq update \ - && apt-get -qq -y install git gnupg software-properties-common lsb cmake &>/dev/null \ + && apt-get -qq -y install git-lfs gnupg software-properties-common lsb cmake &>/dev/null \ && apt-get -qq -y install \ autoconf \ automake \ diff --git a/docs/attestation_flow.md b/docs/attestation_flow.md index 92b62c3be..e9eb14bff 100644 --- a/docs/attestation_flow.md +++ b/docs/attestation_flow.md @@ -9,7 +9,7 @@ It is important to distinguish attestation `validation` from attestation `verifi - Aggregated: https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.1/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof - Unaggregated: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id - Attestation `verification` is defined in the consensus specs. Verified attestations can affect fork choice and may be included in a block. - - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#attestations + - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#attestations From the specs it seems like gossip attestation `validation` is a superset of consensus attestation `verification`. @@ -52,7 +52,7 @@ These GossipSub topics are used to listen for attestations: The attestations are then validated by `validateAttestation()` or `validateAggregate()` in either `attestationValidator()` or `aggregateValidator()` according to the P2P specs. - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof -- https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md#attestation-subnets +- https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#attestation-subnets Finally, valid attestations are added to the local `attestationPool`. Attestations are dropped in case of an error. diff --git a/docs/block_flow.md b/docs/block_flow.md index 4e29e85a9..58dd3b2b0 100644 --- a/docs/block_flow.md +++ b/docs/block_flow.md @@ -9,7 +9,7 @@ Important distinction: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_block. A validated block can be forwarded on gossipsub. - and we distinguish `verification` which is defined in consensus specs: - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/beacon-chain.md#block-processing + https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#block-processing A block needs to be verified to enter fork choice, the DAG and the BeaconChainDB In particular in terms of costly checks validating a block only requires checking: diff --git a/docs/the_nimbus_book/mkdocs.yml b/docs/the_nimbus_book/mkdocs.yml index 44c40a90d..2b6abe5e8 100644 --- a/docs/the_nimbus_book/mkdocs.yml +++ b/docs/the_nimbus_book/mkdocs.yml @@ -82,6 +82,7 @@ nav: - 'profits.md' - 'health.md' - 'prater.md' + - 'holesky.md' - Security: - 'preparation.md' diff --git a/docs/the_nimbus_book/src/developers.md b/docs/the_nimbus_book/src/developers.md index 858fae4ea..6897d81d4 100644 --- a/docs/the_nimbus_book/src/developers.md +++ b/docs/the_nimbus_book/src/developers.md @@ -217,7 +217,7 @@ USE_MULTITAIL="yes" make local-testnet-minimal You’ll get something like this (click for full size): -[![](https://i.imgur.com/Pc99VDO.png)](https://i.imgur.com/Pc99VDO.png) +[![](./img/developers_01.png)](./img/developers_01.png) You can find out more about the beacon node simulation [here](https://our.status.im/nimbus-development-update-03/#beaconsimulation). diff --git a/docs/the_nimbus_book/src/el-light-client.md b/docs/the_nimbus_book/src/el-light-client.md index fa7c028f2..5ab51b00f 100644 --- a/docs/the_nimbus_book/src/el-light-client.md +++ b/docs/the_nimbus_book/src/el-light-client.md @@ -104,7 +104,7 @@ The following sections explain how to do this for certain EL clients. ## Running the light client The light client starts syncing from a trusted block. -This trusted block should be somewhat recent ([~1-2 weeks](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/weak-subjectivity.md)) and needs to be configured each time when starting the light client. +This trusted block should be somewhat recent ([~1-2 weeks](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/weak-subjectivity.md)) and needs to be configured each time when starting the light client. ### 1. Obtaining a trusted block root @@ -188,7 +188,7 @@ NOT 2022-11-21 18:04:03.982+01:00 New LC optimistic block opt ``` !!! note - The [light client protocol](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md) depends on consensus layer (CL) full nodes to serve additional data. + The [light client protocol](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md) depends on consensus layer (CL) full nodes to serve additional data. As this is a new protocol, not all implementations are supporting it yet. Therefore, it may take several minutes to discover supporting peers, during which no log messages may be produced. diff --git a/docs/the_nimbus_book/src/email-notifications.md b/docs/the_nimbus_book/src/email-notifications.md index 1aba10342..0399fbe6d 100644 --- a/docs/the_nimbus_book/src/email-notifications.md +++ b/docs/the_nimbus_book/src/email-notifications.md @@ -8,17 +8,17 @@ You can create an account on [beaconcha.in](https://beaconcha.in/) to set up ema ### 1. Sign up at [beaconcha.in/register](https://beaconcha.in/register) -### 2. Type your validator's public key into the searchbar +### 2. Type your validator's public key into the search bar -![](https://i.imgur.com/jHjkySK.png) +![](./img/email_01.png) ### 3. Click on the bookmark icon -![](https://i.imgur.com/O7zgE0k.png) +![](./img/email_02.png) ### 4. Tick the boxes and select *Add To Watchlist* -![](https://i.imgur.com/7ff4Ta7.png) +![](./img/email_03.png) diff --git a/docs/the_nimbus_book/src/health.md b/docs/the_nimbus_book/src/health.md index 2b98d6a09..6ee0287cf 100644 --- a/docs/the_nimbus_book/src/health.md +++ b/docs/the_nimbus_book/src/health.md @@ -13,7 +13,7 @@ As long as your validator is within the allowed inclusion distance, you will get You can verify your validator's effectiveness on the [beaconcha.in](https://beaconcha.in/) website. -![](https://i.imgur.com/u80Ub2j.png) +![](./img/health.png) Ideally you want to see a value above 95%. diff --git a/docs/the_nimbus_book/src/holesky.md b/docs/the_nimbus_book/src/holesky.md new file mode 100644 index 000000000..b58252494 --- /dev/null +++ b/docs/the_nimbus_book/src/holesky.md @@ -0,0 +1,122 @@ +# Holešky testnet + +`holesky` is the main long-running Ethereum staking, infrastructure and protocol-developer testnet. +For testing decentralized applications, smart contracts, and other EVM functionality, please use Sepolia testnet! +`holesky` replaces the Prater/Görli network which has been deprecated since early 2023. + + +It provides an opportunity to verify your setup works as expected through the proof-of-stake transition and in a post-merge context as well as to safely practice node operations such as adding and removing validators, migrating between clients, and performing upgrades and backups. +If you come across any issues, please [report them here](https://github.com/status-im/nimbus-eth2/issues). + + + + + + +## General Preparation + +1. Generate the JWT secret with `openssl rand -hex 32 | tr -d "\n" > "/opt/jwtsecret"`. This file needs to be passed to both the execution client and the consensus client. + +2. Choose an Ethereum address to receive transaction fees. + This ETH will be immediately available, not part of the staking contract. + +3. Download the [latest release](./binaries.md) and install it by unpacking the archive. + +4. Choose one of Nethermind, Besu, Erigon, or Geth as an execution client. + Download, install, and [run it](https://notes.ethereum.org/@launchpad/goerli#Run-an-Execution-Layer-Client). + + === "Nethermind" + + ```sh + cd nethermind/src/Nethermind/Nethermind.Runner + dotnet run -c Release -- --config holesky \ + --JsonRpc.Host=0.0.0.0 \ + --JsonRpc.JwtSecretFile=/opt/jwtsecret + ``` + + === "Erigon" + + ```sh + ./build/bin/erigon --chain=holesky \ + --datadir holesky-testnet \ + --authrpc.jwtsecret=/opt/jwtsecret \ + --http --http.api=engine,net,eth + ``` + + === "Besu" + + ```sh + build/install/besu/bin/besu \ + --network=holesky \ + --rpc-http-enabled=true \ + --rpc-http-host="0.0.0.0" \ + --rpc-http-cors-origins="*" \ + --sync-mode="X_SNAP" \ + --data-storage-format="BONSAI"\ + --Xmerge-support=true \ + --rpc-ws-host="0.0.0.0" \ + --host-allowlist="*" \ + --engine-rpc-enabled=true \ + --engine-host-allowlist="*" \ + --engine-jwt-enabled=true \ + --engine-jwt-secret=/opt/jwtsecret + ``` + + + + + + ## Sync the beacon node and execution client + +5. [Start syncing](./start-syncing.md) the node consisting of Nimbus and chosen execution client, for example by running: + ```sh + nimbus-eth2/build/nimbus_beacon_node \ + --network=holesky \ + --web3-url=http://127.0.0.1:8551 \ + --rest \ + --metrics \ + --jwt-secret="/opt/jwtsecret" \ + --suggested-fee-recipient= + ``` + + !!! tip + If you want the syncing process to complete much faster, you can [sync from a trusted node](./trusted-node-sync.md). + + One might consider here to [set up a systemd service](./beacon-node-systemd.md) to ensure this runs automatically, including after restarts. + + + + + + ## Obtaining genesis file (optional) + + By default, Nimbus will automatically download the genesis state of Holešky from Github through the HTTPS protocol. + If something prevents you from using this method, you may be able to work-around the issue by either instructing Nimbus to use a different URL by specifying the `--genesis-state-url` command-line parameter (for example, you can point it to the `/eth/v2/debug/beacon/states/genesis` endpoint of a trusted beacon node or a checkpoint provider) or by downloading the `genesis.ssz` file of the network through some other means and then supplying its path through the `--genesis-state` command-line parameter. + + + + + + ## Begin validating + +6. Once this Holešky node is [completely synced](./keep-an-eye.md#keep-track-of-your-syncing-progress), use the [Holesky launchpad](https://holesky.launchpad.ethereum.org/en/) to obtain Holesky validators. +It might require some time before these enter and are activated on the beacon chain. +If one does this before the node which will attest and propose using those validators has synced, one might miss attestations and block proposals. + +7. Follow our validating guide from [step 2 (import the validator keys) onward](./run-a-validator.md#2-import-your-validator-keys). + + + + + + + +## Useful resources + +- Holesky [landing page](https://holesky.ethpandaops.io): view block explorers, request funds from the faucet, and connect to a JSON RPC endpoint. + +- Holesky [EF launchpad notes](https://notes.ethereum.org/@launchpad/holesky): how to run a node; contains instructions for how to build Nimbus from source for this purpose + +- Holesky consensus layer [beacon chain explorer](https://holesky.beaconcha.in/) + +- Holesky execution layer [transaction explorer](https://holesky.etherscan.io/) diff --git a/docs/the_nimbus_book/src/img/developers_01.png b/docs/the_nimbus_book/src/img/developers_01.png new file mode 100644 index 000000000..0771d1c16 Binary files /dev/null and b/docs/the_nimbus_book/src/img/developers_01.png differ diff --git a/docs/the_nimbus_book/src/img/email_01.png b/docs/the_nimbus_book/src/img/email_01.png new file mode 100644 index 000000000..a2bc8e4fc Binary files /dev/null and b/docs/the_nimbus_book/src/img/email_01.png differ diff --git a/docs/the_nimbus_book/src/img/email_02.png b/docs/the_nimbus_book/src/img/email_02.png new file mode 100644 index 000000000..80d7a67bc Binary files /dev/null and b/docs/the_nimbus_book/src/img/email_02.png differ diff --git a/docs/the_nimbus_book/src/img/email_03.png b/docs/the_nimbus_book/src/img/email_03.png new file mode 100644 index 000000000..b7f91a257 Binary files /dev/null and b/docs/the_nimbus_book/src/img/email_03.png differ diff --git a/docs/the_nimbus_book/src/img/health.png b/docs/the_nimbus_book/src/img/health.png new file mode 100644 index 000000000..46e60293c Binary files /dev/null and b/docs/the_nimbus_book/src/img/health.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_01.png b/docs/the_nimbus_book/src/img/metrics_01.png new file mode 100644 index 000000000..602c9c526 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_01.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_02.png b/docs/the_nimbus_book/src/img/metrics_02.png new file mode 100644 index 000000000..2f11901f0 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_02.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_03.png b/docs/the_nimbus_book/src/img/metrics_03.png new file mode 100644 index 000000000..399214a69 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_03.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_04.png b/docs/the_nimbus_book/src/img/metrics_04.png new file mode 100644 index 000000000..e5187871a Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_04.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_05.png b/docs/the_nimbus_book/src/img/metrics_05.png new file mode 100644 index 000000000..e5514d529 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_05.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_06.png b/docs/the_nimbus_book/src/img/metrics_06.png new file mode 100644 index 000000000..b66e03d43 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_06.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_07.png b/docs/the_nimbus_book/src/img/metrics_07.png new file mode 100644 index 000000000..8a2828384 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_07.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_08.png b/docs/the_nimbus_book/src/img/metrics_08.png new file mode 100644 index 000000000..9e3640032 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_08.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_09.png b/docs/the_nimbus_book/src/img/metrics_09.png new file mode 100644 index 000000000..d738c22da Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_09.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_10.png b/docs/the_nimbus_book/src/img/metrics_10.png new file mode 100644 index 000000000..60b1f59df Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_10.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_11.png b/docs/the_nimbus_book/src/img/metrics_11.png new file mode 100644 index 000000000..fc90a96f6 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_11.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_12.png b/docs/the_nimbus_book/src/img/metrics_12.png new file mode 100644 index 000000000..f3d209fb7 Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_12.png differ diff --git a/docs/the_nimbus_book/src/img/metrics_13.png b/docs/the_nimbus_book/src/img/metrics_13.png new file mode 100644 index 000000000..ab4e7b3ba Binary files /dev/null and b/docs/the_nimbus_book/src/img/metrics_13.png differ diff --git a/docs/the_nimbus_book/src/light-client-data.md b/docs/the_nimbus_book/src/light-client-data.md index 2ca4e9d9d..96b40c1c1 100644 --- a/docs/the_nimbus_book/src/light-client-data.md +++ b/docs/the_nimbus_book/src/light-client-data.md @@ -2,7 +2,7 @@ Nimbus is configured by default to serve data that allows light clients to stay in sync with the Ethereum network. Light client data is imported incrementally and does not affect validator performance. -Information about the light client sync protocol can be found in the [Ethereum consensus specs](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md). +Information about the light client sync protocol can be found in the [Ethereum consensus specs](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md). !!! note Nimbus also implements a [standalone light client](./el-light-client.md) that may be used to sync an execution layer (EL) client. diff --git a/docs/the_nimbus_book/src/metrics-pretty-pictures.md b/docs/the_nimbus_book/src/metrics-pretty-pictures.md index b72673517..609586ad3 100644 --- a/docs/the_nimbus_book/src/metrics-pretty-pictures.md +++ b/docs/the_nimbus_book/src/metrics-pretty-pictures.md @@ -124,7 +124,7 @@ Follow [the instructions for your platform](https://grafana.com/docs/grafana/lat Go to [http://localhost:3000/](http://localhost:3000/), you should see a Grafana login screen that looks like this: -![](https://i.imgur.com/jcP1qWl.png) +![](./img/metrics_01.png) Type in `admin` for both the username and password. You'll be asked to change the password (and we recommend you do so). @@ -134,48 +134,48 @@ You'll be asked to change the password (and we recommend you do so). Hover your mouse over the gear icon in the left menu bar, and click on the `Data Sources` option in the sub-menu that pops up. -![](https://i.imgur.com/0Xsgx61.png) +![](./img/metrics_02.png) Now click on the `Add Data Source` button in the center of the screen -![](https://i.imgur.com/YRVJjdD.png) +![](./img/metrics_03.png) Select `Prometheus` -![](https://i.imgur.com/YpwThOr.png) +![](./img/metrics_04.png) Enter `http://localhost:9090` in the URL field -![](https://i.imgur.com/PtVOnur.png) +![](./img/metrics_05.png) Set the "Scrape interval" field to the same value you used in the Prometheus config ("15s" in our example below). Scroll to the bottom and click on `Save and Test` -![](https://i.imgur.com/GJVdwaK.png) +![](./img/metrics_06.png) If everything is working correctly you should see a green `Data source is working` box pop up -![](https://i.imgur.com/vf5ahNA.png) +![](./img/metrics_07.png) #### 8. Import a dashboard Now, let's import a dashboard; hover your mouse over the `+` icon in the left menu bar and select `import` from the pop-up menu -![](https://i.imgur.com/WnnAcUR.png) +![](./img/metrics_08.png) Click on `Upload JSON file` -![](https://i.imgur.com/l65ICZ2.png) +![](./img/metrics_09.png) Select the `beacon_nodes_Grafana_dashboard.json` from the `nimbus-eth2/grafana/` folder and click on `Import` -![](https://i.imgur.com/SoU5Isz.png) +![](./img/metrics_10.png) You'll be directed to the dashboard where you'll be able to gain insights into the performance of `nimbus-eth2` and your validators -![](https://i.imgur.com/aIfJ1iT.png) +![](./img/metrics_11.png) !!! note The dashboard is very much a work in progress. @@ -190,7 +190,7 @@ And voilà! That's all there is to it :) ### Joe Clapis -![](https://i.imgur.com/05eJeBr.png) +![](./img/metrics_12.png) Joe — who’s done some brilliant work [integrating Nimbus with Rocket Pool](https://our.status.im/rocket-pool-integration/) — has created a [wonderful guide](https://github.com/jclapis/rp-pi-guide/blob/main/Grafana.md) where he takes you through how to set up a Grafana server on your Pi, using his dashboard as an example. @@ -203,7 +203,7 @@ Whether or not you're running a Pi, we recommend you check out [his guide]( http ### Metanull -![](https://i.imgur.com/OlvNGlq.jpg) +![](./img/metrics_13.png) A dashboard aimed primarily at users rather than developers. diff --git a/docs/the_nimbus_book/src/options.md b/docs/the_nimbus_book/src/options.md index 270151248..c1c8ce79e 100644 --- a/docs/the_nimbus_book/src/options.md +++ b/docs/the_nimbus_book/src/options.md @@ -109,9 +109,10 @@ The following options are available: --discv5 Enable Discovery v5 [=true]. --dump Write SSZ dumps of blocks, attestations and states to data dir [=false]. --direct-peer The list of privileged, secure and known peers to connect and maintain the - connection to, this requires a not random netkey-file. In the complete - multiaddress format like: /ip4/
/tcp//p2p/. - Peering agreements are established out of band and must be reciprocal.. + connection to. This requires a not random netkey-file. In the multiaddress + format like: /ip4/
/tcp//p2p/, or enr format + (enr:-xx). Peering agreements are established out of band and must be + reciprocal. --doppelganger-detection If enabled, the beacon node prudently listens for 2 epochs for attestations from a validator with the same index (a doppelganger), before sending an attestation itself. This protects against slashing (due to double-voting) but means you will diff --git a/docs/the_nimbus_book/src/prater.md b/docs/the_nimbus_book/src/prater.md index c8a19513c..9ef41abbe 100644 --- a/docs/the_nimbus_book/src/prater.md +++ b/docs/the_nimbus_book/src/prater.md @@ -1,5 +1,11 @@ # Prater testnet +!!! note + Prater/Goerli is deprecated as of January 2023. + It will be supported long term for another 12 months. + Please consider using [Holesky testnet](./holesky.md) moving forward. + + `prater`, also known as `goerli`, is the current long-running merge testnet. It provides an opportunity to verify your setup works as expected through the proof-of-stake transition and in a post-merge context as well as to safely practice node operations such as adding and removing validators, migrating between clients, and performing upgrades and backups. If you come across any issues, please [report them here](https://github.com/status-im/nimbus-eth2/issues). diff --git a/docs/the_nimbus_book/src/web3signer.md b/docs/the_nimbus_book/src/web3signer.md index 8e97641f8..3617dd5aa 100644 --- a/docs/the_nimbus_book/src/web3signer.md +++ b/docs/the_nimbus_book/src/web3signer.md @@ -135,7 +135,7 @@ If you are already using a threshold signing setup (e.g. based on Vouch and Dirk The verifying Web3Signer is an experimental extension to the [Web3Signer protocol](https://consensys.github.io/web3signer/web3signer-eth2.html#tag/Signing/operation/ETH2_SIGN) which allows the remote signer to verify certain details of the signed blocks before creating a signature (for example, the signer may require the signed block to have a particular fee recipient value). -To enable this use case, the `BLOCK_V2` request type of the `/api/v1/eth2/sign/{identifier}` endpoint is extended with an additional array field named `proofs`. The array consists of objects with the properties `index`, `proof` and `value`, where `index` is an arbitrary [generalized index](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/ssz/merkle-proofs.md#generalized-merkle-tree-index) of any property nested under the block body and `proof` is its corresponding Merkle proof against the block body root included in the request. The `value` property is optional and it is included only when the SSZ hash of the field included in the Merkle proof doesn't match its value. +To enable this use case, the `BLOCK_V2` request type of the `/api/v1/eth2/sign/{identifier}` endpoint is extended with an additional array field named `proofs`. The array consists of objects with the properties `index`, `proof` and `value`, where `index` is an arbitrary [generalized index](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/ssz/merkle-proofs.md#generalized-merkle-tree-index) of any property nested under the block body and `proof` is its corresponding Merkle proof against the block body root included in the request. The `value` property is optional and it is included only when the SSZ hash of the field included in the Merkle proof doesn't match its value. Since the generalized index of a particular field may change in a hard-fork, in the remote keystore format the proven fields are usually specified by their name: @@ -155,4 +155,4 @@ Since the generalized index of a particular field may change in a hard-fork, in ``` Nimbus automatically computes the generalized index depending on the currently active fork. -The remote signer is expected to verify the incoming Merkle proof through the standardized [is_valid_merkle_branch](https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#is_valid_merkle_branch) function by utilizing a similar automatic mapping mechanism for the generalized index. +The remote signer is expected to verify the incoming Merkle proof through the standardized [is_valid_merkle_branch](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/phase0/beacon-chain.md#is_valid_merkle_branch) function by utilizing a similar automatic mapping mechanism for the generalized index. diff --git a/grafana/README.md b/grafana/README.md index 1f97782f3..884abde88 100644 --- a/grafana/README.md +++ b/grafana/README.md @@ -19,10 +19,10 @@ In order to use it locally, you would have to make some changes: Click the small "share" icon on the top-left of the Grafana dashboard: -![share icon](https://i.imgur.com/ds3BJoj.png) +![share icon](./img/grafana_01.png) Go to the "Export" tab and enable "Export for sharing externally": -![export tab](https://i.imgur.com/sxgrThb.png) +![export tab](./img/grafana_02.png) Now you can either "Save to file" or "View JSON" and copy/paste into the destination file, whichever is faster for you. diff --git a/grafana/beacon_nodes_Grafana_dashboard.json b/grafana/beacon_nodes_Grafana_dashboard.json index 428fe54d6..5bdc4f523 100644 --- a/grafana/beacon_nodes_Grafana_dashboard.json +++ b/grafana/beacon_nodes_Grafana_dashboard.json @@ -9,13 +9,13 @@ "pluginName": "Prometheus" } ], - "__elements": [], + "__elements": {}, "__requires": [ { "type": "grafana", "id": "grafana", "name": "Grafana", - "version": "8.4.3" + "version": "9.2.5" }, { "type": "panel", @@ -46,7 +46,10 @@ "list": [ { "builtIn": 1, - "datasource": "-- Grafana --", + "datasource": { + "type": "datasource", + "uid": "grafana" + }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", @@ -65,12 +68,15 @@ "fiscalYearStartMonth": 0, "graphTooltip": 0, "id": null, - "iteration": 1668598332189, "links": [], "liveNow": false, "panels": [ { "collapsed": false, + "datasource": { + "type": "prometheus", + "uid": "P5354BB48EF90EBE5" + }, "gridPos": { "h": 1, "w": 24, @@ -79,10 +85,23 @@ }, "id": 85, "panels": [], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P5354BB48EF90EBE5" + }, + "refId": "A" + } + ], "title": "Main", "type": "row" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "mappings": [], @@ -124,10 +143,14 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { - "expr": "validators{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "validators{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "", "refId": "A" @@ -137,6 +160,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -192,10 +219,14 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { - "expr": "nbc_peers{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "nbc_peers{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "", "refId": "A" @@ -205,6 +236,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -260,10 +295,14 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { - "expr": "time() - process_start_time_seconds{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "time() - process_start_time_seconds{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "", "refId": "A" @@ -273,6 +312,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -330,10 +373,14 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { - "expr": "rate(process_cpu_seconds_total{instance=\"${instance}\"}[$__rate_interval]) * 100", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "rate(process_cpu_seconds_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 100", "refId": "A" } ], @@ -341,6 +388,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -396,10 +447,14 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { - "expr": "process_resident_memory_bytes{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "process_resident_memory_bytes{instance=\"${instance}\",container=\"${container}\"}", "refId": "A" } ], @@ -407,12 +462,18 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -468,7 +529,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -477,15 +539,23 @@ }, "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "version{instance=\"${instance}\"} ", + "expr": "version{instance=\"${instance}\",container=\"${container}\"} ", "interval": "", "legendFormat": "{{version}}", "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "network_name{instance=\"${instance}\"} ", + "expr": "network_name{instance=\"${instance}\",container=\"${container}\"} ", "hide": false, "interval": "", "legendFormat": "{{name}}", @@ -496,6 +566,10 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Slot based on current wall clock time", "fieldConfig": { "defaults": { @@ -554,10 +628,14 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { - "expr": "beacon_slot{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "beacon_slot{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "", "refId": "A" @@ -567,6 +645,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -625,11 +707,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "beacon_head_slot{instance=\"${instance}\"}", + "expr": "beacon_head_slot{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "", "refId": "A" @@ -639,6 +725,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Epoch based on current wall clock time", "fieldConfig": { "defaults": { @@ -697,11 +787,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "beacon_slot{instance=\"${instance}\"}/32", + "expr": "beacon_slot{instance=\"${instance}\",container=\"${container}\"}/32", "interval": "", "legendFormat": "", "refId": "A" @@ -711,6 +805,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -769,11 +867,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "beacon_head_slot{instance=\"${instance}\"}/32", + "expr": "beacon_head_slot{instance=\"${instance}\",container=\"${container}\"}/32", "interval": "", "legendFormat": "", "refId": "A" @@ -783,6 +885,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -841,11 +947,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "beacon_current_justified_epoch{instance=\"${instance}\"}", + "expr": "beacon_current_justified_epoch{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "", "refId": "A" @@ -855,6 +965,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -913,10 +1027,14 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { - "expr": "beacon_finalized_epoch{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "beacon_finalized_epoch{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "", "refId": "A" @@ -926,12 +1044,18 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -1027,7 +1151,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -1037,34 +1162,54 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(process_cpu_seconds_total{instance=\"${instance}\"}[$__rate_interval]) * 100", + "expr": "rate(process_cpu_seconds_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 100", "interval": "", "legendFormat": "CPU usage %", "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "process_open_fds{instance=\"${instance}\"}", + "expr": "process_open_fds{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "open file descriptors", "refId": "C" }, { - "expr": "process_resident_memory_bytes{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "process_resident_memory_bytes{instance=\"${instance}\",container=\"${container}\"}", "legendFormat": "RSS", "refId": "D" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(nim_gc_mem_bytes{instance=\"${instance}\"})", + "expr": "sum(nim_gc_mem_bytes{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "Nim GC mem total", "refId": "F" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(nim_gc_mem_occupied_bytes{instance=\"${instance}\"})", + "expr": "sum(nim_gc_mem_occupied_bytes{instance=\"${instance}\",container=\"${container}\"})", "hide": false, "interval": "", "legendFormat": "Nim GC mem used", @@ -1075,12 +1220,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -1139,7 +1290,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -1149,7 +1301,11 @@ "pluginVersion": "8.0.4", "targets": [ { - "expr": "libp2p_open_streams{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "libp2p_open_streams{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "{{type}} ({{dir}})", "refId": "A" @@ -1159,12 +1315,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "hidden", "barAlignment": 0, @@ -1248,7 +1410,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -1258,7 +1421,11 @@ "pluginVersion": "8.0.4", "targets": [ { - "expr": "nim_gc_heap_instance_occupied_bytes{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "nim_gc_heap_instance_occupied_bytes{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "{{type_name}}", "refId": "A" @@ -1268,12 +1435,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -1356,7 +1529,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -1366,8 +1540,12 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "libp2p_peers_identity{instance=\"${instance}\"}", + "expr": "libp2p_peers_identity{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "{{agent}}", "refId": "A" @@ -1383,12 +1561,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -1471,7 +1655,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -1481,8 +1666,12 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(libp2p_peers_traffic_read_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(libp2p_peers_traffic_read_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "interval": "", "legendFormat": "{{agent}}", "refId": "A" @@ -1498,12 +1687,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -1631,7 +1826,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -1645,7 +1841,7 @@ "type": "prometheus", "uid": "${DS_PROMETHEUS-PROXY}" }, - "expr": "rate(beacon_blocks_received_total{instance=\"${instance}\"}[$__rate_interval]) * 12", + "expr": "rate(beacon_blocks_received_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 12", "interval": "", "legendFormat": "received", "refId": "B" @@ -1656,7 +1852,7 @@ "uid": "${DS_PROMETHEUS-PROXY}" }, "exemplar": true, - "expr": "rate(beacon_blocks_proposed_total{instance=\"${instance}\"}[$__rate_interval]) * 12", + "expr": "rate(beacon_blocks_proposed_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 12", "interval": "", "legendFormat": "proposed", "refId": "A" @@ -1667,7 +1863,7 @@ "uid": "${DS_PROMETHEUS-PROXY}" }, "exemplar": true, - "expr": "rate(beacon_blocks_dropped_total{instance=\"${instance}\", reason='Ignore'}[$__rate_interval]) * 12", + "expr": "rate(beacon_blocks_dropped_total{instance=\"${instance}\",container=\"${container}\", reason='Ignore'}[$__rate_interval]) * 12", "hide": false, "interval": "", "legendFormat": "ignored", @@ -1679,7 +1875,7 @@ "uid": "${DS_PROMETHEUS-PROXY}" }, "exemplar": true, - "expr": "rate(beacon_blocks_dropped_total{instance=\"${instance}\", reason='Reject'}[$__rate_interval]) * 12", + "expr": "rate(beacon_blocks_dropped_total{instance=\"${instance}\",container=\"${container}\", reason='Reject'}[$__rate_interval]) * 12", "hide": false, "interval": "", "legendFormat": "rejected", @@ -1690,12 +1886,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -1778,7 +1980,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -1788,8 +1991,12 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(libp2p_peers_traffic_write_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(libp2p_peers_traffic_write_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "interval": "", "legendFormat": "{{agent}}", "refId": "A" @@ -1805,12 +2012,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -1869,7 +2082,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -1879,21 +2093,33 @@ "pluginVersion": "8.0.4", "targets": [ { - "expr": "rate(beacon_attestations_received_total{instance=\"${instance}\"}[$__rate_interval]) * 12", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "rate(beacon_attestations_received_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 12", "interval": "", "legendFormat": "received", "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(beacon_attestations_sent_total{instance=\"${instance}\"}[$__rate_interval]) * 12", + "expr": "rate(beacon_attestations_sent_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 12", "interval": "", "legendFormat": "sent", "refId": "B" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(beacon_aggregates_received_total{instance=\"${instance}\"}[$__rate_interval]) * 12", + "expr": "rate(beacon_aggregates_received_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 12", "hide": false, "interval": "", "legendFormat": "aggregates", @@ -1904,6 +2130,10 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -1911,6 +2141,8 @@ "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -1993,7 +2225,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2008,7 +2241,7 @@ "uid": "${DS_PROMETHEUS-PROXY}" }, "exemplar": true, - "expr": "rate(nbc_reqresp_messages_received_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(nbc_reqresp_messages_received_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "interval": "", "legendFormat": "{{protocol}}", "refId": "A" @@ -2018,11 +2251,13 @@ "type": "prometheus", "uid": "${DS_PROMETHEUS-PROXY}" }, + "editorMode": "code", "exemplar": true, - "expr": "rate(nbc_reqresp_messages_failed{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(nbc_reqresp_messages_failed_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "hide": false, "interval": "", "legendFormat": "{{protocol}} (F)", + "range": true, "refId": "B" }, { @@ -2030,11 +2265,13 @@ "type": "prometheus", "uid": "${DS_PROMETHEUS-PROXY}" }, + "editorMode": "code", "exemplar": true, - "expr": "rate(nbc_reqresp_messages_throttled{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(nbc_reqresp_messages_throttled_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "hide": false, "interval": "", "legendFormat": "{{protocol}} (T)", + "range": true, "refId": "C" } ], @@ -2043,6 +2280,10 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -2050,6 +2291,8 @@ "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -2108,7 +2351,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2118,17 +2362,29 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_sync_committee_messages_received_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(beacon_sync_committee_messages_received_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])*12", "interval": "", "legendFormat": "messages", + "range": true, "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_sync_committee_contributions_received_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(beacon_sync_committee_contributions_received_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])*12", "interval": "", "legendFormat": "contributions", + "range": true, "refId": "B" } ], @@ -2136,6 +2392,10 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -2143,6 +2403,8 @@ "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -2201,7 +2463,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2216,7 +2479,7 @@ "uid": "${DS_PROMETHEUS-PROXY}" }, "exemplar": true, - "expr": "rate(nbc_reqresp_messages_sent_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(nbc_reqresp_messages_sent_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "interval": "", "legendFormat": "{{protocol}}", "refId": "A" @@ -2227,6 +2490,10 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -2234,6 +2501,8 @@ "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -2292,7 +2561,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2302,81 +2572,141 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_blocks_dropped_total{instance=\"${instance}\",reason=\"Ignore\"}[$__rate_interval])", + "expr": "rate(beacon_blocks_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Ignore\"}[$__rate_interval])*12", "hide": false, "interval": "", "legendFormat": "blocks (I)", + "range": true, "refId": "C" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_attestations_dropped_total{instance=\"${instance}\",reason=\"Ignore\"}[$__rate_interval])", + "expr": "rate(beacon_attestations_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Ignore\"}[$__rate_interval])*12", "interval": "", "legendFormat": "attestations (I)", + "range": true, "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_aggregates_dropped_total{instance=\"${instance}\",reason=\"Ignore\"}[$__rate_interval])", + "expr": "rate(beacon_aggregates_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Ignore\"}[$__rate_interval])*12", "interval": "", "legendFormat": "aggregates (I)", + "range": true, "refId": "B" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_sync_committee_messages_dropped_total{instance=\"${instance}\",reason=\"Ignore\"}[$__rate_interval])", + "expr": "rate(beacon_sync_committee_messages_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Ignore\"}[$__rate_interval])*12", "hide": false, "interval": "", "legendFormat": "sync_msgs (I)", + "range": true, "refId": "D" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_sync_committee_contributions_dropped_total{instance=\"${instance}\",reason=\"Ignore\"}[$__rate_interval])", + "expr": "rate(beacon_sync_committee_contributions_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Ignore\"}[$__rate_interval])*12", "hide": false, "interval": "", "legendFormat": "sync_contribs (I)", + "range": true, "refId": "E" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_blocks_dropped_total{instance=\"${instance}\",reason=\"Reject\"}[$__rate_interval])", + "expr": "rate(beacon_blocks_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Reject\"}[$__rate_interval])*12", "hide": false, "interval": "", "legendFormat": "blocks (R)", + "range": true, "refId": "G" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_aggregates_dropped_total{instance=\"${instance}\",reason=\"Reject\"}[$__rate_interval])", + "expr": "rate(beacon_aggregates_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Reject\"}[$__rate_interval])*12", "hide": false, "interval": "", "legendFormat": "aggregates (R)", + "range": true, "refId": "F" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_attestations_dropped_total{instance=\"${instance}\",reason=\"Reject\"}[$__rate_interval])", + "expr": "rate(beacon_attestations_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Reject\"}[$__rate_interval])*12", "hide": false, "interval": "", "legendFormat": "attestations (R)", + "range": true, "refId": "H" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_sync_committee_messages_dropped_total{instance=\"${instance}\",reason=\"Reject\"}[$__rate_interval])", + "expr": "rate(beacon_sync_committee_messages_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Reject\"}[$__rate_interval])*12", "hide": false, "interval": "", "legendFormat": "sync_msgs (R)", + "range": true, "refId": "I" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", "exemplar": true, - "expr": "rate(beacon_sync_committee_contributions_dropped_total{instance=\"${instance}\",reason=\"Reject\"}[$__rate_interval])", + "expr": "rate(beacon_sync_committee_contributions_dropped_total{instance=\"${instance}\",container=\"${container}\",reason=\"Reject\"}[$__rate_interval])*12", "hide": false, "interval": "", "legendFormat": "sync_contribs (R)", + "range": true, "refId": "J" } ], @@ -2384,12 +2714,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -2461,7 +2797,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2470,23 +2807,35 @@ }, "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "libp2p_gossipsub_healthy_peers_topics{instance=\"${instance}\"}", + "expr": "libp2p_gossipsub_healthy_peers_topics{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "healthy", "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "libp2p_gossipsub_low_peers_topics{instance=\"${instance}\"}", + "expr": "libp2p_gossipsub_low_peers_topics{instance=\"${instance}\",container=\"${container}\"}", "hide": false, "interval": "", "legendFormat": "low", "refId": "C" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "libp2p_gossipsub_no_peers_topics{instance=\"${instance}\"}", + "expr": "libp2p_gossipsub_no_peers_topics{instance=\"${instance}\",container=\"${container}\"}", "hide": false, "interval": "", "legendFormat": "no_peers", @@ -2497,12 +2846,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -2561,7 +2916,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2571,7 +2927,11 @@ "pluginVersion": "8.0.4", "targets": [ { - "expr": "rate(attached_validator_balance_total{instance=\"${instance}\"}[$__rate_interval]) * 384 / 1000000000", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "rate(attached_validator_balance_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 384 / 1000000000", "interval": "", "legendFormat": "GWei", "refId": "A" @@ -2581,12 +2941,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -2673,7 +3039,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2682,23 +3049,35 @@ }, "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "nbc_gossipsub_healthy_fanout{instance=\"${instance}\"}", + "expr": "nbc_gossipsub_healthy_fanout{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "healthy", "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "nbc_gossipsub_good_fanout{instance=\"${instance}\"}", + "expr": "nbc_gossipsub_good_fanout{instance=\"${instance}\",container=\"${container}\"}", "hide": false, "interval": "", "legendFormat": "good", "refId": "C" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "nbc_gossipsub_low_fanout{instance=\"${instance}\"}", + "expr": "nbc_gossipsub_low_fanout{instance=\"${instance}\",container=\"${container}\"}", "hide": false, "interval": "", "legendFormat": "low", @@ -2709,12 +3088,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -2730,7 +3115,8 @@ "lineWidth": 1, "pointSize": 5, "scaleDistribution": { - "type": "linear" + "log": 2, + "type": "symlog" }, "showPoints": "never", "spanNulls": false, @@ -2771,7 +3157,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2781,8 +3168,12 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "eth1_chain_len{instance=\"${instance}\"}", + "expr": "eth1_chain_len{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "eth1_chain_len", "refId": "A" @@ -2792,12 +3183,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "hidden", "barAlignment": 0, @@ -2888,7 +3285,8 @@ "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -2898,7 +3296,11 @@ "pluginVersion": "8.0.4", "targets": [ { - "expr": "sqlite3_memory_used_bytes{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "sqlite3_memory_used_bytes{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "Memory used", "refId": "A" @@ -2908,12 +3310,195 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binBps" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Total" + }, + "properties": [ + { + "id": "custom.stacking", + "value": { + "group": "A", + "mode": "none" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineWidth", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*msgs" + }, + "properties": [ + { + "id": "custom.axisPlacement", + "value": "right" + }, + { + "id": "unit", + "value": "pps" + } + ] + } + ] + }, + "gridPos": { + "h": 5, + "w": 12, + "x": 12, + "y": 52 + }, + "id": 124, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "8.0.4", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "rate(libp2p_gossipsub_saved_bytes_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{kind}}", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", + "expr": "rate(libp2p_gossipsub_duplicate_during_validation_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", + "hide": false, + "legendFormat": "validation_dupliact msgs", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "code", + "expr": "rate(libp2p_gossipsub_idontwant_saved_messages_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", + "hide": false, + "legendFormat": "idontwant msgs", + "range": true, + "refId": "C" + } + ], + "title": "mesh efficiency (${instance})", + "transformations": [ + { + "id": "calculateField", + "options": { + "mode": "reduceRow", + "reduce": { + "include": [ + "idontwant", + "validation_duplicate" + ], + "reducer": "sum" + } + } + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -2998,14 +3583,15 @@ "h": 6, "w": 12, "x": 12, - "y": 52 + "y": 57 }, "id": 73, "options": { "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -3015,31 +3601,47 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(libp2p_total_dial_attempts_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(libp2p_total_dial_attempts_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "interval": "", "legendFormat": "Dial attempts", "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(discovery_message_requests_outgoing_total{instance=\"${instance}\",response!=\"no_response\"}[$__rate_interval])", + "expr": "rate(discovery_message_requests_outgoing_total{instance=\"${instance}\",container=\"${container}\",response!=\"no_response\"}[$__rate_interval])", "hide": false, "interval": "", "legendFormat": "Discovery messages", "refId": "B" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(libp2p_successful_dials_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(libp2p_successful_dials_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "hide": false, "interval": "", "legendFormat": "Dial success", "refId": "C" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(nbc_cycling_kicked_peers_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(nbc_cycling_kicked_peers_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "hide": false, "interval": "", "legendFormat": "Kicked peers", @@ -3050,12 +3652,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -3107,14 +3715,15 @@ "h": 5, "w": 12, "x": 12, - "y": 58 + "y": 63 }, "id": 20, "options": { "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -3124,7 +3733,11 @@ "pluginVersion": "8.0.4", "targets": [ { - "expr": "beacon_active_validators{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "beacon_active_validators{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "current validators", "refId": "A" @@ -3134,12 +3747,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -3205,14 +3824,15 @@ "h": 5, "w": 12, "x": 12, - "y": 63 + "y": 68 }, "id": 24, "options": { "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -3222,14 +3842,22 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(beacon_state_data_cache_hits_total{instance=\"${instance}\"}[$__rate_interval]) / (rate(beacon_state_data_cache_misses_total{instance=\"${instance}\"}[$__rate_interval]) + rate(beacon_state_data_cache_hits_total{instance=\"${instance}\"}[$__rate_interval]))", + "expr": "rate(beacon_state_data_cache_hits_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) / (rate(beacon_state_data_cache_misses_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) + rate(beacon_state_data_cache_hits_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]))", "interval": "", "legendFormat": "cache hit rate", "refId": "A" }, { - "expr": "rate(beacon_state_data_cache_misses_total{instance=\"${instance}\"}[$__rate_interval]) * 12 ", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "rate(beacon_state_data_cache_misses_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) * 12 ", "interval": "", "legendFormat": "misses", "refId": "B" @@ -3239,12 +3867,18 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -3302,6 +3936,30 @@ "value": "locale" } ] + }, + { + "__systemRef": "hideSeriesFrom", + "matcher": { + "id": "byNames", + "options": { + "mode": "exclude", + "names": [ + "batches" + ], + "prefix": "All except:", + "readOnly": true + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": false, + "tooltip": false, + "viz": true + } + } + ] } ] }, @@ -3309,14 +3967,15 @@ "h": 5, "w": 12, "x": 12, - "y": 68 + "y": 73 }, "id": 86, "options": { "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -3326,54 +3985,80 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(batch_verification_batches_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(batch_verification_batches_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "interval": "", "legendFormat": "batches", "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(batch_verification_signatures_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(batch_verification_signatures_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "interval": "", "legendFormat": "signatures", "refId": "B" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(batch_verification_aggregates_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(batch_verification_aggregates_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "hide": false, "interval": "", "legendFormat": "aggregates", "refId": "C" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(batch_verification_signatures_total{instance=\"${instance}\"}[$__rate_interval]) /\nrate(batch_verification_aggregates_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(batch_verification_signatures_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) /\nrate(batch_verification_aggregates_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "hide": false, "interval": "", "legendFormat": "sigs per agg", "refId": "D" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(batch_verification_signatures_total{instance=\"${instance}\"}[$__rate_interval]) /\nrate(batch_verification_batches_total{instance=\"${instance}\"}[$__rate_interval])", + "expr": "rate(batch_verification_signatures_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) /\nrate(batch_verification_batches_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "hide": false, "interval": "", "legendFormat": "sigs per batch", "refId": "E" } ], - "title": "Batch verifications/slot (${instance})", + "title": "Batch verifications/second (${instance})", "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -3425,14 +4110,15 @@ "h": 7, "w": 12, "x": 12, - "y": 73 + "y": 78 }, "id": 51, "options": { "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -3442,19 +4128,31 @@ "pluginVersion": "8.0.4", "targets": [ { - "expr": "libp2p_peers{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "libp2p_peers{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "libp2p peers", "refId": "A" }, { - "expr": "libp2p_pubsub_peers{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "libp2p_pubsub_peers{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "libp2p pubsub peers", "refId": "C" }, { - "expr": "nbc_peers{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "nbc_peers{instance=\"${instance}\",container=\"${container}\"}", "interval": "", "legendFormat": "beacon_node peers", "refId": "B" @@ -3464,6 +4162,10 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "fieldConfig": { "defaults": { "color": { @@ -3501,7 +4203,7 @@ "h": 2, "w": 3, "x": 12, - "y": 80 + "y": 85 }, "id": 13, "links": [], @@ -3521,9 +4223,13 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "expr": "sum(beacon_attestations_sent_total)", "interval": "", "legendFormat": "", @@ -3534,6 +4240,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -3572,7 +4282,7 @@ "h": 2, "w": 3, "x": 15, - "y": 80 + "y": 85 }, "id": 14, "links": [], @@ -3592,10 +4302,14 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { - "expr": "beacon_attestations_received_total{instance=\"${instance}\"}", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "beacon_attestations_received_total{instance=\"${instance}\",container=\"${container}\"}", "refId": "A" } ], @@ -3608,14 +4322,532 @@ "h": 1, "w": 24, "x": 0, - "y": 82 + "y": 87 + }, + "id": 112, + "panels": [], + "title": "Execution Layer Requests", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 5, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 2, + "type": "log" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 88 + }, + "id": 114, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "builder", + "expr": "sum by(request) (increase(engine_api_responses_total{instance=\"$instance\", container=\"$container\", status=\"200\"}[$__rate_interval]))", + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "EL Node Successful Requests by type", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 5, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 2, + "type": "log" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 88 + }, + "id": 119, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "builder", + "expr": "sum by(url) (increase(engine_api_responses_total{instance=\"$instance\", container=\"$container\", status=\"200\"}[$__rate_interval]))", + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "EL Node Successful Requests by Endpoint", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 5, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "newPayload - 0" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "forkchoiceUpdated - 0" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 4, + "w": 12, + "x": 0, + "y": 96 + }, + "id": 115, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "builder", + "expr": "sum by(request, status) (increase(engine_api_responses_total{instance=\"$instance\", container=\"$container\", status!=\"200\"}[$__rate_interval]))", + "legendFormat": "{{request}} - {{status}}", + "range": true, + "refId": "A" + } + ], + "title": "EL Node Failed Requests", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "fieldConfig": { + "defaults": { + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "scaleDistribution": { + "type": "linear" + } + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 96 + }, + "id": 118, + "options": { + "calculate": false, + "cellGap": 0, + "cellValues": { + "unit": "reqps" + }, + "color": { + "exponent": 0.4, + "fill": "dark-orange", + "max": 500, + "mode": "scheme", + "reverse": false, + "scale": "exponential", + "scheme": "Turbo", + "steps": 128 + }, + "exemplars": { + "color": "rgba(255,0,255,0.7)" + }, + "filterValues": { + "le": 0.005 + }, + "legend": { + "show": true + }, + "rowsFrame": { + "layout": "auto" + }, + "tooltip": { + "show": true, + "yHistogram": true + }, + "yAxis": { + "axisPlacement": "left", + "reverse": false, + "unit": "s" + } + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "sum by(le) (increase(engine_api_request_duration_seconds_bucket{instance=\"$instance\", container=\"$container\"}[$__rate_interval]))", + "format": "heatmap", + "instant": false, + "interval": "60", + "legendFormat": "{{le}}", + "range": true, + "refId": "A" + } + ], + "title": "EL Node Request Duration", + "type": "heatmap" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 5, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 12, + "x": 0, + "y": 100 + }, + "id": 117, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "editorMode": "builder", + "expr": "sum by(url, request) (increase(engine_api_timeouts_total{instance=\"$instance\", container=\"$container\"}[$__rate_interval]))", + "legendFormat": "{{request}} - {{status}}", + "range": true, + "refId": "A" + } + ], + "title": "EL Node Timed-out Requests", + "type": "timeseries" + }, + { + "collapsed": false, + "datasource": { + "type": "prometheus", + "uid": "P5354BB48EF90EBE5" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 104 }, "id": 88, "panels": [], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P5354BB48EF90EBE5" + }, + "refId": "A" + } + ], "title": "Validator monitoring", "type": "row" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Number of blocks monitored validators produced in previous epoch", "fieldConfig": { "defaults": { @@ -3643,7 +4875,7 @@ "h": 3, "w": 2, "x": 0, - "y": 83 + "y": 105 }, "id": 96, "options": { @@ -3661,11 +4893,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(validator_monitor_beacon_block_total{instance=\"${instance}\"})", + "expr": "sum(validator_monitor_beacon_block_total{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "", "refId": "A" @@ -3675,482 +4911,10 @@ "type": "stat" }, { - "description": "Number of active validators being monitored that should be attesting", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "green", - "value": 1 - } - ] - } - }, - "overrides": [] + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" }, - "gridPos": { - "h": 3, - "w": 2, - "x": 2, - "y": 83 - }, - "id": 97, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "8.4.3", - "targets": [ - { - "exemplar": true, - "expr": "sum(validator_monitor_active{instance=\"${instance}\"})", - "interval": "", - "legendFormat": "", - "refId": "A" - } - ], - "title": "Active", - "type": "stat" - }, - { - "description": "Validators that have exited from the chain, either volunt", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 4, - "y": 83 - }, - "id": 93, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "8.4.3", - "targets": [ - { - "exemplar": true, - "expr": "sum(validator_monitor_exited{instance=\"${instance}\"})", - "interval": "", - "legendFormat": "", - "refId": "A" - } - ], - "title": "Exited", - "type": "stat" - }, - { - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 6, - "y": 83 - }, - "id": 94, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "8.4.3", - "targets": [ - { - "exemplar": true, - "expr": "sum(validator_monitor_slashed{instance=\"${instance}\"})", - "interval": "", - "legendFormat": "", - "refId": "A" - } - ], - "title": "Slashed", - "type": "stat" - }, - { - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 8, - "y": 83 - }, - "id": 95, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "8.4.3", - "targets": [ - { - "exemplar": true, - "expr": "sum(validator_monitor_slashed{instance=\"${instance}\"})", - "interval": "", - "legendFormat": "", - "refId": "A" - } - ], - "title": "Withdrawable", - "type": "stat" - }, - { - "description": "Number of monitored validators in the current sync committee", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "green", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 10, - "y": 83 - }, - "id": 99, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "8.4.3", - "targets": [ - { - "exemplar": true, - "expr": "sum(validator_monitor_validator_in_current_sync_committee{instance=\"${instance}\"})", - "interval": "", - "legendFormat": "", - "refId": "A" - } - ], - "title": "CurrentSync", - "type": "stat" - }, - { - "description": "Number of monitored validators in the next sync committee", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "green", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 12, - "y": 83 - }, - "id": 105, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "8.4.3", - "targets": [ - { - "exemplar": true, - "expr": "sum(validator_monitor_validator_in_next_sync_committee{instance=\"${instance}\"})", - "interval": "", - "legendFormat": "", - "refId": "A" - } - ], - "title": "NextSync", - "type": "stat" - }, - { - "description": "Number of times attestation was seen in a block", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "green", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 14, - "y": 83 - }, - "id": 107, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "8.4.3", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS-PROXY}" - }, - "exemplar": true, - "expr": "sum(validator_monitor_prev_epoch_sync_signature_block_inclusions{instance=\"${instance}\"})", - "interval": "", - "legendFormat": "", - "refId": "A" - } - ], - "title": "Sync block inclusions", - "type": "stat" - }, - { - "description": "Number of validators being monitored", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "green", - "value": 1 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 0, - "y": 86 - }, - "id": 92, - "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "auto" - }, - "pluginVersion": "8.4.3", - "targets": [ - { - "exemplar": true, - "expr": "sum(validator_monitor_active{instance=\"${instance}\"})", - "interval": "", - "legendFormat": "", - "refId": "A" - } - ], - "title": "Monitored", - "type": "stat" - }, - { "description": "Number of attestations monitored validators produced in previous epoch", "fieldConfig": { "defaults": { @@ -4178,7 +4942,7 @@ "h": 3, "w": 2, "x": 2, - "y": 86 + "y": 105 }, "id": 101, "options": { @@ -4196,11 +4960,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(validator_monitor_prev_epoch_attestations_total{instance=\"${instance}\"})", + "expr": "sum(validator_monitor_prev_epoch_attestations_total{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "", "refId": "A" @@ -4210,6 +4978,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Number of aggregates monitored validators produced in previous epoch", "fieldConfig": { "defaults": { @@ -4237,7 +5009,7 @@ "h": 3, "w": 2, "x": 4, - "y": 86 + "y": 105 }, "id": 100, "options": { @@ -4255,11 +5027,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(validator_monitor_prev_epoch_aggregates_total{instance=\"${instance}\"})", + "expr": "sum(validator_monitor_prev_epoch_aggregates_total{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "", "refId": "A" @@ -4269,6 +5045,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Number of times attestation produced by monitored validator was seen in an aggregate", "fieldConfig": { "defaults": { @@ -4296,7 +5076,7 @@ "h": 3, "w": 2, "x": 6, - "y": 86 + "y": 105 }, "id": 98, "options": { @@ -4314,11 +5094,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(validator_monitor_prev_epoch_attestation_aggregate_inclusions{instance=\"${instance}\"})", + "expr": "sum(validator_monitor_prev_epoch_attestation_aggregate_inclusions{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "", "refId": "A" @@ -4328,6 +5112,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Number of times attestation was seen in a block", "fieldConfig": { "defaults": { @@ -4355,7 +5143,7 @@ "h": 3, "w": 2, "x": 8, - "y": 86 + "y": 105 }, "id": 104, "options": { @@ -4373,11 +5161,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(validator_monitor_prev_epoch_attestation_block_inclusions{instance=\"${instance}\"})", + "expr": "sum(validator_monitor_prev_epoch_attestation_block_inclusions{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "", "refId": "A" @@ -4387,6 +5179,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Number of sync messages monitored validators produced in previous epoch", "fieldConfig": { "defaults": { @@ -4414,7 +5210,7 @@ "h": 3, "w": 2, "x": 10, - "y": 86 + "y": 105 }, "id": 102, "options": { @@ -4432,11 +5228,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(validator_monitor_prev_epoch_sync_committee_messages_total{instance=\"${instance}\"})", + "expr": "sum(validator_monitor_prev_epoch_sync_committee_messages_total{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "", "refId": "A" @@ -4446,6 +5246,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Number of sync comntributions monitored validators produced in previous epoch", "fieldConfig": { "defaults": { @@ -4473,7 +5277,7 @@ "h": 3, "w": 2, "x": 12, - "y": 86 + "y": 105 }, "id": 103, "options": { @@ -4491,11 +5295,15 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(validator_monitor_prev_epoch_sync_contributions_total{instance=\"${instance}\"})", + "expr": "sum(validator_monitor_prev_epoch_sync_contributions_total{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "", "refId": "A" @@ -4505,6 +5313,10 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "Number of times attestation was seen in a block", "fieldConfig": { "defaults": { @@ -4532,7 +5344,7 @@ "h": 3, "w": 2, "x": 14, - "y": 86 + "y": 105 }, "id": 108, "options": { @@ -4550,7 +5362,7 @@ "text": {}, "textMode": "auto" }, - "pluginVersion": "8.4.3", + "pluginVersion": "9.2.5", "targets": [ { "datasource": { @@ -4558,7 +5370,7 @@ "uid": "${DS_PROMETHEUS-PROXY}" }, "exemplar": true, - "expr": "sum(validator_monitor_prev_epoch_sync_contribution_inclusions{instance=\"${instance}\"})", + "expr": "sum(validator_monitor_prev_epoch_sync_contribution_inclusions{instance=\"${instance}\",container=\"${container}\"})", "interval": "", "legendFormat": "", "refId": "A" @@ -4568,6 +5380,546 @@ "type": "stat" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "Number of validators being monitored", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 0, + "y": 108 + }, + "id": 92, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "exemplar": true, + "expr": "sum(validator_monitor_active{instance=\"${instance}\",container=\"${container}\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Monitored", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "Number of active validators being monitored that should be attesting", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 2, + "y": 108 + }, + "id": 97, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "exemplar": true, + "expr": "sum(validator_monitor_active{instance=\"${instance}\",container=\"${container}\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Active", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "Validators that have exited from the chain, either volunt", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 4, + "y": 108 + }, + "id": 93, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "exemplar": true, + "expr": "sum(validator_monitor_exited{instance=\"${instance}\",container=\"${container}\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Exited", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 6, + "y": 108 + }, + "id": 94, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "exemplar": true, + "expr": "sum(validator_monitor_slashed{instance=\"${instance}\",container=\"${container}\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Slashed", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 8, + "y": 108 + }, + "id": 95, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "exemplar": true, + "expr": "sum(validator_monitor_slashed{instance=\"${instance}\",container=\"${container}\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Withdrawable", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "Number of monitored validators in the current sync committee", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 10, + "y": 108 + }, + "id": 99, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "exemplar": true, + "expr": "sum(validator_monitor_validator_in_current_sync_committee{instance=\"${instance}\",container=\"${container}\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "CurrentSync", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "Number of monitored validators in the next sync committee", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 12, + "y": 108 + }, + "id": 105, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "exemplar": true, + "expr": "sum(validator_monitor_validator_in_next_sync_committee{instance=\"${instance}\",container=\"${container}\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "NextSync", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "description": "Number of times attestation was seen in a block", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 14, + "y": 108 + }, + "id": 107, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "9.2.5", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "exemplar": true, + "expr": "sum(validator_monitor_prev_epoch_sync_signature_block_inclusions{instance=\"${instance}\",container=\"${container}\"})", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Sync block inclusions", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -4575,6 +5927,8 @@ "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -4641,14 +5995,15 @@ "h": 8, "w": 12, "x": 0, - "y": 89 + "y": 111 }, "id": 89, "options": { "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -4658,22 +6013,34 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(rate(validator_monitor_prev_epoch_on_chain_head_attester_miss_total{instance=\"${instance}\"}[$__rate_interval]))*384", + "expr": "sum(rate(validator_monitor_prev_epoch_on_chain_head_attester_miss_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]))*384", "interval": "384s", "legendFormat": "head", "refId": "A" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(rate(validator_monitor_prev_epoch_on_chain_target_attester_miss_total{instance=\"${instance}\"}[$__rate_interval]))*384", + "expr": "sum(rate(validator_monitor_prev_epoch_on_chain_target_attester_miss_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]))*384", "interval": "384s", "legendFormat": "target", "refId": "B" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "sum(rate(validator_monitor_prev_epoch_on_chain_source_attester_miss_total{instance=\"${instance}\"}[$__rate_interval]))*384", + "expr": "sum(rate(validator_monitor_prev_epoch_on_chain_source_attester_miss_total{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]))*384", "hide": false, "interval": "384s", "legendFormat": "source", @@ -4684,6 +6051,10 @@ "type": "timeseries" }, { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "fieldConfig": { "defaults": { @@ -4691,6 +6062,8 @@ "mode": "palette-classic" }, "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -4740,14 +6113,15 @@ "h": 8, "w": 12, "x": 12, - "y": 89 + "y": 111 }, "id": 90, "options": { "legend": { "calcs": [], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { "mode": "multi", @@ -4757,8 +6131,12 @@ "pluginVersion": "8.0.4", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "exemplar": true, - "expr": "rate(validator_monitor_balance_gwei{instance=\"${instance}\"}[$__rate_interval]) / on(instance) group_left validator_monitor_validators_total{instance=\"${instance}\"}", + "expr": "rate(validator_monitor_balance_gwei{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval]) / on(instance,container) group_left validator_monitor_validators_total{instance=\"${instance}\",container=\"${container}\"}", "interval": "384", "legendFormat": "{{validator}}", "refId": "A" @@ -4769,11 +6147,15 @@ }, { "collapsed": true, + "datasource": { + "type": "prometheus", + "uid": "P5354BB48EF90EBE5" + }, "gridPos": { "h": 1, "w": 24, "x": 0, - "y": 97 + "y": 119 }, "id": 75, "panels": [ @@ -4788,11 +6170,15 @@ "mode": "opacity" }, "dataFormat": "tsbuckets", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "gridPos": { "h": 6, "w": 12, "x": 0, - "y": 84 + "y": 116 }, "heatmap": {}, "hideZeroBuckets": false, @@ -4805,7 +6191,11 @@ "reverseYBuckets": false, "targets": [ { - "expr": "rate(beacon_attestation_delay_bucket{instance=\"${instance}\"}[$__rate_interval])", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "rate(beacon_attestation_delay_bucket{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "format": "heatmap", "instant": false, "interval": "", @@ -4841,12 +6231,16 @@ "mode": "opacity" }, "dataFormat": "tsbuckets", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "gridPos": { "h": 6, "w": 12, "x": 12, - "y": 84 + "y": 116 }, "heatmap": {}, "hideZeroBuckets": false, @@ -4859,7 +6253,11 @@ "reverseYBuckets": false, "targets": [ { - "expr": "rate(beacon_block_delay_bucket{instance=\"${instance}\"}[$__rate_interval])", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "rate(beacon_block_delay_bucket{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "format": "heatmap", "instant": false, "interval": "", @@ -4895,12 +6293,16 @@ "mode": "opacity" }, "dataFormat": "tsbuckets", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "description": "", "gridPos": { "h": 6, "w": 12, "x": 0, - "y": 90 + "y": 122 }, "heatmap": {}, "hideZeroBuckets": false, @@ -4913,7 +6315,11 @@ "reverseYBuckets": false, "targets": [ { - "expr": "rate(beacon_aggregate_delay_bucket{instance=\"${instance}\"}[$__rate_interval])", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "rate(beacon_aggregate_delay_bucket{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "format": "heatmap", "instant": false, "interval": "", @@ -4949,11 +6355,15 @@ "mode": "opacity" }, "dataFormat": "tsbuckets", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, "gridPos": { "h": 6, "w": 12, "x": 12, - "y": 90 + "y": 122 }, "heatmap": {}, "hideZeroBuckets": false, @@ -4966,7 +6376,11 @@ "reverseYBuckets": false, "targets": [ { - "expr": "rate(beacon_store_block_duration_seconds_bucket{instance=\"${instance}\"}[$__rate_interval])", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "expr": "rate(beacon_store_block_duration_seconds_bucket{instance=\"${instance}\",container=\"${container}\"}[$__rate_interval])", "format": "heatmap", "instant": false, "interval": "", @@ -4992,26 +6406,39 @@ "yBucketBound": "auto" } ], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P5354BB48EF90EBE5" + }, + "refId": "A" + } + ], "title": "Block & Attestation Delays (slow)", "type": "row" } ], - "refresh": false, - "schemaVersion": 35, + "refresh": "15m", + "schemaVersion": 37, "style": "dark", "tags": [], "templating": { "list": [ { "current": {}, - "definition": "label_values(beacon_current_epoch,instance)", + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "definition": "label_values(validators, instance)", "hide": 0, "includeAll": false, "multi": false, "name": "instance", "options": [], "query": { - "query": "label_values(beacon_current_epoch,instance)", + "query": "label_values(validators, instance)", "refId": "StandardVariableQuery" }, "refresh": 1, @@ -5021,8 +6448,29 @@ "tagValuesQuery": "", "tagsQuery": "", "type": "query", - "useTags": false, - "datasource": "${DS_PROMETHEUS-PROXY}" + "useTags": false + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS-PROXY}" + }, + "definition": "label_values(validators{instance=\"${instance}\"}, container)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "container", + "options": [], + "query": { + "query": "label_values(validators{instance=\"${instance}\"}, container)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" } ] }, @@ -5046,7 +6494,7 @@ }, "timezone": "", "title": "NBC local testnet/sim (all nodes)", - "uid": "pgeNfj2Wz2a", - "version": 14, + "uid": "pgeNfj2Wz23", + "version": 15, "weekStart": "" } diff --git a/grafana/img/grafana_01.png b/grafana/img/grafana_01.png new file mode 100644 index 000000000..b81997f4c Binary files /dev/null and b/grafana/img/grafana_01.png differ diff --git a/grafana/img/grafana_02.png b/grafana/img/grafana_02.png new file mode 100644 index 000000000..ee1deed6f Binary files /dev/null and b/grafana/img/grafana_02.png differ diff --git a/ncli/ncli.nim b/ncli/ncli.nim index 9f76ba2cd..c3cc9ab0d 100644 --- a/ncli/ncli.nim +++ b/ncli/ncli.nim @@ -134,7 +134,7 @@ proc doTransition(conf: NcliConf) = info = ForkedEpochInfo() let res = withTimerRet(timers[tTransition]): withBlck(blckX): state_transition( - cfg, stateY[], blck, cache, info, flags, noRollback) + cfg, stateY[], forkyBlck, cache, info, flags, noRollback) if res.isErr(): error "State transition failed", error = res.error() quit 1 diff --git a/ncli/ncli_common.nim b/ncli/ncli_common.nim index eaee6a036..b1a10f8d7 100644 --- a/ncli/ncli_common.nim +++ b/ncli/ncli_common.nim @@ -336,28 +336,28 @@ func collectFromProposerSlashings( forkedState: ForkedHashedBeaconState, forkedBlock: ForkedTrustedSignedBeaconBlock) = withStateAndBlck(forkedState, forkedBlock): - for proposer_slashing in blck.message.body.proposer_slashings: + for proposer_slashing in forkyBlck.message.body.proposer_slashings: doAssert check_proposer_slashing( forkyState.data, proposer_slashing, {}).isOk let slashedIndex = proposer_slashing.signed_header_1.message.proposer_index rewardsAndPenalties.collectFromSlashedValidator( forkyState.data, slashedIndex.ValidatorIndex, - blck.message.proposer_index.ValidatorIndex) + forkyBlck.message.proposer_index.ValidatorIndex) func collectFromAttesterSlashings( rewardsAndPenalties: var seq[RewardsAndPenalties], forkedState: ForkedHashedBeaconState, forkedBlock: ForkedTrustedSignedBeaconBlock) = withStateAndBlck(forkedState, forkedBlock): - for attester_slashing in blck.message.body.attester_slashings: + for attester_slashing in forkyBlck.message.body.attester_slashings: let attester_slashing_validity = check_attester_slashing( forkyState.data, attester_slashing, {}) doAssert attester_slashing_validity.isOk for slashedIndex in attester_slashing_validity.value: rewardsAndPenalties.collectFromSlashedValidator( forkyState.data, slashedIndex, - blck.message.proposer_index.ValidatorIndex) + forkyBlck.message.proposer_index.ValidatorIndex) func collectFromAttestations( rewardsAndPenalties: var seq[RewardsAndPenalties], @@ -370,7 +370,7 @@ func collectFromAttestations( let base_reward_per_increment = get_base_reward_per_increment( get_total_active_balance(forkyState.data, cache)) doAssert base_reward_per_increment > 0 - for attestation in blck.message.body.attestations: + for attestation in forkyBlck.message.body.attestations: doAssert check_attestation( forkyState.data, attestation, {}, cache).isOk let proposerReward = @@ -382,8 +382,8 @@ func collectFromAttestations( get_proposer_reward( forkyState.data, attestation, base_reward_per_increment, cache, epochParticipationFlags.previousEpochParticipation) - rewardsAndPenalties[blck.message.proposer_index].proposer_outcome += - proposerReward.int64 + rewardsAndPenalties[forkyBlck.message.proposer_index] + .proposer_outcome += proposerReward.int64 let inclusionDelay = forkyState.data.slot - attestation.data.slot for index in get_attesting_indices( forkyState.data, attestation.data, attestation.aggregation_bits, @@ -397,7 +397,7 @@ proc collectFromDeposits( pubkeyToIndex: var PubkeyToIndexTable, cfg: RuntimeConfig) = withStateAndBlck(forkedState, forkedBlock): - for deposit in blck.message.body.deposits: + for deposit in forkyBlck.message.body.deposits: let pubkey = deposit.data.pubkey let amount = deposit.data.amount var index = findValidatorIndex(forkyState.data, pubkey) @@ -426,7 +426,7 @@ func collectFromSyncAggregate( indices = get_sync_committee_cache( forkyState.data, cache).current_sync_committee - template aggregate: untyped = blck.message.body.sync_aggregate + template aggregate: untyped = forkyBlck.message.body.sync_aggregate doAssert indices.len == SYNC_COMMITTEE_SIZE doAssert aggregate.sync_committee_bits.len == SYNC_COMMITTEE_SIZE @@ -439,8 +439,8 @@ func collectFromSyncAggregate( if aggregate.sync_committee_bits[i]: rewardsAndPenalties[indices[i]].sync_committee_outcome += participant_reward.int64 - rewardsAndPenalties[blck.message.proposer_index].proposer_outcome += - proposer_reward.int64 + rewardsAndPenalties[forkyBlck.message.proposer_index] + .proposer_outcome += proposer_reward.int64 else: rewardsAndPenalties[indices[i]].sync_committee_outcome -= participant_reward.int64 diff --git a/ncli/ncli_db.nim b/ncli/ncli_db.nim index 97f4d6fe5..b63893e39 100644 --- a/ncli/ncli_db.nim +++ b/ncli/ncli_db.nim @@ -431,13 +431,13 @@ proc cmdPutBlock(conf: DbConf, cfg: RuntimeConfig) = cfg, readAllBytes(file).tryGet()) withBlck(blck.asTrusted()): - db.putBlock(blck) + db.putBlock(forkyBlck) if conf.setHead: - db.putHeadBlock(blck.root) + db.putHeadBlock(forkyBlck.root) if conf.setTail: - db.putTailBlock(blck.root) + db.putTailBlock(forkyBlck.root) if conf.setGenesis: - db.putGenesisBlock(blck.root) + db.putGenesisBlock(forkyBlck.root) proc cmdRewindState(conf: DbConf, cfg: RuntimeConfig) = echo "Opening database..." @@ -628,7 +628,7 @@ proc cmdImportEra(conf: DbConf, cfg: RuntimeConfig) = continue withBlck(blck.asTrusted()): - db.putBlock(blck) + db.putBlock(forkyBlck) blocks += 1 elif header.typ == SnappyBeaconState: info "Skipping beacon state (use reindexing to recreate state snapshots)" @@ -1058,13 +1058,13 @@ proc cmdValidatorDb(conf: DbConf, cfg: RuntimeConfig) = for bi in 0 ..< blockRefs.len: let forkedBlock = dag.getForkedBlock(blockRefs[blockRefs.len - bi - 1]).get() withBlck(forkedBlock): - processSlots(blck.message.slot, {skipLastStateRootCalculation}) + processSlots(forkyBlck.message.slot, {skipLastStateRootCalculation}) rewardsAndPenalties.collectBlockRewardsAndPenalties( tmpState[], forkedBlock, auxiliaryState, cache, cfg) let res = state_transition_block( - cfg, tmpState[], blck, cache, {}, noRollback) + cfg, tmpState[], forkyBlck, cache, {}, noRollback) if res.isErr: fatal "State transition failed (!)" quit QuitFailure diff --git a/ncli/ncli_testnet.nim b/ncli/ncli_testnet.nim index 76371f402..57012ebd7 100644 --- a/ncli/ncli_testnet.nim +++ b/ncli/ncli_testnet.nim @@ -32,6 +32,7 @@ type StartUpCommand {.pure.} = enum generateDeposits createTestnet + createTestnetEnr run sendDeposits analyzeLogs @@ -165,6 +166,36 @@ type desc: "Output file with list of bootstrap nodes for the network" name: "output-bootstrap-file" .}: OutFile + of StartUpCommand.createTestnetEnr: + inputBootstrapEnr* {. + desc: "Path to the bootstrap ENR" + name: "bootstrap-enr" .}: InputFile + + enrDataDir* {. + desc: "Nimbus data directory where the keys of the node will be placed" + name: "data-dir" .}: OutDir + + enrNetKeyFile* {. + desc: "Source of network (secp256k1) private key file" + name: "enr-netkey-file" .}: OutFile + + enrNetKeyInsecurePassword* {. + desc: "Use pre-generated INSECURE password for network private key file" + defaultValue: false, + name: "insecure-netkey-password" .}: bool + + enrAddress* {. + desc: "The public IP address of that ENR" + defaultValue: init(ValidIpAddress, defaultAdminListenAddress) + defaultValueDesc: $defaultAdminListenAddressDesc + name: "enr-address" .}: ValidIpAddress + + enrPort* {. + desc: "The TCP/UDP port of that ENR" + defaultValue: defaultEth2TcpPort + defaultValueDesc: $defaultEth2TcpPortDesc + name: "enr-port" .}: Port + of StartUpCommand.sendDeposits: depositsFile* {. desc: "A LaunchPad deposits file" @@ -320,6 +351,46 @@ proc createDepositTreeSnapshot(deposits: seq[DepositData], depositContractState: merkleizer.toDepositContractState, blockHeight: blockHeight) +proc createEnr(rng: var HmacDrbgContext, + dataDir: string, + netKeyFile: string, + netKeyInsecurePassword: bool, + cfg: RuntimeConfig, + forkId: seq[byte], + address: ValidIpAddress, + port: Port): enr.Record + {.raises: [CatchableError].} = + type MetaData = altair.MetaData + let + networkKeys = rng.getPersistentNetKeys( + dataDir, netKeyFile, netKeyInsecurePassword, allowLoadExisting = false) + + netMetadata = MetaData() + bootstrapEnr = enr.Record.init( + 1, # sequence number + networkKeys.seckey.asEthKey, + some(address), + some(port), + some(port), + [ + toFieldPair(enrForkIdField, forkId), + toFieldPair(enrAttestationSubnetsField, SSZ.encode(netMetadata.attnets)) + ]) + bootstrapEnr.tryGet() + +proc doCreateTestnetEnr*(config: CliConfig, + rng: var HmacDrbgContext) + {.raises: [CatchableError].} = + let + cfg = getRuntimeConfig(config.eth2Network) + bootstrapEnr = parseBootstrapAddress(toSeq(lines(string config.inputBootstrapEnr))[0]).get() + forkIdField = bootstrapEnr.tryGet(enrForkIdField, seq[byte]).get() + enr = + createEnr(rng, string config.enrDataDir, string config.enrNetKeyFile, + config.enrNetKeyInsecurePassword, cfg, forkIdField, + config.enrAddress, config.enrPort) + stderr.writeLine(enr.toURI) + proc doCreateTestnet*(config: CliConfig, rng: var HmacDrbgContext) {.raises: [CatchableError].} = @@ -417,29 +488,16 @@ proc doCreateTestnet*(config: CliConfig, let bootstrapFile = string config.outputBootstrapFile if bootstrapFile.len > 0: - type MetaData = altair.MetaData let - networkKeys = rng.getPersistentNetKeys( - string config.dataDir, string config.netKeyFile, - config.netKeyInsecurePassword, allowLoadExisting = false) - - netMetadata = MetaData() forkId = getENRForkID( cfg, Epoch(0), genesisValidatorsRoot) - bootstrapEnr = enr.Record.init( - 1, # sequence number - networkKeys.seckey.asEthKey, - some(config.bootstrapAddress), - some(config.bootstrapPort), - some(config.bootstrapPort), - [ - toFieldPair(enrForkIdField, SSZ.encode(forkId)), - toFieldPair(enrAttestationSubnetsField, SSZ.encode(netMetadata.attnets)) - ]) - - writeFile(bootstrapFile, bootstrapEnr.tryGet().toURI) + enr = + createEnr(rng, string config.dataDir, string config.netKeyFile, + config.netKeyInsecurePassword, cfg, SSZ.encode(forkId), + config.bootstrapAddress, config.bootstrapPort) + writeFile(bootstrapFile, enr.toURI) echo "Wrote ", bootstrapFile proc deployContract*(web3: Web3, code: string): Future[ReceiptObject] {.async.} = @@ -593,6 +651,10 @@ proc main() {.async.} = let rng = HmacDrbgContext.new() doCreateTestnet(conf, rng[]) + of StartUpCommand.createTestnetEnr: + let rng = HmacDrbgContext.new() + doCreateTestnetEnr(conf, rng[]) + of StartUpCommand.deployDepositContract: let web3 = await initWeb3(conf.web3Url, conf.privateKey) let receipt = await web3.deployContract(depositContractCode) diff --git a/ncli/resttest-rules.json b/ncli/resttest-rules.json index dfd151b35..a0e593c85 100644 --- a/ncli/resttest-rules.json +++ b/ncli/resttest-rules.json @@ -2802,7 +2802,7 @@ "response": { "status": {"operator": "equals", "value": "200"}, "headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}], - "body": [{"operator": "jstructcmps", "start": ["data"], "value": {"MAX_COMMITTEES_PER_SLOT":"","TARGET_COMMITTEE_SIZE":"","MAX_VALIDATORS_PER_COMMITTEE":"","SHUFFLE_ROUND_COUNT":"","HYSTERESIS_QUOTIENT":"","HYSTERESIS_DOWNWARD_MULTIPLIER":"","HYSTERESIS_UPWARD_MULTIPLIER":"","MIN_DEPOSIT_AMOUNT":"","MAX_EFFECTIVE_BALANCE":"","EFFECTIVE_BALANCE_INCREMENT":"","MIN_ATTESTATION_INCLUSION_DELAY":"","SLOTS_PER_EPOCH":"","MIN_SEED_LOOKAHEAD":"","MAX_SEED_LOOKAHEAD":"","EPOCHS_PER_ETH1_VOTING_PERIOD":"","SLOTS_PER_HISTORICAL_ROOT":"","MIN_EPOCHS_TO_INACTIVITY_PENALTY":"","EPOCHS_PER_HISTORICAL_VECTOR":"","EPOCHS_PER_SLASHINGS_VECTOR":"","HISTORICAL_ROOTS_LIMIT":"","VALIDATOR_REGISTRY_LIMIT":"","BASE_REWARD_FACTOR":"","WHISTLEBLOWER_REWARD_QUOTIENT":"","PROPOSER_REWARD_QUOTIENT":"","INACTIVITY_PENALTY_QUOTIENT":"","MIN_SLASHING_PENALTY_QUOTIENT":"","PROPORTIONAL_SLASHING_MULTIPLIER":"","MAX_PROPOSER_SLASHINGS":"","MAX_ATTESTER_SLASHINGS":"","MAX_ATTESTATIONS":"","MAX_DEPOSITS":"","MAX_VOLUNTARY_EXITS":"","INACTIVITY_PENALTY_QUOTIENT_ALTAIR":"","MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR":"","PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR":"","SYNC_COMMITTEE_SIZE":"","EPOCHS_PER_SYNC_COMMITTEE_PERIOD":"","MIN_SYNC_COMMITTEE_PARTICIPANTS":"","UPDATE_TIMEOUT":"","INACTIVITY_PENALTY_QUOTIENT_BELLATRIX":"","MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX":"","PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX":"","MAX_BYTES_PER_TRANSACTION":"","MAX_TRANSACTIONS_PER_PAYLOAD":"","BYTES_PER_LOGS_BLOOM":"","MAX_EXTRA_DATA_BYTES":"","MAX_BLS_TO_EXECUTION_CHANGES":"","MAX_WITHDRAWALS_PER_PAYLOAD":"","MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP":"","PRESET_BASE":"","CONFIG_NAME":"","TERMINAL_TOTAL_DIFFICULTY":"","TERMINAL_BLOCK_HASH":"","TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH":"","MIN_GENESIS_ACTIVE_VALIDATOR_COUNT":"","MIN_GENESIS_TIME":"","GENESIS_FORK_VERSION":"","GENESIS_DELAY":"","ALTAIR_FORK_VERSION":"","ALTAIR_FORK_EPOCH":"","BELLATRIX_FORK_VERSION":"","BELLATRIX_FORK_EPOCH":"","CAPELLA_FORK_VERSION":"","CAPELLA_FORK_EPOCH":"","DENEB_FORK_VERSION":"","DENEB_FORK_EPOCH":"","SECONDS_PER_SLOT":"","SECONDS_PER_ETH1_BLOCK":"","MIN_VALIDATOR_WITHDRAWABILITY_DELAY":"","SHARD_COMMITTEE_PERIOD":"","ETH1_FOLLOW_DISTANCE":"","INACTIVITY_SCORE_BIAS":"","INACTIVITY_SCORE_RECOVERY_RATE":"","EJECTION_BALANCE":"","MIN_PER_EPOCH_CHURN_LIMIT":"","CHURN_LIMIT_QUOTIENT":"","PROPOSER_SCORE_BOOST":"","DEPOSIT_CHAIN_ID":"","DEPOSIT_NETWORK_ID":"","DEPOSIT_CONTRACT_ADDRESS":"","BLS_WITHDRAWAL_PREFIX":"","ETH1_ADDRESS_WITHDRAWAL_PREFIX":"","DOMAIN_BEACON_PROPOSER":"","DOMAIN_BEACON_ATTESTER":"","DOMAIN_RANDAO":"","DOMAIN_DEPOSIT":"","DOMAIN_VOLUNTARY_EXIT":"","DOMAIN_SELECTION_PROOF":"","DOMAIN_AGGREGATE_AND_PROOF":"","TIMELY_SOURCE_FLAG_INDEX":"","TIMELY_TARGET_FLAG_INDEX":"","TIMELY_HEAD_FLAG_INDEX":"","TIMELY_SOURCE_WEIGHT":"","TIMELY_TARGET_WEIGHT":"","TIMELY_HEAD_WEIGHT":"","SYNC_REWARD_WEIGHT":"","PROPOSER_WEIGHT":"","WEIGHT_DENOMINATOR":"","DOMAIN_SYNC_COMMITTEE":"","DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF":"","DOMAIN_CONTRIBUTION_AND_PROOF":"","DOMAIN_BLS_TO_EXECUTION_CHANGE":"","TARGET_AGGREGATORS_PER_COMMITTEE":"","ATTESTATION_SUBNET_COUNT":"","TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE":"","SYNC_COMMITTEE_SUBNET_COUNT":""}}] + "body": [{"operator": "jstructcmps", "start": ["data"], "value": {"MAX_COMMITTEES_PER_SLOT":"","TARGET_COMMITTEE_SIZE":"","MAX_VALIDATORS_PER_COMMITTEE":"","SHUFFLE_ROUND_COUNT":"","HYSTERESIS_QUOTIENT":"","HYSTERESIS_DOWNWARD_MULTIPLIER":"","HYSTERESIS_UPWARD_MULTIPLIER":"","MIN_DEPOSIT_AMOUNT":"","MAX_EFFECTIVE_BALANCE":"","EFFECTIVE_BALANCE_INCREMENT":"","MIN_ATTESTATION_INCLUSION_DELAY":"","SLOTS_PER_EPOCH":"","MIN_SEED_LOOKAHEAD":"","MAX_SEED_LOOKAHEAD":"","EPOCHS_PER_ETH1_VOTING_PERIOD":"","SLOTS_PER_HISTORICAL_ROOT":"","MIN_EPOCHS_TO_INACTIVITY_PENALTY":"","EPOCHS_PER_HISTORICAL_VECTOR":"","EPOCHS_PER_SLASHINGS_VECTOR":"","HISTORICAL_ROOTS_LIMIT":"","VALIDATOR_REGISTRY_LIMIT":"","BASE_REWARD_FACTOR":"","WHISTLEBLOWER_REWARD_QUOTIENT":"","PROPOSER_REWARD_QUOTIENT":"","INACTIVITY_PENALTY_QUOTIENT":"","MIN_SLASHING_PENALTY_QUOTIENT":"","PROPORTIONAL_SLASHING_MULTIPLIER":"","MAX_PROPOSER_SLASHINGS":"","MAX_ATTESTER_SLASHINGS":"","MAX_ATTESTATIONS":"","MAX_DEPOSITS":"","MAX_VOLUNTARY_EXITS":"","INACTIVITY_PENALTY_QUOTIENT_ALTAIR":"","MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR":"","PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR":"","SYNC_COMMITTEE_SIZE":"","EPOCHS_PER_SYNC_COMMITTEE_PERIOD":"","MIN_SYNC_COMMITTEE_PARTICIPANTS":"","UPDATE_TIMEOUT":"","INACTIVITY_PENALTY_QUOTIENT_BELLATRIX":"","MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX":"","PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX":"","MAX_BYTES_PER_TRANSACTION":"","MAX_TRANSACTIONS_PER_PAYLOAD":"","BYTES_PER_LOGS_BLOOM":"","MAX_EXTRA_DATA_BYTES":"","MAX_BLS_TO_EXECUTION_CHANGES":"","MAX_WITHDRAWALS_PER_PAYLOAD":"","MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP":"","PRESET_BASE":"","CONFIG_NAME":"","TERMINAL_TOTAL_DIFFICULTY":"","TERMINAL_BLOCK_HASH":"","TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH":"","MIN_GENESIS_ACTIVE_VALIDATOR_COUNT":"","MIN_GENESIS_TIME":"","GENESIS_FORK_VERSION":"","GENESIS_DELAY":"","ALTAIR_FORK_VERSION":"","ALTAIR_FORK_EPOCH":"","BELLATRIX_FORK_VERSION":"","BELLATRIX_FORK_EPOCH":"","CAPELLA_FORK_VERSION":"","CAPELLA_FORK_EPOCH":"","DENEB_FORK_VERSION":"","DENEB_FORK_EPOCH":"","SECONDS_PER_SLOT":"","SECONDS_PER_ETH1_BLOCK":"","MIN_VALIDATOR_WITHDRAWABILITY_DELAY":"","SHARD_COMMITTEE_PERIOD":"","ETH1_FOLLOW_DISTANCE":"","INACTIVITY_SCORE_BIAS":"","INACTIVITY_SCORE_RECOVERY_RATE":"","EJECTION_BALANCE":"","MIN_PER_EPOCH_CHURN_LIMIT":"","CHURN_LIMIT_QUOTIENT":"","MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT":"","PROPOSER_SCORE_BOOST":"","DEPOSIT_CHAIN_ID":"","DEPOSIT_NETWORK_ID":"","DEPOSIT_CONTRACT_ADDRESS":"","BLS_WITHDRAWAL_PREFIX":"","ETH1_ADDRESS_WITHDRAWAL_PREFIX":"","DOMAIN_BEACON_PROPOSER":"","DOMAIN_BEACON_ATTESTER":"","DOMAIN_RANDAO":"","DOMAIN_DEPOSIT":"","DOMAIN_VOLUNTARY_EXIT":"","DOMAIN_SELECTION_PROOF":"","DOMAIN_AGGREGATE_AND_PROOF":"","TIMELY_SOURCE_FLAG_INDEX":"","TIMELY_TARGET_FLAG_INDEX":"","TIMELY_HEAD_FLAG_INDEX":"","TIMELY_SOURCE_WEIGHT":"","TIMELY_TARGET_WEIGHT":"","TIMELY_HEAD_WEIGHT":"","SYNC_REWARD_WEIGHT":"","PROPOSER_WEIGHT":"","WEIGHT_DENOMINATOR":"","DOMAIN_SYNC_COMMITTEE":"","DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF":"","DOMAIN_CONTRIBUTION_AND_PROOF":"","DOMAIN_BLS_TO_EXECUTION_CHANGE":"","TARGET_AGGREGATORS_PER_COMMITTEE":"","ATTESTATION_SUBNET_COUNT":"","TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE":"","SYNC_COMMITTEE_SUBNET_COUNT":""}}] } }, { diff --git a/research/mev_mock.nim b/research/mev_mock.nim index 9e3d0e99b..295e5b913 100644 --- a/research/mev_mock.nim +++ b/research/mev_mock.nim @@ -48,8 +48,8 @@ proc getParentBlock(restClient: RestClientRef): withBlck(resp): when consensusFork >= ConsensusFork.Capella: return Opt.some ParentHeaderInfo( - block_number: blck.message.body.execution_payload.block_number, - timestamp: blck.message.body.execution_payload.timestamp) + block_number: forkyBlck.message.body.execution_payload.block_number, + timestamp: forkyBlck.message.body.execution_payload.timestamp) else: discard @@ -154,7 +154,7 @@ proc setupEngineAPI*(router: var RestRouter, payloadCache: return RestApiResponse.jsonError(Http400, "No parent head hash provided") let execution_payload = (await getInfo(parent_hash.get)).valueOr: return RestApiResponse.jsonError(Http400, "Error getting parent head information") - payloadCache[hash_tree_root(execution_payload)] = execution_payload + payloadCache[hash_tree_root(execution_payload)] = execution_payload return RestApiResponse.jsonResponse( getExecutionPayloadHeader(execution_payload)) @@ -177,7 +177,7 @@ proc setupEngineAPI*(router: var RestRouter, payloadCache: restBlock, payloadCache[execution_header_root])) else: return RestApiResponse.jsonError(Http400, "Unknown execution payload") - + router.api(MethodGet, "/eth/v1/builder/status") do () -> RestApiResponse: return RestApiResponse.response("", Http200, "text/plain") diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index 6f6770719..aa341158e 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -806,6 +806,13 @@ DEPOSITS_FILE="${DATA_DIR}/deposits.json" CONTAINER_DEPOSITS_FILE="${CONTAINER_DATA_DIR}/deposits.json" CONTAINER_DEPOSIT_TREE_SNAPSHOT_FILE="${CONTAINER_DATA_DIR}/deposit_tree_snapshot.ssz" +CONTAINER_BOOTSTRAP_NETWORK_KEYFILE="bootstrap_network_key.json" +DIRECTPEER_NETWORK_KEYFILE="directpeer_network_key.json" + + +BOOTSTRAP_NODE=1 +DIRECTPEER_NODE=2 + if command -v ulimit; then echo "Raising limits" ulimit -n $((TOTAL_VALIDATORS * 10)) @@ -885,22 +892,38 @@ fi jq -r '.hash' "$EXECUTION_GENESIS_BLOCK_JSON" > "${DATA_DIR}/deposit_contract_block_hash.txt" +for NUM_NODE in $(seq 1 $NUM_NODES); do + NODE_DATA_DIR="${DATA_DIR}/node${NUM_NODE}" + rm -rf "${NODE_DATA_DIR}" + scripts/makedir.sh "${NODE_DATA_DIR}" 2>&1 +done + ./build/ncli_testnet createTestnet \ - --data-dir="$CONTAINER_DATA_DIR" \ + --data-dir="$CONTAINER_DATA_DIR/node$BOOTSTRAP_NODE" \ --deposits-file="$CONTAINER_DEPOSITS_FILE" \ --total-validators=$TOTAL_VALIDATORS \ --output-genesis="$CONTAINER_DATA_DIR/genesis.ssz" \ --output-bootstrap-file="$CONTAINER_DATA_DIR/bootstrap_nodes.txt" \ --output-deposit-tree-snapshot="$CONTAINER_DEPOSIT_TREE_SNAPSHOT_FILE" \ --bootstrap-address=127.0.0.1 \ - --bootstrap-port=$BASE_PORT \ - --netkey-file=network_key.json \ + --bootstrap-port=$(( BASE_PORT + BOOTSTRAP_NODE - 1 )) \ + --netkey-file=$CONTAINER_BOOTSTRAP_NETWORK_KEYFILE \ --insecure-netkey-password=true \ --genesis-time=$GENESIS_TIME \ --capella-fork-epoch=$CAPELLA_FORK_EPOCH \ --deneb-fork-epoch=$DENEB_FORK_EPOCH \ --execution-genesis-block="$EXECUTION_GENESIS_BLOCK_JSON" +DIRECTPEER_ENR=$( + ./build/ncli_testnet createTestnetEnr \ + --data-dir="$CONTAINER_DATA_DIR/node$DIRECTPEER_NODE" \ + --bootstrap-enr="$CONTAINER_DATA_DIR/bootstrap_nodes.txt" \ + --enr-address=127.0.0.1 \ + --enr-port=$(( BASE_PORT + DIRECTPEER_NODE - 1 )) \ + --enr-netkey-file=$DIRECTPEER_NETWORK_KEYFILE \ + --insecure-netkey-password=true 2>&1 > /dev/null +) + ./scripts/make_prometheus_config.sh \ --nodes ${NUM_NODES} \ --base-metrics-port ${BASE_METRICS_PORT} \ @@ -948,7 +971,6 @@ dump_logtrace() { } NODES_WITH_VALIDATORS=${NODES_WITH_VALIDATORS:-$NUM_NODES} -BOOTSTRAP_NODE=1 SYSTEM_VALIDATORS=$(( TOTAL_VALIDATORS - USER_VALIDATORS )) VALIDATORS_PER_NODE=$(( SYSTEM_VALIDATORS / NODES_WITH_VALIDATORS )) if [[ "${USE_VC}" == "1" ]]; then @@ -981,8 +1003,6 @@ VALIDATOR_OFFSET=$(( SYSTEM_VALIDATORS / 2 )) BOOTSTRAP_ENR="${DATA_DIR}/node${BOOTSTRAP_NODE}/beacon_node.enr" CONTAINER_BOOTSTRAP_ENR="${CONTAINER_DATA_DIR}/node${BOOTSTRAP_NODE}/beacon_node.enr" -CONTAINER_NETWORK_KEYFILE="network_key.json" - # TODO The deposit generator tool needs to gain support for generating two sets # of deposits (genesis + submitted ones). Then we can enable the sending of # deposits here. @@ -998,8 +1018,6 @@ for NUM_NODE in $(seq 1 $NUM_NODES); do # The first $NODES_WITH_VALIDATORS nodes split them equally between them, # after skipping the first $USER_VALIDATORS. NODE_DATA_DIR="${DATA_DIR}/node${NUM_NODE}" - rm -rf "${NODE_DATA_DIR}" - scripts/makedir.sh "${NODE_DATA_DIR}" 2>&1 scripts/makedir.sh "${NODE_DATA_DIR}/validators" 2>&1 scripts/makedir.sh "${NODE_DATA_DIR}/secrets" 2>&1 @@ -1081,28 +1099,21 @@ for NUM_NODE in $(seq 1 $NUM_NODES); do # Due to star topology, the bootstrap node must relay all attestations, # even if it itself is not interested. --subscribe-all-subnets could be # removed by switching to a fully-connected topology. - BOOTSTRAP_ARG="--netkey-file=${CONTAINER_NETWORK_KEYFILE} --insecure-netkey-password=true --subscribe-all-subnets" + BOOTSTRAP_ARG="--netkey-file=${CONTAINER_BOOTSTRAP_NETWORK_KEYFILE} --insecure-netkey-password=true --subscribe-all-subnets --direct-peer=$DIRECTPEER_ENR" + elif [[ ${NUM_NODE} == ${DIRECTPEER_NODE} ]]; then + # Start a node using the Direct Peer functionality instead of regular bootstraping + BOOTSTRAP_ARG="--netkey-file=${DIRECTPEER_NETWORK_KEYFILE} --direct-peer=$(cat $CONTAINER_BOOTSTRAP_ENR) --insecure-netkey-password=true" else BOOTSTRAP_ARG="--bootstrap-file=${CONTAINER_BOOTSTRAP_ENR}" + fi + if [[ ${NUM_NODE} != ${BOOTSTRAP_NODE} ]]; then if [[ "${CONST_PRESET}" == "minimal" ]]; then # The fast epoch and slot times in the minimal config might cause the # mesh to break down due to re-subscriptions happening within the prune # backoff time BOOTSTRAP_ARG="${BOOTSTRAP_ARG} --subscribe-all-subnets" fi - - # Wait for the master node to write out its address file - START_TIMESTAMP=$(date +%s) - while [[ ! -f "${BOOTSTRAP_ENR}" ]]; do - sleep 0.1 - NOW_TIMESTAMP=$(date +%s) - if [[ "$(( NOW_TIMESTAMP - START_TIMESTAMP - GENESIS_OFFSET ))" -ge "$BOOTSTRAP_TIMEOUT" ]]; then - echo "Bootstrap node failed to start in ${BOOTSTRAP_TIMEOUT} seconds. Aborting." - dump_logs - exit 1 - fi - done fi WEB3_ARG=() @@ -1190,6 +1201,18 @@ for NUM_NODE in $(seq 1 $NUM_NODES); do echo $PID > "$DATA_DIR/pids/nimbus_validator_client.${NUM_NODE}" fi fi + + # Wait for the master node to write out its address file + START_TIMESTAMP=$(date +%s) + while [[ ! -f "${BOOTSTRAP_ENR}" ]]; do + sleep 0.1 + NOW_TIMESTAMP=$(date +%s) + if [[ "$(( NOW_TIMESTAMP - START_TIMESTAMP - GENESIS_OFFSET ))" -ge "$BOOTSTRAP_TIMEOUT" ]]; then + echo "Bootstrap node failed to start in ${BOOTSTRAP_TIMEOUT} seconds. Aborting." + dump_logs + exit 1 + fi + done done # light clients diff --git a/scripts/package_src/nimbus_beacon_node/image/lib/systemd/system/nimbus_beacon_node.service b/scripts/package_src/nimbus_beacon_node/image/lib/systemd/system/nimbus_beacon_node.service index 1c599044a..9dbc5b554 100644 --- a/scripts/package_src/nimbus_beacon_node/image/lib/systemd/system/nimbus_beacon_node.service +++ b/scripts/package_src/nimbus_beacon_node/image/lib/systemd/system/nimbus_beacon_node.service @@ -48,6 +48,9 @@ Environment=METRICS_PORT=8008 Environment=REST_ENABLED=Yes Environment=METRICS_ENABLED=Yes +# Apart from sockets and databases, a file descriptor is needed for every local validator +LimitNOFILE=16384 + # Default group = nimbus User=nimbus WorkingDirectory=/var/lib/nimbus diff --git a/scripts/package_src/nimbus_validator_client/image/lib/systemd/system/nimbus_validator_client.service b/scripts/package_src/nimbus_validator_client/image/lib/systemd/system/nimbus_validator_client.service index 1ece67b01..a336e56d0 100644 --- a/scripts/package_src/nimbus_validator_client/image/lib/systemd/system/nimbus_validator_client.service +++ b/scripts/package_src/nimbus_validator_client/image/lib/systemd/system/nimbus_validator_client.service @@ -39,6 +39,9 @@ Environment=METRICS_PORT=8108 # Interaction and monitoring Environment=METRICS_ENABLED=Yes +# Apart from sockets and databases, a file descriptor is needed for every local validator +LimitNOFILE=16384 + # Default group = nimbus User=nimbus WorkingDirectory=/var/lib/nimbus diff --git a/tests/consensus_spec/altair/test_fixture_light_client_sync_protocol.nim b/tests/consensus_spec/altair/test_fixture_light_client_sync_protocol.nim index 52e7c6d9e..c18b7b766 100644 --- a/tests/consensus_spec/altair/test_fixture_light_client_sync_protocol.nim +++ b/tests/consensus_spec/altair/test_fixture_light_client_sync_protocol.nim @@ -22,7 +22,7 @@ import # Test utilities ../../testutil, ../../testblockutil -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py#L27-L44 +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py#L27-L44 proc compute_aggregate_sync_committee_signature( cfg: RuntimeConfig, forked: ForkedHashedBeaconState, @@ -53,7 +53,7 @@ proc compute_aggregate_sync_committee_signature( aggregateSig.aggregate(signature) aggregateSig.finish.toValidatorSig -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/tests/core/pyspec/eth2spec/test/helpers/light_client.py#L11-L41 +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/tests/core/pyspec/eth2spec/test/helpers/light_client.py#L11-L41 proc get_sync_aggregate( cfg: RuntimeConfig, forked: ForkedHashedBeaconState, @@ -137,7 +137,7 @@ let full_sync_committee_bits = block: res.bytes.fill(byte.high) res -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/sync-protocol.md#initialize_light_client_store +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/altair/light-client/sync-protocol.md#initialize_light_client_store func initialize_light_client_store( state: auto, storeDataFork: static LightClientDataFork): auto = storeDataFork.LightClientStore( diff --git a/tests/consensus_spec/test_fixture_fork_choice.nim b/tests/consensus_spec/test_fixture_fork_choice.nim index 5035c747c..e21969470 100644 --- a/tests/consensus_spec/test_fixture_fork_choice.nim +++ b/tests/consensus_spec/test_fixture_fork_choice.nim @@ -9,7 +9,7 @@ import # Status libraries - stew/results, chronicles, + stew/[byteutils, results], chronicles, taskpools, # Internals ../../beacon_chain/spec/[helpers, forks, state_transition_block], @@ -28,7 +28,7 @@ import from std/json import JsonNode, getBool, getInt, getStr, hasKey, items, len, pairs, `$`, `[]` -from std/sequtils import toSeq +from std/sequtils import mapIt, toSeq from std/strutils import contains # Test format described at https://github.com/ethereum/consensus-specs/tree/v1.3.0/tests/formats/fork_choice @@ -45,6 +45,10 @@ type opInvalidateRoot opChecks + BlobData = object + blobs: seq[KzgBlob] + proofs: seq[KzgProof] + Operation = object valid: bool # variant specific fields @@ -55,6 +59,7 @@ type att: Attestation of opOnBlock: blck: ForkedSignedBeaconBlock + blobData: Opt[BlobData] of opOnMergeBlock: powBlock: PowBlock of opOnAttesterSlashing: @@ -69,7 +74,7 @@ from ../../beacon_chain/spec/datatypes/capella import BeaconBlock, BeaconState, SignedBeaconBlock from ../../beacon_chain/spec/datatypes/deneb import - BeaconBlock, BeaconState, SignedBeaconBlock + KzgBlob, KzgProof, BeaconBlock, BeaconState, SignedBeaconBlock proc initialLoad( path: string, db: BeaconChainDB, @@ -123,7 +128,8 @@ proc initialLoad( dag = ChainDAGRef.init( forkedState[].kind.genesisTestRuntimeConfig, db, validatorMonitor, {}) fkChoice = newClone(ForkChoice.init( - dag.getFinalizedEpochRef(), dag.finalizedHead.blck)) + dag.getFinalizedEpochRef(), dag.finalizedHead.blck, + ForkChoiceVersion.Stable)) (dag, fkChoice) @@ -133,6 +139,8 @@ proc loadOps(path: string, fork: ConsensusFork): seq[Operation] = result = @[] for step in steps[0]: + var numExtraFields = 0 + if step.hasKey"tick": result.add Operation(kind: opOnTick, tick: step["tick"].getInt()) @@ -146,12 +154,14 @@ proc loadOps(path: string, fork: ConsensusFork): seq[Operation] = att: att) elif step.hasKey"block": let filename = step["block"].getStr() + doAssert step.hasKey"blobs" == step.hasKey"proofs" case fork of ConsensusFork.Phase0: let blck = parseTest( path/filename & ".ssz_snappy", SSZ, phase0.SignedBeaconBlock ) + doAssert not step.hasKey"blobs" result.add Operation(kind: opOnBlock, blck: ForkedSignedBeaconBlock.init(blck)) of ConsensusFork.Altair: @@ -159,6 +169,7 @@ proc loadOps(path: string, fork: ConsensusFork): seq[Operation] = path/filename & ".ssz_snappy", SSZ, altair.SignedBeaconBlock ) + doAssert not step.hasKey"blobs" result.add Operation(kind: opOnBlock, blck: ForkedSignedBeaconBlock.init(blck)) of ConsensusFork.Bellatrix: @@ -166,6 +177,7 @@ proc loadOps(path: string, fork: ConsensusFork): seq[Operation] = path/filename & ".ssz_snappy", SSZ, bellatrix.SignedBeaconBlock ) + doAssert not step.hasKey"blobs" result.add Operation(kind: opOnBlock, blck: ForkedSignedBeaconBlock.init(blck)) of ConsensusFork.Capella: @@ -173,15 +185,27 @@ proc loadOps(path: string, fork: ConsensusFork): seq[Operation] = path/filename & ".ssz_snappy", SSZ, capella.SignedBeaconBlock ) + doAssert not step.hasKey"blobs" result.add Operation(kind: opOnBlock, blck: ForkedSignedBeaconBlock.init(blck)) of ConsensusFork.Deneb: - let blck = parseTest( - path/filename & ".ssz_snappy", - SSZ, deneb.SignedBeaconBlock - ) + let + blck = parseTest( + path/filename & ".ssz_snappy", + SSZ, deneb.SignedBeaconBlock) + blobData = + if step.hasKey"blobs": + numExtraFields += 2 + Opt.some BlobData( + blobs: distinctBase(parseTest( + path/(step["blobs"].getStr()) & ".ssz_snappy", + SSZ, List[KzgBlob, Limit MAX_BLOBS_PER_BLOCK])), + proofs: step["proofs"].mapIt(KzgProof.fromHex(it.getStr()))) + else: + Opt.none(BlobData) result.add Operation(kind: opOnBlock, - blck: ForkedSignedBeaconBlock.init(blck)) + blck: ForkedSignedBeaconBlock.init(blck), + blobData: blobData) elif step.hasKey"attester_slashing": let filename = step["attester_slashing"].getStr() let attesterSlashing = parseTest( @@ -204,10 +228,10 @@ proc loadOps(path: string, fork: ConsensusFork): seq[Operation] = doAssert false, "Unknown test step: " & $step if step.hasKey"valid": - doAssert step.len == 2 + doAssert step.len == 2 + numExtraFields result[^1].valid = step["valid"].getBool() elif not step.hasKey"checks" and not step.hasKey"payload_status": - doAssert step.len == 1 + doAssert step.len == 1 + numExtraFields result[^1].valid = true proc stepOnBlock( @@ -217,10 +241,21 @@ proc stepOnBlock( state: var ForkedHashedBeaconState, stateCache: var StateCache, signedBlock: ForkySignedBeaconBlock, + blobData: Opt[BlobData], time: BeaconTime, invalidatedRoots: Table[Eth2Digest, Eth2Digest]): Result[BlockRef, VerifierError] = - # 1. Move state to proper slot. + # 1. Validate blobs + when typeof(signedBlock).toFork() >= ConsensusFork.Deneb: + let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq + if kzgCommits.len > 0 or blobData.isSome: + if blobData.isNone or kzgCommits.validate_blobs( + blobData.get.blobs, blobData.get.proofs).isErr: + return err(VerifierError.Invalid) + else: + doAssert blobData.isNone, "Pre-Deneb test with specified blob data" + + # 2. Move state to proper slot doAssert dag.updateState( state, dag.getBlockIdAtSlot(time.slotOrZero).expect("block exists"), @@ -228,7 +263,7 @@ proc stepOnBlock( stateCache ) - # 2. Add block to DAG + # 3. Add block to DAG when signedBlock is phase0.SignedBeaconBlock: type TrustedBlock = phase0.TrustedSignedBeaconBlock elif signedBlock is altair.SignedBeaconBlock: @@ -271,12 +306,12 @@ proc stepOnBlock( blckRef: BlockRef, signedBlock: TrustedBlock, epochRef: EpochRef, unrealized: FinalityCheckpoints): - # 3. Update fork choice if valid + # 4. Update fork choice if valid let status = fkChoice[].process_block( dag, epochRef, blckRef, unrealized, signedBlock.message, time) doAssert status.isOk() - # 4. Update DAG with new head + # 5. Update DAG with new head var quarantine = Quarantine.init() let newHead = fkChoice[].get_head(dag, time).get() dag.updateHead(dag.getBlockRef(newHead).get(), quarantine, []) @@ -376,7 +411,7 @@ proc doRunTest(path: string, fork: ConsensusFork) = let status = stepOnBlock( stores.dag, stores.fkChoice, verifier, state[], stateCache, - blck, time, invalidatedRoots) + forkyBlck, step.blobData, time, invalidatedRoots) doAssert status.isOk == step.valid of opOnAttesterSlashing: let indices = @@ -435,5 +470,8 @@ template fcSuite(suiteName: static[string], testPathElem: static[string]) = for kind, path in walkDir(basePath, relative = true, checkDir = true): runTest(suiteName, basePath/path, fork) +from ../../beacon_chain/conf import loadKzgTrustedSetup +discard loadKzgTrustedSetup() # Required for Deneb tests + fcSuite("ForkChoice", "fork_choice") fcSuite("Sync", "sync") diff --git a/tests/slashing_protection/test_slashing_protection_db.nim b/tests/slashing_protection/test_slashing_protection_db.nim index 242f5d487..7e5454001 100644 --- a/tests/slashing_protection/test_slashing_protection_db.nim +++ b/tests/slashing_protection/test_slashing_protection_db.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) # * MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) @@ -12,7 +12,7 @@ import std/[os], # Status lib eth/db/[kvstore, kvstore_sqlite3], - stew/results, + stew/[results, endians2], # Internal ../../beacon_chain/validators/slashing_protection, ../../beacon_chain/spec/[helpers], diff --git a/tests/test_attestation_pool.nim b/tests/test_attestation_pool.nim index 6a5ad558d..cc7f0f78d 100644 --- a/tests/test_attestation_pool.nim +++ b/tests/test_attestation_pool.nim @@ -12,7 +12,7 @@ import # Status lib unittest2, chronicles, chronos, - stew/byteutils, + stew/[byteutils, endians2], taskpools, # Internal ../beacon_chain/gossip_processing/[gossip_validation], diff --git a/tests/test_blockchain_dag.nim b/tests/test_blockchain_dag.nim index d8d9751c6..1072672e0 100644 --- a/tests/test_blockchain_dag.nim +++ b/tests/test_blockchain_dag.nim @@ -1212,9 +1212,7 @@ suite "Ancestry": let blck = dag.headState.addTestBlock(cache, nextSlot = false, cfg = cfg) - added = block: - const nilCallback = OnPhase0BlockAdded(nil) - dag.addHeadBlock(verifier, blck.phase0Data, nilCallback) + added = dag.addHeadBlock(verifier, blck.phase0Data, nilPhase0Callback) check added.isOk() dag.updateHead(added[], quarantine[], []) (blck: dag.head, state: newClone(dag.headState.phase0Data)) @@ -1499,27 +1497,13 @@ template runShufflingTests(cfg: RuntimeConfig, numRandomTests: int) = graffiti: GraffitiBytes proc addBlocks(blocks: uint64, attested: bool, cache: var StateCache) = inc distinctBase(graffiti)[0] # Avoid duplicate blocks across branches - for blck in makeTestBlocks( + for forkedBlck in makeTestBlocks( dag.headState, cache, blocks.int, eth1_data = eth1Data, attested = attested, allDeposits = deposits, graffiti = graffiti, cfg = cfg): - let added = - case blck.kind - of ConsensusFork.Phase0: - const nilCallback = OnPhase0BlockAdded(nil) - dag.addHeadBlock(verifier, blck.phase0Data, nilCallback) - of ConsensusFork.Altair: - const nilCallback = OnAltairBlockAdded(nil) - dag.addHeadBlock(verifier, blck.altairData, nilCallback) - of ConsensusFork.Bellatrix: - const nilCallback = OnBellatrixBlockAdded(nil) - dag.addHeadBlock(verifier, blck.bellatrixData, nilCallback) - of ConsensusFork.Capella: - const nilCallback = OnCapellaBlockAdded(nil) - dag.addHeadBlock(verifier, blck.capellaData, nilCallback) - of ConsensusFork.Deneb: - const nilCallback = OnDenebBlockAdded(nil) - dag.addHeadBlock(verifier, blck.denebData, nilCallback) + let added = withBlck(forkedBlck): + const nilCallback = (consensusFork.OnBlockAddedCallback)(nil) + dag.addHeadBlock(verifier, forkyBlck, nilCallback) check added.isOk() dag.updateHead(added[], quarantine[], []) diff --git a/tests/test_gossip_validation.nim b/tests/test_gossip_validation.nim index 584c52551..ad1dc3fac 100644 --- a/tests/test_gossip_validation.nim +++ b/tests/test_gossip_validation.nim @@ -179,78 +179,244 @@ suite "Gossip validation " & preset(): fut_1_0.waitFor().error()[0] == ValidationResult.Reject fut_1_1.waitFor().isOk() -suite "Gossip validation - Extra": # Not based on preset config - test "validateSyncCommitteeMessage": - const num_validators = SLOTS_PER_EPOCH +suite "Gossip validation - Altair": + let cfg = block: + var res = defaultRuntimeConfig + res.ALTAIR_FORK_EPOCH = (EPOCHS_PER_SYNC_COMMITTEE_PERIOD - 2).Epoch + res + + proc addBlock( + dag: ChainDAGRef, + cache: var StateCache, + verifier: var BatchVerifier, + quarantine: var Quarantine) = + for blck in makeTestBlocks( + dag.headState, cache, blocks = 1, + attested = false, cfg = cfg): + let added = withBlck(blck): + const nilCallback = (consensusFork.OnBlockAddedCallback)(nil) + dag.addHeadBlock(verifier, forkyBlck, nilCallback) + check: added.isOk() + dag.updateHead(added[], quarantine, []) + + proc getFirstAggregator(dag: ChainDAGRef, signatureSlot: Slot): tuple[ + subcommitteeIdx: SyncSubcommitteeIndex, + indexInSubcommittee: int + ] = + const indicesPerSubcommittee = + SYNC_COMMITTEE_SIZE div SYNC_COMMITTEE_SUBNET_COUNT + for i, index in dag.syncCommitteeParticipants(signatureSlot): + if (signatureSlot + 1).is_sync_committee_period: + var isAlsoInNextCommittee = false + for other in dag.syncCommitteeParticipants(signatureSlot + 1): + if other == index: + isAlsoInNextCommittee = true + break + if isAlsoInNextCommittee: + continue + let + subcommitteeIndex = SyncSubcommitteeIndex(i div indicesPerSubcommittee) + pubkey = getStateField(dag.headState, validators).item(index).pubkey + keystoreData = KeystoreData( + kind: KeystoreKind.Local, + pubkey: pubkey, + privateKey: MockPrivKeys[index]) + validator = AttachedValidator( + kind: ValidatorKind.Local, data: keystoreData, index: Opt.some index) + proofFut = validator.getSyncCommitteeSelectionProof( + getStateField(dag.headState, fork), + getStateField(dag.headState, genesis_validators_root), + getStateField(dag.headState, slot), + subcommitteeIndex) + check proofFut.completed # Local signatures complete synchronously + let proof = proofFut.value + check proof.isOk + if is_sync_committee_aggregator(proof.get): + return ( + subcommitteeIdx: subcommitteeIndex, + indexInSubcommittee: i mod indicesPerSubcommittee) + raiseAssert "No sync aggregator found who's not also part of next committee" + + proc getSyncCommitteeMessage( + dag: ChainDAGRef, + msgSlot: Slot, + subcommitteeIdx: SyncSubcommitteeIndex, + indexInSubcommittee: int, + signatureSlot = Opt.none(Slot) + ): tuple[ + validator: AttachedValidator, + numPresent: int, + msg: SyncCommitteeMessage + ] = let - cfg = block: - var cfg = defaultRuntimeConfig - cfg.ALTAIR_FORK_EPOCH = (GENESIS_EPOCH + 1).Epoch - cfg - taskpool = Taskpool.new() - quarantine = newClone(Quarantine.init()) - rng = HmacDrbgContext.new() - var - verifier = BatchVerifier.init(rng, taskpool) - dag = block: - let - validatorMonitor = newClone(ValidatorMonitor.init()) - dag = ChainDAGRef.init( - cfg, makeTestDB(num_validators), validatorMonitor, {}) - var cache = StateCache() - for blck in makeTestBlocks( - dag.headState, cache, int(SLOTS_PER_EPOCH), - attested = false, cfg = cfg): - let added = - case blck.kind - of ConsensusFork.Phase0: - const nilCallback = OnPhase0BlockAdded(nil) - dag.addHeadBlock(verifier, blck.phase0Data, nilCallback) - of ConsensusFork.Altair: - const nilCallback = OnAltairBlockAdded(nil) - dag.addHeadBlock(verifier, blck.altairData, nilCallback) - of ConsensusFork.Bellatrix: - const nilCallback = OnBellatrixBlockAdded(nil) - dag.addHeadBlock(verifier, blck.bellatrixData, nilCallback) - of ConsensusFork.Capella: - const nilCallback = OnCapellaBlockAdded(nil) - dag.addHeadBlock(verifier, blck.capellaData, nilCallback) - of ConsensusFork.Deneb: - const nilCallback = OnDenebBlockAdded(nil) - dag.addHeadBlock(verifier, blck.denebData, nilCallback) - check: added.isOk() - dag.updateHead(added[], quarantine[], []) - dag - - let batchCrypto = BatchCrypto.new( - rng, eager = proc(): bool = false, - genesis_validators_root = dag.genesis_validators_root, taskpool).expect( - "working batcher") - - var - state = assignClone(dag.headState.altairData) - slot = state[].data.slot - - subcommitteeIdx = 0.SyncSubcommitteeIndex - syncCommittee = @(dag.syncCommitteeParticipants(slot)) + signatureSlot = signatureSlot.get(msgSlot + 1) + syncCommittee = @(dag.syncCommitteeParticipants(signatureSlot)) subcommittee = toSeq(syncCommittee.syncSubcommittee(subcommitteeIdx)) - index = subcommittee[0] - expectedCount = subcommittee.count(index) - pubkey = state[].data.validators.item(index).pubkey - keystoreData = KeystoreData(kind: KeystoreKind.Local, - pubkey: pubkey, - privateKey: MockPrivKeys[index]) + index = subcommittee[indexInSubcommittee] + numPresent = subcommittee.count(index) + pubkey = getStateField(dag.headState, validators).item(index).pubkey + keystoreData = KeystoreData( + kind: KeystoreKind.Local, + pubkey: pubkey, + privateKey: MockPrivKeys[index]) validator = AttachedValidator( kind: ValidatorKind.Local, data: keystoreData, index: Opt.some index) - resMsg = waitFor getSyncCommitteeMessage( - validator, state[].data.fork, state[].data.genesis_validators_root, - slot, state[].latest_block_root) - msg = resMsg.get() + msgFut = validator.getSyncCommitteeMessage( + getStateField(dag.headState, fork), + getStateField(dag.headState, genesis_validators_root), + msgSlot, dag.headState.latest_block_root) + check msgFut.completed # Local signatures complete synchronously + let msg = msgFut.value + check msg.isOk + (validator: validator, numPresent: numPresent, msg: msg.get) + setup: + let + validatorMonitor = newClone(ValidatorMonitor.init()) + quarantine = newClone(Quarantine.init()) + rng = HmacDrbgContext.new() syncCommitteePool = newClone(SyncCommitteeMsgPool.init(rng, cfg)) + var + taskpool = Taskpool.new() + verifier = BatchVerifier.init(rng, taskpool) + + template prepare(numValidators: Natural): untyped {.dirty.} = + let + dag = ChainDAGRef.init( + cfg, makeTestDB(numValidators, cfg = cfg), validatorMonitor, {}) + batchCrypto = BatchCrypto.new( + rng, eager = proc(): bool = false, + genesis_validators_root = dag.genesis_validators_root, taskpool).expect( + "working batcher") + var + cache: StateCache + info: ForkedEpochInfo + doAssert process_slots( + cfg, dag.headState, + (cfg.ALTAIR_FORK_EPOCH - 1).start_slot(), + cache, info, flags = {}).isOk + for i in 0 ..< SLOTS_PER_EPOCH: + dag.addBlock(cache, verifier, quarantine[]) + + teardown: + taskpool.shutdown() + + test "Period boundary": + prepare(numValidators = SYNC_COMMITTEE_SIZE * 2) + + # Advance to the last slot before period 2. + # The first two periods share the same sync committee, + # so are not suitable for the test + for i in 0 ..< SLOTS_PER_EPOCH: + dag.addBlock(cache, verifier, quarantine[]) + doAssert process_slots( + cfg, dag.headState, + (2.SyncCommitteePeriod.start_epoch() - 1).start_slot(), + cache, info, flags = {}).isOk + for i in 0 ..< SLOTS_PER_EPOCH - 1: + dag.addBlock(cache, verifier, quarantine[]) + let slot = getStateField(dag.headState, slot) + + # The following slots determine what the sync committee signs: + # 1. `state.latest_block_header.slot` --> ConsensusFork of signed block + # 2. `state.slot` --> ForkDigest of signature + # 3. `state.slot + 1` --> Sync committee + proc checkWithSignatureSlot( + signatureSlot: Slot, expectValid: bool) = + warn "checkWithSignatureSlot", signatureSlot, expectValid + + let + (subcommitteeIdx, indexInSubcommittee) = + dag.getFirstAggregator(signatureSlot) + (validator, expectedCount, msg) = dag.getSyncCommitteeMessage( + slot, subcommitteeIdx, indexInSubcommittee, + signatureSlot = Opt.some(signatureSlot)) + msgVerdict = waitFor dag.validateSyncCommitteeMessage( + quarantine, batchCrypto, syncCommitteePool, + msg, subcommitteeIdx, slot.start_beacon_time(), + checkSignature = true) + check msgVerdict.isOk == expectValid + + let (bid, cookedSig, positions) = + if msgVerdict.isOk: + msgVerdict.get + else: + let + blockRoot = msg.beacon_block_root + blck = dag.getBlockRef(blockRoot).expect("Block present") + sig = msg.signature.load().expect("Signature OK") + positionsInSubcommittee = dag.getSubcommitteePositions( + signatureSlot, subcommitteeIdx, msg.validator_index) + (blck.bid, sig, positionsInSubcommittee) + + syncCommitteePool[] = SyncCommitteeMsgPool.init(rng, cfg) + syncCommitteePool[].addSyncCommitteeMessage( + msg.slot, + bid, + msg.validator_index, + cookedSig, + subcommitteeIdx, + positions) + let contrib = block: + let contrib = (ref SignedContributionAndProof)( + message: ContributionAndProof( + aggregator_index: distinctBase(validator.index.get), + selection_proof: validator.getSyncCommitteeSelectionProof( + getStateField(dag.headState, fork), + getStateField(dag.headState, genesis_validators_root), + getStateField(dag.headState, slot), + subcommitteeIdx).value.get)) + check syncCommitteePool[].produceContribution( + slot, bid, subcommitteeIdx, + contrib.message.contribution) + syncCommitteePool[].addContribution( + contrib[], bid, contrib.message.contribution.signature.load.get) + let signRes = waitFor validator.getContributionAndProofSignature( + getStateField(dag.headState, fork), + getStateField(dag.headState, genesis_validators_root), + contrib[].message) + doAssert(signRes.isOk()) + contrib[].signature = signRes.get() + contrib + syncCommitteePool[] = SyncCommitteeMsgPool.init(rng, cfg) + let contribVerdict = waitFor dag.validateContribution( + quarantine, batchCrypto, syncCommitteePool, + contrib[], slot.start_beacon_time(), + checkSignature = true) + check contribVerdict.isOk == expectValid + + # We are at the last slot of a sync committee period: + check slot == (slot.sync_committee_period + 1).start_slot() - 1 + + # Therefore, messages from `current_sync_committee` are no longer allowed + checkWithSignatureSlot( + signatureSlot = slot, + expectValid = false) + + # Messages signed from `next_sync_committee` are accepted + checkWithSignatureSlot( + signatureSlot = slot + 1, + expectValid = true) + + test "validateSyncCommitteeMessage - Duplicate pubkey": + prepare(numValidators = SLOTS_PER_EPOCH) + + for i in 0 ..< SLOTS_PER_EPOCH: + dag.addBlock(cache, verifier, quarantine[]) + + const + subcommitteeIdx = 0.SyncSubcommitteeIndex + indexInSubcommittee = 0 + let + state = assignClone(dag.headState.altairData) + slot = state[].data.slot + (validator, expectedCount, msg) = dag.getSyncCommitteeMessage( + slot, subcommitteeIdx, indexInSubcommittee) + res = waitFor validateSyncCommitteeMessage( dag, quarantine, batchCrypto, syncCommitteePool, - msg, subcommitteeIdx, slot.start_beacon_time(), true) + msg, subcommitteeIdx, slot.start_beacon_time(), + checkSignature = true) (bid, cookedSig, positions) = res.get() syncCommitteePool[].addSyncCommitteeMessage( diff --git a/tests/test_keymanager_api.nim b/tests/test_keymanager_api.nim index 67799e771..6b9a31f83 100644 --- a/tests/test_keymanager_api.nim +++ b/tests/test_keymanager_api.nim @@ -295,7 +295,8 @@ proc startBeaconNode(basePort: int) {.raises: [CatchableError].} = "--keymanager-port=" & $(basePort + PortKind.KeymanagerBN.ord), "--keymanager-token-file=" & tokenFilePath, "--suggested-fee-recipient=" & $defaultFeeRecipient, - "--doppelganger-detection=off"], it)) + "--doppelganger-detection=off", + "--debug-forkchoice-version=stable"], it)) except Exception as exc: # TODO fix confutils exceptions raiseAssert exc.msg diff --git a/tests/test_light_client.nim b/tests/test_light_client.nim index 4a723d64f..d72bca0a0 100644 --- a/tests/test_light_client.nim +++ b/tests/test_light_client.nim @@ -63,24 +63,9 @@ suite "Light client" & preset(): for blck in makeTestBlocks( dag.headState, cache, blocks.int, attested = attested, syncCommitteeRatio = syncCommitteeRatio, cfg = cfg): - let added = - case blck.kind - of ConsensusFork.Phase0: - const nilCallback = OnPhase0BlockAdded(nil) - dag.addHeadBlock(verifier, blck.phase0Data, nilCallback) - of ConsensusFork.Altair: - const nilCallback = OnAltairBlockAdded(nil) - dag.addHeadBlock(verifier, blck.altairData, nilCallback) - of ConsensusFork.Bellatrix: - const nilCallback = OnBellatrixBlockAdded(nil) - dag.addHeadBlock(verifier, blck.bellatrixData, nilCallback) - of ConsensusFork.Capella: - const nilCallback = OnCapellaBlockAdded(nil) - dag.addHeadBlock(verifier, blck.capellaData, nilCallback) - of ConsensusFork.Deneb: - const nilCallback = OnDenebBlockAdded(nil) - dag.addHeadBlock(verifier, blck.denebData, nilCallback) - + let added = withBlck(blck): + const nilCallback = (consensusFork.OnBlockAddedCallback)(nil) + dag.addHeadBlock(verifier, forkyBlck, nilCallback) check: added.isOk() dag.updateHead(added[], quarantine, []) diff --git a/tests/test_light_client_processor.nim b/tests/test_light_client_processor.nim index d6526df3d..2c2cb44aa 100644 --- a/tests/test_light_client_processor.nim +++ b/tests/test_light_client_processor.nim @@ -51,23 +51,9 @@ suite "Light client processor" & preset(): for blck in makeTestBlocks( dag.headState, cache, blocks.int, attested = true, syncCommitteeRatio = syncCommitteeRatio, cfg = cfg): - let added = - case blck.kind - of ConsensusFork.Phase0: - const nilCallback = OnPhase0BlockAdded(nil) - dag.addHeadBlock(verifier, blck.phase0Data, nilCallback) - of ConsensusFork.Altair: - const nilCallback = OnAltairBlockAdded(nil) - dag.addHeadBlock(verifier, blck.altairData, nilCallback) - of ConsensusFork.Bellatrix: - const nilCallback = OnBellatrixBlockAdded(nil) - dag.addHeadBlock(verifier, blck.bellatrixData, nilCallback) - of ConsensusFork.Capella: - const nilCallback = OnCapellaBlockAdded(nil) - dag.addHeadBlock(verifier, blck.capellaData, nilCallback) - of ConsensusFork.Deneb: - const nilCallback = OnDenebBlockAdded(nil) - dag.addHeadBlock(verifier, blck.denebData, nilCallback) + let added = withBlck(blck): + const nilCallback = (consensusFork.OnBlockAddedCallback)(nil) + dag.addHeadBlock(verifier, forkyBlck, nilCallback) doAssert added.isOk() dag.updateHead(added[], quarantine[], []) diff --git a/tests/test_signing_node.nim b/tests/test_signing_node.nim index 9a2597332..c828db672 100644 --- a/tests/test_signing_node.nim +++ b/tests/test_signing_node.nim @@ -804,7 +804,7 @@ block: asyncTest "Signing BeaconBlock (getBlockSignature(bellatrix))": let forked = getBlock(ConsensusFork.Bellatrix) - blockRoot = withBlck(forked): hash_tree_root(blck) + blockRoot = withBlck(forked): hash_tree_root(forkyBlck) sres1 = await validator1.getBlockSignature(SigningFork, GenesisValidatorsRoot, @@ -839,7 +839,7 @@ block: asyncTest "Signing BeaconBlock (getBlockSignature(capella))": let forked = getBlock(ConsensusFork.Capella) - blockRoot = withBlck(forked): hash_tree_root(blck) + blockRoot = withBlck(forked): hash_tree_root(forkyBlck) sres1 = await validator1.getBlockSignature(SigningFork, GenesisValidatorsRoot, @@ -874,7 +874,7 @@ block: asyncTest "Signing BeaconBlock (getBlockSignature(deneb))": let forked = getBlock(ConsensusFork.Deneb) - blockRoot = withBlck(forked): hash_tree_root(blck) + blockRoot = withBlck(forked): hash_tree_root(forkyBlck) sres1 = await validator1.getBlockSignature(SigningFork, GenesisValidatorsRoot, @@ -1042,9 +1042,9 @@ block: let fork = ConsensusFork.Bellatrix forked1 = getBlock(fork) - blockRoot1 = withBlck(forked1): hash_tree_root(blck) + blockRoot1 = withBlck(forked1): hash_tree_root(forkyBlck) forked2 = getBlock(fork, SigningOtherFeeRecipient) - blockRoot2 = withBlck(forked2): hash_tree_root(blck) + blockRoot2 = withBlck(forked2): hash_tree_root(forkyBlck) request1 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot, Web3SignerForkedBeaconBlock.init(forked1)) request2 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot, @@ -1131,9 +1131,9 @@ block: let fork = ConsensusFork.Capella forked1 = getBlock(fork) - blockRoot1 = withBlck(forked1): hash_tree_root(blck) + blockRoot1 = withBlck(forked1): hash_tree_root(forkyBlck) forked2 = getBlock(fork, SigningOtherFeeRecipient) - blockRoot2 = withBlck(forked2): hash_tree_root(blck) + blockRoot2 = withBlck(forked2): hash_tree_root(forkyBlck) request1 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot, Web3SignerForkedBeaconBlock.init(forked1)) request2 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot, @@ -1220,9 +1220,9 @@ block: let fork = ConsensusFork.Deneb forked1 = getBlock(fork) - blockRoot1 = withBlck(forked1): hash_tree_root(blck) + blockRoot1 = withBlck(forked1): hash_tree_root(forkyBlck) forked2 = getBlock(fork, SigningOtherFeeRecipient) - blockRoot2 = withBlck(forked2): hash_tree_root(blck) + blockRoot2 = withBlck(forked2): hash_tree_root(forkyBlck) request1 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot, Web3SignerForkedBeaconBlock.init(forked1)) request2 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot, diff --git a/tests/test_sync_manager.nim b/tests/test_sync_manager.nim index 2285488bc..8001bd88a 100644 --- a/tests/test_sync_manager.nim +++ b/tests/test_sync_manager.nim @@ -724,7 +724,7 @@ suite "SyncManager test suite": let sblock = await aq.popFirst() if sblock.blck.slot == Slot(counter): withBlck(sblock.blck): - if blck.message.proposer_index == 0xDEADBEAF'u64: + if forkyBlck.message.proposer_index == 0xDEADBEAF'u64: sblock.fail(VerifierError.MissingParent) else: inc(counter) @@ -782,7 +782,7 @@ suite "SyncManager test suite": var missingSlice = chain.getSlice(startSlot, r13) withBlck(missingSlice[0][]): - blck.message.proposer_index = 0xDEADBEAF'u64 + forkyBlck.message.proposer_index = 0xDEADBEAF'u64 var f13 = queue.push(r13, missingSlice, Opt.none(seq[BlobSidecars])) await allFutures(f13, f14) @@ -897,7 +897,7 @@ suite "SyncManager test suite": let sblock = await aq.popFirst() if sblock.blck.slot == Slot(counter): withBlck(sblock.blck): - if blck.message.proposer_index == 0xDEADBEAF'u64: + if forkyBlck.message.proposer_index == 0xDEADBEAF'u64: sblock.fail(VerifierError.MissingParent) else: lastSafeSlot = sblock.blck.slot @@ -954,7 +954,7 @@ suite "SyncManager test suite": var missingSlice = chain.getSlice(startSlot, r13) withBlck(missingSlice[0][]): - blck.message.proposer_index = 0xDEADBEAF'u64 + forkyBlck.message.proposer_index = 0xDEADBEAF'u64 var f13 = queue.push(r13, missingSlice, Opt.none(seq[BlobSidecars])) await allFutures(f13, f14) check: diff --git a/tests/testblockutil.nim b/tests/testblockutil.nim index d4ec54745..649764874 100644 --- a/tests/testblockutil.nim +++ b/tests/testblockutil.nim @@ -25,7 +25,7 @@ const MockPrivKeys* = MockPrivKeysT() MockPubKeys* = MockPubKeysT() -# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/tests/core/pyspec/eth2spec/test/helpers/keys.py +# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/tests/core/pyspec/eth2spec/test/helpers/keys.py func `[]`*(sk: MockPrivKeysT, index: ValidatorIndex|uint64): ValidatorPrivKey = var bytes = (index.uint64 + 1'u64).toBytesLE() # Consistent with EF tests static: doAssert sizeof(bytes) <= sizeof(result) @@ -74,7 +74,7 @@ func signBlock( fork: Fork, genesis_validators_root: Eth2Digest, forked: ForkedBeaconBlock, privKey: ValidatorPrivKey, flags: UpdateFlags = {}): ForkedSignedBeaconBlock = let - slot = withBlck(forked): blck.slot + slot = withBlck(forked): forkyBlck.slot root = hash_tree_root(forked) signature = if skipBlsValidation notin flags: diff --git a/vendor/nim-chronos b/vendor/nim-chronos index 176d462b0..2e8551b0d 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit 176d462b076db24d9f71ddb40163d1ef82823771 +Subproject commit 2e8551b0d973cfbebfab3be7f3329e11b9049007 diff --git a/vendor/nim-eth2-scenarios b/vendor/nim-eth2-scenarios index d7d8f64a8..0fcc13e75 160000 --- a/vendor/nim-eth2-scenarios +++ b/vendor/nim-eth2-scenarios @@ -1 +1 @@ -Subproject commit d7d8f64a8df2fc14df09d9ff5946f604787e40cc +Subproject commit 0fcc13e755d7646d0274b9fa6c3ddfb2b434bc3b diff --git a/vendor/nim-kzg4844 b/vendor/nim-kzg4844 index f8b78edcc..6c406c70a 160000 --- a/vendor/nim-kzg4844 +++ b/vendor/nim-kzg4844 @@ -1 +1 @@ -Subproject commit f8b78edcc8296f412c2593e6d60f47c77aa421c5 +Subproject commit 6c406c70ad8cde6ab56320158dd969beb45322ef diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p index 1b8a7d271..b2eac7ecb 160000 --- a/vendor/nim-libp2p +++ b/vendor/nim-libp2p @@ -1 +1 @@ -Subproject commit 1b8a7d271359418d6fe72bbe2976b66ab370df9b +Subproject commit b2eac7ecbdb695b0b7033f2069b03a63d28aee2b diff --git a/vendor/nim-presto b/vendor/nim-presto index 8bb4a54f4..2ae448ff5 160000 --- a/vendor/nim-presto +++ b/vendor/nim-presto @@ -1 +1 @@ -Subproject commit 8bb4a54f4751dc560efc24003be4b3b2b28316e7 +Subproject commit 2ae448ff5b0808c8f562c6f0a70bbd7a05407a37 diff --git a/vendor/nim-ssz-serialization b/vendor/nim-ssz-serialization index 5b7d6d065..f43bfb453 160000 --- a/vendor/nim-ssz-serialization +++ b/vendor/nim-ssz-serialization @@ -1 +1 @@ -Subproject commit 5b7d6d0654b0a34004580c484e2a87eaac50725e +Subproject commit f43bfb453a8c315cf2d51aeff410d43101335feb diff --git a/vendor/nim-stint b/vendor/nim-stint index 94fc521ee..54e24cae4 160000 --- a/vendor/nim-stint +++ b/vendor/nim-stint @@ -1 +1 @@ -Subproject commit 94fc521ee0f1e113d09ceeaa3568d4d7a6c0b67d +Subproject commit 54e24cae415b1bed39a987ecd08c19a34f740972 diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system index fe9bc3f37..81ce5fc75 160000 --- a/vendor/nimbus-build-system +++ b/vendor/nimbus-build-system @@ -1 +1 @@ -Subproject commit fe9bc3f3759ae1add6bf8c899db2e75327f03782 +Subproject commit 81ce5fc7521e400ceababde59b4a90fe7da8919d diff --git a/wasm/README.md b/wasm/README.md index eac8ff00e..1dba498d7 100644 --- a/wasm/README.md +++ b/wasm/README.md @@ -1,11 +1,11 @@ -# Run nimbus state sim in a browser +# Run nimbus ncli in a browser Simple runners for in-browser running of WASM versions of applications - based on emscripten-generated code. ``` # Make sure you have built nimbus-eth2 with make first! -./build.sh +./build_ncli.sh # Run a http server here (wasm + file:/// apparently don't mix) python -m SimpleHTTPServer diff --git a/wasm/build.sh b/wasm/build.sh deleted file mode 100755 index 2aa8612cf..000000000 --- a/wasm/build.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -# Simple build script to produce an Emscripten-based wasm version of the state -# sim. -# Assumes you have emcc latest-upstream in you PATH, per their install -# instructions (https://emscripten.org/docs/getting_started/downloads.html) -# -# git clone https://github.com/emscripten-core/emsdk.git -# cd emsdk -# git pull -# ./emsdk install latest-upstream -# ./emsdk activate latest-upstream -# source ./emsdk_env.sh - -# Clean build every time - we use wildcards below so this keeps it simple -rm -rf state_sim/nimcache - -# GC + emcc optimizer leads to crashes - for now, we disable the GC here -../env.sh nim c \ - --cpu:i386 --os:linux --gc:none --threads:off \ - -d:release -d:clang -d:emscripten -d:noSignalHandler -d:usemalloc \ - --nimcache:state_sim/nimcache \ - -c ../research/state_sim.nim - -../env.sh emcc \ - -I ../vendor/nimbus-build-system/vendor/Nim/lib \ - state_sim/nimcache/*.c \ - ../vendor/nim-blscurve/blscurve/csources/32/{big_384_29.c,ecp2_BLS381.c,rom_curve_BLS381.c,ecp_BLS381.c,fp2_BLS381.c,fp_BLS381.c,rom_field_BLS381.c,pair_BLS381.c,fp12_BLS381.c,fp4_BLS381.c} \ - -s ERROR_ON_UNDEFINED_SYMBOLS=0 \ - -s TOTAL_MEMORY=1073741824 \ - -s EXTRA_EXPORTED_RUNTIME_METHODS=FS \ - -s WASM=1 \ - --shell-file state_sim_shell.html \ - -O3 \ - -o state_sim/state_sim.html diff --git a/wasm/index.html b/wasm/index.html deleted file mode 100644 index 5c2063c4c..000000000 --- a/wasm/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - Nimbus tooling - - - -
-
-

Ethereum Beacon Chain state transition simulation (unoptimized work in progress, you might run out of memory)

-
- - - - - - - - - - - - - -
Create / Validate BLS signaturesValidatorsSlotsAttestation ratio
true false
- -
-
- -
- - \ No newline at end of file diff --git a/wasm/index_state_sim.html b/wasm/index_state_sim.html deleted file mode 100644 index d40402735..000000000 --- a/wasm/index_state_sim.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - Nimbus State Sim - - - -
-
-

Ethereum Beacon Chain state transition simulation (unoptimized work in progress, you might run out of memory)

-
- - - - - - - - - - - - - -
Create / Validate BLS signaturesValidatorsSlotsAttestation ratio
true false
- -
-
- -
- - \ No newline at end of file diff --git a/wasm/state_sim_shell.html b/wasm/state_sim_shell.html deleted file mode 100644 index 8e3800efe..000000000 --- a/wasm/state_sim_shell.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - Nimbus state transition function - - - - -
-
Running...
-
-
- - - {{{ SCRIPT }}} - - - \ No newline at end of file