Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 3 additions & 25 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ use frame_support::{
},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, GetDispatchInfo, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial,
ConstantMultiplier, DispatchClass, GetDispatchInfo, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
PalletId,
};
Expand Down Expand Up @@ -300,28 +300,6 @@ where
}
}

pub struct WeightToFee;
impl WeightToFeePolynomial for WeightToFee {
type Balance = Balance;

/// Return a vec of coefficients. Here we just use one coefficient and reduce it to a constant
/// modifier in order to closely match Ethereum-based fees.
///
/// Calculation, per the documentation in `frame_support`:
///
/// ```ignore
/// coeff_integer * x^(degree) + coeff_frac * x^(degree)
/// ```
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
smallvec![WeightToFeeCoefficient {
degree: 1,
coeff_frac: Perbill::zero(),
coeff_integer: currency::WEIGHT_FEE,
negative: false,
}]
}
}

pub struct LengthToFee;
impl WeightToFeePolynomial for LengthToFee {
type Balance = Balance;
Expand All @@ -347,7 +325,7 @@ impl WeightToFeePolynomial for LengthToFee {
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = WeightToFee;
type WeightToFee = ConstantMultiplier<Balance, ConstU128<{ currency::WEIGHT_FEE }>>;
type LengthToFee = LengthToFee;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}
Expand Down
14 changes: 10 additions & 4 deletions runtime/moonbase/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

use super::{
AccountId, AssetId, AssetManager, Assets, Balance, Balances, Call, DealWithFees, Event,
LocalAssets, Origin, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, Treasury,
WeightToFee, XcmpQueue, FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX,
LocalAssets, Origin, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, Treasury, XcmpQueue,
FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX,
};

use pallet_evm_precompile_assets_erc20::AccountIdAssetIdConversion;
Expand All @@ -29,7 +29,7 @@ use sp_runtime::traits::Hash as THash;
use frame_support::{
parameter_types,
traits::{Everything, Nothing, PalletInfoAccess},
weights::Weight,
weights::{IdentityFee, Weight},
};

use frame_system::EnsureRoot;
Expand Down Expand Up @@ -272,7 +272,13 @@ impl xcm_executor::Config for XcmExecutorConfig {
// When we receive a non-reserve asset, we use AssetManager to fetch how many
// units per second we should charge
type Trader = (
UsingComponents<WeightToFee, SelfReserve, AccountId, Balances, DealWithFees<Runtime>>,
UsingComponents<
IdentityFee<Balance>,
SelfReserve,
AccountId,
Balances,
DealWithFees<Runtime>,
>,
FirstAssetTrader<AssetType, AssetManager, XcmFeesToAccount>,
);
type ResponseHandler = PolkadotXcm;
Expand Down
30 changes: 25 additions & 5 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ use frame_support::{
},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
ConstantMultiplier, DispatchClass, GetDispatchInfo, IdentityFee, Weight,
ConstantMultiplier, DispatchClass, GetDispatchInfo, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
PalletId,
};
Expand All @@ -68,6 +69,7 @@ use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustm
pub use parachain_staking::{InflationInfo, Range};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use smallvec::smallvec;
use sp_api::impl_runtime_apis;
use sp_core::{OpaqueMetadata, H160, H256, U256};
use sp_runtime::{
Expand Down Expand Up @@ -294,15 +296,33 @@ where
}
}

parameter_types! {
pub const TransactionByteFee: Balance = currency::TRANSACTION_BYTE_FEE;
pub struct LengthToFee;
impl WeightToFeePolynomial for LengthToFee {
type Balance = Balance;

fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
smallvec![
WeightToFeeCoefficient {
degree: 1,
coeff_frac: Perbill::zero(),
coeff_integer: currency::TRANSACTION_BYTE_FEE,
negative: false,
},
WeightToFeeCoefficient {
degree: 3,
coeff_frac: Perbill::zero(),
coeff_integer: 1,
negative: false,
},
]
}
}

impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<Balance>;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type WeightToFee = ConstantMultiplier<Balance, ConstU128<{ currency::WEIGHT_FEE }>>;
type LengthToFee = LengthToFee;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}

Expand Down
30 changes: 24 additions & 6 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ use frame_support::{
},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
ConstantMultiplier, DispatchClass, GetDispatchInfo, IdentityFee, Weight,
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
ConstantMultiplier, DispatchClass, GetDispatchInfo, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
PalletId,
};
Expand Down Expand Up @@ -316,15 +316,33 @@ impl WeightToFeePolynomial for WeightToFee {
}
}

parameter_types! {
pub const TransactionByteFee: Balance = currency::TRANSACTION_BYTE_FEE;
pub struct LengthToFee;
impl WeightToFeePolynomial for LengthToFee {
type Balance = Balance;

fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
smallvec![
WeightToFeeCoefficient {
degree: 1,
coeff_frac: Perbill::zero(),
coeff_integer: currency::TRANSACTION_BYTE_FEE,
negative: false,
},
WeightToFeeCoefficient {
degree: 3,
coeff_frac: Perbill::zero(),
coeff_integer: 1,
negative: false,
},
]
}
}

impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<Balance>;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type WeightToFee = ConstantMultiplier<Balance, ConstU128<{ currency::WEIGHT_FEE }>>;
type LengthToFee = LengthToFee;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}

Expand Down