Skip to content

Commit

Permalink
fix(sentry): Disable older beacon committee fetching on Lodestar
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Jul 20, 2023
1 parent 819c625 commit e3947f2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions example_sentry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ forkChoice:
slotTimes:
- 4s

beaconCommittees:
enabled: true

outputs:
- name: http-sink
type: http
Expand Down
6 changes: 3 additions & 3 deletions pkg/sentry/ethereum/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ func (b *BeaconNode) Start(ctx context.Context) error {
wg.Add(1)

service.OnReady(ctx, func(ctx context.Context) error {
b.log.WithField("service", service.Name()).Info("service is ready")
b.log.WithField("service", service.Name()).Info("Service is ready")

wg.Done()

return nil
})

b.log.WithField("service", service.Name()).Info("starting service")
b.log.WithField("service", service.Name()).Info("Starting service")

if err := service.Start(ctx); err != nil {
errs <- fmt.Errorf("failed to start service: %w", err)
Expand All @@ -81,7 +81,7 @@ func (b *BeaconNode) Start(ctx context.Context) error {
wg.Wait()
}

b.log.Info("all services are ready")
b.log.Info("All services are ready")

for _, callback := range b.onReadyCallbacks {
if err := callback(ctx); err != nil {
Expand Down
18 changes: 12 additions & 6 deletions pkg/sentry/ethereum/services/duties.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,25 @@ func (m *DutiesService) Name() Name {
return "duties"
}

func (m *DutiesService) RequiredEpochDuties() []phase0.Epoch {
func (m *DutiesService) RequiredEpochDuties(ctx context.Context) []phase0.Epoch {
now := m.beacon.Wallclock().Epochs().Current()

epochNumber := now.Number()

epochs := []phase0.Epoch{
phase0.Epoch(epochNumber - 3),
phase0.Epoch(epochNumber - 2),
phase0.Epoch(epochNumber - 1),
phase0.Epoch(epochNumber),
phase0.Epoch(epochNumber + 1),
}

// Lodestar does not support fetching beacon committees for older epochs.
if m.metadata.Client(ctx) != string(ClientLodestar) {
epochs = append(epochs,
phase0.Epoch(epochNumber-1),
phase0.Epoch(epochNumber-2),
phase0.Epoch(epochNumber-3),
)
}

final := map[phase0.Epoch]struct{}{}

// Deduplicate in case the current epoch is below epoch 3.
Expand All @@ -133,7 +139,7 @@ func (m *DutiesService) RequiredEpochDuties() []phase0.Epoch {
}

func (m *DutiesService) Ready(ctx context.Context) error {
for _, epoch := range m.RequiredEpochDuties() {
for _, epoch := range m.RequiredEpochDuties(ctx) {
if duties := m.beaconCommittees.Get(epoch); duties == nil {
return fmt.Errorf("duties for epoch %d are not ready", epoch)
}
Expand All @@ -147,7 +153,7 @@ func (m *DutiesService) backFillEpochDuties(ctx context.Context) error {
return fmt.Errorf("metadata service is not ready")
}

for _, epoch := range m.RequiredEpochDuties() {
for _, epoch := range m.RequiredEpochDuties(ctx) {
if duties := m.beaconCommittees.Get(epoch); duties == nil {
if err := m.fetchBeaconCommittee(ctx, epoch); err != nil {
return err
Expand Down

0 comments on commit e3947f2

Please sign in to comment.