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
Changes from 1 commit
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
Next Next commit
transaction payment via fungible impl
muharem committed May 28, 2024
commit cfa6d17dcb192f941c5a7804f222506433a35cfd
20 changes: 10 additions & 10 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
@@ -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 }
@@ -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 }
@@ -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" }
16 changes: 14 additions & 2 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
use runtime_parachains::{
assigner_coretime as parachains_assigner_coretime,
assigner_on_demand as parachains_assigner_on_demand, configuration as parachains_configuration,
configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
coretime, disputes as parachains_disputes,
disputes::slashing as parachains_slashing,
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
@@ -86,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,
@@ -433,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>;
@@ -1341,11 +1342,22 @@ impl pallet_message_queue::Config for Runtime {

impl parachains_dmp::Config for Runtime {}

parameter_types! {
pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
}

impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
type Currency = Balances;
// Use the `HrmpChannelSizeAndCapacityWithSystemRatio` ratio from the actual active
// `HostConfiguration` configuration for `hrmp_channel_max_message_size` and
// `hrmp_channel_max_capacity`.
type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
Runtime,
HrmpChannelSizeAndCapacityWithSystemRatio,
>;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
}

30 changes: 30 additions & 0 deletions relay/kusama/src/weights/runtime_parachains_hrmp.rs

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

19 changes: 16 additions & 3 deletions relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::{
@@ -32,7 +32,9 @@ use polkadot_runtime_common::{

use runtime_parachains::{
assigner_parachains as parachains_assigner_parachains,
configuration as parachains_configuration, disputes as parachains_disputes,
configuration as parachains_configuration,
configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
disputes as parachains_disputes,
disputes::slashing as parachains_slashing,
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
inclusion::{AggregateMessageOrigin, UmpQueueId},
@@ -410,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>;
@@ -1365,11 +1367,22 @@ impl pallet_message_queue::Config for Runtime {

impl parachains_dmp::Config for Runtime {}

parameter_types! {
pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
}

impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
type Currency = Balances;
// Use the `HrmpChannelSizeAndCapacityWithSystemRatio` ratio from the actual active
// `HostConfiguration` configuration for `hrmp_channel_max_message_size` and
// `hrmp_channel_max_capacity`.
type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
Runtime,
HrmpChannelSizeAndCapacityWithSystemRatio,
>;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
}

30 changes: 30 additions & 0 deletions relay/polkadot/src/weights/runtime_parachains_hrmp.rs

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

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
@@ -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;
@@ -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<
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
@@ -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;
@@ -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<
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
@@ -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,
@@ -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;
@@ -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::{
@@ -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>;
Loading
Loading