......@@ -4,8 +4,10 @@
"chainType": "Live",
"bootNodes": [
"/dns/westend-people-collator-node-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWDcLjDLTu9fNhmas9DTWtqdv8eUbFMWQzVwvXRK7QcjHD",
"/dns/westend-people-collator-node-0.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWDcLjDLTu9fNhmas9DTWtqdv8eUbFMWQzVwvXRK7QcjHD",
"/dns/westend-people-collator-node-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWM56JbKWAXsDyWh313z73aKYVMp1Hj2nSnAKY3q6MnoC9",
"/dns/westend-people-collator-node-0.parity-testnet.parity.io/tcp/30335/ws/p2p/12D3KooWDcLjDLTu9fNhmas9DTWtqdv8eUbFMWQzVwvXRK7QcjHD",
"/dns/westend-people-collator-node-1.parity-testnet.parity.io/tcp/30335/ws/p2p/12D3KooWM56JbKWAXsDyWh313z73aKYVMp1Hj2nSnAKY3q6MnoC9",
"/dns/westend-people-collator-node-0.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWDcLjDLTu9fNhmas9DTWtqdv8eUbFMWQzVwvXRK7QcjHD",
"/dns/westend-people-collator-node-1.parity-testnet.parity.io/tcp/443/wss/p2p/12D3KooWM56JbKWAXsDyWh313z73aKYVMp1Hj2nSnAKY3q6MnoC9",
"/dns/identity-westend.bootnodes.polkadotters.com/tcp/30532/p2p/12D3KooWKr9San6KTM7REJ95cBaDoiciGcWnW8TTftEJgxGF5Ehb",
"/dns/identity-westend.bootnodes.polkadotters.com/tcp/30534/wss/p2p/12D3KooWKr9San6KTM7REJ95cBaDoiciGcWnW8TTftEJgxGF5Ehb",
......@@ -39,6 +39,8 @@ decl_test_relay_chains! {
Hrmp: rococo_runtime::Hrmp,
Identity: rococo_runtime::Identity,
IdentityMigrator: rococo_runtime::IdentityMigrator,
Treasury: rococo_runtime::Treasury,
AssetRate: rococo_runtime::AssetRate,
}
},
}
......
......@@ -21,15 +21,20 @@ pallet-balances = { path = "../../../../../../../substrate/frame/balances", defa
pallet-assets = { path = "../../../../../../../substrate/frame/assets", default-features = false }
pallet-asset-conversion = { path = "../../../../../../../substrate/frame/asset-conversion", default-features = false }
pallet-message-queue = { path = "../../../../../../../substrate/frame/message-queue", default-features = false }
pallet-treasury = { path = "../../../../../../../substrate/frame/treasury", default-features = false }
pallet-utility = { path = "../../../../../../../substrate/frame/utility", default-features = false }
# Polkadot
xcm = { package = "staging-xcm", path = "../../../../../../../polkadot/xcm", default-features = false }
pallet-xcm = { path = "../../../../../../../polkadot/xcm/pallet-xcm", default-features = false }
xcm-executor = { package = "staging-xcm-executor", path = "../../../../../../../polkadot/xcm/xcm-executor", default-features = false }
rococo-runtime = { path = "../../../../../../../polkadot/runtime/rococo" }
polkadot-runtime-common = { path = "../../../../../../../polkadot/runtime/common" }
rococo-runtime-constants = { path = "../../../../../../../polkadot/runtime/rococo/constants" }
# Cumulus
asset-test-utils = { path = "../../../../../runtimes/assets/test-utils" }
cumulus-pallet-parachain-system = { path = "../../../../../../pallets/parachain-system", default-features = false }
parachains-common = { path = "../../../../../common" }
asset-hub-rococo-runtime = { path = "../../../../../runtimes/assets/asset-hub-rococo" }
penpal-runtime = { path = "../../../../../runtimes/testing/penpal" }
......
......@@ -19,3 +19,4 @@ mod send;
mod set_xcm_versions;
mod swap;
mod teleport;
mod treasury;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::imports::*;
use emulated_integration_tests_common::accounts::{ALICE, BOB};
use frame_support::{
dispatch::RawOrigin,
sp_runtime::traits::Dispatchable,
traits::{
fungible::Inspect,
fungibles::{Create, Inspect as FungiblesInspect, Mutate},
},
};
use parachains_common::AccountId;
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use rococo_runtime::OriginCaller;
use rococo_runtime_constants::currency::GRAND;
use xcm_executor::traits::ConvertLocation;
// Fund Treasury account on Asset Hub from Treasury account on Relay Chain with ROCs.
#[test]
fn spend_roc_on_asset_hub() {
// initial treasury balance on Asset Hub in ROCs.
let treasury_balance = 9_000 * GRAND;
// the balance spend on Asset Hub.
let treasury_spend_balance = 1_000 * GRAND;
let init_alice_balance = AssetHubRococo::execute_with(|| {
<<AssetHubRococo as AssetHubRococoPallet>::Balances as Inspect<_>>::balance(
&AssetHubRococo::account_id_of(ALICE),
)
});
Rococo::execute_with(|| {
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;
type RuntimeCall = <Rococo as Chain>::RuntimeCall;
type Runtime = <Rococo as Chain>::Runtime;
type Balances = <Rococo as RococoPallet>::Balances;
type Treasury = <Rococo as RococoPallet>::Treasury;
// Fund Treasury account on Asset Hub with ROCs.
let root = <Rococo as Chain>::RuntimeOrigin::root();
let treasury_account = Treasury::account_id();
// Mint assets to Treasury account on Relay Chain.
assert_ok!(Balances::force_set_balance(
root.clone(),
treasury_account.clone().into(),
treasury_balance * 2,
));
let native_asset = Location::here();
let asset_hub_location: Location = [Parachain(1000)].into();
let treasury_location: Location = (Parent, PalletInstance(18)).into();
let teleport_call = RuntimeCall::Utility(pallet_utility::Call::<Runtime>::dispatch_as {
as_origin: bx!(OriginCaller::system(RawOrigin::Signed(treasury_account))),
call: bx!(RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::teleport_assets {
dest: bx!(VersionedLocation::V4(asset_hub_location.clone())),
beneficiary: bx!(VersionedLocation::V4(treasury_location)),
assets: bx!(VersionedAssets::V4(
Asset { id: native_asset.clone().into(), fun: treasury_balance.into() }.into()
)),
fee_asset_item: 0,
})),
});
// Dispatched from Root to `despatch_as` `Signed(treasury_account)`.
assert_ok!(teleport_call.dispatch(root));
assert_expected_events!(
Rococo,
vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {},
]
);
});
Rococo::execute_with(|| {
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;
type RuntimeCall = <Rococo as Chain>::RuntimeCall;
type RuntimeOrigin = <Rococo as Chain>::RuntimeOrigin;
type Runtime = <Rococo as Chain>::Runtime;
type Treasury = <Rococo as RococoPallet>::Treasury;
// Fund Alice account from Rococo Treasury account on Asset Hub.
let treasury_origin: RuntimeOrigin =
rococo_runtime::governance::pallet_custom_origins::Origin::Treasurer.into();
let alice_location: Location =
[Junction::AccountId32 { network: None, id: Rococo::account_id_of(ALICE).into() }]
.into();
let asset_hub_location: Location = [Parachain(1000)].into();
let native_asset = Location::parent();
let treasury_spend_call = RuntimeCall::Treasury(pallet_treasury::Call::<Runtime>::spend {
asset_kind: bx!(VersionedLocatableAsset::V4 {
location: asset_hub_location.clone(),
asset_id: native_asset.into(),
}),
amount: treasury_spend_balance,
beneficiary: bx!(VersionedLocation::V4(alice_location)),
valid_from: None,
});
assert_ok!(treasury_spend_call.dispatch(treasury_origin));
// Claim the spend.
let bob_signed = RuntimeOrigin::signed(Rococo::account_id_of(BOB));
assert_ok!(Treasury::payout(bob_signed.clone(), 0));
assert_expected_events!(
Rococo,
vec![
RuntimeEvent::Treasury(pallet_treasury::Event::AssetSpendApproved { .. }) => {},
RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. }) => {},
]
);
});
AssetHubRococo::execute_with(|| {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
type Balances = <AssetHubRococo as AssetHubRococoPallet>::Balances;
// Ensure that the funds deposited to Alice account.
let alice_account = AssetHubRococo::account_id_of(ALICE);
assert_eq!(
<Balances as Inspect<_>>::balance(&alice_account),
treasury_spend_balance + init_alice_balance
);
// Assert events triggered by xcm pay program:
// 1. treasury asset transferred to spend beneficiary;
// 2. response to Relay Chain Treasury pallet instance sent back;
// 3. XCM program completed;
assert_expected_events!(
AssetHubRococo,
vec![
RuntimeEvent::Balances(pallet_balances::Event::Transfer { .. }) => {},
RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. }) => {},
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true ,.. }) => {},
]
);
});
}
#[test]
fn create_and_claim_treasury_spend_in_usdt() {
const ASSET_ID: u32 = 1984;
const SPEND_AMOUNT: u128 = 1_000_000;
// treasury location from a sibling parachain.
let treasury_location: Location = Location::new(1, PalletInstance(18));
// treasury account on a sibling parachain.
let treasury_account =
asset_hub_rococo_runtime::xcm_config::LocationToAccountId::convert_location(
&treasury_location,
)
.unwrap();
let asset_hub_location =
v3::Location::new(0, v3::Junction::Parachain(AssetHubRococo::para_id().into()));
let root = <Rococo as Chain>::RuntimeOrigin::root();
// asset kind to be spend from the treasury.
let asset_kind = VersionedLocatableAsset::V3 {
location: asset_hub_location,
asset_id: v3::AssetId::Concrete(
(v3::Junction::PalletInstance(50), v3::Junction::GeneralIndex(ASSET_ID.into())).into(),
),
};
// treasury spend beneficiary.
let alice: AccountId = Rococo::account_id_of(ALICE);
let bob: AccountId = Rococo::account_id_of(BOB);
let bob_signed = <Rococo as Chain>::RuntimeOrigin::signed(bob.clone());
AssetHubRococo::execute_with(|| {
type Assets = <AssetHubRococo as AssetHubRococoPallet>::Assets;
// create an asset class and mint some assets to the treasury account.
assert_ok!(<Assets as Create<_>>::create(
ASSET_ID,
treasury_account.clone(),
true,
SPEND_AMOUNT / 2
));
assert_ok!(<Assets as Mutate<_>>::mint_into(ASSET_ID, &treasury_account, SPEND_AMOUNT * 4));
// beneficiary has zero balance.
assert_eq!(<Assets as FungiblesInspect<_>>::balance(ASSET_ID, &alice,), 0u128,);
});
Rococo::execute_with(|| {
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;
type Treasury = <Rococo as RococoPallet>::Treasury;
type AssetRate = <Rococo as RococoPallet>::AssetRate;
// create a conversion rate from `asset_kind` to the native currency.
assert_ok!(AssetRate::create(root.clone(), Box::new(asset_kind.clone()), 2.into()));
// create and approve a treasury spend.
assert_ok!(Treasury::spend(
root,
Box::new(asset_kind),
SPEND_AMOUNT,
Box::new(Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into()),
None,
));
// claim the spend.
assert_ok!(Treasury::payout(bob_signed.clone(), 0));
assert_expected_events!(
Rococo,
vec![
RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. }) => {},
]
);
});
AssetHubRococo::execute_with(|| {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
type Assets = <AssetHubRococo as AssetHubRococoPallet>::Assets;
// assert events triggered by xcm pay program
// 1. treasury asset transferred to spend beneficiary
// 2. response to Relay Chain treasury pallet instance sent back
// 3. XCM program completed
assert_expected_events!(
AssetHubRococo,
vec![
RuntimeEvent::Assets(pallet_assets::Event::Transferred { asset_id: id, from, to, amount }) => {
id: id == &ASSET_ID,
from: from == &treasury_account,
to: to == &alice,
amount: amount == &SPEND_AMOUNT,
},
RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. }) => {},
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true ,.. }) => {},
]
);
// beneficiary received the assets from the treasury.
assert_eq!(<Assets as FungiblesInspect<_>>::balance(ASSET_ID, &alice,), SPEND_AMOUNT,);
});
Rococo::execute_with(|| {
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;
type Treasury = <Rococo as RococoPallet>::Treasury;
// check the payment status to ensure the response from the AssetHub was received.
assert_ok!(Treasury::check_status(bob_signed, 0));
assert_expected_events!(
Rococo,
vec![
RuntimeEvent::Treasury(pallet_treasury::Event::SpendProcessed { .. }) => {},
]
);
});
}
[package]
name = "collectives-westend-integration-tests"
version = "1.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
description = "Collectives Westend runtime integration tests with xcm-emulator"
publish = false
[lints]
workspace = true
[dependencies]
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }
assert_matches = "1.5.0"
# Substrate
sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false }
frame-support = { path = "../../../../../../../substrate/frame/support", default-features = false }
pallet-balances = { path = "../../../../../../../substrate/frame/balances", default-features = false }
pallet-asset-rate = { path = "../../../../../../../substrate/frame/asset-rate", default-features = false }
pallet-assets = { path = "../../../../../../../substrate/frame/assets", default-features = false }
pallet-treasury = { path = "../../../../../../../substrate/frame/treasury", default-features = false }
pallet-message-queue = { path = "../../../../../../../substrate/frame/message-queue", default-features = false }
pallet-utility = { path = "../../../../../../../substrate/frame/utility", default-features = false }
# Polkadot
polkadot-runtime-common = { path = "../../../../../../../polkadot/runtime/common" }
xcm = { package = "staging-xcm", path = "../../../../../../../polkadot/xcm", default-features = false }
xcm-executor = { package = "staging-xcm-executor", path = "../../../../../../../polkadot/xcm/xcm-executor", default-features = false }
pallet-xcm = { path = "../../../../../../../polkadot/xcm/pallet-xcm", default-features = false }
westend-runtime = { path = "../../../../../../../polkadot/runtime/westend" }
westend-runtime-constants = { path = "../../../../../../../polkadot/runtime/westend/constants" }
# Cumulus
parachains-common = { path = "../../../../../../parachains/common" }
testnet-parachains-constants = { path = "../../../../../runtimes/constants", features = ["westend"] }
asset-hub-westend-runtime = { path = "../../../../../runtimes/assets/asset-hub-westend" }
collectives-westend-runtime = { path = "../../../../../runtimes/collectives/collectives-westend" }
cumulus-pallet-xcmp-queue = { default-features = false, path = "../../../../../../pallets/xcmp-queue" }
cumulus-pallet-parachain-system = { default-features = false, path = "../../../../../../pallets/parachain-system" }
emulated-integration-tests-common = { path = "../../../common", default-features = false }
westend-system-emulated-network = { path = "../../../networks/westend-system" }
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pub use xcm::{prelude::*, v3};
pub use emulated_integration_tests_common::xcm_emulator::{
assert_expected_events, bx, Chain, RelayChain as Relay, TestExt,
};
pub use westend_system_emulated_network::{
asset_hub_westend_emulated_chain::AssetHubWestendParaPallet as AssetHubWestendPallet,
collectives_westend_emulated_chain::CollectivesWestendParaPallet as CollectivesWestendPallet,
westend_emulated_chain::WestendRelayPallet as WestendPallet,
AssetHubWestendPara as AssetHubWestend, CollectivesWestendPara as CollectivesWestend,
WestendRelay as Westend,
};
#[cfg(test)]
mod tests;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use asset_hub_westend_runtime::xcm_config::LocationToAccountId as AssetHubLocationToAccountId;
use emulated_integration_tests_common::accounts::ALICE;
use frame_support::{
assert_ok, dispatch::RawOrigin, instances::Instance1, sp_runtime::traits::Dispatchable,
traits::fungible::Inspect,
};
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use westend_runtime::OriginCaller;
use westend_runtime_constants::currency::UNITS;
use xcm_executor::traits::ConvertLocation;
// Fund Fellowship Treasury from Westend Treasury and spend from Fellowship Treasury.
#[test]
fn fellowship_treasury_spend() {
// initial treasury balance on Asset Hub in WNDs.
let treasury_balance = 20_000_000 * UNITS;
// target fellowship balance on Asset Hub in WNDs.
let fellowship_treasury_balance = 1_000_000 * UNITS;
// fellowship first spend balance in WNDs.
let fellowship_spend_balance = 10_000 * UNITS;
let init_alice_balance = AssetHubWestend::execute_with(|| {
<<AssetHubWestend as AssetHubWestendPallet>::Balances as Inspect<_>>::balance(
&AssetHubWestend::account_id_of(ALICE),
)
});
Westend::execute_with(|| {
type RuntimeEvent = <Westend as Chain>::RuntimeEvent;
type RuntimeCall = <Westend as Chain>::RuntimeCall;
type Runtime = <Westend as Chain>::Runtime;
type Balances = <Westend as WestendPallet>::Balances;
type Treasury = <Westend as WestendPallet>::Treasury;
// Fund Treasury account on Asset Hub with WNDs.
let root = <Westend as Chain>::RuntimeOrigin::root();
let treasury_account = Treasury::account_id();
// Mist assets to Treasury account on Relay Chain.
assert_ok!(Balances::force_set_balance(
root.clone(),
treasury_account.clone().into(),
treasury_balance * 2,
));
let native_asset = Location::here();
let asset_hub_location: Location = [Parachain(1000)].into();
let treasury_location: Location = (Parent, PalletInstance(37)).into();
let teleport_call = RuntimeCall::Utility(pallet_utility::Call::<Runtime>::dispatch_as {
as_origin: bx!(OriginCaller::system(RawOrigin::Signed(treasury_account))),
call: bx!(RuntimeCall::XcmPallet(pallet_xcm::Call::<Runtime>::teleport_assets {
dest: bx!(VersionedLocation::V4(asset_hub_location.clone())),
beneficiary: bx!(VersionedLocation::V4(treasury_location)),
assets: bx!(VersionedAssets::V4(
Asset { id: native_asset.clone().into(), fun: treasury_balance.into() }.into()
)),
fee_asset_item: 0,
})),
});
// Dispatched from Root to `dispatch_as` `Signed(treasury_account)`.
assert_ok!(teleport_call.dispatch(root));
assert_expected_events!(
Westend,
vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {},
]
);
});
Westend::execute_with(|| {
type RuntimeEvent = <Westend as Chain>::RuntimeEvent;
type RuntimeCall = <Westend as Chain>::RuntimeCall;
type RuntimeOrigin = <Westend as Chain>::RuntimeOrigin;
type Runtime = <Westend as Chain>::Runtime;
type Treasury = <Westend as WestendPallet>::Treasury;
// Fund Fellowship Treasury from Westend Treasury.
let treasury_origin: RuntimeOrigin =
westend_runtime::governance::pallet_custom_origins::Origin::Treasurer.into();
let fellowship_treasury_location: Location =
Location::new(1, [Parachain(1001), PalletInstance(65)]);
let asset_hub_location: Location = [Parachain(1000)].into();
let native_asset = Location::parent();
let treasury_spend_call = RuntimeCall::Treasury(pallet_treasury::Call::<Runtime>::spend {
asset_kind: bx!(VersionedLocatableAsset::V4 {
location: asset_hub_location.clone(),
asset_id: native_asset.into(),
}),
amount: fellowship_treasury_balance,
beneficiary: bx!(VersionedLocation::V4(fellowship_treasury_location)),
valid_from: None,
});
assert_ok!(treasury_spend_call.dispatch(treasury_origin));
// Claim the spend.
let alice_signed = RuntimeOrigin::signed(Westend::account_id_of(ALICE));
assert_ok!(Treasury::payout(alice_signed.clone(), 0));
assert_expected_events!(
Westend,
vec![
RuntimeEvent::Treasury(pallet_treasury::Event::AssetSpendApproved { .. }) => {},
RuntimeEvent::Treasury(pallet_treasury::Event::Paid { .. }) => {},
]
);
});
AssetHubWestend::execute_with(|| {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
type Balances = <AssetHubWestend as AssetHubWestendPallet>::Balances;
// Ensure that the funds deposited to the Fellowship Treasury account.
let fellowship_treasury_location: Location =
Location::new(1, [Parachain(1001), PalletInstance(65)]);
let fellowship_treasury_account =
AssetHubLocationToAccountId::convert_location(&fellowship_treasury_location).unwrap();
assert_eq!(
<Balances as Inspect<_>>::balance(&fellowship_treasury_account),
fellowship_treasury_balance
);
// Assert events triggered by xcm pay program:
// 1. treasury asset transferred to spend beneficiary;
// 2. response to Relay Chain Treasury pallet instance sent back;
// 3. XCM program completed;
assert_expected_events!(
AssetHubWestend,
vec![
RuntimeEvent::Balances(pallet_balances::Event::Transfer { .. }) => {},
RuntimeEvent::ParachainSystem(cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. }) => {},
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true ,.. }) => {},
]
);
});
CollectivesWestend::execute_with(|| {
type RuntimeEvent = <CollectivesWestend as Chain>::RuntimeEvent;
type RuntimeCall = <CollectivesWestend as Chain>::RuntimeCall;
type RuntimeOrigin = <CollectivesWestend as Chain>::RuntimeOrigin;
type Runtime = <CollectivesWestend as Chain>::Runtime;
type FellowshipTreasury =
<CollectivesWestend as CollectivesWestendPallet>::FellowshipTreasury;
// Fund Alice account from Fellowship Treasury.
let fellows_origin: RuntimeOrigin =
collectives_westend_runtime::fellowship::pallet_fellowship_origins::Origin::Fellows
.into();
let asset_hub_location: Location = (Parent, Parachain(1000)).into();
let native_asset = Location::parent();
let alice_location: Location = [Junction::AccountId32 {
network: None,
id: CollectivesWestend::account_id_of(ALICE).into(),
}]
.into();
let fellowship_treasury_spend_call =
RuntimeCall::FellowshipTreasury(pallet_treasury::Call::<Runtime, Instance1>::spend {
asset_kind: bx!(VersionedLocatableAsset::V4 {
location: asset_hub_location,
asset_id: native_asset.into(),
}),
amount: fellowship_spend_balance,
beneficiary: bx!(VersionedLocation::V4(alice_location)),
valid_from: None,
});
assert_ok!(fellowship_treasury_spend_call.dispatch(fellows_origin));
// Claim the spend.
let alice_signed = RuntimeOrigin::signed(CollectivesWestend::account_id_of(ALICE));
assert_ok!(FellowshipTreasury::payout(alice_signed.clone(), 0));
assert_expected_events!(
CollectivesWestend,
vec![
RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::AssetSpendApproved { .. }) => {},
RuntimeEvent::FellowshipTreasury(pallet_treasury::Event::Paid { .. }) => {},
]
);
});
AssetHubWestend::execute_with(|| {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
type Balances = <AssetHubWestend as AssetHubWestendPallet>::Balances;
// Ensure that the funds deposited to Alice account.
let alice_account = AssetHubWestend::account_id_of(ALICE);
assert_eq!(
<Balances as Inspect<_>>::balance(&alice_account),
fellowship_spend_balance + init_alice_balance
);
// Assert events triggered by xcm pay program:
// 1. treasury asset transferred to spend beneficiary;
// 2. response to Relay Chain Treasury pallet instance sent back;
// 3. XCM program completed;
assert_expected_events!(
AssetHubWestend,
vec![
RuntimeEvent::Balances(pallet_balances::Event::Transfer { .. }) => {},
RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {},
RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true ,.. }) => {},
]
);
});
}
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
mod fellowship_treasury;
......@@ -25,6 +25,7 @@ frame-system-rpc-runtime-api = { path = "../../../../../substrate/frame/system/r
frame-try-runtime = { path = "../../../../../substrate/frame/try-runtime", default-features = false, optional = true }
pallet-asset-conversion-tx-payment = { path = "../../../../../substrate/frame/transaction-payment/asset-conversion-tx-payment", default-features = false }
pallet-assets = { path = "../../../../../substrate/frame/assets", default-features = false }
pallet-asset-conversion-ops = { path = "../../../../../substrate/frame/asset-conversion/ops", default-features = false }
pallet-asset-conversion = { path = "../../../../../substrate/frame/asset-conversion", default-features = false }
pallet-aura = { path = "../../../../../substrate/frame/aura", default-features = false }
pallet-authorship = { path = "../../../../../substrate/frame/authorship", default-features = false }
......@@ -36,7 +37,7 @@ pallet-nfts = { path = "../../../../../substrate/frame/nfts", default-features =
pallet-nfts-runtime-api = { path = "../../../../../substrate/frame/nfts/runtime-api", default-features = false }
pallet-proxy = { path = "../../../../../substrate/frame/proxy", default-features = false }
pallet-session = { path = "../../../../../substrate/frame/session", default-features = false }
pallet-state-trie-migration = { path = "../../../../../substrate/frame/state-trie-migration", default-features = false, optional = true }
pallet-state-trie-migration = { path = "../../../../../substrate/frame/state-trie-migration", default-features = false }
pallet-timestamp = { path = "../../../../../substrate/frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../../../substrate/frame/transaction-payment", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../../../substrate/frame/transaction-payment/rpc/runtime-api", default-features = false }
......@@ -101,14 +102,6 @@ substrate-wasm-builder = { path = "../../../../../substrate/utils/wasm-builder",
[features]
default = ["std"]
# When enabled the `state_version` is set to `1`.
# This means that the chain will start using the new state format. The migration is lazy, so
# it requires to write a storage value to use the new state format. To migrate all the other
# storage values that aren't touched the state migration pallet is added as well.
# This pallet will migrate the entire state, controlled through some account.
#
# This feature should be removed when the main-net will be migrated.
state-trie-version-1 = ["pallet-state-trie-migration"]
runtime-benchmarks = [
"assets-common/runtime-benchmarks",
"cumulus-pallet-parachain-system/runtime-benchmarks",
......@@ -120,6 +113,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-asset-conversion-ops/runtime-benchmarks",
"pallet-asset-conversion/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
......@@ -153,6 +147,7 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-asset-conversion-ops/try-runtime",
"pallet-asset-conversion-tx-payment/try-runtime",
"pallet-asset-conversion/try-runtime",
"pallet-assets/try-runtime",
......@@ -201,6 +196,7 @@ std = [
"frame-system/std",
"frame-try-runtime?/std",
"log/std",
"pallet-asset-conversion-ops/std",
"pallet-asset-conversion-tx-payment/std",
"pallet-asset-conversion/std",
"pallet-assets/std",
......
......@@ -107,7 +107,6 @@ impl_opaque_keys! {
}
}
#[cfg(feature = "state-trie-version-1")]
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
......@@ -120,19 +119,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
state_version: 1,
};
#[cfg(not(feature = "state-trie-version-1"))]
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 1_010_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 14,
state_version: 0,
};
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
......@@ -333,6 +319,11 @@ pub type NativeAndAssets = fungible::UnionOf<
AccountId,
>;
pub type PoolIdToAccountId = pallet_asset_conversion::AccountIdConverter<
AssetConversionPalletId,
(xcm::v3::Location, xcm::v3::Location),
>;
impl pallet_asset_conversion::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
......@@ -340,8 +331,12 @@ impl pallet_asset_conversion::Config for Runtime {
type AssetKind = xcm::v3::Location;
type Assets = NativeAndAssets;
type PoolId = (Self::AssetKind, Self::AssetKind);
type PoolLocator =
pallet_asset_conversion::WithFirstAsset<TokenLocationV3, AccountId, Self::AssetKind>;
type PoolLocator = pallet_asset_conversion::WithFirstAsset<
TokenLocationV3,
AccountId,
Self::AssetKind,
PoolIdToAccountId,
>;
type PoolAssetId = u32;
type PoolAssets = PoolAssets;
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
......@@ -362,6 +357,18 @@ impl pallet_asset_conversion::Config for Runtime {
>;
}
impl pallet_asset_conversion_ops::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<
<Runtime as pallet_asset_conversion::Config>::PoolId,
>;
type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
type DepositAsset = Balances;
type WeightInfo = weights::pallet_asset_conversion_ops::WeightInfo<Runtime>;
}
parameter_types! {
// we just reuse the same deposits
pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
......@@ -932,8 +939,11 @@ construct_runtime!(
PoolAssets: pallet_assets::<Instance3> = 55,
AssetConversion: pallet_asset_conversion = 56,
#[cfg(feature = "state-trie-version-1")]
StateTrieMigration: pallet_state_trie_migration = 70,
// TODO: the pallet instance should be removed once all pools have migrated
// to the new account IDs.
AssetConversionMigration: pallet_asset_conversion_ops = 200,
}
);
......@@ -961,6 +971,7 @@ pub type SignedExtra = (
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// Migrations to apply on runtime upgrade.
#[allow(deprecated)]
pub type Migrations = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
InitStorageVersions,
......@@ -1054,6 +1065,7 @@ mod benches {
[cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_xcm_bridge_hub_router, ToWestend]
[pallet_asset_conversion_ops, AssetConversionMigration]
// XCM
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
// NOTE: Make sure you point to the individual modules below.
......@@ -1668,7 +1680,6 @@ cumulus_pallet_parachain_system::register_validate_block! {
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
}
#[cfg(feature = "state-trie-version-1")]
parameter_types! {
// The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high)
pub const MigrationSignedDepositPerItem: Balance = CENTS;
......@@ -1676,7 +1687,6 @@ parameter_types! {
pub const MigrationMaxKeyLen: u32 = 512;
}
#[cfg(feature = "state-trie-version-1")]
impl pallet_state_trie_migration::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
......@@ -1694,13 +1704,11 @@ impl pallet_state_trie_migration::Config for Runtime {
type MaxKeyLen = MigrationMaxKeyLen;
}
#[cfg(feature = "state-trie-version-1")]
frame_support::ord_parameter_types! {
pub const MigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
pub const RootMigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
}
#[cfg(feature = "state-trie-version-1")]
#[test]
fn ensure_key_ss58() {
use frame_support::traits::SortedMembers;
......
......@@ -20,6 +20,7 @@ pub mod cumulus_pallet_xcmp_queue;
pub mod extrinsic_weights;
pub mod frame_system;
pub mod pallet_asset_conversion;
pub mod pallet_asset_conversion_ops;
pub mod pallet_assets_foreign;
pub mod pallet_assets_local;
pub mod pallet_assets_pool;
......
......@@ -154,4 +154,26 @@ impl<T: frame_system::Config> pallet_asset_conversion::WeightInfo for WeightInfo
.saturating_add(T::DbWeight::get().writes(4))
.saturating_add(Weight::from_parts(0, 393).saturating_mul(n.into()))
}
/// Storage: `AssetConversion::Pools` (r:1 w:0)
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
/// Storage: `Assets::Asset` (r:2 w:2)
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `Assets::Account` (r:2 w:2)
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 3]`.
fn touch(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1571`
// Estimated: `6360`
// Minimum execution time: 381_000_000 picoseconds.
Weight::from_parts(398_540_909, 6360)
// Standard Error: 1_330_283
.saturating_add(Weight::from_parts(209_463_636, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into())))
}
}
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_asset_conversion_ops`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `cob`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-rococo-dev")`, DB CACHE: 1024
// Executed Command:
// ./target/debug/polkadot-parachain
// benchmark
// pallet
// --chain=asset-hub-rococo-dev
// --steps=10
// --repeat=2
// --pallet=pallet-asset-conversion-ops
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_asset_conversion_ops`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_asset_conversion_ops::WeightInfo for WeightInfo<T> {
/// Storage: `AssetConversion::Pools` (r:1 w:0)
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(1224), added: 3699, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:2 w:2)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:2 w:2)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
fn migrate_to_new_account() -> Weight {
// Proof Size summary in bytes:
// Measured: `1105`
// Estimated: `7404`
// Minimum execution time: 2_323_000_000 picoseconds.
Weight::from_parts(2_404_000_000, 0)
.saturating_add(Weight::from_parts(0, 7404))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(8))
}
}
......@@ -23,6 +23,7 @@ frame-system = { path = "../../../../../substrate/frame/system", default-feature
frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true }
frame-system-rpc-runtime-api = { path = "../../../../../substrate/frame/system/rpc/runtime-api", default-features = false }
frame-try-runtime = { path = "../../../../../substrate/frame/try-runtime", default-features = false, optional = true }
pallet-asset-conversion-ops = { path = "../../../../../substrate/frame/asset-conversion/ops", default-features = false }
pallet-asset-conversion-tx-payment = { path = "../../../../../substrate/frame/transaction-payment/asset-conversion-tx-payment", default-features = false }
pallet-assets = { path = "../../../../../substrate/frame/assets", default-features = false }
pallet-asset-conversion = { path = "../../../../../substrate/frame/asset-conversion", default-features = false }
......@@ -111,6 +112,7 @@ runtime-benchmarks = [
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"pallet-asset-conversion-ops/runtime-benchmarks",
"pallet-asset-conversion/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
......@@ -142,6 +144,7 @@ try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-asset-conversion-ops/try-runtime",
"pallet-asset-conversion-tx-payment/try-runtime",
"pallet-asset-conversion/try-runtime",
"pallet-assets/try-runtime",
......@@ -189,6 +192,7 @@ std = [
"frame-system/std",
"frame-try-runtime?/std",
"log/std",
"pallet-asset-conversion-ops/std",
"pallet-asset-conversion-tx-payment/std",
"pallet-asset-conversion/std",
"pallet-assets/std",
......
......@@ -315,6 +315,11 @@ pub type NativeAndAssets = fungible::UnionOf<
AccountId,
>;
pub type PoolIdToAccountId = pallet_asset_conversion::AccountIdConverter<
AssetConversionPalletId,
(xcm::v3::Location, xcm::v3::Location),
>;
impl pallet_asset_conversion::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
......@@ -322,8 +327,12 @@ impl pallet_asset_conversion::Config for Runtime {
type AssetKind = xcm::v3::Location;
type Assets = NativeAndAssets;
type PoolId = (Self::AssetKind, Self::AssetKind);
type PoolLocator =
pallet_asset_conversion::WithFirstAsset<WestendLocationV3, AccountId, Self::AssetKind>;
type PoolLocator = pallet_asset_conversion::WithFirstAsset<
WestendLocationV3,
AccountId,
Self::AssetKind,
PoolIdToAccountId,
>;
type PoolAssetId = u32;
type PoolAssets = PoolAssets;
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
......@@ -344,6 +353,18 @@ impl pallet_asset_conversion::Config for Runtime {
>;
}
impl pallet_asset_conversion_ops::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PriorAccountIdConverter = pallet_asset_conversion::AccountIdConverterNoSeed<
<Runtime as pallet_asset_conversion::Config>::PoolId,
>;
type AssetsRefund = <Runtime as pallet_asset_conversion::Config>::Assets;
type PoolAssetsRefund = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
type PoolAssetsTeam = <Runtime as pallet_asset_conversion::Config>::PoolAssets;
type DepositAsset = Balances;
type WeightInfo = weights::pallet_asset_conversion_ops::WeightInfo<Runtime>;
}
parameter_types! {
// we just reuse the same deposits
pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
......@@ -906,6 +927,10 @@ construct_runtime!(
NftFractionalization: pallet_nft_fractionalization = 54,
PoolAssets: pallet_assets::<Instance3> = 55,
AssetConversion: pallet_asset_conversion = 56,
// TODO: the pallet instance should be removed once all pools have migrated
// to the new account IDs.
AssetConversionMigration: pallet_asset_conversion_ops = 200,
}
);
......@@ -1085,6 +1110,7 @@ mod benches {
[cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_xcm_bridge_hub_router, ToRococo]
[pallet_asset_conversion_ops, AssetConversionMigration]
// XCM
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
// NOTE: Make sure you point to the individual modules below.
......
......@@ -19,6 +19,7 @@ pub mod cumulus_pallet_xcmp_queue;
pub mod extrinsic_weights;
pub mod frame_system;
pub mod pallet_asset_conversion;
pub mod pallet_asset_conversion_ops;
pub mod pallet_assets_foreign;
pub mod pallet_assets_local;
pub mod pallet_assets_pool;
......
......@@ -153,4 +153,26 @@ impl<T: frame_system::Config> pallet_asset_conversion::WeightInfo for WeightInfo
.saturating_add(T::DbWeight::get().writes(4))
.saturating_add(Weight::from_parts(0, 393).saturating_mul(n.into()))
}
/// Storage: `AssetConversion::Pools` (r:1 w:0)
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
/// Storage: `Assets::Asset` (r:2 w:2)
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `Assets::Account` (r:2 w:2)
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:1 w:1)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 3]`.
fn touch(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1571`
// Estimated: `6360`
// Minimum execution time: 381_000_000 picoseconds.
Weight::from_parts(398_540_909, 6360)
// Standard Error: 1_330_283
.saturating_add(Weight::from_parts(209_463_636, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into())))
}
}
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_asset_conversion_ops`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-02-15, STEPS: `10`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `cob`, CPU: `<UNKNOWN>`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("asset-hub-westend-dev")`, DB CACHE: 1024
// Executed Command:
// ./target/debug/polkadot-parachain
// benchmark
// pallet
// --chain=asset-hub-westend-dev
// --steps=10
// --repeat=2
// --pallet=pallet-asset-conversion-ops
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_asset_conversion_ops`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_asset_conversion_ops::WeightInfo for WeightInfo<T> {
/// Storage: `AssetConversion::Pools` (r:1 w:0)
/// Proof: `AssetConversion::Pools` (`max_values`: None, `max_size`: Some(1224), added: 3699, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Account` (r:2 w:2)
/// Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Account` (r:2 w:2)
/// Proof: `PoolAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
/// Storage: `PoolAssets::Asset` (r:1 w:1)
/// Proof: `PoolAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `ForeignAssets::Asset` (r:1 w:1)
/// Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`)
fn migrate_to_new_account() -> Weight {
// Proof Size summary in bytes:
// Measured: `1105`
// Estimated: `7404`
// Minimum execution time: 2_216_000_000 picoseconds.
Weight::from_parts(2_379_000_000, 0)
.saturating_add(Weight::from_parts(0, 7404))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(8))
}
}
......@@ -21,13 +21,16 @@ mod tracks;
use crate::{
weights,
xcm_config::{FellowshipAdminBodyId, LocationToAccountId, TreasurerBodyId, UsdtAssetHub},
AccountId, AssetRate, Balance, Balances, FellowshipReferenda, GovernanceLocation, Preimage,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler, WestendTreasuryAccount, DAYS,
AccountId, AssetRate, Balance, Balances, FellowshipReferenda, GovernanceLocation,
ParachainInfo, Preimage, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler,
WestendTreasuryAccount, DAYS,
};
use cumulus_primitives_core::ParaId;
use frame_support::{
parameter_types,
traits::{
EitherOf, EitherOfDiverse, MapSuccess, NeverEnsureOrigin, OriginTrait, TryWithMorphedArg,
tokens::UnityOrOuterConversion, EitherOf, EitherOfDiverse, FromContains, MapSuccess,
NeverEnsureOrigin, OriginTrait, TryWithMorphedArg,
},
PalletId,
};
......@@ -40,10 +43,10 @@ use pallet_ranked_collective::EnsureOfRank;
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use parachains_common::impls::ToParentTreasury;
use polkadot_runtime_common::impls::{
LocatableAssetConverter, VersionedLocatableAsset, VersionedLocationConverter,
ContainsParts, LocatableAssetConverter, VersionedLocatableAsset, VersionedLocationConverter,
};
use sp_arithmetic::Permill;
use sp_core::{ConstU128, ConstU32};
use sp_core::{ConstU128, ConstU32, ConstU8};
use sp_runtime::traits::{ConstU16, ConvertToValue, IdentityLookup, Replace, TakeFirst};
use testnet_parachains_constants::westend::{account, currency::GRAND};
use westend_runtime_constants::time::HOURS;
......@@ -263,6 +266,7 @@ parameter_types! {
// The asset's interior location for the paying account. This is the Fellowship Treasury
// pallet instance (which sits at index 65).
pub FellowshipTreasuryInteriorLocation: InteriorLocation = PalletInstance(65).into();
pub SelfParaId: ParaId = ParachainInfo::parachain_id();
}
#[cfg(feature = "runtime-benchmarks")]
......@@ -345,7 +349,15 @@ impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime {
type Paymaster = FellowshipTreasuryPaymaster;
#[cfg(feature = "runtime-benchmarks")]
type Paymaster = PayWithEnsure<FellowshipTreasuryPaymaster, OpenHrmpChannel<ConstU32<1000>>>;
type BalanceConverter = AssetRate;
type BalanceConverter = UnityOrOuterConversion<
ContainsParts<
FromContains<
xcm_builder::IsSiblingSystemParachain<ParaId, SelfParaId>,
xcm_builder::IsParentsOnly<ConstU8<1>>,
>,
>,
AssetRate,
>;
type PayoutPeriod = ConstU32<{ 30 * DAYS }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments<
......