Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add migrations from pallet_asset to statemine, statemint and westmint (
Browse files Browse the repository at this point in the history
…#1742)

* statemine: migrate pallet assets to v1

* statemint and westmint: migrate pallet assets to v1

* remove items limit

* update dependencies and crate imports

* change substrate version to dependent PR

* revert to master

* revert changes to cargo toml

* fix weights to test compilation with companion substrate branch

* change destroy etrinsic in westmint to new extrinsics

* update lockfile for {"polkadot", "substrate"}

* rebase

Co-authored-by: parity-processbot <>
  • Loading branch information
tonyalaribe authored and EgorPopelyaev committed Nov 22, 2022
1 parent 46e95e2 commit 2e371ef
Show file tree
Hide file tree
Showing 12 changed files with 386 additions and 346 deletions.
522 changes: 254 additions & 268 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions parachains/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive
scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }

# Substrate
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-assets = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }

# Polkadot
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
Expand Down
8 changes: 6 additions & 2 deletions parachains/runtimes/assets/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ impl pallet_assets::Config for Runtime {
type Extra = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
}

parameter_types! {
Expand Down Expand Up @@ -360,7 +361,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::AssetOwner => matches!(
c,
RuntimeCall::Assets(pallet_assets::Call::create { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::start_destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy_accounts { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy_approvals { .. }) |
RuntimeCall::Assets(pallet_assets::Call::finish_destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::transfer_ownership { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_team { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_metadata { .. }) |
Expand Down Expand Up @@ -648,7 +652,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(),
pallet_assets::migration::v1::MigrateToV1<Runtime>,
>;

#[cfg(feature = "runtime-benchmarks")]
Expand Down
53 changes: 33 additions & 20 deletions parachains/runtimes/assets/statemine/src/weights/pallet_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,44 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:5002 w:5001)
// Storage: System Account (r:5000 w:5000)
// Storage: Assets Metadata (r:1 w:0)
// Storage: Assets Approvals (r:501 w:500)
/// The range of component `c` is `[0, 5000]`.
/// The range of component `s` is `[0, 5000]`.
/// The range of component `a` is `[0, 500]`.
fn destroy(c: u32, s: u32, a: u32, ) -> Weight {
Weight::from_ref_time(0 as u64)
// Standard Error: 103_000
.saturating_add(Weight::from_ref_time(17_019_000 as u64).saturating_mul(c as u64))
// Standard Error: 103_000
.saturating_add(Weight::from_ref_time(18_891_000 as u64).saturating_mul(s as u64))
// Standard Error: 1_038_000
.saturating_add(Weight::from_ref_time(32_265_000 as u64).saturating_mul(a as u64))
.saturating_add(T::DbWeight::get().reads(5 as u64))
fn start_destroy() -> Weight {
Weight::from_ref_time(31_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:1 w:0)
// Storage: System Account (r:20 w:20)
/// The range of component `c` is `[0, 1000]`.
fn destroy_accounts(c: u32, ) -> Weight {
Weight::from_ref_time(37_000_000 as u64)
// Standard Error: 19_301
.saturating_add(Weight::from_ref_time(25_467_908 as u64).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64)))
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(s as u64)))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(a as u64)))
.saturating_add(T::DbWeight::get().writes(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64)))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(s as u64)))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Approvals (r:1 w:0)
/// The range of component `a` is `[0, 1000]`.
fn destroy_approvals(a: u32, ) -> Weight {
Weight::from_ref_time(39_000_000 as u64)
// Standard Error: 14_298
.saturating_add(Weight::from_ref_time(27_632_144 as u64).saturating_mul(a as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(a as u64)))
.saturating_add(T::DbWeight::get().writes(1 as u64))
.saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(a as u64)))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Metadata (r:1 w:0)
fn finish_destroy() -> Weight {
Weight::from_ref_time(33_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:1 w:1)
fn mint() -> Weight {
Weight::from_ref_time(35_875_000 as u64)
Expand Down
2 changes: 1 addition & 1 deletion parachains/runtimes/assets/statemint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ frame-system = { git = "https://github.com/paritytech/substrate", default-featur
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "master" }
pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down
7 changes: 6 additions & 1 deletion parachains/runtimes/assets/statemint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ impl pallet_assets::Config for Runtime {
type Extra = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
}

parameter_types! {
Expand Down Expand Up @@ -376,7 +377,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::AssetOwner => matches!(
c,
RuntimeCall::Assets(pallet_assets::Call::create { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::start_destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy_accounts { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy_approvals { .. }) |
RuntimeCall::Assets(pallet_assets::Call::finish_destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::transfer_ownership { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_team { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_metadata { .. }) |
Expand Down Expand Up @@ -661,6 +665,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
pallet_assets::migration::v1::MigrateToV1<Runtime>,
>;

#[cfg(feature = "runtime-benchmarks")]
Expand Down
53 changes: 33 additions & 20 deletions parachains/runtimes/assets/statemint/src/weights/pallet_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,44 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:5002 w:5001)
// Storage: System Account (r:5000 w:5000)
// Storage: Assets Metadata (r:1 w:0)
// Storage: Assets Approvals (r:501 w:500)
/// The range of component `c` is `[0, 5000]`.
/// The range of component `s` is `[0, 5000]`.
/// The range of component `a` is `[0, 500]`.
fn destroy(c: u32, s: u32, a: u32, ) -> Weight {
Weight::from_ref_time(0 as u64)
// Standard Error: 96_000
.saturating_add(Weight::from_ref_time(15_834_000 as u64).saturating_mul(c as u64))
// Standard Error: 96_000
.saturating_add(Weight::from_ref_time(17_275_000 as u64).saturating_mul(s as u64))
// Standard Error: 966_000
.saturating_add(Weight::from_ref_time(35_635_000 as u64).saturating_mul(a as u64))
.saturating_add(T::DbWeight::get().reads(5 as u64))
fn start_destroy() -> Weight {
Weight::from_ref_time(31_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:1 w:0)
// Storage: System Account (r:20 w:20)
/// The range of component `c` is `[0, 1000]`.
fn destroy_accounts(c: u32, ) -> Weight {
Weight::from_ref_time(37_000_000 as u64)
// Standard Error: 19_301
.saturating_add(Weight::from_ref_time(25_467_908 as u64).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64)))
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(s as u64)))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(a as u64)))
.saturating_add(T::DbWeight::get().writes(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64)))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(s as u64)))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Approvals (r:1 w:0)
/// The range of component `a` is `[0, 1000]`.
fn destroy_approvals(a: u32, ) -> Weight {
Weight::from_ref_time(39_000_000 as u64)
// Standard Error: 14_298
.saturating_add(Weight::from_ref_time(27_632_144 as u64).saturating_mul(a as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(a as u64)))
.saturating_add(T::DbWeight::get().writes(1 as u64))
.saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(a as u64)))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Metadata (r:1 w:0)
fn finish_destroy() -> Weight {
Weight::from_ref_time(33_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:1 w:1)
fn mint() -> Weight {
Weight::from_ref_time(36_535_000 as u64)
Expand Down
8 changes: 6 additions & 2 deletions parachains/runtimes/assets/westmint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ impl pallet_assets::Config for Runtime {
type Extra = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
}

parameter_types! {
Expand Down Expand Up @@ -341,7 +342,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::AssetOwner => matches!(
c,
RuntimeCall::Assets(pallet_assets::Call::create { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::start_destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy_accounts { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy_approvals { .. }) |
RuntimeCall::Assets(pallet_assets::Call::finish_destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::transfer_ownership { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_team { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_metadata { .. }) |
Expand Down Expand Up @@ -621,7 +625,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(),
pallet_assets::migration::v1::MigrateToV1<Runtime>,
>;

#[cfg(feature = "runtime-benchmarks")]
Expand Down
53 changes: 33 additions & 20 deletions parachains/runtimes/assets/westmint/src/weights/pallet_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,44 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:5002 w:5001)
// Storage: System Account (r:5000 w:5000)
// Storage: Assets Metadata (r:1 w:0)
// Storage: Assets Approvals (r:501 w:500)
/// The range of component `c` is `[0, 5000]`.
/// The range of component `s` is `[0, 5000]`.
/// The range of component `a` is `[0, 500]`.
fn destroy(c: u32, s: u32, a: u32, ) -> Weight {
Weight::from_ref_time(0 as u64)
// Standard Error: 70_000
.saturating_add(Weight::from_ref_time(17_625_000 as u64).saturating_mul(c as u64))
// Standard Error: 70_000
.saturating_add(Weight::from_ref_time(18_034_000 as u64).saturating_mul(s as u64))
// Standard Error: 700_000
.saturating_add(Weight::from_ref_time(16_396_000 as u64).saturating_mul(a as u64))
.saturating_add(T::DbWeight::get().reads(5 as u64))
fn start_destroy() -> Weight {
Weight::from_ref_time(31_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:1 w:0)
// Storage: System Account (r:20 w:20)
/// The range of component `c` is `[0, 1000]`.
fn destroy_accounts(c: u32, ) -> Weight {
Weight::from_ref_time(37_000_000 as u64)
// Standard Error: 19_301
.saturating_add(Weight::from_ref_time(25_467_908 as u64).saturating_mul(c as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64)))
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(s as u64)))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(a as u64)))
.saturating_add(T::DbWeight::get().writes(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64)))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(s as u64)))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Approvals (r:1 w:0)
/// The range of component `a` is `[0, 1000]`.
fn destroy_approvals(a: u32, ) -> Weight {
Weight::from_ref_time(39_000_000 as u64)
// Standard Error: 14_298
.saturating_add(Weight::from_ref_time(27_632_144 as u64).saturating_mul(a as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(a as u64)))
.saturating_add(T::DbWeight::get().writes(1 as u64))
.saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(a as u64)))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Metadata (r:1 w:0)
fn finish_destroy() -> Weight {
Weight::from_ref_time(33_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Assets Asset (r:1 w:1)
// Storage: Assets Account (r:1 w:1)
fn mint() -> Weight {
Weight::from_ref_time(38_154_000 as u64)
Expand Down
2 changes: 1 addition & 1 deletion parachains/runtimes/starters/shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ scale-info = { version = "2.3.0", default-features = false, features = ["derive"
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down
1 change: 1 addition & 0 deletions parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ impl pallet_assets::Config for Runtime {
type Extra = ();
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions parachains/runtimes/testing/rococo-parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ impl pallet_assets::Config for Runtime {
type Extra = ();
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
}

impl pallet_aura::Config for Runtime {
Expand Down

0 comments on commit 2e371ef

Please sign in to comment.