Skip to content

Commit

Permalink
Revert "Auxiliary commit to revert individual files from deadb21"
Browse files Browse the repository at this point in the history
This reverts commit 32ad5009537bc5ec0e6caf9f52143d380d00be85.
  • Loading branch information
rkapka committed Apr 17, 2024
1 parent deadb21 commit 02e6b21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
32 changes: 16 additions & 16 deletions beacon-chain/p2p/gossip_topic_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ import (

// gossipTopicMappings represent the protocol ID to protobuf message type map for easy
// lookup.
var gossipTopicMappings = map[string][]proto.Message{
BlockSubnetTopicFormat: {&ethpb.SignedBeaconBlock{}},
AttestationSubnetTopicFormat: {&ethpb.Attestation{}, &ethpb.AttestationElectra{}},
ExitSubnetTopicFormat: {&ethpb.SignedVoluntaryExit{}},
ProposerSlashingSubnetTopicFormat: {&ethpb.ProposerSlashing{}},
AttesterSlashingSubnetTopicFormat: {&ethpb.AttesterSlashing{}},
AggregateAndProofSubnetTopicFormat: {&ethpb.SignedAggregateAttestationAndProof{}},
SyncContributionAndProofSubnetTopicFormat: {&ethpb.SignedContributionAndProof{}},
SyncCommitteeSubnetTopicFormat: {&ethpb.SyncCommitteeMessage{}},
BlsToExecutionChangeSubnetTopicFormat: {&ethpb.SignedBLSToExecutionChange{}},
BlobSubnetTopicFormat: {&ethpb.BlobSidecar{}},
var gossipTopicMappings = map[string]proto.Message{
BlockSubnetTopicFormat: &ethpb.SignedBeaconBlock{},
AttestationSubnetTopicFormat: &ethpb.Attestation{}, // TODO: how to extend to Electra?
ExitSubnetTopicFormat: &ethpb.SignedVoluntaryExit{},
ProposerSlashingSubnetTopicFormat: &ethpb.ProposerSlashing{},
AttesterSlashingSubnetTopicFormat: &ethpb.AttesterSlashing{},
AggregateAndProofSubnetTopicFormat: &ethpb.SignedAggregateAttestationAndProof{},
SyncContributionAndProofSubnetTopicFormat: &ethpb.SignedContributionAndProof{},
SyncCommitteeSubnetTopicFormat: &ethpb.SyncCommitteeMessage{},
BlsToExecutionChangeSubnetTopicFormat: &ethpb.SignedBLSToExecutionChange{},
BlobSubnetTopicFormat: &ethpb.BlobSidecar{},
}

// GossipTopicMappings is a function to return the assigned data type
// versioned by epoch.
func GossipTopicMappings(topic string, epoch primitives.Epoch) []proto.Message {
func GossipTopicMappings(topic string, epoch primitives.Epoch) proto.Message {
if topic == BlockSubnetTopicFormat {
if epoch >= params.BeaconConfig().DenebForkEpoch {
return []proto.Message{&ethpb.SignedBeaconBlockDeneb{}}
return &ethpb.SignedBeaconBlockDeneb{}
}
if epoch >= params.BeaconConfig().CapellaForkEpoch {
return []proto.Message{&ethpb.SignedBeaconBlockCapella{}}
return &ethpb.SignedBeaconBlockCapella{}
}
if epoch >= params.BeaconConfig().BellatrixForkEpoch {
return []proto.Message{&ethpb.SignedBeaconBlockBellatrix{}}
return &ethpb.SignedBeaconBlockBellatrix{}
}
if epoch >= params.BeaconConfig().AltairForkEpoch {
return []proto.Message{&ethpb.SignedBeaconBlockAltair{}}
return &ethpb.SignedBeaconBlockAltair{}
}
}
return gossipTopicMappings[topic]
Expand Down
11 changes: 2 additions & 9 deletions beacon-chain/sync/decode_pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,9 @@ func (s *Service) decodePubsubMessage(msg *pubsub.Message) (ssz.Unmarshaler, err
if base == nil {
return nil, p2p.ErrMessageNotMapped
}
var m ssz.Unmarshaler
var ok bool
for _, b := range base {
m, ok = proto.Clone(b).(ssz.Unmarshaler)
if ok {
break
}
}
m, ok := proto.Clone(base).(ssz.Unmarshaler)
if !ok {
return nil, errors.Errorf("messages for topic %s do not support marshaller interface", topic)
return nil, errors.Errorf("message of %T does not support marshaller interface", base)
}
// Handle different message types across forks.
if topic == p2p.BlockSubnetTopicFormat {
Expand Down

0 comments on commit 02e6b21

Please sign in to comment.