-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
f42b326
to
0c7f3cc
Compare
7a66220
to
c3925b7
Compare
beacon-chain/builder/service.go
Outdated
return nil, ErrNoBuilder | ||
return nil, nil, ErrNoBuilder | ||
} | ||
if blobs != nil && uint64(len(blobs)) > fieldparams.MaxBlobsPerBlock { |
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.
Do i need this check here?
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.
I dont think you need blobs != nil
here
return nil, nil, errors.Wrapf(err, "could not get protobuf block") | ||
} | ||
|
||
b := ðpb.SignedBlindedBeaconBlockAndBlobsDeneb{Block: psb, Blobs: blobs} |
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.
any additional checks needed for blobs here?
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.
I think we are good here
153380c
to
4216dd8
Compare
// 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 | ||
} |
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.
let's move these before or after builderBidDeneb
methods
return nil, nil, errors.Wrapf(err, "could not get protobuf block") | ||
} | ||
|
||
b := ðpb.SignedBlindedBeaconBlockAndBlobsDeneb{Block: psb, Blobs: blobs} |
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.
I think we are good here
blobs := make([][]byte, len(b.Blobs)) | ||
for i := range b.Blobs { | ||
blobs[i] = b.Blobs[i] | ||
} |
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.
I'd probably check the length here similar to the above fieldparams.BlobLength
api/client/builder/types.go
Outdated
func (b BlobsBundle) ToProto() (*v1.BlobsBundle, error) { | ||
commitments := make([][]byte, len(b.Commitments)) | ||
for i := range b.Commitments { | ||
if len(b.Commitments[i]) != 48 { |
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.
Replace 48 with fieldparams.BLSPubkeyLength
api/client/builder/types_test.go
Outdated
name: "ExecPayloadResponse.ExecutionPayload.BlockHash", | ||
}, | ||
{ | ||
expected: "1", |
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.
DataGasUsed
and ExcessDataGas
should be using different values to avoid mix up
api/client/builder/types_test.go
Outdated
DataGasUsed: 1, | ||
ExcessDataGas: 1, |
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.
Let's use different values here
DataGasUsed: 1, | ||
ExcessDataGas: 1, |
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.
Let's use different values here
beacon-chain/builder/service.go
Outdated
return nil, ErrNoBuilder | ||
return nil, nil, ErrNoBuilder | ||
} | ||
if blobs != nil && uint64(len(blobs)) > fieldparams.MaxBlobsPerBlock { |
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.
I dont think you need blobs != nil
here
25b25cc
to
ae02dcd
Compare
ccf3258
to
ab9623e
Compare
4fd3bef
to
bd554c4
Compare
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.
We should make safe copies when converting to proto objects
api/client/builder/bid.go
Outdated
|
||
// Header -- | ||
func (b builderBidDeneb) Header() (interfaces.ExecutionData, error) { | ||
if b.p == nil { |
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.
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.
api/client/builder/bid.go
Outdated
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)) |
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.
I would extract math.WeiToGwei(big.NewInt(0).SetBytes(bytesutil.ReverseByteOrder(b.p.Value)))
to a function and reuse it for Capella/Deneb/etc.
return payload, bundle, nil | ||
} | ||
|
||
func (p *ExecutionPayloadDeneb) ToProto() (*v1.ExecutionPayloadDeneb, error) { |
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.
We make unsafe copies everywhere
@@ -43,6 +43,10 @@ func NewBlindedBeaconBlockDeneb() *ethpb.SignedBlindedBeaconBlockDeneb { | |||
return HydrateSignedBlindedBeaconBlockDeneb(ðpb.SignedBlindedBeaconBlockDeneb{}) | |||
} | |||
|
|||
func NewBlindedBlobSidecar() *ethpb.SignedBlindedBlobSidecar { |
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.
godoc missing
69b60fc
to
ceb1ad3
Compare
7b92a6c
to
fbaafd9
Compare
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.
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
@@ -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 |
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.
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
math/math_helper.go
Outdated
// 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. |
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.
// 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.
f67e3bb
to
6b0a45f
Compare
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