Skip to content

Commit

Permalink
feat: added governance (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
irmannmal authored Feb 22, 2023
1 parent cda91b3 commit 8619453
Show file tree
Hide file tree
Showing 10 changed files with 390 additions and 166 deletions.
6 changes: 3 additions & 3 deletions .maintain/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
99 changes: 53 additions & 46 deletions .maintain/pallet-weight-template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand All @@ -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<T>(PhantomData<T>);
{{~#if (eq pallet "frame_system")}}
{{#if (eq pallet "frame_system")}}
impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
{{~else}}
{{else}}
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
{{~/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}}
}
77 changes: 73 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>']
Expand Down
13 changes: 10 additions & 3 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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) },
}
}
2 changes: 1 addition & 1 deletion pallets/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>']
Expand Down
Loading

0 comments on commit 8619453

Please sign in to comment.