From 0964cd72b8c1be0c1547e8fa32b5df6caa6fcb5d Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Tue, 10 Oct 2023 12:21:55 +1000 Subject: [PATCH] feat(beacon): add FetchBeaconBlockBlobs method --- pkg/beacon/beacon.go | 3 +++ pkg/beacon/fetch.go | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/pkg/beacon/beacon.go b/pkg/beacon/beacon.go index 0fc2d41..de4db2a 100644 --- a/pkg/beacon/beacon.go +++ b/pkg/beacon/beacon.go @@ -11,6 +11,7 @@ import ( v1 "github.com/attestantio/go-eth2-client/api/v1" "github.com/attestantio/go-eth2-client/spec" "github.com/attestantio/go-eth2-client/spec/altair" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/chuckpreslar/emission" "github.com/ethpandaops/beacon/pkg/beacon/api" @@ -82,6 +83,8 @@ type Node interface { FetchBeaconCommittees(ctx context.Context, state string, epoch phase0.Epoch) ([]*v1.BeaconCommittee, error) // FetchAttestationData fetches the attestation data for the given slot and committee index. FetchAttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) + // FetchBeaconBlockBlobs fetches blob sidecars for the given block id. + FetchBeaconBlockBlobs(ctx context.Context, blockID string) ([]*deneb.BlobSidecar, error) // Subscriptions // - Proxied Beacon events diff --git a/pkg/beacon/fetch.go b/pkg/beacon/fetch.go index 7cc2099..d720438 100644 --- a/pkg/beacon/fetch.go +++ b/pkg/beacon/fetch.go @@ -7,6 +7,7 @@ import ( eth2client "github.com/attestantio/go-eth2-client" v1 "github.com/attestantio/go-eth2-client/api/v1" "github.com/attestantio/go-eth2-client/spec" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/ethpandaops/beacon/pkg/beacon/api/types" "github.com/ethpandaops/beacon/pkg/beacon/state" @@ -136,6 +137,20 @@ func (n *node) FetchSpec(ctx context.Context) (*state.Spec, error) { return &sp, nil } +func (n *node) FetchBeaconBlockBlobs(ctx context.Context, blockID string) ([]*deneb.BlobSidecar, error) { + provider, isProvider := n.client.(eth2client.BeaconBlockBlobsProvider) + if !isProvider { + return nil, errors.New("client does not implement eth2client.BeaconBlockBlobsProvider") + } + + data, err := provider.BeaconBlockBlobs(ctx, blockID) + if err != nil { + return nil, err + } + + return data, nil +} + func (n *node) FetchProposerDuties(ctx context.Context, epoch phase0.Epoch) ([]*v1.ProposerDuty, error) { n.log.WithField("epoch", epoch).Debug("Fetching proposer duties")