feat(nns/sns): Add allowed_viewers variant case into canister_status responses #3660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
Currently, the management canister can return the LogVisibility::AllowedViewers variant for the canister status of a canister under NNS/SNS root control. Although it's currently impossible for NNS/SNS root to change the log visibility of any canister under their control into this variant, it's still possible for a canister with this variant to be brought under its control. When the
canister_status
is called in this case, thecanister_status
call made by root to the management canister will fail at decoding the response. This PR aims to improve that.What
allowed_viewers
variant intoLogVisibility
where it's part of thecanister_status
response (not when it's part ofupdate_settings
). Since the response from SNS/NNS root also uses this enum, this change also affects NNS/SNS root response types.canister_status
response typesWhy It's Safe
We need to reason about the data flow in such sequence (true for both NNS/SNS Root, and will refer to them as Root below), when
Root::canister_status
is called:canister_status
response from the management canister as bytesCanisterStatusResultFromManagementCanister
CanisterStatusResultFromManagementCanister
toCanisterStatusResult
orCanisterStatusResultV2
CanisterStatusResult
orCanisterStatusResultV2
into bytesWe can then reason about the above data flow in several cases:
controllers/public
, there is no change.allowed_viewers
and the client uses the oldroot.did
:CanisterStatusResult
orCanisterStatusResultV2
having theallowed_viewers
variantroot.did
(noallowed_viewers
) will not understand the variant, but sincelog_visibility : opt LogVisibility
, it will decode it tolog_visibility : null
allowed_viewers
and the client uses the newroot.did
, the client will be able to seeallowed_viewers