From 54b479ce3dca243c6352c3eb5455f1705c9a2393 Mon Sep 17 00:00:00 2001 From: Clara van Staden Date: Wed, 26 Oct 2022 16:52:19 +0200 Subject: [PATCH] Adds minimal config for snowbase. (#701) * Adds minimal config for snowbase. * Formatting * Removes space. * Adds runtime benchmarks for eth beacon client for snowbase * Adds generated weights for snowbase and updates template path comments in weights files. * Fix formatting. --- .../basic-channel/src/outbound/weights.rs | 2 +- parachain/pallets/dot-app/src/weights.rs | 2 +- parachain/pallets/erc20-app/src/weights.rs | 2 +- parachain/pallets/eth-app/src/weights.rs | 2 +- .../ethereum-beacon-client/src/weights.rs | 52 +++++++++++++++---- .../ethereum-light-client/src/weights.rs | 2 +- .../src/inbound/weights.rs | 2 +- .../src/outbound/weights.rs | 2 +- parachain/runtime/snowbase/src/lib.rs | 4 +- .../src/weights/ethereum_beacon_client.rs | 52 +++++++++++++++++++ parachain/runtime/snowbase/src/weights/mod.rs | 1 + parachain/scripts/benchmark.sh | 2 +- .../module-weight-template.hbs | 52 +++++++++---------- .../templates/runtime-weight-template.hbs | 47 +++++++++++++++++ 14 files changed, 178 insertions(+), 46 deletions(-) create mode 100644 parachain/runtime/snowbase/src/weights/ethereum_beacon_client.rs create mode 100644 parachain/runtime/snowbase/src/weights/mod.rs rename parachain/{ => templates}/module-weight-template.hbs (78%) create mode 100644 parachain/templates/runtime-weight-template.hbs diff --git a/parachain/pallets/basic-channel/src/outbound/weights.rs b/parachain/pallets/basic-channel/src/outbound/weights.rs index c4a2fa03623f5..f915a0675f185 100644 --- a/parachain/pallets/basic-channel/src/outbound/weights.rs +++ b/parachain/pallets/basic-channel/src/outbound/weights.rs @@ -25,7 +25,7 @@ // --output // pallets/basic-channel/src/outbound/weights.rs // --template -// module-weight-template.hbs +// templates/module-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] diff --git a/parachain/pallets/dot-app/src/weights.rs b/parachain/pallets/dot-app/src/weights.rs index e47c16ca50634..7bd9e39fe9577 100644 --- a/parachain/pallets/dot-app/src/weights.rs +++ b/parachain/pallets/dot-app/src/weights.rs @@ -25,7 +25,7 @@ // --output // pallets/dot-app/src/weights.rs // --template -// module-weight-template.hbs +// templates/module-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] diff --git a/parachain/pallets/erc20-app/src/weights.rs b/parachain/pallets/erc20-app/src/weights.rs index 57c17a09f2bcb..6f00456b95598 100644 --- a/parachain/pallets/erc20-app/src/weights.rs +++ b/parachain/pallets/erc20-app/src/weights.rs @@ -25,7 +25,7 @@ // --output // pallets/erc20-app/src/weights.rs // --template -// module-weight-template.hbs +// templates/module-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] diff --git a/parachain/pallets/eth-app/src/weights.rs b/parachain/pallets/eth-app/src/weights.rs index 1736fdaa29e23..7a9e738c99517 100644 --- a/parachain/pallets/eth-app/src/weights.rs +++ b/parachain/pallets/eth-app/src/weights.rs @@ -25,7 +25,7 @@ // --output // pallets/eth-app/src/weights.rs // --template -// module-weight-template.hbs +// templates/module-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] diff --git a/parachain/pallets/ethereum-beacon-client/src/weights.rs b/parachain/pallets/ethereum-beacon-client/src/weights.rs index b28ba796a752e..dff8df0e00ce3 100644 --- a/parachain/pallets/ethereum-beacon-client/src/weights.rs +++ b/parachain/pallets/ethereum-beacon-client/src/weights.rs @@ -1,7 +1,7 @@ //! Autogenerated weights for ethereum_beacon_client //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-09-27, STEPS: `10`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `10`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("/tmp/snowbridge/spec.json"), DB CACHE: 1024 // Executed Command: @@ -22,7 +22,7 @@ // --output // pallets/ethereum-beacon-client/src/weights.rs // --template -// module-weight-template.hbs +// templates/module-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -32,17 +32,47 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; /// Weight functions needed for ethereum_beacon_client. -pub trait WeightInfo { fn sync_committee_period_update() -> Weight; fn import_finalized_header() -> Weight; fn import_execution_header() -> Weight;} +pub trait WeightInfo { + fn sync_committee_period_update() -> Weight; + fn import_finalized_header() -> Weight; + fn import_execution_header() -> Weight; +} /// Weights for ethereum_beacon_client using the Snowbridge node and recommended hardware. pub struct SnowbridgeWeight(PhantomData); -impl WeightInfo for SnowbridgeWeight { fn sync_committee_period_update() -> Weight { - (170_683_416_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn import_finalized_header() -> Weight { - (166_954_505_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn import_execution_header() -> Weight { - (162_194_827_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) }} +impl WeightInfo for SnowbridgeWeight { + fn sync_committee_period_update() -> Weight { + (175_039_777_000 as Weight) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + fn import_finalized_header() -> Weight { + (171_871_518_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn import_execution_header() -> Weight { + (166_011_885_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} // For backwards compatibility and tests -impl WeightInfo for () { fn sync_committee_period_update() -> Weight { - (170_683_416_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn import_finalized_header() -> Weight { - (166_954_505_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn import_execution_header() -> Weight { - (162_194_827_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) }} +impl WeightInfo for () { + fn sync_committee_period_update() -> Weight { + (175_039_777_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } + fn import_finalized_header() -> Weight { + (171_871_518_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } + fn import_execution_header() -> Weight { + (166_011_885_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } +} diff --git a/parachain/pallets/ethereum-light-client/src/weights.rs b/parachain/pallets/ethereum-light-client/src/weights.rs index 77e797e7dd294..995ecc18d1e47 100644 --- a/parachain/pallets/ethereum-light-client/src/weights.rs +++ b/parachain/pallets/ethereum-light-client/src/weights.rs @@ -24,7 +24,7 @@ // --output // pallets/ethereum-light-client/src/weights.rs // --template -// module-weight-template.hbs +// templates/module-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] diff --git a/parachain/pallets/incentivized-channel/src/inbound/weights.rs b/parachain/pallets/incentivized-channel/src/inbound/weights.rs index 247b235a392eb..85306aa15e549 100644 --- a/parachain/pallets/incentivized-channel/src/inbound/weights.rs +++ b/parachain/pallets/incentivized-channel/src/inbound/weights.rs @@ -25,7 +25,7 @@ // --output // pallets/incentivized-channel/src/inbound/weights.rs // --template -// module-weight-template.hbs +// templates/module-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] diff --git a/parachain/pallets/incentivized-channel/src/outbound/weights.rs b/parachain/pallets/incentivized-channel/src/outbound/weights.rs index 86ce3cc384f40..654bbc7c1c39d 100644 --- a/parachain/pallets/incentivized-channel/src/outbound/weights.rs +++ b/parachain/pallets/incentivized-channel/src/outbound/weights.rs @@ -25,7 +25,7 @@ // --output // pallets/incentivized-channel/src/outbound/weights.rs // --template -// module-weight-template.hbs +// templates/module-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] diff --git a/parachain/runtime/snowbase/src/lib.rs b/parachain/runtime/snowbase/src/lib.rs index a31be71ca0570..ae7c9e6b2e223 100644 --- a/parachain/runtime/snowbase/src/lib.rs +++ b/parachain/runtime/snowbase/src/lib.rs @@ -7,6 +7,8 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +mod weights; + use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata, U256}; @@ -641,7 +643,7 @@ impl ethereum_beacon_client::Config for Runtime { type MaxVoluntaryExitSize = MaxVoluntaryExitSize; type MaxAttestationSize = MaxAttestationSize; type MaxValidatorsPerCommittee = MaxValidatorsPerCommittee; - type WeightInfo = ethereum_beacon_client::weights::SnowbridgeWeight; + type WeightInfo = weights::ethereum_beacon_client::SnowbridgeWeight; } parameter_types! { diff --git a/parachain/runtime/snowbase/src/weights/ethereum_beacon_client.rs b/parachain/runtime/snowbase/src/weights/ethereum_beacon_client.rs new file mode 100644 index 0000000000000..374fe7a0dc120 --- /dev/null +++ b/parachain/runtime/snowbase/src/weights/ethereum_beacon_client.rs @@ -0,0 +1,52 @@ +//! Autogenerated weights for ethereum_beacon_client +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `10`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("/tmp/snowbridge/spec.json"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/snowbridge +// benchmark +// pallet +// --chain +// /tmp/snowbridge/spec.json +// --execution=wasm +// --pallet +// ethereum_beacon_client +// --extrinsic +// * +// --steps +// 10 +// --repeat +// 10 +// --output +// runtime/snowbase/src/weights/ethereum_beacon_client.rs +// --template +// templates/runtime-weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for ethereum_beacon_client. +pub struct SnowbridgeWeight(PhantomData); +impl ethereum_beacon_client::WeightInfo for SnowbridgeWeight { + fn sync_committee_period_update() -> Weight { + (48_609_506_000 as Weight) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + fn import_finalized_header() -> Weight { + (48_328_434_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + fn import_execution_header() -> Weight { + (48_505_068_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} \ No newline at end of file diff --git a/parachain/runtime/snowbase/src/weights/mod.rs b/parachain/runtime/snowbase/src/weights/mod.rs new file mode 100644 index 0000000000000..f58312db792cf --- /dev/null +++ b/parachain/runtime/snowbase/src/weights/mod.rs @@ -0,0 +1 @@ +pub mod ethereum_beacon_client; diff --git a/parachain/scripts/benchmark.sh b/parachain/scripts/benchmark.sh index 25d2c6815c093..2284a7304242d 100755 --- a/parachain/scripts/benchmark.sh +++ b/parachain/scripts/benchmark.sh @@ -10,4 +10,4 @@ target/release/snowbridge benchmark \ --repeat 20 \ --steps 50 \ --output pallets/incentivized-channel/src/inbound/weights.rs \ - --template module-weight-template.hbs + --template templates/module-weight-template.hbs diff --git a/parachain/module-weight-template.hbs b/parachain/templates/module-weight-template.hbs similarity index 78% rename from parachain/module-weight-template.hbs rename to parachain/templates/module-weight-template.hbs index e8dfbf292ac11..4187b669fc04e 100644 --- a/parachain/module-weight-template.hbs +++ b/parachain/templates/module-weight-template.hbs @@ -5,7 +5,7 @@ //! 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,70 +18,70 @@ 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 Snowbridge node and recommended hardware. pub struct SnowbridgeWeight(PhantomData); impl WeightInfo for SnowbridgeWeight { - {{~#each benchmarks as |benchmark|}} + {{#each benchmarks as |benchmark|}} fn {{benchmark.name~}} ( {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { ({{underscore benchmark.base_weight}} as Weight) - {{~#each benchmark.component_weight as |cw|}} + {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) - {{~/each}} - {{~#if (ne benchmark.base_reads "0")}} + {{/each}} + {{#if (ne benchmark.base_reads "0")}} .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) - {{~/if}} - {{~#each benchmark.component_reads as |cr|}} + {{/if}} + {{#each benchmark.component_reads as |cr|}} .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) - {{~/each}} - {{~#if (ne benchmark.base_writes "0")}} + {{/each}} + {{#if (ne benchmark.base_writes "0")}} .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) - {{~/if}} + {{/if}} {{~#each benchmark.component_writes as |cw|}} .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) - {{~/each}} + {{/each}} } - {{~/each}} + {{/each}} } // For backwards compatibility and tests impl WeightInfo for () { - {{~#each benchmarks as |benchmark|}} + {{#each benchmarks as |benchmark|}} fn {{benchmark.name~}} ( {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { ({{underscore benchmark.base_weight}} as Weight) - {{~#each benchmark.component_weight as |cw|}} + {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) - {{~/each}} - {{~#if (ne benchmark.base_reads "0")}} + {{/each}} + {{#if (ne benchmark.base_reads "0")}} .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as Weight)) - {{~/if}} - {{~#each benchmark.component_reads as |cr|}} + {{/if}} + {{#each benchmark.component_reads as |cr|}} .saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) - {{~/each}} - {{~#if (ne benchmark.base_writes "0")}} + {{/each}} + {{#if (ne benchmark.base_writes "0")}} .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}} as Weight)) - {{~/if}} - {{~#each benchmark.component_writes as |cw|}} + {{/if}} + {{#each benchmark.component_writes as |cw|}} .saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) - {{~/each}} + {{/each}} } - {{~/each}} + {{/each}} } diff --git a/parachain/templates/runtime-weight-template.hbs b/parachain/templates/runtime-weight-template.hbs new file mode 100644 index 0000000000000..8809d4165a823 --- /dev/null +++ b/parachain/templates/runtime-weight-template.hbs @@ -0,0 +1,47 @@ +//! Autogenerated weights for {{pallet}} +//! +//! 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}}` +//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} + +// Executed Command: +{{#each args as |arg|}} +// {{arg}} +{{/each}} + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for {{pallet}}. +pub struct SnowbridgeWeight(PhantomData); +impl {{pallet}}::WeightInfo for SnowbridgeWeight { + {{#each benchmarks as |benchmark|}} + fn {{benchmark.name~}} + ( + {{~#each benchmark.components as |c| ~}} + {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} + ) -> Weight { + ({{underscore benchmark.base_weight}} as Weight) + {{#each benchmark.component_weight as |cw|}} + // Standard Error: {{underscore cw.error}} + .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + {{/each}} + {{#if (ne benchmark.base_reads "0")}} + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + {{/if}} + {{#each benchmark.component_reads as |cr|}} + .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + {{/each}} + {{#if (ne benchmark.base_writes "0")}} + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + {{/if}} + {{#each benchmark.component_writes as |cw|}} + .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + {{/each}} + } + {{/each}} +}