mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-02 09:46:26 +00:00
subscribe to/unsubscribe from sync committee subnets (#2832)
This commit is contained in:
parent
b1ed4d6ef4
commit
3efcdb0de5
@ -793,9 +793,30 @@ proc removePhase0MessageHandlers(node: BeaconNode) =
|
||||
proc addAltairMessageHandlers(node: BeaconNode, slot: Slot) =
|
||||
node.addPhase0MessageHandlers(node.dag.forkDigests.altair)
|
||||
|
||||
var syncnets: BitArray[SYNC_COMMITTEE_SUBNET_COUNT]
|
||||
|
||||
# TODO: What are the best topic params for this?
|
||||
for committeeIdx in allSyncCommittees():
|
||||
closureScope:
|
||||
let idx = committeeIdx
|
||||
# TODO This should be done in dynamic way in trackSyncCommitteeTopics
|
||||
node.network.subscribe(getSyncCommitteeTopic(node.dag.forkDigests.altair, idx), basicParams)
|
||||
syncnets.setBit(idx.asInt)
|
||||
|
||||
node.network.subscribe(getSyncCommitteeContributionAndProofTopic(node.dag.forkDigests.altair), basicParams)
|
||||
node.network.updateSyncnetsMetadata(syncnets)
|
||||
|
||||
proc removeAltairMessageHandlers(node: BeaconNode) =
|
||||
node.removePhase0MessageHandlers(node.dag.forkDigests.altair)
|
||||
|
||||
for committeeIdx in allSyncCommittees():
|
||||
closureScope:
|
||||
let idx = committeeIdx
|
||||
# TODO This should be done in dynamic way in trackSyncCommitteeTopics
|
||||
node.network.unsubscribe(getSyncCommitteeTopic(node.dag.forkDigests.altair, idx))
|
||||
|
||||
node.network.unsubscribe(getSyncCommitteeContributionAndProofTopic(node.dag.forkDigests.altair))
|
||||
|
||||
func getTopicSubscriptionEnabled(node: BeaconNode): bool =
|
||||
node.attestationSubnets.enabled
|
||||
|
||||
@ -820,7 +841,11 @@ proc setupDoppelgangerDetection(node: BeaconNode, slot: Slot) =
|
||||
broadcastStartEpoch =
|
||||
node.processor.doppelgangerDetection.broadcastStartEpoch
|
||||
|
||||
proc updateGossipStatus(node: BeaconNode, slot: Slot) =
|
||||
proc trackSyncCommitteeTopics*(node: BeaconNode) =
|
||||
# TODO
|
||||
discard
|
||||
|
||||
proc updateGossipStatus(node: BeaconNode, slot: Slot) {.raises: [Defect, CatchableError].} =
|
||||
# Syncing tends to be ~1 block/s, and allow for an epoch of time for libp2p
|
||||
# subscribing to spin up. The faster the sync, the more wallSlot - headSlot
|
||||
# lead time is required
|
||||
@ -1256,6 +1281,20 @@ proc installMessageValidators(node: BeaconNode) =
|
||||
proc (signedVoluntaryExit: SignedVoluntaryExit): ValidationResult =
|
||||
node.processor[].voluntaryExitValidator(signedVoluntaryExit))
|
||||
|
||||
for committeeIdx in allSyncCommittees():
|
||||
closureScope:
|
||||
let idx = committeeIdx
|
||||
node.network.addValidator(
|
||||
getSyncCommitteeTopic(node.dag.forkDigests.altair, idx),
|
||||
# This proc needs to be within closureScope; don't lift out of loop.
|
||||
proc(msg: SyncCommitteeMessage): ValidationResult =
|
||||
node.processor.syncCommitteeMsgValidator(msg, idx))
|
||||
|
||||
node.network.addValidator(
|
||||
getSyncCommitteeContributionAndProofTopic(node.dag.forkDigests.altair),
|
||||
proc(msg: SignedContributionAndProof): ValidationResult =
|
||||
node.processor.syncCommitteeContributionValidator(msg))
|
||||
|
||||
proc stop*(node: BeaconNode) =
|
||||
bnStatus = BeaconNodeStatus.Stopping
|
||||
notice "Graceful shutdown"
|
||||
|
Loading…
x
Reference in New Issue
Block a user