-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: asset metadata xcm v3 migration cleanup other migrations #1528
Conversation
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.
Will take a final look once Altair is in! Migrations looks like it was really tricky, thanks that looks great now!
runtime/centrifuge/src/migrations.rs
Outdated
// TODO(@review): Should probably be LiquidityPoolsTransferability? | ||
transferability: CrossChainTransferability::Xcm(XcmMetadata { | ||
fee_per_second: None, | ||
}), |
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.
No, that is perfect as is. We only want to receive that via xcm into accounts for now. I think we first need to go over the implications of having both transferabilities enabled for a single asset.
|
||
// Complexity: O(loc_count) writes | ||
let result = | ||
orml_asset_registry::LocationToAssetId::<T>::clear(loc_count.saturating_add(2), None); |
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.
Why the plus 2?
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.
Sorry, this can be removed. It was needed when we read the counts via the iter_keys
API due to key decoding failures. However, the current approach ignores decoding and thus catches all keys.
); | ||
|
||
// Complexity: O(meta_count) writes | ||
let result = orml_asset_registry::Metadata::<T>::clear(meta_count.saturating_add(1), None); |
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.
Why the plus 1?
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.
See above.
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.
Sick!
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.
Native currency needs absolut path.
let mut tranche_id = [0u8; 16]; | ||
tranche_id[..tranche_id_bytes.len()].copy_from_slice(tranche_id_bytes); | ||
|
||
vec![ |
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.
Can we also register Native
here? Wdyt? No hard requirement.
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.
Sure! I suppose we want to register all Centrifuge assets actually?
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.
I think Native
is sufficient, no?
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.
Not sure TBH. Catalyst is not connected to anything and we control Council. So I would say we can also do it later. Are there any other reasons I am missing? Whatever you think is best and easiest.
Co-authored-by: Frederik Gartenmeister <[email protected]>
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.
Look good! I was thinking that we would "just" basically call omrl_asset_registry::update_asset
for each known CurrencyId
with the updated, xcm v3 multilocation, instead of clearing all the different storages and registering the tokens anew. That still seems much simpler but now we have this already in place so that's not a problem for me 👍
runtime/altair/src/xcm.rs
Outdated
RuntimeCall::System( | ||
frame_system::Call::kill_prefix { .. } | frame_system::Call::set_heap_pages { .. }, | ||
) | RuntimeCall::Timestamp(..) | ||
RuntimeCall::Timestamp(..) | ||
| RuntimeCall::Balances(..) | ||
| RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | ||
| RuntimeCall::Treasury(..) | ||
| RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | ||
| RuntimeCall::Vesting(..) | ||
| RuntimeCall::PolkadotXcm( | ||
pallet_xcm::Call::limited_reserve_transfer_assets { .. } | ||
) | RuntimeCall::CollatorSelection( | ||
pallet_collator_selection::Call::set_desired_candidates { .. } | ||
| pallet_collator_selection::Call::set_candidacy_bond { .. } | ||
| pallet_collator_selection::Call::register_as_candidate { .. } | ||
| pallet_collator_selection::Call::leave_intent { .. }, | ||
) | RuntimeCall::XcmpQueue(..) | ||
) | RuntimeCall::XcmpQueue(..) | ||
| RuntimeCall::DmpQueue(..) | ||
| RuntimeCall::Proxy(..) | ||
| RuntimeCall::LiquidityPoolsGateway( |
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.
These changes to the other calls are unrelated to this PR and could introduce undesired behaviour given that we don't have tests in place to properly assess this. Not a blocker tho
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.
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.
Removing change request as it is addressed. Just so that I am not the blocking person anymore.
Same here. I took over this approach from @mikiquantum and wanted to change as little as possible apart from making it runtime agnostic. I suppose we don't need to run the |
Ah, that makes sense! :) And no worries, what is important is that we get this right 🏄♂️ |
a877a4e
to
0b64fa1
Compare
FYI, I cleaned up and checked all migrations against Algol, Altair, Catalyst and Centrifuge with |
pallet_rewards::migrations::new_instance::FundExistentialDeposit< | ||
crate::Runtime, | ||
pallet_rewards::Instance2, | ||
crate::NativeToken, | ||
crate::ExistentialDeposit, | ||
>, | ||
asset_registry::AssetRegistryMultilocationToXCMV3<crate::Runtime>, |
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: Replaces with runtime_common::migrations::asset_registry_xcmv3::Migration
|
||
pub type UpgradeCentrifuge1020 = ( | ||
asset_registry::CrossChainTransferabilityMigration, |
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: Not necessary due to hardcoded metadata from runtime_common::migrations::asset_registry_xcmv3::Migration
// FIXME: This migration fails to decode 4 entries against Altair | ||
// orml_tokens_migration::CurrencyIdRefactorMigration, |
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: Needs fixing before Altair upgrade!
// orml_tokens_migration::CurrencyIdRefactorMigration, | ||
pool_system::MigrateAUSDPools, |
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: Superseeded by runtime_common::migrations::nuke::Migration<crate::PoolSystem, crate::RocksDbWeight, 0>
pallet_rewards::migrations::new_instance::FundExistentialDeposit< | ||
crate::Runtime, | ||
pallet_rewards::Instance2, | ||
crate::NativeToken, | ||
crate::ExistentialDeposit, | ||
>, | ||
asset_registry::AssetRegistryMultilocationToXCMV3<crate::Runtime>, |
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: Replaced with runtime_common::migrations::asset_registry_xcmv3::Migration
// At minimum, bumps storage version from 0 to 1 | ||
runtime_common::migrations::nuke::Migration<crate::PoolSystem, crate::RocksDbWeight, 0>, | ||
// At minimum, bumps storage version from 0 to 1 | ||
runtime_common::migrations::nuke::Migration<crate::Investments, crate::RocksDbWeight, 0>, | ||
// Funds pallet_rewards::Instance2 account with existential deposit |
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: Storage is empty but this nuke still bumps StorageVersion
.
// runtime_common::migrations::nuke::Migration<crate::Loans, RocksDbWeight, 1>, | ||
// runtime_common::migrations::nuke::Migration<crate::InterestAccrual, RocksDbWeight, 0>, |
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: No nuke required on Algol
for Loans
and InterestAccrual
as these are already at the latest StorageVersion
// At minimum, bumps storage version from 0 to 1 | ||
runtime_common::migrations::nuke::Migration<crate::PoolSystem, crate::RocksDbWeight, 0>, | ||
// At minimum, bumps storage version from 0 to 1 | ||
runtime_common::migrations::nuke::Migration<crate::Investments, crate::RocksDbWeight, 0>, |
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: Storage is empty but this nuke still bumps StorageVersion
.
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.
Altair native wrong location. Otherwise fine.
runtime/altair/src/migrations.rs
Outdated
location: Some(VersionedMultiLocation::V3(MultiLocation::new( | ||
0, | ||
Junctions::X1(GeneralKey { | ||
length: 2, | ||
data: gk, | ||
}), |
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.
Absolut path needed
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.
None => { | ||
break count; | ||
} | ||
pub fn get_algol_assets() -> Vec<( |
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.
missing native.
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.
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.
LGTM! Thanks for the effort, that was quite a pice ^^
Indeed... Migrations always multiply the usual required time by orders of magnitude. At least we can be sure all migrations are now properly configured - 🤞 it works out in practice. |
* wip xcm v3 asset-registry migrations * fix: xcm v3 altair, centrifuge * feat: add defensive SafeCallFilter for transact * clean up asset addition for catalyst & centrifuge * add Altair + Algol migration * Add Liquidity Pools related pallets to centrifuge runtime (#1523) * centrifuge: Add liquidity pools pallets to runtime * centrifuge: Add LP OutboundQueue wrapper to runtime * taplo: Obey * runtime: Move OutboundQueue import * centrifuge: Allow both root and half of council as admin origins for LP pallets * centrifuge: Add Axelar Gateway precompile * centrifuge: Use correct HRMP encoder, update HRMP fee to 1 DOT, use XCM V3 imports * centrifuge: Update error message for InboundQueue * clippy: Fix warnings * centrifuge: Rename outbound queue, fix migration import for orml asset registry * Upgrade1020 LP follow-ups (#1525) * centrifuge: Enable LP gateway XCM origin converter * centrifuge: Update LP pallet config to use Quantity for BalanceRatio * runtime: Update XCM origin converter, use Quantity in LP message, add OriginRecovery to LP gateway * feat: safe XCM version migration + extend SafeCallFilter (#1526) * fix: allow gateway process msg for xcm * feat: add safe xcm version migration * fix: Allow process_msg for xcm transact * refactor: remove spec_version check * refactor: stricter SafeCallFilter * Upgrade1020 LP follow-ups (#1525) * centrifuge: Enable LP gateway XCM origin converter * centrifuge: Update LP pallet config to use Quantity for BalanceRatio * runtime: Update XCM origin converter, use Quantity in LP message, add OriginRecovery to LP gateway * fix: rm OrderBook safe call cause missing * fix: OrderBook missing in both runtimes * fix: clippy --------- Co-authored-by: Cosmin Damian <[email protected]> * Feat/upgrade1020 misc 1 (#1529) * fix: asset metadata xcm v3 migration cleanup other migrations (#1528) * fix: centrifuge asset migration * Apply suggestions from code review Co-authored-by: Frederik Gartenmeister <[email protected]> * chore: append cfg assets to catalyst * fix: asset registry migration improvements * feat: apply asset metadata migration to altair runtime * fix: cleanup altair/algol migrations * fix: less aggressive nuke pre-upgrade * fix: finalize migrations, add context * fix: clippy + cleanup imports * fix: native currency altair, algol * fix: Algol native currency name --------- Co-authored-by: Frederik Gartenmeister <[email protected]> * fmt * fixup * Upgrade1020 gateway changes (#1531) * gateway: Use BoundedVec instead of EVMChain enum * gateway: Add Sender type to LP gateway config * gateway: Rename EVM chain size const, emit event when submitting message, adjust gateway sender provider * Feat: upgrade1020 misc 2 (#1532) * feat: account ensuring origin * feat: bumb runtime version develpment * fix: allow council to control gatway on Altair based chains * fix: use EnsureSigned, make use of type and add admin * feat: overestimated weights for lp logic * fix: taplooo * fix: tests and comment * chore: bump weights for 1020 (#1533) * chore: update centrifuge, altair weights * feat: bump and improve dev weights * fix: transfer_allowlist weights * feat: normalize SafeCallFilter across runtimes * fix: native asset key in migration --------- Co-authored-by: William Freudenberger <[email protected]> Co-authored-by: Cosmin Damian <[email protected]> Co-authored-by: Frederik Gartenmeister <[email protected]> Co-authored-by: nuno <[email protected]>
LocationToAssetId
storage keys via theiter_keys().count()
API as all prod chains contain keys which cannot be decoded (XCMv1MultiLocations
)runtime-common
, we can reduce the code heavilytry-runtime
output for CentrifugeBoth the weight as well as PoV are low so that we don't need to be worried applying this migration