-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[subsystem-bench] Add mocks for own assignments triggering (#5042)
Since #4772, the benchamrks triggers its own assignments, but the mocks weren't properly hooked up, so that the approval is sent as well, so they would have counted as no-shows and impact the time it takes for a block to be approved. Fixed by adding mocks for availability recovery and candidate-validation and hook those into the benchmark. Signed-off-by: Alexandru Gheorghe <[email protected]>
- Loading branch information
Showing
5 changed files
with
172 additions
and
5 deletions.
There are no files selected for viewing
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
73 changes: 73 additions & 0 deletions
73
polkadot/node/subsystem-bench/src/lib/mock/availability_recovery.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,73 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Polkadot is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! A generic mock availability recovery suitable to be used in benchmarks. | ||
|
||
use std::sync::Arc; | ||
|
||
use futures::FutureExt; | ||
use polkadot_node_primitives::{AvailableData, BlockData, PoV}; | ||
use polkadot_node_subsystem::{ | ||
messages::AvailabilityRecoveryMessage, overseer, SpawnedSubsystem, SubsystemError, | ||
}; | ||
use polkadot_node_subsystem_types::OverseerSignal; | ||
use polkadot_primitives::{Hash, HeadData, PersistedValidationData}; | ||
|
||
pub struct MockAvailabilityRecovery {} | ||
|
||
impl MockAvailabilityRecovery { | ||
pub fn new() -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
#[overseer::subsystem(AvailabilityRecovery, error=SubsystemError, prefix=self::overseer)] | ||
impl<Context> MockAvailabilityRecovery { | ||
fn start(self, ctx: Context) -> SpawnedSubsystem { | ||
let future = self.run(ctx).map(|_| Ok(())).boxed(); | ||
|
||
SpawnedSubsystem { name: "test-environment", future } | ||
} | ||
} | ||
|
||
#[overseer::contextbounds(AvailabilityRecovery, prefix = self::overseer)] | ||
impl MockAvailabilityRecovery { | ||
async fn run<Context>(self, mut ctx: Context) { | ||
loop { | ||
let msg = ctx.recv().await.expect("Overseer never fails us"); | ||
match msg { | ||
orchestra::FromOrchestra::Signal(signal) => | ||
if signal == OverseerSignal::Conclude { | ||
return | ||
}, | ||
orchestra::FromOrchestra::Communication { msg } => match msg { | ||
AvailabilityRecoveryMessage::RecoverAvailableData(_, _, _, _, tx) => { | ||
let available_data = AvailableData { | ||
pov: Arc::new(PoV { block_data: BlockData(Vec::new()) }), | ||
validation_data: PersistedValidationData { | ||
parent_head: HeadData(Vec::new()), | ||
relay_parent_number: 0, | ||
relay_parent_storage_root: Hash::default(), | ||
max_pov_size: 2, | ||
}, | ||
}; | ||
tx.send(Ok(available_data)).unwrap(); | ||
}, | ||
}, | ||
} | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
polkadot/node/subsystem-bench/src/lib/mock/candidate_validation.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,74 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Polkadot is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! A generic mock candidate validation subsystem suitable for using in benchmarks, it | ||
//! is responding with candidate valid for every request. | ||
|
||
use futures::FutureExt; | ||
use polkadot_node_primitives::ValidationResult; | ||
use polkadot_node_subsystem::{ | ||
messages::CandidateValidationMessage, overseer, SpawnedSubsystem, SubsystemError, | ||
}; | ||
use polkadot_node_subsystem_types::OverseerSignal; | ||
use polkadot_primitives::{CandidateCommitments, Hash, HeadData, PersistedValidationData}; | ||
|
||
pub struct MockCandidateValidation {} | ||
|
||
impl MockCandidateValidation { | ||
pub fn new() -> Self { | ||
Self {} | ||
} | ||
} | ||
|
||
#[overseer::subsystem(CandidateValidation, error=SubsystemError, prefix=self::overseer)] | ||
impl<Context> MockCandidateValidation { | ||
fn start(self, ctx: Context) -> SpawnedSubsystem { | ||
let future = self.run(ctx).map(|_| Ok(())).boxed(); | ||
|
||
SpawnedSubsystem { name: "test-environment", future } | ||
} | ||
} | ||
|
||
#[overseer::contextbounds(CandidateValidation, prefix = self::overseer)] | ||
impl MockCandidateValidation { | ||
async fn run<Context>(self, mut ctx: Context) { | ||
loop { | ||
let msg = ctx.recv().await.expect("Overseer never fails us"); | ||
match msg { | ||
orchestra::FromOrchestra::Signal(signal) => | ||
if signal == OverseerSignal::Conclude { | ||
return | ||
}, | ||
orchestra::FromOrchestra::Communication { msg } => match msg { | ||
CandidateValidationMessage::ValidateFromExhaustive { | ||
response_sender, .. | ||
} => response_sender | ||
.send(Ok(ValidationResult::Valid( | ||
CandidateCommitments::default(), | ||
PersistedValidationData { | ||
parent_head: HeadData(Vec::new()), | ||
relay_parent_number: 0, | ||
relay_parent_storage_root: Hash::default(), | ||
max_pov_size: 2, | ||
}, | ||
))) | ||
.unwrap(), | ||
_ => unimplemented!("Unexpected chain-api message"), | ||
}, | ||
} | ||
} | ||
} | ||
} |
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