-
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
allow users to publish blobs #14442
allow users to publish blobs #14442
Conversation
beacon-chain/rpc/endpoints.go
Outdated
@@ -558,6 +559,16 @@ func (s *Service) beaconEndpoints( | |||
handler: server.PublishBlockV2, | |||
methods: []string{http.MethodPost}, | |||
}, | |||
{ |
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.
since this isn't a beacon-api https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/ this should probably go under prysmBeaconEndpoints ( line 930 and below in the same file) and be under that namespace with the prysm subpath
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.
+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.
Updated
beacon-chain/rpc/endpoints_test.go
Outdated
@@ -31,6 +31,7 @@ func Test_endpoints(t *testing.T) { | |||
"/eth/v2/beacon/blinded_blocks": {http.MethodPost}, | |||
"/eth/v1/beacon/blocks": {http.MethodPost}, | |||
"/eth/v2/beacon/blocks": {http.MethodPost}, | |||
"/eth/v2/beacon/blobs": {http.MethodPost}, |
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.
path would be affected based on my previous 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.
+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.
Updated
return | ||
} | ||
|
||
readOnlySc, err := blocks.NewROBlobWithRoot(sc, beaconRoot) |
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 have a helper function bytesutil.ToBytes32 maybe don't need lines 981/982
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.
Updated
api/server/structs/endpoints_blob.go
Outdated
|
||
type PublishBlobsRequest struct { | ||
BlobSidecars *BlobSidecars `json:"blob_sidecars"` | ||
BeaconRoot string `json:"beacon_root"` |
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 should be called either block_root
or beacon_block_root
since there is no such thing as a beacon root
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.
Updated
@@ -959,6 +959,54 @@ func (s *Server) publishBlock(ctx context.Context, w http.ResponseWriter, r *htt | |||
httputil.HandleError(w, "Body does not represent a valid block type", http.StatusBadRequest) | |||
} | |||
|
|||
func (s *Server) PublishBlobs(w http.ResponseWriter, r *http.Request) { |
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.
Echoing what @james-prysm said, this handler should be placed in /home/radek/go/prysm/beacon-chain/rpc/prysm/beacon/handlers.go
since it's not an official Beacon API endpoint
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.
Updated
beacon-chain/rpc/endpoints.go
Outdated
@@ -558,6 +559,16 @@ func (s *Service) beaconEndpoints( | |||
handler: server.PublishBlockV2, | |||
methods: []string{http.MethodPost}, | |||
}, | |||
{ |
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.
+1
beacon-chain/rpc/endpoints_test.go
Outdated
@@ -31,6 +31,7 @@ func Test_endpoints(t *testing.T) { | |||
"/eth/v2/beacon/blinded_blocks": {http.MethodPost}, | |||
"/eth/v1/beacon/blocks": {http.MethodPost}, | |||
"/eth/v2/beacon/blocks": {http.MethodPost}, | |||
"/eth/v2/beacon/blobs": {http.MethodPost}, |
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.
+1
copy(beaconRoot[:], root) | ||
|
||
for _, blobSidecar := range req.BlobSidecars.Sidecars { | ||
|
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.
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.
Updated
|
||
root, err := bytesutil.DecodeHexWithLength(req.BeaconRoot, 32) | ||
if err != nil { | ||
httputil.HandleError(w, "Could not decode beacon root", http.StatusBadRequest) |
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.
httputil.HandleError(w, "Could not decode beacon root", http.StatusBadRequest) | |
httputil.HandleError(w, "Could not decode block root", http.StatusBadRequest) |
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.
Updated
|
||
sc, err := blobSidecar.ToConsensus() | ||
if err != nil { | ||
http.Error(w, "Could not decode blob sidecar", http.StatusBadRequest) |
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.
please use httputil.HandleError
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.
Updated
|
||
readOnlySc, err := blocks.NewROBlobWithRoot(sc, beaconRoot) | ||
if err != nil { | ||
http.Error(w, "Could not create read-only blob", http.StatusInternalServerError) |
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.
please use httputil.HandleError
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.
Updated
|
||
verifiedBlob := blocks.NewVerifiedROBlob(readOnlySc) | ||
if err := s.BlobReceiver.ReceiveBlob(ctx, verifiedBlob); err != nil { | ||
http.Error(w, "Could not receive blob", http.StatusInternalServerError) |
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.
please use httputil.HandleError
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.
Updated
abb5e6d
to
e7017f0
Compare
|
||
go_library( | ||
name = "go_default_library", | ||
testonly = True, |
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. Thanks for marking this as testonly = True.
@@ -18,12 +18,15 @@ go_library( | |||
"//beacon-chain/rpc/eth/helpers:go_default_library", | |||
"//beacon-chain/rpc/eth/shared:go_default_library", | |||
"//beacon-chain/rpc/lookup:go_default_library", |
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 file is missing somethings. Please run bazel run //:gazelle
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.
done
waiting for conflicts to resolve before next review |
Conflicts resolved now |
} | ||
}`, Blob) | ||
|
||
var PublishBlobsRequestEmptySidecarsList = fmt.Sprintf(`{ |
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.
linter complaining here
There are linting errors |
642badf
to
9398025
Compare
linting should be fixed now |
seems like stuff is still broken |
Allowing users to publish blobs before publishing blocks, gives the blobs a head start. They can begin to propagate around the network while the block is being validated.
OK hopefully It's fixed now. I've also squashed the commits as it was getting a bit long. |
Please run gazelle |
Done |
What type of PR is this?
Feature
What does this PR do? Why is it needed?
Allowing users to publish blobs before publishing blocks, gives the blobs a head start. They can begin to propagate around the network while the block is being validated.
Which issues(s) does this PR fix?
Fixes #
Other notes for review
Acknowledgements