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

Merged
merged 74 commits into from
Jan 23, 2025
Merged

Builder: Electra #14344

merged 74 commits into from
Jan 23, 2025

Conversation

james-prysm
Copy link
Contributor

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

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

@james-prysm james-prysm added Builder PR or issue that supports builder related work Electra electra hardfork labels Aug 14, 2024
@james-prysm james-prysm added the Blocked Blocked by research or external factors label Aug 15, 2024
go.mod Outdated
@@ -284,3 +284,5 @@ replace github.com/json-iterator/go => github.com/prestonvanloon/go v1.1.7-0.201

// 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
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
}
for _, c := range kzgCommitments {
Copy link
Contributor Author

@james-prysm james-prysm Oct 17, 2024

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) {

@@ -179,6 +180,9 @@ func (b *SignedBeaconBlock) SetExecutionRequests(req *enginev1.ExecutionRequests
if b.version < version.Electra {
return consensus_types.ErrNotSupported("SetExecutionRequests", b.version)
}
if req == nil {
return errors.New("nil execution request")
Copy link
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
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
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

@@ -292,6 +292,50 @@ func TestClient_GetHeader(t *testing.T) {
_, 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
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
Member

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
Member

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
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)

@@ -1307,6 +1275,208 @@ func (p *ExecutionPayloadDeneb) ToProto() (*v1.ExecutionPayloadDeneb, error) {
}, nil
}

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

Choose a reason for hiding this comment

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

Why cant the testing middleware uses this struct here?

type ExecHeaderResponseElectra struct {

Copy link
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

if bb.ExecutionRequests == nil {
return nil, errors.New("execution requests is empty")
}
ExecutionRequests, err := bb.ExecutionRequests.ToProto()
Copy link
Member

Choose a reason for hiding this comment

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

Why is ExecutionRequests cap?

@@ -395,6 +395,14 @@ func (b *BeaconChainConfig) MaxBlobsPerBlock(slot primitives.Slot) int {
return b.DeprecatedMaxBlobsPerBlock
}

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

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

api/client/builder/types.go Outdated Show resolved Hide resolved
api/client/builder/types.go Outdated Show resolved Hide resolved
api/client/builder/types.go Outdated Show resolved Hide resolved
api/client/builder/types.go Outdated Show resolved Hide resolved
@@ -179,6 +180,9 @@ func (b *SignedBeaconBlock) SetExecutionRequests(req *enginev1.ExecutionRequests
if b.version < version.Electra {
return consensus_types.ErrNotSupported("SetExecutionRequests", b.version)
}
if req == nil {
return errors.New("nil execution request")
Copy link
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 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
15 checks passed
@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
Builder PR or issue that supports builder related work Electra electra hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants