Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
snapshot WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
drahnr committed May 6, 2021
1 parent 63cf483 commit a38f2b8
Show file tree
Hide file tree
Showing 11 changed files with 1,505 additions and 800 deletions.
1,598 changes: 820 additions & 778 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ members = [
"node/network/collator-protocol",
"node/network/gossip-support",
"node/overseer",
"node/overseer/overseer-gen",
"node/overseer/subsystems-gen",
"node/primitives",
"node/service",
"node/subsystem",
Expand Down
3 changes: 3 additions & 0 deletions behavior-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ thiserror = "1"
polkadot-service = { path = "../node/service", default-features = false }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
test-runner = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
log = "0.4"
env_logger = "0.8"
tokio = { version = "0.2.21", features = [ "signal", "rt-core", "rt-threaded", "blocking" ] }
futures = "0.3"
59 changes: 47 additions & 12 deletions behavior-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,68 @@

use polkadot_service as service;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, TaskExecutor};
use sp_core::crypto::set_default_ss58_version;
use test_runner::default_config;
use log::info;
use sc_chain_spec::ChainSpec;
use futures::future::FutureExt;

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("foo")]
Foo
#[error(transparent)]
SubstrateService(#[from] sc_service::Error),


#[error(transparent)]
PolkadotService(#[from] polkadot_service::Error),

#[error(transparent)]
Io(#[from]std::io::Error)
}

pub type Result = std::result::Result<T, Error>;
pub type Result<T> = std::result::Result<T, Error>;


macro_rules! behavior_testcase {
($name:ident => (&name:literal : $x:ty)* ) => {
let _ = env_logger::Builder::new().is_test(true).try_init();


for
};
}

/// ```rust
bahvior_test!(alpha_omega => {
"Alice"
}
/// ```


/// Launch a modified node with a given all subsystems instance
pub fn modded_node<S>(subsystems: S, chain_spec: Box<dyn ChainSpec>) -> Result<()> {
pub fn modded_node<Sel>(subsystemselection: Sel, chain_spec: Box<dyn ChainSpec>) -> Result<()> {

set_default_ss58_version(chain_spec);
// set_default_ss58_version(&chain_spec);

let grandpa_pause = None;

let jaeger_agent = None;

let telemetry_worker = None;

let mut runtime = tokio::runtime::Builder::new()
let mut tokio_rt = tokio::runtime::Builder::new()
.threaded_scheduler()
.enable_all()
.build();
.build()?;


let handle = tokio_rt.handle().clone();
let task_executor: TaskExecutor = (move |future, _task_type| {
handle.spawn(future).map(|_| ())
}).into();


let config = default_config();
let config = default_config(task_executor, chain_spec);
let initialize = move |config: Configuration| async move {
let task_manager =
service::build_full(
Expand All @@ -43,9 +76,11 @@ pub fn modded_node<S>(subsystems: S, chain_spec: Box<dyn ChainSpec>) -> Result<(
Ok::<_, Error>(task_manager)
};

let mut task_manager = tokio.block_on(initialize(self.config))?;
let res = tokio.block_on(main(task_manager.future().fuse()));
tokio.block_on(task_manager.clean_shutdown());
let mut task_manager = tokio_rt.block_on(initialize(config))?;
// futures::pin_mut!(task_manager);
let res = tokio_rt.block_on(task_manager.future().fuse());
tokio_rt.block_on(task_manager.clean_shutdown());
Ok(())
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion doc/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ and might not prove viable or yield signifcant outcomes.
### Impl

```rust
launch_integration_testcase!{
behavior_testcase!{
"TestRuntime" =>
"Alice": SubsystemsAll<GenericParam=DropAll,..>,
"Bob": SubsystemsAll<GenericParam=DropSome,..>,
Expand Down
10 changes: 6 additions & 4 deletions node/network/availability-recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use polkadot_node_network_protocol::{
request::RequestError,
},
};
use polkadot_node_subsystem_util::metrics::Metrics;
use polkadot_node_subsystem_util::request_session_info;
use polkadot_erasure_coding::{branches, branch_hash, recovery_threshold, obtain_chunks_v1};
mod error;
Expand All @@ -67,6 +68,7 @@ const LRU_SIZE: usize = 16;
/// The Availability Recovery Subsystem.
pub struct AvailabilityRecoverySubsystem {
fast_path: bool,
metrics: Metrics,
}

struct RequestFromBackersPhase {
Expand Down Expand Up @@ -742,13 +744,13 @@ async fn query_full_data(

impl AvailabilityRecoverySubsystem {
/// Create a new instance of `AvailabilityRecoverySubsystem` which starts with a fast path to request data from backers.
pub fn with_fast_path() -> Self {
Self { fast_path: true }
pub fn with_fast_path(metrics: Metrics) -> Self {
Self { fast_path: true, metrics }
}

/// Create a new instance of `AvailabilityRecoverySubsystem` which requests only chunks
pub fn with_chunks_only() -> Self {
Self { fast_path: false }
pub fn with_chunks_only(metrics: Metrics) -> Self {
Self { fast_path: false, metrics }
}

async fn run(
Expand Down
18 changes: 18 additions & 0 deletions node/overseer/overseer-gen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "polkadot-procmacro-overseer-gen"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
description = "Generate an overseer including builder pattern and message wrapper from a single struct."

[lib]
proc-macro = true

[dependencies]
syn = { version = "1.0.60", features = ["full", "extra-traits"] }
quote = "1.0.9"
proc-macro2 = "1.0.24"
assert_matches = "1.5.0"

[dev-dependencies]
trybuild = "1.0.41"
Loading

0 comments on commit a38f2b8

Please sign in to comment.