diff --git a/CHANGELOG.md b/CHANGELOG.md index b7e585ca8f..db3c856a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve ### Fixed - Added check to prevent nil pointer deference or out of bounds array access when validating the BLSToExecutionChange on an impossibly nil validator. +- EIP-7691: Ensure new blobs subnets are subscribed on epoch in advance. ### Security diff --git a/beacon-chain/sync/subscriber.go b/beacon-chain/sync/subscriber.go index 55655b7f7c..69afe97eb0 100644 --- a/beacon-chain/sync/subscriber.go +++ b/beacon-chain/sync/subscriber.go @@ -117,7 +117,7 @@ func (s *Service) registerSubscribers(epoch primitives.Epoch, digest [4]byte) { s.persistentAndAggregatorSubnetIndices, s.attesterSubnetIndices, ) - // Altair Fork Version + // Altair fork version if params.BeaconConfig().AltairForkEpoch <= epoch { s.subscribe( p2p.SyncContributionAndProofSubnetTopicFormat, @@ -135,7 +135,7 @@ func (s *Service) registerSubscribers(epoch primitives.Epoch, digest [4]byte) { ) } - // New Gossip Topic in Capella + // New gossip topic in Capella if params.BeaconConfig().CapellaForkEpoch <= epoch { s.subscribe( p2p.BlsToExecutionChangeSubnetTopicFormat, @@ -145,28 +145,33 @@ func (s *Service) registerSubscribers(epoch primitives.Epoch, digest [4]byte) { ) } - // New Gossip Topic in Deneb - if params.BeaconConfig().DenebForkEpoch <= epoch { + // New gossip topic in Deneb, modified in Electra + if params.BeaconConfig().DenebForkEpoch <= epoch && epoch < params.BeaconConfig().ElectraForkEpoch { s.subscribeWithParameters( p2p.BlobSubnetTopicFormat, s.validateBlob, s.blobSubscriber, digest, - blobSubnetSlice, + func(currentSlot primitives.Slot) []uint64 { + return sliceFromCount(params.BeaconConfig().BlobsidecarSubnetCount) + }, func(currentSlot primitives.Slot) []uint64 { return []uint64{} }, ) } -} -// blobSubnetSlice returns the blob subnet slice for the given slot. -func blobSubnetSlice(currentSlot primitives.Slot) []uint64 { - currentEpoch := slots.ToEpoch(currentSlot) - - if currentEpoch >= params.BeaconConfig().ElectraForkEpoch { - return sliceFromCount(params.BeaconConfig().BlobsidecarSubnetCountElectra) + // Modified gossip topic in Electra + if params.BeaconConfig().ElectraForkEpoch <= epoch { + s.subscribeWithParameters( + p2p.BlobSubnetTopicFormat, + s.validateBlob, + s.blobSubscriber, + digest, + func(currentSlot primitives.Slot) []uint64 { + return sliceFromCount(params.BeaconConfig().BlobsidecarSubnetCountElectra) + }, + func(currentSlot primitives.Slot) []uint64 { return []uint64{} }, + ) } - - return sliceFromCount(params.BeaconConfig().BlobsidecarSubnetCount) } // subscribe to a given topic with a given validator and subscription handler. @@ -440,7 +445,14 @@ func (s *Service) subscribeToSubnets( description = topicFormat[pos+1:] } - log.WithField("digest", fmt.Sprintf("%#x", digest)).Warningf("%s subnets with this digest are no longer valid, unsubscribing from all of them.", description) + if pos := strings.LastIndex(description, "_"); pos != -1 { + description = description[:pos] + } + + log.WithFields(logrus.Fields{ + "digest": fmt.Sprintf("%#x", digest), + "subnets": description, + }).Debug("Subnets with this digest are no longer valid, unsubscribing from all of them") s.reValidateSubscriptions(subscriptions, []uint64{}, topicFormat, digest) return false }