Skip to content

Commit 71481da

Browse files
authored
remove unused struct in payment and add impl for FeeMultiplierUpdate (paritytech#126)
1 parent a27bf19 commit 71481da

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

runtime/src/lib.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ use static_assertions::const_assert;
1313
use sp_api::impl_runtime_apis;
1414
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
1515
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
16-
use sp_runtime::traits::{
17-
BlakeTwo256, Block as BlockT, DispatchInfoOf, IdentityLookup, NumberFor, Saturating,
18-
SignedExtension,
19-
};
2016
use sp_runtime::{
2117
create_runtime_str, generic, impl_opaque_keys,
18+
traits::{
19+
BlakeTwo256, Block as BlockT, DispatchInfoOf, IdentityLookup, NumberFor, Saturating,
20+
SignedExtension,
21+
},
2222
transaction_validity::{
2323
InvalidTransaction, TransactionSource, TransactionValidity, TransactionValidityError,
2424
ValidTransaction,
2525
},
26-
ApplyExtrinsicResult,
26+
ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill,
2727
};
2828
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
2929
#[cfg(feature = "std")]
@@ -32,7 +32,7 @@ use sp_version::RuntimeVersion;
3232

3333
#[cfg(any(feature = "std", test))]
3434
pub use sp_runtime::BuildStorage;
35-
pub use sp_runtime::{Perbill, Permill};
35+
3636
// A few exports that help ease life for downstream crates.
3737
pub use frame_support::{
3838
construct_runtime, parameter_types,
@@ -65,6 +65,7 @@ pub use xpallet_bridge_bitcoin::{
6565
pub use xpallet_contracts::Schedule as ContractsSchedule;
6666
pub use xpallet_contracts_primitives::XRC20Selector;
6767
pub use xpallet_protocol::*;
68+
pub use xpallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
6869

6970
impl_opaque_keys! {
7071
pub struct SessionKeys {
@@ -300,13 +301,17 @@ impl xpallet_contracts::Trait for Runtime {
300301
}
301302

302303
parameter_types! {
303-
pub const TransactionByteFee: Balance = 1;
304+
pub const TransactionByteFee: Balance = 1; // TODO change in future
305+
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
306+
pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000);
307+
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128);
304308
}
305309

306310
impl xpallet_transaction_payment::Trait for Runtime {
307311
type TransactionByteFee = TransactionByteFee;
308312
type WeightToFee = IdentityFee<Balance>;
309-
type FeeMultiplierUpdate = ();
313+
type FeeMultiplierUpdate =
314+
TargetedFeeAdjustment<Self, TargetBlockFullness, AdjustmentVariable, MinimumMultiplier>;
310315
}
311316

312317
construct_runtime!(

xpallets/transaction-payment/src/lib.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use sp_runtime::{
5151
InvalidTransaction, TransactionPriority, TransactionValidity, TransactionValidityError,
5252
ValidTransaction,
5353
},
54-
FixedPointNumber, FixedPointOperand, FixedU128, Perquintill, RuntimeDebug,
54+
FixedPointNumber, FixedPointOperand, FixedU128, Perquintill,
5555
};
5656
use sp_std::prelude::*;
5757
use xpallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
@@ -169,21 +169,6 @@ where
169169
}
170170
}
171171

172-
/// Storage releases of the module.
173-
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug)]
174-
enum Releases {
175-
/// Original version of the module.
176-
V1Ancient,
177-
/// One that bumps the usage to FixedU128 from FixedI128.
178-
V2,
179-
}
180-
181-
impl Default for Releases {
182-
fn default() -> Self {
183-
Releases::V1Ancient
184-
}
185-
}
186-
187172
pub trait Trait: frame_system::Trait + xpallet_assets::Trait {
188173
// /// The currency type in which fees will be paid.
189174
// type Currency: Currency<Self::AccountId> + Send + Sync;
@@ -206,8 +191,6 @@ pub trait Trait: frame_system::Trait + xpallet_assets::Trait {
206191
decl_storage! {
207192
trait Store for Module<T: Trait> as TransactionPayment {
208193
pub NextFeeMultiplier get(fn next_fee_multiplier): Multiplier = Multiplier::saturating_from_integer(1);
209-
210-
StorageVersion build(|_: &GenesisConfig| Releases::V2): Releases;
211194
}
212195
}
213196

0 commit comments

Comments
 (0)