-
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
New prysm get block RPC #11834
New prysm get block RPC #11834
Conversation
61abc7c
to
144b800
Compare
I am marking it as blocked. I want to test this with mev-boost |
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not prepare blind beacon block: %v", err) | ||
} | ||
if !ok { | ||
return nil, status.Error(codes.Unavailable, "Builder is not available due to miss-config or circuit breaker") |
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 error right now?
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 a beacon API for retrieving blind blocks (only). By the beacon API definition, you must return a valid blind block or fail. Very different than our current implementation used by Prysm API
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 mean are you sure that the only failures are miss-config or circuit breaker in this path?
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.
The error msg is wrong. I'll update
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not fetch Altair beacon block: %v", err) | ||
log.WithError(err).Error("Could not pack deposits and attestations") |
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.
Same here, do we need to set the empty deposits and attestations here or the marshaller takes care of it automatically?
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 this one is fine since those are not vectors but I added anyway
return vs.getBellatrixBeaconBlock(ctx, req) | ||
// Set bls to execution change. New in Capella. | ||
if err := vs.setBlsToExecData(blk, head); err != nil { | ||
return nil, status.Errorf(codes.Internal, "Could not set bls to execution data: %v", err) |
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 a non-blocking error, a block is valid with an empty bls-to-exec-changes slice.
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.
Nice catch!
return nil, fmt.Errorf("could not build block data: %v", err) | ||
func (vs *Server) setSyncAggregate(ctx context.Context, blk interfaces.BeaconBlock) { | ||
slot := blk.Slot() | ||
if slot == 0 || slots.ToEpoch(slot) < params.BeaconConfig().AltairForkEpoch { |
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 feel there's something wrong here. For networks that start with AltairForkEpoch == 0
this should not fail. The problem is the slot - 1
statement below. In any case, we should never reach this point as there's no proposing on slot 0.
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.
Ok, maybe a cleaner check should be based on block version
if err := blk.Body().SetSyncAggregate(ðpb.SyncAggregate{ | ||
SyncCommitteeBits: make([]byte, params.BeaconConfig().SyncCommitteeSize), | ||
SyncCommitteeSignature: make([]byte, fieldparams.BLSSignatureLength), |
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 don't think this is a valid empty sync committee signature. Take a look a my helper functions on testing/util for an example on how to sign with the point at infinity in the BLS curve.
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.
Nice catch!
) | ||
|
||
// Sets the bls to exec data for a block. | ||
func (vs *Server) setBlsToExecData(blk interfaces.BeaconBlock, headState state.BeaconState) 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.
I think it's better to deal with the error case withing this function. That is this function does not return an error, and if the call to SetBLSToExecutionChanges
errors out, we set the empty slice 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.
Agree
blk.Body().SetDeposits([]*ethpb.Deposit{}) | ||
blk.Body().SetAttestations([]*ethpb.Attestation{}) |
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 need to go outside of the if/else block and remove the else block
log.WithError(err).Error("Could not get bls to execution changes") | ||
} else { | ||
if err := blk.Body().SetBLSToExecutionChanges(changes); err != nil { | ||
if err := blk.Body().SetBLSToExecutionChanges([]*ethpb.SignedBLSToExecutionChange{}); err != nil { | ||
log.WithError(err).Error("Could not set bls to execution data in block") |
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 part of the requests in my feedback was to remove the error return in this function, so that we don't need to be doing this if/else in multiple places.
e05915f
to
575e523
Compare
What type of PR is this?
What does this PR do? Why is it needed?
This PR rewrites
GetBlock
Prysm RPC to be better, cleaner, and more extensive. In the end, we were able to delete much of the "spaghetti" code. This piece of the code is already live incapella
branch and utilized in all the Capella and eip-4844 testnets. This is the original PR which documents the workflow: #11721I'm still working on more unit tests so please hold off on the detailed reviews