Skip to content

Commit

Permalink
Merge branch 'master' into muharem-meta-tx
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi authored Nov 12, 2024
2 parents 867cbcb + aff3a07 commit d7dc7ae
Show file tree
Hide file tree
Showing 34 changed files with 1,021 additions and 391 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use xcm_builder::{
use xcm_executor::XcmExecutor;

parameter_types! {
pub const RootLocation: Location = Location::here();
pub const TokenLocation: Location = Location::parent();
pub const RelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
Expand Down Expand Up @@ -315,6 +316,7 @@ pub type ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger =
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
Equals<RootLocation>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ use xcm_builder::{
use xcm_executor::XcmExecutor;

parameter_types! {
pub const RootLocation: Location = Location::here();
pub const WestendLocation: Location = Location::parent();
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::ByGenesis(WESTEND_GENESIS_HASH));
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
Expand Down Expand Up @@ -336,6 +337,7 @@ pub type ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger =
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
Equals<RootLocation>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
FellowshipEntities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use xcm_executor::{
};

parameter_types! {
pub const RootLocation: Location = Location::here();
pub const TokenLocation: Location = Location::parent();
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub RelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
Expand Down Expand Up @@ -164,6 +165,7 @@ pub type Barrier = TrailingSetTopicAsId<
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
Equals<RootLocation>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ use xcm_executor::{
};

parameter_types! {
pub const RootLocation: Location = Location::here();
pub const WestendLocation: Location = Location::parent();
pub const RelayNetwork: NetworkId = NetworkId::ByGenesis(WESTEND_GENESIS_HASH);
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
Expand Down Expand Up @@ -161,6 +162,7 @@ pub type Barrier = TrailingSetTopicAsId<
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
Equals<RootLocation>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ use xcm_builder::{
use xcm_executor::XcmExecutor;

parameter_types! {
pub const RootLocation: Location = Location::here();
pub const RelayLocation: Location = Location::parent();
pub const RelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
Expand Down Expand Up @@ -166,6 +167,7 @@ pub type Barrier = TrailingSetTopicAsId<
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
Equals<RootLocation>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
);
Expand Down
22 changes: 21 additions & 1 deletion cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
pub use sp_runtime::BuildStorage;
use sp_runtime::{
generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT},
traits::{BlakeTwo256, Block as BlockT, BlockNumberProvider},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill, RuntimeDebug,
};
Expand Down Expand Up @@ -124,6 +124,7 @@ pub type Migrations = (
pallet_broker::migration::MigrateV0ToV1<Runtime>,
pallet_broker::migration::MigrateV1ToV2<Runtime>,
pallet_broker::migration::MigrateV2ToV3<Runtime>,
pallet_broker::migration::MigrateV3ToV4<Runtime, BrokerMigrationV4BlockConversion>,
// permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
);
Expand Down Expand Up @@ -591,6 +592,25 @@ impl pallet_sudo::Config for Runtime {
type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
}

pub struct BrokerMigrationV4BlockConversion;

impl pallet_broker::migration::v4::BlockToRelayHeightConversion<Runtime>
for BrokerMigrationV4BlockConversion
{
fn convert_block_number_to_relay_height(input_block_number: u32) -> u32 {
let relay_height = pallet_broker::RCBlockNumberProviderOf::<
<Runtime as pallet_broker::Config>::Coretime,
>::current_block_number();
let parachain_block_number = frame_system::Pallet::<Runtime>::block_number();
let offset = relay_height - parachain_block_number * 2;
offset + input_block_number * 2
}

fn convert_block_length_to_relay_length(input_block_length: u32) -> u32 {
input_block_length * 2
}
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use xcm_builder::{
use xcm_executor::XcmExecutor;

parameter_types! {
pub const RootLocation: Location = Location::here();
pub const RocRelayLocation: Location = Location::parent();
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH));
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
Expand Down Expand Up @@ -177,6 +178,7 @@ parameter_types! {
/// Locations that will not be charged fees in the executor, neither for execution nor delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
Equals<RootLocation>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
);
Expand Down
22 changes: 21 additions & 1 deletion cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
pub use sp_runtime::BuildStorage;
use sp_runtime::{
generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT},
traits::{BlakeTwo256, Block as BlockT, BlockNumberProvider},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill, RuntimeDebug,
};
Expand Down Expand Up @@ -124,6 +124,7 @@ pub type Migrations = (
pallet_broker::migration::MigrateV0ToV1<Runtime>,
pallet_broker::migration::MigrateV1ToV2<Runtime>,
pallet_broker::migration::MigrateV2ToV3<Runtime>,
pallet_broker::migration::MigrateV3ToV4<Runtime, BrokerMigrationV4BlockConversion>,
// permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
);
Expand Down Expand Up @@ -586,6 +587,25 @@ impl pallet_utility::Config for Runtime {
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}

pub struct BrokerMigrationV4BlockConversion;

impl pallet_broker::migration::v4::BlockToRelayHeightConversion<Runtime>
for BrokerMigrationV4BlockConversion
{
fn convert_block_number_to_relay_height(input_block_number: u32) -> u32 {
let relay_height = pallet_broker::RCBlockNumberProviderOf::<
<Runtime as pallet_broker::Config>::Coretime,
>::current_block_number();
let parachain_block_number = frame_system::Pallet::<Runtime>::block_number();
let offset = relay_height - parachain_block_number * 2;
offset + input_block_number * 2
}

fn convert_block_length_to_relay_length(input_block_length: u32) -> u32 {
input_block_length * 2
}
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use xcm_builder::{
use xcm_executor::XcmExecutor;

parameter_types! {
pub const RootLocation: Location = Location::here();
pub const TokenRelayLocation: Location = Location::parent();
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::ByGenesis(WESTEND_GENESIS_HASH));
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
Expand Down Expand Up @@ -185,6 +186,7 @@ parameter_types! {
/// Locations that will not be charged fees in the executor, neither for execution nor delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
Equals<RootLocation>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
);
Expand Down
6 changes: 4 additions & 2 deletions cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use core::marker::PhantomData;
use frame_support::{
parameter_types,
traits::{
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, ContainsPair, Everything,
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, ContainsPair, Equals, Everything,
EverythingBut, Get, Nothing, PalletInfoAccess,
},
weights::Weight,
Expand Down Expand Up @@ -210,6 +210,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
);

parameter_types! {
pub const RootLocation: Location = Location::here();
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
pub const MaxInstructions: u32 = 100;
Expand Down Expand Up @@ -336,6 +337,7 @@ pub type TrustedReserves = (
pub type TrustedTeleporters =
(AssetFromChain<LocalTeleportableToAssetHub, SystemAssetHubLocation>,);

pub type WaivedLocations = Equals<RootLocation>;
/// `AssetId`/`Balance` converter for `TrustBackedAssets`.
pub type TrustBackedAssetsConvertedConcreteId =
assets_common::TrustBackedAssetsConvertedConcreteId<AssetsPalletLocation, Balance>;
Expand Down Expand Up @@ -399,7 +401,7 @@ impl xcm_executor::Config for XcmConfig {
type AssetLocker = ();
type AssetExchanger = PoolAssetsExchanger;
type FeeManager = XcmFeeManagerFromComponents<
(),
WaivedLocations,
SendXcmFeeToAccount<Self::AssetTransactor, TreasuryAccount>,
>;
type MessageExporter = ();
Expand Down
17 changes: 9 additions & 8 deletions polkadot/xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ use xcm_runtime_apis::{

#[cfg(any(feature = "try-runtime", test))]
use sp_runtime::TryRuntimeError;
use xcm_executor::traits::{FeeManager, FeeReason};

pub trait WeightInfo {
fn send() -> Weight;
Expand Down Expand Up @@ -240,7 +241,7 @@ pub mod pallet {
type XcmExecuteFilter: Contains<(Location, Xcm<<Self as Config>::RuntimeCall>)>;

/// Something to execute an XCM message.
type XcmExecutor: ExecuteXcm<<Self as Config>::RuntimeCall> + XcmAssetTransfers;
type XcmExecutor: ExecuteXcm<<Self as Config>::RuntimeCall> + XcmAssetTransfers + FeeManager;

/// Our XCM filter which messages to be teleported using the dedicated extrinsic must pass.
type XcmTeleportFilter: Contains<(Location, Vec<Asset>)>;
Expand Down Expand Up @@ -2468,17 +2469,17 @@ impl<T: Config> Pallet<T> {
mut message: Xcm<()>,
) -> Result<XcmHash, SendError> {
let interior = interior.into();
let local_origin = interior.clone().into();
let dest = dest.into();
let maybe_fee_payer = if interior != Junctions::Here {
let is_waived =
<T::XcmExecutor as FeeManager>::is_waived(Some(&local_origin), FeeReason::ChargeFees);
if interior != Junctions::Here {
message.0.insert(0, DescendOrigin(interior.clone()));
Some(interior.into())
} else {
None
};
}
tracing::debug!(target: "xcm::send_xcm", "{:?}, {:?}", dest.clone(), message.clone());
let (ticket, price) = validate_send::<T::XcmRouter>(dest, message)?;
if let Some(fee_payer) = maybe_fee_payer {
Self::charge_fees(fee_payer, price).map_err(|e| {
if !is_waived {
Self::charge_fees(local_origin, price).map_err(|e| {
tracing::error!(
target: "xcm::pallet_xcm::send_xcm",
?e,
Expand Down
10 changes: 10 additions & 0 deletions polkadot/xcm/xcm-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,16 @@ impl<Config: config::Config> XcmAssetTransfers for XcmExecutor<Config> {
type AssetTransactor = Config::AssetTransactor;
}

impl<Config: config::Config> FeeManager for XcmExecutor<Config> {
fn is_waived(origin: Option<&Location>, r: FeeReason) -> bool {
Config::FeeManager::is_waived(origin, r)
}

fn handle_fee(fee: Assets, context: Option<&XcmContext>, r: FeeReason) {
Config::FeeManager::handle_fee(fee, context, r)
}
}

#[derive(Debug)]
pub struct ExecutorError {
pub index: u32,
Expand Down
14 changes: 14 additions & 0 deletions prdoc/pr_5363.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: "[pallet-xcm] waive transport fees based on XcmConfig"

doc:
- audience: Runtime Dev
description: |
pallet-xcm::send() no longer implicitly waives transport fees for the local root location,
but instead relies on xcm_executor::Config::FeeManager to determine whether certain locations have free transport.

🚨 Warning: 🚨 If your chain relies on free transport for local root, please make
sure to add Location::here() to the waived-fee locations in your configured xcm_executor::Config::FeeManager.

crates:
- name: pallet-xcm
bump: major
18 changes: 18 additions & 0 deletions prdoc/pr_5656.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Use Relay Blocknumber in Pallet Broker

doc:
- audience: Runtime Dev
description: |
Changing `sale_start`, `interlude_length` and `leading_length` in `pallet_broker` to use relay chain block numbers instead of parachain block numbers.
Relay chain block numbers are almost deterministic and more future proof.

crates:
- name: pallet-broker
bump: major
- name: coretime-rococo-runtime
bump: major
- name: coretime-westend-runtime
bump: major
10 changes: 10 additions & 0 deletions prdoc/pr_6262.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: "Size limits implemented for fork aware transaction pool"

doc:
- audience: Node Dev
description: |
Size limits are now obeyed in fork aware transaction pool

crates:
- name: sc-transaction-pool
bump: minor
11 changes: 11 additions & 0 deletions prdoc/pr_6301.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: migrate pallet-nft-fractionalization to benchmarking v2 syntax
doc:
- audience: Runtime Dev
description: |-
Migrates pallet-nft-fractionalization to benchmarking v2 syntax.

Part of:
* #6202
crates:
- name: pallet-nft-fractionalization
bump: patch
10 changes: 10 additions & 0 deletions prdoc/pr_6439.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: 'pallet-membership: Do not verify the `MembershipChanged` in bechmarks'
doc:
- audience: Runtime Dev
description: |-
There is no need to verify in the `pallet-membership` benchmark that the `MemembershipChanged` implementation works as the pallet thinks it should work. If you for example set it to `()`, `get_prime()` will always return `None`.

TLDR: Remove the checks of `MembershipChanged` in the benchmarks to support any kind of implementation.
crates:
- name: pallet-membership
bump: patch
Loading

0 comments on commit d7dc7ae

Please sign in to comment.