-
Notifications
You must be signed in to change notification settings - Fork 1.3k
builder: deneb and handling blobs #12477
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import ( | |
| "github.com/prysmaticlabs/prysm/v4/monitoring/tracing" | ||
| "github.com/prysmaticlabs/prysm/v4/network" | ||
| "github.com/prysmaticlabs/prysm/v4/network/authorization" | ||
| v1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1" | ||
| ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" | ||
| "github.com/prysmaticlabs/prysm/v4/runtime/version" | ||
| log "github.com/sirupsen/logrus" | ||
|
|
@@ -86,7 +87,7 @@ type BuilderClient interface { | |
| NodeURL() string | ||
| GetHeader(ctx context.Context, slot primitives.Slot, parentHash [32]byte, pubkey [48]byte) (SignedBid, error) | ||
| RegisterValidator(ctx context.Context, svr []*ethpb.SignedValidatorRegistrationV1) error | ||
| SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, error) | ||
| SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock, blobs []*ethpb.SignedBlindedBlobSidecar) (interfaces.ExecutionData, *v1.BlobsBundle, error) | ||
| Status(ctx context.Context) error | ||
| } | ||
|
|
||
|
|
@@ -220,6 +221,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.Deneb)): | ||
| hr := &ExecHeaderResponseDeneb{} | ||
| 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 WrappedSignedBuilderBidDeneb(p) | ||
| case strings.ToLower(version.String(version.Capella)): | ||
| hr := &ExecHeaderResponseCapella{} | ||
| if err := json.Unmarshal(hb, hr); err != nil { | ||
|
|
@@ -274,20 +285,20 @@ func (c *Client) RegisterValidator(ctx context.Context, svr []*ethpb.SignedValid | |
|
|
||
| // SubmitBlindedBlock calls the builder API endpoint that binds the validator to the builder and submits the block. | ||
| // The response is the full execution payload used to create the blinded block. | ||
| func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock) (interfaces.ExecutionData, error) { | ||
| func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlySignedBeaconBlock, blobs []*ethpb.SignedBlindedBlobSidecar) (interfaces.ExecutionData, *v1.BlobsBundle, error) { | ||
| if !sb.IsBlinded() { | ||
| return nil, errNotBlinded | ||
| return nil, nil, errNotBlinded | ||
| } | ||
| switch sb.Version() { | ||
| case version.Bellatrix: | ||
| psb, err := sb.PbBlindedBellatrixBlock() | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "could not get protobuf block") | ||
| return nil, nil, errors.Wrapf(err, "could not get protobuf block") | ||
| } | ||
| b := &SignedBlindedBeaconBlockBellatrix{SignedBlindedBeaconBlockBellatrix: psb} | ||
| body, err := json.Marshal(b) | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "error encoding the SignedBlindedBeaconBlockBellatrix value body in SubmitBlindedBlock") | ||
| return nil, nil, errors.Wrap(err, "error encoding the SignedBlindedBeaconBlockBellatrix value body in SubmitBlindedBlock") | ||
| } | ||
|
|
||
| versionOpt := func(r *http.Request) { | ||
|
|
@@ -296,29 +307,33 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS | |
| rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt) | ||
|
|
||
| if err != nil { | ||
| return nil, errors.Wrap(err, "error posting the SignedBlindedBeaconBlockBellatrix to the builder api") | ||
| return nil, nil, errors.Wrap(err, "error posting the SignedBlindedBeaconBlockBellatrix to the builder api") | ||
| } | ||
| ep := &ExecPayloadResponse{} | ||
| if err := json.Unmarshal(rb, ep); err != nil { | ||
| return nil, errors.Wrap(err, "error unmarshaling the builder SubmitBlindedBlock response") | ||
| return nil, nil, errors.Wrap(err, "error unmarshaling the builder SubmitBlindedBlock response") | ||
| } | ||
| if strings.ToLower(ep.Version) != version.String(version.Bellatrix) { | ||
| return nil, errors.New("not a bellatrix payload") | ||
| return nil, nil, errors.New("not a bellatrix payload") | ||
| } | ||
| p, err := ep.ToProto() | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "could not extract proto message from payload") | ||
| return nil, nil, errors.Wrapf(err, "could not extract proto message from payload") | ||
| } | ||
| return blocks.WrappedExecutionPayload(p) | ||
| payload, err := blocks.WrappedExecutionPayload(p) | ||
| if err != nil { | ||
| return nil, nil, errors.Wrapf(err, "could not wrap execution payload in interface") | ||
| } | ||
| return payload, nil, nil | ||
| case version.Capella: | ||
| psb, err := sb.PbBlindedCapellaBlock() | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "could not get protobuf block") | ||
| return nil, nil, errors.Wrapf(err, "could not get protobuf block") | ||
| } | ||
| b := &SignedBlindedBeaconBlockCapella{SignedBlindedBeaconBlockCapella: psb} | ||
| body, err := json.Marshal(b) | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "error encoding the SignedBlindedBeaconBlockCapella value body in SubmitBlindedBlockCapella") | ||
| return nil, nil, errors.Wrap(err, "error encoding the SignedBlindedBeaconBlockCapella value body in SubmitBlindedBlockCapella") | ||
| } | ||
|
|
||
| versionOpt := func(r *http.Request) { | ||
|
|
@@ -327,22 +342,58 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS | |
| rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt) | ||
|
|
||
| if err != nil { | ||
| return nil, errors.Wrap(err, "error posting the SignedBlindedBeaconBlockCapella to the builder api") | ||
| return nil, nil, errors.Wrap(err, "error posting the SignedBlindedBeaconBlockCapella to the builder api") | ||
| } | ||
| ep := &ExecPayloadResponseCapella{} | ||
| if err := json.Unmarshal(rb, ep); err != nil { | ||
| return nil, errors.Wrap(err, "error unmarshaling the builder SubmitBlindedBlockCapella response") | ||
| return nil, nil, errors.Wrap(err, "error unmarshaling the builder SubmitBlindedBlockCapella response") | ||
| } | ||
| if strings.ToLower(ep.Version) != version.String(version.Capella) { | ||
| return nil, errors.New("not a capella payload") | ||
| return nil, nil, errors.New("not a capella payload") | ||
| } | ||
| p, err := ep.ToProto() | ||
| if err != nil { | ||
| return nil, errors.Wrapf(err, "could not extract proto message from payload") | ||
| return nil, nil, errors.Wrapf(err, "could not extract proto message from payload") | ||
| } | ||
| payload, err := blocks.WrappedExecutionPayloadCapella(p, 0) | ||
| if err != nil { | ||
| return nil, nil, errors.Wrapf(err, "could not wrap execution payload in interface") | ||
| } | ||
| return payload, nil, nil | ||
| case version.Deneb: | ||
| psb, err := sb.PbBlindedDenebBlock() | ||
| if err != nil { | ||
| return nil, nil, errors.Wrapf(err, "could not get protobuf block") | ||
| } | ||
|
|
||
| b := ðpb.SignedBlindedBeaconBlockAndBlobsDeneb{Block: psb, Blobs: blobs} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any additional checks needed for blobs here?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we are good here |
||
| body, err := json.Marshal(b) | ||
| if err != nil { | ||
| return nil, nil, errors.Wrap(err, "error encoding the SignedBlindedBeaconBlockDeneb value body in SubmitBlindedBlockDeneb") | ||
| } | ||
|
|
||
| versionOpt := func(r *http.Request) { | ||
| r.Header.Add("Eth-Consensus-Version", version.String(version.Deneb)) | ||
| } | ||
| rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt) | ||
| ep := &ExecPayloadResponseDeneb{} | ||
| if err := json.Unmarshal(rb, ep); err != nil { | ||
| return nil, nil, errors.Wrap(err, "error unmarshaling the builder SubmitBlindedBlockDeneb response") | ||
| } | ||
| if strings.ToLower(ep.Version) != version.String(version.Deneb) { | ||
| return nil, nil, errors.New("not a deneb payload") | ||
| } | ||
| p, blobBundle, err := ep.ToProto() | ||
| if err != nil { | ||
| return nil, nil, errors.Wrapf(err, "could not extract proto message from payload") | ||
| } | ||
| payload, err := blocks.WrappedExecutionPayloadDeneb(p, 0) | ||
| if err != nil { | ||
| return nil, nil, errors.Wrapf(err, "could not wrap execution payload in interface") | ||
| } | ||
| return blocks.WrappedExecutionPayloadCapella(p, 0) | ||
| return payload, blobBundle, nil | ||
| default: | ||
| return nil, fmt.Errorf("unsupported block version %s", version.String(sb.Version())) | ||
| return nil, nil, fmt.Errorf("unsupported block version %s", version.String(sb.Version())) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move these before or after
builderBidDenebmethods