-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add cycles cost endpoints #509
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
1248a02 to
b4be97a
Compare
b4be97a to
a101ab5
Compare
d9e44f4 to
1deb585
Compare
1deb585 to
d7a8a66
Compare
src/memory.rs
Outdated
| // requests and responses in logs. | ||
| *counter = counter.wrapping_add(1); | ||
| Id::from(current_request_id) | ||
| Id::from(ConstantSizeId::from(current_request_id)) |
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.
@gregorydemay I realized that this is necessary so that the CyclesCost endpoints give the correct cost back. The reason is, that currently the requests get initialized with a ConstantSizeId::ZERO ID here (which is called here), but in the actual update endpoints, the IDs get changed from a ConstantSizeId to an Id::Number here.
Note that I opened another PR (#514) with the relevant changes, but didn't want to rebase this one as it was already in review. I would aim to merge that one first, and then merge those changes here. I did include some changes here already just so that the CI is green.
…-cycles-cost-endpoints
…-cycles-cost-endpoints
This PR refactors the way requests are created in the EVM RPC canister to make the way for #509 where `CyclesCost` endpoints are added to estimate the cycles cost of requests. The refactoring introduces a new `MultiRpcResult` struct which represents the HTTP outcalls required to answer a request. `MultiRpcResult` currently only has a public `send_and_reduce` method, however #509 adds a `cycles_cost` method. 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`).
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 @lpahlavi for this PR! some minor comments but otherwise LGTM!
## 🤖 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]>
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 existingrequestCostendpoint in 2 significant ways: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.As a result, the existing
requestCostendpoint is left for backwards compatibility but is now deprecated.In addition, the
EvmRpcClientnow has arequest_cost()method that allows computing the estimated cost of a request with the new query endpoints.