Skip to content

Commit

Permalink
fix parachains benchmarks (paritytech#1717)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and serban300 committed Apr 8, 2024
1 parent 4aa0a5c commit bd46d42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions bridges/bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,11 @@ impl_runtime_apis! {
}

impl ParachainsConfig<WithRialtoParachainsInstance> for Runtime {
fn parachains() -> Vec<bp_polkadot_core::parachains::ParaId> {
use bp_runtime::Parachain;
vec![bp_polkadot_core::parachains::ParaId(bp_rialto_parachain::RialtoParachain::PARACHAIN_ID)]
}

fn prepare_parachain_heads_proof(
parachains: &[bp_polkadot_core::parachains::ParaId],
parachain_head_size: u32,
Expand Down
11 changes: 7 additions & 4 deletions bridges/modules/parachains/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct Pallet<T: Config<I>, I: 'static>(crate::Pallet<T, I>);

/// Trait that must be implemented by runtime to benchmark the parachains finality pallet.
pub trait Config<I: 'static>: crate::Config<I> {
/// Returns vector of supported parachains.
fn parachains() -> Vec<ParaId>;
/// Generate parachain heads proof and prepare environment for verifying this proof.
fn prepare_parachain_heads_proof(
parachains: &[ParaId],
Expand All @@ -53,10 +55,11 @@ benchmarks_instance_pallet! {

// Benchmark `submit_parachain_heads` extrinsic with different number of parachains.
submit_parachain_heads_with_n_parachains {
let p in 1..1024;
let p in 1..(T::parachains().len() + 1) as u32;

let sender = account("sender", 0, 0);
let parachains = (1..=p).map(ParaId).collect::<Vec<_>>();
let mut parachains = T::parachains();
let _ = parachains.split_off(p as usize - 1);
let (relay_block_number, relay_block_hash, parachain_heads_proof, parachains_heads) = T::prepare_parachain_heads_proof(
&parachains,
DEFAULT_PARACHAIN_HEAD_SIZE,
Expand All @@ -73,7 +76,7 @@ benchmarks_instance_pallet! {
// Benchmark `submit_parachain_heads` extrinsic with 1kb proof size.
submit_parachain_heads_with_1kb_proof {
let sender = account("sender", 0, 0);
let parachains = vec![ParaId(1)];
let parachains = vec![T::parachains()[0]];
let (relay_block_number, relay_block_hash, parachain_heads_proof, parachains_heads) = T::prepare_parachain_heads_proof(
&parachains,
DEFAULT_PARACHAIN_HEAD_SIZE,
Expand All @@ -90,7 +93,7 @@ benchmarks_instance_pallet! {
// Benchmark `submit_parachain_heads` extrinsic with 16kb proof size.
submit_parachain_heads_with_16kb_proof {
let sender = account("sender", 0, 0);
let parachains = vec![ParaId(1)];
let parachains = vec![T::parachains()[0]];
let (relay_block_number, relay_block_hash, parachain_heads_proof, parachains_heads) = T::prepare_parachain_heads_proof(
&parachains,
DEFAULT_PARACHAIN_HEAD_SIZE,
Expand Down

0 comments on commit bd46d42

Please sign in to comment.