-
Notifications
You must be signed in to change notification settings - Fork 43
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
Simplify canister state lifecycle #6302
base: main
Are you sure you want to change the base?
Conversation
46cd53b
to
527e236
Compare
d5dc422
to
00893e4
Compare
494327d
to
3b7de2f
Compare
…6301) # Motivation `accounts_db_stats_recomputed_on_upgrade` is no longer useful after the migration of accounts to stable structures. It is always `opt false`, which can be verified by `dfx canister --ic call qoctq-giaaa-aaaaa-aaaea-cai get_stats | grep accounts_db_stats_recomputed_on_upgrade` # Changes Remove everything related to `accounts_db_stats_recomputed_on_upgrade` # Tests N/A # Related PRs [Previous](#6298) | [Next](#6302)
e527938
to
46a8a44
Compare
46a8a44
to
042e60f
Compare
let expected_accounts: BTreeMap<_, _> = accounts_store.range(..).collect(); | ||
let mut expected_account_stats = Stats::default(); | ||
accounts_store.get_stats(&mut expected_account_stats); | ||
let expected_assets = assets.clone(); | ||
let expected_tvl_state = tvl_state.clone(); | ||
let expected_asset_hashes = asset_hashes.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is a side effect of doing a conversion from State
to SerializableState
, since during the conversion, State
is destroyed, so we need to clone parts of the state before consuming it. An alternative is impl From<&State> for SerializableState
. However, this would worsen the production code, since the conversion would have to clone data unnecessarily. The downside of having to clone the parts of the state for comparison in a unit test seems to acceptable.
ad26122
to
19088a5
Compare
19088a5
to
b6bbedc
Compare
Motivation
When deserializing the
State
and reconstruct it, anAccountsDbAsMap
is first created when deserializing, then gets replaced withAccountsDbAsUnboundedStableBTreeMap
. This makes the removal ofAccountsDbAsMap
(which is no longer used in production difficult.Changes
thread_local!
variableState
State
(conversion->)SerializableState
SerializableState
(encode ->)Vec<u8>
Vec<u8>
Vec<u8>
(decode ->)SerializableState
SerializableState
(conversion->)State
Tests
N/A since there are no functionality changes. The test in
rs/backend/src/state/tests.rs
should (still) cover the code being changed in this PR.Related PRs
Previous | Next