Repository navigation
feat: new canister setting status_visibility - #10667
Conversation
# Conflicts: # rs/execution_environment/tests/execution_test.rs # rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs
…n_test.rs Commit 2c0413f ("simplify") deliberately removed the three canister_status_via_query_call_* tests and the canister_status_count helper from execution_test.rs, as they are fully covered by the table-driven test_status_visibility_of_canister_status in canister_status.rs (which exercises every visibility x sender combination over both the query and update call paths). The merge of master (6ab53de) accidentally resurrected these tests during conflict resolution, reintroducing the stale negative test that still asserted the pre-status-visibility error code (CanisterInvalidControllerOrSubnetAdmin instead of the new CanisterStatusAccessDenied). Re-remove them to restore the intended state. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
bef2cc0 to
7849177
Compare
Re-add the query success-metric coverage lost when the canister_status_via_query_call_* tests were removed from execution_test.rs, folding it into the status_visibility matrix test: the successful canister_status query metric must increment exactly once for an allowed query call and never for a denied query or an update call. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Create the test canister with zero cycles: the subnet uses a free cost schedule, so no cycles are needed (removes the INITIAL_CYCLES_BALANCE constant that was carried over from the original tests). - Fix the two `.expect` messages on the success path so each matches the layer it unwraps: the outer Result is the access-control gate, the inner Result is the reply/reject layer (unreachable via ingress/query). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds a new canister setting, status_visibility, to control who can call the management canister’s canister_status endpoint, aligning it with existing visibility patterns (logs/snapshots) while preserving default behavior (controllers). The change propagates through the public management canister types, replicated state persistence (protobuf/checkpoints), access-control enforcement in the execution environment, and test coverage (including a new integration test matrix and updated error-code expectations).
Changes:
- Introduce
StatusVisibilityas a first-class setting in management types and canister settings APIs, and persist it in checkpoints/protobuf (tag 69). - Enforce
status_visibilityforcanister_statusacross ingress acceptance and execution paths, returning the newCanisterStatusAccessDeniederror code on denial. - Add/adjust tests to cover the access matrix and metric behavior; update existing tests for the new error code.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rs/types/management_canister_types/tests/ic.did | Extends candid test interface with status_visibility and new settings fields. |
| rs/types/management_canister_types/src/lib.rs | Adds StatusVisibility type + protobuf conversions; wires it into settings/status result types. |
| rs/state_manager/src/tip.rs | Serializes status_visibility into checkpointed canister state bits. |
| rs/state_manager/src/checkpoint.rs | Loads status_visibility from persisted canister state bits. |
| rs/state_layout/src/state_layout/tests.rs | Updates default CanisterStateBits test fixture to include status_visibility. |
| rs/state_layout/src/state_layout/proto.rs | Adds protobuf encode/decode plumbing for status_visibility in CanisterStateBits. |
| rs/state_layout/src/state_layout.rs | Extends CanisterStateBits struct with status_visibility. |
| rs/rust_canisters/tests/test/canister_management.rs | Updates expected error code for denied canister_status. |
| rs/replicated_state/src/canister_state/system_state.rs | Adds status_visibility to SystemState and ensures default/init/checkpoint paths carry it. |
| rs/replicated_state/src/canister_state.rs | Exposes status_visibility() accessor on CanisterState. |
| rs/replica_tests/tests/canister_lifecycle.rs | Updates test construction of CanisterStatusResultV2 to include status_visibility. |
| rs/protobuf/src/gen/state/state.canister_state_bits.v1.rs | Regenerates prost types to include StatusVisibility and tag 69 in CanisterStateBits. |
| rs/protobuf/def/state/canister_state_bits/v1/canister_state_bits.proto | Adds StatusVisibility messages and field 69; bumps Next ID. |
| rs/pocket_ic_server/src/pocket_ic.rs | Sets explicit default status_visibility when creating canisters in PocketIC scenarios. |
| rs/nervous_system/clients/src/update_settings.rs | Adapts client-side update_settings conversion to new field (currently always sending None). |
| rs/execution_environment/tests/execution_test.rs | Removes older canister_status query metric/access tests (replaced by new matrix test). |
| rs/execution_environment/tests/canister_status.rs | Adds new integration test covering {visibility} x {caller} x {update/query} plus metrics assertions. |
| rs/execution_environment/src/execution/common.rs | Introduces validate_status_visibility helper to centralize access checks. |
| rs/execution_environment/src/execution_environment/tests.rs | Updates ingress acceptance tests to expect CanisterStatusAccessDenied. |
| rs/execution_environment/src/canister_settings.rs | Extends settings parsing/builders and visibility abstraction to include StatusVisibility. |
| rs/execution_environment/src/canister_manager/types.rs | Adds CanisterStatusAccessDenied variant + mapping to UserError (error code 542). |
| rs/execution_environment/src/canister_manager/tests.rs | Updates manager tests to assert new error code/message for denied status calls. |
| rs/execution_environment/src/canister_manager.rs | Enforces status_visibility for canister_status (ingress acceptance + execution paths) and returns it in results. |
| rs/cycles_account_manager/src/cycles_account_manager.rs | Bumps max “delayed ingress induction cost” payload size constant for update_settings payload changes. |
Comments suppressed due to low confidence (1)
rs/nervous_system/clients/src/update_settings.rs:96
CanisterSettingsis documented as matching the ic-interface-spec, but the newstatus_visibilitysetting is not represented here and is always sent asNonein theCanisterSettingsArgsconversion. This means nervous-system clients cannot setstatus_visibility(even to the defaults likecontrollers/public), and the local struct is now out of sync with the management canister interface.
management_canister::CanisterSettingsArgs {
controllers: controllers.map(management_canister::BoundedControllers::new),
compute_allocation,
memory_allocation,
freezing_threshold,
reserved_cycles_limit,
log_visibility: log_visibility.map(management_canister::LogVisibilityV2::from),
snapshot_visibility: snapshot_visibility
.map(management_canister::SnapshotVisibility::from),
status_visibility: None,
log_memory_limit: None,
wasm_memory_limit,
wasm_memory_threshold,
environment_variables: None,
minimum_incoming_canister_call_cycles: None,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):
-
Update
unreleased_changelog.md(if there are behavior changes, even if they are
non-breaking). -
Are there BREAKING changes?
-
Is a data migration needed?
-
Security review?
How to Satisfy This Automatic Review
-
Go to the bottom of the pull request page.
-
Look for where it says this bot is requesting changes.
-
Click the three dots to the right.
-
Select "Dismiss review".
-
In the text entry box, respond to each of the numbered items in the previous
section, declare one of the following:
-
Done.
-
$REASON_WHY_NO_NEED. E.g. for
unreleased_changelog.md, "No
canister behavior changes.", or for item 2, "Existing APIs
behave as before.".
Brief Guide to "Externally Visible" Changes
"Externally visible behavior change" is very often due to some NEW canister API.
Changes to EXISTING APIs are more likely to be "breaking".
If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.
If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.
Reference(s)
For a more comprehensive checklist, see here.
GOVERNANCE_CHECKLIST_REMINDER_DEDUP
|
✅ No security or compliance issues detected. Reviewed everything up to f092104. Security OverviewDetected Code Changes
|
|
✅ No security or compliance issues detected. Reviewed everything up to f092104. Security OverviewDetected Code Changes
|
No canister behavior changes.
…315) Reflect the new status_visibility canister setting (dfinity/ic#10667), which governs who can read a canister's status via canister_status: controllers (default), public, or allowed_viewers. Mirrors the existing log_visibility and snapshot_visibility settings. --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…ity#11119) The `status_visibility` canister setting (introduced in dfinity#10667) was only available in the internal `ic-management-canister-types-private` crate. Add it to the public crate as well: the `StatusVisibility` type, the fields on `CanisterSettings` and `DefiniteCanisterSettings`, and the corresponding entries in `tests/ic.did`. Also complete the unreleased changelog, which was missing the `minimum_incoming_canister_call_cycles` field (dfinity#10398) and the tightened `wasm_memory_threshold` bound (dfinity#10574). Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Adds the `status_visibility` canister setting from dfinity/ic#10667, which controls who may read a canister's status through the management canister's `canister_status` endpoint. It takes the same three forms as `log_visibility` in a manifest and the same flag shapes on `icp canister settings update`; `icp canister status` and `icp canister settings show` report it, it is applied at creation, and it is kept in sync by `icp canister settings sync`. The three visibility settings the management canister exposes are structurally identical but distinct Candid types, so rather than duplicate the manifest type, the parser, the set-wise comparison, the add/remove merge and the renderer per setting, this introduces one shared `Visibility` enum in `icp::canister::visibility` plus a `visibility_setting!` macro that declares the per-setting manifest newtype, so parse errors and the generated schema still name the specific setting. `log_visibility` behaviour is unchanged. Requires `ic-management-canister-types` 0.9.0, which is where `StatusVisibility` landed. `DefiniteCanisterSettings` gained a non-optional `status_visibility`, so reading a canister's status now requires a replica that reports it — every mainnet subnet does, and so does the pinned network launcher. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp
Adds the `status_visibility` canister setting from dfinity/ic#10667, which controls who may read a canister's status through the management canister's `canister_status` endpoint. It takes the same three forms as `log_visibility` in a manifest and the same flag shapes on `icp canister settings update`; `icp canister status` and `icp canister settings show` report it, it is applied at creation, and it is kept in sync by `icp canister settings sync`. The three visibility settings the management canister exposes are structurally identical but distinct Candid types, so rather than duplicate the manifest type, the parser, the set-wise comparison, the add/remove merge and the renderer per setting, this introduces one shared `Visibility` enum in `icp::canister::visibility` plus a `visibility_setting!` macro that declares the per-setting manifest newtype, so parse errors and the generated schema still name the specific setting. `log_visibility` behaviour is unchanged. Requires `ic-management-canister-types` 0.9.0, which is where `StatusVisibility` landed. `DefiniteCanisterSettings` gained a non-optional `status_visibility`, so reading a canister's status now requires a replica that reports it — every mainnet subnet does, and so does the pinned network launcher. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp
Adds the `status_visibility` canister setting from dfinity/ic#10667, which controls who may read a canister's status through the management canister's `canister_status` endpoint. It takes the same three forms as `log_visibility` in a manifest and the same flag shapes on `icp canister settings update`; `icp canister status` and `icp canister settings show` report it, it is applied at creation, and it is kept in sync by `icp canister settings sync`. The three visibility settings the management canister exposes are structurally identical but distinct Candid types, so rather than duplicate the manifest type, the parser, the set-wise comparison, the add/remove merge and the renderer per setting, this introduces one shared `Visibility` enum in `icp::canister::visibility` plus a `visibility_setting!` macro that declares the per-setting manifest newtype, so parse errors and the generated schema still name the specific setting. `log_visibility` behaviour is unchanged. Requires `ic-management-canister-types` 0.9.0, which is where `StatusVisibility` landed. `DefiniteCanisterSettings` gained a non-optional `status_visibility`, so reading a canister's status now requires a replica that reports it — every mainnet subnet does, and so does the pinned network launcher. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp
* feat: new canister setting status_visibility Adds the `status_visibility` canister setting from dfinity/ic#10667, which controls who may read a canister's status through the management canister's `canister_status` endpoint. It takes the same three forms as `log_visibility` in a manifest and the same flag shapes on `icp canister settings update`; `icp canister status` and `icp canister settings show` report it, it is applied at creation, and it is kept in sync by `icp canister settings sync`. The three visibility settings the management canister exposes are structurally identical but distinct Candid types, so rather than duplicate the manifest type, the parser, the set-wise comparison, the add/remove merge and the renderer per setting, this introduces one shared `Visibility` enum in `icp::canister::visibility` plus a `visibility_setting!` macro that declares the per-setting manifest newtype, so parse errors and the generated schema still name the specific setting. `log_visibility` behaviour is unchanged. Requires `ic-management-canister-types` 0.9.0, which is where `StatusVisibility` landed. `DefiniteCanisterSettings` gained a non-optional `status_visibility`, so reading a canister's status now requires a replica that reports it — every mainnet subnet does, and so does the pinned network launcher. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp * feat: list allowed viewers one per line `Allowed viewers: <a>, <b>` put two 63-character principals on the label's line, which wraps in any normal terminal. The policy now stays on the label and each viewer gets its own line, nested two spaces past the label the way the other lists in those reports are: Status visibility: Allowed viewers viewer: 7tjgl-udln4-... viewer: cgbip-rubo2-... The label sits at a different indent in `canister status` than in `canister settings show`, so `format_visibility` takes the label's indent and nests relative to it. `log_visibility` is rendered by the same function, so it changes with it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp * feat: list controllers one per line, and name the viewer per setting Applies the per-line rendering to the controller list too, so the two reports list principals the same way throughout: Controllers: controller: 2vxsx-fae ... Log visibility: Allowed viewers log viewer: aaaaa-aa Status visibility: Allowed viewers status viewer: 2vxsx-fae `format_principal_list` holds the shared shape — sorted, one entry per line, nested two spaces past the label, with a note where the entries would have gone when the list is empty. Controllers were not sorted before; they are now, since the replica does not promise an order. Each entry names what it grants rather than a bare `viewer:`, because a report carries a line for both visibility settings and the entries under them would otherwise not say which they belong to. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp * chore: stop tracking the Python bytecode from the test assets `crates/icp-cli/tests/assets/__pycache__/limit_transfer.cpython-312.pyc` was committed alongside the Python asset it is compiled from. Nothing reads it, and since `.gitignore` did not cover it, anyone who ran the asset saw it come back as a dirty working tree. Untracked, and `__pycache__/` ignored so it stays that way. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp * feat: warn when a viewer edit takes access away instead of granting it `--add-status-viewer P` on a canister whose status is `public` resolves to `AllowedViewers([P])`, which revokes everyone else's access rather than adding to it; `--remove-status-viewer P` on the same canister resolves to an empty list. The log flags behave the same way — the resolution is shared — and neither said anything about it. `resolve` stays pure. `maybe_warn_on_lost_access` runs at the callsite alongside `maybe_warn_on_env_vars_change` and warns in the two cases where a viewer edit costs access: the current policy is `public` and the result names viewers, or the result names none at all. A warning rather than a prompt, because unlike losing control of a canister either change can be undone by any controller, and a prompt would break scripted use. `--set-*-viewer` did not fetch the current settings, since it does not build on them, so the public-to-viewers case could not be detected for the one flag that states the new list outright. It now fetches too; the extra query buys a warning that fires for all three flags. Removal switches from `swap_remove` to `retain`, so the viewers it leaves behind keep their order — that order is what the `status viewer:` and `log viewer:` lines print. The resolution matrix is now unit-tested, which is what the integration test already claimed: a fixed policy beats viewer edits, `--set` replaces, `--add` dedupes, an edit against a fixed policy starts from an empty list, removal is order-preserving and may empty the list, and every viewer edit requires the current settings. The two warnings are covered against a live replica instead, since they go through `warn!`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp * fix: refuse a relative viewer edit while the visibility is public `public` grants access to everyone, so it carries no allowed viewers list for `--add-log-viewer` / `--remove-log-viewer` and their status counterparts to be relative to. They started one from empty instead, which meant `--add-log-viewer P` on a public canister took access away from everyone but P, and `--remove-log-viewer P` took it away from everyone including P. Warning about it was the wrong tool: these flags do not say to change the policy at all, so there is nothing to warn about — the edit has no meaning to carry out. They are now refused while the setting is public, and the error names the two flags that do state a policy outright: Log visibility is currently public, so there is no allowed viewers list for --add-log-viewer to edit. Use `--set-log-viewer <PRINCIPAL>` to replace the public policy with an explicit list, or `--log-visibility controllers` to revoke public access on its own. `controllers` keeps accepting relative edits, because a list built from it grants access on top of the controllers rather than taking any away. `--set-*-viewer` on a public canister stays legal for the same reason the relative edits are not: it states the whole new list, so what it revokes is on its face — it warns rather than refuses, as does removing the last viewer. `resolve` grows a `Result` and the group carries the setting's names, so one implementation still serves both settings and its messages can name whichever it was reached through. This is breaking for the log flags, which shipped with the old behaviour: `canister_settings_update_log_visibility` asserted the add-to-a-public-canister case succeeding, and now asserts the refusal followed by the `--set-log-viewer` that expresses it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QooMLZ15EWRrknWtXfFZNp --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Bump the workspace dependency `ic-management-canister-types` from 0.8.0 to 0.11.0. This is needed for dfinity#11894 (offline derivation of secp256r1 keys in `ic-pub-key`). Between 0.8.0 and 0.11.0 nothing was removed or renamed. The additions still break Rust code in places, because none of these types is `#[non_exhaustive]`: - `CanisterSettings` and `DefiniteCanisterSettings` gained the fields `minimum_incoming_canister_call_cycles` and `status_visibility`, along with the new `StatusVisibility` type. - `HttpRequestArgs` gained `pricing_version`, and `HttpMethod` gained `PATCH`. - New types for flexible HTTP outcalls and subnet metrics. - `EcdsaCurve` gained `Secp256r1`. Changes that follow from the bump: - `canister_test`: one struct literal lists every `CanisterSettings` field, so it now sets the two new fields as well. - CMC: `cmc.did` declares the two new `CanisterSettings` fields, because `test_candid_interface_compatibility` requires it. The CMC now forwards these two settings in `create_canister` and `notify_create_canister`. Before, it dropped them. `unreleased_changelog.md` records this. dfinity#10756 did the same for `snapshot_visibility`. - ckDOGE minter: `ckdoge_minter.did` declares the two new `DefiniteCanisterSettings` fields, which `get_canister_status` now returns. The replica returns both fields unconditionally since dfinity#10398 and dfinity#10667, and all mainnet GuestOS versions in `mainnet-icos-revisions.json` contain both PRs. So decoding `canister_status` with the new types also works on mainnet. - Changelogs: `pocket-ic` and `ic-pub-key` re-export these types, so both record the bump. The older copies left in `Cargo.lock` come from `ic-utils` and `evm_rpc_types`, which have no newer release, and from the cdk, which a follow-up PR bumps. This does not yet remove the secp256r1 workarounds in the system tests (`cast_ecdsa_key_id`, the signer canister) and in the PocketIC test canister. Those are cdk canisters, and the workspace's `ic-cdk-management-canister` 0.1.1 re-exports the 0.7.1 types. Its 0.3.0 requires `ic-management-canister-types` ^0.11, so this bump comes first. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
What
Introduces a new canister setting,
status_visibility, that governs whichprincipals are allowed to read a canister's status via the
canister_statusmanagement endpoint. It mirrors the existing
log_visibilityandsnapshot_visibilitysettings:controllers(default): only the canister's controllers (and subnetadmins) can read the status — the pre-existing behavior.
public: anyone can read the status.allowed_viewers: the controllers, the subnet admins, and up to 10explicitly listed principals can read the status.
How
validate_status_visibilityhelper reuses theexisting
VisibilitySettings::has_accessmechanism. It is enforced on boththe ingress-acceptance path (
should_accept_ingress_message) and bothexecution paths (replicated update and non-replicated query) via
get_canister_status. A canister reading its own status is still exempt.status_visibilityis added toSystemState, persisted inCanisterStateBits(proto tag 69). Checkpoints written before this changedecode to the default (
controllers), so loading old state isbackward-compatible.
canister_statuscalls now return the dedicatedCanisterStatusAccessDenied(542) error code, replacing the previousCanisterInvalidController/CanisterInvalidControllerOrSubnetAdmin. It mapsto the same
CanisterErrorreject code as before.Compatibility notes
the setting default to
controllers, so access is unchanged.ErrorCodefor adenied
canister_status(previouslyCanisterInvalidController/CanisterInvalidControllerOrSubnetAdmin) will now seeCanisterStatusAccessDenied. The reject code is unchanged.Testing
rs/execution_environment/tests/canister_status.rsexercises the full matrix of
{status_visibility} x {controller, subnet_admin, allowed_viewer, other} x {update, query}call paths, asserting thegranted/denied outcome (and that canister_status returns the expected
status visibility upon success), and, on denial, the returned error code and
description.
canister_statusquery success metric incrementsexactly once for an allowed query call and never for a denied query or an
update call — restoring (and broadening) the coverage from the
canister_status_via_query_call_*tests removed fromexecution_test.rs.