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

*: fix compatibility with latest go-eth2-client #2650

Merged
merged 18 commits into from
Oct 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
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,12 @@
}

// Check BN chain/network.
schedule, err := eth2Cl.ForkSchedule(ctx)
eth2Resp, err := eth2Cl.ForkSchedule(ctx)

Check warning on line 812 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L812

Added line #L812 was not covered by tests
if err != nil {
return nil, errors.Wrap(err, "fetch fork schedule")
}
schedule := eth2Resp.Data

Check warning on line 817 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L816-L817

Added lines #L816 - L817 were not covered by tests
var ok bool
for _, fork := range schedule {
if bytes.Equal(fork.CurrentVersion[:], forkVersion) {
Expand Down
11 changes: 6 additions & 5 deletions app/eth2wrap/eth2wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"sync"
"time"

eth2api "github.com/attestantio/go-eth2-client/api"
eth2http "github.com/attestantio/go-eth2-client/http"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
Expand Down Expand Up @@ -329,12 +330,12 @@
// wrapError returns the error as a wrapped structured error.
func wrapError(ctx context.Context, err error, label string, fields ...z.Field) error {
// Decompose go-eth2-client http errors
if e2err := new(eth2http.Error); errors.As(err, e2err) {
if apiErr := new(eth2api.Error); errors.As(err, apiErr) {
err = errors.New("nok http response",
z.Int("status_code", e2err.StatusCode),
z.Str("endpoint", e2err.Endpoint),
z.Str("method", e2err.Method),
z.Str("data", string(e2err.Data)),
z.Int("status_code", apiErr.StatusCode),
z.Str("endpoint", apiErr.Endpoint),
z.Str("method", apiErr.Method),
z.Str("data", string(apiErr.Data)),

Check warning on line 338 in app/eth2wrap/eth2wrap.go

View check run for this annotation

Codecov / codecov/patch

app/eth2wrap/eth2wrap.go#L335-L338

Added lines #L335 - L338 were not covered by tests
)
}

Expand Down
278 changes: 116 additions & 162 deletions app/eth2wrap/eth2wrap_gen.go

Large diffs are not rendered by default.

14 changes: 1 addition & 13 deletions app/eth2wrap/eth2wrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestSyncState(t *testing.T) {

resp, err := eth2Cl.NodeSyncing(context.Background())
require.NoError(t, err)
require.False(t, resp.IsSyncing)
require.False(t, resp.Data.IsSyncing)
}

func TestErrors(t *testing.T) {
Expand Down Expand Up @@ -203,18 +203,6 @@ func TestErrors(t *testing.T) {
require.ErrorContains(t, err, "beacon api slots_per_epoch: context canceled")
})

t.Run("go-eth2-client http error", func(t *testing.T) {
bmock, err := beaconmock.New()
require.NoError(t, err)
eth2Cl, err := eth2wrap.NewMultiHTTP(time.Second, bmock.Address())
require.NoError(t, err)

_, err = eth2Cl.AggregateAttestation(ctx, 0, eth2p0.Root{})
log.Error(ctx, "See this error log for fields", err)
require.Error(t, err)
require.ErrorContains(t, err, "beacon api aggregate_attestation: nok http response")
})

t.Run("zero net op error", func(t *testing.T) {
bmock, err := beaconmock.New()
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions app/eth2wrap/genwrap/genwrap.go

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

11 changes: 6 additions & 5 deletions app/eth2wrap/success.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
package eth2wrap

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"
)

// isSyncStateOk returns tue if the sync state is not syncing.
func isSyncStateOk(s *apiv1.SyncState) bool {
return !s.IsSyncing
// isSyncStateOk returns true if the sync state is not syncing.
func isSyncStateOk(resp *api.Response[*apiv1.SyncState]) bool {
return !resp.Data.IsSyncing
}

// isAggregateAttestationOk returns true if the aggregate attestation is not nil (which can happen if the subscription wasn't successful).
func isAggregateAttestationOk(att *phase0.Attestation) bool {
return att != nil
func isAggregateAttestationOk(resp *api.Response[*phase0.Attestation]) bool {
return resp.Data != nil

Check warning on line 18 in app/eth2wrap/success.go

View check run for this annotation

Codecov / codecov/patch

app/eth2wrap/success.go#L17-L18

Added lines #L17 - L18 were not covered by tests
}
Loading
Loading