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

Commit

Permalink
Fix issues found by Martin
Browse files Browse the repository at this point in the history
  • Loading branch information
ulan committed Dec 4, 2023
1 parent f7dba9f commit 2985f8d
Showing 1 changed file with 50 additions and 38 deletions.
88 changes: 50 additions & 38 deletions spec/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3768,17 +3768,19 @@ Cycles_reserved = cycles_to_reserve(S, New_compute_allocation, New_memory_alloca
New_balance = M.transferred_cycles - Cycles_reserved
New_reserved_balance = Cycles_reserved
New_reserved_balance <= New_reserved_balance_limit
liquid_balance(
New_balance,
New_reserved_balance,
freezing_limit(
New_compute_allocation,
New_memory_allocation,
New_freezing_threshold,
memory_usage_canister_history(New_canister_history),
SubnetSize,
)
) ≥ 0
if New_compute_allocation > 0 or New_memory_allocation > 0 or Cycles_reserved > 0:
liquid_balance(
New_balance,
New_reserved_balance,
freezing_limit(
New_compute_allocation,
New_memory_allocation,
New_freezing_threshold,
memory_usage_canister_history(New_canister_history),
SubnetSize,
)
) ≥ 0


New_canister_history = {
total_num_changes = 1
Expand Down Expand Up @@ -3807,7 +3809,7 @@ S with
compute_allocation[CanisterId] = New_compute_allocation
memory_allocation[CanisterId] = New_memory_allocation
freezing_threshold[CanisterId] = New_freezing_threshold
balances[CanisterId] = M.transferred_cycles
balances[CanisterId] = New_balance
reserved_balances[Canister_id] = New_reserved_balance
reserved_balance_limits[Canister_id] = New_reserved_balance_limit
certified_data[CanisterId] = ""
Expand Down Expand Up @@ -3858,20 +3860,6 @@ M.method_name = 'update_settings'
M.arg = candid(A)
M.caller ∈ S.controllers[A.canister_id]

if New_compute_allocation > S.compute_allocation[A.canister_id] or New_memory_allocation > S.memory_allocation[A.canister_id]:
liquid_balance(
S.balances[A.canister_id],
S.reserved_balances[A.canister_id],
freezing_limit(
New_compute_allocation,
New_memory_allocation,
New_freezing_threshold,
memory_usage_wasm_state(S.canisters[A.canister_id].wasm_state) +
memory_usage_raw_module(S.canisters[A.canister_id].raw_module) +
memory_usage_canister_history(New_canister_history),
S.canister_subnet[A.canister_id].subnet_size,
)
) ≥ 0
if New_memory_allocation > 0:
memory_usage_wasm_state(S.canisters[A.canister_id].wasm_state) +
memory_usage_raw_module(S.canisters[A.canister_id].raw_module) +
Expand All @@ -3893,7 +3881,26 @@ if A.settings.reserved_cycles_limit is not null:
New_reserved_balance_limit = A.settings.reserved_cycles_limit
else:
New_reserved_balance_limit = S.reserved_balance_limits[A.canister_id]
S.reserved_balances[A.canister_id] ≤ New_reserved_balance_limit

Cycles_reserved = cycles_to_reserve(S, New_compute_allocation, New_memory_allocation, S.canisters[A.canister_id].wasm_state)
New_balance = S.balances[A.canister_id] - Cycles_reserved
New_reserved_balance = S.reserved_balances[A.canister_id] + Cycles_reserved
New_reserved_balance ≤ New_reserved_balance_limit
if New_compute_allocation > S.compute_allocation[A.canister_id] or New_memory_allocation > S.memory_allocation[A.canister_id] or Cycles_reserved > 0:
liquid_balance(
New_balance,
New_reserved_balance,
freezing_limit(
New_compute_allocation,
New_memory_allocation,
New_freezing_threshold,
memory_usage_wasm_state(S.canisters[A.canister_id].wasm_state) +
memory_usage_raw_module(S.canisters[A.canister_id].raw_module) +
memory_usage_canister_history(New_canister_history),
S.canister_subnet[A.canister_id].subnet_size,
)
) ≥ 0

S.canister_history[A.canister_id] = {
total_num_changes = N;
recent_changes = H;
Expand Down Expand Up @@ -3926,6 +3933,8 @@ S with
compute_allocation[A.canister_id] = New_compute_allocation
memory_allocation[A.canister_id] = New_memory_allocation
freezing_threshold[A.canister_id] = New_freezing_threshold
balances[A.canister_id] = New_balance
reserved_balances[A.canister_id] = New_reserved_balance
reserved_balance_limits[A.canister_id] = New_reserved_balance_limit
canister_version[A.canister_id] = S.canister_version[A.canister_id] + 1
messages = Older_messages · Younger_messages ·
Expand Down Expand Up @@ -4847,6 +4856,7 @@ if A.settings.controllers is not null:
New_controllers = A.settings.controllers
else:
New_controllers = [M.caller]

if New_memory_allocation > 0:
memory_usage_canister_history(New_canister_history) ≤ New_memory_allocation

Expand Down Expand Up @@ -4874,17 +4884,19 @@ else:
New_balance = DEFAULT_PROVISIONAL_CYCLES_BALANCE - Cycles_reserved
New_reserved_balance = Cycles_reserved
New_reserved_balance ≤ New_reserved_balance_limit
liquid_balance(
New_balance,
New_reserved_balance,
freezing_limit(
New_compute_allocation,
New_memory_allocation,
New_freezing_threshold,
memory_usage_canister_history(New_canister_history),
SubnetSize
)
) ≥ 0
if New_compute_allocation > 0 or New_memory_allocation > 0 or Cycles_reserved > 0:
liquid_balance(
New_balance,
New_reserved_balance,
freezing_limit(
New_compute_allocation,
New_memory_allocation,
New_freezing_threshold,
memory_usage_canister_history(New_canister_history),
SubnetSize,
)
) ≥ 0


New_canister_history {
total_num_changes = 1
Expand Down

0 comments on commit 2985f8d

Please sign in to comment.