diff --git a/beacon-chain/p2p/discovery.go b/beacon-chain/p2p/discovery.go index a8b0f59d6bb3..eeb03c8f15ec 100644 --- a/beacon-chain/p2p/discovery.go +++ b/beacon-chain/p2p/discovery.go @@ -181,9 +181,16 @@ func (s *Service) RefreshPersistentSubnets() { // Get the current attestation subnet bitfield. bitV := bitfield.NewBitvector64() - attestationCommittees := cache.SubnetIDs.GetAllSubnets() - for _, idx := range attestationCommittees { - bitV.SetBitAt(idx, true) + if flags.Get().SubscribeToAllSubnets { + // Set all 64 bits for all attestation subnets + for i := uint64(0); i < params.BeaconConfig().AttestationSubnetCount; i++ { + bitV.SetBitAt(i, true) + } + } else { + attestationCommittees := cache.SubnetIDs.GetAllSubnets() + for _, idx := range attestationCommittees { + bitV.SetBitAt(idx, true) + } } // Get the attestation subnet bitfield we store in our record. diff --git a/changelog/samcm_fix-attnets-metadata-all-subnets.md b/changelog/samcm_fix-attnets-metadata-all-subnets.md new file mode 100644 index 000000000000..e903d59ac76b --- /dev/null +++ b/changelog/samcm_fix-attnets-metadata-all-subnets.md @@ -0,0 +1,3 @@ +### Fixed + +- Fixed `--subscribe-all-subnets` flag to correctly advertise all 64 attestation subnets in reqresp metadata.