Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
62dca08
wip
james-prysm Feb 21, 2025
91754b9
refactoring functions for easier readability
james-prysm Feb 21, 2025
8a2dc57
allow ssz for register validator
james-prysm Feb 21, 2025
0cb1807
Merge branch 'develop' into builder-ssz
james-prysm Feb 21, 2025
0a677c9
changelog
james-prysm Feb 21, 2025
750abf3
adding in blinded block submission tests
james-prysm Feb 21, 2025
17338be
adding in tests for header ssz
james-prysm Feb 21, 2025
b1a8036
fixing linting and tests
james-prysm Feb 24, 2025
6399b5a
Merge branch 'develop' into builder-ssz
james-prysm Feb 24, 2025
33adbf6
adding in custom errors and fixing ssz validator registration
james-prysm Feb 24, 2025
490409d
Merge branch 'develop' into builder-ssz
james-prysm Feb 26, 2025
dd7d22c
Merge branch 'develop' into builder-ssz
james-prysm Feb 27, 2025
d954d4c
Merge branch 'develop' into builder-ssz
james-prysm Mar 3, 2025
d032738
Update api/client/builder/client.go
james-prysm Mar 4, 2025
325b6b5
Update api/client/builder/client.go
james-prysm Mar 4, 2025
863553b
Merge branch 'develop' into builder-ssz
james-prysm Mar 4, 2025
5a792a6
manu's feedback
james-prysm Mar 4, 2025
dceb51b
Merge branch 'develop' into builder-ssz
james-prysm Mar 4, 2025
8047191
linting
james-prysm Mar 4, 2025
1932f79
Merge branch 'develop' into builder-ssz
james-prysm Mar 5, 2025
69c8168
Merge branch 'develop' into builder-ssz
james-prysm Mar 11, 2025
86b83cd
adding in info log to notify that this setting was turned on
james-prysm Mar 11, 2025
46dbe67
fixing linting
james-prysm Mar 12, 2025
e726fd6
manu's feedback
james-prysm Mar 14, 2025
ce21af6
Merge branch 'develop' into builder-ssz
james-prysm Mar 14, 2025
aebf5ad
fixing import
james-prysm Mar 14, 2025
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
53 changes: 29 additions & 24 deletions api/client/builder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: else not needed.

Could be:

if ver >= version.Electra {
   return ...
}

if ver >=  version.Deneb {
   return ...
}

...

return nil, fmt.Errorf("unsupported header version %s", versionHeader)

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)
}
}
Expand Down Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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))
}
}
Expand Down