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

feat: add canister init args #112

Merged
merged 13 commits into from
Jan 3, 2024
Merged

feat: add canister init args #112

merged 13 commits into from
Jan 3, 2024

Conversation

rvanasa
Copy link
Collaborator

@rvanasa rvanasa commented Jan 3, 2024

Replaces getNodesInSubnet() and setNodesInSubnet() methods with a Candid init argument:

dfx deploy evm_rpc --argument "(variant {nodesInSubnet = 13})"
dfx deploy evm_rpc_fiduciary --argument "(variant {nodesInSubnet = 28})"

The ideal situation would be to specify defaults in the dfx.json file, but this doesn't seem to be possible at the moment.

@@ -9,6 +9,7 @@ edition = "2021"
[profile.release]
debug = false
lto = true
strip = true
Copy link
Collaborator Author

@rvanasa rvanasa Jan 3, 2024

Choose a reason for hiding this comment

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

(Quick fix for getting below the 2 MB Wasm size limit)

@rvanasa rvanasa changed the title feat: add optional canister init args feat: add canister init args Jan 3, 2024
Comment on lines +16 to +17
(EvmRpcCanister, "default", 13, 521_498_000),
(EvmRpcFidicuaryCanister, "fiduciary", 28, 1_123_226_461),
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not clear what these numbers mean (readers may be able to guess what 13 and 28 mean but not the other numbers).
How about either adding a comment or replacing the plain numbers with meaningfully named constants?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a comment to clarify. There's also a line directly after this which shows the variable names for each tuple entry, although I see how it could be easy to miss.


let candidRpcCycles = 1_000_000_000_000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is there so much code in red and identical-looking code in green below..?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is due to a change in indentation (modified the E2E test to cover both the standard and fiduciary canisters).

@@ -35,7 +35,7 @@ pub fn get_http_request_cost(
json_rpc_payload: &str,
max_response_bytes: u64,
) -> u128 {
let nodes_in_subnet = METADATA.with(|m| m.borrow().get().nodes_in_subnet);
let nodes_in_subnet = TRANSIENT_SUBNET_SIZE.with(|m| *m.borrow());
Copy link
Contributor

Choose a reason for hiding this comment

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

What's a "transient subnet size"?

Copy link
Collaborator Author

@rvanasa rvanasa Jan 3, 2024

Choose a reason for hiding this comment

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

Data stored in non-stable memory uses a TRANSIENT_ prefix. Open to suggestions for a different naming convention (also see response below).

src/memory.rs Outdated
@@ -21,6 +21,7 @@ declare_log_buffer!(name = ERROR, capacity = 1000);
thread_local! {
// Transient static data: this is reset when the canister is upgraded.
pub static TRANSIENT_METRICS: RefCell<Metrics> = RefCell::new(Metrics::default());
pub static TRANSIENT_SUBNET_SIZE: RefCell<u32> = RefCell::new(DEFAULT_NODES_IN_SUBNET);
Copy link
Contributor

Choose a reason for hiding this comment

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

So, it's called "transient" because this information is not persisted?
It's a bit misleading in my opinion because an upgrade doesn't change the subnet size.

Copy link
Collaborator Author

@rvanasa rvanasa Jan 3, 2024

Choose a reason for hiding this comment

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

Do you know if there is a conventional name for non-stable memory on the IC? I've seen "main memory" and "flexible memory" but neither seem to work better in this case. I suppose we could remove the TRANSIENT_ prefix and define these constants in stable::* and unstable::* modules, or something along those lines.

For now I'll rename these to UNSTABLE_* as a slightly clearer alternative.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the approach with different modules better. "Unstable subnet size" also sounds weird. 🙂

But we can go with your suggestion for now and have some bike-shedding fun later.

@rvanasa rvanasa merged commit db4cf6e into main Jan 3, 2024
3 checks passed
@rvanasa rvanasa deleted the canister-init-args branch January 3, 2024 22:35
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