Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FRAME] Parameters pallet #2061

Merged
merged 62 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8bdbbec
Import pallet from ORML
ggwpez Oct 26, 2023
2381a0b
Change everything
ggwpez Oct 27, 2023
c0a7538
Deploy to rococo
ggwpez Oct 27, 2023
ec974c6
Adds proc macros for dynamic params
gupnik Nov 6, 2023
f5fa37a
Adds attr support
gupnik Nov 6, 2023
b8099db
Merge branch 'master' of github.com:paritytech/polkadot-sdk into oty-…
gupnik Nov 10, 2023
5dad373
Try in kitchensink example pallet
ggwpez Nov 24, 2023
2c3043c
Fix macro
ggwpez Nov 24, 2023
b2cb9ff
fmt
ggwpez Nov 24, 2023
cc4dec1
Fixes parser
gupnik Nov 27, 2023
28d3f18
Cleanup and fixes
ggwpez Dec 4, 2023
188e393
Fixes
ggwpez Dec 5, 2023
2deb2ab
Remove old stuff
ggwpez Dec 5, 2023
04bde56
Merge remote-tracking branch 'origin/master' into oty-parameters-pallet
ggwpez Jan 8, 2024
811b023
fmt
ggwpez Jan 8, 2024
e48118b
Add ORML compatibility tests
ggwpez Jan 8, 2024
27c741c
Fork ORML traits
ggwpez Jan 8, 2024
777f4bc
Fix
ggwpez Jan 8, 2024
ad573f7
Merge remote-tracking branch 'origin/master' into oty-parameters-pallet
ggwpez Jan 25, 2024
4bdf258
fmt
ggwpez Jan 25, 2024
46230b1
Rename ORML traits
ggwpez Jan 25, 2024
65eb8c7
Remove ORML macros
ggwpez Jan 25, 2024
1a3c615
Add docs and remove old tests
ggwpez Jan 25, 2024
cabaed4
Add tests
ggwpez Jan 25, 2024
64146c3
Use explicit type
ggwpez Jan 25, 2024
db90aa5
Clippy
ggwpez Jan 25, 2024
436cf13
Add PrDoc
ggwpez Jan 25, 2024
d977599
Revert Rococo deployment - can be done later
ggwpez Jan 25, 2024
fae55cc
Update
ggwpez Jan 29, 2024
bb08742
Cleanup macros
ggwpez Jan 30, 2024
877ba5c
Fix features
ggwpez Jan 30, 2024
9a79aed
Merge remote-tracking branch 'origin/master' into oty-parameters-pallet
ggwpez Jan 30, 2024
c11a3db
No duplicate bench
ggwpez Jan 30, 2024
66ebbe3
Fixup
ggwpez Jan 31, 2024
f31cd80
Add benchmark
ggwpez Jan 31, 2024
d42412b
Fix kitchensink
ggwpez Feb 1, 2024
9968cdf
Clippy
ggwpez Feb 1, 2024
64e6d12
Merge remote-tracking branch 'origin/master' into oty-parameters-pallet
ggwpez Feb 1, 2024
4ce3862
Add error when index is missing
ggwpez Feb 1, 2024
15a1e28
Fix test
ggwpez Feb 1, 2024
fd69b6d
Update substrate/frame/parameters/src/lib.rs
ggwpez Feb 5, 2024
9832196
Fix prdoc
ggwpez Feb 5, 2024
5a3b67f
Rename to RuntimeParameters
ggwpez Feb 5, 2024
4fe37b6
Introduce default config
ggwpez Feb 5, 2024
19cee20
Deploy benchmarks for kitchensink
ggwpez Feb 5, 2024
f980bef
toml format
ggwpez Feb 5, 2024
9b5b4d2
Fix doc links
ggwpez Feb 5, 2024
b518928
Fix UI tests
ggwpez Feb 5, 2024
38aea42
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Feb 5, 2024
39fd233
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Feb 5, 2024
6096f08
Review fixes
ggwpez Feb 7, 2024
2ad0f6e
Rename AggregatedKey -> Key and Value
ggwpez Feb 7, 2024
e6d02b0
Review fixes
ggwpez Feb 7, 2024
2d68aba
Require RuntimeParameters: Default for benchmarks
ggwpez Feb 7, 2024
bbd2504
Linters
ggwpez Feb 7, 2024
095d245
Make compile
ggwpez Feb 7, 2024
b40bc32
Merge branch 'master' into oty-parameters-pallet
ggwpez Feb 7, 2024
aeb3ab6
Remove unused dep
ggwpez Feb 7, 2024
1669a7c
Merge remote-tracking branch 'origin/oty-parameters-pallet' into oty-…
ggwpez Feb 7, 2024
0d0ebb9
Merge branch 'master' into oty-parameters-pallet
ggwpez Feb 8, 2024
a696893
Fix and test renaming
ggwpez Feb 8, 2024
d63d07c
Merge remote-tracking branch 'origin/master' into oty-parameters-pallet
ggwpez Feb 8, 2024
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: 24 additions & 4 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ members = [
"substrate/frame/election-provider-support/solution-type/fuzzer",
"substrate/frame/elections-phragmen",
"substrate/frame/examples",
"substrate/frame/parameters",
"substrate/frame/examples/basic",
"substrate/frame/examples/default-config",
"substrate/frame/examples/dev-mode",
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ frame-support = { path = "../../../substrate/frame/support", default-features =
pallet-staking = { path = "../../../substrate/frame/staking", default-features = false }
frame-system = { path = "../../../substrate/frame/system", default-features = false }
frame-system-rpc-runtime-api = { path = "../../../substrate/frame/system/rpc/runtime-api", default-features = false }
pallet-parameters = { path = "../../../substrate/frame/parameters", default-features = false }
pallet-timestamp = { path = "../../../substrate/frame/timestamp", default-features = false }
pallet-tips = { path = "../../../substrate/frame/tips", default-features = false }
pallet-treasury = { path = "../../../substrate/frame/treasury", default-features = false }
Expand Down
99 changes: 83 additions & 16 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ use frame_system::EnsureRoot;
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_identity::simple::IdentityInfo;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_parameters::define_aggregrated_parameters;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
use sp_core::{ConstU128, OpaqueMetadata, H256};
Expand Down Expand Up @@ -137,7 +138,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("rococo"),
impl_name: create_runtime_str!("parity-rococo-v2.0"),
authoring_version: 0,
spec_version: 10020,
spec_version: 8888,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 22,
Expand Down Expand Up @@ -229,8 +230,6 @@ impl pallet_scheduler::Config for Runtime {
}

parameter_types! {
pub const PreimageBaseDeposit: Balance = deposit(2, 64);
pub const PreimageByteDeposit: Balance = deposit(0, 1);
pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
}

Expand All @@ -243,7 +242,11 @@ impl pallet_preimage::Config for Runtime {
AccountId,
Balances,
PreimageHoldReason,
LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
LinearStoragePrice<
dynamic_params::preimage::BaseDeposit,
dynamic_params::preimage::ByteDeposit,
Balance,
>,
>;
}

Expand Down Expand Up @@ -1095,12 +1098,11 @@ impl pallet_balances::Config<NisCounterpartInstance> for Runtime {

parameter_types! {
pub const NisBasePeriod: BlockNumber = 30 * DAYS;
pub const MinBid: Balance = 100 * UNITS;
pub MinReceipt: Perquintill = Perquintill::from_rational(1u64, 10_000_000u64);
pub const IntakePeriod: BlockNumber = 5 * MINUTES;
pub MaxIntakeWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
pub storage NisTarget: Perquintill = Perquintill::zero();
pub const NisMinBid: Balance = 100 * UNITS;
pub NisMinReceipt: Perquintill = Perquintill::from_rational(1u64, 10_000_000u64);
pub const NisIntakePeriod: BlockNumber = 5 * MINUTES;
pub NisMaxIntakeWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
pub const NisThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
pub const NisPalletId: PalletId = PalletId(*b"py/nis ");
}

Expand All @@ -1114,17 +1116,17 @@ impl pallet_nis::Config for Runtime {
type CounterpartAmount = WithMaximumOf<ConstU128<21_000_000_000_000_000_000u128>>;
type Deficit = (); // Mint
type IgnoredIssuance = ();
type Target = NisTarget;
type Target = dynamic_params::nis::NisTarget;
type PalletId = NisPalletId;
type QueueCount = ConstU32<300>;
type MaxQueueLen = ConstU32<1000>;
type FifoQueueLen = ConstU32<250>;
type BasePeriod = NisBasePeriod;
type MinBid = MinBid;
type MinReceipt = MinReceipt;
type IntakePeriod = IntakePeriod;
type MaxIntakeWeight = MaxIntakeWeight;
type ThawThrottle = ThawThrottle;
type MinBid = NisMinBid;
type MinReceipt = NisMinReceipt;
type IntakePeriod = NisIntakePeriod;
type MaxIntakeWeight = NisMaxIntakeWeight;
type ThawThrottle = NisThawThrottle;
type RuntimeHoldReason = RuntimeHoldReason;
}

Expand Down Expand Up @@ -1242,6 +1244,68 @@ impl pallet_asset_rate::Config for Runtime {
type BenchmarkHelper = runtime_common::impls::benchmarks::AssetRateArguments;
}

use frame_system::EnsureRootWithSuccess;
use pallet_parameters::define_parameters;
use sp_runtime::traits::ConstBool;

/// Dynamic parameters that can be set by Root without a runtime upgrade.
///
/// All parameters expose metadata and docs.
pub mod dynamic_params {
use super::*;

/// Dynamic params for [`pallet_nis`].
pub mod nis {
use super::*;

define_parameters! {
pub NisParams = {
/// Configures [`pallet_nis::Config::Target`].
#[codec(index = 0)]
NisTarget: Perquintill = Perquintill::zero(),
},
Pallet = pallet_parameters::Parameters::<Runtime>,
Aggregation = RuntimeParameters::Nis
}
}

/// Dynamic params for [`pallet_preimage`].
pub mod preimage {
use super::*;

define_parameters! {
pub PreimageParams = {
/// Configures the base deposit of noting a preimage.
#[codec(index = 0)]
BaseDeposit: Balance = deposit(2, 64),

/// Configures the per-byte deposit of noting a preimage.
#[codec(index = 1)]
ByteDeposit: Balance = deposit(0, 1),
},
Pallet = pallet_parameters::Parameters::<Runtime>,
Aggregation = RuntimeParameters::Preimage
}
}

define_aggregrated_parameters! {
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
pub RuntimeParameters = {
#[codec(index = 0)]
Nis: nis::NisParams,

#[codec(index = 1)]
Preimage: preimage::PreimageParams,
}
}
}

impl pallet_parameters::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type AggregratedKeyValue = dynamic_params::RuntimeParameters;
type AdminOrigin = EnsureRootWithSuccess<AccountId, ConstBool<true>>;
type WeightInfo = ();
}

construct_runtime! {
pub enum Runtime
{
Expand Down Expand Up @@ -1365,11 +1429,14 @@ construct_runtime! {
// Validator Manager pallet.
ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>} = 252,

Parameters: pallet_parameters::{Pallet, Call, Storage, Event<T>} = 253,

// State trie migration pallet, only temporary.
StateTrieMigration: pallet_state_trie_migration = 254,

// Sudo.
Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>} = 255,

}
}

Expand Down
49 changes: 49 additions & 0 deletions substrate/frame/parameters/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
name = "pallet-parameters"
description = "(unaudited) Pallet to store and configure parameters."
repository.workspace = true
license = "Apache-2.0"
version = "0.5.0-unaudited"
authors = ["Acala Developers", "Parity Technologies <[email protected]>"]
edition.workspace = true

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["max-encoded-len"] }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
paste = { version = "1.0.14", default-features = false }
serde = { version = "1.0.188", features = ["derive"], optional = true }

frame-support = { path = "../support", default-features = false }
frame-system = { path = "../system", default-features = false }
sp-core = { path = "../../primitives/core", default-features = false }
sp-runtime = { path = "../../primitives/runtime", default-features = false }
sp-std = { path = "../../primitives/std", default-features = false }
docify = "0.2.5"

[dev-dependencies]
sp-core = { path = "../../primitives/core", features = ["std"] }
sp-io = { path = "../../primitives/io", features = ["std"] }
pallet-example-basic = { path = "../examples/basic", features = ["std"] }
pallet-balances = { path = "../balances", features = ["std"] }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
"sp-core/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
]
5 changes: 5 additions & 0 deletions substrate/frame/parameters/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Parameters Store

### Overview

Offer a central place to store and configure parameters.
Loading
Loading