Skip to content
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: make subnet nodes configurable and fix https outcall cost calculation #351

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ninegua
Copy link
Member

@ninegua ninegua commented Jan 6, 2025

XC-257

Fix the cycle computation according to the latest document on the cost for https outcalls https://internetcomputer.org/docs/current/developer-docs/gas-cost/#https-outcalls

Also add nodesInSubnet as an optional initialization parameter when creating the EVM RPC canister. It defaults to 34 if not set, which is also the default used previously.

@ninegua ninegua force-pushed the paulliu/fix-http-request-cost-calculation branch from 1259708 to b4d4885 Compare January 7, 2025 04:54
@ninegua ninegua force-pushed the paulliu/fix-http-request-cost-calculation branch from b4d4885 to e98a9d3 Compare January 20, 2025 13:47
@ninegua ninegua force-pushed the paulliu/fix-http-request-cost-calculation branch from f0f049d to dc90e48 Compare January 23, 2025 14:09
@ninegua ninegua marked this pull request as ready for review January 23, 2025 14:28
@ninegua ninegua requested a review from a team as a code owner January 23, 2025 14:28
Copy link
Contributor

@lpahlavi lpahlavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ninegua Thanks a lot for this PR! Some small nits, otherwise LGTM!

@@ -108,6 +108,7 @@ type InstallArgs = record {
manageApiKeys : opt vec principal;
logFilter : opt LogFilter;
overrideProvider : opt OverrideProvider;
nodesInSubnet : opt nat32;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nodesInSubnet : opt nat32;
numNodesInSubnet : opt nat32;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a method called getNodesInSubnet, so I'm reusing the same term nodesInSubnet to be consistent in the interface.

let nodes_in_subnet = NODES_IN_SUBNET as u128;
/// See https://internetcomputer.org/docs/current/developer-docs/gas-cost/#https-outcalls
pub fn get_http_request_cost(
nodes_in_subnet: u32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would use num_nodes_in_subnet here and everywhere to be more explicit.

Suggested change
nodes_in_subnet: u32,
num_nodes_in_subnet: u32,

@@ -1,15 +1,5 @@
// HTTP outcall cost calculation
// See https://internetcomputer.org/docs/current/developer-docs/gas-cost#special-features
// Constant used in HTTP outcall cost calculation
pub const INGRESS_OVERHEAD_BYTES: u128 = 100;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there perhaps a link where this is documented? I'm not super familiar with all of this so I appreciate when there is documentation available :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why this gets the value 100 in the first place. But I guess it was some heuristics?

@@ -1042,6 +1049,38 @@ fn candid_rpc_should_err_without_cycles() {
);
}

#[test]
fn candid_rpc_should_err_with_insufficient_cycles() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would add a test for when the number of nodes in the subnet is not specified in the install args.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants