Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Adds minimal config for snowbase. (paritytech#701)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
claravanstaden authored Oct 26, 2022
1 parent a259a80 commit 54b479c
Show file tree
Hide file tree
Showing 14 changed files with 178 additions and 46 deletions.
2 changes: 1 addition & 1 deletion parachain/pallets/basic-channel/src/outbound/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion parachain/pallets/dot-app/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion parachain/pallets/erc20-app/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion parachain/pallets/eth-app/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
52 changes: 41 additions & 11 deletions parachain/pallets/ethereum-beacon-client/src/weights.rs
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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)]
Expand All @@ -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<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SnowbridgeWeight<T> { 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<T: frame_system::Config> WeightInfo for SnowbridgeWeight<T> {
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))
}
}
2 changes: 1 addition & 1 deletion parachain/pallets/ethereum-light-client/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 3 additions & 1 deletion parachain/runtime/snowbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<Self>;
type WeightInfo = weights::ethereum_beacon_client::SnowbridgeWeight<Self>;
}

parameter_types! {
Expand Down
52 changes: 52 additions & 0 deletions parachain/runtime/snowbase/src/weights/ethereum_beacon_client.rs
Original file line number Diff line number Diff line change
@@ -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<T>(PhantomData<T>);
impl<T: frame_system::Config> ethereum_beacon_client::WeightInfo for SnowbridgeWeight<T> {
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))
}
}
1 change: 1 addition & 0 deletions parachain/runtime/snowbase/src/weights/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod ethereum_beacon_client;
2 changes: 1 addition & 1 deletion parachain/scripts/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand All @@ -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<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SnowbridgeWeight<T> {
{{~#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}}
}
47 changes: 47 additions & 0 deletions parachain/templates/runtime-weight-template.hbs
Original file line number Diff line number Diff line change
@@ -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<T>(PhantomData<T>);
impl<T: frame_system::Config> {{pallet}}::WeightInfo for SnowbridgeWeight<T> {
{{#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}}
}

0 comments on commit 54b479c

Please sign in to comment.