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(nervous-system): Enable Root to upgrade canisters using chunked Wasms #3300

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

Conversation

aterga
Copy link
Contributor

@aterga aterga commented Dec 28, 2024

This PR enables Root to upgrade canisters using chunked Wasms. This is relevant to both the NNS and the SNSs.

@github-actions github-actions bot added the feat label Dec 28, 2024
@aterga aterga marked this pull request as ready for review December 28, 2024 13:32
@aterga aterga requested review from a team as code owners December 28, 2024 13:32
(&install_code_args,),
)
.await
if let Some(ChunkedCanisterWasm {
Copy link
Contributor

Choose a reason for hiding this comment

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

There will need to be validation somewhere that chunked_canister_wasm and wasm_module are mutually exclusive, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about it, too, but couldn't convince myself that this was necessary.

Currently, if there are some bytes in wasm_module and chunked_canister_wasm, then the former would be used and the latter ignored.

Are you sure it's better to reject requests that specify more data than we need?

Either way, I'm happy to add a unit test to make sure this behavior is well specified.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the principle of least surprise should apply. One would not expect to be able to submit two mutually exclusive options into an
API and not get an error. If the API silently ignores one, this could be confusing.

It might be a good change, for future forward compatibility, to make the new field actually support both as an enum, and then translate the old field into the enum as part of the validation, so that we can eventually retire the old field and have the type structure enforce the either-or nature of the arguments.

@max-dfinity
Copy link
Contributor

This seems like a good first and necessary step. Can you add a test?

@aterga
Copy link
Contributor Author

aterga commented Dec 30, 2024

This seems like a good first and necessary step. Can you add a test?

Done (please see rs/nervous_system/integration_tests/tests/upgrade_sns_controlled_canister_with_large_wasm.rs)

@aterga aterga requested a review from max-dfinity December 30, 2024 23:34
sns::swap::await_swap_lifecycle(&pocket_ic, sns.swap.canister_id, Lifecycle::Open)
.await
.unwrap();
sns::swap::smoke_test_participate_and_finalize(
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to not have all our tests do this. This was originally created for the sake of final release qualification and is the slowest part of most tests.

PocketIC tests seem to be a bit slower for some reason

.upload_chunk(
store_canister_id.into(),
// This is a simplification; for now, we assume the Root itself decides to upload
// some WASM chunks, but eventually this should be triggered via proposal.
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it doesn't matter how the chunks get there so long as 1) root is a co-controller and 2) the wasm hash is correct (which is part of the proposal and should be verified). I think that means that you don't need root to upload the chunks necessarily.

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

Successfully merging this pull request may close these issues.

2 participants