-
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
Unwrap payload bid #14035
Unwrap payload bid #14035
Conversation
//d := time.Now().Add(defaultEngineTimeout) | ||
//ctx, cancel := context.WithDeadline(ctx, d) | ||
//defer cancel() |
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.
What should we do about these commented code?
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.
✂️
@@ -154,7 +155,7 @@ func TestConstructGenericBeaconBlock(t *testing.T) { | |||
t.Run("phase0 block", func(t *testing.T) { | |||
b, err := blocks.NewSignedBeaconBlock(util.NewBeaconBlock()) | |||
require.NoError(t, err) | |||
result, err := vs.constructGenericBeaconBlock(b, nil) | |||
result, err := vs.constructGenericBeaconBlock(b, nil, primitives.ZeroWei) |
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.
note to self: primitives.ZeroWei
should be a func that returns a new value each call. Returning a pointer type risks some code mutating it accidentally.
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'm going to fix this in a follow-up PR.
log.WithError(err).Error("Could not get builder payload") | ||
} else if builderBid == nil { | ||
builderGetPayloadMissCount.Inc() | ||
log.WithError(err).Error("Could not get builder payload") |
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 is wonky, I actually don't think we need to do anything if err == nil && builderBid == nil
- this means getBuilderPayloadAndBlobs
decided we didn't need to call the builder, because it's disabled or pre-bellatrix.
res, err := vs.ExecutionEngineCaller.GetPayload(ctx, pid, slot) | ||
if err == nil { | ||
//payload, bundle, overrideBuilder := res.ExecutionData, res.BlobsBundle, res.OverrideBuilder | ||
//bundleCache.add(slot, bundle) |
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.
✂️
return payload, overrideBuilder, nil | ||
|
||
// TODO: remove bundleCache code | ||
//bundleCache.add(slot, res.BlobsBundle) |
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.
✂️
} | ||
winningBid := primitives.ZeroWei | ||
var bundle *enginev1.BlobsBundle | ||
if slots.ToEpoch(sBlk.Block().Slot()) >= params.BeaconConfig().BellatrixForkEpoch { |
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.
dumb question maybe, do we have to check in this way to account for forks? instead of checking the block/state version?
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.
As to why I did it this way, I think I was copying existing code in setExecutionData
(which this method calls). I don't mind changing it though.
if err != nil { | ||
return nil, nil, errors.Wrap(err, "could not wrap capella payload") | ||
} | ||
return w, nil, s.ErrSubmitBlindedBlock | ||
case version.Deneb: | ||
w, err := blocks.WrappedExecutionPayloadDeneb(s.PayloadDeneb, big.NewInt(0)) | ||
w, err := blocks.WrappedExecutionPayloadDeneb(s.PayloadDeneb) |
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.
should we add electra stuff in this PR? ( I saw some electra stuff but also a lot of other places not accounted for)
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 rather not, I'm only touching electra stuff that needs to be changed in reaction to removing bids from the payload interface.
} | ||
|
||
// Compare payload values between local and builder. Default to the local value if it is higher. | ||
localValueGwei := primitives.WeiToGwei(local.Bid) | ||
builderValueGwei := primitives.WeiToGwei(bid.WeiValue()) |
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.
should we add a function on bid to return GweiValue instead? not sure which is more readable
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 only added the WeiValue method because it encapsulates the tricky reversing logic for accessing a value that is directly stored by the type. IMO the gwei conversion is pretty trivial and doesn't warrant another method.
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.
Also thinking about modifying the Value
method to just be the WeiValue
method since I don't think we want to expose the little endian version, but I'll need to double check usage.
} | ||
return setExecution(blk, execution, false, kzgCommitments) | ||
// TODO: plumb blobs bundle through 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.
is this still a TODO?
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.
nope, will delete
} | ||
|
||
// warnIfFeeRecipientDiffers logs a warning if the fee recipient in the included payload does not | ||
// match the requested one. | ||
func warnIfFeeRecipientDiffers(payload interfaces.ExecutionData, feeRecipient primitives.ExecutionAddress) { | ||
func warnIfFeeRecipientDiffers(payload, val []byte) { |
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.
these parameters feel harder to read, is there a better name for this? ( not a big deal , just a comment)
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 thought this was more clear since both parameters are fee recipients and now have the same type (previously one was called feeRecipient
, which is also in the fuction name, and yeah they're both fee recipients). The function name tells you that you are comparing fee recipients, I figured it would be clear that one is the fee recipient from the payload, and the other is the one from the validator registration. Maybe the val
name is too ambiguous and something like this would be more clear?
func warnIfFeeRecipientDiffers(payload, registration []byte) {
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.
func warnIfFeeRecipientDiffers(payload, registration []byte) {
yeah i think that may be better 👍
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.
Even more simple: func warnIfFeeRecipientDiffers(want, got []byte) {
What type of PR is this?
Other
What does this PR do? Why is it needed?
This PR removes the need for types that satisfy
ExecutionData
to internally carry bid values in wei/gwei. The payload bid is a separate piece of data from the payload and coupling them together creates complexity outside of the small proposal code path where it applies.Which issues(s) does this PR fix?
This PR is setting the stage for further simplification of the consesus-types package. By bringing
ExecutionData
closer to the spec types, we can begin to reduce the number of different representations for the type.This is a big set of changes but I built it up in layers, so if you look at the individual commits that should make the review more managable. Feedback to break this up to a smaller commit is welcome - I can strip off the newest commits that remove helper methods from
consensus-types
without breaking the earlier changes in proposal or engine code.