forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inbound queue benchmarks (paritytech#876)
* Start with inbound channel benchmarks. * Add method to set execution header storage for benchmark test. * Working on benchmarks * Basic working version * Cleanup * Removes cleanup. * Adds some comments for Alistair. * Adds branch name. * Makes note * Test transactions * Cleaning up beacon client deps. * Clean up comments. * Tests cleanup. * Fixes non-benchmark test runs. * Cleanup. * Update fixtures and generates benchmarks. * Revert relayer logs. * Cleanup BenchmarkHelper impl and inbound queue dependencies. * fmt * Cleanup imports. * Cleanup imports. * Touch * Adds weights in inbound queue pallet. * Fix tests. * Update cumulus. --------- Co-authored-by: claravanstaden <Cats 4 life!>
- Loading branch information
1 parent
4947f1e
commit a99fc50
Showing
11 changed files
with
204 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
parachain/pallets/inbound-queue/src/benchmarking/fixtures.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use super::*; | ||
use hex_literal::hex; | ||
use snowbridge_beacon_primitives::CompactExecutionHeader; | ||
use snowbridge_core::{Message, Proof}; | ||
|
||
pub struct InboundQueueTest { | ||
pub execution_header: CompactExecutionHeader, | ||
pub message: Message, | ||
} | ||
|
||
pub fn make_create_message() -> InboundQueueTest { | ||
InboundQueueTest{ | ||
execution_header: CompactExecutionHeader{ | ||
parent_hash: hex!("04a7f6ab8282203562c62f38b0ab41d32aaebe2c7ea687702b463148a6429e04").into(), | ||
block_number: 55, | ||
state_root: hex!("894d968712976d613519f973a317cb0781c7b039c89f27ea2b7ca193f7befdb3").into(), | ||
receipts_root: hex!("cf0d1c1ba57d1e0edfb59786c7e30c2b7e12bd54612b00cd21c4eaeecedf44fb").into(), | ||
}, | ||
message: Message { | ||
data: hex!("f9011c94ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0f863a01b11dcf133cc240f682dab2d3a8e4cd35c5da8c9cf99adac4336f8512584c5ada000000000000000000000000000000000000000000000000000000000000003e8a00000000000000000000000000000000000000000000000000000000000000001b8a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004b000f000000000000000100d184c103f7acc340847eee82a0b909e3358bc28d440edffa1352b13227e8ee646f3ea37456dec701345772617070656420457468657210574554481235003511000000000000000000000000000000000000000000").to_vec(), | ||
proof: Proof { | ||
block_hash: hex!("05aaa60b0f27cce9e71909508527264b77ee14da7b5bf915fcc4e32715333213").into(), | ||
tx_index: 0, | ||
data: (vec![ | ||
hex!("cf0d1c1ba57d1e0edfb59786c7e30c2b7e12bd54612b00cd21c4eaeecedf44fb").to_vec(), | ||
hex!("d21fc4f68ab05bc4dcb23c67008e92c4d466437cdd6ed7aad0c008944c185510").to_vec(), | ||
hex!("b9890f91ca0d77aa2a4adfaf9b9e40c94cac9e638b6d9797923865872944b646").to_vec(), | ||
], vec![ | ||
hex!("f90131a0b601337b3aa10a671caa724eba641e759399979856141d3aea6b6b4ac59b889ba00c7d5dd48be9060221a02fb8fa213860b4c50d47046c8fa65ffaba5737d569e0a094601b62a1086cd9c9cb71a7ebff9e718f3217fd6e837efe4246733c0a196f63a06a4b0dd0aefc37b3c77828c8f07d1b7a2455ceb5dbfd3c77d7d6aeeddc2f7e8ca0d6e8e23142cdd8ec219e1f5d8b56aa18e456702b195deeaa210327284d42ade4a08a313d4c87023005d1ab631bbfe3f5de1e405d0e66d0bef3e033f1e5711b5521a0bf09a5d9a48b10ade82b8d6a5362a15921c8b5228a3487479b467db97411d82fa0f95cccae2a7c572ef3c566503e30bac2b2feb2d2f26eebf6d870dcf7f8cf59cea0d21fc4f68ab05bc4dcb23c67008e92c4d466437cdd6ed7aad0c008944c1855108080808080808080").to_vec(), | ||
hex!("f851a0b9890f91ca0d77aa2a4adfaf9b9e40c94cac9e638b6d9797923865872944b646a060a634b9280e3a23fb63375e7bbdd9ab07fd379ab6a67e2312bbc112195fa358808080808080808080808080808080").to_vec(), | ||
hex!("f9030820b9030402f90300018301d6e2b9010000000000000800000000000020040008000000000000000000000000400000008000000000000000000000000000000000000000000000000000000000042010000000001000000000000000000000000000000000040000000000000000000000000000000000000000000000008000000000000000002000000000000000000000000200000000000000200000000000100000000040000001000200008000000000000200000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000f901f5f87a942ffa5ecdbe006d30397c7636d3e015eee251369ff842a0c965575a00553e094ca7c5d14f02e107c258dda06867cbf9e0e69f80e71bbcc1a000000000000000000000000000000000000000000000000000000000000003e8a000000000000000000000000000000000000000000000000000000000000003e8f9011c94ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0f863a01b11dcf133cc240f682dab2d3a8e4cd35c5da8c9cf99adac4336f8512584c5ada000000000000000000000000000000000000000000000000000000000000003e8a00000000000000000000000000000000000000000000000000000000000000001b8a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004b000f000000000000000100d184c103f7acc340847eee82a0b909e3358bc28d440edffa1352b13227e8ee646f3ea37456dec701345772617070656420457468657210574554481235003511000000000000000000000000000000000000000000f858948cf6147918a5cbb672703f879f385036f8793a24e1a01449abf21e49fd025f33495e77f7b1461caefdd3d4bb646424a3f445c4576a5ba0000000000000000000000000440edffa1352b13227e8ee646f3ea37456dec701").to_vec(), | ||
]), | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
mod fixtures; | ||
|
||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com> | ||
use super::*; | ||
|
||
use crate::Pallet as InboundQueue; | ||
use frame_benchmarking::v2::*; | ||
use frame_system::RawOrigin; | ||
|
||
#[benchmarks] | ||
mod benchmarks { | ||
use super::*; | ||
use crate::benchmarking::fixtures::make_create_message; | ||
use hex_literal::hex; | ||
|
||
const OUTBOUND_QUEUE_ADDRESS: [u8; 20] = hex!["ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0"]; | ||
|
||
#[benchmark] | ||
fn submit() -> Result<(), BenchmarkError> { | ||
let caller: T::AccountId = whitelisted_caller(); | ||
|
||
let create_message = make_create_message(); | ||
|
||
T::Helper::initialize_storage( | ||
create_message.message.proof.block_hash, | ||
create_message.execution_header, | ||
); | ||
|
||
<AllowList<T>>::put(create_allowlist::<T>()); | ||
|
||
let dest_para: ParaId = 1000u32.into(); | ||
let sovereign_account = dest_para.into_account_truncating(); | ||
|
||
// So that the receiving account exists | ||
let _ = T::Token::mint_into(&caller, T::Token::minimum_balance().into()); | ||
// Fund the sovereign account (parachain sovereign account) so it can transfer a reward | ||
// fee to the caller account | ||
let _ = T::Token::mint_into(&sovereign_account, 10000u32.into()); | ||
|
||
#[block] | ||
{ | ||
let _ = InboundQueue::<T>::submit( | ||
RawOrigin::Signed(caller.clone()).into(), | ||
create_message.message, | ||
)?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
impl_benchmark_test_suite!( | ||
InboundQueue, | ||
crate::test::new_tester(crate::H160::default()), | ||
crate::test::Test | ||
); | ||
|
||
fn create_allowlist<T>() -> BoundedBTreeSet<H160, T::AllowListLength> | ||
where | ||
T: Config, | ||
{ | ||
let allowlist: BoundedBTreeSet<H160, T::AllowListLength> = | ||
BTreeSet::from_iter(vec![OUTBOUND_QUEUE_ADDRESS.into()].into_iter()) | ||
.try_into() | ||
.expect("exceeded bound"); | ||
|
||
allowlist | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,31 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com> | ||
pub trait WeightInfo {} | ||
//! Autogenerated weights for `snowbridge_inbound_queue` | ||
//! | ||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev | ||
//! DATE: 2023-07-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` | ||
//! WORST CASE MAP SIZE: `1000000` | ||
//! HOSTNAME: `Claras-MacBook-Pro-2.local`, CPU: `<UNKNOWN>` | ||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 | ||
|
||
impl WeightInfo for () {} | ||
#![cfg_attr(rustfmt, rustfmt_skip)] | ||
#![allow(unused_parens)] | ||
#![allow(unused_imports)] | ||
|
||
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 submit() -> Weight; | ||
} | ||
|
||
// For backwards compatibility and tests | ||
impl WeightInfo for () { | ||
fn submit() -> Weight { | ||
Weight::from_parts(125_000_000, 0) | ||
.saturating_add(Weight::from_parts(0, 4042)) | ||
.saturating_add(RocksDbWeight::get().reads(9)) | ||
.saturating_add(RocksDbWeight::get().writes(4)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters