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(sns): Enable upgrading SNS-controlled canisters using chunked WASMs #3287

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

Conversation

aterga
Copy link
Contributor

@aterga aterga commented Dec 23, 2024

This PR extends the existing proposal type UpgradeSnsControllerCanister with a new field chunked_canister_wasm that can be used for specifying an upgrade to a large WASM module (over 2 MiB) priorly uploaded to some store canister.

Example proposal render for chunked Wasm:

# Proposal to Upgrade an SNS Controlled Canister

## Target canister: xbgkv-fyaaa-aaaaa-aaava-cai

## Wasm info

Remote module stored on canister zyo6l-paaaa-aaaaa-aabxq-cai with SHA256 `010203`. Split into 3 chunks:
  - `010101`
  - `020202`
  - `030303`

## Mode: Upgrade

## Argument info

No upgrade argument.

Example proposal render for embedded Wasm:

# Proposal to upgrade SNS controlled canister:

## Target canister id: xbgkv-fyaaa-aaaaa-aaava-cai

## Wasm info

Embedded module with 8 bytes and SHA256 `93a44bbb96c751218e4c00d479e4c14358122a389acca16205b1e4d0dc5f9476`.

## Mode: Upgrade

## Argument info

Upgrade argument with 8 bytes and SHA256 `0a141e28323c4650`.

@github-actions github-actions bot added the feat label Dec 23, 2024
@aterga aterga force-pushed the arshavir/upgrade-sns-controlled-canister-with-chunked-wasm branch from 534ea16 to 49f5888 Compare January 8, 2025 21:12
@aterga aterga changed the title feat(sns): Large WASM support for SNS-controlled canisters feat(sns): Enable upgrading SNS-controlled canisters using chunked WASMs Jan 9, 2025
@aterga aterga marked this pull request as ready for review January 9, 2025 22:45
@aterga aterga requested a review from a team as a code owner January 9, 2025 22:45
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

If this pull request affects the behavior of any canister owned by
the Governance team, remember to update the corresponding
unreleased_changes.md file(s).

To acknowldge this reminder (and unblock the PR), dismiss this
code review by going to the bottom of the pull request page, and
supply one of the following reasons:

  1. Done.

  2. No canister behavior changes.

@aterga
Copy link
Contributor Author

aterga commented Jan 10, 2025

TODO: Extend the rs/nervous_system/integration_tests/tests/upgrade_sns_controlled_canister_with_large_wasm.rs test to submit a proposal that would tirgger the upgrade.

Done

@daniel-wong-dfinity-org
Copy link
Contributor

I think you need to modify the second example in your PR description? It lists chunks, but IIUC, the idea is that "embedded Wasm" means that there are no chunks.

@daniel-wong-dfinity-org daniel-wong-dfinity-org dismissed github-actions[bot]’s stale review January 10, 2025 12:12

changelog files have not been added for SNS yet, but that will happen very soon. If that goes in before this, then, yes, let's update those. Otherwise, this shouldn't be a blocker.

rs/sns/governance/src/governance.rs Show resolved Hide resolved
rs/sns/governance/src/proposal.rs Outdated Show resolved Hide resolved
rs/sns/governance/src/proposal.rs Show resolved Hide resolved
rs/sns/governance/src/types.rs Show resolved Hide resolved
rs/sns/governance/src/proposal.rs Show resolved Hide resolved
rs/sns/governance/src/proposal.rs Show resolved Hide resolved
rs/sns/governance/src/proposal.rs Outdated Show resolved Hide resolved
rs/sns/governance/src/proposal.rs Show resolved Hide resolved
@@ -212,7 +179,7 @@ async fn run_test(store_same_as_target: bool) {
app_subnet,
vec![],
None,
vec![sns.root.canister_id],
vec![sns.governance.canister_id, sns.root.canister_id],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does governance have to be a controller?

@@ -64,7 +64,7 @@ pub struct ChangeCanisterRequest {
#[serde(with = "serde_bytes")]
pub wasm_module: Vec<u8>,

/// If the entire WASM does not into the 2 MiB ingress limit, then `new_canister_wasm`
/// If the entire WASM does not fit into the 2 MiB ingress limit, then `new_canister_wasm`
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a field called "new_canister_wasm" - should that say "wasm_module"?


// Generate final report.
if !defects.is_empty() {
let tip = if upgrade.chunked_canister_wasm.is_some() {
format!(
"\nPlease make sure that both Governance ({}) and Root ({}) are controllers of \
Copy link
Contributor

@max-dfinity max-dfinity Jan 11, 2025

Choose a reason for hiding this comment

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

This comment made me think... if the canister is malicious, does root or governance need to make a request to that store canister? That seems like a risk we don't want.

};

let stored_chunks_response = env
.call_canister(CanisterId::ic_00(), "stored_chunks", arg)
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 we should cut this validation of stored_chunks out of the code.
The controller of that canister can change the chunks at any point. Maybe the proposals should simply have instructions to verify the overall wasm hash via the build instructions?

Can users submit text with the UpgradeSnsControlledCanister? If yes, then they should say how to verify it. The overall hash is all that needs to be verified by the voters. The chunks are either here or not, and if they're here during this part of the process that doesn't guarantee they're there later, since this canister can be controlled by whoever....

I guess this is helpful for the proposer, but it adds quite a bit of extra complexity to the code. I'm not sure it's really worth it.

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.

3 participants