Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ tool:
$(GET_TOOL) github.com/vektra/mockery/v2@latest
$(GET_TOOL) github.com/hexdigest/gowrap/cmd/gowrap@latest
$(RUN_TOOL) github.com/vektra/mockery/v2 --name Client && mv mocks/Client.go mocks/client.go
$(RUN_TOOL) github.com/hexdigest/gowrap/cmd/gowrap gen -p github.com/bloxapp/beacon-kit -i Client -t ./pool/methods.template -o ./pool/methods.go -l ""
$(RUN_TOOL) github.com/hexdigest/gowrap/cmd/gowrap gen -p github.com/ssvlabs/beacon-kit -i Client -t ./pool/methods.template -o ./pool/methods.go -l ""
5 changes: 4 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

// Client is an interface which interacts with a Beacon node.
// NOTE: "make generate" MUST be run after changing this interface,
// NOTE: "make tool" MUST be run after changing this interface,
// in order to update any generated code which depends on it.
type Client interface {
// Name returns the name of the client implementation.
Expand All @@ -28,6 +28,7 @@ type Client interface {
eth2client.DomainProvider

eth2client.ValidatorsProvider
eth2client.ValidatorBalancesProvider

eth2client.ProposerDutiesProvider
eth2client.AttesterDutiesProvider
Expand All @@ -51,4 +52,6 @@ type Client interface {
eth2client.SyncCommitteeMessagesSubmitter
eth2client.SyncCommitteeContributionProvider
eth2client.SyncCommitteeContributionsSubmitter

eth2client.EventsProvider
}
10 changes: 9 additions & 1 deletion go-eth2-client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/beacon-kit"
"github.com/ssvlabs/beacon-kit"
)

// ErrCallNotSupported is returned when the implementation does not support the requested call.
Expand Down Expand Up @@ -168,6 +168,14 @@ func (c *Client) Validators(ctx context.Context, opts *api.ValidatorsOpts) (*api
return checkResponse(provider.Validators(ctx, opts))
}

func (c *Client) ValidatorBalances(ctx context.Context, opts *api.ValidatorBalancesOpts) (*api.Response[map[phase0.ValidatorIndex]phase0.Gwei], error) {
provider, ok := c.service.(eth2client.ValidatorBalancesProvider)
if !ok {
return nil, ErrCallNotSupported
}
return provider.ValidatorBalances(ctx, opts)
}

func (c *Client) SubmitProposalPreparations(ctx context.Context, preparations []*apiv1.ProposalPreparation) error {
provider, ok := c.service.(eth2client.ProposalPreparationsSubmitter)
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/bloxapp/beacon-kit
module github.com/ssvlabs/beacon-kit

go 1.24
go 1.25

require (
github.com/attestantio/go-eth2-client v0.25.0
Expand Down
50 changes: 49 additions & 1 deletion mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions multi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/attestantio/go-eth2-client/spec/phase0"
"go.uber.org/zap"

"github.com/bloxapp/beacon-kit"
"github.com/bloxapp/beacon-kit/logging"
"github.com/bloxapp/beacon-kit/pool"
"github.com/ssvlabs/beacon-kit"
"github.com/ssvlabs/beacon-kit/logging"
"github.com/ssvlabs/beacon-kit/pool"
)

type CallTrace struct {
Expand Down
8 changes: 5 additions & 3 deletions multi/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/bloxapp/beacon-kit"
"github.com/bloxapp/beacon-kit/mocks"
"github.com/bloxapp/beacon-kit/pool"
"github.com/ssvlabs/beacon-kit"
"github.com/ssvlabs/beacon-kit/mocks"
"github.com/ssvlabs/beacon-kit/pool"
)

func TestWith(t *testing.T) {
Expand Down Expand Up @@ -68,13 +68,15 @@ func TestBestAttestationDataSelection(t *testing.T) {
// Create an offline client (which will never return).
offlineClient := mocks.NewClient(t)
offlineClient.On("Address", mock.Anything).Return("offline")
offlineClient.On("Events", mock.Anything, mock.Anything).Return(nil)
offlineClient.On("AttestationData", mock.Anything, mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
<-args.Get(0).(context.Context).Done()
}).Return(nil, context.Canceled)

// Create an online client (which will return immediately).
onlineClient := mocks.NewClient(t)
onlineClient.On("Address", mock.Anything).Return("online")
onlineClient.On("Events", mock.Anything, mock.Anything).Return(nil)
onlineClient.On("AttestationData", mock.Anything, mock.Anything, mock.Anything).Return(&api.Response[*phase0.AttestationData]{Data: &phase0.AttestationData{}}, nil)

// Create a multi.Client with BestAttestationDataSelection.
Expand Down
4 changes: 2 additions & 2 deletions pool/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"sync"
"time"

"github.com/bloxapp/beacon-kit"
"github.com/bloxapp/beacon-kit/logging"
"github.com/ssvlabs/beacon-kit"
"github.com/ssvlabs/beacon-kit/logging"
"go.uber.org/zap"
)

Expand Down
9 changes: 2 additions & 7 deletions pool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"strings"
"sync"

eth2client "github.com/attestantio/go-eth2-client"
"github.com/attestantio/go-eth2-client/api"
v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/bloxapp/beacon-kit"
"github.com/google/uuid"
"github.com/hashicorp/go-multierror"
"github.com/ssvlabs/beacon-kit"
)

// state holds properties for Client, so that a pointer to it can be shared for read/write
Expand Down Expand Up @@ -200,10 +199,6 @@ func (c *Client) updateSubscriptions(ctx context.Context) error {
if clientSubcribed {
continue
}
provider, ok := client.(eth2client.EventsProvider)
if !ok {
continue
}

// Register client subscription.
subscriptionCtx, cancel := context.WithCancel(context.Background())
Expand All @@ -218,7 +213,7 @@ func (c *Client) updateSubscriptions(ctx context.Context) error {
func(client beacon.Client, sub subscription, subscriptionUUID uuid.UUID) {
g.Go(func() error {
log.Printf("Subscribing %s to %s (UUID: %x)", strings.ToUpper(sub.topics[0]), client.Address(), subscriptionUUID[:])
return provider.Events(subscriptionCtx, &api.EventsOpts{
return client.Events(subscriptionCtx, &api.EventsOpts{
Topics: sub.topics,
Handler: func(e *v1.Event) {
sub.handler(client, e)
Expand Down
4 changes: 2 additions & 2 deletions pool/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/attestantio/go-eth2-client/api"
apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/beacon-kit"
"github.com/bloxapp/beacon-kit/mocks"
"github.com/ssvlabs/beacon-kit"
"github.com/ssvlabs/beacon-kit/mocks"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

Expand Down
47 changes: 45 additions & 2 deletions pool/methods.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"sync"

"github.com/bloxapp/beacon-kit"
"github.com/hashicorp/go-multierror"
"github.com/ssvlabs/beacon-kit"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion pool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/bloxapp/beacon-kit"
"github.com/ssvlabs/beacon-kit"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
Expand Down
2 changes: 1 addition & 1 deletion pool/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math/rand"
"time"

"github.com/bloxapp/beacon-kit"
"github.com/ssvlabs/beacon-kit"
)

// Scope dictates the behaviour of calls to the pool.
Expand Down
2 changes: 1 addition & 1 deletion spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/beacon-kit/clock"
"github.com/ssvlabs/beacon-kit/clock"
)

// Spec contains the network-specific Beacon Chain configuration
Expand Down
Loading
Loading