Skip to content

Commit

Permalink
fix(cannon): Correct slot calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Sep 27, 2023
1 parent 810ed74 commit aa76e0e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (a *AttesterSlashingDeriver) lookAheadAtLocations(ctx context.Context, loca
return
}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

// Add the block to the preload queue so it's available when we need it
Expand All @@ -181,7 +181,7 @@ func (a *AttesterSlashingDeriver) processEpoch(ctx context.Context, epoch phase0

allEvents := []*xatu.DecoratedEvent{}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

events, err := a.processSlot(ctx, slot)
Expand Down
6 changes: 4 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/beacon_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (b *BeaconBlockDeriver) lookAheadAtLocation(ctx context.Context, locations
return
}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

// Add the block to the preload queue so it's available when we need it
Expand All @@ -184,14 +184,16 @@ func (b *BeaconBlockDeriver) processEpoch(ctx context.Context, epoch phase0.Epoc

allEvents := []*xatu.DecoratedEvent{}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

events, err := b.processSlot(ctx, slot)
if err != nil {
return nil, errors.Wrapf(err, "failed to process slot %d", slot)
}

b.log.WithField("slot", slot).WithField("index", i).Debug("Created event from block")

allEvents = append(allEvents, events...)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/bls_to_execution_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (b *BLSToExecutionChangeDeriver) lookAheadAtLocation(ctx context.Context, l
return
}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

// Add the block to the preload queue so it's available when we need it
Expand All @@ -184,7 +184,7 @@ func (b *BLSToExecutionChangeDeriver) processEpoch(ctx context.Context, epoch ph

allEvents := []*xatu.DecoratedEvent{}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

events, err := b.processSlot(ctx, slot)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (b *DepositDeriver) lookAheadAtLocation(ctx context.Context, locations []*x
return
}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

// Add the block to the preload queue so it's available when we need it
Expand All @@ -182,7 +182,7 @@ func (b *DepositDeriver) processEpoch(ctx context.Context, epoch phase0.Epoch) (

allEvents := []*xatu.DecoratedEvent{}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

events, err := b.processSlot(ctx, slot)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (b *ExecutionTransactionDeriver) processEpoch(ctx context.Context, epoch ph

allEvents := []*xatu.DecoratedEvent{}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

events, err := b.processSlot(ctx, slot)
Expand All @@ -186,7 +186,7 @@ func (b *ExecutionTransactionDeriver) lookAheadAtLocation(ctx context.Context, l
return
}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

// Add the block to the preload queue so it's available when we need it
Expand Down
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (b *ProposerSlashingDeriver) processEpoch(ctx context.Context, epoch phase0

allEvents := []*xatu.DecoratedEvent{}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

events, err := b.processSlot(ctx, slot)
Expand Down Expand Up @@ -259,7 +259,7 @@ func (b *ProposerSlashingDeriver) lookAheadAtLocation(ctx context.Context, locat
return
}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

// Add the block to the preload queue so it's available when we need it
Expand Down
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (b *VoluntaryExitDeriver) lookAheadAtLocation(ctx context.Context, location
return
}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

// Add the block to the preload queue so it's available when we need it
Expand All @@ -182,7 +182,7 @@ func (b *VoluntaryExitDeriver) processEpoch(ctx context.Context, epoch phase0.Ep

allEvents := []*xatu.DecoratedEvent{}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

events, err := b.processSlot(ctx, slot)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (b *WithdrawalDeriver) processEpoch(ctx context.Context, epoch phase0.Epoch

allEvents := []*xatu.DecoratedEvent{}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

events, err := b.processSlot(ctx, slot)
Expand Down Expand Up @@ -218,7 +218,7 @@ func (b *WithdrawalDeriver) lookAheadAtLocation(ctx context.Context, locations [
return
}

for i := uint64(0); i <= uint64(sp.SlotsPerEpoch); i++ {
for i := uint64(0); i <= uint64(sp.SlotsPerEpoch-1); i++ {
slot := phase0.Slot(i + uint64(epoch)*uint64(sp.SlotsPerEpoch))

// Add the block to the preload queue so it's available when we need it
Expand Down

0 comments on commit aa76e0e

Please sign in to comment.