-
Notifications
You must be signed in to change notification settings - Fork 20
refactor: prepare to add RequestCost endpoints
#508
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
Conversation
| pub type MultiCallResults<T> = MultiResults<RpcService, T, RpcError>; | ||
| pub type ReducedResult<T> = canhttp::multi::ReducedResult<RpcService, T, RpcError>; | ||
|
|
||
| fn process_result<T>( |
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 method was moved from candid_rpc/mod.rs (unchanged).
afe5e68 to
a65dec5
Compare
src/candid_rpc/tests.rs
Outdated
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.
These tests were moved to rpc_client/tests.rs (unchanged).
a65dec5 to
eddd95a
Compare
RequestCost endpoints
eddd95a to
24b69e2
Compare
gregorydemay
left a 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.
Thanks for this refactoring @lpahlavi ! Some minor questions about lifetimes
Building on the refactoring from #508, this PR adds query endpoints for all `eth_*` endpoints on the EVM RPC canister that allow estimating the number of cycles required for a request. This improves on the existing `requestCost` endpoint in 2 significant ways: * The new query endpoints (e.g. `eth_getLogsCyclesCost`) have the same signature as their update counterparts (e.g. `eth_getLogs`) instead of requiring the user to construct the raw JSON payload themselves. * The new query endpoints can be used to compute the cycles cost of requests with multiple RPC providers (e.g. with the default providers). As a result, the existing `requestCost` endpoint is left for backwards compatibility but is now deprecated. In addition, the `EvmRpcClient` now has a `request_cost()` method that allows computing the estimated cost of a request with the new query endpoints.
## 🤖 New release * `evm_rpc_client`: 0.1.0 -> 0.2.0 (✓ API compatible changes) * `evm_rpc`: 2.6.0 -> 2.7.0 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> ## `evm_rpc_client` <blockquote> ## [0.2.0] - 2025-11-03 ### Added - Add `.request_cost()` method to `RequestBuilder` to compute the cycles cost of a request via the new `CyclesCost` query endpoints ([#509](#509)) - Add the option to configure a retry strategy in the EVM RPC client to e.g., try a request with increasingly many cycles if it fails to to insufficient cycles ([#512](#512)) [0.2.0]: evm_rpc_client-v0.1.0...evm_rpc_client-v0.2.0 </blockquote> ## `evm_rpc` <blockquote> ## [2.7.0] - 2025-11-03 ### Added - For each `eth_*` endpoint, add a new corresponding `eth_*CyclesCost` query endpoint with the same Candid arguments, that allows computing the cycles cost of calling the corresponding `eth_*` update endpoint ([#508](#508), [#509](#509)) ### Changed - Use constant-size request IDs in JSON-RPC requests to allow for consistent request cycles costs ([#514](#514)) [2.7.0]: v2.6.0...v2.7.0 </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Louis Pahlavi <[email protected]>
This PR refactors the way requests are created in the EVM RPC canister to make the way for #509 where
CyclesCostendpoints are added to estimate the cycles cost of requests.The refactoring introduces a new
MultiRpcResultstruct which represents the HTTP outcalls required to answer a request.MultiRpcResultcurrently only has a publicsend_and_reducemethod, however #509 adds acycles_costmethod. This will allow re-using the request creation logic (e.g. computing the estimated response size) between the actual request endpoints (e.g.eth_getLogs) and the cycles cost endpoints (e.g.eth_getLogsCyclesCost).