-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
eth/catalyst: make getPayloadBodiesByRange take hex inputs #26624
Changes from 3 commits
6e6ff10
83fb777
60f45ba
a8d5036
eb46cb1
11c44e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -772,20 +772,21 @@ func (api *ConsensusAPI) GetPayloadBodiesByHashV1(hashes []common.Hash) []*engin | |
|
||
// GetPayloadBodiesByRangeV1 implements engine_getPayloadBodiesByRangeV1 which allows for retrieval of a range | ||
// of block bodies by the engine api. | ||
func (api *ConsensusAPI) GetPayloadBodiesByRangeV1(start, count uint64) ([]*engine.ExecutionPayloadBodyV1, error) { | ||
func (api *ConsensusAPI) GetPayloadBodiesByRangeV1(start, count hexutil.Uint64) ([]engine.ExecutionPayloadBodyV1, error) { | ||
if start == 0 || count == 0 || count > 1024 { | ||
return nil, engine.InvalidParams.With(fmt.Errorf("invalid start or count, start: %v count: %v", start, count)) | ||
} | ||
// limit count up until current | ||
current := api.eth.BlockChain().CurrentBlock().NumberU64() | ||
end := start + count | ||
end := uint64(start) + uint64(count) | ||
if end > current { | ||
end = current | ||
} | ||
var bodies []*engine.ExecutionPayloadBodyV1 | ||
for i := start; i < end; i++ { | ||
bodies := make([]*engine.ExecutionPayloadBodyV1, 0, uint64(count)) | ||
for i := uint64(start); i < end; i++ { | ||
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. A problem is here though. If we hit the 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.
|
||
block := api.eth.BlockChain().GetBlockByNumber(i) | ||
bodies = append(bodies, getBody(block)) | ||
body := getBody(block) | ||
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. Hmm, it's wrong. The returned body can be nil, isn't it? 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.
That's fine, we want a 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. But the deref in line 789 should panic then, no? 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.
I agree 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.
it was a shot-in-the-dark attempt at a fix. prob should have moved the PR back to draft at that point. |
||
bodies = append(bodies, *body) | ||
} | ||
return bodies, nil | ||
} | ||
|
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.