From 8284977b1a679694494c3960deb447679809bced Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Mon, 5 Aug 2024 10:33:18 +0100 Subject: [PATCH 01/24] pallet parameters --- Cargo.toml | 1 + runtime/moonbase/src/governance/referenda.rs | 3 +- runtime/moonbase/src/lib.rs | 13 +++++++++ runtime/moonbase/src/runtime_params.rs | 29 ++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 runtime/moonbase/src/runtime_params.rs diff --git a/Cargo.toml b/Cargo.toml index 0578bfc1bf..c3a8bea3d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -148,6 +148,7 @@ pallet-identity = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", pallet-message-queue = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false } pallet-multisig = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false } pallet-preimage = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false } +pallet-parameters = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false } pallet-proxy = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false } pallet-referenda = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false } pallet-root-testing = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false } diff --git a/runtime/moonbase/src/governance/referenda.rs b/runtime/moonbase/src/governance/referenda.rs index 96bb3628d2..91d430cf77 100644 --- a/runtime/moonbase/src/governance/referenda.rs +++ b/runtime/moonbase/src/governance/referenda.rs @@ -45,7 +45,6 @@ impl pallet_conviction_voting::Config for Runtime { parameter_types! { pub const AlarmInterval: BlockNumber = 1; - pub const SubmissionDeposit: Balance = 10 * UNIT * SUPPLY_FACTOR; pub const UndecidingTimeout: BlockNumber = 21 * DAYS; } @@ -92,7 +91,7 @@ impl pallet_referenda::Config for Runtime { type Slash = Treasury; type Votes = pallet_conviction_voting::VotesOf; type Tally = pallet_conviction_voting::TallyOf; - type SubmissionDeposit = SubmissionDeposit; + type SubmissionDeposit = runtime_params::dynamic_params::pallet_referenda::SubmissionDeposit; type MaxQueued = ConstU32<100>; type UndecidingTimeout = UndecidingTimeout; type AlarmInterval = AlarmInterval; diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 50d5dafd4c..59bd4a1499 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -31,6 +31,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); pub mod asset_config; pub mod governance; pub mod xcm_config; +pub mod runtime_params; mod migrations; mod precompiles; @@ -58,6 +59,7 @@ use fp_rpc::TransactionStatus; use frame_support::{ construct_runtime, dispatch::{DispatchClass, GetDispatchInfo, PostDispatchInfo}, + dynamic_params::{dynamic_pallet_params, dynamic_params}, ensure, pallet_prelude::DispatchResult, parameter_types, @@ -126,6 +128,8 @@ use xcm_config::AssetType; use xcm_fee_payment_runtime_api::Error as XcmPaymentApiError; use xcm_primitives::UnitsToWeightRatio; +use runtime_params::*; + use smallvec::smallvec; use sp_runtime::serde::{Deserialize, Serialize}; @@ -1380,6 +1384,13 @@ impl pallet_precompile_benchmarks::Config for Runtime { type WeightInfo = moonbeam_weights::pallet_precompile_benchmarks::WeightInfo; } +impl pallet_parameters::Config for Runtime { + type AdminOrigin = EnsureRoot; + type RuntimeEvent = RuntimeEvent; + type RuntimeParameters = RuntimeParameters; + type WeightInfo = (); +} + construct_runtime! { pub enum Runtime { @@ -1442,6 +1453,7 @@ construct_runtime! { MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event} = 54, EmergencyParaXcm: pallet_emergency_para_xcm::{Pallet, Call, Storage, Event} = 55, EvmForeignAssets: pallet_moonbeam_foreign_assets::{Pallet, Call, Storage, Event} = 56, + Parameters: pallet_parameters = 57, } } @@ -1517,6 +1529,7 @@ mod benches { [pallet_relay_storage_roots, RelayStorageRoots] [pallet_precompile_benchmarks, PrecompileBenchmarks] [pallet_moonbeam_lazy_migrations, MoonbeamLazyMigrations] + [pallet_parameters, Parameters] ); } diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs new file mode 100644 index 0000000000..1be72d1dd2 --- /dev/null +++ b/runtime/moonbase/src/runtime_params.rs @@ -0,0 +1,29 @@ +use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params}; +use crate::{Treasury, Runtime, Balance}; +use crate::currency::{UNIT, SUPPLY_FACTOR}; + +#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::)] +pub mod dynamic_params { + use super::*; + + #[dynamic_pallet_params] + #[codec(index = 0)] + pub mod pallet_referenda { + + #[codec(index = 0)] + pub static SubmissionDeposit: Balance = 10 * UNIT * SUPPLY_FACTOR; + } + +} + +#[cfg(feature = "runtime-benchmarks")] +impl Default for RuntimeParameters { + fn default() -> Self { + RuntimeParameters::PalletReferenda( + runtime_params::dynamic_params::pallet_referenda::Parameters::SubmissionDeposit( + runtime_params::dynamic_params::pallet_referenda::SubmissionDeposit, + Some(10 * UNIT * SUPPLY_FACTOR), + ) + ) + } +} \ No newline at end of file From 2f2ae0b523fbe1f120d2d553d2ff30b963d2eca5 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Tue, 6 Aug 2024 12:24:04 +0100 Subject: [PATCH 02/24] add pallet parameters --- Cargo.lock | 1 + runtime/common/src/apis.rs | 4 ++ .../common/src/weights/pallet_parameters.rs | 60 +++++++++++++++++++ runtime/moonbase/Cargo.toml | 4 ++ runtime/moonbase/src/runtime_params.rs | 4 +- 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 runtime/common/src/weights/pallet_parameters.rs diff --git a/Cargo.lock b/Cargo.lock index ef880365f9..051e47b931 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6373,6 +6373,7 @@ dependencies = [ "pallet-moonbeam-orbiters", "pallet-multisig", "pallet-parachain-staking", + "pallet-parameters", "pallet-precompile-benchmarks", "pallet-preimage", "pallet-proxy", diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index 38912cb7d4..f096c52b96 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -1124,6 +1124,10 @@ macro_rules! impl_runtime_apis_plus_common { hex_literal::hex!( "0d715f2646c8f85767b5d2764bb27826" "04a74d81251e398fd8a0a4d55023bb3f") .to_vec().into(), + // Parameters Parameters + hex_literal::hex!( "c63bdd4a39095ccf55623a6f2872bf8a" + "c63bdd4a39095ccf55623a6f2872bf8a") + .to_vec().into(), ]; diff --git a/runtime/common/src/weights/pallet_parameters.rs b/runtime/common/src/weights/pallet_parameters.rs new file mode 100644 index 0000000000..ed4a72ba2b --- /dev/null +++ b/runtime/common/src/weights/pallet_parameters.rs @@ -0,0 +1,60 @@ +// Copyright 2019-2022 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +//! Autogenerated weights for `pallet_parameters` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-08-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `COV0706`, CPU: `AMD Ryzen 9 7950X 16-Core Processor` +//! WASM-EXECUTION: Compiled, CHAIN: Some("moonbase-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/moonbeam +// benchmark +// pallet +// --chain=moonbase-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_parameters +// --extrinsic=* +// --wasm-execution=compiled +// --header=./file_header.txt +// --template=./benchmarking/frame-weight-template.hbs +// --output=./runtime/common/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weights for `pallet_parameters`. +pub struct WeightInfo(PhantomData); +impl pallet_parameters::WeightInfo for WeightInfo { + /// Storage: `Parameters::Parameters` (r:1 w:1) + /// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + fn set_parameter() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3501` + // Minimum execution time: 5_480_000 picoseconds. + Weight::from_parts(5_610_000, 3501) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} diff --git a/runtime/moonbase/Cargo.toml b/runtime/moonbase/Cargo.toml index f059b33244..b12ede2a83 100644 --- a/runtime/moonbase/Cargo.toml +++ b/runtime/moonbase/Cargo.toml @@ -89,6 +89,7 @@ pallet-conviction-voting = { workspace = true } pallet-identity = { workspace = true } pallet-multisig = { workspace = true } pallet-preimage = { workspace = true } +pallet-parameters = { workspace = true } pallet-proxy = { workspace = true } pallet-referenda = { workspace = true } pallet-root-testing = { workspace = true } @@ -274,6 +275,7 @@ std = [ "pallet-parachain-staking/std", "pallet-precompile-benchmarks/std", "pallet-preimage/std", + "pallet-parameters/std", "pallet-proxy-genesis-companion/std", "pallet-proxy/std", "pallet-randomness/std", @@ -365,6 +367,7 @@ runtime-benchmarks = [ "pallet-parachain-staking/runtime-benchmarks", "pallet-precompile-benchmarks/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", + "pallet-parameters/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-randomness/runtime-benchmarks", "pallet-referenda/runtime-benchmarks", @@ -406,6 +409,7 @@ try-runtime = [ "pallet-moonbeam-lazy-migrations/try-runtime", "pallet-parachain-staking/try-runtime", "pallet-preimage/try-runtime", + "pallet-parameters/try-runtime", "pallet-referenda/try-runtime", "pallet-relay-storage-roots/try-runtime", "pallet-root-testing/try-runtime", diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index 1be72d1dd2..a5bc6906b8 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -20,8 +20,8 @@ pub mod dynamic_params { impl Default for RuntimeParameters { fn default() -> Self { RuntimeParameters::PalletReferenda( - runtime_params::dynamic_params::pallet_referenda::Parameters::SubmissionDeposit( - runtime_params::dynamic_params::pallet_referenda::SubmissionDeposit, + dynamic_params::pallet_referenda::Parameters::SubmissionDeposit( + dynamic_params::pallet_referenda::SubmissionDeposit, Some(10 * UNIT * SUPPLY_FACTOR), ) ) From 795609edd3b2a33aa2e7c41cb8d723930f8ca452 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Tue, 6 Aug 2024 12:41:27 +0100 Subject: [PATCH 03/24] remove unused import --- runtime/moonbase/src/governance/referenda.rs | 1 - runtime/moonbase/src/lib.rs | 1 - runtime/moonbase/src/runtime_params.rs | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/runtime/moonbase/src/governance/referenda.rs b/runtime/moonbase/src/governance/referenda.rs index 91d430cf77..bfa8542786 100644 --- a/runtime/moonbase/src/governance/referenda.rs +++ b/runtime/moonbase/src/governance/referenda.rs @@ -21,7 +21,6 @@ //! 3. pallet-referenda use super::*; -use crate::currency::*; use frame_support::traits::{EitherOf, MapSuccess}; use frame_system::EnsureRootWithSuccess; use moonbeam_runtime_common::weights as moonbeam_weights; diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 59bd4a1499..5c1f4bc7f2 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -59,7 +59,6 @@ use fp_rpc::TransactionStatus; use frame_support::{ construct_runtime, dispatch::{DispatchClass, GetDispatchInfo, PostDispatchInfo}, - dynamic_params::{dynamic_pallet_params, dynamic_params}, ensure, pallet_prelude::DispatchResult, parameter_types, diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index a5bc6906b8..fb03cc2b6c 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -1,5 +1,5 @@ use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params}; -use crate::{Treasury, Runtime, Balance}; +use crate::{Runtime, Balance}; use crate::currency::{UNIT, SUPPLY_FACTOR}; #[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::)] From 3926815114e9b8991b51256543d9dbeff261c90a Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Tue, 6 Aug 2024 15:49:38 +0100 Subject: [PATCH 04/24] XcmFeesAccount --- runtime/moonbase/src/runtime_params.rs | 10 ++++++++++ runtime/moonbase/src/xcm_config.rs | 9 ++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index fb03cc2b6c..5c04ec5cd5 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -1,6 +1,7 @@ use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params}; use crate::{Runtime, Balance}; use crate::currency::{UNIT, SUPPLY_FACTOR}; +use account::AccountId20; #[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::)] pub mod dynamic_params { @@ -14,6 +15,15 @@ pub mod dynamic_params { pub static SubmissionDeposit: Balance = 10 * UNIT * SUPPLY_FACTOR; } + #[dynamic_pallet_params] + #[codec(index = 1)] + pub mod xcm_executor { + + #[codec(index = 0)] + /// Xcm fees will go to the treasury account + pub static XcmFeesAccount: AccountId20 = crate::Treasury::account_id(); + } + } #[cfg(feature = "runtime-benchmarks")] diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index 7b1da02f32..78bf031b04 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -23,7 +23,7 @@ use super::{ ParachainInfo, ParachainSystem, Perbill, PolkadotXcm, Runtime, RuntimeBlockWeights, RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, XcmpQueue, }; -use crate::OpenTechCommitteeInstance; +use crate::{runtime_params, OpenTechCommitteeInstance}; use moonbeam_runtime_common::weights as moonbeam_weights; use moonkit_xcm_primitives::AccountIdAssetIdConversion; use sp_runtime::{ @@ -227,11 +227,6 @@ pub type XcmBarrier = ( >, ); -parameter_types! { - /// Xcm fees will go to the treasury account - pub XcmFeesAccount: AccountId = Treasury::account_id(); -} - /// This is the struct that will handle the revenue from xcm fees /// We do not burn anything because we want to mimic exactly what /// the sovereign account has @@ -246,7 +241,7 @@ pub type XcmFeesToAccount = xcm_primitives::XcmFeesToAccount< >, ), AccountId, - XcmFeesAccount, + runtime_params::dynamic_params::xcm_executor::XcmFeesAccount, >; // Our implementation of the Moonbeam Call From c7c54d29eb40d8066c5d22e23d61b8062b2d4e0a Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Wed, 7 Aug 2024 11:40:49 +0300 Subject: [PATCH 05/24] Update runtime/moonbase/src/lib.rs Co-authored-by: Rodrigo Quelhas <22591718+RomarQ@users.noreply.github.com> --- runtime/moonbase/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 5c1f4bc7f2..5e7b71631f 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -1387,7 +1387,7 @@ impl pallet_parameters::Config for Runtime { type AdminOrigin = EnsureRoot; type RuntimeEvent = RuntimeEvent; type RuntimeParameters = RuntimeParameters; - type WeightInfo = (); + type WeightInfo = moonbase_weights::pallet_parameters::WeightInfo; } construct_runtime! { From 806312aab59eb726d0954b4249c15da93f7fb48b Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Wed, 7 Aug 2024 09:41:26 +0100 Subject: [PATCH 06/24] format --- runtime/moonbase/src/runtime_params.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index 5c04ec5cd5..3908b68d81 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -1,13 +1,13 @@ -use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params}; -use crate::{Runtime, Balance}; -use crate::currency::{UNIT, SUPPLY_FACTOR}; +use crate::currency::{SUPPLY_FACTOR, UNIT}; +use crate::{Balance, Runtime}; use account::AccountId20; +use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params}; #[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::)] pub mod dynamic_params { use super::*; - #[dynamic_pallet_params] + #[dynamic_pallet_params] #[codec(index = 0)] pub mod pallet_referenda { @@ -23,17 +23,16 @@ pub mod dynamic_params { /// Xcm fees will go to the treasury account pub static XcmFeesAccount: AccountId20 = crate::Treasury::account_id(); } - } #[cfg(feature = "runtime-benchmarks")] impl Default for RuntimeParameters { - fn default() -> Self { - RuntimeParameters::PalletReferenda( + fn default() -> Self { + RuntimeParameters::PalletReferenda( dynamic_params::pallet_referenda::Parameters::SubmissionDeposit( dynamic_params::pallet_referenda::SubmissionDeposit, Some(10 * UNIT * SUPPLY_FACTOR), - ) + ), ) - } -} \ No newline at end of file + } +} From 30ef82db88a9df837c397dbe4d2dce6f93f9cfd6 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Wed, 7 Aug 2024 10:15:29 +0100 Subject: [PATCH 07/24] fix --- Cargo.lock | 1 + runtime/common/Cargo.toml | 3 +++ runtime/common/src/weights/mod.rs | 1 + runtime/moonbase/src/xcm_config.rs | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 051e47b931..b770af74ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6967,6 +6967,7 @@ dependencies = [ "pallet-moonbeam-orbiters", "pallet-multisig", "pallet-parachain-staking", + "pallet-parameters", "pallet-precompile-benchmarks", "pallet-preimage", "pallet-proxy", diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 292ba44bbc..8d67fc51a6 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -43,6 +43,7 @@ pallet-identity = { workspace = true } pallet-moonbeam-orbiters = { workspace = true } pallet-multisig = { workspace = true } pallet-preimage = { workspace = true } +pallet-parameters = { workspace = true } pallet-proxy = { workspace = true } pallet-referenda = { workspace = true } pallet-scheduler = { workspace = true } @@ -99,6 +100,7 @@ std = [ "pallet-evm/std", "pallet-migrations/std", "pallet-parachain-staking/std", + "pallet-parameters/std", "pallet-randomness/std", "pallet-referenda/std", "pallet-scheduler/std", @@ -136,6 +138,7 @@ runtime-benchmarks = [ "pallet-multisig/runtime-benchmarks", "pallet-parachain-staking/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", + "pallet-parameters/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-randomness/runtime-benchmarks", "pallet-referenda/runtime-benchmarks", diff --git a/runtime/common/src/weights/mod.rs b/runtime/common/src/weights/mod.rs index 314d5e30c4..256841efe1 100644 --- a/runtime/common/src/weights/mod.rs +++ b/runtime/common/src/weights/mod.rs @@ -36,6 +36,7 @@ pub mod pallet_multisig; pub mod pallet_parachain_staking; pub mod pallet_precompile_benchmarks; pub mod pallet_preimage; +pub mod pallet_parameters; pub mod pallet_proxy; pub mod pallet_randomness; pub mod pallet_referenda; diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index 4070a7079e..e8a78a6018 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -24,7 +24,7 @@ use super::{ RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, XcmpQueue, }; use crate::{runtime_params, OpenTechCommitteeInstance}; -use moonbeam_runtime_common::weights as moonbeam_weights; +use moonbeam_runtime_common::weights as moonbase_weights; use moonkit_xcm_primitives::AccountIdAssetIdConversion; use sp_runtime::{ traits::{Hash as THash, MaybeEquivalence, PostDispatchInfoOf}, From 116732a4634f39e748406797fa7a4a2eae632b17 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Wed, 7 Aug 2024 11:08:58 +0100 Subject: [PATCH 08/24] fix --- runtime/moonbase/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index e8a78a6018..f16e4906fb 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -21,7 +21,7 @@ use super::{ governance, AccountId, AssetId, AssetManager, Balance, Balances, DealWithFees, EmergencyParaXcm, Erc20XcmBridge, EvmForeignAssets, MaintenanceMode, MessageQueue, ParachainInfo, ParachainSystem, Perbill, PolkadotXcm, Runtime, RuntimeBlockWeights, - RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, XcmpQueue, + RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmpQueue, }; use crate::{runtime_params, OpenTechCommitteeInstance}; use moonbeam_runtime_common::weights as moonbase_weights; From bb95d2807f040ffd8209e4430e45343283f4b0e2 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Wed, 7 Aug 2024 11:51:54 +0100 Subject: [PATCH 09/24] fix --- runtime/moonbase/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 96a4da35e3..90adc081fa 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -30,8 +30,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); pub mod asset_config; pub mod governance; -pub mod xcm_config; pub mod runtime_params; +pub mod xcm_config; mod migrations; mod precompiles; @@ -1383,10 +1383,10 @@ impl pallet_precompile_benchmarks::Config for Runtime { } impl pallet_parameters::Config for Runtime { - type AdminOrigin = EnsureRoot; - type RuntimeEvent = RuntimeEvent; - type RuntimeParameters = RuntimeParameters; - type WeightInfo = moonbase_weights::pallet_parameters::WeightInfo; + type AdminOrigin = EnsureRoot; + type RuntimeEvent = RuntimeEvent; + type RuntimeParameters = RuntimeParameters; + type WeightInfo = moonbase_weights::pallet_parameters::WeightInfo; } construct_runtime! { From e4cb2b8515fa895ea2012ca104115e41a34c4ab1 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Wed, 7 Aug 2024 12:03:38 +0100 Subject: [PATCH 10/24] fix --- runtime/common/src/weights/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/weights/mod.rs b/runtime/common/src/weights/mod.rs index 256841efe1..455d46d3b5 100644 --- a/runtime/common/src/weights/mod.rs +++ b/runtime/common/src/weights/mod.rs @@ -34,9 +34,9 @@ pub mod pallet_moonbeam_lazy_migrations; pub mod pallet_moonbeam_orbiters; pub mod pallet_multisig; pub mod pallet_parachain_staking; +pub mod pallet_parameters; pub mod pallet_precompile_benchmarks; pub mod pallet_preimage; -pub mod pallet_parameters; pub mod pallet_proxy; pub mod pallet_randomness; pub mod pallet_referenda; From 921b1dc6bbce64bf0b7de8f78cf71bcf41d16d05 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Wed, 7 Aug 2024 12:14:46 +0100 Subject: [PATCH 11/24] add copyrights --- runtime/moonbase/src/runtime_params.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index 3908b68d81..02e9dd3071 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -1,3 +1,20 @@ +// Copyright 2019-2022 PureStake Inc. +// This file is part of Moonbeam. + +// Moonbeam is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Moonbeam is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Moonbeam. If not, see . + +//! Dynamic runtime parametes. use crate::currency::{SUPPLY_FACTOR, UNIT}; use crate::{Balance, Runtime}; use account::AccountId20; From 081701b7356789c01c93805597f469eed6d36042 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Wed, 7 Aug 2024 12:22:17 +0100 Subject: [PATCH 12/24] fix copyright --- runtime/moonbase/src/runtime_params.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index 02e9dd3071..ea97877c61 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -1,4 +1,4 @@ -// Copyright 2019-2022 PureStake Inc. +// Copyright 2024 Moonbeam Foundation. // This file is part of Moonbeam. // Moonbeam is free software: you can redistribute it and/or modify From e296721da0d06e8d33206e23a2f4c9427be71de9 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Fri, 16 Aug 2024 06:16:59 +0100 Subject: [PATCH 13/24] testing --- .../test-parameters/test-parameters.ts | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 test/suites/dev/moonbase/test-parameters/test-parameters.ts diff --git a/test/suites/dev/moonbase/test-parameters/test-parameters.ts b/test/suites/dev/moonbase/test-parameters/test-parameters.ts new file mode 100644 index 0000000000..fa7f87ae7e --- /dev/null +++ b/test/suites/dev/moonbase/test-parameters/test-parameters.ts @@ -0,0 +1,117 @@ +import { describeSuite, DevModeContext, expect } from "@moonwall/cli"; +import "@moonbeam-network/api-augment"; +import { + alith, baltathar, charleth, dorothy, ethan, faith, goliath, + BALTATHAR_ADDRESS, +} from "@moonwall/util"; +import { jumpRounds } from "../../../../helpers"; +import { hexToU8a } from "@polkadot/util"; + +const UNIT = 1_000_000_000_000_000_000n; + +const RUNTIME = "MoonbaseRuntime"; +const CRATE = "RuntimeParams" +const ALL_PARAMS = "DynamicParams"; + +function parameterType(context: DevModeContext, module: string, name: string, value: unknown) { + const paramWrapper = context + .polkadotJs() + .createType(`${RUNTIME}${CRATE}${ALL_PARAMS}${module}Parameters`, { + [name]: [null, value], + }); + + const runtimeParameter = context + .polkadotJs() + .createType(`${RUNTIME}${CRATE}RuntimeParameters`, { + [module]: paramWrapper + }); + + return runtimeParameter; +} + +function parameterKey(context: DevModeContext, module: string, name: string) { + const key = context + .polkadotJs() + .createType(`${RUNTIME}${CRATE}${ALL_PARAMS}${module}ParametersKey`, { + [name]: null + }); + + const keyWrapper = context + .polkadotJs() + .createType(`${RUNTIME}${CRATE}RuntimeParametersKey`, { + [module]: key + }); + + return keyWrapper; +} + +describeSuite({ + id: "DTemp01", + title: "Parameters", + foundationMethods: "dev", + testCases: ({ it, context, log }) => { + + let testCounter = 0; + function testParam(module: string, name: string, valueCreation: [string, unknown]) { + it({ + id: `T${testCounter++} - ${module} - ${name}`, + title: "Parameters cannot be changed by normal user", + test: async () => { + const value = context.polkadotJs().createType(valueCreation[0], valueCreation[1]); + const param = parameterType( + context, module, name, value, + ); + + const res = await context.createBlock( + context + .polkadotJs() + .tx.parameters.setParameter(param.toU8a()) + .signAsync(alith), + { allowFailures: true } + ); + expect(res.result?.error?.name).toEqual("BadOrigin"); + } + }); + + it({ + id: `T${testCounter++} - ${module} - ${name}`, + title: "Parameters can be changed by root user", + test: async () => { + const value = context.polkadotJs().createType(valueCreation[0], valueCreation[1]); + const param = parameterType( + context, module, name, value, + ); + + await context.createBlock( + context + .polkadotJs() + .tx.sudo.sudo(context.polkadotJs().tx.parameters.setParameter(param.toU8a())) + .signAsync(alith), + { allowFailures: false } + ); + + const key = parameterKey( + context, module, name, + ); + + const wrappedValue = await context.polkadotJs().query.parameters.parameters(key.toU8a()); + const gotValue = wrappedValue.value.value.value.toU8a(); + expect(gotValue).toEqual(value.toU8a()); + } + }); + } + + + testParam( + "PalletReferenda", + "SubmissionDeposit", + ["Balance", 55n * UNIT], + ); + + testParam( + "XcmExecutor", + "XcmFeesAccount", + ["AccountId20", hexToU8a(BALTATHAR_ADDRESS)], + ); + }, +}) \ No newline at end of file From a4546e0df9f7aebec250e48dedb7b47603308622 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Fri, 16 Aug 2024 13:06:29 +0100 Subject: [PATCH 14/24] remove unused --- test/suites/dev/moonbase/test-parameters/test-parameters.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/suites/dev/moonbase/test-parameters/test-parameters.ts b/test/suites/dev/moonbase/test-parameters/test-parameters.ts index fa7f87ae7e..0cccd3bf13 100644 --- a/test/suites/dev/moonbase/test-parameters/test-parameters.ts +++ b/test/suites/dev/moonbase/test-parameters/test-parameters.ts @@ -1,10 +1,6 @@ import { describeSuite, DevModeContext, expect } from "@moonwall/cli"; import "@moonbeam-network/api-augment"; -import { - alith, baltathar, charleth, dorothy, ethan, faith, goliath, - BALTATHAR_ADDRESS, -} from "@moonwall/util"; -import { jumpRounds } from "../../../../helpers"; +import {alith, BALTATHAR_ADDRESS} from "@moonwall/util"; import { hexToU8a } from "@polkadot/util"; const UNIT = 1_000_000_000_000_000_000n; From 150e8168df9649e3214c5e631a53aef5bf7b2ad0 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Fri, 16 Aug 2024 13:19:54 +0100 Subject: [PATCH 15/24] format --- .../test-parameters/test-parameters.ts | 171 ++++++++---------- 1 file changed, 74 insertions(+), 97 deletions(-) diff --git a/test/suites/dev/moonbase/test-parameters/test-parameters.ts b/test/suites/dev/moonbase/test-parameters/test-parameters.ts index 0cccd3bf13..f2aa2d6bb3 100644 --- a/test/suites/dev/moonbase/test-parameters/test-parameters.ts +++ b/test/suites/dev/moonbase/test-parameters/test-parameters.ts @@ -1,113 +1,90 @@ import { describeSuite, DevModeContext, expect } from "@moonwall/cli"; import "@moonbeam-network/api-augment"; -import {alith, BALTATHAR_ADDRESS} from "@moonwall/util"; +import { alith, BALTATHAR_ADDRESS } from "@moonwall/util"; import { hexToU8a } from "@polkadot/util"; const UNIT = 1_000_000_000_000_000_000n; const RUNTIME = "MoonbaseRuntime"; -const CRATE = "RuntimeParams" +const CRATE = "RuntimeParams"; const ALL_PARAMS = "DynamicParams"; function parameterType(context: DevModeContext, module: string, name: string, value: unknown) { - const paramWrapper = context - .polkadotJs() - .createType(`${RUNTIME}${CRATE}${ALL_PARAMS}${module}Parameters`, { - [name]: [null, value], - }); - - const runtimeParameter = context - .polkadotJs() - .createType(`${RUNTIME}${CRATE}RuntimeParameters`, { - [module]: paramWrapper - }); - - return runtimeParameter; + const paramWrapper = context + .polkadotJs() + .createType(`${RUNTIME}${CRATE}${ALL_PARAMS}${module}Parameters`, { + [name]: [null, value], + }); + + const runtimeParameter = context.polkadotJs().createType(`${RUNTIME}${CRATE}RuntimeParameters`, { + [module]: paramWrapper, + }); + + return runtimeParameter; } function parameterKey(context: DevModeContext, module: string, name: string) { - const key = context - .polkadotJs() - .createType(`${RUNTIME}${CRATE}${ALL_PARAMS}${module}ParametersKey`, { - [name]: null - }); - - const keyWrapper = context - .polkadotJs() - .createType(`${RUNTIME}${CRATE}RuntimeParametersKey`, { - [module]: key - }); - - return keyWrapper; + const key = context + .polkadotJs() + .createType(`${RUNTIME}${CRATE}${ALL_PARAMS}${module}ParametersKey`, { + [name]: null, + }); + + const keyWrapper = context.polkadotJs().createType(`${RUNTIME}${CRATE}RuntimeParametersKey`, { + [module]: key, + }); + + return keyWrapper; } describeSuite({ - id: "DTemp01", - title: "Parameters", - foundationMethods: "dev", - testCases: ({ it, context, log }) => { - - let testCounter = 0; - function testParam(module: string, name: string, valueCreation: [string, unknown]) { - it({ - id: `T${testCounter++} - ${module} - ${name}`, - title: "Parameters cannot be changed by normal user", - test: async () => { - const value = context.polkadotJs().createType(valueCreation[0], valueCreation[1]); - const param = parameterType( - context, module, name, value, - ); - - const res = await context.createBlock( - context - .polkadotJs() - .tx.parameters.setParameter(param.toU8a()) - .signAsync(alith), - { allowFailures: true } - ); - expect(res.result?.error?.name).toEqual("BadOrigin"); - } - }); - - it({ - id: `T${testCounter++} - ${module} - ${name}`, - title: "Parameters can be changed by root user", - test: async () => { - const value = context.polkadotJs().createType(valueCreation[0], valueCreation[1]); - const param = parameterType( - context, module, name, value, - ); - - await context.createBlock( - context - .polkadotJs() - .tx.sudo.sudo(context.polkadotJs().tx.parameters.setParameter(param.toU8a())) - .signAsync(alith), - { allowFailures: false } - ); - - const key = parameterKey( - context, module, name, - ); - - const wrappedValue = await context.polkadotJs().query.parameters.parameters(key.toU8a()); - const gotValue = wrappedValue.value.value.value.toU8a(); - expect(gotValue).toEqual(value.toU8a()); - } - }); - } - - - testParam( - "PalletReferenda", - "SubmissionDeposit", - ["Balance", 55n * UNIT], - ); - - testParam( - "XcmExecutor", - "XcmFeesAccount", - ["AccountId20", hexToU8a(BALTATHAR_ADDRESS)], - ); - }, -}) \ No newline at end of file + id: "DTemp01", + title: "Parameters", + foundationMethods: "dev", + testCases: ({ it, context, log }) => { + let testCounter = 0; + function testParam(module: string, name: string, valueCreation: [string, unknown]) { + it({ + id: `T${testCounter++} - ${module} - ${name}`, + title: "Parameters cannot be changed by normal user", + test: async () => { + const value = context.polkadotJs().createType(valueCreation[0], valueCreation[1]); + const param = parameterType(context, module, name, value); + + const res = await context.createBlock( + context.polkadotJs().tx.parameters.setParameter(param.toU8a()).signAsync(alith), + { allowFailures: true } + ); + expect(res.result?.error?.name).toEqual("BadOrigin"); + }, + }); + + it({ + id: `T${testCounter++} - ${module} - ${name}`, + title: "Parameters can be changed by root user", + test: async () => { + const value = context.polkadotJs().createType(valueCreation[0], valueCreation[1]); + const param = parameterType(context, module, name, value); + + await context.createBlock( + context + .polkadotJs() + .tx.sudo.sudo(context.polkadotJs().tx.parameters.setParameter(param.toU8a())) + .signAsync(alith), + { allowFailures: false } + ); + + const key = parameterKey(context, module, name); + + const wrappedValue = await context.polkadotJs().query.parameters.parameters(key.toU8a()); + const gotValue = wrappedValue.value.value.value.toU8a(); + expect(gotValue).toEqual(value.toU8a()); + }, + }); + } + + testParam("PalletReferenda", "SubmissionDeposit", ["Balance", 55n * UNIT]); + + testParam("XcmExecutor", "XcmFeesAccount", ["AccountId20", hexToU8a(BALTATHAR_ADDRESS)]); + }, +}); From d731b4069f8aa0e462586a3f45cd196370a06d5b Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Thu, 22 Aug 2024 12:23:41 +0100 Subject: [PATCH 16/24] add FeesTreasuryPercentage --- runtime/moonbase/src/lib.rs | 6 ++++-- runtime/moonbase/src/runtime_params.rs | 10 +++++++++- .../dev/moonbase/test-parameters/test-parameters.ts | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 90adc081fa..fbe572b034 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -351,8 +351,10 @@ where mut fees_then_tips: impl Iterator>>, ) { if let Some(fees) = fees_then_tips.next() { - // for fees, 80% are burned, 20% to the treasury - let (_, to_treasury) = fees.ration(80, 20); + let treasury_perbill = runtime_params::dynamic_params::runtime_config::FeesTreasuryPercentage::get(); + let treasury_part = treasury_perbill.deconstruct(); + let burn_part = Perbill::one().deconstruct() - treasury_part; + let (_, to_treasury) = fees.ration(burn_part, treasury_part); // Balances pallet automatically burns dropped Credits by decreasing // total_supply accordingly ResolveTo::, pallet_balances::Pallet>::on_unbalanced( diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index ea97877c61..df8540fa82 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -19,6 +19,7 @@ use crate::currency::{SUPPLY_FACTOR, UNIT}; use crate::{Balance, Runtime}; use account::AccountId20; use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params}; +use sp_runtime::Perbill; #[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::)] pub mod dynamic_params { @@ -26,6 +27,13 @@ pub mod dynamic_params { #[dynamic_pallet_params] #[codec(index = 0)] + pub mod runtime_config { + // for fees, 80% are burned, 20% to the treasury + #[codec(index = 0)] + pub static FeesTreasuryPercentage: Perbill = Perbill::from_percent(20); + } + #[dynamic_pallet_params] + #[codec(index = 1)] pub mod pallet_referenda { #[codec(index = 0)] @@ -33,7 +41,7 @@ pub mod dynamic_params { } #[dynamic_pallet_params] - #[codec(index = 1)] + #[codec(index = 2)] pub mod xcm_executor { #[codec(index = 0)] diff --git a/test/suites/dev/moonbase/test-parameters/test-parameters.ts b/test/suites/dev/moonbase/test-parameters/test-parameters.ts index f2aa2d6bb3..b941617789 100644 --- a/test/suites/dev/moonbase/test-parameters/test-parameters.ts +++ b/test/suites/dev/moonbase/test-parameters/test-parameters.ts @@ -86,5 +86,7 @@ describeSuite({ testParam("PalletReferenda", "SubmissionDeposit", ["Balance", 55n * UNIT]); testParam("XcmExecutor", "XcmFeesAccount", ["AccountId20", hexToU8a(BALTATHAR_ADDRESS)]); + + testParam("RuntimeConfig", "FeesTreasuryPercentage", ["Perbill", 200_000_000]); }, }); From b276f546eb6c0b51b5fb21edcf4b9f2a23bf5d32 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Thu, 22 Aug 2024 14:29:08 +0100 Subject: [PATCH 17/24] fmt --- runtime/moonbase/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index fbe572b034..920705a144 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -351,8 +351,9 @@ where mut fees_then_tips: impl Iterator>>, ) { if let Some(fees) = fees_then_tips.next() { - let treasury_perbill = runtime_params::dynamic_params::runtime_config::FeesTreasuryPercentage::get(); - let treasury_part = treasury_perbill.deconstruct(); + let treasury_perbill = + runtime_params::dynamic_params::runtime_config::FeesTreasuryPercentage::get(); + let treasury_part = treasury_perbill.deconstruct(); let burn_part = Perbill::one().deconstruct() - treasury_part; let (_, to_treasury) = fees.ration(burn_part, treasury_part); // Balances pallet automatically burns dropped Credits by decreasing From 8b498d47ea40be5af4e5c8d10f377bf5113919b5 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Fri, 23 Aug 2024 09:04:12 +0100 Subject: [PATCH 18/24] revert --- runtime/moonbase/src/governance/referenda.rs | 3 ++- runtime/moonbase/src/runtime_params.rs | 17 ----------------- runtime/moonbase/src/xcm_config.rs | 9 +++++++-- .../moonbase/test-parameters/test-parameters.ts | 4 ---- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/runtime/moonbase/src/governance/referenda.rs b/runtime/moonbase/src/governance/referenda.rs index 0089a1a33c..d856b0d43d 100644 --- a/runtime/moonbase/src/governance/referenda.rs +++ b/runtime/moonbase/src/governance/referenda.rs @@ -44,6 +44,7 @@ impl pallet_conviction_voting::Config for Runtime { parameter_types! { pub const AlarmInterval: BlockNumber = 1; + pub const SubmissionDeposit: Balance = 10 * UNIT * SUPPLY_FACTOR; pub const UndecidingTimeout: BlockNumber = 21 * DAYS; } @@ -90,7 +91,7 @@ impl pallet_referenda::Config for Runtime { type Slash = Treasury; type Votes = pallet_conviction_voting::VotesOf; type Tally = pallet_conviction_voting::TallyOf; - type SubmissionDeposit = runtime_params::dynamic_params::pallet_referenda::SubmissionDeposit; + type SubmissionDeposit = SubmissionDeposit; type MaxQueued = ConstU32<100>; type UndecidingTimeout = UndecidingTimeout; type AlarmInterval = AlarmInterval; diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index df8540fa82..e7b57700c8 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -24,7 +24,6 @@ use sp_runtime::Perbill; #[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::)] pub mod dynamic_params { use super::*; - #[dynamic_pallet_params] #[codec(index = 0)] pub mod runtime_config { @@ -32,22 +31,6 @@ pub mod dynamic_params { #[codec(index = 0)] pub static FeesTreasuryPercentage: Perbill = Perbill::from_percent(20); } - #[dynamic_pallet_params] - #[codec(index = 1)] - pub mod pallet_referenda { - - #[codec(index = 0)] - pub static SubmissionDeposit: Balance = 10 * UNIT * SUPPLY_FACTOR; - } - - #[dynamic_pallet_params] - #[codec(index = 2)] - pub mod xcm_executor { - - #[codec(index = 0)] - /// Xcm fees will go to the treasury account - pub static XcmFeesAccount: AccountId20 = crate::Treasury::account_id(); - } } #[cfg(feature = "runtime-benchmarks")] diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index f16e4906fb..34f3febf3d 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -23,7 +23,7 @@ use super::{ ParachainInfo, ParachainSystem, Perbill, PolkadotXcm, Runtime, RuntimeBlockWeights, RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmpQueue, }; -use crate::{runtime_params, OpenTechCommitteeInstance}; +use crate::OpenTechCommitteeInstance; use moonbeam_runtime_common::weights as moonbase_weights; use moonkit_xcm_primitives::AccountIdAssetIdConversion; use sp_runtime::{ @@ -227,6 +227,11 @@ pub type XcmBarrier = ( >, ); +parameter_types! { + /// Xcm fees will go to the treasury account + pub XcmFeesAccount: AccountId = Treasury::account_id(); +} + /// This is the struct that will handle the revenue from xcm fees /// We do not burn anything because we want to mimic exactly what /// the sovereign account has @@ -241,7 +246,7 @@ pub type XcmFeesToAccount = xcm_primitives::XcmFeesToAccount< >, ), AccountId, - runtime_params::dynamic_params::xcm_executor::XcmFeesAccount, + XcmFeesAccount, >; // Our implementation of the Moonbeam Call diff --git a/test/suites/dev/moonbase/test-parameters/test-parameters.ts b/test/suites/dev/moonbase/test-parameters/test-parameters.ts index b941617789..bd94b41663 100644 --- a/test/suites/dev/moonbase/test-parameters/test-parameters.ts +++ b/test/suites/dev/moonbase/test-parameters/test-parameters.ts @@ -83,10 +83,6 @@ describeSuite({ }); } - testParam("PalletReferenda", "SubmissionDeposit", ["Balance", 55n * UNIT]); - - testParam("XcmExecutor", "XcmFeesAccount", ["AccountId20", hexToU8a(BALTATHAR_ADDRESS)]); - testParam("RuntimeConfig", "FeesTreasuryPercentage", ["Perbill", 200_000_000]); }, }); From 8e7c049552aec5a1fcfc10adc67f9b9e379f6555 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Fri, 23 Aug 2024 09:26:48 +0100 Subject: [PATCH 19/24] fix --- runtime/moonbase/src/governance/referenda.rs | 1 + runtime/moonbase/src/runtime_params.rs | 4 +--- runtime/moonbase/src/xcm_config.rs | 2 +- test/suites/dev/moonbase/test-parameters/test-parameters.ts | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/runtime/moonbase/src/governance/referenda.rs b/runtime/moonbase/src/governance/referenda.rs index d856b0d43d..36cd0420e6 100644 --- a/runtime/moonbase/src/governance/referenda.rs +++ b/runtime/moonbase/src/governance/referenda.rs @@ -21,6 +21,7 @@ //! 3. pallet-referenda use super::*; +use crate::currency::*; use frame_support::traits::{EitherOf, MapSuccess}; use frame_system::EnsureRootWithSuccess; use moonbeam_runtime_common::weights as moonbase_weights; diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index e7b57700c8..d0f18c7e8a 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -15,9 +15,7 @@ // along with Moonbeam. If not, see . //! Dynamic runtime parametes. -use crate::currency::{SUPPLY_FACTOR, UNIT}; -use crate::{Balance, Runtime}; -use account::AccountId20; +use crate::Runtime; use frame_support::dynamic_params::{dynamic_pallet_params, dynamic_params}; use sp_runtime::Perbill; diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index 34f3febf3d..4e44f607a4 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -21,7 +21,7 @@ use super::{ governance, AccountId, AssetId, AssetManager, Balance, Balances, DealWithFees, EmergencyParaXcm, Erc20XcmBridge, EvmForeignAssets, MaintenanceMode, MessageQueue, ParachainInfo, ParachainSystem, Perbill, PolkadotXcm, Runtime, RuntimeBlockWeights, - RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmpQueue, + RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, XcmpQueue, }; use crate::OpenTechCommitteeInstance; use moonbeam_runtime_common::weights as moonbase_weights; diff --git a/test/suites/dev/moonbase/test-parameters/test-parameters.ts b/test/suites/dev/moonbase/test-parameters/test-parameters.ts index bd94b41663..edc956d326 100644 --- a/test/suites/dev/moonbase/test-parameters/test-parameters.ts +++ b/test/suites/dev/moonbase/test-parameters/test-parameters.ts @@ -1,7 +1,6 @@ import { describeSuite, DevModeContext, expect } from "@moonwall/cli"; import "@moonbeam-network/api-augment"; -import { alith, BALTATHAR_ADDRESS } from "@moonwall/util"; -import { hexToU8a } from "@polkadot/util"; +import { alith } from "@moonwall/util"; const UNIT = 1_000_000_000_000_000_000n; From 68bb6ccdf8be69ff32526bb55b6df34bff3e005d Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Fri, 23 Aug 2024 12:17:02 +0100 Subject: [PATCH 20/24] fix --- runtime/moonbase/src/runtime_params.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index d0f18c7e8a..0db9c356fc 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -34,10 +34,10 @@ pub mod dynamic_params { #[cfg(feature = "runtime-benchmarks")] impl Default for RuntimeParameters { fn default() -> Self { - RuntimeParameters::PalletReferenda( - dynamic_params::pallet_referenda::Parameters::SubmissionDeposit( - dynamic_params::pallet_referenda::SubmissionDeposit, - Some(10 * UNIT * SUPPLY_FACTOR), + RuntimeParameters::RuntimeConfig( + dynamic_params::runtime_config::Parameters::FeesTreasuryPercentage( + dynamic_params::runtime_config::FeesTreasuryPercentage, + Some(Perbill::from_percent(20)), ), ) } From 77e2ee78a9dd6553682134551b26d7b857183741 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Tue, 27 Aug 2024 13:03:52 +0100 Subject: [PATCH 21/24] rename to FeesTreasuryProportion --- runtime/moonbase/src/lib.rs | 2 +- runtime/moonbase/src/runtime_params.rs | 6 +++--- test/suites/dev/moonbase/test-parameters/test-parameters.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 920705a144..37d8bc5650 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -352,7 +352,7 @@ where ) { if let Some(fees) = fees_then_tips.next() { let treasury_perbill = - runtime_params::dynamic_params::runtime_config::FeesTreasuryPercentage::get(); + runtime_params::dynamic_params::runtime_config::FeesTreasuryProportion::get(); let treasury_part = treasury_perbill.deconstruct(); let burn_part = Perbill::one().deconstruct() - treasury_part; let (_, to_treasury) = fees.ration(burn_part, treasury_part); diff --git a/runtime/moonbase/src/runtime_params.rs b/runtime/moonbase/src/runtime_params.rs index 0db9c356fc..4916cc27df 100644 --- a/runtime/moonbase/src/runtime_params.rs +++ b/runtime/moonbase/src/runtime_params.rs @@ -27,7 +27,7 @@ pub mod dynamic_params { pub mod runtime_config { // for fees, 80% are burned, 20% to the treasury #[codec(index = 0)] - pub static FeesTreasuryPercentage: Perbill = Perbill::from_percent(20); + pub static FeesTreasuryProportion: Perbill = Perbill::from_percent(20); } } @@ -35,8 +35,8 @@ pub mod dynamic_params { impl Default for RuntimeParameters { fn default() -> Self { RuntimeParameters::RuntimeConfig( - dynamic_params::runtime_config::Parameters::FeesTreasuryPercentage( - dynamic_params::runtime_config::FeesTreasuryPercentage, + dynamic_params::runtime_config::Parameters::FeesTreasuryProportion( + dynamic_params::runtime_config::FeesTreasuryProportion, Some(Perbill::from_percent(20)), ), ) diff --git a/test/suites/dev/moonbase/test-parameters/test-parameters.ts b/test/suites/dev/moonbase/test-parameters/test-parameters.ts index edc956d326..8ff2b8cd9a 100644 --- a/test/suites/dev/moonbase/test-parameters/test-parameters.ts +++ b/test/suites/dev/moonbase/test-parameters/test-parameters.ts @@ -82,6 +82,6 @@ describeSuite({ }); } - testParam("RuntimeConfig", "FeesTreasuryPercentage", ["Perbill", 200_000_000]); + testParam("RuntimeConfig", "FeesTreasuryProportion", ["Perbill", 200_000_000]); }, }); From efd180439fa9848ec91eb426be1afe69ecdcccc4 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Thu, 29 Aug 2024 12:59:27 +0100 Subject: [PATCH 22/24] fix the white list --- runtime/common/src/apis.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index f096c52b96..8db35974c0 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -1125,8 +1125,10 @@ macro_rules! impl_runtime_apis_plus_common { "04a74d81251e398fd8a0a4d55023bb3f") .to_vec().into(), // Parameters Parameters - hex_literal::hex!( "c63bdd4a39095ccf55623a6f2872bf8a" - "c63bdd4a39095ccf55623a6f2872bf8a") + hex_literal::hex!( "c63bdd4a39095ccf55623a6f2872bf8a" // Pallet: "Parameters" + "c63bdd4a39095ccf55623a6f2872bf8a" // Storage Prefix: "Parameters" + "71d0aacb690b61280d0c97c6b6a666640000" // MoonbaseRuntimeRuntimeParamsRuntimeParametersKey(FeesTreasuryProportion) + ) .to_vec().into(), ]; From 26b7e7cb4f1cd9a28a8b1c935010d6ee14b7085d Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Thu, 29 Aug 2024 14:26:11 +0100 Subject: [PATCH 23/24] fix line --- runtime/common/src/apis.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index 8db35974c0..1123fa0387 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -1127,7 +1127,8 @@ macro_rules! impl_runtime_apis_plus_common { // Parameters Parameters hex_literal::hex!( "c63bdd4a39095ccf55623a6f2872bf8a" // Pallet: "Parameters" "c63bdd4a39095ccf55623a6f2872bf8a" // Storage Prefix: "Parameters" - "71d0aacb690b61280d0c97c6b6a666640000" // MoonbaseRuntimeRuntimeParamsRuntimeParametersKey(FeesTreasuryProportion) + // MoonbaseRuntimeRuntimeParamsRuntimeParametersKey(FeesTreasuryProportion) + "71d0aacb690b61280d0c97c6b6a666640000" ) .to_vec().into(), From f6ca687d1dde03f1c94152d01462ae49e338bd8a Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Thu, 29 Aug 2024 14:32:52 +0100 Subject: [PATCH 24/24] fmt --- runtime/common/src/apis.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index 1123fa0387..d9aa574eaa 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -1128,7 +1128,7 @@ macro_rules! impl_runtime_apis_plus_common { hex_literal::hex!( "c63bdd4a39095ccf55623a6f2872bf8a" // Pallet: "Parameters" "c63bdd4a39095ccf55623a6f2872bf8a" // Storage Prefix: "Parameters" // MoonbaseRuntimeRuntimeParamsRuntimeParametersKey(FeesTreasuryProportion) - "71d0aacb690b61280d0c97c6b6a666640000" + "71d0aacb690b61280d0c97c6b6a666640000" ) .to_vec().into(),