Use same fmt and clippy configs as in Polkadot (#3004)

* Copy rustfmt.toml from Polkadot master

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Format with new config

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Add Polkadot clippy config

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update Cargo.lock

Looks like https://github.com/paritytech/polkadot/pull/7611 did not
correctly update the lockfile. Maybe a different Rust Version?!

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2023-08-14 22:30:12 +02:00
committed by GitHub
parent 61480a1881
commit 6c79b58567
60 changed files with 333 additions and 233 deletions
@@ -112,8 +112,10 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte
// Ignore `TrustBackedAssets` explicitly
StartsWith<TrustBackedAssetsPalletLocation>,
// Ignore assets that start explicitly with our `GlobalConsensus(NetworkId)`, means:
// - foreign assets from our consensus should be: `MultiLocation {parents: 1, X*(Parachain(xyz), ..)}`
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't be accepted here
// - foreign assets from our consensus should be: `MultiLocation {parents: 1,
// X*(Parachain(xyz), ..)}`
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't
// be accepted here
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
),
Balance,
@@ -355,7 +357,8 @@ pub type Barrier = TrailingSetTopicAsId<
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
// If the message is one that immediately attemps to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its pluralities (i.e. governance bodies) get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
@@ -455,7 +458,8 @@ impl pallet_xcm::Config for Runtime {
type XcmRouter = XcmRouter;
// We support local origins dispatching XCM executions in principle...
type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
// ... but disallow generic XCM execution. As a result only teleports and reserve transfers are allowed.
// ... but disallow generic XCM execution. As a result only teleports and reserve transfers are
// allowed.
type XcmExecuteFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
@@ -183,7 +183,8 @@ fn test_asset_xcm_trader_with_refund() {
assert_ok!(trader.buy_weight(bought, asset.clone().into(), &ctx));
// Make sure again buy_weight does return an error
// This assert relies on the fact, that we use `TakeFirstAssetTrader` in `WeightTrader` tuple chain, which cannot be called twice
// This assert relies on the fact, that we use `TakeFirstAssetTrader` in `WeightTrader`
// tuple chain, which cannot be called twice
assert_noop!(trader.buy_weight(bought, asset.into(), &ctx), XcmError::TooExpensive);
// We actually use half of the weight
@@ -113,8 +113,10 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte
// Ignore `TrustBackedAssets` explicitly
StartsWith<TrustBackedAssetsPalletLocation>,
// Ignore assets that start explicitly with our `GlobalConsensus(NetworkId)`, means:
// - foreign assets from our consensus should be: `MultiLocation {parents: 1, X*(Parachain(xyz), ..)}`
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't be accepted here
// - foreign assets from our consensus should be: `MultiLocation {parents: 1,
// X*(Parachain(xyz), ..)}`
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't
// be accepted here
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
),
Balance,
@@ -466,7 +468,8 @@ impl pallet_xcm::Config for Runtime {
type XcmRouter = XcmRouter;
// We support local origins dispatching XCM executions in principle...
type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
// ... but disallow generic XCM execution. As a result only teleports and reserve transfers are allowed.
// ... but disallow generic XCM execution. As a result only teleports and reserve transfers are
// allowed.
type XcmExecuteFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
@@ -190,7 +190,8 @@ fn test_asset_xcm_trader_with_refund() {
assert_ok!(trader.buy_weight(bought, asset.clone().into(), &ctx));
// Make sure again buy_weight does return an error
// This assert relies on the fact, that we use `TakeFirstAssetTrader` in `WeightTrader` tuple chain, which cannot be called twice
// This assert relies on the fact, that we use `TakeFirstAssetTrader` in `WeightTrader`
// tuple chain, which cannot be called twice
assert_noop!(trader.buy_weight(bought, asset.into(), &ctx), XcmError::TooExpensive);
// We actually use half of the weight
@@ -1392,8 +1392,9 @@ pub mod migrations {
use sp_runtime::{traits::StaticLookup, Saturating};
use xcm::latest::prelude::*;
/// Temporary migration because of bug with native asset, it can be removed once applied on `AssetHubWestend`.
/// Migrates pools with `MultiLocation { parents: 0, interior: Here }` to `MultiLocation { parents: 1, interior: Here }`
/// Temporary migration because of bug with native asset, it can be removed once applied on
/// `AssetHubWestend`. Migrates pools with `MultiLocation { parents: 0, interior: Here }` to
/// `MultiLocation { parents: 1, interior: Here }`
pub struct NativeAssetParents0ToParents1Migration<T>(sp_std::marker::PhantomData<T>);
impl<
T: pallet_asset_conversion::Config<
@@ -118,8 +118,10 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte
// Ignore `TrustBackedAssets` explicitly
StartsWith<TrustBackedAssetsPalletLocation>,
// Ignore asset which starts explicitly with our `GlobalConsensus(NetworkId)`, means:
// - foreign assets from our consensus should be: `MultiLocation {parents: 1, X*(Parachain(xyz), ..)}
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` wont be accepted here
// - foreign assets from our consensus should be: `MultiLocation {parents: 1,
// X*(Parachain(xyz), ..)}
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` wont
// be accepted here
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
),
Balance,
@@ -417,7 +419,8 @@ pub type Barrier = TrailingSetTopicAsId<
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
// If the message is one that immediately attemps to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its pluralities (i.e. governance bodies) get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
@@ -193,7 +193,8 @@ fn test_asset_xcm_trader_with_refund() {
assert_ok!(trader.buy_weight(bought, asset.clone().into(), &ctx));
// Make sure again buy_weight does return an error
// This assert relies on the fact, that we use `TakeFirstAssetTrader` in `WeightTrader` tuple chain, which cannot be called twice
// This assert relies on the fact, that we use `TakeFirstAssetTrader` in `WeightTrader`
// tuple chain, which cannot be called twice
assert_noop!(trader.buy_weight(bought, asset.into(), &ctx), XcmError::TooExpensive);
// We actually use half of the weight
@@ -55,7 +55,8 @@ pub type MultiLocationConvertedConcreteId<MultiLocationFilter, Balance> =
JustTry,
>;
/// [`MatchedConvertedConcreteId`] converter dedicated for storing `ForeignAssets` with `AssetId` as `MultiLocation`.
/// [`MatchedConvertedConcreteId`] converter dedicated for storing `ForeignAssets` with `AssetId` as
/// `MultiLocation`.
///
/// Excludes by default:
/// - parent as relay chain
@@ -68,7 +69,8 @@ pub type ForeignAssetsConvertedConcreteId<AdditionalMultiLocationExclusionFilter
// Excludes relay/parent chain currency
Equals<ParentLocation>,
// Here we rely on fact that something like this works:
// assert!(MultiLocation::new(1, X1(Parachain(100))).starts_with(&MultiLocation::parent()));
// assert!(MultiLocation::new(1,
// X1(Parachain(100))).starts_with(&MultiLocation::parent()));
// assert!(X1(Parachain(100)).starts_with(&Here));
StartsWith<LocalMultiLocationPattern>,
// Here we can exclude more stuff or leave it as `()`
@@ -273,7 +273,8 @@ macro_rules! include_teleports_for_native_asset_works(
}
);
/// Test-case makes sure that `Runtime` can receive teleported assets from sibling parachain relay chain
/// Test-case makes sure that `Runtime` can receive teleported assets from sibling parachain relay
/// chain
pub fn teleports_for_foreign_assets_works<
Runtime,
XcmConfig,
@@ -595,7 +596,8 @@ macro_rules! include_teleports_for_foreign_assets_works(
}
);
/// Test-case makes sure that `Runtime`'s `xcm::AssetTransactor` can handle native relay chain currency
/// Test-case makes sure that `Runtime`'s `xcm::AssetTransactor` can handle native relay chain
/// currency
pub fn asset_transactor_transfer_with_local_consensus_currency_works<Runtime, XcmConfig>(
collator_session_keys: CollatorSessionKeys<Runtime>,
source_account: AccountIdOf<Runtime>,
@@ -707,7 +709,8 @@ macro_rules! include_asset_transactor_transfer_with_local_consensus_currency_wor
}
);
///Test-case makes sure that `Runtime`'s `xcm::AssetTransactor` can handle native relay chain currency
///Test-case makes sure that `Runtime`'s `xcm::AssetTransactor` can handle native relay chain
/// currency
pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
Runtime,
XcmConfig,
@@ -827,7 +830,8 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
);
additional_checks_before();
// transfer_asset (deposit/withdraw) ALICE -> CHARLIE (not ok - Charlie does not have ExistentialDeposit)
// transfer_asset (deposit/withdraw) ALICE -> CHARLIE (not ok - Charlie does not have
// ExistentialDeposit)
assert_noop!(
RuntimeHelper::<XcmConfig>::do_transfer(
MultiLocation {
@@ -1103,7 +1107,8 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
freezer: bob_account.clone().into(),
});
// lets simulate this was triggered by relay chain from local consensus sibling parachain
// lets simulate this was triggered by relay chain from local consensus sibling
// parachain
let xcm = Xcm(vec![
WithdrawAsset(buy_execution_fee.clone().into()),
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
@@ -1206,7 +1211,8 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
pallet_assets::Error::<Runtime, ForeignAssetsPalletInstance>::NoPermission
);
// lets try create asset for different parachain(3333) (foreign_creator(2222) can create just his assets)
// lets try create asset for different parachain(3333) (foreign_creator(2222) can create
// just his assets)
let foreign_asset_id_multilocation =
MultiLocation { parents: 1, interior: X2(Parachain(3333), GeneralIndex(1234567)) };
let asset_id = AssetIdConverter::convert(&foreign_asset_id_multilocation).unwrap();