Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekkMA committed Oct 7, 2024
1 parent aab0e01 commit be6c451
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 93 deletions.
1 change: 0 additions & 1 deletion runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ mod impl_on_charge_evm_transaction;
mod impl_self_contained_call;
mod impl_xcm_evm_runner;
pub mod migrations;
pub mod runtime_params;
pub mod timestamp;
pub mod types;
pub mod weights;
Expand Down
70 changes: 0 additions & 70 deletions runtime/common/src/runtime_params.rs

This file was deleted.

48 changes: 42 additions & 6 deletions runtime/moonbase/src/runtime_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,47 @@

//! Dynamic runtime parameters for moonbase.

use moonbeam_runtime_common::gen_runtime_params;
use crate::{currency, Runtime};
use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params};
use moonbeam_runtime_common::expose_u128_get;
use moonbeam_runtime_common::types::BoundedU128;
use sp_runtime::Perbill;

gen_runtime_params!(
UNIT: UNIT,
RuntimeConfig_TreasuryProportion: Perbill::from_percent(20),
PalletRandomness_Deposit:
BoundedU128::const_new::<{ 1 * currency::UNIT * currency::SUPPLY_FACTOR }>(),
#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
pub mod dynamic_params {
use super::*;
#[dynamic_pallet_params]
#[codec(index = 0)]
pub mod runtime_config {
// for fees, 80% are burned, 20% to the treasury
#[codec(index = 0)]
pub static FeesTreasuryProportion: Perbill = Perbill::from_percent(20);
}

#[dynamic_pallet_params]
#[codec(index = 1)]
pub mod pallet_randomness {
#[codec(index = 0)]
pub static Deposit: BoundedU128<
{ 1 * currency::UNIT * currency::SUPPLY_FACTOR },
{ 1_000 * currency::UNIT * currency::SUPPLY_FACTOR },
> = BoundedU128::const_new::<{ 1 * currency::UNIT * currency::SUPPLY_FACTOR }>();
}
}

expose_u128_get!(
PalletRandomnessDepositU128,
dynamic_params::pallet_randomness::Deposit
);

#[cfg(feature = "runtime-benchmarks")]
impl Default for RuntimeParameters {
fn default() -> Self {
RuntimeParameters::RuntimeConfig(
dynamic_params::runtime_config::Parameters::FeesTreasuryProportion(
dynamic_params::runtime_config::FeesTreasuryProportion,
Some(Perbill::from_percent(20)),
),
)
}
}
3 changes: 1 addition & 2 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,7 @@ construct_runtime! {
ProxyGenesisCompanion: pallet_proxy_genesis_companion::{Pallet, Config<T>} = 35,
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 36,
MoonbeamLazyMigrations: pallet_moonbeam_lazy_migrations::{Pallet, Call, Storage} = 37,
Parameters: pallet_parameters = 38,

// Has been permanently removed for safety reasons.
// Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 40,
Expand Down Expand Up @@ -1488,8 +1489,6 @@ construct_runtime! {

// Randomness
Randomness: pallet_randomness::{Pallet, Call, Storage, Event<T>, Inherent} = 120,

Parameters: pallet_parameters = 121,
}
}

Expand Down
48 changes: 42 additions & 6 deletions runtime/moonbeam/src/runtime_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,47 @@

//! Dynamic runtime parameters for moonbeam.

use moonbeam_runtime_common::gen_runtime_params;
use crate::{currency, Runtime};
use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params};
use moonbeam_runtime_common::expose_u128_get;
use moonbeam_runtime_common::types::BoundedU128;
use sp_runtime::Perbill;

