diff --git a/.maintain/benchmark.sh b/.maintain/benchmark.sh index 41a8911..fba8ba8 100755 --- a/.maintain/benchmark.sh +++ b/.maintain/benchmark.sh @@ -21,14 +21,14 @@ cd $PROJECT_ROOT PALLET=$1 FOLDER=$2 -cargo +nightly run --release --locked --features=runtime-benchmarks -- benchmark \ +cargo +nightly run --release --locked --features=runtime-benchmarks -- benchmark pallet \ --chain=dev \ --execution=wasm \ --wasm-execution=compiled \ --pallet="$PALLET" \ --extrinsic="*" \ - --steps=20 \ - --repeat=10 \ + --steps=50 \ + --repeat=20 \ --heap-pages=4096 \ --template="./.maintain/pallet-weight-template.hbs" \ --output="./pallets/${FOLDER}/src/weights.rs" diff --git a/.maintain/pallet-weight-template.hbs b/.maintain/pallet-weight-template.hbs index a116eab..e2248b4 100644 --- a/.maintain/pallet-weight-template.hbs +++ b/.maintain/pallet-weight-template.hbs @@ -2,10 +2,11 @@ //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} //! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}` //! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} // Executed Command: -{{#each args as |arg|~}} +{{#each args as |arg|}} // {{arg}} {{/each}} @@ -18,80 +19,86 @@ use sp_std::marker::PhantomData; /// Weight functions needed for {{pallet}}. pub trait WeightInfo { - {{~#each benchmarks as |benchmark|}} + {{#each benchmarks as |benchmark|}} fn {{benchmark.name~}} ( {{~#each benchmark.components as |c| ~}} {{c.name}}: u32, {{/each~}} ) -> Weight; - {{~/each}} + {{/each}} } /// Weights for {{pallet}} using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); -{{~#if (eq pallet "frame_system")}} +{{#if (eq pallet "frame_system")}} impl WeightInfo for SubstrateWeight { -{{~else}} +{{else}} impl WeightInfo for SubstrateWeight { -{{~/if}} - {{~#each benchmarks as |benchmark|}} - {{~#each benchmark.comments as |comment|}} +{{/if}} + {{#each benchmarks as |benchmark|}} + {{#each benchmark.comments as |comment|}} // {{comment}} - {{~/each}} + {{/each}} + {{#each benchmark.component_ranges as |range|}} + /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. + {{/each}} fn {{benchmark.name~}} ( {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - Weight::from_ref_time({{underscore benchmark.base_weight}}_u64) - {{~#each benchmark.component_weight as |cw|}} + Weight::from_ref_time({{underscore benchmark.base_weight}} as u64) + {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(Weight::from_ref_time(({{underscore cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) - {{~/each}} - {{~#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64)) - {{~/if}} - {{~#each benchmark.component_reads as |cr|}} - .saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) - {{~/each}} - {{~#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}_u64)) - {{~/if}} - {{~#each benchmark.component_writes as |cw|}} - .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) - {{~/each}} + .saturating_add(Weight::from_ref_time({{underscore cw.slope}} as u64).saturating_mul({{cw.name}} as u64)) + {{/each}} + {{#if (ne benchmark.base_reads "0")}} + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as u64)) + {{/if}} + {{#each benchmark.component_reads as |cr|}} + .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as u64).saturating_mul({{cr.name}} as u64))) + {{/each}} + {{#if (ne benchmark.base_writes "0")}} + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as u64)) + {{/if}} + {{#each benchmark.component_writes as |cw|}} + .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as u64).saturating_mul({{cw.name}} as u64))) + {{/each}} } - {{~/each}} + {{/each}} } // For backwards compatibility and tests impl WeightInfo for () { - {{~#each benchmarks as |benchmark|}} - {{~#each benchmark.comments as |comment|}} + {{#each benchmarks as |benchmark|}} + {{#each benchmark.comments as |comment|}} // {{comment}} - {{~/each}} + {{/each}} + {{#each benchmark.component_ranges as |range|}} + /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. + {{/each}} fn {{benchmark.name~}} ( {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - Weight::from_ref_time({{underscore benchmark.base_weight}}_u64) - {{~#each benchmark.component_weight as |cw|}} + Weight::from_ref_time({{underscore benchmark.base_weight}} as u64) + {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(Weight::from_ref_time(({{underscore cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) - {{~/each}} - {{~#if (ne benchmark.base_reads "0")}} - .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}}_u64)) - {{~/if}} - {{~#each benchmark.component_reads as |cr|}} - .saturating_add(RocksDbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) - {{~/each}} - {{~#if (ne benchmark.base_writes "0")}} - .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}}_u64)) - {{~/if}} - {{~#each benchmark.component_writes as |cw|}} - .saturating_add(RocksDbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) - {{~/each}} + .saturating_add(Weight::from_ref_time({{underscore cw.slope}} as u64).saturating_mul({{cw.name}} as u64)) + {{/each}} + {{#if (ne benchmark.base_reads "0")}} + .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as u64)) + {{/if}} + {{#each benchmark.component_reads as |cr|}} + .saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as u64).saturating_mul({{cr.name}} as u64))) + {{/each}} + {{#if (ne benchmark.base_writes "0")}} + .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as u64)) + {{/if}} + {{#each benchmark.component_writes as |cw|}} + .saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as u64).saturating_mul({{cw.name}} as u64))) + {{/each}} } - {{~/each}} + {{/each}} } diff --git a/Cargo.lock b/Cargo.lock index c77396c..4b398c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3965,7 +3965,7 @@ dependencies = [ [[package]] name = "myriad" -version = "2.3.4" +version = "2.3.5" dependencies = [ "beefy-gadget", "beefy-gadget-rpc", @@ -4027,7 +4027,7 @@ dependencies = [ [[package]] name = "myriad-runtime" -version = "2.3.4" +version = "2.3.5" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -4046,6 +4046,8 @@ dependencies = [ "pallet-balances", "pallet-beefy", "pallet-beefy-mmr", + "pallet-collective", + "pallet-democracy", "pallet-grandpa", "pallet-im-online", "pallet-mmr", @@ -4057,6 +4059,8 @@ dependencies = [ "pallet-octopus-upward-messages", "pallet-offences", "pallet-offences-benchmarking", + "pallet-preimage", + "pallet-scheduler", "pallet-server", "pallet-session", "pallet-session-benchmarking", @@ -4496,6 +4500,39 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-collective" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-democracy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -4745,9 +4782,41 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-preimage" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-scheduler" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-server" -version = "2.3.4" +version = "2.3.5" dependencies = [ "frame-benchmarking", "frame-support", @@ -4857,7 +4926,7 @@ dependencies = [ [[package]] name = "pallet-tipping" -version = "2.3.4" +version = "2.3.5" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/node/Cargo.toml b/node/Cargo.toml index 6035800..581aee9 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'myriad' -version = '2.3.4' +version = '2.3.5' edition = '2021' license = 'AGPL-3.0' authors = ['Myriad Dev Team '] diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 6069b3c..db9968d 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -15,9 +15,10 @@ use pallet_octopus_appchain::sr25519::AuthorityId as OctopusId; use myriad_runtime::{ currency::UNITS as MYRIA, opaque::{Block, SessionKeys}, - AccountId, BabeConfig, Balance, BalancesConfig, GenesisConfig, OctopusAppchainConfig, - OctopusBridgeConfig, OctopusLposConfig, OctopusUpwardMessagesConfig, SessionConfig, Signature, - SudoConfig, SystemConfig, BABE_GENESIS_EPOCH_CONFIG, WASM_BINARY, + AccountId, BabeConfig, Balance, BalancesConfig, CouncilConfig, DemocracyConfig, GenesisConfig, + OctopusAppchainConfig, OctopusBridgeConfig, OctopusLposConfig, OctopusUpwardMessagesConfig, + SessionConfig, Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, + BABE_GENESIS_EPOCH_CONFIG, WASM_BINARY, }; use serde::{Deserialize, Serialize}; @@ -293,6 +294,12 @@ fn genesis( octopus_lpos: OctopusLposConfig { era_payout: appchain_config.3, ..Default::default() }, octopus_upward_messages: OctopusUpwardMessagesConfig { interval: 1 }, octopus_assets: Default::default(), + democracy: DemocracyConfig::default(), + council: CouncilConfig { members: vec![], phantom: Default::default() }, + technical_committee: TechnicalCommitteeConfig { + members: vec![], + phantom: Default::default(), + }, sudo: SudoConfig { key: Some(root_key) }, } } diff --git a/pallets/server/Cargo.toml b/pallets/server/Cargo.toml index 7e58ba5..c779a56 100644 --- a/pallets/server/Cargo.toml +++ b/pallets/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-server' -version = '2.3.4' +version = '2.3.5' edition = '2021' license = 'AGPL-3.0' authors = ['Myriad Dev Team '] diff --git a/pallets/server/src/weights.rs b/pallets/server/src/weights.rs index 33e7d49..3092186 100644 --- a/pallets/server/src/weights.rs +++ b/pallets/server/src/weights.rs @@ -1,33 +1,24 @@ //! Autogenerated weights for pallet_server //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-13, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-02-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `Irmans-MacBook-Pro.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/myriad +// target/release/myriad // benchmark // pallet -// --chain -// dev -// --execution -// wasm -// --wasm-execution -// compiled -// --pallet -// pallet-server -// --extrinsic -// * -// --steps -// 20 -// --repeat -// 10 -// --heap-pages -// 4096 -// --output -// ./pallets/server/src/weights.rs -// --template -// ./.maintain/pallet-weight-template.hbs +// --chain=dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=pallet-server +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --heap-pages=4096 +// --template=./.maintain/pallet-weight-template.hbs +// --output=./pallets/server/src/weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -42,7 +33,8 @@ pub trait WeightInfo { fn update_server(s: u32, ) -> Weight; fn unregister() -> Weight; fn cancel_unregister() -> Weight; - fn on_initialize_server() -> Weight;} + fn on_initialize_server() -> Weight; +} /// Weights for pallet_server using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); @@ -53,9 +45,11 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Server ServerById (r:0 w:1) // Storage: Server ServerByOwner (r:0 w:1) + /// The range of component `s` is `[1, 100]`. fn register(s: u32, ) -> Weight { - Weight::from_ref_time(121_100_000_u64) // Standard Error: 59_304 - .saturating_add(Weight::from_ref_time((456_153_u64).saturating_mul(s.into()))) + Weight::from_ref_time(157_000_000_u64) + // Standard Error: 2_258 + .saturating_add(Weight::from_ref_time(31_163_u64).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -63,19 +57,21 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Server ServerByOwner (r:0 w:1) // Storage: Server ServerByApiUrl (r:2 w:2) + /// The range of component `s` is `[0, 2]`. fn update_server(s: u32, ) -> Weight { - Weight::from_ref_time(71_300_000_u64) // Standard Error: 2_834_637 - .saturating_add(Weight::from_ref_time((4_472_857_u64).saturating_mul(s.into()))) + Weight::from_ref_time(87_000_000_u64) + // Standard Error: 1_129_362 + .saturating_add(Weight::from_ref_time(614_285_u64).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(s.into()))) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(s as u64))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64.saturating_mul(s as u64))) } // Storage: Server ServerById (r:1 w:1) // Storage: Server Tasks (r:1 w:1) // Storage: Server ServerByOwner (r:0 w:1) fn unregister() -> Weight { - Weight::from_ref_time(64_100_000_u64) + Weight::from_ref_time(77_000_000_u64) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -83,7 +79,7 @@ impl WeightInfo for SubstrateWeight { // Storage: Server Tasks (r:1 w:1) // Storage: Server ServerByOwner (r:0 w:1) fn cancel_unregister() -> Weight { - Weight::from_ref_time(86_900_000_u64) + Weight::from_ref_time(77_000_000_u64) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -94,7 +90,7 @@ impl WeightInfo for SubstrateWeight { // Storage: Server ServerByOwner (r:0 w:1) // Storage: Server ServerByApiUrl (r:0 w:1) fn on_initialize_server() -> Weight { - Weight::from_ref_time(160_200_000_u64) + Weight::from_ref_time(156_000_000_u64) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -108,9 +104,11 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Server ServerById (r:0 w:1) // Storage: Server ServerByOwner (r:0 w:1) + /// The range of component `s` is `[1, 100]`. fn register(s: u32, ) -> Weight { - Weight::from_ref_time(121_100_000_u64) // Standard Error: 59_304 - .saturating_add(Weight::from_ref_time((456_153_u64).saturating_mul(s.into()))) + Weight::from_ref_time(157_000_000_u64) + // Standard Error: 2_258 + .saturating_add(Weight::from_ref_time(31_163_u64).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -118,19 +116,21 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Server ServerByOwner (r:0 w:1) // Storage: Server ServerByApiUrl (r:2 w:2) + /// The range of component `s` is `[0, 2]`. fn update_server(s: u32, ) -> Weight { - Weight::from_ref_time(71_300_000_u64) // Standard Error: 2_834_637 - .saturating_add(Weight::from_ref_time((4_472_857_u64).saturating_mul(s.into()))) + Weight::from_ref_time(87_000_000_u64) + // Standard Error: 1_129_362 + .saturating_add(Weight::from_ref_time(614_285_u64).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(s.into()))) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(s as u64))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64.saturating_mul(s as u64))) } // Storage: Server ServerById (r:1 w:1) // Storage: Server Tasks (r:1 w:1) // Storage: Server ServerByOwner (r:0 w:1) fn unregister() -> Weight { - Weight::from_ref_time(64_100_000_u64) + Weight::from_ref_time(77_000_000_u64) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -138,7 +138,7 @@ impl WeightInfo for () { // Storage: Server Tasks (r:1 w:1) // Storage: Server ServerByOwner (r:0 w:1) fn cancel_unregister() -> Weight { - Weight::from_ref_time(86_900_000_u64) + Weight::from_ref_time(77_000_000_u64) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -149,7 +149,7 @@ impl WeightInfo for () { // Storage: Server ServerByOwner (r:0 w:1) // Storage: Server ServerByApiUrl (r:0 w:1) fn on_initialize_server() -> Weight { - Weight::from_ref_time(160_200_000_u64) + Weight::from_ref_time(156_000_000_u64) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } diff --git a/pallets/tipping/Cargo.toml b/pallets/tipping/Cargo.toml index 52d936c..7d8599c 100644 --- a/pallets/tipping/Cargo.toml +++ b/pallets/tipping/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-tipping' -version = '2.3.4' +version = '2.3.5' edition = '2021' license = 'AGPL-3.0' authors = ['Myriad Dev Team '] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 0d6df1f..7157717 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'myriad-runtime' -version = '2.3.4' +version = '2.3.5' edition = '2021' license = 'AGPL-3.0' authors = ['Myriad Dev Team '] @@ -58,11 +58,15 @@ pallet-babe = { git = 'https://github.com/paritytech/substrate.git', branch = 'p pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } pallet-beefy = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } pallet-beefy-mmr = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } +pallet-collective = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } +pallet-democracy = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } pallet-grandpa = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } pallet-im-online = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } pallet-mmr = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } pallet-offences = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } pallet-offences-benchmarking = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false, optional = true } +pallet-preimage = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } +pallet-scheduler = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } pallet-session = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false, features = ['historical'] } pallet-session-benchmarking = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false, optional = true } pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.30', default-features = false } @@ -103,10 +107,14 @@ runtime-benchmarks = [ ## Substrate Pallet Dependencies 'pallet-babe/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', + 'pallet-collective/runtime-benchmarks', + 'pallet-democracy/runtime-benchmarks', 'pallet-grandpa/runtime-benchmarks', 'pallet-im-online/runtime-benchmarks', 'pallet-mmr/runtime-benchmarks', 'pallet-offences-benchmarking/runtime-benchmarks', + 'pallet-preimage/runtime-benchmarks', + 'pallet-scheduler/runtime-benchmarks', 'pallet-session-benchmarking/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', 'pallet-uniques/runtime-benchmarks', @@ -165,10 +173,14 @@ std = [ 'pallet-balances/std', 'pallet-beefy-mmr/std', 'pallet-beefy/std', + 'pallet-collective/std', + 'pallet-democracy/std', 'pallet-grandpa/std', 'pallet-im-online/std', 'pallet-mmr/std', 'pallet-offences/std', + 'pallet-preimage/std', + 'pallet-scheduler/std', 'pallet-session/std', 'pallet-sudo/std', 'pallet-timestamp/std', @@ -203,10 +215,14 @@ try-runtime = [ 'pallet-authorship/try-runtime', 'pallet-babe/try-runtime', 'pallet-balances/try-runtime', + 'pallet-collective/try-runtime', + 'pallet-democracy/try-runtime', 'pallet-grandpa/try-runtime', 'pallet-im-online/try-runtime', 'pallet-mmr/try-runtime', 'pallet-offences/try-runtime', + 'pallet-preimage/try-runtime', + 'pallet-scheduler/try-runtime', 'pallet-session/try-runtime', 'pallet-sudo/try-runtime', 'pallet-timestamp/try-runtime', diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index a5ef9b0..7e59f52 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -26,7 +26,7 @@ use sp_runtime::{ ApplyExtrinsicResult, FixedPointNumber, MultiAddress, MultiSignature, Perbill, Perquintill, }; use sp_staking::SessionIndex; -use sp_std::prelude::*; +use sp_std::{cmp::Ordering, prelude::*}; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -36,7 +36,8 @@ use frame_support::{ dispatch::DispatchClass, parameter_types, traits::{ - AsEnsureOriginWithArg, ConstU128, ConstU16, ConstU32, Everything, KeyOwnerProofSystem, + AsEnsureOriginWithArg, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, EitherOfDiverse, + Everything, KeyOwnerProofSystem, PrivilegeCmp, }, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, @@ -48,7 +49,7 @@ pub use frame_system::Call as SystemCall; use frame_system::{ limits::{BlockLength, BlockWeights}, offchain, ChainContext, CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, - CheckSpecVersion, CheckTxVersion, CheckWeight, EnsureRoot, EnsureSigned, + CheckSpecVersion, CheckTxVersion, CheckWeight, EnsureRoot, EnsureSigned, RawOrigin, }; use pallet_babe::{ @@ -56,6 +57,9 @@ use pallet_babe::{ }; pub use pallet_balances::{AccountData, Call as BalancesCall}; use pallet_beefy_mmr::{BeefyEcdsaToEthereum, DepositBeefyDigest}; +use pallet_collective::{ + EnsureMember, EnsureProportionAtLeast, PrimeDefaultVote, RawOrigin as CollectiveRawOrigin, +}; use pallet_grandpa::{ fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, EquivocationHandler as GrandpaEquivocationHandler, @@ -123,8 +127,11 @@ pub type Executive = frame_executive::Executive< pub type CollectionId = u128; pub type ItemId = u128; pub type AssetId = u32; +pub type CouncilCollective = pallet_collective::Instance1; +pub type TechnicalCollective = pallet_collective::Instance2; pub struct OctopusAppCrypto; +pub struct OriginPrivilegeCmp; #[cfg(feature = "runtime-benchmarks")] #[macro_use] @@ -176,11 +183,11 @@ pub mod currency { pub const CENTS: Balance = DOLLARS / 100; pub const MILLICENTS: Balance = CENTS / 1_000; - pub const EXISTENSIAL_DEPOSIT: Balance = CENTS; + pub const EXISTENSIAL_DEPOSIT: Balance = DOLLARS; pub const BYTE_FEE: Balance = 10 * MILLICENTS; pub const fn deposit(items: u32, bytes: u32) -> Balance { - (items as Balance) * CENTS + (bytes as Balance) * BYTE_FEE + (items as Balance) * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS } } @@ -196,10 +203,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 2034, + spec_version: 2035, impl_version: 1, apis: RUNTIME_API_VERSIONS, - transaction_version: 2, + transaction_version: 3, state_version: 1, }; @@ -414,10 +421,6 @@ impl pallet_timestamp::Config for Runtime { parameter_types! { pub const ExistentialDeposit: Balance = currency::EXISTENSIAL_DEPOSIT; - // For weight estimation, we assume that the most locks on an individual account will be 50. - // This number may need to be adjusted in the future if this assumption no longer holds true. - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 50; } impl pallet_balances::Config for Runtime { @@ -425,15 +428,14 @@ impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } parameter_types! { - pub const OperationalFeeMultiplier: u8 = 5; pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); pub const TransactionByteFee: Balance = currency::BYTE_FEE; pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000); @@ -445,7 +447,7 @@ impl pallet_transaction_payment::Config for Runtime { TargetedFeeAdjustment; type LengthToFee = ConstantMultiplier; type OnChargeTransaction = CurrencyAdapter; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type OperationalFeeMultiplier = ConstU8<5>; type RuntimeEvent = RuntimeEvent; type WeightToFee = IdentityFee; } @@ -453,8 +455,6 @@ impl pallet_transaction_payment::Config for Runtime { parameter_types! { pub const CollectionDeposit: Balance = 100 * currency::DOLLARS; pub const ItemDeposit: Balance = currency::DOLLARS; - pub const KeyLimit: u32 = 32; - pub const ValueLimit: u32 = 256; } impl pallet_uniques::Config for Runtime { @@ -469,12 +469,12 @@ impl pallet_uniques::Config for Runtime { type Helper = (); type ItemDeposit = ItemDeposit; type ItemId = ItemId; - type KeyLimit = KeyLimit; + type KeyLimit = ConstU32<32>; type Locker = (); type MetadataDepositBase = MetadataDepositBase; type RuntimeEvent = RuntimeEvent; - type StringLimit = StringLimit; - type ValueLimit = ValueLimit; + type StringLimit = ConstU32<50>; + type ValueLimit = ConstU32<256>; type WeightInfo = (); } @@ -483,7 +483,6 @@ parameter_types! { pub const AssetDeposit: Balance = 100 * currency::DOLLARS; pub const MetadataDepositBase: Balance = 10 * currency::DOLLARS; pub const MetadataDepositPerByte: Balance = currency::DOLLARS; - pub const StringLimit: u32 = 50; } impl pallet_assets::Config for Runtime { @@ -499,37 +498,29 @@ impl pallet_assets::Config for Runtime { type MetadataDepositBase = MetadataDepositBase; type MetadataDepositPerByte = MetadataDepositPerByte; type RuntimeEvent = RuntimeEvent; - type StringLimit = StringLimit; + type StringLimit = ConstU32<50>; type WeightInfo = (); } parameter_types! { - pub const GracePeriod: u32 = 10; pub const OctopusAppchainPalletId: PalletId = PalletId(*b"py/octps"); - pub const RequestEventLimit: u32 = 10; - pub const UnsignedPriority: u64 = 1 << 21; } impl pallet_octopus_appchain::Config for Runtime { type AppCrypto = OctopusAppCrypto; type AuthorityId = OctopusId; type BridgeInterface = OctopusBridge; - type GracePeriod = GracePeriod; + type GracePeriod = ConstU32<10>; type LposInterface = OctopusLpos; type MaxValidators = MaxAuthorities; - type RequestEventLimit = RequestEventLimit; + type RequestEventLimit = ConstU32<10>; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; - type UnsignedPriority = UnsignedPriority; + type UnsignedPriority = ConstU64<{ 1 << 21 }>; type UpwardMessagesInterface = OctopusUpwardMessages; type WeightInfo = (); } -parameter_types! { - pub const NativeTokenDecimals: u128 = 1_000_000_000_000_000_000; - pub const FeeThreshold: u64 = 300; -} - impl pallet_octopus_bridge::Config for Runtime { type AppchainInterface = OctopusAppchain; type AssetBalance = Balance; @@ -540,11 +531,11 @@ impl pallet_octopus_bridge::Config for Runtime { type Currency = Balances; type Fungibles = OctopusAssets; type ItemId = ItemId; - type NativeTokenDecimals = NativeTokenDecimals; + type NativeTokenDecimals = ConstU128<1_000_000_000_000_000_000>; type Nonfungibles = OctopusUniques; type PalletId = OctopusAppchainPalletId; type RuntimeEvent = RuntimeEvent; - type Threshold = FeeThreshold; + type Threshold = ConstU64<300>; type UpwardMessagesInterface = OctopusUpwardMessages; type WeightInfo = (); } @@ -567,28 +558,19 @@ impl pallet_octopus_lpos::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub const MaxMessagePayloadSize: u32 = 256; - pub const MaxMessagesPerCommit: u32 = 20; -} - impl pallet_octopus_upward_messages::Config for Runtime { type Hashing = Keccak256; - type MaxMessagePayloadSize = MaxMessagePayloadSize; - type MaxMessagesPerCommit = MaxMessagesPerCommit; + type MaxMessagePayloadSize = ConstU32<256>; + type MaxMessagesPerCommit = ConstU32<20>; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } -parameter_types! { - pub const UncleGenerations: BlockNumber = 0; -} - impl pallet_authorship::Config for Runtime { type EventHandler = (OctopusLpos, ImOnline); type FilterUncle = (); type FindAuthor = FindAccountFromAuthorIndex; - type UncleGenerations = UncleGenerations; + type UncleGenerations = ConstU32<0>; } impl pallet_session_historical::Config for Runtime { @@ -673,17 +655,14 @@ impl pallet_mmr::Config for Runtime { parameter_types! { pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); - pub const MaxKeys: u32 = 10_000; - pub const MaxPeerDataEncodingSize: u32 = 1_000; - pub const MaxPeerInHeartbeats: u32 = 10_000; pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; } impl pallet_im_online::Config for Runtime { type AuthorityId = ImOnlineId; - type MaxKeys = MaxKeys; - type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize; - type MaxPeerInHeartbeats = MaxPeerInHeartbeats; + type MaxKeys = ConstU32<10_000>; + type MaxPeerDataEncodingSize = ConstU32<1_000>; + type MaxPeerInHeartbeats = ConstU32<1_000>; type NextSessionRotation = Babe; type ReportUnresponsiveness = FilterHistoricalOffences; type RuntimeEvent = RuntimeEvent; @@ -692,6 +671,155 @@ impl pallet_im_online::Config for Runtime { type WeightInfo = (); } +parameter_types! { + pub const PreimageBaseDeposit: Balance = currency::deposit(2, 64); + pub const PreimageByteDeposit: Balance = currency::deposit(0, 1); +} + +impl pallet_preimage::Config for Runtime { + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type MaxSize = ConstU32<{ 4096 * 1024 }>; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); +} + +parameter_types! { + pub MaximumSchedulerWeight: Weight = NORMAL_DISPATCH_RATIO * RuntimeBlockWeights::get().max_block; + pub const NoPreimagePostponement: Option = Some(10); +} + +/// Used the compare the privilege of an origin inside the scheduler. +impl PrivilegeCmp for OriginPrivilegeCmp { + fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option { + if left == right { + return Some(Ordering::Equal) + } + + match (left, right) { + // Root is greater than anything. + (OriginCaller::system(RawOrigin::Root), _) => Some(Ordering::Greater), + // Check which one has more yes votes. + ( + OriginCaller::Council(CollectiveRawOrigin::Members(l_yes_votes, l_count)), + OriginCaller::Council(CollectiveRawOrigin::Members(r_yes_votes, r_count)), + ) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))), + // For every other origin we don't care, as they are not used for `ScheduleOrigin`. + _ => None, + } + } +} + +impl pallet_scheduler::Config for Runtime { + type MaxScheduledPerBlock = ConstU32<50>; + type MaximumWeight = MaximumSchedulerWeight; + type NoPreimagePostponement = NoPreimagePostponement; + type OriginPrivilegeCmp = OriginPrivilegeCmp; + type PalletsOrigin = OriginCaller; + type PreimageProvider = Preimage; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type ScheduleOrigin = EitherOfDiverse< + EnsureRoot, + EnsureProportionAtLeast, + >; + type WeightInfo = (); +} + +impl pallet_collective::Config for Runtime { + type DefaultVote = PrimeDefaultVote; + type MaxMembers = ConstU32<100>; + type MaxProposals = ConstU32<100>; + type MotionDuration = ConstU32<{ 7 * DAYS }>; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type WeightInfo = (); +} + +impl pallet_collective::Config for Runtime { + type DefaultVote = PrimeDefaultVote; + type MaxMembers = ConstU32<100>; + type MaxProposals = ConstU32<100>; + type MotionDuration = ConstU32<{ 7 * DAYS }>; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type WeightInfo = (); +} + +parameter_types! { + pub const MinimumDeposit: Balance = 100 * currency::DOLLARS; + pub const InstantAllowed: bool = true; +} + +impl pallet_democracy::Config for Runtime { + type BlacklistOrigin = EnsureRoot; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EitherOfDiverse< + EnsureProportionAtLeast, + EnsureRoot, + >; + // To cancel a proposal which has been passed, 2/3 of the council must agree to it. + type CancellationOrigin = EitherOfDiverse< + EnsureProportionAtLeast, + EnsureRoot, + >; + type CooloffPeriod = ConstU32<{ 7 * DAYS }>; + type Currency = Balances; + type EnactmentPeriod = ConstU32<{ 28 * DAYS }>; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = EitherOfDiverse< + EnsureProportionAtLeast, + EnsureRoot, + >; + /// A 60% super-majority can have the next scheduled referendum be a straight majority-carries + /// vote. + type ExternalMajorityOrigin = EitherOfDiverse< + EnsureProportionAtLeast, + EnsureRoot, + >; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = EitherOfDiverse< + EnsureProportionAtLeast, + EnsureRoot, + >; + /// Two thirds of the technical committee can have an `ExternalMajority/ExternalDefault` vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = EitherOfDiverse< + EnsureProportionAtLeast, + EnsureRoot, + >; + type FastTrackVotingPeriod = ConstU32<{ 3 * HOURS }>; + type InstantAllowed = InstantAllowed; + type InstantOrigin = EitherOfDiverse< + EnsureProportionAtLeast, + EnsureRoot, + >; + type LaunchPeriod = ConstU32<{ 28 * DAYS }>; + type MaxProposals = ConstU32<100>; + type MaxVotes = ConstU32<100>; + type MinimumDeposit = MinimumDeposit; + type OperationalPreimageOrigin = EnsureMember; + type PalletsOrigin = OriginCaller; + type PreimageByteDeposit = PreimageByteDeposit; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type Scheduler = Scheduler; + type Slash = (); + // Any single technical committee member may veto a coming council proposal, however they can + // only do it once and it lasts only for the cooloff period. + type VetoOrigin = EnsureMember; + type VoteLockingPeriod = ConstU32<{ 28 * DAYS }>; + type VotingPeriod = ConstU32<{ 28 * DAYS }>; + type WeightInfo = (); +} + impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; @@ -699,34 +827,26 @@ impl pallet_sudo::Config for Runtime { // Local pallets parameter_types! { - pub const MaxScheduledPerBlock: u32 = 5; pub const MinimumStakeAmount: Balance = 50_000 * currency::DOLLARS; - pub const ScheduledBlockTime: BlockNumber = DAYS; } impl pallet_server::Config for Runtime { type Currency = Balances; - type MaxScheduledPerBlock = MaxScheduledPerBlock; + type MaxScheduledPerBlock = ConstU32<5>; type MinimumStakeAmount = MinimumStakeAmount; type RuntimeEvent = RuntimeEvent; - type ScheduledBlockTime = ScheduledBlockTime; + type ScheduledBlockTime = ConstU32<{ DAYS }>; type WeightInfo = (); } -parameter_types! { - // In percentage - pub const AdminFee: u8 = 10; - pub const TransactionFee: u8 = 5; -} - impl pallet_tipping::Config for Runtime { type Assets = OctopusAssets; type Currency = Balances; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type TimeProvider = Timestamp; - type AdminFee = AdminFee; - type TransactionFee = TransactionFee; + type AdminFee = ConstU8<10>; + type TransactionFee = ConstU8<5>; type WeightInfo = (); } @@ -772,6 +892,11 @@ construct_runtime!( MmrLeaf: pallet_beefy_mmr, Mmr: pallet_mmr, ImOnline: pallet_im_online, + Preimage: pallet_preimage, + Scheduler: pallet_scheduler, + Council: pallet_collective::, + TechnicalCommittee: pallet_collective::, + Democracy: pallet_democracy, Sudo: pallet_sudo, // Local pallets