-
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
Batch Reconstruction Of Bellatrix Blocks #11210
Conversation
@@ -315,6 +319,43 @@ func (s *Service) ExecutionBlockByHash(ctx context.Context, hash common.Hash, wi | |||
return result, handleRPCError(err) | |||
} | |||
|
|||
// ExecutionBlockByHashes fetches a batch of execution engine blocks by hash by calling | |||
// eth_blockByHash via JSON-RPC. | |||
func (s *Service) ExecutionBlockByHashes(ctx context.Context, hashes []common.Hash, withTxs bool) ([]*pb.ExecutionBlock, 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.
func (s *Service) ExecutionBlockByHashes(ctx context.Context, hashes []common.Hash, withTxs bool) ([]*pb.ExecutionBlock, error) { | |
func (s *Service) ExecutionBlocksByHashes(ctx context.Context, hashes []common.Hash, withTxs bool) ([]*pb.ExecutionBlock, error) { |
for _, h := range hashes { | ||
blk := &pb.ExecutionBlock{} | ||
err := error(nil) | ||
newH := h |
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 newH := h
necessary? We worry about mutation?
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.
If you dont create a new hash value, the hash value referenced will change with each iteration in the loop.
} | ||
for _, e := range errs { | ||
if e != nil { | ||
return nil, handleRPCError(e) |
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.
If one of the requests fail, do we fail the whole thing?
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.
Yeap, we do as the whole batch now becomes inconsistent.
} | ||
// Determine if the block is pre-merge or post-merge. Depending on the result, | ||
// we will ask the execution engine for the full payload. | ||
executionBlockHash := common.BytesToHash(header.BlockHash()) |
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 can move this to within the else
right?
What type of PR is this?
Feature Improvement
What does this PR do? Why is it needed?
For nodes running with blinded blocks enabled, they have to request the payloads from the execution client before
being able to respond to the remote peer who requested the block range.
However currently prysm does sequential json-rpc requests for each block requested from the execution node. This is an extremely inefficient method as we have to wait for geth to marshal and prysm to unmarshal the payload before we can proceed to the next block. With addition to network latency between the consensus and execution client, timeouts can frequently occur due to how we request payloads from the execution client.
This PR instead decides to batch all json-rpc requests into a single call, thereby making it much more efficient for prysm to retrieve all the desired execution payloads from the execution client.
Which issues(s) does this PR fix?
N.A
Other notes for review