gen_runtime_params!(
UNIT: GLMR,
RuntimeConfig_TreasuryProportion: Perbill::from_percent(20),
PalletRandomness_Deposit:
BoundedU128::const_new::<{ 1 * currency::GLMR * currency::SUPPLY_FACTOR }>(),
#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
pub mod dynamic_params {
use super::*;
#[dynamic_pallet_params]
#[codec(index = 0)]
pub mod runtime_config {
// for fees, 80% are burned, 20% to the treasury
#[codec(index = 0)]
pub static FeesTreasuryProportion: Perbill = Perbill::from_percent(20);
}

#[dynamic_pallet_params]
#[codec(index = 1)]
pub mod pallet_randomness {
#[codec(index = 0)]
pub static Deposit: BoundedU128<
{ 1 * currency::GLMR * currency::SUPPLY_FACTOR },
{ 1_000 * currency::GLMR * currency::SUPPLY_FACTOR },
> = BoundedU128::const_new::<{ 1 * currency::GLMR * currency::SUPPLY_FACTOR }>();
}
}

expose_u128_get!(
PalletRandomnessDepositU128,
dynamic_params::pallet_randomness::Deposit
);

#[cfg(feature = "runtime-benchmarks")]
impl Default for RuntimeParameters {
fn default() -> Self {
RuntimeParameters::RuntimeConfig(
dynamic_params::runtime_config::Parameters::FeesTreasuryProportion(
dynamic_params::runtime_config::FeesTreasuryProportion,
Some(Perbill::from_percent(20)),
),
)
}
}
3 changes: 1 addition & 2 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ construct_runtime! {
ProxyGenesisCompanion: pallet_proxy_genesis_companion::{Pallet, Config<T>} = 35,
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 36,
MoonbeamLazyMigrations: pallet_moonbeam_lazy_migrations::{Pallet, Call, Storage} = 37,
Parameters: pallet_parameters = 38,

// Sudo was previously index 40

Expand Down Expand Up @@ -1489,8 +1490,6 @@ construct_runtime! {

// Randomness
Randomness: pallet_randomness::{Pallet, Call, Storage, Event<T>, Inherent} = 120,

Parameters: pallet_parameters = 121,
}
}

Expand Down
48 changes: 42 additions & 6 deletions runtime/moonriver/src/runtime_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,47 @@

//! Dynamic runtime parameters for moonriver.

use moonbeam_runtime_common::gen_runtime_params;
use crate::{currency, Runtime};
use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params};
use moonbeam_runtime_common::expose_u128_get;
use moonbeam_runtime_common::types::BoundedU128;
use sp_runtime::Perbill;

gen_runtime_params!(
UNIT: MOVR,
RuntimeConfig_TreasuryProportion: Perbill::from_percent(20),
PalletRandomness_Deposit:
BoundedU128::const_new::<{ 1 * currency::MOVR * currency::SUPPLY_FACTOR }>(),
#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::<Runtime>)]
pub mod dynamic_params {
use super::*;
#[dynamic_pallet_params]
#[codec(index = 0)]
pub mod runtime_config {
// for fees, 80% are burned, 20% to the treasury
#[codec(index = 0)]
pub static FeesTreasuryProportion: Perbill = Perbill::from_percent(20);
}

#[dynamic_pallet_params]
#[codec(index = 1)]
pub mod pallet_randomness {
#[codec(index = 0)]
pub static Deposit: BoundedU128<
{ 1 * currency::MOVR * currency::SUPPLY_FACTOR },
{ 1_000 * currency::MOVR * currency::SUPPLY_FACTOR },
> = BoundedU128::const_new::<{ 1 * currency::MOVR * currency::SUPPLY_FACTOR }>();
}
}

expose_u128_get!(
PalletRandomnessDepositU128,
dynamic_params::pallet_randomness::Deposit
);

#[cfg(feature = "runtime-benchmarks")]
impl Default for RuntimeParameters {
fn default() -> Self {
RuntimeParameters::RuntimeConfig(
dynamic_params::runtime_config::Parameters::FeesTreasuryProportion(
dynamic_params::runtime_config::FeesTreasuryProportion,
Some(Perbill::from_percent(20)),
),
)
}
}

0 comments on commit be6c451

Please sign in to comment.