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

Builder: Electra #14344

Draft
wants to merge 30 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d0522ac
removing skip from test
james-prysm Aug 14, 2024
9269e0e
Merge branch 'develop' into electra-test-remove-skip
james-prysm Aug 14, 2024
1ed404c
builder wip
james-prysm Aug 14, 2024
592a45a
Merge branch 'develop' into builder-electra
james-prysm Aug 14, 2024
512e388
removing todo, it's probably ok
james-prysm Aug 14, 2024
bfae0ca
adding more TODOs
james-prysm Aug 14, 2024
d8b98d7
adding fromProtoElectra
james-prysm Aug 14, 2024
dbc55c9
using lightclient
james-prysm Aug 15, 2024
2521755
minor fixes
james-prysm Aug 15, 2024
9c8d26e
Merge branch 'develop' into builder-electra
james-prysm Sep 5, 2024
734ef94
Merge branch 'develop' into builder-electra
james-prysm Sep 16, 2024
066ce6a
Merge branch 'develop' into builder-electra
james-prysm Sep 24, 2024
67235fb
rolling back dependency changes
james-prysm Sep 24, 2024
6d580ec
go mod tidy
james-prysm Sep 24, 2024
c67df35
adding space back in
james-prysm Sep 24, 2024
6d1a9fa
Merge branch 'develop' into builder-electra
james-prysm Sep 25, 2024
d5f8e02
updating builder changes based on execution request changes
james-prysm Sep 26, 2024
2c907b2
Merge branch 'develop' into builder-electra
james-prysm Oct 15, 2024
289bb52
update ssz
james-prysm Oct 15, 2024
1c4be98
changelog
james-prysm Oct 15, 2024
45c1d0b
Merge branch 'develop' into builder-electra
james-prysm Oct 17, 2024
c1a93d8
updating based on execution request changes
james-prysm Oct 17, 2024
802a68b
fixing validation
james-prysm Oct 17, 2024
0aae98d
adding builder test for electra
james-prysm Oct 18, 2024
1adc957
Merge branch 'develop' into builder-electra
james-prysm Oct 18, 2024
759b819
gaz
james-prysm Oct 21, 2024
35e8541
attempting to fix test
james-prysm Oct 21, 2024
a5cea41
fixing ssz
james-prysm Oct 21, 2024
9cdb111
Merge branch 'develop' into builder-electra
james-prysm Oct 21, 2024
b409a59
Merge branch 'develop' into builder-electra
james-prysm Oct 23, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Added GetBlockAttestationsV2 endpoint.
- Light client support: Consensus types for Electra
- Added SubmitPoolAttesterSlashingV2 endpoint.
- Builder API endpooint to support Electra
- Added SubmitAggregateAndProofsRequestV2 endpoint.
- Updated the `beacon-chain/monitor` package to Electra. [PR](https://github.com/prysmaticlabs/prysm/pull/14562)

Expand Down
3 changes: 3 additions & 0 deletions api/client/builder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//api:go_default_library",
"//api/server:go_default_library",
"//api/server/structs:go_default_library",
"//config/fieldparams:go_default_library",
"//config/params:go_default_library",
"//consensus-types:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/interfaces:go_default_library",
Expand All @@ -25,6 +27,7 @@ go_library(
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//runtime/version:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_fastssz//:go_default_library",
Expand Down
105 changes: 105 additions & 0 deletions api/client/builder/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
v1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v5/runtime/version"
)
Expand All @@ -31,6 +32,12 @@ type Bid interface {
HashTreeRootWith(hh *ssz.Hasher) error
}

// BidElectra is an interface that exposes the newly added execution requests on top of the builder bid
type BidElectra interface {
Bid
ExecutionRequests() (*v1.ExecutionRequests, error)
}

type signedBuilderBid struct {
p *ethpb.SignedBuilderBid
}
Expand Down Expand Up @@ -290,3 +297,101 @@ func (b signedBuilderBidDeneb) Version() int {
func (b signedBuilderBidDeneb) IsNil() bool {
return b.p == nil
}

type builderBidElectra struct {
p *ethpb.BuilderBidElectra
}

// WrappedBuilderBidElectra is a constructor which wraps a protobuf bid into an interface.
func WrappedBuilderBidElectra(p *ethpb.BuilderBidElectra) (Bid, error) {
w := builderBidElectra{p: p}
if w.IsNil() {
return nil, consensus_types.ErrNilObjectWrapped
}
return w, nil
}

// Version --
func (b builderBidElectra) Version() int {
return version.Electra
}

// Value --
func (b builderBidElectra) Value() primitives.Wei {
return primitives.LittleEndianBytesToWei(b.p.Value)
}

// Pubkey --
func (b builderBidElectra) Pubkey() []byte {
return b.p.Pubkey
}

// IsNil --
func (b builderBidElectra) IsNil() bool {
return b.p == nil
}

// HashTreeRoot --
func (b builderBidElectra) HashTreeRoot() ([32]byte, error) {
return b.p.HashTreeRoot()
}

// HashTreeRootWith --
func (b builderBidElectra) HashTreeRootWith(hh *ssz.Hasher) error {
return b.p.HashTreeRootWith(hh)
}

// Header --
func (b builderBidElectra) Header() (interfaces.ExecutionData, error) {
// We have to convert big endian to little endian because the value is coming from the execution layer.
return blocks.WrappedExecutionPayloadHeaderElectra(b.p.Header)
}

// ExecutionRequests --
func (b builderBidElectra) ExecutionRequests() (*v1.ExecutionRequests, error) {
if b.p == nil {
return nil, consensus_types.ErrNilObjectWrapped
}
if b.p.ExecutionRequests == nil {
return nil, errors.New("ExecutionRequests is nil")
}
return b.p.ExecutionRequests, nil
}

// BlobKzgCommitments --
func (b builderBidElectra) BlobKzgCommitments() ([][]byte, error) {
return b.p.BlobKzgCommitments, nil
}

type signedBuilderBidElectra struct {
p *ethpb.SignedBuilderBidElectra
}

// WrappedSignedBuilderBidElectra is a constructor which wraps a protobuf signed bit into an interface.
func WrappedSignedBuilderBidElectra(p *ethpb.SignedBuilderBidElectra) (SignedBid, error) {
w := signedBuilderBidElectra{p: p}
if w.IsNil() {
return nil, consensus_types.ErrNilObjectWrapped
}
return w, nil
}

// Message --
func (b signedBuilderBidElectra) Message() (Bid, error) {
return WrappedBuilderBidElectra(b.p.Message)
}

// Signature --
func (b signedBuilderBidElectra) Signature() []byte {
return b.p.Signature
}

// Version --
func (b signedBuilderBidElectra) Version() int {
return version.Electra
}

// IsNil --
func (b signedBuilderBidElectra) IsNil() bool {
return b.p == nil
}
10 changes: 10 additions & 0 deletions api/client/builder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ func (c *Client) GetHeader(ctx context.Context, slot primitives.Slot, parentHash
return nil, errors.Wrapf(err, "error unmarshaling the builder GetHeader response, using slot=%d, parentHash=%#x, pubkey=%#x", slot, parentHash, pubkey)
}
switch strings.ToLower(v.Version) {
case strings.ToLower(version.String(version.Electra)):
hr := &ExecHeaderResponseElectra{}
if err := json.Unmarshal(hb, hr); err != nil {
return nil, errors.Wrapf(err, "error unmarshaling the builder GetHeader response, using slot=%d, parentHash=%#x, pubkey=%#x", slot, parentHash, pubkey)
}
p, err := hr.ToProto()
if err != nil {
return nil, errors.Wrapf(err, "could not extract proto message from header")
}
return WrappedSignedBuilderBidElectra(p)
case strings.ToLower(version.String(version.Deneb)):
hr := &ExecHeaderResponseDeneb{}
if err := json.Unmarshal(hb, hr); err != nil {
Expand Down
Loading
Loading