Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction payments work via new fungible traits implementation #332

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Staking runtime api to check if reward is pending for an era ([polkadot-fellows/runtimes#318](https://github.com/polkadot-fellows/runtimes/pull/318))
- Allow any parachain to have bidirectional channel with any system parachains ([polkadot-fellows/runtimes#329](https://github.com/polkadot-fellows/runtimes/pull/329))

### Changed

- Transaction payments work via new `fungible` trait implementation ([polkadot-fellows/runtimes#332](https://github.com/polkadot-fellows/runtimes/pull/332))

### Fixed

- Handle extra erroneous consumer reference when a nomination pool is destroying ([polkadot-fellows/runtimes#318](https://github.com/polkadot-fellows/runtimes/pull/318))
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ pallet-staking-runtime-api = { version = "15.0.1", default-features = false }
pallet-state-trie-migration = { version = "30.0.0", default-features = false }
pallet-sudo = { version = "29.0.0", default-features = false }
pallet-timestamp = { version = "28.0.0", default-features = false }
pallet-transaction-payment = { version = "29.0.0", default-features = false }
pallet-transaction-payment = { version = "29.0.1", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "29.0.0", default-features = false }
pallet-treasury = { version = "28.0.0", default-features = false }
pallet-treasury = { version = "28.0.1", default-features = false }
pallet-uniques = { version = "29.0.0", default-features = false }
pallet-utility = { version = "29.0.0", default-features = false }
pallet-vesting = { version = "29.0.0", default-features = false }
Expand All @@ -174,7 +174,7 @@ polkadot-emulated-chain = { path = "integration-tests/emulated/chains/relays/pol
polkadot-parachain-primitives = { version = "7.0.0", default-features = false }
polkadot-primitives = { version = "8.0.1", default-features = false }
polkadot-runtime = { path = "relay/polkadot" }
polkadot-runtime-common = { version = "8.0.1", default-features = false }
polkadot-runtime-common = { version = "8.0.2", default-features = false }
polkadot-runtime-constants = { path = "relay/polkadot/constants", default-features = false }
polkadot-system-emulated-network = { path = "integration-tests/emulated/networks/polkadot-system" }
primitive-types = { version = "0.12.2", default-features = false }
Expand Down Expand Up @@ -226,7 +226,7 @@ substrate-wasm-builder = { version = "18.0.0" }
system-parachains-constants = { path = "system-parachains/constants", default-features = false }
tokio = { version = "1.36.0" }
xcm = { version = "8.0.1", default-features = false, package = "staging-xcm" }
xcm-builder = { version = "8.0.1", default-features = false, package = "staging-xcm-builder" }
xcm-builder = { version = "8.0.2", default-features = false, package = "staging-xcm-builder" }
xcm-emulator = { version = "0.6.0" }
xcm-executor = { version = "8.0.1", default-features = false, package = "staging-xcm-executor" }
anyhow = { version = "1.0.82" }
Expand Down
4 changes: 2 additions & 2 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ use frame_system::{EnsureRoot, EnsureSigned};
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_identity::legacy::IdentityInfo;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
use pallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
use sp_core::{ConstU128, OpaqueMetadata, H256};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
Expand Down Expand Up @@ -434,7 +434,7 @@ parameter_types! {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Self>>;
type OnChargeTransaction = FungibleAdapter<Balances, DealWithFees<Self>>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
4 changes: 2 additions & 2 deletions relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "512"]

use pallet_transaction_payment::CurrencyAdapter;
use pallet_transaction_payment::FungibleAdapter;
use polkadot_runtime_common::{
auctions, claims, crowdloan, impl_runtime_weights,
impls::{
Expand Down Expand Up @@ -412,7 +412,7 @@ parameter_types! {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>;
type OnChargeTransaction = FungibleAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
21 changes: 12 additions & 9 deletions system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ use assets_common::{
use frame_support::{
parameter_types,
traits::{
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing,
PalletInfoAccess,
tokens::imbalance::{ResolveAssetTo, ResolveTo},
ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess,
},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier,
ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
},
use parachains_common::xcm_config::{
AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem,
ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
};
use polkadot_parachain_primitives::primitives::Sibling;
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
Expand Down Expand Up @@ -323,7 +320,13 @@ impl xcm_executor::Config for XcmConfig {
MaxInstructions,
>;
type Trader = (
UsingComponents<WeightToFee, KsmLocation, AccountId, Balances, ToStakingPot<Runtime>>,
UsingComponents<
WeightToFee,
KsmLocation,
AccountId,
Balances,
ResolveTo<StakingPot, Balances>,
>,
// This trader allows to pay with any assets exchangeable to KSM with
// [`AssetConversion`].
cumulus_primitives_utility::SwapFirstAssetTrader<
Expand Down
21 changes: 12 additions & 9 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ use assets_common::{
use frame_support::{
parameter_types,
traits::{
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing,
PalletInfoAccess,
tokens::imbalance::{ResolveAssetTo, ResolveTo},
ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess,
},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier,
ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
},
use parachains_common::xcm_config::{
AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem,
ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_constants::system_parachain;
Expand Down Expand Up @@ -385,7 +382,13 @@ impl xcm_executor::Config for XcmConfig {
MaxInstructions,
>;
type Trader = (
UsingComponents<WeightToFee, DotLocation, AccountId, Balances, ToStakingPot<Runtime>>,
UsingComponents<
WeightToFee,
DotLocation,
AccountId,
Balances,
ResolveTo<StakingPot, Balances>,
>,
// This trader allows to pay with any assets exchangeable to DOT with
// [`AssetConversion`].
cumulus_primitives_utility::SwapFirstAssetTrader<
Expand Down
13 changes: 7 additions & 6 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ use frame_support::{
genesis_builder_helper::{build_config, create_default_config},
parameter_types,
traits::{
ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, TransformOrigin,
tokens::imbalance::ResolveTo, ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse,
Everything, TransformOrigin,
},
weights::{ConstantMultiplier, Weight},
PalletId,
Expand All @@ -69,7 +70,9 @@ use frame_system::{
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm_config::{FellowshipLocation, GovernanceLocation, XcmOriginToTransactDispatchOrigin};
use xcm_config::{
FellowshipLocation, GovernanceLocation, StakingPot, XcmOriginToTransactDispatchOrigin,
};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand All @@ -78,9 +81,7 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};

use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};

use parachains_common::{
impls::DealWithFees, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
};
use parachains_common::{AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature};
pub use system_parachains_constants::SLOT_DURATION;

use system_parachains_constants::{
Expand Down Expand Up @@ -295,7 +296,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, ResolveTo<StakingPot, Balances>>;
muharem marked this conversation as resolved.
Show resolved Hide resolved
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
23 changes: 13 additions & 10 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@
use super::{
bridge_to_ethereum_config::EthereumNetwork,
bridge_to_polkadot_config::ToBridgeHubPolkadotHaulBlobExporter, AccountId,
AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
AllPalletsWithSystem, Balances, CollatorSelection, ParachainInfo, ParachainSystem, PolkadotXcm,
PriceForParentDelivery, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
XcmpQueue,
};
use frame_support::{
parameter_types,
traits::{ConstU32, Contains, Equals, Everything, Nothing},
traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
},
use parachains_common::xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
};
use polkadot_parachain_primitives::primitives::Sibling;
use snowbridge_runtime_common::XcmExportFeeToSibling;
Expand Down Expand Up @@ -72,6 +69,7 @@ parameter_types! {
pub RelayTreasuryPalletAccount: AccountId =
LocationToAccountId::convert_location(&RelayTreasuryLocation::get())
.unwrap_or(TreasuryAccount::get());
pub StakingPot: AccountId = CollatorSelection::account_id();
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -191,8 +189,13 @@ impl xcm_executor::Config for XcmConfig {
RuntimeCall,
MaxInstructions,
>;
type Trader =
UsingComponents<WeightToFee, KsmRelayLocation, AccountId, Balances, ToStakingPot<Runtime>>;
type Trader = UsingComponents<
WeightToFee,
KsmRelayLocation,
AccountId,
Balances,
ResolveTo<StakingPot, Balances>,
>;
type ResponseHandler = PolkadotXcm;
type AssetTrap = PolkadotXcm;
type AssetClaims = PolkadotXcm;
Expand Down
13 changes: 7 additions & 6 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ use frame_support::{
genesis_builder_helper::{build_config, create_default_config},
parameter_types,
traits::{
ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, TransformOrigin,
tokens::imbalance::ResolveTo, ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse,
Everything, TransformOrigin,
},
weights::{ConstantMultiplier, Weight},
PalletId,
Expand All @@ -71,7 +72,9 @@ use frame_system::{
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm_config::{FellowshipLocation, GovernanceLocation, XcmOriginToTransactDispatchOrigin};
use xcm_config::{
FellowshipLocation, GovernanceLocation, StakingPot, XcmOriginToTransactDispatchOrigin,
};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand All @@ -82,9 +85,7 @@ use polkadot_runtime_constants::system_parachain::{ASSET_HUB_ID, BRIDGE_HUB_ID};

use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};

use parachains_common::{
impls::DealWithFees, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
};
use parachains_common::{AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature};
pub use system_parachains_constants::SLOT_DURATION;

use system_parachains_constants::{
Expand Down Expand Up @@ -308,7 +309,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, ResolveTo<StakingPot, Balances>>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
26 changes: 15 additions & 11 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@
use super::{
bridge_to_ethereum_config::EthereumNetwork,
bridge_to_kusama_config::ToBridgeHubKusamaHaulBlobExporter, AccountId, AllPalletsWithSystem,
Balances, ParachainInfo, ParachainSystem, PolkadotXcm, PriceForParentDelivery, Runtime,
RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
Balances, CollatorSelection, ParachainInfo, ParachainSystem, PolkadotXcm,
PriceForParentDelivery, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
XcmpQueue,
};
use frame_support::{
parameter_types,
traits::{ConstU32, Contains, Equals, Everything, Nothing},
traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
},
use parachains_common::xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
RelayOrOtherSystemParachains,
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_constants::system_parachain;
Expand Down Expand Up @@ -72,6 +70,7 @@ parameter_types! {
pub RelayTreasuryPalletAccount: AccountId =
LocationToAccountId::convert_location(&RelayTreasuryLocation::get())
.unwrap_or(TreasuryAccount::get());
pub StakingPot: AccountId = CollatorSelection::account_id();
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -209,8 +208,13 @@ impl xcm_executor::Config for XcmConfig {
RuntimeCall,
MaxInstructions,
>;
type Trader =
UsingComponents<WeightToFee, DotRelayLocation, AccountId, Balances, ToStakingPot<Runtime>>;
type Trader = UsingComponents<
WeightToFee,
DotRelayLocation,
AccountId,
Balances,
ResolveTo<StakingPot, Balances>,
>;
type ResponseHandler = PolkadotXcm;
type AssetTrap = PolkadotXcm;
type AssetClaims = PolkadotXcm;
Expand Down
Loading
Loading