Skip to content

Commit

Permalink
Merge pull request #32 from probe-lab/fix/subnet-count
Browse files Browse the repository at this point in the history
Fix subnet composer start from subnet idx 0
  • Loading branch information
cortze committed Jun 17, 2024
2 parents a050845 + 168bae4 commit 1fe47e9
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions eth/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,18 @@ func pubsubGossipParam() pubsub.GossipSubParams {
// desiredPubSubBaseTopics returns the list of gossip_topics we want to subscribe to
func desiredPubSubBaseTopics() []string {
return []string{
p2p.GossipBlockMessage,
p2p.GossipAggregateAndProofMessage,
p2p.GossipAttestationMessage,
// p2p.GossipBlockMessage,
// p2p.GossipAggregateAndProofMessage,
// p2p.GossipAttestationMessage,
// In relation to https://github.com/probe-lab/hermes/issues/24
// we unfortunatelly can't validate the messages (yet)
// thus, better not to forward invalid messages
//p2p.GossipExitMessage,
p2p.GossipAttesterSlashingMessage,
p2p.GossipProposerSlashingMessage,
p2p.GossipContributionAndProofMessage,
p2p.GossipSyncCommitteeMessage,
p2p.GossipBlsToExecutionChangeMessage,
// p2p.GossipExitMessage,
// p2p.GossipAttesterSlashingMessage,
// p2p.GossipProposerSlashingMessage,
// p2p.GossipContributionAndProofMessage,
// p2p.GossipSyncCommitteeMessage,
// p2p.GossipBlsToExecutionChangeMessage,
p2p.GossipBlobSidecarMessage,
}
}
Expand Down Expand Up @@ -443,12 +443,12 @@ func hasSubnets(topic string) (subnets uint64, hasSubnets bool) {
}
}

func (n *NodeConfig) composeEthTopic(base string, encoder encoder.NetworkEncoding, subnet uint64) string {
if subnet > 0 { // as far as I know, there aren't subnets with index 0
return fmt.Sprintf(base, n.ForkDigest, subnet) + encoder.ProtocolSuffix()
} else {
return fmt.Sprintf(base, n.ForkDigest) + encoder.ProtocolSuffix()
}
func (n *NodeConfig) composeEthTopic(base string, encoder encoder.NetworkEncoding) string {
return fmt.Sprintf(base, n.ForkDigest) + encoder.ProtocolSuffix()
}

func (n *NodeConfig) composeEthTopicWithSubnet(base string, encoder encoder.NetworkEncoding, subnet uint64) string {
return fmt.Sprintf(base, n.ForkDigest, subnet) + encoder.ProtocolSuffix()
}

func (n *NodeConfig) getDesiredFullTopics(encoder encoder.NetworkEncoding) []string {
Expand All @@ -463,11 +463,11 @@ func (n *NodeConfig) getDesiredFullTopics(encoder encoder.NetworkEncoding) []str
}
subnets, withSubnets := hasSubnets(topicBase)
if withSubnets {
for subnet := uint64(1); subnet <= subnets; subnet++ {
fullTopics = append(fullTopics, n.composeEthTopic(topicFormat, encoder, subnet))
for subnet := uint64(0); subnet < subnets; subnet++ {
fullTopics = append(fullTopics, n.composeEthTopicWithSubnet(topicFormat, encoder, subnet))
}
} else {
fullTopics = append(fullTopics, n.composeEthTopic(topicFormat, encoder, 0))
fullTopics = append(fullTopics, n.composeEthTopic(topicFormat, encoder))
}
}

Expand Down

0 comments on commit 1fe47e9

Please sign in to comment.