Skip to content
Closed
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions runtime/moonbase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build = "build.rs"
serde = { version = "1.0.101", default-features = false, optional = true, features = ["derive"] }
parity-scale-codec = { version = "2.2", default-features = false, features = ["derive", "max-encoded-len"] }
log = "0.4"
smallvec = "1.4.1"

runtime-common = { path = "../common", default-features = false }

Expand Down
22 changes: 20 additions & 2 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ use frame_support::{
traits::{Contains, Everything, Get, Imbalance, InstanceFilter, OnUnbalanced},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, GetDispatchInfo, IdentityFee, Weight,
DispatchClass, GetDispatchInfo, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial,
},
PalletId,
};
Expand Down Expand Up @@ -74,6 +75,8 @@ use sp_version::RuntimeVersion;

use nimbus_primitives::{CanAuthor, NimbusId};

use smallvec::smallvec;

mod precompiles;
use precompiles::MoonbasePrecompiles;

Expand All @@ -97,6 +100,7 @@ pub mod currency {

pub const TRANSACTION_BYTE_FEE: Balance = 10 * MICROUNIT;
pub const STORAGE_BYTE_FEE: Balance = 100 * MICROUNIT;
pub const WEIGHT_FEE: Balance = MEGAWEI;

pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 1 * UNIT + (bytes as Balance) * STORAGE_BYTE_FEE
Expand Down Expand Up @@ -277,10 +281,24 @@ parameter_types! {
pub const TransactionByteFee: Balance = currency::TRANSACTION_BYTE_FEE;
}

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

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

impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
type WeightToFee = WeightToFee;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}

Expand Down
1 change: 1 addition & 0 deletions runtime/moonbeam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build = "build.rs"
serde = { version = "1.0.101", default-features = false, optional = true, features = ["derive"] }
parity-scale-codec = { version = "2.2", default-features = false, features = ["derive", "max-encoded-len"] }
log = "0.4"
smallvec = "1.4.1"

runtime-common = { path = "../common", default-features = false }

Expand Down
22 changes: 20 additions & 2 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ use frame_support::{
traits::{Contains, Get, Imbalance, InstanceFilter, OnUnbalanced},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, GetDispatchInfo, IdentityFee, Weight,
DispatchClass, GetDispatchInfo, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial,
},
PalletId,
};
Expand Down Expand Up @@ -74,6 +75,8 @@ use sp_version::RuntimeVersion;

use nimbus_primitives::{CanAuthor, NimbusId};

use smallvec::smallvec;

mod precompiles;
use precompiles::MoonbeamPrecompiles;

Expand All @@ -97,6 +100,7 @@ pub mod currency {

pub const TRANSACTION_BYTE_FEE: Balance = 10 * MICROGLMR;
pub const STORAGE_BYTE_FEE: Balance = 100 * MICROGLMR;
pub const WEIGHT_FEE: Balance = MEGAWEI;

pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 1 * GLMR + (bytes as Balance) * STORAGE_BYTE_FEE
Expand Down Expand Up @@ -282,10 +286,24 @@ parameter_types! {
pub const TransactionByteFee: Balance = currency::TRANSACTION_BYTE_FEE;
}

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

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

impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
type WeightToFee = WeightToFee;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}

Expand Down
1 change: 1 addition & 0 deletions runtime/moonriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build = "build.rs"
serde = { version = "1.0.101", default-features = false, optional = true, features = ["derive"] }
parity-scale-codec = { version = "2.2", default-features = false, features = ["derive", "max-encoded-len"] }
log = "0.4"
smallvec = "1.4.1"

runtime-common = { path = "../common", default-features = false }

Expand Down
22 changes: 20 additions & 2 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ use frame_support::{
traits::{Contains, Everything, Get, Imbalance, InstanceFilter, OnUnbalanced},
weights::{
constants::{RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, GetDispatchInfo, IdentityFee, Weight,
DispatchClass, GetDispatchInfo, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial,
},
PalletId,
};
Expand Down Expand Up @@ -74,6 +75,8 @@ use sp_version::RuntimeVersion;

use nimbus_primitives::{CanAuthor, NimbusId};

use smallvec::smallvec;

mod precompiles;
use precompiles::MoonriverPrecompiles;

Expand All @@ -97,6 +100,7 @@ pub mod currency {

pub const TRANSACTION_BYTE_FEE: Balance = 10 * MICROMOVR;
pub const STORAGE_BYTE_FEE: Balance = 100 * MICROMOVR;
pub const WEIGHT_FEE: Balance = MEGAWEI;

pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 1 * MOVR + (bytes as Balance) * STORAGE_BYTE_FEE
Expand Down Expand Up @@ -267,10 +271,24 @@ parameter_types! {
pub const TransactionByteFee: Balance = currency::TRANSACTION_BYTE_FEE;
}

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

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

impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
type WeightToFee = WeightToFee;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}

Expand Down