allow inspector tool to log interop attestations

This commit is contained in:
Dustin Brody 2020-05-14 13:35:29 +02:00 committed by zah
parent 57519bebac
commit 2db99545cd
1 changed files with 14 additions and 3 deletions

View File

@ -51,7 +51,8 @@ type
next_fork_epoch*: Epoch next_fork_epoch*: Epoch
TopicFilter* {.pure.} = enum TopicFilter* {.pure.} = enum
Blocks, Attestations, Exits, ProposerSlashing, AttesterSlashings Blocks, Attestations, Exits, ProposerSlashing, AttesterSlashings,
InteropAttestations
BootstrapKind* {.pure.} = enum BootstrapKind* {.pure.} = enum
Enr, MultiAddr Enr, MultiAddr
@ -200,6 +201,9 @@ func getTopics(forkDigest: ForkDigest,
of TopicFilter.AttesterSlashings: of TopicFilter.AttesterSlashings:
let topic = getAttesterSlashingsTopic(forkDigest) let topic = getAttesterSlashingsTopic(forkDigest)
@[topic, topic & "_snappy"] @[topic, topic & "_snappy"]
of TopicFilter.InteropAttestations:
let topic = getInteropAttestationTopic(forkDigest)
@[topic, topic & "_snappy"]
of TopicFilter.Attestations: of TopicFilter.Attestations:
var topics = newSeq[string](ATTESTATION_SUBNET_COUNT * 2) var topics = newSeq[string](ATTESTATION_SUBNET_COUNT * 2)
var offset = 0 var offset = 0
@ -530,6 +534,9 @@ proc pubsubLogger(conf: InspectorConf, switch: Switch,
elif topic.endsWith(topicAggregateAndProofsSuffix) or elif topic.endsWith(topicAggregateAndProofsSuffix) or
topic.endsWith(topicAggregateAndProofsSuffix & "_snappy"): topic.endsWith(topicAggregateAndProofsSuffix & "_snappy"):
info "AggregateAndProof", msg = SSZ.decode(buffer, AggregateAndProof) info "AggregateAndProof", msg = SSZ.decode(buffer, AggregateAndProof)
elif topic.endsWith(topicInteropAttestationSuffix) or
topic.endsWith(topicInteropAttestationSuffix & "_snappy"):
info "Attestation", msg = SSZ.decode(buffer, Attestation)
except CatchableError as exc: except CatchableError as exc:
info "Unable to decode message", errMsg = exc.msg info "Unable to decode message", errMsg = exc.msg
@ -696,7 +703,8 @@ proc run(conf: InspectorConf) {.async.} =
if lcitem == "*": if lcitem == "*":
topics.incl({TopicFilter.Blocks, TopicFilter.Attestations, topics.incl({TopicFilter.Blocks, TopicFilter.Attestations,
TopicFilter.Exits, TopicFilter.ProposerSlashing, TopicFilter.Exits, TopicFilter.ProposerSlashing,
TopicFilter.AttesterSlashings}) TopicFilter.AttesterSlashings,
TopicFilter.InteropAttestations})
break break
elif lcitem == "a": elif lcitem == "a":
topics.incl(TopicFilter.Attestations) topics.incl(TopicFilter.Attestations)
@ -708,12 +716,15 @@ proc run(conf: InspectorConf) {.async.} =
topics.incl(TopicFilter.ProposerSlashing) topics.incl(TopicFilter.ProposerSlashing)
elif lcitem == "as": elif lcitem == "as":
topics.incl(TopicFilter.AttesterSlashings) topics.incl(TopicFilter.AttesterSlashings)
elif lcitem == "ia":
topics.incl(TopicFilter.InteropAttestations)
else: else:
discard discard
else: else:
topics.incl({TopicFilter.Blocks, TopicFilter.Attestations, topics.incl({TopicFilter.Blocks, TopicFilter.Attestations,
TopicFilter.Exits, TopicFilter.ProposerSlashing, TopicFilter.Exits, TopicFilter.ProposerSlashing,
TopicFilter.AttesterSlashings}) TopicFilter.AttesterSlashings,
TopicFilter.InteropAttestations})
proc pubsubTrampoline(topic: string, proc pubsubTrampoline(topic: string,
data: seq[byte]): Future[void] {.gcsafe.} = data: seq[byte]): Future[void] {.gcsafe.} =