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

[FINAL] feat: [EXC-1676] add allowed viewers variant to canister's log visibility #326

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions spec/_attachments/ic.did
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ type wasm_module = blob;

type log_visibility = variant {
controllers;
allowlist : opt vec principal;
maksymar marked this conversation as resolved.
Show resolved Hide resolved
public;
};

Expand Down
19 changes: 17 additions & 2 deletions spec/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2603,7 +2603,12 @@ The canister logs are *not* collected in canister methods running in non-replica
The total size of all returned logs does not exceed 4KiB.
If new logs are added resulting in exceeding the maximum total log size of 4KiB, the oldest logs will be removed.
Logs persist across canister upgrades and they are deleted if the canister is reinstalled or uninstalled.
The log visibility is defined in the `log_visibility` field of `canister_settings`: logs can be either public (visible to everyone) or only visible to the canister's controllers (by default).

The log visibility is defined in the `log_visibility` field of `canister_settings` and it can be:

- `controllers`: only visible to the canister's controllers (by default)
- `allowlist`: visible to the provided list of principals, max number is limited by 10
maksymar marked this conversation as resolved.
Show resolved Hide resolved
- `public`: visible to everyone

A single log is a record with the following fields:

Expand Down Expand Up @@ -3242,6 +3247,7 @@ CanisterHistory = {
}
CanisterLogVisibility
= Controllers
| AllowList
| Public
CanisterLog = {
idx : Nat;
Expand Down Expand Up @@ -3277,6 +3283,7 @@ S = {
certified_data: CanisterId ↦ Blob;
canister_history: CanisterId ↦ CanisterHistory;
canister_log_visibility: CanisterId ↦ CanisterLogVisibility;
canister_log_allowlist: CanisterId ↦ Set Principal;
maksymar marked this conversation as resolved.
Show resolved Hide resolved
canister_logs: CanisterId ↦ [CanisterLog];
query_stats: CanisterId ↦ [QueryStats];
system_time : Timestamp
Expand Down Expand Up @@ -3354,6 +3361,7 @@ The initial state of the IC is
certified_data = ();
canister_history = ();
canister_log_visibility = ();
canister_log_allowlist = ();
canister_logs = ();
query_stats = ();
system_time = T;
Expand Down Expand Up @@ -4203,6 +4211,8 @@ New_canister_history = {

if A.settings.log_visibility is not null:
New_canister_log_visibility = A.settings.log_visibility
if New_canister_log_visibility is AllowList:
New_canister_log_allowlist = A.settings.log_visibility ?? how to get allowlist?
maksymar marked this conversation as resolved.
Show resolved Hide resolved
else:
New_canister_log_visibility = Controllers

Expand All @@ -4229,6 +4239,7 @@ S with
query_stats[Canister_id] = []
canister_history[Canister_id] = New_canister_history
canister_log_visibility[Canister_id] = New_canister_log_visibility
canister_log_allowlist[Canister_id] = New_canister_log_allowlist
canister_logs[Canister_id] = []
messages = Older_messages · Younger_messages ·
ResponseMessage {
Expand Down Expand Up @@ -4360,6 +4371,7 @@ S with
canister_version[A.canister_id] = S.canister_version[A.canister_id] + 1
if A.settings.log_visibility is not null:
canister_log_visibility[A.canister_id] = A.settings.log_visibility
// TODO: update canister_log_allowlist
messages = Older_messages · Younger_messages ·
ResponseMessage {
origin = M.origin
Expand Down Expand Up @@ -5251,6 +5263,7 @@ S with
certified_data[A.canister_id] = (deleted)
canister_history[A.canister_id] = (deleted)
canister_log_visibility[A.canister_id] = (deleted)
canister_log_allowlist[A.canister_id] = (deleted)
canister_logs[A.canister_id] = (deleted)
query_stats[A.canister_id] = (deleted)
messages = Older_messages · Younger_messages ·
Expand Down Expand Up @@ -5445,6 +5458,7 @@ New_canister_history {

if A.settings.log_visibility is not null:
New_canister_log_visibility = A.settings.log_visibility
// TODO: update New_canister_log_allowlist
else:
New_canister_log_visibility = Controllers

Expand All @@ -5469,6 +5483,7 @@ S with
certified_data[Canister_id] = ""
canister_history[Canister_id] = New_canister_history
canister_log_visibility[Canister_id] = New_canister_log_visibility
canister_log_allowlist[Canister_id] = New_canister_log_allowlist
canister_logs[Canister_id] = []
query_stats[CanisterId] = []
messages = Older_messages · Younger_messages ·
Expand Down Expand Up @@ -5878,7 +5893,7 @@ Q.canister_id = ic_principal
Q.method_name = 'fetch_canister_logs'
Q.arg = candid(A)
A.canister_id = effective_canister_id
S[A.canister_id].canister_log_visibility = Public or Q.sender in S[A.canister_id].controllers
S[A.canister_id].canister_log_visibility = Public or Q.sender in S[A.canister_id].controllers or Q.sender in S[A.canister_id].canister_log_allowlist
maksymar marked this conversation as resolved.
Show resolved Hide resolved

```

Expand Down
Loading