add merge gossip validation, except for beaconblocks (#3095)

This commit is contained in:
tersec 2021-11-13 21:26:02 +00:00 committed by GitHub
parent 222674b203
commit 00d066f7dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,7 @@ import
slashing_protection, keystore_management], slashing_protection, keystore_management],
./sync/[sync_manager, sync_protocol, request_manager], ./sync/[sync_manager, sync_protocol, request_manager],
./rpc/[rest_api, rpc_api], ./rpc/[rest_api, rpc_api],
./spec/datatypes/[altair, phase0], ./spec/datatypes/[altair, merge, phase0],
./spec/eth2_apis/rpc_beacon_client, ./spec/eth2_apis/rpc_beacon_client,
./spec/[ ./spec/[
beaconstate, forks, helpers, network, weak_subjectivity, signatures, beaconstate, forks, helpers, network, weak_subjectivity, signatures,
@ -1026,31 +1026,36 @@ proc installMessageValidators(node: BeaconNode) =
installPhase0Validators(node.dag.forkDigests.phase0) installPhase0Validators(node.dag.forkDigests.phase0)
# Validators introduced in phase0 are also used in altair, but with different # Validators introduced in phase0 are also used in altair and merge, but with
# fork digest # different fork digest
installPhase0Validators(node.dag.forkDigests.altair) installPhase0Validators(node.dag.forkDigests.altair)
installPhase0Validators(node.dag.forkDigests.merge)
node.network.addValidator( node.network.addValidator(
getBeaconBlocksTopic(node.dag.forkDigests.altair), getBeaconBlocksTopic(node.dag.forkDigests.altair),
proc (signedBlock: altair.SignedBeaconBlock): ValidationResult = proc (signedBlock: altair.SignedBeaconBlock): ValidationResult =
toValidationResult(node.processor[].blockValidator(signedBlock))) toValidationResult(node.processor[].blockValidator(signedBlock)))
template installSyncCommitteeeValidators(digest: auto) =
for committeeIdx in allSyncSubcommittees(): for committeeIdx in allSyncSubcommittees():
closureScope: closureScope:
let idx = committeeIdx let idx = committeeIdx
node.network.addValidator( node.network.addValidator(
getSyncCommitteeTopic(node.dag.forkDigests.altair, idx), getSyncCommitteeTopic(digest, idx),
# This proc needs to be within closureScope; don't lift out of loop. # This proc needs to be within closureScope; don't lift out of loop.
proc(msg: SyncCommitteeMessage): ValidationResult = proc(msg: SyncCommitteeMessage): ValidationResult =
toValidationResult( toValidationResult(
node.processor.syncCommitteeMsgValidator(msg, idx))) node.processor.syncCommitteeMsgValidator(msg, idx)))
node.network.addValidator( node.network.addValidator(
getSyncCommitteeContributionAndProofTopic(node.dag.forkDigests.altair), getSyncCommitteeContributionAndProofTopic(digest),
proc(msg: SignedContributionAndProof): ValidationResult = proc(msg: SignedContributionAndProof): ValidationResult =
toValidationResult( toValidationResult(
node.processor.syncCommitteeContributionValidator(msg))) node.processor.syncCommitteeContributionValidator(msg)))
installSyncCommitteeeValidators(node.dag.forkDigests.altair)
installSyncCommitteeeValidators(node.dag.forkDigests.merge)
proc stop*(node: BeaconNode) = proc stop*(node: BeaconNode) =
bnStatus = BeaconNodeStatus.Stopping bnStatus = BeaconNodeStatus.Stopping
notice "Graceful shutdown" notice "Graceful shutdown"