diff --git a/pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go b/pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go index babddf08..5d994868 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go +++ b/pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go @@ -178,14 +178,14 @@ func (a *AttesterSlashingDeriver) processSlot(ctx context.Context, slot phase0.S return []*xatu.DecoratedEvent{}, nil } - blockIdentifier, err := GetBlockIdentifier(block, a.beacon.Metadata().Wallclock()) - if err != nil { - return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) - } - events := []*xatu.DecoratedEvent{} for _, slashing := range a.getAttesterSlashings(ctx, block) { + blockIdentifier, err := GetBlockIdentifier(block, a.beacon.Metadata().Wallclock()) + if err != nil { + return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) + } + event, err := a.createEvent(ctx, slashing, blockIdentifier) if err != nil { a.log.WithError(err).Error("Failed to create event") diff --git a/pkg/cannon/deriver/beacon/eth/v2/bls_to_execution_change.go b/pkg/cannon/deriver/beacon/eth/v2/bls_to_execution_change.go index e62d5775..717e72ad 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/bls_to_execution_change.go +++ b/pkg/cannon/deriver/beacon/eth/v2/bls_to_execution_change.go @@ -181,11 +181,6 @@ func (b *BLSToExecutionChangeDeriver) processSlot(ctx context.Context, slot phas return []*xatu.DecoratedEvent{}, nil } - blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) - if err != nil { - return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) - } - events := []*xatu.DecoratedEvent{} changes, err := b.getBLSToExecutionChanges(ctx, block) @@ -194,6 +189,11 @@ func (b *BLSToExecutionChangeDeriver) processSlot(ctx context.Context, slot phas } for _, change := range changes { + blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) + if err != nil { + return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) + } + event, err := b.createEvent(ctx, change, blockIdentifier) if err != nil { b.log.WithError(err).Error("Failed to create event") diff --git a/pkg/cannon/deriver/beacon/eth/v2/deposit.go b/pkg/cannon/deriver/beacon/eth/v2/deposit.go index 4188e926..6b4a90d2 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/deposit.go +++ b/pkg/cannon/deriver/beacon/eth/v2/deposit.go @@ -179,19 +179,19 @@ func (b *DepositDeriver) processSlot(ctx context.Context, slot phase0.Slot) ([]* return []*xatu.DecoratedEvent{}, nil } - blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) - if err != nil { - return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) - } - events := []*xatu.DecoratedEvent{} deposits, err := b.getDeposits(ctx, block) if err != nil { - return nil, errors.Wrapf(err, "failed to get deposits for block %s", blockIdentifier.String()) + return nil, errors.Wrapf(err, "failed to get deposits for slot %d", slot) } for _, deposit := range deposits { + blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) + if err != nil { + return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) + } + event, err := b.createEvent(ctx, deposit, blockIdentifier) if err != nil { b.log.WithError(err).Error("Failed to create event") diff --git a/pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go b/pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go index f8fd3dd8..5eccdd74 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go +++ b/pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go @@ -182,11 +182,6 @@ func (b *ExecutionTransactionDeriver) processSlot(ctx context.Context, slot phas return []*xatu.DecoratedEvent{}, nil } - blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) - if err != nil { - return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) - } - events := []*xatu.DecoratedEvent{} transactions, err := b.getExecutionTransactions(ctx, block) @@ -195,6 +190,11 @@ func (b *ExecutionTransactionDeriver) processSlot(ctx context.Context, slot phas } for index, transaction := range transactions { + blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) + if err != nil { + return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) + } + from, err := types.Sender(types.LatestSignerForChainID(transaction.ChainId()), transaction) if err != nil { return nil, fmt.Errorf("failed to get transaction sender: %v", err) diff --git a/pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go b/pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go index a6ccb8cb..e54bae06 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go +++ b/pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go @@ -178,11 +178,6 @@ func (b *ProposerSlashingDeriver) processSlot(ctx context.Context, slot phase0.S return []*xatu.DecoratedEvent{}, nil } - blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) - if err != nil { - return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) - } - events := []*xatu.DecoratedEvent{} slashings, err := b.getProposerSlashings(ctx, block) @@ -191,6 +186,11 @@ func (b *ProposerSlashingDeriver) processSlot(ctx context.Context, slot phase0.S } for _, slashing := range slashings { + blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) + if err != nil { + return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) + } + event, err := b.createEvent(ctx, slashing, blockIdentifier) if err != nil { b.log.WithError(err).Error("Failed to create event") diff --git a/pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go b/pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go index f877803a..6e2044fe 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go +++ b/pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go @@ -179,11 +179,6 @@ func (b *VoluntaryExitDeriver) processSlot(ctx context.Context, slot phase0.Slot return []*xatu.DecoratedEvent{}, nil } - blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) - if err != nil { - return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) - } - events := []*xatu.DecoratedEvent{} exits, err := b.getVoluntaryExits(ctx, block) @@ -192,6 +187,11 @@ func (b *VoluntaryExitDeriver) processSlot(ctx context.Context, slot phase0.Slot } for _, exit := range exits { + blockIdentifier, err := GetBlockIdentifier(block, b.beacon.Metadata().Wallclock()) + if err != nil { + return nil, errors.Wrapf(err, "failed to get block identifier for slot %d", slot) + } + event, err := b.createEvent(ctx, exit, blockIdentifier) if err != nil { b.log.WithError(err).Error("Failed to create event")