feat: initialize Kurdistan SDK - independent fork of Polkadot SDK
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezkuwi.
|
||||
|
||||
// Pezkuwi 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.
|
||||
|
||||
// Pezkuwi 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 Pezkuwi. 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 pezkuwi_node_primitives::ValidationResult;
|
||||
use pezkuwi_node_subsystem::{
|
||||
messages::CandidateValidationMessage, overseer, SpawnedSubsystem, SubsystemError,
|
||||
};
|
||||
use pezkuwi_node_subsystem_types::OverseerSignal;
|
||||
use pezkuwi_primitives::{CandidateCommitments, Hash, HeadData, PersistedValidationData};
|
||||
|
||||
const LOG_TARGET: &str = "subsystem-bench::candidate-validation-mock";
|
||||
|
||||
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,
|
||||
validation_data,
|
||||
..
|
||||
} => {
|
||||
gum::debug!(target: LOG_TARGET, "ValidateFromExhaustive, PVD hash {:?}", validation_data.hash());
|
||||
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"),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user