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: deneb and handling blobs #12477

Merged
merged 1 commit into from
Jun 14, 2023
Merged

Conversation

james-prysm
Copy link
Contributor

@james-prysm james-prysm commented May 30, 2023

What type of PR is this?
Feature

What does this PR do? Why is it needed?

Introduces deneb block and blobs to builder

implements changes from
ethereum/builder-specs#80
ethereum/builder-specs#79
ethereum/builder-specs#61

ethereum/consensus-specs#3391
ethereum/consensus-specs#3392

part of #12248

@james-prysm james-prysm changed the title adding builder changes to handle blobs builder: deneb and handling blobs May 31, 2023
@james-prysm james-prysm force-pushed the builder-deneb branch 2 times, most recently from 7a66220 to c3925b7 Compare June 1, 2023 03:59
return nil, ErrNoBuilder
return nil, nil, ErrNoBuilder
}
if blobs != nil && uint64(len(blobs)) > fieldparams.MaxBlobsPerBlock {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do i need this check here?

Copy link
Member

Choose a reason for hiding this comment

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

I dont think you need blobs != nil here

return nil, nil, errors.Wrapf(err, "could not get protobuf block")
}

b := &ethpb.SignedBlindedBeaconBlockAndBlobsDeneb{Block: psb, Blobs: blobs}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

any additional checks needed for blobs here?

Copy link
Member

Choose a reason for hiding this comment

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

I think we are good here

@james-prysm james-prysm marked this pull request as ready for review June 5, 2023 16:59
@james-prysm james-prysm requested a review from a team as a code owner June 5, 2023 16:59
@james-prysm james-prysm requested review from prestonvanloon, saolyn, potuz and terencechain and removed request for a team June 5, 2023 16:59
Comment on lines +276 to +292
// Signature --
func (b signedBuilderBidDeneb) Signature() []byte {
return b.p.Signature
}

// Version --
func (b signedBuilderBidDeneb) Version() int {
return version.Deneb
}

// IsNil --
func (b signedBuilderBidDeneb) IsNil() bool {
return b.p == nil
}
Copy link
Member

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 builderBidDeneb methods

return nil, nil, errors.Wrapf(err, "could not get protobuf block")
}

b := &ethpb.SignedBlindedBeaconBlockAndBlobsDeneb{Block: psb, Blobs: blobs}
Copy link
Member

Choose a reason for hiding this comment

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

I think we are good here

blobs := make([][]byte, len(b.Blobs))
for i := range b.Blobs {
blobs[i] = b.Blobs[i]
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably check the length here similar to the above fieldparams.BlobLength

func (b BlobsBundle) ToProto() (*v1.BlobsBundle, error) {
commitments := make([][]byte, len(b.Commitments))
for i := range b.Commitments {
if len(b.Commitments[i]) != 48 {
Copy link
Member

Choose a reason for hiding this comment

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

Replace 48 with fieldparams.BLSPubkeyLength

name: "ExecPayloadResponse.ExecutionPayload.BlockHash",
},
{
expected: "1",
Copy link
Member

Choose a reason for hiding this comment

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

DataGasUsed and ExcessDataGas should be using different values to avoid mix up

Comment on lines 1040 to 1041
DataGasUsed: 1,
ExcessDataGas: 1,
Copy link
Member

Choose a reason for hiding this comment

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

Let's use different values here

Comment on lines +1315 to +1316
DataGasUsed: 1,
ExcessDataGas: 1,
Copy link
Member

Choose a reason for hiding this comment

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

Let's use different values here

return nil, ErrNoBuilder
return nil, nil, ErrNoBuilder
}
if blobs != nil && uint64(len(blobs)) > fieldparams.MaxBlobsPerBlock {
Copy link
Member

Choose a reason for hiding this comment

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

I dont think you need blobs != nil here

@james-prysm james-prysm force-pushed the builder-deneb branch 3 times, most recently from 25b25cc to ae02dcd Compare June 5, 2023 21:30
@james-prysm james-prysm requested a review from rkapka June 6, 2023 14:43
Copy link
Contributor

@rkapka rkapka left a comment

Choose a reason for hiding this comment

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

We should make safe copies when converting to proto objects


// Header --
func (b builderBidDeneb) Header() (interfaces.ExecutionData, error) {
if b.p == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should either verify b.p in all getters or skip it everywhere. Since we error out in the constructor when wrapping a nil object, I would just remove it.

return nil, errors.New("builder bid is nil")
}
// We have to convert big endian to little endian because the value is coming from the execution layer.
v := big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(b.p.Value))
Copy link
Contributor

Choose a reason for hiding this comment

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

I would extract math.WeiToGwei(big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(b.p.Value))) to a function and reuse it for Capella/Deneb/etc.

api/client/builder/client.go Outdated Show resolved Hide resolved
api/client/builder/client.go Outdated Show resolved Hide resolved
api/client/builder/client.go Outdated Show resolved Hide resolved
return payload, bundle, nil
}

func (p *ExecutionPayloadDeneb) ToProto() (*v1.ExecutionPayloadDeneb, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We make unsafe copies everywhere

proto/engine/v1/execution_engine.proto Outdated Show resolved Hide resolved
testing/util/blob.go Outdated Show resolved Hide resolved
testing/util/blob.go Outdated Show resolved Hide resolved
@@ -43,6 +43,10 @@ func NewBlindedBeaconBlockDeneb() *ethpb.SignedBlindedBeaconBlockDeneb {
return HydrateSignedBlindedBeaconBlockDeneb(&ethpb.SignedBlindedBeaconBlockDeneb{})
}

func NewBlindedBlobSidecar() *ethpb.SignedBlindedBlobSidecar {
Copy link
Contributor

Choose a reason for hiding this comment

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

godoc missing

@terencechain terencechain force-pushed the deneb-integration branch 2 times, most recently from 69b60fc to ceb1ad3 Compare June 12, 2023 19:43
Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

It's not entirely clear to me on why we need to copy. To be clear, I'm not against it but I will like to under why. We have similar implementations that we don't copy so there seems to be a miss alignment. Ex: consensus-types/blocks/execution.go

@terencechain terencechain dismissed their stale review June 13, 2023 01:49

sorry, wrong PR

@james-prysm james-prysm requested a review from rkapka June 13, 2023 15:19
@@ -369,9 +369,11 @@ func (p *Builder) handleHeadeRequestCapella(w http.ResponseWriter) {
return
}
v := big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(b.Value))
// used for testing bid values
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment doesn't really explain what's special about multiplying by 2. I think adding Nishant's explanation will be better:

we set the payload value as twice its actual one so that it always chooses builder payloads vs local payloads

Comment on lines 216 to 217
// Wei is the smallest unit of Ether, and sent in the payload value of the execution engine API call.
// represented as a pointer to a bigInt.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Wei is the smallest unit of Ether, and sent in the payload value of the execution engine API call.
// represented as a pointer to a bigInt.
// Wei is the smallest unit of Ether, represented as a pointer to a bigInt.

I don't think a type definition should specify a particular use case, although it's a nitpick really.

@james-prysm james-prysm merged commit 4ba782a into deneb-integration Jun 14, 2023
@james-prysm james-prysm deleted the builder-deneb branch June 14, 2023 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants