-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix: get_block_by_number endpoint #310
Conversation
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.
Looks good!
crates/rpc/rpc.rs
Outdated
let request = ForkChoiceUpdatedV3::parse(&req.params).ok_or(RpcErr::BadParams)?; | ||
Ok( | ||
serde_json::to_value(fork_choice::forkchoice_updated_v3(request, storage)?) | ||
.unwrap(), |
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.
Could we return an error instead of unwrapping 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.
Totally!
crates/rpc/rpc.rs
Outdated
"engine_newPayloadV3" => { | ||
let request = NewPayloadV3Request::parse(&req.params).ok_or(RpcErr::BadParams)?; | ||
Ok(serde_json::to_value(engine::new_payload_v3(request, storage)?).unwrap()) | ||
Ok(serde_json::to_value(payload::new_payload_v3(request, storage)?).unwrap()) |
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.
Could we return an error instead of unwrapping 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.
Done!
let safe = storage.get_block_number(request.fork_choice_state.safe_block_hash); | ||
let finalized = storage.get_block_number(request.fork_choice_state.finalized_block_hash); | ||
|
||
// Check if we already have the blocks stored. |
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.
no need for this check, you might get multiple updates that have the same safe/finalized block. You don't need to return an error 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.
Hmmm, in this step I'm actually checking that we have those blocks stored beforehand, rather than if we have already marked them as safe/finalized. But maybe I didn't fully understand what you meant.
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.
Ahh, my bad then.
**Motivation** The `get-finalized` and `get-safe` endpoints were returning null values because we weren't handling the forkchoice updates from the engine. **Description** This PR adds a minimal implementation to store forkchoice updates and pass the tests. Additionally, it takes the opportunity to implement a refactor. - Moves `core/types/engine/payload.rs` to `rpc/types/payload.rs`. - Creates `rpc/engine/payload.rs` and `rpc/engine/fork_choice.rs` to modularize `rpc/engine/mod.rs`. - Adds a minimal implementation of `forkchoice_updated_v3()`. - Fixes`eth_getBlockByNumber`. **Observations** This PR doesn't implement the `engine_forkchoiceUpdatedV3` endpoint, It only stores the minimal data needed to pass `eth_getBlockByNumber`. Closes lambdaclass#270
Motivation
The
get-finalized
andget-safe
endpoints were returning null values because we weren't handling the forkchoice updates from the engine.Description
This PR adds a minimal implementation to store forkchoice updates and pass the tests. Additionally, it takes the opportunity to implement a refactor.
core/types/engine/payload.rs
torpc/types/payload.rs
.rpc/engine/payload.rs
andrpc/engine/fork_choice.rs
to modularizerpc/engine/mod.rs
.forkchoice_updated_v3()
.eth_getBlockByNumber
.Observations
This PR doesn't implement the
engine_forkchoiceUpdatedV3
endpoint, It only stores the minimal data needed to passeth_getBlockByNumber
.Closes #270