Skip to content

Commit

Permalink
fix(cannon): Use consistent fork type (#419)
Browse files Browse the repository at this point in the history
* fix(server): Add details about client sending data without a module name

* fix(cannon): Use consistent fork type
  • Loading branch information
samcm authored Dec 2, 2024
1 parent a3efc43 commit d4847e4
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 41 deletions.
5 changes: 3 additions & 2 deletions pkg/cannon/cannon.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
//nolint:gosec // only exposed if pprofAddr config is set
_ "net/http/pprof"

"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/beevik/ntp"
"github.com/ethpandaops/ethwallclock"
Expand Down Expand Up @@ -690,7 +691,7 @@ func (c *Cannon) startDeriverWhenReady(ctx context.Context, d deriver.EventDeriv
for {
// Handle derivers that require phase0, since its not actually a fork it'll never appear
// in the spec.
if d.ActivationFork() != ethereum.ForkNamePhase0 {
if d.ActivationFork() != spec.DataVersionPhase0 {
spec, err := c.beacon.Node().Spec()
if err != nil {
c.log.WithError(err).Error("Failed to get spec")
Expand All @@ -700,7 +701,7 @@ func (c *Cannon) startDeriverWhenReady(ctx context.Context, d deriver.EventDeriv
continue
}

fork, err := spec.ForkEpochs.GetByName(d.ActivationFork())
fork, err := spec.ForkEpochs.GetByName(d.ActivationFork().String())
if err != nil {
c.log.WithError(err).Errorf("unknown activation fork: %s", d.ActivationFork())

Expand Down
5 changes: 3 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v1/beacon_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/attestantio/go-eth2-client/api"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
backoff "github.com/cenkalti/backoff/v4"
Expand Down Expand Up @@ -61,8 +62,8 @@ func (b *BeaconBlobDeriver) CannonType() xatu.CannonType {
return BeaconBlobDeriverName
}

func (b *BeaconBlobDeriver) ActivationFork() string {
return ethereum.ForkNameDeneb
func (b *BeaconBlobDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionDeneb
}

func (b *BeaconBlobDeriver) Name() string {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v1/beacon_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
backoff "github.com/cenkalti/backoff/v4"
"github.com/ethpandaops/xatu/pkg/cannon/ethereum"
Expand Down Expand Up @@ -59,8 +60,8 @@ func (b *BeaconCommitteeDeriver) CannonType() xatu.CannonType {
return BeaconCommitteeDeriverName
}

func (b *BeaconCommitteeDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *BeaconCommitteeDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *BeaconCommitteeDeriver) Name() string {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
backoff "github.com/cenkalti/backoff/v4"
"github.com/ethpandaops/xatu/pkg/cannon/ethereum"
Expand Down Expand Up @@ -60,8 +61,8 @@ func (b *BeaconValidatorsDeriver) CannonType() xatu.CannonType {
return BeaconValidatorsDeriverName
}

func (b *BeaconValidatorsDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *BeaconValidatorsDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *BeaconValidatorsDeriver) Name() string {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v1/proposer_duty.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
backoff "github.com/cenkalti/backoff/v4"
"github.com/ethpandaops/xatu/pkg/cannon/ethereum"
Expand Down Expand Up @@ -60,8 +61,8 @@ func (b *ProposerDutyDeriver) CannonType() xatu.CannonType {
return ProposerDutyDeriverName
}

func (b *ProposerDutyDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *ProposerDutyDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *ProposerDutyDeriver) Name() string {
Expand Down
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 @@ -58,8 +58,8 @@ func (a *AttesterSlashingDeriver) CannonType() xatu.CannonType {
return AttesterSlashingDeriverName
}

func (a *AttesterSlashingDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (a *AttesterSlashingDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (a *AttesterSlashingDeriver) Name() string {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/beacon_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (b *BeaconBlockDeriver) CannonType() xatu.CannonType {
return BeaconBlockDeriverName
}

func (b *BeaconBlockDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *BeaconBlockDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *BeaconBlockDeriver) Name() string {
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 @@ -68,8 +68,8 @@ func (b *BLSToExecutionChangeDeriver) OnEventsDerived(ctx context.Context, fn fu
b.onEventsCallbacks = append(b.onEventsCallbacks, fn)
}

func (b *BLSToExecutionChangeDeriver) ActivationFork() string {
return ethereum.ForkNameCapella
func (b *BLSToExecutionChangeDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionCapella
}

func (b *BLSToExecutionChangeDeriver) Start(ctx context.Context) error {
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 @@ -62,8 +62,8 @@ func (b *DepositDeriver) Name() string {
return DepositDeriverName.String()
}

func (b *DepositDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *DepositDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *DepositDeriver) OnEventsDerived(ctx context.Context, fn func(ctx context.Context, events []*xatu.DecoratedEvent) error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cannon/deriver/beacon/eth/v2/elaborated_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (b *ElaboratedAttestationDeriver) Name() string {
return ElaboratedAttestationDeriverName.String()
}

func (b *ElaboratedAttestationDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *ElaboratedAttestationDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *ElaboratedAttestationDeriver) OnEventsDerived(ctx context.Context, fn func(ctx context.Context, events []*xatu.DecoratedEvent) error) {
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 @@ -63,8 +63,8 @@ func (b *ExecutionTransactionDeriver) CannonType() xatu.CannonType {
return ExecutionTransactionDeriverName
}

func (b *ExecutionTransactionDeriver) ActivationFork() string {
return ethereum.ForkNameBellatrix
func (b *ExecutionTransactionDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionBellatrix
}

func (b *ExecutionTransactionDeriver) Name() string {
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 @@ -62,8 +62,8 @@ func (b *ProposerSlashingDeriver) Name() string {
return ProposerSlashingDeriverName.String()
}

func (b *ProposerSlashingDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *ProposerSlashingDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *ProposerSlashingDeriver) OnEventsDerived(ctx context.Context, fn func(ctx context.Context, events []*xatu.DecoratedEvent) error) {
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 @@ -58,8 +58,8 @@ func (b *VoluntaryExitDeriver) CannonType() xatu.CannonType {
return VoluntaryExitDeriverName
}

func (b *VoluntaryExitDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *VoluntaryExitDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *VoluntaryExitDeriver) Name() string {
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 @@ -62,8 +62,8 @@ func (b *WithdrawalDeriver) Name() string {
return WithdrawalDeriverName.String()
}

func (b *WithdrawalDeriver) ActivationFork() string {
return ethereum.ForkNameCapella
func (b *WithdrawalDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionCapella
}

func (b *WithdrawalDeriver) OnEventsDerived(ctx context.Context, fn func(ctx context.Context, events []*xatu.DecoratedEvent) error) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cannon/deriver/blockprint/block_classification.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
backoff "github.com/cenkalti/backoff/v4"
aBlockprint "github.com/ethpandaops/xatu/pkg/cannon/blockprint"
Expand Down Expand Up @@ -67,8 +68,8 @@ func (b *BlockClassificationDeriver) CannonType() xatu.CannonType {
return BlockClassificationName
}

func (b *BlockClassificationDeriver) ActivationFork() string {
return ethereum.ForkNamePhase0
func (b *BlockClassificationDeriver) ActivationFork() spec.DataVersion {
return spec.DataVersionPhase0
}

func (b *BlockClassificationDeriver) Name() string {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cannon/deriver/event_deriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package deriver
import (
"context"

"github.com/attestantio/go-eth2-client/spec"
v1 "github.com/ethpandaops/xatu/pkg/cannon/deriver/beacon/eth/v1"
v2 "github.com/ethpandaops/xatu/pkg/cannon/deriver/beacon/eth/v2"
"github.com/ethpandaops/xatu/pkg/cannon/deriver/blockprint"
Expand All @@ -17,7 +18,7 @@ type EventDeriver interface {
// Callbacks
OnEventsDerived(ctx context.Context, fn func(ctx context.Context, events []*xatu.DecoratedEvent) error)
// ActivationFork is the fork at which the deriver should start deriving events
ActivationFork() string
ActivationFork() spec.DataVersion
}

// Ensure that derivers implements the EventDeriver interface
Expand Down
10 changes: 0 additions & 10 deletions pkg/cannon/ethereum/forks.go

This file was deleted.

0 comments on commit d4847e4

Please sign in to comment.