From a3a651b565bd743a6f7193a63df458e34d2e4d9f Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Date: Tue, 12 Jan 2021 12:27:09 +0900 Subject: [PATCH] always enable topic and aggreate metric topics (#2229) --- beacon_chain/eth2_network.nim | 10 ++++++++-- beacon_chain/nimbus_beacon_node.nim | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index a4c6015ad..a63fc22db 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -1591,11 +1591,17 @@ proc announcedENR*(node: Eth2Node): enr.Record = proc shortForm*(id: KeyPair): string = $PeerID.init(id.pubkey) -proc subscribe*(node: Eth2Node, topic: string) = +proc subscribe*(node: Eth2Node, topic: string, enableTopicMetrics: bool = false) = proc dummyMsgHandler(topic: string, data: seq[byte]) {.async.} = discard - node.pubsub.subscribe(topic & "_snappy", dummyMsgHandler) + let + topicName = topic & "_snappy" + + if enableTopicMetrics: + node.pubsub.knownTopics.incl(topicName) + + node.pubsub.subscribe(topicName, dummyMsgHandler) proc addValidator*[MsgType](node: Eth2Node, topic: string, diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index c7f389a40..a4f1e6051 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -475,11 +475,11 @@ proc getAttestationSubnetHandlers(node: BeaconNode) = proc addMessageHandlers(node: BeaconNode) = # As a side-effect, this gets the attestation subnets too. - node.network.subscribe(node.topicBeaconBlocks) + node.network.subscribe(node.topicBeaconBlocks, enableTopicMetrics = true) node.network.subscribe(getAttesterSlashingsTopic(node.forkDigest)) node.network.subscribe(getProposerSlashingsTopic(node.forkDigest)) node.network.subscribe(getVoluntaryExitsTopic(node.forkDigest)) - node.network.subscribe(getAggregateAndProofsTopic(node.forkDigest)) + node.network.subscribe(getAggregateAndProofsTopic(node.forkDigest), enableTopicMetrics = true) node.getAttestationSubnetHandlers()