diff --git a/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_bls_to_execution_change.go b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_bls_to_execution_change.go new file mode 100644 index 00000000..a1e983c2 --- /dev/null +++ b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_bls_to_execution_change.go @@ -0,0 +1,42 @@ +package v2 + +import ( + "context" + "errors" + + "github.com/ethpandaops/xatu/pkg/proto/xatu" + "github.com/sirupsen/logrus" +) + +const ( + BeaconBlockBLSToExecutionChangeType = "BEACON_API_ETH_V2_BEACON_BLOCK_BLS_TO_EXECUTION_CHANGE" +) + +type BeaconBlockBLSToExecutionChange struct { + log logrus.FieldLogger + event *xatu.DecoratedEvent +} + +func NewBeaconBlockBLSToExecutionChange(log logrus.FieldLogger, event *xatu.DecoratedEvent) *BeaconBlockBLSToExecutionChange { + return &BeaconBlockBLSToExecutionChange{ + log: log.WithField("event", BeaconBlockBLSToExecutionChangeType), + event: event, + } +} + +func (b *BeaconBlockBLSToExecutionChange) Type() string { + return BeaconBlockBLSToExecutionChangeType +} + +func (b *BeaconBlockBLSToExecutionChange) Validate(ctx context.Context) error { + _, ok := b.event.Data.(*xatu.DecoratedEvent_EthV2BeaconBlockBlsToExecutionChange) + if !ok { + return errors.New("failed to cast event data") + } + + return nil +} + +func (b *BeaconBlockBLSToExecutionChange) Filter(ctx context.Context) bool { + return false +} diff --git a/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_deposit.go b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_deposit.go new file mode 100644 index 00000000..578694f5 --- /dev/null +++ b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_deposit.go @@ -0,0 +1,42 @@ +package v2 + +import ( + "context" + "errors" + + "github.com/ethpandaops/xatu/pkg/proto/xatu" + "github.com/sirupsen/logrus" +) + +const ( + BeaconBlockDepositType = "BEACON_API_ETH_V2_BEACON_BLOCK_DEPOSIT" +) + +type BeaconBlockDeposit struct { + log logrus.FieldLogger + event *xatu.DecoratedEvent +} + +func NewBeaconBlockDeposit(log logrus.FieldLogger, event *xatu.DecoratedEvent) *BeaconBlockDeposit { + return &BeaconBlockDeposit{ + log: log.WithField("event", BeaconBlockDepositType), + event: event, + } +} + +func (b *BeaconBlockDeposit) Type() string { + return BeaconBlockDepositType +} + +func (b *BeaconBlockDeposit) Validate(ctx context.Context) error { + _, ok := b.event.Data.(*xatu.DecoratedEvent_EthV2BeaconBlockDeposit) + if !ok { + return errors.New("failed to cast event data") + } + + return nil +} + +func (b *BeaconBlockDeposit) Filter(ctx context.Context) bool { + return false +} diff --git a/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_execution_transaction.go b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_execution_transaction.go new file mode 100644 index 00000000..9b4c401c --- /dev/null +++ b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_execution_transaction.go @@ -0,0 +1,42 @@ +package v2 + +import ( + "context" + "errors" + + "github.com/ethpandaops/xatu/pkg/proto/xatu" + "github.com/sirupsen/logrus" +) + +const ( + BeaconBlockExecutionTransactionType = "BEACON_API_ETH_V2_BEACON_BLOCK_EXECUTION_TRANSACTION" +) + +type BeaconBlockExecutionTransaction struct { + log logrus.FieldLogger + event *xatu.DecoratedEvent +} + +func NewBeaconBlockExecutionTransaction(log logrus.FieldLogger, event *xatu.DecoratedEvent) *BeaconBlockExecutionTransaction { + return &BeaconBlockExecutionTransaction{ + log: log.WithField("event", BeaconBlockExecutionTransactionType), + event: event, + } +} + +func (b *BeaconBlockExecutionTransaction) Type() string { + return BeaconBlockExecutionTransactionType +} + +func (b *BeaconBlockExecutionTransaction) Validate(ctx context.Context) error { + _, ok := b.event.Data.(*xatu.DecoratedEvent_EthV2BeaconBlockExecutionTransaction) + if !ok { + return errors.New("failed to cast event data") + } + + return nil +} + +func (b *BeaconBlockExecutionTransaction) Filter(ctx context.Context) bool { + return false +} diff --git a/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_proposer_slashing.go b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_proposer_slashing.go new file mode 100644 index 00000000..c96c3fb7 --- /dev/null +++ b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_proposer_slashing.go @@ -0,0 +1,42 @@ +package v2 + +import ( + "context" + "errors" + + "github.com/ethpandaops/xatu/pkg/proto/xatu" + "github.com/sirupsen/logrus" +) + +const ( + BeaconBlockProposerSlashingType = "BEACON_API_ETH_V2_BEACON_BLOCK_PROPOSER_SLASHING" +) + +type BeaconBlockProposerSlashing struct { + log logrus.FieldLogger + event *xatu.DecoratedEvent +} + +func NewBeaconBlockProposerSlashing(log logrus.FieldLogger, event *xatu.DecoratedEvent) *BeaconBlockProposerSlashing { + return &BeaconBlockProposerSlashing{ + log: log.WithField("event", BeaconBlockProposerSlashingType), + event: event, + } +} + +func (b *BeaconBlockProposerSlashing) Type() string { + return BeaconBlockProposerSlashingType +} + +func (b *BeaconBlockProposerSlashing) Validate(ctx context.Context) error { + _, ok := b.event.Data.(*xatu.DecoratedEvent_EthV2BeaconBlockProposerSlashing) + if !ok { + return errors.New("failed to cast event data") + } + + return nil +} + +func (b *BeaconBlockProposerSlashing) Filter(ctx context.Context) bool { + return false +} diff --git a/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_voluntary_exit.go b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_voluntary_exit.go new file mode 100644 index 00000000..db74a802 --- /dev/null +++ b/pkg/server/service/event-ingester/event/beacon/eth/v2/beacon_block_voluntary_exit.go @@ -0,0 +1,42 @@ +package v2 + +import ( + "context" + "errors" + + "github.com/ethpandaops/xatu/pkg/proto/xatu" + "github.com/sirupsen/logrus" +) + +const ( + BeaconBlockVoluntaryExitType = "BEACON_API_ETH_V2_BEACON_BLOCK_VOLUNTARY_EXIT" +) + +type BeaconBlockVoluntaryExit struct { + log logrus.FieldLogger + event *xatu.DecoratedEvent +} + +func NewBeaconBlockVoluntaryExit(log logrus.FieldLogger, event *xatu.DecoratedEvent) *BeaconBlockVoluntaryExit { + return &BeaconBlockVoluntaryExit{ + log: log.WithField("event", BeaconBlockVoluntaryExitType), + event: event, + } +} + +func (b *BeaconBlockVoluntaryExit) Type() string { + return BeaconBlockVoluntaryExitType +} + +func (b *BeaconBlockVoluntaryExit) Validate(ctx context.Context) error { + _, ok := b.event.Data.(*xatu.DecoratedEvent_EthV2BeaconBlockVoluntaryExit) + if !ok { + return errors.New("failed to cast event data") + } + + return nil +} + +func (b *BeaconBlockVoluntaryExit) Filter(ctx context.Context) bool { + return false +} diff --git a/pkg/server/service/event-ingester/event/event.go b/pkg/server/service/event-ingester/event/event.go index e9455e0a..d5c43431 100644 --- a/pkg/server/service/event-ingester/event/event.go +++ b/pkg/server/service/event-ingester/event/event.go @@ -42,6 +42,11 @@ const ( TypeBeaconEthV1BeaconCommittee Type = v1.BeaconCommitteeType TypeBeaconEthV1ValidatorAttestationData Type = v1.ValidatorAttestationDataType TypeBeaconEthV2BeaconBlockAttesterSlashing Type = v2.BeaconBlockAttesterSlashingType + TypeBeaconEthV2BeaconBlockProposerSlashing Type = v2.BeaconBlockProposerSlashingType + TypeBeaconEthV2BeaconBlockVoluntaryExit Type = v2.BeaconBlockVoluntaryExitType + TypeBeaconEthV2BeaconBlockDeposit Type = v2.BeaconBlockDepositType + TypeBeaconEthV2BeaconExecutionTransaction Type = v2.BeaconBlockExecutionTransactionType + TypeBeaconEthV2BeaconBLSToExecutionChange Type = v2.BeaconBlockBLSToExecutionChangeType ) type Event interface { @@ -50,6 +55,7 @@ type Event interface { Filter(ctx context.Context) bool } +//nolint:gocyclo //not that complex func New(eventType Type, log logrus.FieldLogger, event *xatu.DecoratedEvent, cache store.Cache) (Event, error) { if eventType == TypeUnknown { return nil, errors.New("event type is required") @@ -106,6 +112,17 @@ func New(eventType Type, log logrus.FieldLogger, event *xatu.DecoratedEvent, cac return v1.NewValidatorAttestationData(log, event), nil case TypeBeaconEthV2BeaconBlockAttesterSlashing: return v2.NewBeaconBlockAttesterSlashing(log, event), nil + case TypeBeaconEthV2BeaconBlockProposerSlashing: + return v2.NewBeaconBlockProposerSlashing(log, event), nil + case TypeBeaconEthV2BeaconBlockVoluntaryExit: + return v2.NewBeaconBlockVoluntaryExit(log, event), nil + case TypeBeaconEthV2BeaconBlockDeposit: + return v2.NewBeaconBlockDeposit(log, event), nil + case TypeBeaconEthV2BeaconExecutionTransaction: + return v2.NewBeaconBlockExecutionTransaction(log, event), nil + case TypeBeaconEthV2BeaconBLSToExecutionChange: + return v2.NewBeaconBlockBLSToExecutionChange(log, event), nil + default: return nil, fmt.Errorf("event type %s is unknown", eventType) }