From 46666d33d6d8d82ab4686a910ef97ef3b7591577 Mon Sep 17 00:00:00 2001 From: tersec Date: Sun, 2 Mar 2025 20:19:13 +0000 Subject: [PATCH] address most remaining debugComments (including single_attestation event support) --- AllTests-mainnet.md | 2 - beacon_chain/beacon_node.nim | 5 +- beacon_chain/nimbus_beacon_node.nim | 11 +- beacon_chain/rpc/rest_event_api.nim | 21 ++- beacon_chain/spec/datatypes/electra.nim | 5 +- .../eth2_apis/eth2_rest_serialization.nim | 4 + beacon_chain/spec/eth2_apis/rest_types.nim | 8 +- beacon_chain/spec/state_transition_block.nim | 4 +- beacon_chain/validators/beacon_validators.nim | 3 +- tests/test_keymanager_api.nim | 3 +- tests/test_signing_node.nim | 142 +----------------- tests/test_toblindedblock.nim | 4 +- 12 files changed, 46 insertions(+), 166 deletions(-) diff --git a/AllTests-mainnet.md b/AllTests-mainnet.md index 4b3968cd87..260e4f46e0 100644 --- a/AllTests-mainnet.md +++ b/AllTests-mainnet.md @@ -740,7 +740,6 @@ AllTests-mainnet ``` ## Nimbus remote signer/signing test (verifying-web3signer) ```diff -+ Signing BeaconBlock (getBlockSignature(capella)) OK + Signing BeaconBlock (getBlockSignature(deneb)) OK + Waiting for signing node (/upcheck) test OK ``` @@ -749,7 +748,6 @@ AllTests-mainnet + Connection timeout test OK + Public keys enumeration (/api/v1/eth2/publicKeys) test OK + Public keys reload (/reload) test OK -+ Signing BeaconBlock (getBlockSignature(capella)) OK + Signing BeaconBlock (getBlockSignature(deneb)) OK + Signing SC contribution and proof (getContributionAndProofSignature()) OK + Signing SC message (getSyncCommitteeMessage()) OK diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index c1fcfd8e37..eb22148dfa 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -47,12 +47,13 @@ type EventBus* = object headQueue*: AsyncEventQueue[HeadChangeInfoObject] blocksQueue*: AsyncEventQueue[EventBeaconBlockObject] - attestQueue*: AsyncEventQueue[phase0.Attestation] + phase0AttestQueue*: AsyncEventQueue[phase0.Attestation] singleAttestQueue*: AsyncEventQueue[SingleAttestation] exitQueue*: AsyncEventQueue[SignedVoluntaryExit] blsToExecQueue*: AsyncEventQueue[SignedBLSToExecutionChange] propSlashQueue*: AsyncEventQueue[ProposerSlashing] - attSlashQueue*: AsyncEventQueue[phase0.AttesterSlashing] + phase0AttSlashQueue*: AsyncEventQueue[phase0.AttesterSlashing] + electraAttSlashQueue*: AsyncEventQueue[electra.AttesterSlashing] blobSidecarQueue*: AsyncEventQueue[BlobSidecarInfoObject] finalQueue*: AsyncEventQueue[FinalizationInfoObject] reorgQueue*: AsyncEventQueue[ReorgInfoObject] diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 5f842f2ef3..e4d8152ac0 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -300,7 +300,7 @@ proc initFullNode( template config(): auto = node.config proc onPhase0AttestationReceived(data: phase0.Attestation) = - node.eventBus.attestQueue.emit(data) + node.eventBus.phase0AttestQueue.emit(data) proc onSingleAttestationReceived(data: SingleAttestation) = node.eventBus.singleAttestQueue.emit(data) proc onSyncContribution(data: SignedContributionAndProof) = @@ -312,9 +312,9 @@ proc initFullNode( proc onProposerSlashingAdded(data: ProposerSlashing) = node.eventBus.propSlashQueue.emit(data) proc onPhase0AttesterSlashingAdded(data: phase0.AttesterSlashing) = - node.eventBus.attSlashQueue.emit(data) + node.eventBus.phase0AttSlashQueue.emit(data) proc onElectraAttesterSlashingAdded(data: electra.AttesterSlashing) = - debugComment "electra att slasher queue" + node.eventBus.electraAttSlashQueue.emit(data) proc onBlobSidecarAdded(data: BlobSidecarInfoObject) = node.eventBus.blobSidecarQueue.emit(data) proc onBlockAdded(data: ForkedTrustedSignedBeaconBlock) = @@ -744,12 +744,13 @@ proc init*(T: type BeaconNode, eventBus = EventBus( headQueue: newAsyncEventQueue[HeadChangeInfoObject](), blocksQueue: newAsyncEventQueue[EventBeaconBlockObject](), - attestQueue: newAsyncEventQueue[phase0.Attestation](), + phase0AttestQueue: newAsyncEventQueue[phase0.Attestation](), singleAttestQueue: newAsyncEventQueue[SingleAttestation](), exitQueue: newAsyncEventQueue[SignedVoluntaryExit](), blsToExecQueue: newAsyncEventQueue[SignedBLSToExecutionChange](), propSlashQueue: newAsyncEventQueue[ProposerSlashing](), - attSlashQueue: newAsyncEventQueue[phase0.AttesterSlashing](), + phase0AttSlashQueue: newAsyncEventQueue[phase0.AttesterSlashing](), + electraAttSlashQueue: newAsyncEventQueue[electra.AttesterSlashing](), blobSidecarQueue: newAsyncEventQueue[BlobSidecarInfoObject](), finalQueue: newAsyncEventQueue[FinalizationInfoObject](), reorgQueue: newAsyncEventQueue[ReorgInfoObject](), diff --git a/beacon_chain/rpc/rest_event_api.nim b/beacon_chain/rpc/rest_event_api.nim index ca2fe34ed9..360405363f 100644 --- a/beacon_chain/rpc/rest_event_api.nim +++ b/beacon_chain/rpc/rest_event_api.nim @@ -114,7 +114,6 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) = # so there no need to respond with HTTP error response. return - debugComment "add single_attestation handler" let handlers = block: var res: seq[Future[void]] @@ -127,9 +126,13 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) = "block") res.add(handler) if EventTopic.Attestation in eventTopics: - let handler = response.eventHandler(node.eventBus.attestQueue, + let handler = response.eventHandler(node.eventBus.phase0AttestQueue, "attestation") res.add(handler) + if EventTopic.Attestation in eventTopics: + let handler = response.eventHandler(node.eventBus.singleAttestQueue, + "single_attestation") + res.add(handler) if EventTopic.VoluntaryExit in eventTopics: let handler = response.eventHandler(node.eventBus.exitQueue, "voluntary_exit") @@ -143,9 +146,15 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) = "proposer_slashing") res.add(handler) if EventTopic.AttesterSlashing in eventTopics: - let handler = response.eventHandler(node.eventBus.attSlashQueue, - "attester_slashing") - res.add(handler) + block: + let handler = response.eventHandler(node.eventBus.phase0AttSlashQueue, + "attester_slashing") + res.add(handler) + + block: + let handler = response.eventHandler(node.eventBus.electraAttSlashQueue, + "attester_slashing") + res.add(handler) if EventTopic.BlobSidecar in eventTopics: let handler = response.eventHandler(node.eventBus.blobSidecarQueue, "blob_sidecar") @@ -179,7 +188,7 @@ proc installEventApiHandlers*(router: var RestRouter, node: BeaconNode) = except ValueError: raiseAssert "There should be more than one event handler at this point!" # One of the handlers finished, it means that connection has been dropped, so - # we cancelling all other handlers. + # we are cancelling all other handlers. let pending = handlers.filterIt(not(it.finished())).mapIt(it.cancelAndWait()) await noCancel allFutures(pending) diff --git a/beacon_chain/spec/datatypes/electra.nim b/beacon_chain/spec/datatypes/electra.nim index e0271c5517..5121f77fe8 100644 --- a/beacon_chain/spec/datatypes/electra.nim +++ b/beacon_chain/spec/datatypes/electra.nim @@ -964,11 +964,10 @@ template asTrusted*( MsgTrustedSignedBeaconBlock): TrustedSignedBeaconBlock = isomorphicCast[TrustedSignedBeaconBlock](x) -debugComment "this whole section with getValidatorIndices/shortLog needs refactoring and probably can be combined with identical implementations elsewhere" - from std/sets import toHashSet -iterator getValidatorIndices*(attester_slashing: AttesterSlashing | TrustedAttesterSlashing): uint64 = +iterator getValidatorIndices*( + attester_slashing: AttesterSlashing | TrustedAttesterSlashing): uint64 = template attestation_1(): auto = attester_slashing.attestation_1 template attestation_2(): auto = attester_slashing.attestation_2 diff --git a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim index 3cd01bd8e5..da85d28920 100644 --- a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim +++ b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim @@ -3638,6 +3638,8 @@ func decodeString*(t: typedesc[EventTopic], ok(EventTopic.Block) of "attestation": ok(EventTopic.Attestation) + of "single_attestation": + ok(EventTopic.SingleAttestation) of "voluntary_exit": ok(EventTopic.VoluntaryExit) of "bls_to_execution_change": @@ -3669,6 +3671,8 @@ func encodeString*(value: set[EventTopic]): Result[string, cstring] = res.add("block,") if EventTopic.Attestation in value: res.add("attestation,") + if EventTopic.SingleAttestation in value: + res.add("single_attestation,") if EventTopic.VoluntaryExit in value: res.add("voluntary_exit,") if EventTopic.BLSToExecutionChange in value: diff --git a/beacon_chain/spec/eth2_apis/rest_types.nim b/beacon_chain/spec/eth2_apis/rest_types.nim index 06182eb2b1..b995948ac8 100644 --- a/beacon_chain/spec/eth2_apis/rest_types.nim +++ b/beacon_chain/spec/eth2_apis/rest_types.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2024 Status Research & Development GmbH +# Copyright (c) 2018-2025 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). @@ -57,9 +57,9 @@ type # https://github.com/ethereum/beacon-APIs/blob/v2.4.2/apis/eventstream/index.yaml EventTopic* {.pure.} = enum Head, Block, Attestation, VoluntaryExit, BLSToExecutionChange, - ProposerSlashing, AttesterSlashing, BlobSidecar, FinalizedCheckpoint, - ChainReorg, ContributionAndProof, LightClientFinalityUpdate, - LightClientOptimisticUpdate + ProposerSlashing, AttesterSlashing, BlobSidecar, SingleAttestation, + FinalizedCheckpoint, ChainReorg, ContributionAndProof, + LightClientFinalityUpdate, LightClientOptimisticUpdate EventTopics* = set[EventTopic] diff --git a/beacon_chain/spec/state_transition_block.nim b/beacon_chain/spec/state_transition_block.nim index 48834a4961..eea1101907 100644 --- a/beacon_chain/spec/state_transition_block.nim +++ b/beacon_chain/spec/state_transition_block.nim @@ -418,8 +418,10 @@ proc check_voluntary_exit*( return err("Exit: not in validator set long enough") when typeof(state).kind >= ConsensusFork.Electra: + if voluntary_exit.validator_index >= state.validators.lenu64: + return err("Exit: validator index out of range") + # Only exit validator if it has no pending withdrawals in the queue - debugComment "truncating" if not (get_pending_balance_to_withdraw( state, voluntary_exit.validator_index.ValidatorIndex) == 0.Gwei): return err("Exit: still has pending withdrawals") diff --git a/beacon_chain/validators/beacon_validators.nim b/beacon_chain/validators/beacon_validators.nim index fc3d36a572..a2b4da24e8 100644 --- a/beacon_chain/validators/beacon_validators.nim +++ b/beacon_chain/validators/beacon_validators.nim @@ -248,7 +248,7 @@ proc isSynced*(node: BeaconNode, head: BlockRef): bool = ## determine if we're in sync and should be producing blocks and ## attestations. Generally, the problem is that slot time keeps advancing ## even when there are no blocks being produced, so there's no way to - ## distinguish validators geniunely going missing from the node not being + ## distinguish validators genuinely going missing from the node not being ## well connected (during a network split or an internet outage for ## example). It would generally be correct to simply keep running as if ## we were the only legit node left alive, but then we run into issues: @@ -958,7 +958,6 @@ proc getBlindedBlockParts[ else: static: doAssert false - debugComment "the electra builder API bids have these requests" let newBlock = await makeBeaconBlockForHeadAndSlot( PayloadType, node, randao, validator_index, graffiti, head, slot, execution_payload = Opt.some shimExecutionPayload, diff --git a/tests/test_keymanager_api.nim b/tests/test_keymanager_api.nim index eab91e186e..c01c2fa8c9 100644 --- a/tests/test_keymanager_api.nim +++ b/tests/test_keymanager_api.nim @@ -24,8 +24,7 @@ import ../beacon_chain/networking/network_metadata, ../beacon_chain/rpc/rest_key_management_api, ../beacon_chain/[conf, filepath, beacon_node, - nimbus_beacon_node, beacon_node_status, - nimbus_validator_client], + nimbus_beacon_node, beacon_node_status], ../beacon_chain/validator_client/common, ../ncli/ncli_testnet, ./testutil diff --git a/tests/test_signing_node.nim b/tests/test_signing_node.nim index e99d4ee8db..aff49f0530 100644 --- a/tests/test_signing_node.nim +++ b/tests/test_signing_node.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2023-2024 Status Research & Development GmbH +# Copyright (c) 2023-2025 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). @@ -62,7 +62,6 @@ const AgAttestationPhase0 = "{\"data\":{\"aggregation_bits\":\"0x01\",\"signature\":\"0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505\",\"data\":{\"slot\":\"1\",\"index\":\"1\",\"beacon_block_root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\",\"source\":{\"epoch\":\"1\",\"root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\"},\"target\":{\"epoch\":\"1\",\"root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\"}}}}" AgAttestationElectra = "{\"data\":{\"aggregation_bits\":\"0x01\",\"committee_bits\":\"0x0000000000000001\",\"signature\":\"0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505\",\"data\":{\"slot\":\"1\",\"index\":\"1\",\"beacon_block_root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\",\"source\":{\"epoch\":\"1\",\"root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\"},\"target\":{\"epoch\":\"1\",\"root\":\"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2\"}}}}" - CapellaBlock = "{\"message\":{\"slot\":\"5297696\",\"proposer_index\":\"153094\",\"parent_root\":\"0xe6106533af9be918120ead7440a8006c7f123cc3cb7daf1f11d951864abea014\",\"state_root\":\"0xf86196d34500ca25d1f4e7431d4d52f6f85540bcaf97dd0d2ad9ecdb3eebcdf0\",\"body\":{\"randao_reveal\":\"0xa7efee3d5ddceb60810b23e3b5d39734696418f41dfd13a0851c7be7a72acbdceaa61e1db27513801917d72519d1c1040ccfed829faf06abe06d9964949554bf4369134b66de715ea49eb4fecf3e2b7e646f1764a1993e31e53dbc6557929c12\",\"eth1_data\":{\"deposit_root\":\"0x8ec87d7219a3c873fff3bfe206b4f923d1b471ce4ff9d6d6ecc162ef07825e14\",\"deposit_count\":\"259476\",\"block_hash\":\"0x877b6f8332c7397251ff3f0c5cecec105ff7d4cb78251b47f91fd15a86a565ab\"},\"graffiti\":\"\",\"proposer_slashings\":[],\"attester_slashings\":[],\"attestations\":[],\"deposits\":[],\"voluntary_exits\":[],\"sync_aggregate\":{\"sync_committee_bits\":\"0x733dfda7f5ffde5ade73367fcbf7fffeef7fe43777ffdffab9dbad6f7eed5fff9bfec4affdefbfaddf35bf5efbff9ffff9dfd7dbf97fbfcdfaddfeffbf95f75f\",\"sync_committee_signature\":\"0x81fdf76e797f81b0116a1c1ae5200b613c8041115223cd89e8bd5477aab13de6097a9ebf42b130c59527bbb4c96811b809353a17c717549f82d4bd336068ef0b99b1feebd4d2432a69fa77fac12b78f1fcc9d7b59edbeb381adf10b15bc4a520\"},\"execution_payload\":{\"parent_hash\":\"0x14c2242a8cfbce559e84c391f5f16d10d7719751b8558873012dc88ae5a193e8\",\"fee_recipient\":\"$1\",\"state_root\":\"0xdf8d96b2c292736d39e72e25802c2744d34d3d3c616de5b362425cab01f72fa5\",\"receipts_root\":\"0x4938a2bf640846d213b156a1a853548b369cd02917fa63d8766ab665d7930bac\",\"logs_bloom\":\"0x298610600038408c201080013832408850a00bc8f801920121840030a015310010e2a0e0108628110552062811441c84802f43825c4fc82140b036c58025a28800054c80a44025c052090a0f2c209a0400058040019ea0008e589084078048050880930113a2894082e0112408b088382402a851621042212aa40018a408d07e178c68691486411aa9a2809043b000a04c040000065a030028018540b04b1820271d00821b00c29059095022322c10a530060223240416140190056608200063c82248274ba8f0098e402041cd9f451031481a1010b8220824833520490221071898802d206348449116812280014a10a2d1c210100a30010802490f0a221849\",\"prev_randao\":\"0xc061711e135cd40531ec3ee29d17d3824c0e5f80d07f721e792ab83240aa0ab5\",\"block_number\":\"8737497\",\"gas_limit\":\"30000000\",\"gas_used\":\"16367052\",\"timestamp\":\"1680080352\",\"extra_data\":\"0xd883010b05846765746888676f312e32302e32856c696e7578\",\"base_fee_per_gas\":\"231613172261\",\"block_hash\":\"0x5aa9fd22a9238925adb2b038fd6eafc77adabf554051db5bc16ae5168a52eff6\",\"transactions\":[],\"withdrawals\":[]},\"bls_to_execution_changes\":[]}},\"signature\":\"$2\"}" DenebBlockContents = "{\"signed_block\":{\"message\":{\"slot\":\"5297696\",\"proposer_index\":\"153094\",\"parent_root\":\"0xe6106533af9be918120ead7440a8006c7f123cc3cb7daf1f11d951864abea014\",\"state_root\":\"0xf86196d34500ca25d1f4e7431d4d52f6f85540bcaf97dd0d2ad9ecdb3eebcdf0\",\"body\":{\"randao_reveal\":\"0xa7efee3d5ddceb60810b23e3b5d39734696418f41dfd13a0851c7be7a72acbdceaa61e1db27513801917d72519d1c1040ccfed829faf06abe06d9964949554bf4369134b66de715ea49eb4fecf3e2b7e646f1764a1993e31e53dbc6557929c12\",\"eth1_data\":{\"deposit_root\":\"0x8ec87d7219a3c873fff3bfe206b4f923d1b471ce4ff9d6d6ecc162ef07825e14\",\"deposit_count\":\"259476\",\"block_hash\":\"0x877b6f8332c7397251ff3f0c5cecec105ff7d4cb78251b47f91fd15a86a565ab\"},\"graffiti\":\"\",\"proposer_slashings\":[],\"attester_slashings\":[],\"attestations\":[],\"deposits\":[],\"voluntary_exits\":[],\"sync_aggregate\":{\"sync_committee_bits\":\"0x733dfda7f5ffde5ade73367fcbf7fffeef7fe43777ffdffab9dbad6f7eed5fff9bfec4affdefbfaddf35bf5efbff9ffff9dfd7dbf97fbfcdfaddfeffbf95f75f\",\"sync_committee_signature\":\"0x81fdf76e797f81b0116a1c1ae5200b613c8041115223cd89e8bd5477aab13de6097a9ebf42b130c59527bbb4c96811b809353a17c717549f82d4bd336068ef0b99b1feebd4d2432a69fa77fac12b78f1fcc9d7b59edbeb381adf10b15bc4a520\"},\"execution_payload\":{\"parent_hash\":\"0x14c2242a8cfbce559e84c391f5f16d10d7719751b8558873012dc88ae5a193e8\",\"fee_recipient\":\"$1\",\"state_root\":\"0xdf8d96b2c292736d39e72e25802c2744d34d3d3c616de5b362425cab01f72fa5\",\"receipts_root\":\"0x4938a2bf640846d213b156a1a853548b369cd02917fa63d8766ab665d7930bac\",\"logs_bloom\":\"0x298610600038408c201080013832408850a00bc8f801920121840030a015310010e2a0e0108628110552062811441c84802f43825c4fc82140b036c58025a28800054c80a44025c052090a0f2c209a0400058040019ea0008e589084078048050880930113a2894082e0112408b088382402a851621042212aa40018a408d07e178c68691486411aa9a2809043b000a04c040000065a030028018540b04b1820271d00821b00c29059095022322c10a530060223240416140190056608200063c82248274ba8f0098e402041cd9f451031481a1010b8220824833520490221071898802d206348449116812280014a10a2d1c210100a30010802490f0a221849\",\"prev_randao\":\"0xc061711e135cd40531ec3ee29d17d3824c0e5f80d07f721e792ab83240aa0ab5\",\"block_number\":\"8737497\",\"gas_limit\":\"30000000\",\"gas_used\":\"16367052\",\"timestamp\":\"1680080352\",\"extra_data\":\"0xd883010b05846765746888676f312e32302e32856c696e7578\",\"base_fee_per_gas\":\"231613172261\",\"block_hash\":\"0x5aa9fd22a9238925adb2b038fd6eafc77adabf554051db5bc16ae5168a52eff6\",\"transactions\":[],\"withdrawals\":[],\"blob_gas_used\":\"2316131761\",\"excess_blob_gas\":\"231613172261\"},\"bls_to_execution_changes\":[],\"blob_kzg_commitments\":[]}},\"signature\":\"$2\"},\"kzg_proofs\":[],\"blobs\":[]}" SigningNodeAddress = "127.0.0.1" @@ -92,12 +91,8 @@ proc getBlock( ): ForkedBeaconBlock {.raises: [ResultError[cstring]].} = try: case fork - of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix: + of ConsensusFork.Phase0 .. ConsensusFork.Capella: raiseAssert "Unsupported fork" - of ConsensusFork.Capella: - ForkedBeaconBlock.init(RestJson.decode( - CapellaBlock % [feeRecipient, SomeSignature], - capella.SignedBeaconBlock).message) of ConsensusFork.Deneb: ForkedBeaconBlock.init(RestJson.decode( DenebBlockContents % [feeRecipient, SomeSignature], @@ -117,12 +112,8 @@ proc getBlock( func init(t: typedesc[Web3SignerForkedBeaconBlock], forked: ForkedBeaconBlock): Web3SignerForkedBeaconBlock = case forked.kind - of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix: - raiseAssert "supports Capella and later forks" - of ConsensusFork.Capella: - Web3SignerForkedBeaconBlock( - kind: ConsensusFork.Capella, - data: forked.capellaData.toBeaconBlockHeader) + of ConsensusFork.Phase0 .. ConsensusFork.Capella: + raiseAssert "supports Deneb and later forks" of ConsensusFork.Deneb: Web3SignerForkedBeaconBlock( kind: ConsensusFork.Deneb, @@ -251,7 +242,6 @@ func getRemoteKeystoreData(data: string, basePort: int, pubkey: publicKey ) - debugComment "check electraIndex" ok case rt of RemoteSignerType.Web3Signer: KeystoreData( @@ -843,41 +833,6 @@ block: sres2.get() == rres2.get() sres3.get() == rres3.get() - asyncTest "Signing BeaconBlock (getBlockSignature(capella))": - let - forked = getBlock(ConsensusFork.Capella) - blockRoot = withBlck(forked): hash_tree_root(forkyBlck) - - sres1 = - await validator1.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot, forked) - sres2 = - await validator2.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot, forked) - sres3 = - await validator3.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot, forked) - rres1 = - await validator4.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot, forked) - rres2 = - await validator5.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot, forked) - rres3 = - await validator6.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot, forked) - - check: - sres1.isOk() - sres2.isOk() - sres3.isOk() - rres1.isOk() - rres2.isOk() - rres3.isOk() - sres1.get() == rres1.get() - sres2.get() == rres2.get() - sres3.get() == rres3.get() - asyncTest "Signing BeaconBlock (getBlockSignature(deneb))": let forked = getBlock(ConsensusFork.Deneb) @@ -1045,95 +1000,6 @@ block: await client.closeWait() - asyncTest "Signing BeaconBlock (getBlockSignature(capella))": - let - fork = ConsensusFork.Capella - forked1 = getBlock(fork) - blockRoot1 = withBlck(forked1): hash_tree_root(forkyBlck) - forked2 = getBlock(fork, SigningOtherFeeRecipient) - blockRoot2 = withBlck(forked2): hash_tree_root(forkyBlck) - request1 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot, - Web3SignerForkedBeaconBlock.init(forked1)) - request2 = Web3SignerRequest.init(SigningFork, GenesisValidatorsRoot, - Web3SignerForkedBeaconBlock.init(forked1), @[]) - remoteUrl = "http://" & SigningNodeAddress & ":" & - $getNodePort(basePort, RemoteSignerType.VerifyingWeb3Signer) - prestoFlags = {RestClientFlag.CommaSeparatedArray} - rclient = RestClientRef.new(remoteUrl, prestoFlags, {}) - publicKey1 = ValidatorPubKey.fromHex(ValidatorPubKey1).get() - publicKey2 = ValidatorPubKey.fromHex(ValidatorPubKey2).get() - publicKey3 = ValidatorPubKey.fromHex(ValidatorPubKey3).get() - - check rclient.isOk() - - let - client = rclient.get() - sres1 = - await validator1.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot1, forked1) - sres2 = - await validator2.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot1, forked1) - sres3 = - await validator3.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot1, forked1) - rres1 = - await validator4.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot1, forked1) - rres2 = - await validator5.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot1, forked1) - rres3 = - await validator6.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot1, forked1) - bres1 = - await validator4.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot2, forked2) - bres2 = - await validator5.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot2, forked2) - bres3 = - await validator6.getBlockSignature(SigningFork, GenesisValidatorsRoot, - Slot(1), blockRoot2, forked2) - - check: - # Local requests - sres1.isOk() - sres2.isOk() - sres3.isOk() - # Remote requests with proper Merkle proof of proper FeeRecipent field - rres1.isOk() - rres2.isOk() - rres3.isOk() - # Signature comparison - sres1.get() == rres1.get() - sres2.get() == rres2.get() - sres3.get() == rres3.get() - # Remote requests with changed FeeRecipient field - bres1.isErr() - bres2.isErr() - bres3.isErr() - - try: - let - # `proofs` array is not present. - response1 = await client.signDataPlain(publicKey1, request1) - response2 = await client.signDataPlain(publicKey2, request1) - response3 = await client.signDataPlain(publicKey3, request1) - # `proofs` array is empty. - response4 = await client.signDataPlain(publicKey1, request2) - response5 = await client.signDataPlain(publicKey2, request2) - response6 = await client.signDataPlain(publicKey3, request2) - check: - response1.status == 400 - response2.status == 400 - response3.status == 400 - response4.status == 400 - response5.status == 400 - response6.status == 400 - finally: - await client.closeWait() - asyncTest "Signing BeaconBlock (getBlockSignature(deneb))": let fork = ConsensusFork.Deneb diff --git a/tests/test_toblindedblock.nim b/tests/test_toblindedblock.nim index 8e6b9e9156..4c337e2401 100644 --- a/tests/test_toblindedblock.nim +++ b/tests/test_toblindedblock.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2024 Status Research & Development GmbH +# Copyright (c) 2024-2025 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). @@ -155,4 +155,6 @@ suite "Blinded block conversions": deneb_steps when consensusFork >= ConsensusFork.Electra: electra_steps + when consensusFork >= ConsensusFork.Fulu: + fulu_steps static: doAssert high(ConsensusFork) == ConsensusFork.Fulu