Skip to content

Builder: Electra - #14344

Merged
james-prysm merged 74 commits into
developfrom
builder-electra
Jan 23, 2025
Merged

Builder: Electra#14344
james-prysm merged 74 commits into
developfrom
builder-electra

Conversation

@james-prysm

@james-prysm james-prysm commented Aug 14, 2024

Copy link
Copy Markdown
Contributor

What type of PR is this?

Feature

What does this PR do? Why is it needed?

implements ethereum/builder-specs#101

does not include

Which issues(s) does this PR fix?

Fixes #

Other notes for review

Comment thread go.mod Outdated
// See https://github.com/prysmaticlabs/grpc-gateway/issues/2
replace github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20230315201114-09284ba20446

replace github.com/ethereum/go-ethereum => github.com/lightclient/go-ethereum v1.10.10-0.20240726203109-4a0622f95d30

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

temp uses lightclient's fork to use the updated libraries in e2e

@james-prysm james-prysm changed the title Builder electra Builder: Electra Sep 24, 2024
if !ok {
return nil, errors.New("builder returned non-electra bid")
}
for _, c := range kzgCommitments {

@james-prysm james-prysm Oct 17, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removing this validation as we already validate when we convert the bid from json to proto in func (bb *BuilderBidElectra) ToProto() (*eth.BuilderBidElectra, error) {

Comment thread consensus-types/blocks/setters.go Outdated
return consensus_types.ErrNotSupported("SetExecutionRequests", b.version)
}
if req == nil {
return errors.New("nil execution request")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should I throw an error or just set it to an empty request object?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In my opinion it's bad practice to have different ways of handling the same thing within one package. We don't check this in other setters, so we should just skip it here too.

http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
p.currVersion = version.Electra

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i'm not sure if this is the best way to do it, it's because the payload is still deneb so I can't do it by payload version

_, err := c.GetHeader(ctx, slot, bytesutil.ToBytes32(parentHash), bytesutil.ToBytes48(pubkey))
require.ErrorContains(t, "could not extract proto message from header: too many blob commitments: 7", err)
})
t.Run("electra", func(t *testing.T) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should i add any more kinds of tests?

Comment on lines +83 to +97
bidDeneb, ok := bid.(builder.BidDeneb)
if !ok {
log.Warnf("bid type %T does not implement builder.BidDeneb ", bid)
} else {
builderKzgCommitments = bidDeneb.BlobKzgCommitments()
}
}

var executionRequests *enginev1.ExecutionRequests
if bid.Version() >= version.Electra {
bidElectra, ok := bid.(builder.BidElectra)
if !ok {
log.Warnf("bid type %T does not implement builder.BidElectra ", bid)
} else {
executionRequests = bidElectra.ExecutionRequests()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we dont need to do this until after: higherValueBuilder && withdrawalsMatched
for the default bellatrix case, we can just set them as nil: setBuilderExecution(blk, builderPayload, nil, nil)

if isBlinded {
requestsErr = "failed to set builder execution requests"
}
if err := blk.SetExecutionRequests(requests); err != nil {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If a builder returns us an invalid execution requests, shouldn't we default to local block?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

isn't that what we do? it returns an error and then it falls back to

	if err := setBuilderExecution(blk, builderPayload, builderKzgCommitments, executionRequests); err != nil {
				log.WithError(err).Warn("Proposer: failed to set builder payload")
				return local.Bid, local.BlobsBundle, setLocalExecution(blk, local)

}

// ExecHeaderResponseElectra is the header response for builder API /eth/v1/builder/header/{slot}/{parent_hash}/{pubkey}.
type ExecHeaderResponseElectra struct {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good question i'm not sure i should fix the old ones too

Comment thread api/client/builder/types.go Outdated
if bb.ExecutionRequests == nil {
return nil, errors.New("execution requests is empty")
}
ExecutionRequests, err := bb.ExecutionRequests.ToProto()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is ExecutionRequests cap?

Comment thread config/params/config.go
}

// MaxBlobsPerBlockByVersion returns the maximum number of blobs per block for the given fork version
func (b *BeaconChainConfig) MaxBlobsPerBlockByVersion(v int) int {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add a test for this helper function

Comment thread api/client/builder/types.go Outdated
Comment thread api/client/builder/types.go Outdated
Comment thread api/client/builder/types.go Outdated
Comment thread api/client/builder/types.go Outdated
Comment thread beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go Outdated
Comment thread beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go Outdated
Comment thread beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go Outdated
Comment thread beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go Outdated
Comment thread consensus-types/blocks/setters.go Outdated
return consensus_types.ErrNotSupported("SetExecutionRequests", b.version)
}
if req == nil {
return errors.New("nil execution request")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In my opinion it's bad practice to have different ways of handling the same thing within one package. We don't check this in other setters, so we should just skip it here too.

james-prysm and others added 8 commits January 23, 2025 08:10
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
@james-prysm
james-prysm enabled auto-merge January 23, 2025 17:37
@james-prysm
james-prysm added this pull request to the merge queue Jan 23, 2025
Merged via the queue into develop with commit 2c78e50 Jan 23, 2025
@james-prysm
james-prysm deleted the builder-electra branch January 23, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants