Skip to content

Commit e93e6cd

Browse files
Add change history
1 parent 1e05ca0 commit e93e6cd

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

docs/references/_attachments/ic.did

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ type change_details = variant {
6161
controllers_change : record {
6262
controllers : vec principal;
6363
};
64+
environment_variables_change: record {
65+
hash: blob;
66+
}
6467
};
6568

6669
type change = record {

docs/references/ic-interface-spec.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,7 @@ This method can only be called by canisters, i.e., it cannot be called by extern
24612461

24622462
Provides the history of the canister, its current module SHA-256 hash, and its current controllers. Every canister can call this method on every other canister (including itself). Users cannot call this method.
24632463

2464-
The canister history consists of a list of canister changes (canister creation, code uninstallation, code deployment, snapshot restoration, or controllers change). Every canister change consists of the system timestamp at which the change was performed, the canister version after performing the change, the change's origin (a user or a canister), and its details. The change origin includes the principal (called *originator* in the following) that initiated the change and, if the originator is a canister, the originator's canister version when the originator initiated the change (if available). Code deployments are described by their mode (code install, code reinstall, code upgrade) and the SHA-256 hash of the newly deployed canister module. Loading a snapshot is described by the canister version, snapshot ID and timestamp at which the snapshot was taken. Canister creations and controllers changes are described by the full new set of the canister controllers after the change. The order of controllers stored in the canister history may vary depending on the implementation.
2464+
The canister history consists of a list of canister changes (canister creation, code uninstallation, code deployment, snapshot restoration, or controllers or environment variable change). Every canister change consists of the system timestamp at which the change was performed, the canister version after performing the change, the change's origin (a user or a canister), and its details. The change origin includes the principal (called *originator* in the following) that initiated the change and, if the originator is a canister, the originator's canister version when the originator initiated the change (if available). Code deployments are described by their mode (code install, code reinstall, code upgrade) and the SHA-256 hash of the newly deployed canister module. Loading a snapshot is described by the canister version, snapshot ID and timestamp at which the snapshot was taken. Canister creations and controllers changes are described by the full new set of the canister controllers after the change. The order of controllers stored in the canister history may vary depending on the implementation.
24652465

24662466
The system can drop the oldest canister changes from the list to keep its length bounded (at least `20` changes are guaranteed to remain in the list). The system also drops all canister changes if the canister runs out of cycles.
24672467

@@ -4903,18 +4903,39 @@ S.canister_history[A.canister_id] = {
49034903
total_num_changes = N;
49044904
recent_changes = H;
49054905
}
4906-
if A.settings.controllers is not null:
4907-
New_canister_history = {
4908-
total_num_changes = N + 1;
4909-
recent_changes = H · {
4910-
timestamp_nanos = S.time[A.canister_id];
4911-
canister_version = S.canister_version[A.canister_id] + 1;
4912-
origin = change_origin(M.caller, A.sender_canister_version, M.origin);
4913-
details = ControllersChange {
4914-
controllers = A.settings.controllers;
4915-
};
4916-
environment_variables[A.canister_id] = New_environment_variables
4906+
4907+
New_recent_changes = H ·
4908+
// Add controllers change if present
4909+
(if A.settings.controllers is not null then
4910+
[{
4911+
timestamp_nanos = S.time[A.canister_id];
4912+
canister_version = S.canister_version[A.canister_id] + 1;
4913+
origin = change_origin(M.caller, A.sender_canister_version, M.origin);
4914+
details = ControllersChange {
4915+
controllers = A.settings.controllers;
49174916
};
4917+
}]
4918+
else
4919+
[]) ·
4920+
// Add environment variables change if present
4921+
(if A.settings.environment_variables is not null then
4922+
[{
4923+
timestamp_nanos = S.time[A.canister_id];
4924+
canister_version = S.canister_version[A.canister_id] + 1;
4925+
origin = change_origin(M.caller, A.sender_canister_version, M.origin);
4926+
details = EnvironmentVariablesChange {
4927+
hash = SHA-256(A.settings.environment_variables);
4928+
};
4929+
}]
4930+
else
4931+
[])
4932+
4933+
if A.settings.controllers is not null or A.settings.environment_variables is not null:
4934+
New_canister_history = {
4935+
total_num_changes = N +
4936+
(if A.settings.controllers is not null then 1 else 0) +
4937+
(if A.settings.environment_variables is not null then 1 else 0);
4938+
recent_changes = New_recent_changes
49184939
}
49194940
else:
49204941
New_canister_history = S.canister_history[A.canister_id]

0 commit comments

Comments
 (0)