Support paying DOT as a fee (#404)

* generic template implemented

* support pay do as a fee

* update locks with latest fixes

* docs & tests

* fix clippy

* fix fmt
This commit is contained in:
Nikita Khateev
2025-02-18 07:09:43 +04:00
committed by GitHub
parent 268bb2dd12
commit d953d959e6
16 changed files with 354 additions and 26 deletions
+35 -2
View File
@@ -3870,10 +3870,13 @@ dependencies = [
"nimbus-primitives",
"openzeppelin-pallet-abstractions",
"openzeppelin-pallet-abstractions-proc",
"orml-oracle",
"orml-oracle-runtime-api",
"orml-traits",
"orml-xcm-support",
"orml-xtokens",
"pallet-asset-manager",
"pallet-asset-tx-payment",
"pallet-assets",
"pallet-aura",
"pallet-author-inherent",
@@ -3882,6 +3885,7 @@ dependencies = [
"pallet-cc-authorities-noting",
"pallet-collator-selection",
"pallet-conviction-voting",
"pallet-membership",
"pallet-message-queue",
"pallet-multisig",
"pallet-preimage",
@@ -6790,7 +6794,7 @@ dependencies = [
[[package]]
name = "openzeppelin-pallet-abstractions"
version = "0.1.0"
source = "git+https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions?tag=v0.1-rc3#130bff8b34d6d4f10885e0691614f57a59f3ecab"
source = "git+https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions?branch=dot-as-a-fee-fixes#2e88d23d3d336d4c65b039c431ea3219e8e3b856"
dependencies = [
"cumulus-primitives-core",
"frame-support",
@@ -6803,7 +6807,7 @@ dependencies = [
[[package]]
name = "openzeppelin-pallet-abstractions-proc"
version = "0.1.0"
source = "git+https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions?tag=v0.1-rc3#130bff8b34d6d4f10885e0691614f57a59f3ecab"
source = "git+https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions?branch=dot-as-a-fee-fixes#2e88d23d3d336d4c65b039c431ea3219e8e3b856"
dependencies = [
"darling",
"openzeppelin-pallet-abstractions",
@@ -6860,6 +6864,35 @@ dependencies = [
"num-traits",
]
[[package]]
name = "orml-oracle"
version = "0.10.0"
source = "git+https://github.com/OpenZeppelin/open-runtime-module-library?branch=polkadot-stable2407-1#aafe9077c9ec61dd8b3a42e899ef8353b2b050c0"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"orml-traits",
"orml-utilities",
"parity-scale-codec",
"scale-info",
"serde",
"sp-application-crypto",
"sp-io",
"sp-runtime",
"sp-std",
]
[[package]]
name = "orml-oracle-runtime-api"
version = "0.10.0"
source = "git+https://github.com/OpenZeppelin/open-runtime-module-library?branch=polkadot-stable2407-1#aafe9077c9ec61dd8b3a42e899ef8353b2b050c0"
dependencies = [
"parity-scale-codec",
"sp-api",
"sp-std",
]
[[package]]
name = "orml-traits"
version = "0.10.0"
+6 -2
View File
@@ -26,8 +26,8 @@ serde_json = "1.0.121"
smallvec = "1.11.0"
# TODO: update to release
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", branch = "dot-as-a-fee-fixes", default-features = false }
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", branch = "dot-as-a-fee-fixes", default-features = false }
# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -39,11 +39,13 @@ frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-fea
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-asset-tx-payment = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
@@ -145,6 +147,8 @@ pallet-xcm-weight-trader = { git = "https://github.com/OpenZeppelin/moonbeam.git
xcm-primitives = { git = "https://github.com/OpenZeppelin/moonbeam.git", branch = "polkadot-stable2407-1", default-features = false }
# ORML
orml-oracle = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
orml-oracle-runtime-api = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
orml-traits = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
orml-xcm-support = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
orml-xtokens = { git = "https://github.com/OpenZeppelin/open-runtime-module-library", branch = "polkadot-stable2407-1", default-features = false }
+14
View File
@@ -29,9 +29,11 @@ frame-system = { workspace = true }
frame-system-benchmarking = { workspace = true, optional = true }
frame-system-rpc-runtime-api = { workspace = true }
frame-try-runtime = { workspace = true, optional = true }
pallet-asset-tx-payment = { workspace = true }
pallet-assets = { workspace = true }
pallet-balances = { workspace = true }
pallet-conviction-voting = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
@@ -96,6 +98,8 @@ xcm-primitives = { workspace = true }
# ORML
dp-consensus = { workspace = true }
nimbus-primitives = { workspace = true }
orml-oracle = { workspace = true }
orml-oracle-runtime-api = { workspace = true }
orml-traits = { workspace = true }
orml-xcm-support = { workspace = true }
orml-xtokens = { workspace = true }
@@ -137,8 +141,11 @@ std = [
"log/std",
"nimbus-primitives/std",
"openzeppelin-pallet-abstractions/std",
"orml-oracle-runtime-api/std",
"orml-oracle/std",
"orml-xtokens/std",
"pallet-asset-manager/std",
"pallet-asset-tx-payment/std",
"pallet-assets/std",
"pallet-aura/std",
"pallet-author-inherent/std",
@@ -147,6 +154,7 @@ std = [
"pallet-cc-authorities-noting/std",
"pallet-collator-selection/std",
"pallet-conviction-voting/std",
"pallet-membership/std",
"pallet-message-queue/std",
"pallet-multisig/std",
"pallet-preimage/std",
@@ -202,12 +210,15 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"hex-literal",
"nimbus-primitives/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
"pallet-asset-manager/runtime-benchmarks",
"pallet-asset-tx-payment/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-author-inherent/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-cc-authorities-noting/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
@@ -240,8 +251,10 @@ try-runtime = [
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"nimbus-primitives/try-runtime",
"orml-oracle/try-runtime",
"orml-xtokens/try-runtime",
"pallet-asset-manager/try-runtime",
"pallet-asset-tx-payment/try-runtime",
"pallet-assets/try-runtime",
"pallet-aura/try-runtime",
"pallet-author-inherent/try-runtime",
@@ -249,6 +262,7 @@ try-runtime = [
"pallet-cc-authorities-noting/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-membership/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
"pallet-preimage/try-runtime",
+6 -2
View File
@@ -11,8 +11,8 @@ use crate::{
use crate::{constants::SLOT_DURATION, types::ConsensusHook};
use crate::{
constants::VERSION,
types::{AccountId, Balance, Block, Executive, Nonce},
InherentDataExt, ParachainSystem, Runtime, RuntimeBlockWeights, RuntimeCall,
types::{AccountId, AssetId, Balance, Block, Executive, Nonce},
InherentDataExt, Oracle, ParachainSystem, Runtime, RuntimeBlockWeights, RuntimeCall,
RuntimeGenesisConfig, SessionKeys, System, TransactionPayment,
};
@@ -29,6 +29,8 @@ mod apis {
type RuntimeCall = RuntimeCall;
type TransactionPayment = TransactionPayment;
type Balance = Balance;
type Oracle = Oracle;
type OracleKey = AssetId;
}
mod consensus {
@@ -83,6 +85,8 @@ mod apis {
type RuntimeCall = RuntimeCall;
type TransactionPayment = TransactionPayment;
type Balance = Balance;
type Oracle = Oracle;
type OracleKey = AssetId;
}
mod tanssi {
+15 -4
View File
@@ -82,10 +82,10 @@ use crate::{
TreasuryAccount, TreasuryInteriorLocation, TreasuryPalletId, TreasuryPaymaster, Version,
},
weights::{BlockExecutionWeight, ExtrinsicBaseWeight},
AllPalletsWithSystem, AssetManager, Balances, MessageQueue, OriginCaller, PalletInfo,
ParachainInfo, ParachainSystem, PolkadotXcm, Preimage, Referenda, Runtime, RuntimeCall,
RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Scheduler,
System, Treasury, WeightToFee, XcmpQueue,
AllPalletsWithSystem, AssetManager, Balances, MessageQueue, Oracle, OracleMembership,
OriginCaller, PalletInfo, ParachainInfo, ParachainSystem, PolkadotXcm, Preimage, Referenda,
Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin,
RuntimeTask, Scheduler, System, Timestamp, Treasury, WeightToFee, XcmpQueue,
};
#[cfg(not(feature = "tanssi"))]
use crate::{Aura, CollatorSelection, Session};
@@ -176,7 +176,13 @@ impl XcmConfig for OpenZeppelinRuntime {
type XcmpQueueMaxInboundSuspended = ConstU32<1000>;
type XtokensReserveProviders = ReserveProviders;
}
parameter_types! {
pub RootOperatorAccountId: AccountId = AccountId::from([0xffu8; 32]);
}
impl AssetsConfig for OpenZeppelinRuntime {
type AccountId = AccountId;
type ApprovalDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
type AssetAccountDeposit = ConstU128<{ deposit(1, 16) }>;
type AssetDeposit = ConstU128<{ 10 * CENTS }>;
@@ -184,11 +190,16 @@ impl AssetsConfig for OpenZeppelinRuntime {
type AssetRegistrar = AssetRegistrar;
type AssetRegistrarMetadata = AssetRegistrarMetadata;
type AssetType = AssetType;
type AssetsToBlockAuthor = parachains_common::impls::AssetsToBlockAuthor<Runtime, ()>;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type ForceOrigin = EnsureRoot<AccountId>;
type ForeignAssetModifierOrigin = EnsureRoot<AccountId>;
type FungiblesToAccount = TreasuryAccount;
type RootOperatorAccountId = RootOperatorAccountId;
type Timestamp = Timestamp;
type WeightToFee = WeightToFee;
}
#[cfg(feature = "tanssi")]
impl TanssiConfig for OpenZeppelinRuntime {
type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight<Runtime>;
@@ -31,6 +31,9 @@ impl ConsensusWeight for OpenZeppelinRuntime {
impl AssetsWeight for OpenZeppelinRuntime {
type AssetManager = weights::pallet_asset_manager::WeightInfo<Runtime>;
type Assets = weights::pallet_assets::WeightInfo<Runtime>;
// TODO: fix weight on release
type OracleMembership = ();
type OrmlOracle = (); // TODO: fix weight
}
impl GovernanceWeight for OpenZeppelinRuntime {
+1 -1
View File
@@ -81,7 +81,7 @@ pub type SignedExtra = (
frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
pallet_asset_tx_payment::ChargeAssetTxPayment<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim<Runtime>,
);