-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(deneb): proposer rpc to handle builder flow #12554
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d5dfbc6
feat(deneb): proposer rpc to handle builder flow
terencechain 2c8530e
fix: refactor blobs
terencechain d1284cc
test: get block
terencechain db935ce
test: more tests
terencechain 4a0b960
test: fix unblinder
terencechain f5f9478
chrone: renames
terencechain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,7 +148,7 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) ( | |
| return nil, status.Errorf(codes.Internal, "Could not get local payload: %v", err) | ||
| } | ||
|
|
||
| builderPayload, err := vs.getBuilderPayload(ctx, sBlk.Block().Slot(), sBlk.Block().ProposerIndex()) | ||
| builderPayload, blindBlobsBundle, err := vs.getBuilderPayloadAndBlobs(ctx, sBlk.Block().Slot(), sBlk.Block().ProposerIndex()) | ||
| if err != nil { | ||
| builderGetPayloadMissCount.Inc() | ||
| log.WithError(err).Error("Could not get builder payload") | ||
|
|
@@ -158,7 +158,7 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) ( | |
| return nil, status.Errorf(codes.Internal, "Could not set execution data: %v", err) | ||
| } | ||
|
|
||
| if err := setKzgCommitments(sBlk, blobsBundle); err != nil { | ||
| if err := setKzgCommitments(sBlk, blobsBundle, blindBlobsBundle); err != nil { | ||
| return nil, status.Errorf(codes.Internal, "Could not set kzg commitment: %v", err) | ||
| } | ||
|
|
||
|
|
@@ -181,7 +181,18 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) ( | |
| return nil, status.Errorf(codes.Internal, "Could not convert block to proto: %v", err) | ||
| } | ||
| if slots.ToEpoch(req.Slot) >= params.BeaconConfig().DenebForkEpoch { | ||
| // TODO: Handle blind case | ||
| if sBlk.IsBlinded() { | ||
| scs, err := blindBlobsBundleToSidecars(blindBlobsBundle, sBlk.Block()) | ||
| if err != nil { | ||
| return nil, status.Errorf(codes.Internal, "Could not convert blind blobs bundle to sidecar: %v", err) | ||
| } | ||
| blockAndBlobs := ðpb.BlindedBeaconBlockAndBlobsDeneb{ | ||
| Block: pb.(*ethpb.BlindedBeaconBlockDeneb), | ||
| Blobs: scs, | ||
| } | ||
| return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_BlindedDeneb{BlindedDeneb: blockAndBlobs}}, nil | ||
| } | ||
|
|
||
| scs, err := blobsBundleToSidecars(blobsBundle, sBlk.Block()) | ||
| if err != nil { | ||
| return nil, status.Errorf(codes.Internal, "Could not convert blobs bundle to sidecar: %v", err) | ||
|
|
@@ -222,11 +233,18 @@ func (vs *Server) ProposeBeaconBlock(ctx context.Context, req *ethpb.GenericSign | |
| return nil, status.Errorf(codes.InvalidArgument, "%s: %v", CouldNotDecodeBlock, err) | ||
| } | ||
|
|
||
| unblinder, err := newUnblinder(blk, vs.BlockBuilder) | ||
| var blindSidecars []*ethpb.SignedBlindedBlobSidecar | ||
| if blk.Version() >= version.Deneb && blk.IsBlinded() { | ||
| blindSidecars = req.GetBlindedDeneb().Blobs | ||
| } | ||
|
|
||
| unblinder, err := newUnblinder(blk, blindSidecars, vs.BlockBuilder) | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "could not create unblinder") | ||
| } | ||
| blk, err = unblinder.unblindBuilderBlock(ctx) | ||
| blind := unblinder.b.IsBlinded() // | ||
|
|
||
| blk, sidecars, err := unblinder.unblindBuilderBlock(ctx) | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "could not unblind builder block") | ||
| } | ||
|
|
@@ -240,23 +258,25 @@ func (vs *Server) ProposeBeaconBlock(ctx context.Context, req *ethpb.GenericSign | |
| return nil, fmt.Errorf("could not broadcast block: %v", err) | ||
| } | ||
|
|
||
| var scs []*ethpb.SignedBlobSidecar | ||
| if blk.Version() >= version.Deneb { | ||
| b, ok := req.GetBlock().(*ethpb.GenericSignedBeaconBlock_Deneb) | ||
| if !ok { | ||
| return nil, status.Error(codes.Internal, "Could not cast block to Deneb") | ||
| } | ||
| if len(b.Deneb.Blobs) > fieldparams.MaxBlobsPerBlock { | ||
| return nil, status.Errorf(codes.InvalidArgument, "Too many blobs in block: %d", len(b.Deneb.Blobs)) | ||
| if blind { | ||
| scs = sidecars // Use sidecars from unblinder if the block was blinded. | ||
| } else { | ||
| scs, err = extraSidecars(req) // Use sidecars from the request if the block was not blinded. | ||
| if err != nil { | ||
| return nil, errors.Wrap(err, "could not extract blobs") | ||
| } | ||
| } | ||
| scs := make([]*ethpb.BlobSidecar, len(b.Deneb.Blobs)) | ||
| for i, blob := range b.Deneb.Blobs { | ||
| if err := vs.P2P.BroadcastBlob(ctx, blob.Message.Index, blob); err != nil { | ||
| log.WithError(err).Errorf("Could not broadcast blob index %d / %d", i, len(b.Deneb.Blobs)) | ||
| sidecar := make([]*ethpb.BlobSidecar, len(scs)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sidecar -> sidecars? or maybe savableSidecars?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| for i, sc := range scs { | ||
| if err := vs.P2P.BroadcastBlob(ctx, sc.Message.Index, sc); err != nil { | ||
| log.WithError(err).Errorf("Could not broadcast blob sidecar index %d / %d", i, len(scs)) | ||
| } | ||
| scs[i] = blob.Message | ||
| sidecar[i] = sc.Message | ||
| } | ||
| if len(scs) > 0 { | ||
| if err := vs.BeaconDB.SaveBlobSidecar(ctx, scs); err != nil { | ||
| if err := vs.BeaconDB.SaveBlobSidecar(ctx, sidecar); err != nil { | ||
| return nil, err | ||
| } | ||
| } | ||
|
|
@@ -286,6 +306,19 @@ func (vs *Server) ProposeBeaconBlock(ctx context.Context, req *ethpb.GenericSign | |
| }, nil | ||
| } | ||
|
|
||
| // extraSidecars extracts the sidecars from the request. | ||
| // return error if there are too many sidecars. | ||
| func extraSidecars(req *ethpb.GenericSignedBeaconBlock) ([]*ethpb.SignedBlobSidecar, error) { | ||
| b, ok := req.GetBlock().(*ethpb.GenericSignedBeaconBlock_Deneb) | ||
| if !ok { | ||
| return nil, errors.New("Could not cast block to Deneb") | ||
| } | ||
| if len(b.Deneb.Blobs) > fieldparams.MaxBlobsPerBlock { | ||
| return nil, fmt.Errorf("too many blobs in block: %d", len(b.Deneb.Blobs)) | ||
| } | ||
| return b.Deneb.Blobs, nil | ||
| } | ||
|
|
||
| // PrepareBeaconProposer caches and updates the fee recipient for the given proposer. | ||
| func (vs *Server) PrepareBeaconProposer( | ||
| ctx context.Context, request *ethpb.PrepareBeaconProposerRequest, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
sidecars -> signedSidecars?
or hmm unblindedSignedSidecars?
a bit verbose but I think it can get rid of some of the comments and the blind check below.
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.
f5f9478, went with
unblindedSidecars. Didn't think signed convey anything extra here