From 99f9bc4eee17523d1c251953ccab146e5886ae00 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 15 Apr 2020 06:11:45 +0300 Subject: [PATCH] Fix the inspector build --- beacon_chain/inspector.nim | 25 ++++++++++++++++--------- beacon_chain/spec/network.nim | 2 +- vendor/nim-eth | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/beacon_chain/inspector.nim b/beacon_chain/inspector.nim index 83c2c09c0..6e42944cb 100644 --- a/beacon_chain/inspector.nim +++ b/beacon_chain/inspector.nim @@ -57,6 +57,10 @@ type abbr: "g" name: "gossipsub" }: bool + forkDigest* {. + desc: "Sets the fork-digest value used to construct all topic names" + name: "forkdigest"}: string + signFlag* {. defaultValue: false desc: "Sets the inspector's to send/verify signatures in pubsub messages" @@ -93,18 +97,18 @@ type abbr: "d" defaultValue: false }: bool -func getTopics(filter: TopicFilter): seq[string] {.inline.} = +func getTopics(forkDigest: ForkDigest, filter: TopicFilter): seq[string] {.inline.} = case filter of TopicFilter.Blocks: - @[topicBeaconBlocks] + @[getBeaconBlocksTopic(forkDigest)] of TopicFilter.Attestations: - mapIt(0'u64 ..< ATTESTATION_SUBNET_COUNT.uint64, it.getAttestationTopic) + mapIt(0'u64 ..< ATTESTATION_SUBNET_COUNT.uint64, getAttestationTopic(forkDigest, it)) of TopicFilter.Exits: - @[topicVoluntaryExits] + @[getVoluntaryExitsTopic(forkDigest)] of TopicFilter.ProposerSlashing: - @[topicProposerSlashings] + @[getProposerSlashingsTopic(forkDigest)] of TopicFilter.AttesterSlashings: - @[topicAttesterSlashings] + @[getAttesterSlashingsTopic(forkDigest)] func getPeerId(peer: PeerID, conf: InspectorConf): string {.inline.} = if conf.fullPeerId: @@ -186,9 +190,9 @@ proc run(conf: InspectorConf) {.async.} = try: if ticket.topic.endsWith(topicBeaconBlocksSuffix): info "SignedBeaconBlock", msg = SSZ.decode(message.data, SignedBeaconBlock) - elif ticket.topic.endsWith(topicAttestationSuffix): + elif ticket.topic.endsWith(topicAttestationsSuffix): info "Attestation", msg = SSZ.decode(message.data, Attestation) - elif ticket.topic.endssWith(topicVoluntaryExitsSuffix): + elif ticket.topic.endsWith(topicVoluntaryExitsSuffix): info "SignedVoluntaryExit", msg = SSZ.decode(message.data, SignedVoluntaryExit) elif ticket.topic.endsWith(topicProposerSlashingsSuffix): info "ProposerSlashing", msg = SSZ.decode(message.data, ProposerSlashing) @@ -278,9 +282,12 @@ proc run(conf: InspectorConf) {.async.} = exception = e.msg quit(1) + var forkDigest: ForkDigest + hexToByteArray(conf.forkDigest, forkDigest) + try: for filter in topics: - for topic in getTopics(filter): + for topic in getTopics(forkDigest, filter): let t = await api.pubsubSubscribe(topic, pubsubLogger) info "Subscribed to topic", topic = topic subs.add((ticket: t, future: t.transp.join())) diff --git a/beacon_chain/spec/network.nim b/beacon_chain/spec/network.nim index c71ed6a82..dbfbb87ad 100644 --- a/beacon_chain/spec/network.nim +++ b/beacon_chain/spec/network.nim @@ -29,7 +29,7 @@ const func getBeaconBlocksTopic*(forkDigest: ForkDigest): string = &"/eth2/{toHex forkDigest}/{topicBeaconBlocksSuffix}" -func getVoluntaryExistsTopic*(forkDigest: ForkDigest): string = +func getVoluntaryExitsTopic*(forkDigest: ForkDigest): string = &"/eth2/{toHex forkDigest}/{topicVoluntaryExitsSuffix}" func getProposerSlashingsTopic*(forkDigest: ForkDigest): string = diff --git a/vendor/nim-eth b/vendor/nim-eth index bac624830..ee5c9619e 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit bac62483016f7e66fcf2bfbf83372e9e4dfbc24f +Subproject commit ee5c9619e0ae7e847e205f3a9dcc1c95a2e10f90