Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Bump go-eth2-client to v0.19.5 #25

Merged
merged 1 commit into from
Nov 30, 2023
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
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ethpandaops/beacon
go 1.19

require (
github.com/attestantio/go-eth2-client v0.18.4-0.20231012194602-0eff364fec01
github.com/attestantio/go-eth2-client v0.19.5
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
github.com/ethpandaops/ethwallclock v0.2.0
github.com/go-co-op/gocron v1.16.2
Expand All @@ -23,6 +23,7 @@ require (
github.com/goccy/go-yaml v1.9.5 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/holiman/uint256 v1.2.2 // indirect
github.com/huandu/go-clone v1.6.0 // indirect
github.com/klauspost/cpuid/v2 v2.1.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
Expand Down
7 changes: 5 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/attestantio/go-eth2-client v0.18.4-0.20231012194602-0eff364fec01 h1:KSfIKKL501RgHJrQIoS+0OpJuG3pFi2o5wKPrHkcs5M=
github.com/attestantio/go-eth2-client v0.18.4-0.20231012194602-0eff364fec01/go.mod h1:KSVlZSW1A3jUg5H8O89DLtqxgJprRfTtI7k89fLdhu0=
github.com/attestantio/go-eth2-client v0.19.5 h1:4V+vhXsCYji5jWrlONbr03GV7qoLRdzq96dLgXaqmek=
github.com/attestantio/go-eth2-client v0.19.5/go.mod h1:mZve1kV9Ctj0I1HH9gdg+MnI8lZ+Cb2EktEtOYrBlsM=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
Expand Down Expand Up @@ -45,7 +45,10 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/holiman/uint256 v1.2.2 h1:TXKcSGc2WaxPD2+bmzAsVthL4+pEN0YwXcL5qED83vk=
github.com/holiman/uint256 v1.2.2/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw=
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
github.com/huandu/go-clone v1.6.0 h1:HMo5uvg4wgfiy5FoGOqlFLQED/VGRm2D9Pi8g1FXPGc=
github.com/huandu/go-clone v1.6.0/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE=
github.com/huandu/go-clone/generic v1.6.0 h1:Wgmt/fUZ28r16F2Y3APotFD59sHk1p78K0XLdbUYN5U=
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.1.2 h1:XhdX4fqAJUA0yj+kUwMavO0hHrSPAecYdYf1ZmxHvak=
Expand Down
19 changes: 16 additions & 3 deletions pkg/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

eth2client "github.com/attestantio/go-eth2-client"
eapi "github.com/attestantio/go-eth2-client/api"
v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/altair"
Expand Down Expand Up @@ -386,7 +387,7 @@ func (n *node) fetchIsHealthy(ctx context.Context) error {
return errors.New("client does not implement eth2client.NodeSyncingProvider")
}

_, err := provider.NodeSyncing(ctx)
_, err := provider.NodeSyncing(ctx, &eapi.NodeSyncingOpts{})
if err != nil {
return err
}
Expand Down Expand Up @@ -437,12 +438,24 @@ func (n *node) getBlock(ctx context.Context, blockID string) (*spec.VersionedSig
return nil, errors.New("client does not implement eth2client.SignedBeaconBlockProvider")
}

signedBeaconBlock, err := provider.SignedBeaconBlock(ctx, blockID)
signedBeaconBlock, err := provider.SignedBeaconBlock(ctx, &eapi.SignedBeaconBlockOpts{
Block: blockID,
})
if err != nil {
var apiErr *eapi.Error
if errors.As(err, &apiErr) {
switch apiErr.StatusCode {
case 404:
return nil, nil
case 503:
return nil, errors.New("beacon node is syncing")
}
}

return nil, err
}

return signedBeaconBlock, nil
return signedBeaconBlock.Data, nil
}

func (n *node) Healthy() bool {
Expand Down
70 changes: 46 additions & 24 deletions pkg/beacon/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"

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/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/deneb"
Expand All @@ -19,16 +20,16 @@ func (n *node) FetchSyncStatus(ctx context.Context) (*v1.SyncState, error) {
return nil, errors.New("client does not implement eth2client.NodeSyncingProvider")
}

status, err := provider.NodeSyncing(ctx)
status, err := provider.NodeSyncing(ctx, &api.NodeSyncingOpts{})
if err != nil {
return nil, err
}

n.stat.UpdateSyncState(status)
n.stat.UpdateSyncState(status.Data)

n.publishSyncStatus(ctx, status)
n.publishSyncStatus(ctx, status.Data)

return status, nil
return status.Data, nil
}

func (n *node) FetchPeers(ctx context.Context) (*types.Peers, error) {
Expand All @@ -50,16 +51,16 @@ func (n *node) FetchNodeVersion(ctx context.Context) (string, error) {
return "", errors.New("client does not implement eth2client.NodeVersionProvider")
}

version, err := provider.NodeVersion(ctx)
rsp, err := provider.NodeVersion(ctx, &api.NodeVersionOpts{})
if err != nil {
return "", err
}

n.nodeVersion = version
n.nodeVersion = rsp.Data

n.publishNodeVersionUpdated(ctx, version)
n.publishNodeVersionUpdated(ctx, rsp.Data)

return version, nil
return rsp.Data, nil
}

func (n *node) FetchBlock(ctx context.Context, stateID string) (*spec.VersionedSignedBeaconBlock, error) {
Expand All @@ -72,12 +73,14 @@ func (n *node) FetchBeaconState(ctx context.Context, stateID string) (*spec.Vers
return nil, errors.New("client does not implement eth2client.NodeVersionProvider")
}

beaconState, err := provider.BeaconState(ctx, stateID)
rsp, err := provider.BeaconState(ctx, &api.BeaconStateOpts{
State: stateID,
})
if err != nil {
return nil, err
}

return beaconState, nil
return rsp.Data, nil
}

func (n *node) FetchRawBeaconState(ctx context.Context, stateID string, contentType string) ([]byte, error) {
Expand All @@ -90,11 +93,15 @@ func (n *node) FetchFinality(ctx context.Context, stateID string) (*v1.Finality,
return nil, errors.New("client does not implement eth2client.FinalityProvider")
}

finality, err := provider.Finality(ctx, stateID)
rsp, err := provider.Finality(ctx, &api.FinalityOpts{
State: stateID,
})
if err != nil {
return nil, err
}

finality := rsp.Data

if stateID == "head" {
changed := false
if n.finality == nil ||
Expand Down Expand Up @@ -123,12 +130,12 @@ func (n *node) FetchSpec(ctx context.Context) (*state.Spec, error) {
return nil, errors.New("client does not implement eth2client.SpecProvider")
}

data, err := provider.Spec(ctx)
rsp, err := provider.Spec(ctx, &api.SpecOpts{})
if err != nil {
return nil, err
}

sp := state.NewSpec(data)
sp := state.NewSpec(rsp.Data)

n.spec = &sp

Expand All @@ -138,17 +145,19 @@ func (n *node) FetchSpec(ctx context.Context) (*state.Spec, error) {
}

func (n *node) FetchBeaconBlockBlobs(ctx context.Context, blockID string) ([]*deneb.BlobSidecar, error) {
provider, isProvider := n.client.(eth2client.BeaconBlockBlobsProvider)
provider, isProvider := n.client.(eth2client.BlobSidecarsProvider)
if !isProvider {
return nil, errors.New("client does not implement eth2client.BeaconBlockBlobsProvider")
return nil, errors.New("client does not implement eth2client.BlobSidecarsProvider")
}

data, err := provider.BeaconBlockBlobs(ctx, blockID)
rsp, err := provider.BlobSidecars(ctx, &api.BlobSidecarsOpts{
Block: blockID,
})
if err != nil {
return nil, err
}

return data, nil
return rsp.Data, nil
}

func (n *node) FetchProposerDuties(ctx context.Context, epoch phase0.Epoch) ([]*v1.ProposerDuty, error) {
Expand All @@ -159,12 +168,14 @@ func (n *node) FetchProposerDuties(ctx context.Context, epoch phase0.Epoch) ([]*
return nil, errors.New("client does not implement eth2client.ProposerDutiesProvider")
}

duties, err := provider.ProposerDuties(ctx, epoch, nil)
rsp, err := provider.ProposerDuties(ctx, &api.ProposerDutiesOpts{
Epoch: epoch,
})
if err != nil {
return nil, err
}

return duties, nil
return rsp.Data, nil
}

func (n *node) FetchForkChoice(ctx context.Context) (*v1.ForkChoice, error) {
Expand All @@ -173,7 +184,12 @@ func (n *node) FetchForkChoice(ctx context.Context) (*v1.ForkChoice, error) {
return nil, errors.New("client does not implement eth2client.ForkChoiceProvider")
}

return provider.ForkChoice(ctx)
rsp, err := provider.ForkChoice(ctx, &api.ForkChoiceOpts{})
if err != nil {
return nil, err
}

return rsp.Data, nil
}

func (n *node) FetchDepositSnapshot(ctx context.Context) (*types.DepositSnapshot, error) {
Expand All @@ -186,12 +202,15 @@ func (n *node) FetchBeaconCommittees(ctx context.Context, state string, epoch ph
return nil, errors.New("client does not implement eth2client.BeaconCommitteesProvider")
}

duties, err := provider.BeaconCommitteesAtEpoch(ctx, state, epoch)
rsp, err := provider.BeaconCommittees(ctx, &api.BeaconCommitteesOpts{
State: state,
Epoch: &epoch,
})
if err != nil {
return nil, err
}

return duties, nil
return rsp.Data, nil
}

func (n *node) FetchAttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error) {
Expand All @@ -200,10 +219,13 @@ func (n *node) FetchAttestationData(ctx context.Context, slot phase0.Slot, commi
return nil, errors.New("client does not implement eth2client.AttestationDataProvider")
}

attestationData, err := provider.AttestationData(ctx, slot, committeeIndex)
rsp, err := provider.AttestationData(ctx, &api.AttestationDataOpts{
Slot: slot,
CommitteeIndex: committeeIndex,
})
if err != nil {
return nil, err
}

return attestationData, nil
return rsp.Data, nil
}
7 changes: 4 additions & 3 deletions pkg/beacon/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"

eth2client "github.com/attestantio/go-eth2-client"
"github.com/attestantio/go-eth2-client/api"
v1 "github.com/attestantio/go-eth2-client/api/v1"
)

Expand All @@ -14,12 +15,12 @@ func (n *node) FetchGenesis(ctx context.Context) (*v1.Genesis, error) {
return nil, errors.New("client does not implement eth2client.GenesisProvider")
}

genesis, err := provider.Genesis(ctx)
rsp, err := provider.Genesis(ctx, &api.GenesisOpts{})
if err != nil {
return nil, err
}

n.genesis = genesis
n.genesis = rsp.Data

return genesis, nil
return rsp.Data, nil
}
Loading