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

Storage Version Migration #3220

Merged
merged 33 commits into from
Jan 7, 2025

Conversation

wangminqi
Copy link
Member

P-1245
Our Litentry, Paseo are Storage version outdated. It will block tools/CI like try-runtime.

Copy link

linear bot commented Dec 26, 2024

Copy link
Collaborator

@Kailai-Wang Kailai-Wang left a comment

Choose a reason for hiding this comment

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

Thank you!

Just to double-check: we'll need to apply this migration first, then try-runtime cli will work?

// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

// By the time of this migration on Litentry 9220 (polkadot stable2407)
// The current storage version: pallet version:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm I think we only have StorageVersion now, no PalletVersion?

As I saw there was once a migration from PalletVersion to the new StorageVersion: https://paritytech.github.io/polkadot-sdk/master/src/frame_support/migrations.rs.html#255-261

Copy link
Member Author

@wangminqi wangminqi Jan 2, 2025

Choose a reason for hiding this comment

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

Yes, apply this migration first then try-runtime feature.

pallet version is indeed storage version. And truth is we are missing/wrong on both.

There are few pallets (weird) using a special "storageVersion" StorageMap holding the info. But palletVersion query onchain is not bonding to this storage at all. (see my comment on transactionPayment, vesting pallets)

The PalletVersion migration you providing is mostly likely not going to work for us. It just clean the Pallet version storage (if any) and assign the latest storage version without doing any specific migration.

// Balances V0 => V1
// The official pallet migration is not need since we do not have any XCM deactive accounts
// But our onchain inactiveIssuance storage of pallet_balance is non-negative
// TODO: Where does this number come from?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe it's just calculated from total_issuance - active_issuance.

I googled a bit:

How Does It Emerge?
inactive issuance can accumulate in the following scenarios:

Locks Applied by Other Pallets: Pallets like pallet-staking or pallet-democracy can introduce locks on tokens, marking them as inactive until certain conditions are met (e.g., unlocking after a referendum).
Misconfiguration or Bugs: An incorrect runtime implementation or upgrade could inadvertently increase inactive issuance.
Custom Pallets or Extensions: Developers may implement additional features that lock balances in ways not accounted for during runtime upgrades or storage migrations.
When tokens are locked via these mechanisms, they are no longer counted as "active issuance" but still exist in the chain's total issuance.

"StorageVersion".as_bytes(),
));

InactiveIssuance::<T>::kill();
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO we should not touch it - just upgrading the storage version is enough

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I will remove this part of code for security purpose.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove it? Then we are good to go I guess

// TODO: Where does this number come from?
BalancesUpdateStorageVersionResetInactive<Runtime>,
// Democracy V0 => V1
// This migration only effects onging proposal/referedum, NextExternal
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it mean it's better to wait until there's no on-going ref/proposals to do this migration?

Copy link
Member Author

Choose a reason for hiding this comment

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

Technically it should be the same whether or not there is any onging ones.

see extra comment
// The referedum info's proposal hash is migrated if the hash is in old form (In our case, even for an onging one it will do nothing)

new ongoing ref/proposal should already have new form, so it will do nothing.

But from a ghost story perspective, of course it will be better if no onging ones.

// V4 to V5
// Did nothing to storage
// Just checking MaxActiveOutboundChannels is not exceeded
// Our current Paseo Storage is 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you mean Litentry?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, updated.

// V3 to V4
// XCMP QueueConfig has different default value
// Migration targeting at changing storage value to new default value if old value matched
// Our current Paseo setting has already hard-coded
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you mean Litentry?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, updated.

@wangminqi wangminqi requested review from Kailai-Wang and a team January 2, 2025 05:52
@BillyWooo BillyWooo merged commit 2df2053 into dev Jan 7, 2025
20 checks passed
@BillyWooo BillyWooo deleted the p-1245-manul-migration-based-on-storage-version branch January 7, 2025 14:03
@Kailai-Wang
Copy link
Collaborator

Kailai-Wang commented Jan 7, 2025

This comment is not yet resolved:
https://github.com/litentry/heima/pull/3220/files/a7230bb2d845ee2b2e97ec7e71d1bb8b4e7d62ab#r1905144095

Nor is this PR approved :(

BillyWooo added a commit that referenced this pull request Jan 7, 2025
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.

3 participants