From e9fe5c1fefd928d9e0fc93c20dfd41721087cf20 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Wed, 9 Oct 2024 15:24:04 +1000 Subject: [PATCH] Revert "feat(sentry): Improve startup procedure (#393)" This reverts commit 0aa3b3c0a9bfb5c694bd811e84e940fc8e016bbe. --- go.mod | 2 +- go.sum | 4 ++-- pkg/sentry/ethereum/beacon.go | 25 +++--------------------- pkg/sentry/ethereum/services/metadata.go | 6 +----- 4 files changed, 7 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index e482e1ad..d00f81b4 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 github.com/creasty/defaults v1.7.0 github.com/ethereum/go-ethereum v1.14.10 - github.com/ethpandaops/beacon v0.42.0 + github.com/ethpandaops/beacon v0.41.0 github.com/ethpandaops/ethcore v0.0.0-20240422023000-2a5727b18756 github.com/ethpandaops/ethwallclock v0.3.0 github.com/go-co-op/gocron v1.27.1 diff --git a/go.sum b/go.sum index 6f63c6a0..5b9a9184 100644 --- a/go.sum +++ b/go.sum @@ -248,8 +248,8 @@ github.com/ethereum/go-ethereum v1.14.10 h1:kC24WjYeRjDy86LVo6MfF5Xs7nnUu+XG4Aja github.com/ethereum/go-ethereum v1.14.10/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= -github.com/ethpandaops/beacon v0.42.0 h1:5a3ld5wuAgX+N5KxEPuNfxDhdeiBG4gXlTAgCm0AuSE= -github.com/ethpandaops/beacon v0.42.0/go.mod h1:hKfalJGsF4BuWPwcGCX/4fdQR31zDJVaTLWwrkfNTzw= +github.com/ethpandaops/beacon v0.41.0 h1:9CmgNeTZ6X+B1U7SOJzy3rf6WFtFb3CA2DTFEgGwLc8= +github.com/ethpandaops/beacon v0.41.0/go.mod h1:hKfalJGsF4BuWPwcGCX/4fdQR31zDJVaTLWwrkfNTzw= github.com/ethpandaops/ethcore v0.0.0-20240422023000-2a5727b18756 h1:8JWjrRfP14m0oxOk03m11n/xgdY5ceyUf/ZxYdOs5gE= github.com/ethpandaops/ethcore v0.0.0-20240422023000-2a5727b18756/go.mod h1:ZvKqL6CKxiraefdXPHeJurV2pDD/f2HF2uklDVdrry8= github.com/ethpandaops/ethwallclock v0.3.0 h1:xF5fwtBf+bHFHZKBnwiPFEuelW3sMM7SD3ZNFq1lJY4= diff --git a/pkg/sentry/ethereum/beacon.go b/pkg/sentry/ethereum/beacon.go index 3f0b208c..aaaf739b 100644 --- a/pkg/sentry/ethereum/beacon.go +++ b/pkg/sentry/ethereum/beacon.go @@ -67,13 +67,8 @@ func (b *BeaconNode) Start(ctx context.Context) error { s := gocron.NewScheduler(time.Local) errs := make(chan error, 1) - healthyFirstTime := make(chan struct{}) - - b.beacon.OnFirstTimeHealthy(ctx, func(ctx context.Context, event *beacon.FirstTimeHealthyEvent) error { - b.log.Info("Upstream beacon node is healthy") - - close(healthyFirstTime) + go func() { wg := sync.WaitGroup{} for _, service := range b.services { @@ -93,8 +88,6 @@ func (b *BeaconNode) Start(ctx context.Context) error { errs <- fmt.Errorf("failed to start service: %w", err) } - b.log.WithField("service", service.Name()).Info("Waiting for service to be ready") - wg.Wait() } @@ -105,26 +98,14 @@ func (b *BeaconNode) Start(ctx context.Context) error { errs <- fmt.Errorf("failed to run on ready callback: %w", err) } } - - return nil - }) + }() s.StartAsync() - b.beacon.StartAsync(ctx) - - select { - case err := <-errs: + if err := b.beacon.Start(ctx); err != nil { return err - case <-ctx.Done(): - return ctx.Err() - case <-healthyFirstTime: - // Beacon node is healthy, continue with normal operation - case <-time.After(10 * time.Minute): - return errors.New("upstream beacon node is not healthy. check your configuration.") } - // Wait for any errors after the first healthy event select { case err := <-errs: return err diff --git a/pkg/sentry/ethereum/services/metadata.go b/pkg/sentry/ethereum/services/metadata.go index 7295460f..ddc2c29d 100644 --- a/pkg/sentry/ethereum/services/metadata.go +++ b/pkg/sentry/ethereum/services/metadata.go @@ -67,14 +67,10 @@ func (m *MetadataService) Start(ctx context.Context) error { return nil } - if err := backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), func(err error, duration time.Duration) { - m.log.WithError(err).Warnf("Failed to refresh metadata, retrying in %s", duration) - }); err != nil { + if err := backoff.Retry(operation, backoff.NewExponentialBackOff()); err != nil { m.log.WithError(err).Warn("Failed to refresh metadata") } - m.log.Info("Metadata service is ready") - for _, cb := range m.onReadyCallbacks { if err := cb(ctx); err != nil { m.log.WithError(err).Warn("Failed to execute onReady callback")