-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ICRC-ledger: FI-1439: Implement V4 for ICRC ledger - migrate ba…
…lances to stable structures (#2901) This version of the ledger migrates the balances stored by the ledger from heap to stable memory stable structures. This allows the ledger to store more data (heap memory is limited to 4GB) and reduces the number of instructions used during the upgrades - there is no need to serialize and deserialize the balances stored in heap memory. Since we are no longer limited by the heap size, the logic for trimming balances and related init/upgrade arguments (`maximum_number_of_accounts`, `accounts_overflow_trim_quantity`) were removed. The migration to stable structures is performed during the upgrade and, if 200B instruction limit is reached, using timer invocations after the upgrade. If timer invocations are used by the migration, the ledger is unavailable for transfers and approvals until migration is finished. The migration status can be checked by checking the value of the `ledger_stable_upgrade_migration_steps` metric and calling the `is_ledger_ready` endpoint. The metric will increase at roughly 1s intervals until the migration is finished. The canister logs will also contain some information about the number of migrated allowances and balances (e.g. "Migration partially done. Scheduling the next part. Number of elements migrated: allowances: 0 expirations: 0 balances: 7657..."). If migration is not progressing and the ledger is not ready, the ledger can still be downgraded to the previous version. After migration is finished and `is_ledger_ready` returns true, it is no longer possible to downgrade the ledger to the previous version . --------- Co-authored-by: Mathias Björkqvist <mathias.bjorkqvist@dfinity.org>
- Loading branch information
1 parent
21c5e93
commit c741e34
Showing
18 changed files
with
494 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1250,6 +1250,7 @@ fn test_upgrade_serialization() { | |
upgrade_args, | ||
minter, | ||
false, | ||
false, | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 16 additions & 16 deletions
32
rs/ledger_suite/icrc1/ledger/canbench_results/canbench_u256.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
benches: | ||
bench_icrc1_transfers: | ||
total: | ||
instructions: 6398923208 | ||
heap_increase: 227 | ||
instructions: 13798815361 | ||
heap_increase: 172 | ||
stable_memory_increase: 128 | ||
scopes: | ||
before_upgrade: | ||
instructions: 5790054103 | ||
heap_increase: 71 | ||
instructions: 13630531777 | ||
heap_increase: 43 | ||
stable_memory_increase: 0 | ||
post_upgrade: | ||
instructions: 424320009 | ||
heap_increase: 27 | ||
instructions: 118601062 | ||
heap_increase: 0 | ||
stable_memory_increase: 0 | ||
pre_upgrade: | ||
instructions: 184546072 | ||
instructions: 49679478 | ||
heap_increase: 129 | ||
stable_memory_increase: 128 | ||
upgrade: | ||
instructions: 608867671 | ||
heap_increase: 156 | ||
instructions: 168282130 | ||
heap_increase: 129 | ||
stable_memory_increase: 128 | ||
bench_upgrade_baseline: | ||
total: | ||
instructions: 8755062 | ||
instructions: 8684974 | ||
heap_increase: 258 | ||
stable_memory_increase: 129 | ||
stable_memory_increase: 128 | ||
scopes: | ||
post_upgrade: | ||
instructions: 8627524 | ||
instructions: 8606422 | ||
heap_increase: 129 | ||
stable_memory_increase: 0 | ||
pre_upgrade: | ||
instructions: 125131 | ||
instructions: 76145 | ||
heap_increase: 129 | ||
stable_memory_increase: 129 | ||
stable_memory_increase: 128 | ||
upgrade: | ||
instructions: 8754373 | ||
instructions: 8684285 | ||
heap_increase: 258 | ||
stable_memory_increase: 129 | ||
stable_memory_increase: 128 | ||
version: 0.1.7 |
32 changes: 16 additions & 16 deletions
32
rs/ledger_suite/icrc1/ledger/canbench_results/canbench_u64.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
benches: | ||
bench_icrc1_transfers: | ||
total: | ||
instructions: 5926738616 | ||
heap_increase: 214 | ||
instructions: 13237283790 | ||
heap_increase: 171 | ||
stable_memory_increase: 128 | ||
scopes: | ||
before_upgrade: | ||
instructions: 5341274673 | ||
heap_increase: 64 | ||
instructions: 13068913917 | ||
heap_increase: 42 | ||
stable_memory_increase: 0 | ||
post_upgrade: | ||
instructions: 406888378 | ||
heap_increase: 21 | ||
instructions: 118797275 | ||
heap_increase: 0 | ||
stable_memory_increase: 0 | ||
pre_upgrade: | ||
instructions: 178572258 | ||
instructions: 49569466 | ||
heap_increase: 129 | ||
stable_memory_increase: 128 | ||
upgrade: | ||
instructions: 585462226 | ||
heap_increase: 150 | ||
instructions: 168368331 | ||
heap_increase: 129 | ||
stable_memory_increase: 128 | ||
bench_upgrade_baseline: | ||
total: | ||
instructions: 8758206 | ||
instructions: 8686052 | ||
heap_increase: 258 | ||
stable_memory_increase: 129 | ||
stable_memory_increase: 128 | ||
scopes: | ||
post_upgrade: | ||
instructions: 8627876 | ||
instructions: 8606533 | ||
heap_increase: 129 | ||
stable_memory_increase: 0 | ||
pre_upgrade: | ||
instructions: 127923 | ||
instructions: 77112 | ||
heap_increase: 129 | ||
stable_memory_increase: 129 | ||
stable_memory_increase: 128 | ||
upgrade: | ||
instructions: 8757517 | ||
instructions: 8685363 | ||
heap_increase: 258 | ||
stable_memory_increase: 129 | ||
stable_memory_increase: 128 | ||
version: 0.1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.