Fix no custody info available at start (#15732)

* Change wrap message to avoid the could not...: could not...: could not... effect.

Reference: https://github.com/uber-go/guide/blob/master/style.md#error-wrapping.

* Log: remove period at the end of the latest sentence.

* Dirty quick fix to ensure that the custody group count is set at P2P service start.

A real fix would involve a chan implement a proper synchronization scheme.

* Add changelog.
This commit is contained in:
Manu NALEPA
2025-09-23 16:09:29 +02:00
committed by GitHub
parent 606294e17f
commit 80eba4e6dd
4 changed files with 32 additions and 15 deletions

View File

@@ -122,18 +122,18 @@ type BlobStorage struct {
func (bs *BlobStorage) WarmCache() { func (bs *BlobStorage) WarmCache() {
start := time.Now() start := time.Now()
if bs.layoutName == LayoutNameFlat { if bs.layoutName == LayoutNameFlat {
log.Info("Blob filesystem cache warm-up started. This may take a few minutes.") log.Info("Blob filesystem cache warm-up started. This may take a few minutes")
} else { } else {
log.Info("Blob filesystem cache warm-up started.") log.Info("Blob filesystem cache warm-up started")
} }
if err := warmCache(bs.layout, bs.cache); err != nil { if err := warmCache(bs.layout, bs.cache); err != nil {
log.WithError(err).Error("Error encountered while warming up blob filesystem cache.") log.WithError(err).Error("Error encountered while warming up blob filesystem cache")
} }
if err := bs.migrateLayouts(); err != nil { if err := bs.migrateLayouts(); err != nil {
log.WithError(err).Error("Error encountered while migrating blob storage.") log.WithError(err).Error("Error encountered while migrating blob storage")
} }
log.WithField("elapsed", time.Since(start)).Info("Blob filesystem cache warm-up complete.") log.WithField("elapsed", time.Since(start)).Info("Blob filesystem cache warm-up complete")
} }
// If any blob storage directories are found for layouts besides the configured layout, migrate them. // If any blob storage directories are found for layouts besides the configured layout, migrate them.

View File

@@ -10,6 +10,8 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var errNoCustodyInfo = errors.New("no custody info available")
var _ CustodyManager = (*Service)(nil) var _ CustodyManager = (*Service)(nil)
// EarliestAvailableSlot returns the earliest available slot. // EarliestAvailableSlot returns the earliest available slot.
@@ -30,7 +32,7 @@ func (s *Service) CustodyGroupCount() (uint64, error) {
defer s.custodyInfoLock.Unlock() defer s.custodyInfoLock.Unlock()
if s.custodyInfo == nil { if s.custodyInfo == nil {
return 0, errors.New("no custody info available") return 0, errNoCustodyInfo
} }
return s.custodyInfo.groupCount, nil return s.custodyInfo.groupCount, nil

View File

@@ -79,7 +79,7 @@ func (quicProtocol) ENRKey() string { return quickProtocolEnrKey }
func newListener(listenerCreator func() (*discover.UDPv5, error)) (*listenerWrapper, error) { func newListener(listenerCreator func() (*discover.UDPv5, error)) (*listenerWrapper, error) {
rawListener, err := listenerCreator() rawListener, err := listenerCreator()
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not create new listener") return nil, errors.Wrap(err, "create new listener")
} }
return &listenerWrapper{ return &listenerWrapper{
listener: rawListener, listener: rawListener,
@@ -536,7 +536,7 @@ func (s *Service) createListener(
int(s.cfg.QUICPort), int(s.cfg.QUICPort),
) )
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not create local node") return nil, errors.Wrap(err, "create local node")
} }
bootNodes := make([]*enode.Node, 0, len(s.cfg.Discv5BootStrapAddrs)) bootNodes := make([]*enode.Node, 0, len(s.cfg.Discv5BootStrapAddrs))
@@ -604,13 +604,26 @@ func (s *Service) createLocalNode(
localNode = initializeSyncCommSubnets(localNode) localNode = initializeSyncCommSubnets(localNode)
if params.FuluEnabled() { if params.FuluEnabled() {
custodyGroupCount, err := s.CustodyGroupCount() // TODO: Replace this quick fix with a proper synchronization scheme (chan?)
if err != nil { const delay = 1 * time.Second
return nil, errors.Wrap(err, "could not retrieve custody group count")
}
custodyGroupCountEntry := peerdas.Cgc(custodyGroupCount) var custodyGroupCount uint64
localNode.Set(custodyGroupCountEntry)
err := errNoCustodyInfo
for errors.Is(err, errNoCustodyInfo) {
custodyGroupCount, err = s.CustodyGroupCount()
if errors.Is(err, errNoCustodyInfo) {
log.WithField("delay", delay).Debug("No custody info available yet, retrying later")
continue
}
if err != nil {
return nil, errors.Wrap(err, "retrieve custody group count")
}
custodyGroupCountEntry := peerdas.Cgc(custodyGroupCount)
localNode.Set(custodyGroupCountEntry)
}
} }
if s.cfg != nil && s.cfg.HostAddress != "" { if s.cfg != nil && s.cfg.HostAddress != "" {
@@ -652,7 +665,7 @@ func (s *Service) startDiscoveryV5(
} }
wrappedListener, err := newListener(createListener) wrappedListener, err := newListener(createListener)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not create listener") return nil, errors.Wrap(err, "create listener")
} }
record := wrappedListener.Self() record := wrappedListener.Self()

View File

@@ -0,0 +1,2 @@
### Fixed
- In P2P service start, wait for the custody info to be correctly initialized.