Skip to content

Commit

Permalink
feat(beacon): add FetchBeaconBlockBlobs method
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Oct 10, 2023
1 parent 1019d16 commit 0964cd7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions pkg/beacon/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 0964cd7

Please sign in to comment.