Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

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

Merged
merged 21 commits into from
Nov 1, 2024
Merged
2 changes: 1 addition & 1 deletion spec/_attachments/ic.did
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type wasm_module = blob;

type log_visibility = variant {
controllers;
allowlist : vec principal;
allowed_viewers : vec principal;
public;
};

Expand Down
21 changes: 6 additions & 15 deletions spec/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2604,11 +2604,11 @@ 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` and it can be:
The log visibility is defined in the `log_visibility` field of `canister_settings`:

- `controllers`: only visible to the canister's controllers (by default)
- `allowlist`: visible to the provided list of principals, the maximum length of the list is 10
- `public`: visible to everyone
- `controllers`: only canister's controllers can fetch logs (by default)
- `allowed_viewers`: only provided list of principals can fetch logs, the maximum length of the list is 10
maksymar marked this conversation as resolved.
Show resolved Hide resolved
- `public`: everyone can fetch logs

A single log is a record with the following fields:

Expand Down Expand Up @@ -3247,7 +3247,7 @@ CanisterHistory = {
}
CanisterLogVisibility
= Controllers
| AllowList
| AllowedViewers
maksymar marked this conversation as resolved.
Show resolved Hide resolved
| Public
CanisterLog = {
idx : Nat;
Expand Down Expand Up @@ -3283,7 +3283,6 @@ S = {
certified_data: CanisterId ↦ Blob;
canister_history: CanisterId ↦ CanisterHistory;
canister_log_visibility: CanisterId ↦ CanisterLogVisibility;
canister_log_allowlist: CanisterId ↦ Set Principal;
canister_logs: CanisterId ↦ [CanisterLog];
query_stats: CanisterId ↦ [QueryStats];
system_time : Timestamp
Expand Down Expand Up @@ -3361,7 +3360,6 @@ 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 @@ -4211,8 +4209,6 @@ 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?
else:
New_canister_log_visibility = Controllers

Expand All @@ -4239,7 +4235,6 @@ 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 @@ -4371,7 +4366,6 @@ 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 @@ -5263,7 +5257,6 @@ 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 @@ -5458,7 +5451,6 @@ 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 @@ -5483,7 +5475,6 @@ 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 @@ -5893,7 +5884,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 or Q.sender in S[A.canister_id].canister_log_allowlist
S[A.canister_id].canister_log_visibility = Public or (S[A.canister_id].canister_log_visibility = AllowedViewers Principals and Q.sender in Principals) or Q.sender in S[A.canister_id].controllers
mraszyk marked this conversation as resolved.
Show resolved Hide resolved

```

Expand Down
Loading