diff --git a/pkg/cannon/cannon.go b/pkg/cannon/cannon.go index 4e494073..8de4a077 100644 --- a/pkg/cannon/cannon.go +++ b/pkg/cannon/cannon.go @@ -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" @@ -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") @@ -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()) diff --git a/pkg/cannon/deriver/beacon/eth/v1/beacon_blob.go b/pkg/cannon/deriver/beacon/eth/v1/beacon_blob.go index ca07627c..52025871 100644 --- a/pkg/cannon/deriver/beacon/eth/v1/beacon_blob.go +++ b/pkg/cannon/deriver/beacon/eth/v1/beacon_blob.go @@ -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" @@ -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 { diff --git a/pkg/cannon/deriver/beacon/eth/v1/beacon_committee.go b/pkg/cannon/deriver/beacon/eth/v1/beacon_committee.go index 7f0b0e21..943cb0ff 100644 --- a/pkg/cannon/deriver/beacon/eth/v1/beacon_committee.go +++ b/pkg/cannon/deriver/beacon/eth/v1/beacon_committee.go @@ -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" @@ -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 { diff --git a/pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go b/pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go index 1d5bc5e4..169f5672 100644 --- a/pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go +++ b/pkg/cannon/deriver/beacon/eth/v1/beacon_validators.go @@ -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" @@ -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 { diff --git a/pkg/cannon/deriver/beacon/eth/v1/proposer_duty.go b/pkg/cannon/deriver/beacon/eth/v1/proposer_duty.go index f52cd268..5eec0847 100644 --- a/pkg/cannon/deriver/beacon/eth/v1/proposer_duty.go +++ b/pkg/cannon/deriver/beacon/eth/v1/proposer_duty.go @@ -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" @@ -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 { diff --git a/pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go b/pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go index f047b02d..7aa7cc9d 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go +++ b/pkg/cannon/deriver/beacon/eth/v2/attester_slashing.go @@ -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 { diff --git a/pkg/cannon/deriver/beacon/eth/v2/beacon_block.go b/pkg/cannon/deriver/beacon/eth/v2/beacon_block.go index 9c04a47d..3dbbbdb5 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/beacon_block.go +++ b/pkg/cannon/deriver/beacon/eth/v2/beacon_block.go @@ -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 { 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 740362e1..ab07828e 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 @@ -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 { diff --git a/pkg/cannon/deriver/beacon/eth/v2/deposit.go b/pkg/cannon/deriver/beacon/eth/v2/deposit.go index 9eb3f558..1d3b389c 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/deposit.go +++ b/pkg/cannon/deriver/beacon/eth/v2/deposit.go @@ -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) { diff --git a/pkg/cannon/deriver/beacon/eth/v2/elaborated_attestation.go b/pkg/cannon/deriver/beacon/eth/v2/elaborated_attestation.go index dc3d74e4..ad9bf8c4 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/elaborated_attestation.go +++ b/pkg/cannon/deriver/beacon/eth/v2/elaborated_attestation.go @@ -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) { diff --git a/pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go b/pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go index 69a6f7ad..02b23ff4 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go +++ b/pkg/cannon/deriver/beacon/eth/v2/execution_transaction.go @@ -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 { diff --git a/pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go b/pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go index f265273f..17537f39 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go +++ b/pkg/cannon/deriver/beacon/eth/v2/proposer_slashing.go @@ -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) { diff --git a/pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go b/pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go index 9cbcc9b8..f402d300 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go +++ b/pkg/cannon/deriver/beacon/eth/v2/voluntary_exit.go @@ -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 { diff --git a/pkg/cannon/deriver/beacon/eth/v2/withdrawal.go b/pkg/cannon/deriver/beacon/eth/v2/withdrawal.go index ef54a18e..585f09be 100644 --- a/pkg/cannon/deriver/beacon/eth/v2/withdrawal.go +++ b/pkg/cannon/deriver/beacon/eth/v2/withdrawal.go @@ -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) { diff --git a/pkg/cannon/deriver/blockprint/block_classification.go b/pkg/cannon/deriver/blockprint/block_classification.go index 1033c875..d2086609 100644 --- a/pkg/cannon/deriver/blockprint/block_classification.go +++ b/pkg/cannon/deriver/blockprint/block_classification.go @@ -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" @@ -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 { diff --git a/pkg/cannon/deriver/event_deriver.go b/pkg/cannon/deriver/event_deriver.go index 8aa42ed5..e89090b2 100644 --- a/pkg/cannon/deriver/event_deriver.go +++ b/pkg/cannon/deriver/event_deriver.go @@ -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" @@ -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 diff --git a/pkg/cannon/ethereum/forks.go b/pkg/cannon/ethereum/forks.go deleted file mode 100644 index 2fd6d1d5..00000000 --- a/pkg/cannon/ethereum/forks.go +++ /dev/null @@ -1,10 +0,0 @@ -package ethereum - -var ( - ForkNamePhase0 = "PHASE0" - ForkNameAltair = "ALTAIR" - ForkNameBellatrix = "BELLATRIX" - ForkNameCapella = "CAPELLA" - ForkNameDeneb = "DENEB" - ForkNameElectra = "ELECTRA" -)