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

Remove dead code related to accounts migration #6311

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

jasonz-dfinity
Copy link
Contributor

@jasonz-dfinity jasonz-dfinity commented Feb 1, 2025

Motivation

Some of the migration code is already dead. Either they are marked as #allow[dead_code], or they are structs/enums not used anymore.

Changes

  • Remove SchemaLabel and serialization/deserialization code around it
  • Remove step_migration canister method (it's an internal method since it checks the caller, so no backward compatibility problems)
  • Assume AccountsDbAsProxy::migration is always None, remove the field and simplifies the code paths

Tests

N/A

Related PRs

Previous | Next

@dskloetd
Copy link
Contributor

dskloetd commented Feb 3, 2025

The diff looks much larger than what the PR description describes. Did you make changes to the merge base?

@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-3030-4 branch 4 times, most recently from 3930cab to 8f323c8 Compare February 4, 2025 06:27
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-3030-5 branch 2 times, most recently from a34a6a6 to 00dc316 Compare February 4, 2025 06:43
@jasonz-dfinity jasonz-dfinity changed the title Inline all the StableBtreeMap operations Remove dead code related to accounts migration Feb 4, 2025
@jasonz-dfinity
Copy link
Contributor Author

The diff looks much larger than what the PR description describes. Did you make changes to the merge base?

I started removing the proxy code and the diffs just got bigger and bigger. I repurposed this PR for those that can already by removed without changing the AccountsDbProxy. The next PR will be about AccountsDbProxy. PTAL

github-merge-queue bot pushed a commit that referenced this pull request Feb 4, 2025
…_db (#6302)

# Motivation

The `AccountsDb::Map(AccountsDbAsMap)` enum value (i.e. representing
accounts as a map in heap memory) is deprecated, and we'd like to remove
this case (and only have the branch of code for the
`AccountsDb::UnboundedStableBTreeMap(AccountsDbAsUnboundedStableBTreeMap<>)`).
However, currently it's impossible, since `AccountsStore::decode` calls
`AccountsDbAsProxy::default()`, which is an instance of the deprecated
type. The `accounts_db` is later
[replaced](https://sourcegraph.com/github.com/dfinity/nns-dapp@395ad2a74c9309b2f6b943bce3964921904d6e36/-/blob/rs/backend/src/state.rs?L147)
so that the production code indeed uses the `StableBTreeMap`. Therefore,
this PR aims at removing the default-then-replace approach, by
initializing the `AccountsDb::UnboundedStableBTreeMap` directly.


# Changes

- Inline and remove `State::save_heap_to_managed_memory` and
`State::recover_heap_from_managed_memory`, since the logic is simple (so
the indirection is no longer necessary)
- Move some of the logic from `State::new_restored` into `State::decode`
and remove the `default`/`replace_accounts_db` logic (which is the main
goal of the PR)
- Move the `accounts_store` initialization logic from `State::new` to
`AccountsStore::new`, to keep StableBTreeMap initialization logic close
to each other

# 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](#6301) |
[Next](#6311)
Base automatically changed from jason/NNS1-3030-4 to main February 4, 2025 08:16
@jasonz-dfinity jasonz-dfinity added this pull request to the merge queue Feb 4, 2025
Merged via the queue into main with commit 7fc1e5a Feb 4, 2025
32 checks passed
@jasonz-dfinity jasonz-dfinity deleted the jason/NNS1-3030-5 branch February 4, 2025 16:33
github-merge-queue bot pushed a commit that referenced this pull request Feb 4, 2025
# Motivation

There are currently 3 layers of indirection:
`AccountsStore`->`AccountsDbAsProxy`->`AccountsDb`->`AccountsDbAsUnboundedStableBTreeMap`->`StableBTreeMap`.
This PR inlines the `AccountsDbAsUnboundedStableBTreeMap` into
`AccountsStore` directly, since each layer is very thin.

# Changes

* Change `AccountsStore::accounts_db` from `AccountsDbAsProxy` to
`StableBTreeMap`
* Inline the all the function calls related to `StableBTreeMap`
* Refactor `impl PartialEq/Eq/Default` from `AccountsDbAsProxy` to
`AccountsStore` (since the former doesn't exist anymore, and the latter
can no longer derive because of `StableBTreeMap` does not have those
traits)

# Tests

N/A

# Related PR

[Previous](#6311)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants