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

core: integrating go-eth2-client for for v3 endpoint #2913

Merged
merged 14 commits into from
Mar 1, 2024
31 changes: 31 additions & 0 deletions app/eth2wrap/eth2wrap_gen.go

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

1 change: 1 addition & 0 deletions app/eth2wrap/genwrap/genwrap.go

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

18 changes: 17 additions & 1 deletion core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
DutyPrepareSyncContribution DutyType = 11
DutySyncContribution DutyType = 12
DutyInfoSync DutyType = 13
DutyUniversalProposer DutyType = 14
// Only ever append new types here...

dutySentinel DutyType = 14 // Must always be last
dutySentinel DutyType = 15 // Must always be last
)

func (d DutyType) Valid() bool {
Expand All @@ -64,6 +65,7 @@
DutyPrepareSyncContribution: "prepare_sync_contribution",
DutySyncContribution: "sync_contribution",
DutyInfoSync: "info_sync",
DutyUniversalProposer: "universal_proposer",
}[d]
}

Expand Down Expand Up @@ -142,6 +144,20 @@
}
}

// NewUniversalProposerDuty returns a new universal proposer duty.
// It is a convenience function that is slightly more readable
// and concise than the struct literal equivalent:
//
// core.Duty{Slot: slot, Type: core.DutyUniversalProposer}
// vs
// core.NewUniversalProposerDuty(slot)
func NewUniversalProposerDuty(slot uint64) Duty {
return Duty{
Slot: slot,
Type: DutyUniversalProposer,
}

Check warning on line 158 in core/types.go

View check run for this annotation

Codecov / codecov/patch

core/types.go#L154-L158

Added lines #L154 - L158 were not covered by tests
}

// NewVoluntaryExit returns a new voluntary exit duty. It is a convenience function that is
// slightly more readable and concise than the struct literal equivalent:
//
Expand Down
3 changes: 2 additions & 1 deletion core/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ func TestBackwardsCompatability(t *testing.T) {
require.EqualValues(t, 11, core.DutyPrepareSyncContribution)
require.EqualValues(t, 12, core.DutySyncContribution)
require.EqualValues(t, 13, core.DutyInfoSync)
require.EqualValues(t, 14, core.DutyUniversalProposer)
// Add more types here.

const sentinel = core.DutyType(14)
const sentinel = core.DutyType(15)
for i := core.DutyUnknown; i <= sentinel; i++ {
if i == core.DutyUnknown {
require.False(t, i.Valid())
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,6 @@ require (

// We're replacing kryptology with our own fork, which fixes dependencies' security vulnerabilities.
replace github.com/coinbase/kryptology => github.com/ObolNetwork/kryptology v0.0.0-20231016091344-eed023b6cac8

// We're replacing kryptology with our own fork, which adds UniversalProposel model for produceBlockV3 endpoint.
pinebit marked this conversation as resolved.
Show resolved Hide resolved
replace github.com/attestantio/go-eth2-client v0.19.10 => github.com/obolNetwork/go-eth2-client v0.0.0-20240228100742-8eb0c82f8153
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ github.com/ObolNetwork/kryptology v0.0.0-20231016091344-eed023b6cac8/go.mod h1:q
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
github.com/attestantio/go-eth2-client v0.19.10 h1:NLs9mcBvZpBTZ3du7Ey2NHQoj8d3UePY7pFBXX6C6qs=
github.com/attestantio/go-eth2-client v0.19.10/go.mod h1:TTz7YF6w4z6ahvxKiHuGPn6DbQn7gH6HPuWm/DEQeGE=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
Expand Down Expand Up @@ -372,6 +370,8 @@ github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/n
github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
github.com/obolNetwork/go-eth2-client v0.0.0-20240228100742-8eb0c82f8153 h1:KtEnfQIcXHxZGQNqWl1FjkAbWG0Juq0iFVbicR/tmXQ=
github.com/obolNetwork/go-eth2-client v0.0.0-20240228100742-8eb0c82f8153/go.mod h1:TTz7YF6w4z6ahvxKiHuGPn6DbQn7gH6HPuWm/DEQeGE=
github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc=
Expand Down
10 changes: 10 additions & 0 deletions testutil/beaconmock/beaconmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
NodePeerCountFunc func(ctx context.Context) (int, error)
ProposalFunc func(ctx context.Context, opts *eth2api.ProposalOpts) (*eth2api.VersionedProposal, error)
BlindedProposalFunc func(ctx context.Context, opts *eth2api.BlindedProposalOpts) (*eth2api.VersionedBlindedProposal, error)
UniversalProposalFunc func(ctx context.Context, opts *eth2api.UniversalProposalOpts) (*eth2api.VersionedUniversalProposal, error)
SignedBeaconBlockFunc func(ctx context.Context, blockID string) (*eth2spec.VersionedSignedBeaconBlock, error)
ProposerDutiesFunc func(context.Context, eth2p0.Epoch, []eth2p0.ValidatorIndex) ([]*eth2v1.ProposerDuty, error)
SubmitAttestationsFunc func(context.Context, []*eth2p0.Attestation) error
Expand Down Expand Up @@ -181,6 +182,15 @@
return wrapResponse(block), nil
}

func (m Mock) UniversalProposal(ctx context.Context, opts *eth2api.UniversalProposalOpts) (*eth2api.Response[*eth2api.VersionedUniversalProposal], error) {
block, err := m.UniversalProposalFunc(ctx, opts)
if err != nil {
return nil, err
}

Check warning on line 189 in testutil/beaconmock/beaconmock.go

View check run for this annotation

Codecov / codecov/patch

testutil/beaconmock/beaconmock.go#L185-L189

Added lines #L185 - L189 were not covered by tests

return wrapResponse(block), nil

Check warning on line 191 in testutil/beaconmock/beaconmock.go

View check run for this annotation

Codecov / codecov/patch

testutil/beaconmock/beaconmock.go#L191

Added line #L191 was not covered by tests
}

func (m Mock) BlindedProposal(ctx context.Context, opts *eth2api.BlindedProposalOpts) (*eth2api.Response[*eth2api.VersionedBlindedProposal], error) {
block, err := m.BlindedProposalFunc(ctx, opts)
if err != nil {
Expand Down
Loading