@@ -1973,188 +1973,190 @@ proc installMessageValidators(node: BeaconNode) =
19731973
19741974 for fork in ConsensusFork :
19751975 withConsensusFork (fork):
1976- let digest = forkDigests[].atConsensusFork (consensusFork)
1977-
1978- # beacon_block
1979- # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#beacon_block
1980- node.network.addValidator (
1981- getBeaconBlocksTopic (digest), proc (
1982- signedBlock: consensusFork.SignedBeaconBlock ,
1983- src: PeerId
1984- ): ValidationResult =
1985- if node.shouldSyncOptimistically (node.currentSlot):
1986- toValidationResult (
1987- node.optimisticProcessor.processSignedBeaconBlock (
1988- signedBlock))
1989- else :
1990- toValidationResult (
1991- node.processor[].processSignedBeaconBlock (
1992- MsgSource .gossip, signedBlock)))
1993-
1994- # beacon_attestation_{subnet_id}
1995- # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
1996- when consensusFork >= ConsensusFork .Electra :
1997- for it in SubnetId :
1998- closureScope: # Needed for inner `proc`; don't lift it out of loop.
1999- let subnet_id = it
2000- node.network.addAsyncValidator (
2001- getAttestationTopic (digest, subnet_id), proc (
2002- attestation: SingleAttestation , src: PeerId
2003- ): Future [ValidationResult ] {.
2004- async : (raises: [CancelledError ]).} =
2005- return toValidationResult (
2006- await node.processor.processAttestation (
2007- MsgSource .gossip, attestation, subnet_id,
2008- checkSignature = true , checkValidator = false )))
2009- else :
2010- for it in SubnetId :
2011- closureScope: # Needed for inner `proc`; don't lift it out of loop.
2012- let subnet_id = it
2013- node.network.addAsyncValidator (
2014- getAttestationTopic (digest, subnet_id), proc (
2015- attestation: phase0.Attestation , src: PeerId
2016- ): Future [ValidationResult ] {.
2017- async : (raises: [CancelledError ]).} =
2018- return toValidationResult (
2019- await node.processor.processAttestation (
2020- MsgSource .gossip, attestation, subnet_id,
2021- checkSignature = true , checkValidator = false )))
2022-
2023- # beacon_aggregate_and_proof
2024- # https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
2025- when consensusFork >= ConsensusFork .Electra :
2026- node.network.addAsyncValidator (
2027- getAggregateAndProofsTopic (digest), proc (
2028- signedAggregateAndProof: electra.SignedAggregateAndProof ,
2029- src: PeerId
2030- ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2031- return toValidationResult (
2032- await node.processor.processSignedAggregateAndProof (
2033- MsgSource .gossip, signedAggregateAndProof)))
2034- else :
2035- node.network.addAsyncValidator (
2036- getAggregateAndProofsTopic (digest), proc (
2037- signedAggregateAndProof: phase0.SignedAggregateAndProof ,
2038- src: PeerId
2039- ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2040- return toValidationResult (
2041- await node.processor.processSignedAggregateAndProof (
2042- MsgSource .gossip, signedAggregateAndProof)))
2043-
2044- # attester_slashing
2045- # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/phase0/p2p-interface.md#attester_slashing
2046- # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/p2p-interface.md#modifications-in-electra
2047- when consensusFork >= ConsensusFork .Electra :
1976+ for digest in @ [forkDigests[].atConsensusFork (consensusFork)] &
1977+ forkDigests[].bpos.filterIt (it[1 ] == consensusFork).mapIt (it[2 ]):
1978+ let digest = digest # lent
1979+ # beacon_block
1980+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#beacon_block
1981+ node.network.addValidator (
1982+ getBeaconBlocksTopic (digest), proc (
1983+ signedBlock: consensusFork.SignedBeaconBlock ,
1984+ src: PeerId ,
1985+ ): ValidationResult =
1986+ if node.shouldSyncOptimistically (node.currentSlot):
1987+ toValidationResult (
1988+ node.optimisticProcessor.processSignedBeaconBlock (
1989+ signedBlock))
1990+ else :
1991+ toValidationResult (
1992+ node.processor[].processSignedBeaconBlock (
1993+ MsgSource .gossip, signedBlock)))
1994+
1995+ # beacon_attestation_{subnet_id}
1996+ # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
1997+ when consensusFork >= ConsensusFork .Electra :
1998+ for it in SubnetId :
1999+ closureScope: # Needed for inner `proc`; don't lift it out of loop.
2000+ let subnet_id = it
2001+ node.network.addAsyncValidator (
2002+ getAttestationTopic (digest, subnet_id), proc (
2003+ attestation: SingleAttestation , src: PeerId
2004+ ): Future [ValidationResult ] {.
2005+ async : (raises: [CancelledError ]).} =
2006+ return toValidationResult (
2007+ await node.processor.processAttestation (
2008+ MsgSource .gossip, attestation, subnet_id,
2009+ checkSignature = true , checkValidator = false )))
2010+ else :
2011+ for it in SubnetId :
2012+ closureScope: # Needed for inner `proc`; don't lift it out of loop.
2013+ let subnet_id = it
2014+ node.network.addAsyncValidator (
2015+ getAttestationTopic (digest, subnet_id), proc (
2016+ attestation: phase0.Attestation , src: PeerId
2017+ ): Future [ValidationResult ] {.
2018+ async : (raises: [CancelledError ]).} =
2019+ return toValidationResult (
2020+ await node.processor.processAttestation (
2021+ MsgSource .gossip, attestation, subnet_id,
2022+ checkSignature = true , checkValidator = false )))
2023+
2024+ # beacon_aggregate_and_proof
2025+ # https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
2026+ when consensusFork >= ConsensusFork .Electra :
2027+ node.network.addAsyncValidator (
2028+ getAggregateAndProofsTopic (digest), proc (
2029+ signedAggregateAndProof: electra.SignedAggregateAndProof ,
2030+ src: PeerId
2031+ ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2032+ return toValidationResult (
2033+ await node.processor.processSignedAggregateAndProof (
2034+ MsgSource .gossip, signedAggregateAndProof)))
2035+ else :
2036+ node.network.addAsyncValidator (
2037+ getAggregateAndProofsTopic (digest), proc (
2038+ signedAggregateAndProof: phase0.SignedAggregateAndProof ,
2039+ src: PeerId
2040+ ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2041+ return toValidationResult (
2042+ await node.processor.processSignedAggregateAndProof (
2043+ MsgSource .gossip, signedAggregateAndProof)))
2044+
2045+ # attester_slashing
2046+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/phase0/p2p-interface.md#attester_slashing
2047+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/p2p-interface.md#modifications-in-electra
2048+ when consensusFork >= ConsensusFork .Electra :
2049+ node.network.addValidator (
2050+ getAttesterSlashingsTopic (digest), proc (
2051+ attesterSlashing: electra.AttesterSlashing ,
2052+ src: PeerId
2053+ ): ValidationResult =
2054+ toValidationResult (
2055+ node.processor[].processAttesterSlashing (
2056+ MsgSource .gossip, attesterSlashing)))
2057+ else :
2058+ node.network.addValidator (
2059+ getAttesterSlashingsTopic (digest), proc (
2060+ attesterSlashing: phase0.AttesterSlashing ,
2061+ src: PeerId
2062+ ): ValidationResult =
2063+ toValidationResult (
2064+ node.processor[].processAttesterSlashing (
2065+ MsgSource .gossip, attesterSlashing)))
2066+
2067+ # proposer_slashing
2068+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#proposer_slashing
20482069 node.network.addValidator (
2049- getAttesterSlashingsTopic (digest), proc (
2050- attesterSlashing: electra. AttesterSlashing ,
2070+ getProposerSlashingsTopic (digest), proc (
2071+ proposerSlashing: ProposerSlashing ,
20512072 src: PeerId
20522073 ): ValidationResult =
20532074 toValidationResult (
2054- node.processor[].processAttesterSlashing (
2055- MsgSource .gossip, attesterSlashing)))
2056- else :
2075+ node.processor[].processProposerSlashing (
2076+ MsgSource .gossip, proposerSlashing)))
2077+
2078+ # voluntary_exit
2079+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/phase0/p2p-interface.md#voluntary_exit
20572080 node.network.addValidator (
2058- getAttesterSlashingsTopic (digest), proc (
2059- attesterSlashing: phase0. AttesterSlashing ,
2081+ getVoluntaryExitsTopic (digest), proc (
2082+ signedVoluntaryExit: SignedVoluntaryExit ,
20602083 src: PeerId
20612084 ): ValidationResult =
20622085 toValidationResult (
2063- node.processor[].processAttesterSlashing (
2064- MsgSource .gossip, attesterSlashing)))
2065-
2066- # proposer_slashing
2067- # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#proposer_slashing
2068- node.network.addValidator (
2069- getProposerSlashingsTopic (digest), proc (
2070- proposerSlashing: ProposerSlashing ,
2071- src: PeerId
2072- ): ValidationResult =
2073- toValidationResult (
2074- node.processor[].processProposerSlashing (
2075- MsgSource .gossip, proposerSlashing)))
2076-
2077- # voluntary_exit
2078- # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/phase0/p2p-interface.md#voluntary_exit
2079- node.network.addValidator (
2080- getVoluntaryExitsTopic (digest), proc (
2081- signedVoluntaryExit: SignedVoluntaryExit ,
2082- src: PeerId
2083- ): ValidationResult =
2084- toValidationResult (
2085- node.processor[].processSignedVoluntaryExit (
2086- MsgSource .gossip, signedVoluntaryExit)))
2087-
2088- when consensusFork >= ConsensusFork .Altair :
2089- # sync_committee_{subnet_id}
2090- # https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#sync_committee_subnet_id
2091- for subcommitteeIdx in SyncSubcommitteeIndex :
2092- closureScope: # Needed for inner `proc`; don't lift it out of loop.
2093- let idx = subcommitteeIdx
2094- node.network.addAsyncValidator (
2095- getSyncCommitteeTopic (digest, idx), proc (
2096- msg: SyncCommitteeMessage ,
2097- src: PeerId
2098- ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2099- return toValidationResult (
2100- await node.processor.processSyncCommitteeMessage (
2101- MsgSource .gossip, msg, idx)))
2102-
2103- # sync_committee_contribution_and_proof
2104- # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/altair/p2p-interface.md#sync_committee_contribution_and_proof
2105- node.network.addAsyncValidator (
2106- getSyncCommitteeContributionAndProofTopic (digest), proc (
2107- msg: SignedContributionAndProof ,
2108- src: PeerId
2109- ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2110- return toValidationResult (
2111- await node.processor.processSignedContributionAndProof (
2112- MsgSource .gossip, msg)))
2113-
2114- when consensusFork >= ConsensusFork .Capella :
2115- # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/capella/p2p-interface.md#bls_to_execution_change
2116- node.network.addAsyncValidator (
2117- getBlsToExecutionChangeTopic (digest), proc (
2118- msg: SignedBLSToExecutionChange ,
2119- src: PeerId
2120- ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2121- return toValidationResult (
2122- await node.processor.processBlsToExecutionChange (
2123- MsgSource .gossip, msg)))
2086+ node.processor[].processSignedVoluntaryExit (
2087+ MsgSource .gossip, signedVoluntaryExit)))
2088+
2089+ when consensusFork >= ConsensusFork .Altair :
2090+ # sync_committee_{subnet_id}
2091+ # https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#sync_committee_subnet_id
2092+ for subcommitteeIdx in SyncSubcommitteeIndex :
2093+ closureScope: # Needed for inner `proc`; don't lift it out of loop.
2094+ let idx = subcommitteeIdx
2095+ node.network.addAsyncValidator (
2096+ getSyncCommitteeTopic (digest, idx), proc (
2097+ msg: SyncCommitteeMessage ,
2098+ src: PeerId
2099+ ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2100+ return toValidationResult (
2101+ await node.processor.processSyncCommitteeMessage (
2102+ MsgSource .gossip, msg, idx)))
2103+
2104+ # sync_committee_contribution_and_proof
2105+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/altair/p2p-interface.md#sync_committee_contribution_and_proof
2106+ node.network.addAsyncValidator (
2107+ getSyncCommitteeContributionAndProofTopic (digest), proc (
2108+ msg: SignedContributionAndProof ,
2109+ src: PeerId
2110+ ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2111+ return toValidationResult (
2112+ await node.processor.processSignedContributionAndProof (
2113+ MsgSource .gossip, msg)))
2114+
2115+ when consensusFork >= ConsensusFork .Capella :
2116+ # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/capella/p2p-interface.md#bls_to_execution_change
2117+ node.network.addAsyncValidator (
2118+ getBlsToExecutionChangeTopic (digest), proc (
2119+ msg: SignedBLSToExecutionChange ,
2120+ src: PeerId
2121+ ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2122+ return toValidationResult (
2123+ await node.processor.processBlsToExecutionChange (
2124+ MsgSource .gossip, msg)))
21242125
2125- when consensusFork >= ConsensusFork .Fulu :
21262126 # data_column_sidecar_{subnet_id}
2127- for it in 0 'u64 ..< node.dag.cfg.NUMBER_OF_CUSTODY_GROUPS :
2128- closureScope:
2129- let subnet_id = it
2130- node.network.addAsyncValidator (
2131- getDataColumnSidecarTopic (digest, subnet_id), proc (
2132- dataColumnSidecar: fulu.DataColumnSidecar ,
2133- src: PeerId
2134- ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2135- toValidationResult (
2136- await node.processor.processDataColumnSidecar (
2137- MsgSource .gossip, dataColumnSidecar, subnet_id)))
2138-
2139- when consensusFork in [ConsensusFork .Deneb , ConsensusFork .Electra ]:
2140- # blob_sidecar_{subnet_id}
2141- # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/p2p-interface.md#blob_sidecar_subnet_id
2142- let subnetCount =
2143- when consensusFork >= ConsensusFork .Electra :
2144- node.dag.cfg.BLOB_SIDECAR_SUBNET_COUNT_ELECTRA
2145- else :
2146- node.dag.cfg.BLOB_SIDECAR_SUBNET_COUNT
2147- for it in 0 .BlobId ..< subnetCount.BlobId :
2148- closureScope: # Needed for inner `proc`; don't lift it out of loop.
2149- let subnet_id = it
2150- node.network.addValidator (
2151- getBlobSidecarTopic (digest, subnet_id), proc (
2152- blobSidecar: deneb.BlobSidecar ,
2153- src: PeerId
2154- ): ValidationResult =
2155- toValidationResult (
2156- node.processor[].processBlobSidecar (
2157- MsgSource .gossip, blobSidecar, subnet_id)))
2127+ when consensusFork >= ConsensusFork .Fulu :
2128+ # data_column_sidecar_{subnet_id}
2129+ for it in 0 'u64 ..< node.dag.cfg.NUMBER_OF_CUSTODY_GROUPS :
2130+ closureScope:
2131+ let subnet_id = it
2132+ node.network.addAsyncValidator (
2133+ getDataColumnSidecarTopic (digest, subnet_id), proc (
2134+ dataColumnSidecar: fulu.DataColumnSidecar ,
2135+ src: PeerId
2136+ ): Future [ValidationResult ] {.async : (raises: [CancelledError ]).} =
2137+ toValidationResult (
2138+ await node.processor.processDataColumnSidecar (
2139+ MsgSource .gossip, dataColumnSidecar, subnet_id)))
2140+
2141+ when consensusFork in [ConsensusFork .Deneb , ConsensusFork .Electra ]:
2142+ # blob_sidecar_{subnet_id}
2143+ # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/p2p-interface.md#blob_sidecar_subnet_id
2144+ let subnetCount =
2145+ when consensusFork >= ConsensusFork .Electra :
2146+ node.dag.cfg.BLOB_SIDECAR_SUBNET_COUNT_ELECTRA
2147+ else :
2148+ node.dag.cfg.BLOB_SIDECAR_SUBNET_COUNT
2149+ for it in 0 .BlobId ..< subnetCount.BlobId :
2150+ closureScope: # Needed for inner `proc`; don't lift it out of loop.
2151+ let subnet_id = it
2152+ node.network.addValidator (
2153+ getBlobSidecarTopic (digest, subnet_id), proc (
2154+ blobSidecar: deneb.BlobSidecar ,
2155+ src: PeerId
2156+ ): ValidationResult =
2157+ toValidationResult (
2158+ node.processor[].processBlobSidecar (
2159+ MsgSource .gossip, blobSidecar, subnet_id)))
21582160
21592161 node.installLightClientMessageValidators ()
21602162
0 commit comments