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

feat: ICRC-ledger: FI-1439: Implement V4 for ICRC ledger - migrate balances to stable structures #2901

Merged
merged 67 commits into from
Jan 7, 2025

Conversation

maciejdfinity
Copy link
Contributor

@maciejdfinity maciejdfinity commented Nov 29, 2024

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 .

@maciejdfinity maciejdfinity changed the title ICRC stable balances feat(ICRC-ledger): FI-1439: Implement V4 for ICRC ledger - migrate balances to stable structures Nov 29, 2024
@github-actions github-actions bot added the feat label Nov 29, 2024
Copy link
Member

@mbjorkqvist mbjorkqvist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving the tests and re-enabling the ignored ones!

@max-dfinity
Copy link
Contributor

I see our review is requested, but we don't seem to have anything to review for our team specifically - I'm assuming this was because of an earlier PR version. Let me know if that's not correct!

@maciejdfinity maciejdfinity requested a review from a team as a code owner December 20, 2024 18:19
@maciejdfinity maciejdfinity added this pull request to the merge queue Jan 7, 2025
Merged via the queue into master with commit c741e34 Jan 7, 2025
25 checks passed
@maciejdfinity maciejdfinity deleted the maciej-icrc-v4 branch January 7, 2025 11:09
daniel-wong-dfinity-org pushed a commit that referenced this pull request Jan 7, 2025
…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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants