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

Make Westmint Support Bridged Assets #1895

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
aa67a43
rustc grumbles
joepetrowski Nov 17, 2022
9ab1739
add second instance
joepetrowski Nov 17, 2022
df40d77
leave some todos
joepetrowski Nov 17, 2022
94717a4
fix AssetsToBlockAuthor
joepetrowski Nov 17, 2022
47d96e0
make it almost compile
joepetrowski Nov 18, 2022
1e0515e
make it actually compile
joepetrowski Nov 18, 2022
6de6313
fix logical error
joepetrowski Nov 18, 2022
35d1e57
cargo fmt to resolve duplicate imports on merge
joepetrowski Nov 18, 2022
362a907
fix deps to make compile
joepetrowski Nov 18, 2022
b8ed7e7
fmt
joepetrowski Nov 18, 2022
633366b
(pallet-assets/pallet-asset-tx-payment) pathched with `sv-locked-for-…
bkontur Nov 21, 2022
5f7f8c2
statemine progress
joepetrowski Nov 22, 2022
e8afde4
ForeignCreators :tada:
joepetrowski Nov 22, 2022
e569b68
fix AssetFeeAsExistentialDepositMultiplier
joepetrowski Nov 30, 2022
c487586
no default instance
joepetrowski Nov 30, 2022
4191a4d
instantiate statemint
joepetrowski Dec 1, 2022
d9d5a9d
compile tests
bkontur Dec 22, 2022
3353263
don't rename pallet in runtime
joepetrowski Jan 11, 2023
9e211b8
don't rename and fix tests
joepetrowski Jan 11, 2023
25c2fc5
fix benchmark helper
joepetrowski Jan 12, 2023
a4a581b
fix benchmark build
joepetrowski Jan 12, 2023
9cd2708
more benchmark fixes
joepetrowski Jan 12, 2023
81e9703
fix penpal and rococo
joepetrowski Jan 12, 2023
4365baa
Merge branch 'bridge-hub-base' into joe-bridge-hub-westmint-assets
bkontur Jan 15, 2023
3aae882
XCM v3 Companion (#697)
gavofyork Jan 17, 2023
0c3f3b7
update BenchmarkHelper interface
joepetrowski Jan 17, 2023
c3d2108
fmt
joepetrowski Jan 17, 2023
85de406
Instantiate All Assets Pallets (#1908)
joepetrowski Jan 18, 2023
e350102
Bump assert_cmd from 2.0.7 to 2.0.8 (#2074)
dependabot[bot] Jan 18, 2023
6d47326
adjust pallet_contracts config (#2108)
agryaznov Jan 19, 2023
b6b2c1c
Companion for paritytech/polkadot#6578 (#2112)
KiChjang Jan 19, 2023
df40e7e
[backport] version bumps from release 9370 (#2095)
EgorPopelyaev Jan 19, 2023
46d3091
Simplify the template (#2072)
bkchr Jan 19, 2023
2b9a640
Use correct runtime function name (#2116)
bkchr Jan 20, 2023
01c83d2
Bump clap from 4.0.32 to 4.1.1 (#2096)
dependabot[bot] Jan 20, 2023
b322482
Warn validators with slow hardware (#1863)
Szegoo Jan 21, 2023
0d75123
Merge remote-tracking branch 'origin/master' into joe-bridge-hub-west…
bkontur Jan 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
statemine progress
  • Loading branch information
joepetrowski committed Nov 22, 2022
commit 5f7f8c2a01bd74ca5e346142c6daf181c7110573
63 changes: 43 additions & 20 deletions parachains/runtimes/assets/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,13 @@ parameter_types! {
pub type AssetsForceOrigin =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureXcm<IsMajorityOfBody<KsmLocation, ExecutiveBody>>>;

impl pallet_assets::Config for Runtime {
pub type TrustBackedAssetsInstance = pallet_assets::Instance1;
impl pallet_assets::Config<TrustBackedAssetsInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
type AssetId = AssetId;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AssetsForceOrigin;
type AssetDeposit = AssetDeposit;
type MetadataDepositBase = MetadataDepositBase;
Expand All @@ -243,6 +245,8 @@ impl pallet_assets::Config for Runtime {
type Extra = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
}

parameter_types! {
Expand Down Expand Up @@ -317,14 +321,15 @@ impl Default for ProxyType {
Self::Any
}
}
type TrustBackedAssetsCall = pallet_assets::Call<Runtime, frame_support::instances::Instance1>;
impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::Any => true,
ProxyType::NonTransfer => !matches!(
c,
RuntimeCall::Balances { .. } |
RuntimeCall::Assets { .. } |
RuntimeCall::TrustBackedAssets { .. } |
RuntimeCall::Uniques { .. }
),
ProxyType::CancelProxy => matches!(
Expand All @@ -336,20 +341,21 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::Assets => {
matches!(
c,
RuntimeCall::Assets { .. } |
RuntimeCall::TrustBackedAssets { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::Uniques { .. }
)
},
ProxyType::AssetOwner => matches!(
c,
RuntimeCall::Assets(pallet_assets::Call::create { .. }) |
RuntimeCall::Assets(pallet_assets::Call::destroy { .. }) |
RuntimeCall::Assets(pallet_assets::Call::transfer_ownership { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_team { .. }) |
RuntimeCall::Assets(pallet_assets::Call::set_metadata { .. }) |
RuntimeCall::Assets(pallet_assets::Call::clear_metadata { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::create { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::destroy { .. }) |
RuntimeCall::TrustBackedAssets(
TrustBackedAssetsCall::transfer_ownership { .. }
) | RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::set_team { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::set_metadata { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::clear_metadata { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) |
Expand All @@ -366,12 +372,12 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
),
ProxyType::AssetManager => matches!(
c,
RuntimeCall::Assets(pallet_assets::Call::mint { .. }) |
RuntimeCall::Assets(pallet_assets::Call::burn { .. }) |
RuntimeCall::Assets(pallet_assets::Call::freeze { .. }) |
RuntimeCall::Assets(pallet_assets::Call::thaw { .. }) |
RuntimeCall::Assets(pallet_assets::Call::freeze_asset { .. }) |
RuntimeCall::Assets(pallet_assets::Call::thaw_asset { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::mint { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::burn { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::freeze { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::thaw { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::freeze_asset { .. }) |
RuntimeCall::TrustBackedAssets(TrustBackedAssetsCall::thaw_asset { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) |
RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) |
Expand Down Expand Up @@ -516,9 +522,17 @@ impl pallet_collator_selection::Config for Runtime {

impl pallet_asset_tx_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Fungibles = Assets;
// TODO https://github.com/paritytech/substrate/issues/12724
// This should be able to take assets from any pallet instance. For now we only allow
// sufficient, trust backed assets to pay for transaction fees.
type Fungibles = TrustBackedAssets;
type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter<
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>,
pallet_assets::BalanceToAssetBalance<
Balances,
Runtime,
ConvertInto,
TrustBackedAssetsInstance,
>,
AssetsToBlockAuthor<Runtime>,
>;
}
Expand Down Expand Up @@ -595,7 +609,7 @@ construct_runtime!(
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 42,

// The main stage.
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 50,
TrustBackedAssets: pallet_assets::<Instance1>::{Pallet, Call, Storage, Event<T>} = 50,
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51,
}
);
Expand Down Expand Up @@ -631,9 +645,18 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(),
MigrateAssetsPallet,
>;

pub struct MigrateAssetsPallet;
impl frame_support::traits::OnRuntimeUpgrade for MigrateAssetsPallet {
fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration;
migration::move_pallet(b"Assets", b"TrustBackedAssets");
<Runtime as frame_system::Config>::DbWeight::get().writes(1)
}
}

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
Expand All @@ -642,7 +665,7 @@ extern crate frame_benchmarking;
mod benches {
define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Assets]
[pallet_assets, TrustBackedAssets]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
Expand Down
27 changes: 16 additions & 11 deletions parachains/runtimes/assets/statemine/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// limitations under the License.

use super::{
AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
XcmpQueue,
AccountId, AllPalletsWithSystem, AssetId, Authorship, Balance, Balances, ParachainInfo,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
TrustBackedAssets, TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
};
use frame_support::{
match_types, parameter_types,
Expand Down Expand Up @@ -48,8 +48,8 @@ parameter_types! {
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
pub const Local: MultiLocation = Here.into_location();
pub AssetsPalletLocation: MultiLocation =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
pub TrustBackedAssetsPalletLocation: MultiLocation =
PalletInstance(<TrustBackedAssets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
}

Expand Down Expand Up @@ -82,12 +82,12 @@ pub type CurrencyTransactor = CurrencyAdapter<
/// Means for transacting assets besides the native currency on this chain.
pub type FungiblesTransactor = FungiblesAdapter<
// Use this fungibles implementation:
Assets,
TrustBackedAssets,
// Use this currency when it is a fungible asset matching the given location or name:
ConvertedConcreteId<
AssetId,
Balance,
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
AsPrefixedGeneralIndex<TrustBackedAssetsPalletLocation, AssetId, JustTry>,
JustTry,
>,
// Convert an XCM MultiLocation into a local account id:
Expand All @@ -96,7 +96,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
AccountId,
// We only want to allow teleports of known assets. We use non-zero issuance as an indication
// that this asset is known.
parachains_common::impls::NonZeroIssuance<AccountId, Assets>,
parachains_common::impls::NonZeroIssuance<AccountId, TrustBackedAssets>,
// The account to use for tracking teleports.
CheckingAccount,
>;
Expand Down Expand Up @@ -183,15 +183,20 @@ impl xcm_executor::Config for XcmConfig {
AssetFeeAsExistentialDepositMultiplier<
Runtime,
WeightToFee,
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>,
pallet_assets::BalanceToAssetBalance<
Balances,
Runtime,
ConvertInto,
TrustBackedAssetsInstance,
>,
>,
ConvertedConcreteId<
AssetId,
Balance,
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
AsPrefixedGeneralIndex<TrustBackedAssetsPalletLocation, AssetId, JustTry>,
JustTry,
>,
Assets,
TrustBackedAssets,
cumulus_primitives_utility::XcmFeesTo32ByteAccount<
FungiblesTransactor,
AccountId,
Expand Down
3 changes: 3 additions & 0 deletions parachains/runtimes/assets/statemint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ impl pallet_assets::Config for Runtime {
type Balance = Balance;
type AssetId = AssetId;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = AssetsForceOrigin;
type AssetDeposit = AssetDeposit;
type MetadataDepositBase = MetadataDepositBase;
Expand All @@ -273,6 +274,8 @@ impl pallet_assets::Config for Runtime {
type Extra = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
}

parameter_types! {
Expand Down
16 changes: 14 additions & 2 deletions parachains/runtimes/assets/westmint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,15 @@ impl pallet_assets::Config<TrustBackedAssetsInstance> for Runtime {
type Extra = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
}

/// Assets managed by some foreign location.
type ForeignAssetsInstance = pallet_assets::Instance2;
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = Balance;
// TODO: need HasCompact for MultiLocation
type AssetId = AssetId; // MultiLocationForAssetId;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>; // ForeignCreators;
Expand All @@ -266,6 +267,8 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
type Extra = ();
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
type AssetAccountDeposit = AssetAccountDeposit;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
}

parameter_types! {
Expand Down Expand Up @@ -663,9 +666,18 @@ pub type Executive = frame_executive::Executive<
// TODO
// 1. Move this instance https://substrate.stackexchange.com/questions/4343/how-to-migrate-storage-from-a-default-pallet-instance-to-an-actual-one
// 2. Make sure this migration applies to the old instance
(), //pallet_assets::migration::v1::MigrateToV1<Runtime>,
MigrateAssetsPallet, //pallet_assets::migration::v1::MigrateToV1<Runtime>,
>;

pub struct MigrateAssetsPallet;
impl frame_support::traits::OnRuntimeUpgrade for MigrateAssetsPallet {
fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration;
migration::move_pallet(b"Assets", b"TrustBackedAssets");
<Runtime as frame_system::Config>::DbWeight::get().writes(1)
}
}

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
Expand Down