Retire puppet workers (#1449)

Closes #583

After the separation of PVF worker binaries, dedicated puppet workers
are not needed for tests anymore. The production workers can be used
instead, avoiding some code duplication and decreasing complexity.

The changes also make it possible to further refactor the code to
isolate workers completely.
This commit is contained in:
s0me0ne-unkn0wn
2023-09-11 19:14:07 +02:00
committed by GitHub
parent 4b8bd9060e
commit 2c8021f998
20 changed files with 71 additions and 376 deletions
@@ -11,11 +11,6 @@ license.workspace = true
name = "adder-collator"
path = "src/main.rs"
[[bin]]
name = "adder_collator_puppet_worker"
path = "bin/puppet_worker.rs"
required-features = ["test-utils"]
[dependencies]
parity-scale-codec = { version = "3.6.1", default-features = false, features = ["derive"] }
clap = { version = "4.4.2", features = ["derive"] }
@@ -33,25 +28,17 @@ polkadot-node-subsystem = { path = "../../../../node/subsystem" }
sc-cli = { path = "../../../../../substrate/client/cli" }
sp-core = { path = "../../../../../substrate/primitives/core" }
sc-service = { path = "../../../../../substrate/client/service" }
# This one is tricky. Even though it is not used directly by the collator, we still need it for the
# `puppet_worker` binary, which is required for the integration test. However, this shouldn't be
# a big problem since it is used transitively anyway.
polkadot-node-core-pvf = { path = "../../../../node/core/pvf", features = ["test-utils"], optional = true }
[dev-dependencies]
polkadot-parachain-primitives = { path = "../../.." }
polkadot-test-service = { path = "../../../../node/test/service" }
polkadot-node-core-pvf = { path = "../../../../node/core/pvf", features = ["test-utils"] }
substrate-test-utils = { path = "../../../../../substrate/test-utils" }
sc-service = { path = "../../../../../substrate/client/service" }
sp-keyring = { path = "../../../../../substrate/primitives/keyring" }
# For the puppet worker, depend on ourselves with the test-utils feature.
test-parachain-adder-collator = { path = "", features = ["test-utils"] }
tokio = { version = "1.24.2", features = ["macros"] }
[features]
network-protocol-staging = [ "polkadot-cli/network-protocol-staging" ]
# This feature is used to export test code to other crates without putting it in the production build.
# This is also used by the `puppet_worker` binary.
test-utils = [ "polkadot-node-core-pvf/test-utils" ]
@@ -1,17 +0,0 @@
// 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/>.
polkadot_node_core_pvf::decl_puppet_worker_main!();
@@ -17,8 +17,6 @@
//! Integration test that ensures that we can build and include parachain
//! blocks of the adder parachain.
const PUPPET_EXE: &str = env!("CARGO_BIN_EXE_adder_collator_puppet_worker");
// If this test is failing, make sure to run all tests with the `real-overseer` feature being
// enabled.
@@ -41,8 +39,12 @@ async fn collating_using_adder_collator() {
true,
);
let mut workers_path = std::env::current_exe().unwrap();
workers_path.pop();
workers_path.pop();
// start alice
let alice = polkadot_test_service::run_validator_node(alice_config, Some(PUPPET_EXE.into()));
let alice = polkadot_test_service::run_validator_node(alice_config, Some(workers_path.clone()));
let bob_config = polkadot_test_service::node_config(
|| {},
@@ -53,7 +55,7 @@ async fn collating_using_adder_collator() {
);
// start bob
let bob = polkadot_test_service::run_validator_node(bob_config, Some(PUPPET_EXE.into()));
let bob = polkadot_test_service::run_validator_node(bob_config, Some(workers_path));
let collator = test_parachain_adder_collator::Collator::new();
@@ -11,15 +11,10 @@ publish = false
name = "undying-collator"
path = "src/main.rs"
[[bin]]
name = "undying_collator_puppet_worker"
path = "bin/puppet_worker.rs"
required-features = ["test-utils"]
[dependencies]
parity-scale-codec = { version = "3.6.1", default-features = false, features = ["derive"] }
clap = { version = "4.4.2", features = ["derive"] }
futures = "0.3.19"
futures = "0.3.21"
futures-timer = "3.0.2"
log = "0.4.17"
@@ -33,24 +28,14 @@ polkadot-node-subsystem = { path = "../../../../node/subsystem" }
sc-cli = { path = "../../../../../substrate/client/cli" }
sp-core = { path = "../../../../../substrate/primitives/core" }
sc-service = { path = "../../../../../substrate/client/service" }
# This one is tricky. Even though it is not used directly by the collator, we still need it for the
# `puppet_worker` binary, which is required for the integration test. However, this shouldn't be
# a big problem since it is used transitively anyway.
polkadot-node-core-pvf = { path = "../../../../node/core/pvf", features = ["test-utils"], optional = true }
[dev-dependencies]
polkadot-parachain-primitives = { path = "../../.." }
polkadot-test-service = { path = "../../../../node/test/service" }
# For the puppet worker, depend on ourselves with the test-utils feature.
test-parachain-undying-collator = { path = "", features = ["test-utils"] }
polkadot-node-core-pvf = { path = "../../../../node/core/pvf", features = ["test-utils"] }
substrate-test-utils = { path = "../../../../../substrate/test-utils" }
sc-service = { path = "../../../../../substrate/client/service" }
sp-keyring = { path = "../../../../../substrate/primitives/keyring" }
tokio = { version = "1.24.2", features = ["macros"] }
[features]
# This feature is used to export test code to other crates without putting it in the production build.
# This is also used by the `puppet_worker` binary.
test-utils = [ "polkadot-node-core-pvf/test-utils" ]
@@ -1,17 +0,0 @@
// 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/>.
polkadot_node_core_pvf::decl_puppet_worker_main!();
@@ -17,8 +17,6 @@
//! Integration test that ensures that we can build and include parachain
//! blocks of the `Undying` parachain.
const PUPPET_EXE: &str = env!("CARGO_BIN_EXE_undying_collator_puppet_worker");
// If this test is failing, make sure to run all tests with the `real-overseer` feature being
// enabled.
#[tokio::test(flavor = "multi_thread")]
@@ -40,8 +38,12 @@ async fn collating_using_undying_collator() {
true,
);
let mut workers_path = std::env::current_exe().unwrap();
workers_path.pop();
workers_path.pop();
// start alice
let alice = polkadot_test_service::run_validator_node(alice_config, Some(PUPPET_EXE.into()));
let alice = polkadot_test_service::run_validator_node(alice_config, Some(workers_path.clone()));
let bob_config = polkadot_test_service::node_config(
|| {},
@@ -52,7 +54,7 @@ async fn collating_using_undying_collator() {
);
// start bob
let bob = polkadot_test_service::run_validator_node(bob_config, Some(PUPPET_EXE.into()));
let bob = polkadot_test_service::run_validator_node(bob_config, Some(workers_path));
let collator = test_parachain_undying_collator::Collator::new(1_000, 1);