mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 19:01:08 +00:00
XCM revamp & Ping pallet (#391)
* Add spambot * Fixes * Add some extra functions to spambot, bump version * Lock.. * Aggregate HRMP (XCMP/HMP) messages. Payloads for spambot. * Fix tests, bump Polkadot. * Fix HMP tests * Rename Hrmp -> Xcmp for handler/sender * Use master branch * Test Xcm message passing & rename away from HMP * Docs * Introduce fee payment mechanics into XCM. * Rename spambot -> ping * Lock * XCMP message dispatch system reimagining - Moved most of the logic into xcm-handler pallet - Altered the outgoing XCMP API from push to pull - Changed underlying outgoing queue data structures to avoid multi-page read/writes - Introduced queuing for incoming messages - Introduced signal messages as a flow-control sub-stream - Introduced flow-control with basic threshold back-pressure - Introduced overall weight limitation on messages executed - Additonal alterations to XCM APIs for the new system * Should process any remaining XCM messages when we're not doing anything else. * Update API usage and preparation for the big build. * Some build fixes * Build fixes * xcm-handler builds * Fix warnings * Docs * Parachains system builds * Parachain runtime building * Fix build * Introduce transfer_asset specialisation. * Fixes * Two-stage upgrade for parachains. * Fixes * Fixes * Updates for message sending. * Repotting/renaming. Add primitives/utility. * Remove real-overseer and bump refs * Configure & document Rococo XCM runtime. * Add shell runtime, some companion changes for #8589 * Bumps & fixes * Fix test * Build fix * Update pallets/xcmp-queue/src/lib.rs Co-authored-by: Amar Singh <asinghchrony@protonmail.com> * Make tests compile * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * remove unused * remove unused event stuff * Adds proper validation-worker to make integration tests work * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * import saturating * remove panic test Co-authored-by: Robert Habermeier <rphmeier@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Amar Singh <asinghchrony@protonmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "cumulus-test-relay-validation-worker-provider"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
polkadot-node-core-pvf = { git = "https://github.com/paritytech/polkadot", branch = "master" }
|
||||
@@ -0,0 +1,113 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus 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.
|
||||
|
||||
// Cumulus 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 Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{
|
||||
env, fs,
|
||||
path::{Path, PathBuf},
|
||||
process::{self, Command},
|
||||
};
|
||||
|
||||
/// The name of the project we will building.
|
||||
const PROJECT_NAME: &str = "validation-worker";
|
||||
/// The env variable that instructs us to skip the build.
|
||||
const SKIP_ENV: &str = "SKIP_BUILD";
|
||||
|
||||
fn main() {
|
||||
if env::var(SKIP_ENV).is_ok() { return
|
||||
}
|
||||
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("`OUT_DIR` is set by cargo"));
|
||||
|
||||
let project = create_project(&out_dir);
|
||||
build_project(&project.join("Cargo.toml"));
|
||||
|
||||
fs::copy(
|
||||
project.join("target/release").join(PROJECT_NAME),
|
||||
out_dir.join(PROJECT_NAME),
|
||||
)
|
||||
.expect("Copies validation worker");
|
||||
}
|
||||
|
||||
fn find_cargo_lock() -> PathBuf {
|
||||
let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is set by cargo"));
|
||||
|
||||
loop {
|
||||
if path.join("Cargo.lock").exists() {
|
||||
return path.join("Cargo.lock")
|
||||
}
|
||||
|
||||
if !path.pop() {
|
||||
panic!("Could not find `Cargo.lock`")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_project(out_dir: &Path) -> PathBuf {
|
||||
let project_dir = out_dir.join(format!("{}-project", PROJECT_NAME));
|
||||
fs::create_dir_all(project_dir.join("src")).expect("Creates project dir and project src dir");
|
||||
|
||||
let cargo_toml = format!(
|
||||
r#"
|
||||
[package]
|
||||
name = "{project_name}"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
cumulus-test-relay-validation-worker-provider = {{ path = "{provider_path}" }}
|
||||
|
||||
[workspace]
|
||||
"#,
|
||||
project_name = PROJECT_NAME,
|
||||
provider_path =
|
||||
env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is set by cargo"),
|
||||
);
|
||||
|
||||
fs::write(project_dir.join("Cargo.toml"), cargo_toml).expect("Writes project `Cargo.toml`");
|
||||
|
||||
fs::write(
|
||||
project_dir.join("src").join("main.rs"),
|
||||
r#"
|
||||
cumulus_test_relay_validation_worker_provider::polkadot_node_core_pvf::decl_puppet_worker_main!();
|
||||
"#,
|
||||
)
|
||||
.expect("Writes `main.rs`");
|
||||
|
||||
fs::copy(find_cargo_lock(), project_dir.join("Cargo.lock")).expect("Copies `Cargo.lock`");
|
||||
|
||||
project_dir
|
||||
}
|
||||
|
||||
fn build_project(cargo_toml: &Path) {
|
||||
let cargo = env::var("CARGO").expect("`CARGO` env variable is always set by cargo");
|
||||
|
||||
let status = Command::new(cargo)
|
||||
.arg("build")
|
||||
.arg("--release")
|
||||
.arg(format!("--manifest-path={}", cargo_toml.display()))
|
||||
// Unset the `CARGO_TARGET_DIR` to prevent a cargo deadlock (cargo locks a target dir exclusive).
|
||||
.env_remove("CARGO_TARGET_DIR")
|
||||
// Do not call us recursively.
|
||||
.env(SKIP_ENV, "1")
|
||||
.status();
|
||||
|
||||
match status.map(|s| s.success()) {
|
||||
Ok(true) => {}
|
||||
// Use `process.exit(1)` to have a clean error output.
|
||||
_ => process::exit(1),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus 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.
|
||||
|
||||
// Cumulus 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 Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Provides the [`VALIDATION_WORKER`] for integration tests in Cumulus.
|
||||
//!
|
||||
//! The validation worker is used by the relay chain to validate parachains. This worker is placed
|
||||
//! in an extra process to provide better security and to ensure that a worker can be killed etc.
|
||||
//!
|
||||
//! !!This should only be used for tests!!
|
||||
|
||||
pub use polkadot_node_core_pvf;
|
||||
|
||||
/// The path to the validation worker.
|
||||
pub const VALIDATION_WORKER: &str = concat!(env!("OUT_DIR"), "/validation-worker");
|
||||
@@ -213,7 +213,9 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
type Event = Event;
|
||||
type OnValidationData = ();
|
||||
type DownwardMessageHandlers = ();
|
||||
type HrmpMessageHandlers = ();
|
||||
type OutboundXcmpMessageSource = ();
|
||||
type XcmpMessageHandler = ();
|
||||
type ReservedXcmpWeight = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -231,7 +233,7 @@ construct_runtime! {
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
|
||||
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event},
|
||||
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>},
|
||||
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ cumulus-client-network = { path = "../../client/network" }
|
||||
cumulus-client-service = { path = "../../client/service" }
|
||||
cumulus-primitives-core = { path = "../../primitives/core" }
|
||||
cumulus-test-runtime = { path = "../runtime" }
|
||||
cumulus-test-relay-validation-worker-provider = { path = "../relay-validation-worker-provider" }
|
||||
|
||||
# RPC related dependencies
|
||||
jsonrpc-core = "15.1.0"
|
||||
|
||||
@@ -162,6 +162,7 @@ where
|
||||
} else {
|
||||
polkadot_service::IsCollator::No
|
||||
},
|
||||
None,
|
||||
)
|
||||
.map_err(|e| match e {
|
||||
polkadot_service::Error::Sub(x) => x,
|
||||
@@ -546,3 +547,22 @@ impl TestNode {
|
||||
self.client.wait_for_blocks(count)
|
||||
}
|
||||
}
|
||||
|
||||
/// Run a relay-chain validator node.
|
||||
///
|
||||
/// This is essentially a wrapper around
|
||||
/// [`run_validator_node`](polkadot_test_service::run_validator_node).
|
||||
pub fn run_relay_chain_validator_node(
|
||||
task_executor: TaskExecutor,
|
||||
key: Sr25519Keyring,
|
||||
storage_update_func: impl Fn(),
|
||||
boot_nodes: Vec<MultiaddrWithPeerId>,
|
||||
) -> polkadot_test_service::PolkadotTestNode {
|
||||
polkadot_test_service::run_validator_node(
|
||||
task_executor,
|
||||
key,
|
||||
storage_update_func,
|
||||
boot_nodes,
|
||||
Some(cumulus_test_relay_validation_worker_provider::VALIDATION_WORKER.into()),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use cumulus_test_service::{initial_head_data, Keyring::*};
|
||||
use cumulus_test_service::{initial_head_data, run_relay_chain_validator_node, Keyring::*};
|
||||
use futures::join;
|
||||
use sc_service::TaskExecutor;
|
||||
|
||||
@@ -28,16 +28,11 @@ async fn test_collating_and_non_collator_mode_catching_up(task_executor: TaskExe
|
||||
let para_id = ParaId::from(100);
|
||||
|
||||
// start alice
|
||||
let alice =
|
||||
polkadot_test_service::run_validator_node(task_executor.clone(), Alice, || {}, vec![]);
|
||||
let alice = run_relay_chain_validator_node(task_executor.clone(), Alice, || {}, vec![]);
|
||||
|
||||
// start bob
|
||||
let bob = polkadot_test_service::run_validator_node(
|
||||
task_executor.clone(),
|
||||
Bob,
|
||||
|| {},
|
||||
vec![alice.addr.clone()],
|
||||
);
|
||||
let bob =
|
||||
run_relay_chain_validator_node(task_executor.clone(), Bob, || {}, vec![alice.addr.clone()]);
|
||||
|
||||
// register parachain
|
||||
alice
|
||||
|
||||
Reference in New Issue
Block a user