-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Builder ssz #14976
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
Builder ssz #14976
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
62dca08
wip
james-prysm 91754b9
refactoring functions for easier readability
james-prysm 8a2dc57
allow ssz for register validator
james-prysm 0cb1807
Merge branch 'develop' into builder-ssz
james-prysm 0a677c9
changelog
james-prysm 750abf3
adding in blinded block submission tests
james-prysm 17338be
adding in tests for header ssz
james-prysm b1a8036
fixing linting and tests
james-prysm 6399b5a
Merge branch 'develop' into builder-ssz
james-prysm 33adbf6
adding in custom errors and fixing ssz validator registration
james-prysm 490409d
Merge branch 'develop' into builder-ssz
james-prysm dd7d22c
Merge branch 'develop' into builder-ssz
james-prysm d954d4c
Merge branch 'develop' into builder-ssz
james-prysm d032738
Update api/client/builder/client.go
james-prysm 325b6b5
Update api/client/builder/client.go
james-prysm 863553b
Merge branch 'develop' into builder-ssz
james-prysm 5a792a6
manu's feedback
james-prysm dceb51b
Merge branch 'develop' into builder-ssz
james-prysm 8047191
linting
james-prysm 1932f79
Merge branch 'develop' into builder-ssz
james-prysm 69c8168
Merge branch 'develop' into builder-ssz
james-prysm 86b83cd
adding in info log to notify that this setting was turned on
james-prysm 46dbe67
fixing linting
james-prysm e726fd6
manu's feedback
james-prysm ce21af6
Merge branch 'develop' into builder-ssz
james-prysm aebf5ad
fixing import
james-prysm 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,13 +42,7 @@ var ( | |
| errMalformedHostname = errors.New("hostname must include port, separated by one colon, like example.com:3500") | ||
| errMalformedRequest = errors.New("required request data are missing") | ||
| errNotBlinded = errors.New("submitted block is not blinded") | ||
| blockToPayloadMapping = map[int]int{ | ||
| version.Bellatrix: version.Bellatrix, | ||
| version.Capella: version.Capella, | ||
| version.Deneb: version.Deneb, | ||
| version.Electra: version.Deneb, | ||
| version.Fulu: version.Deneb, | ||
| } | ||
| errVersionUnsupported = errors.New("version is not supported") | ||
| ) | ||
|
|
||
| // ClientOpt is a functional option for the Client type (http.Client wrapper) | ||
|
|
@@ -281,16 +275,15 @@ func (c *Client) parseHeaderResponse(data []byte, header http.Header) (SignedBid | |
| return nil, errors.Wrap(err, fmt.Sprintf("unsupported header version %s", versionHeader)) | ||
| } | ||
|
|
||
| switch { | ||
| case ver >= version.Electra: | ||
| if ver >= version.Electra { | ||
| return c.parseHeaderElectra(data) | ||
| case ver >= version.Deneb: | ||
| } else if ver >= version.Deneb { | ||
| return c.parseHeaderDeneb(data) | ||
| case ver >= version.Capella: | ||
| } else if ver >= version.Capella { | ||
| return c.parseHeaderCapella(data) | ||
| case ver >= version.Bellatrix: | ||
| } else if ver >= version.Bellatrix { | ||
| return c.parseHeaderBellatrix(data) | ||
| default: | ||
| } else { | ||
| return nil, fmt.Errorf("unsupported header version %s", versionHeader) | ||
| } | ||
| } | ||
|
|
@@ -449,6 +442,18 @@ func sszValidatorRegisterRequest(svr []*ethpb.SignedValidatorRegistrationV1) ([] | |
|
|
||
| var errResponseVersionMismatch = errors.New("builder API response uses a different version than requested in " + api.VersionHeader + " header") | ||
|
|
||
| func getVersionsBlockToPayload(blockVersion int) (int, error) { | ||
|
Contributor
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. Same comment about else. |
||
| if blockVersion >= version.Deneb { | ||
| return version.Deneb, nil | ||
| } else if blockVersion == version.Capella { | ||
| return version.Capella, nil | ||
| } else if blockVersion == version.Bellatrix { | ||
| return version.Bellatrix, nil | ||
| } else { | ||
| return 0, errors.Wrapf(errVersionUnsupported, "block version %d", blockVersion) | ||
| } | ||
| } | ||
|
|
||
| // 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, *v1.BlobsBundle, error) { | ||
|
|
@@ -469,13 +474,13 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS | |
| return nil, nil, err | ||
| } | ||
|
|
||
| expectedPayloadVer, ok := blockToPayloadMapping[sb.Version()] | ||
| if !ok { | ||
| return nil, nil, errors.Errorf("unsupported block version %d", sb.Version()) | ||
| expectedPayloadVer, err := getVersionsBlockToPayload(sb.Version()) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
| gotPayloadVer, ok := blockToPayloadMapping[ver] | ||
| if !ok { | ||
| return nil, nil, errors.Errorf("unsupported block version %d", ver) | ||
| gotPayloadVer, err := getVersionsBlockToPayload(ver) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
| if expectedPayloadVer != gotPayloadVer { | ||
| return nil, nil, errors.Wrapf(errResponseVersionMismatch, "expected payload version %d, got %d", expectedPayloadVer, gotPayloadVer) | ||
|
|
@@ -560,8 +565,8 @@ func (c *Client) parseBlindedBlockResponseSSZ( | |
| respBytes []byte, | ||
| forkVersion int, | ||
| ) (interfaces.ExecutionData, *v1.BlobsBundle, error) { | ||
| switch { | ||
| case forkVersion >= version.Deneb: | ||
|
|
||
| if forkVersion >= version.Deneb { | ||
| payloadAndBlobs := &v1.ExecutionPayloadDenebAndBlobsBundle{} | ||
| if err := payloadAndBlobs.UnmarshalSSZ(respBytes); err != nil { | ||
| return nil, nil, errors.Wrap(err, "unable to unmarshal ExecutionPayloadDenebAndBlobsBundle SSZ") | ||
|
|
@@ -571,7 +576,7 @@ func (c *Client) parseBlindedBlockResponseSSZ( | |
| return nil, nil, errors.Wrapf(err, "unable to wrap execution data for %s", version.String(forkVersion)) | ||
| } | ||
| return ed, payloadAndBlobs.BlobsBundle, nil | ||
| case forkVersion >= version.Capella: | ||
| } else if forkVersion >= version.Capella { | ||
| payload := &v1.ExecutionPayloadCapella{} | ||
| if err := payload.UnmarshalSSZ(respBytes); err != nil { | ||
| return nil, nil, errors.Wrap(err, "unable to unmarshal ExecutionPayloadCapella SSZ") | ||
|
|
@@ -581,7 +586,7 @@ func (c *Client) parseBlindedBlockResponseSSZ( | |
| return nil, nil, errors.Wrapf(err, "unable to wrap execution data for %s", version.String(forkVersion)) | ||
| } | ||
| return ed, nil, nil | ||
| case forkVersion >= version.Bellatrix: | ||
| } else if forkVersion >= version.Bellatrix { | ||
| payload := &v1.ExecutionPayload{} | ||
| if err := payload.UnmarshalSSZ(respBytes); err != nil { | ||
| return nil, nil, errors.Wrap(err, "unable to unmarshal ExecutionPayload SSZ") | ||
|
|
@@ -591,7 +596,7 @@ func (c *Client) parseBlindedBlockResponseSSZ( | |
| return nil, nil, errors.Wrapf(err, "unable to wrap execution data for %s", version.String(forkVersion)) | ||
| } | ||
| return ed, nil, nil | ||
| default: | ||
| } else { | ||
| return nil, nil, fmt.Errorf("unsupported header version %s", version.String(forkVersion)) | ||
| } | ||
| } | ||
|
|
||
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.
Nit:
elsenot needed.Could be: