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

PVF: separate worker binaries and build with musl #7147

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ root = true
indent_style=tab
indent_size=tab
tab_width=4
max_line_length=120
max_line_length=100
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
Expand Down
81 changes: 70 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tikv-jemallocator = "0.5.0"

# Crates in our workspace, defined as dependencies so we can pass them feature flags.
polkadot-cli = { path = "cli", features = [ "kusama-native", "westend-native", "rococo-native" ] }
polkadot-node-core-pvf-worker = { path = "node/core/pvf/worker" }
polkadot-node-core-pvf-prepare-worker = { path = "node/core/pvf/prepare-worker" }
polkadot-overseer = { path = "node/overseer" }

[dev-dependencies]
Expand Down Expand Up @@ -80,7 +80,10 @@ members = [
"node/core/parachains-inherent",
"node/core/provisioner",
"node/core/pvf",
"node/core/pvf/worker",
"node/core/pvf/common",
"node/core/pvf/binary-builder",
"node/core/pvf/execute-worker",
"node/core/pvf/prepare-worker",
"node/core/pvf-checker",
"node/core/runtime-api",
"node/network/approval-distribution",
Expand Down Expand Up @@ -207,7 +210,7 @@ try-runtime = [ "polkadot-cli/try-runtime" ]
fast-runtime = [ "polkadot-cli/fast-runtime" ]
runtime-metrics = [ "polkadot-cli/runtime-metrics" ]
pyroscope = ["polkadot-cli/pyroscope"]
jemalloc-allocator = ["polkadot-node-core-pvf-worker/jemalloc-allocator", "polkadot-overseer/jemalloc-allocator"]
jemalloc-allocator = ["polkadot-node-core-pvf-prepare-worker/jemalloc-allocator", "polkadot-overseer/jemalloc-allocator"]

# Configuration for building a .deb package - for use with `cargo-deb`
[package.metadata.deb]
Expand Down
2 changes: 0 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pyro = { package = "pyroscope", version = "0.3.1", optional = true }

service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true }
polkadot-client = { path = "../node/client", optional = true }
polkadot-node-core-pvf-worker = { path = "../node/core/pvf/worker", optional = true }
polkadot-performance-test = { path = "../node/test/performance-test", optional = true }

sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down Expand Up @@ -53,7 +52,6 @@ cli = [
"frame-benchmarking-cli",
"try-runtime-cli",
"polkadot-client",
"polkadot-node-core-pvf-worker",
]
runtime-benchmarks = [
"service/runtime-benchmarks",
Expand Down
19 changes: 0 additions & 19 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ pub enum Subcommand {
/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),

#[allow(missing_docs)]
#[command(name = "prepare-worker", hide = true)]
PvfPrepareWorker(ValidationWorkerCommand),

#[allow(missing_docs)]
#[command(name = "execute-worker", hide = true)]
PvfExecuteWorker(ValidationWorkerCommand),

/// Sub-commands concerned with benchmarking.
/// The pallet benchmarking moved to the `pallet` sub-command.
#[command(subcommand)]
Expand All @@ -75,17 +67,6 @@ pub enum Subcommand {
ChainInfo(sc_cli::ChainInfoCmd),
}

#[allow(missing_docs)]
#[derive(Debug, Parser)]
pub struct ValidationWorkerCommand {
/// The path to the validation host's socket.
#[arg(long)]
pub socket_path: String,
/// Calling node implementation version
#[arg(long)]
pub node_impl_version: String,
}

#[allow(missing_docs)]
#[derive(Debug, Parser)]
#[group(skip)]
Expand Down
44 changes: 0 additions & 44 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,50 +479,6 @@ pub fn run() -> Result<()> {
))
})?)
},
Some(Subcommand::PvfPrepareWorker(cmd)) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_colors(false);
let _ = builder.init();

#[cfg(target_os = "android")]
{
return Err(sc_cli::Error::Input(
"PVF preparation workers are not supported under this platform".into(),
)
.into())
}

#[cfg(not(target_os = "android"))]
{
polkadot_node_core_pvf_worker::prepare_worker_entrypoint(
&cmd.socket_path,
Some(&cmd.node_impl_version),
);
Ok(())
}
},
Some(Subcommand::PvfExecuteWorker(cmd)) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_colors(false);
let _ = builder.init();

#[cfg(target_os = "android")]
{
return Err(sc_cli::Error::Input(
"PVF execution workers are not supported under this platform".into(),
)
.into())
}

#[cfg(not(target_os = "android"))]
{
polkadot_node_core_pvf_worker::execute_worker_entrypoint(
&cmd.socket_path,
Some(&cmd.node_impl_version),
);
Ok(())
}
},
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
Expand Down
10 changes: 7 additions & 3 deletions node/core/candidate-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ const DEFAULT_APPROVAL_EXECUTION_TIMEOUT: Duration = Duration::from_secs(12);
pub struct Config {
/// The path where candidate validation can store compiled artifacts for PVFs.
pub artifacts_cache_path: PathBuf,
/// The path to extract the PVF workers to, if `program_path` is `None`.
pub pvf_workers_path: PathBuf,
/// The path to the executable which can be used for spawning PVF compilation & validation
/// workers.
pub program_path: PathBuf,
pub program_path: Option<PathBuf>,
}

/// The candidate validation subsystem.
Expand Down Expand Up @@ -117,6 +119,7 @@ impl<Context> CandidateValidationSubsystem {
self.metrics,
self.pvf_metrics,
self.config.artifacts_cache_path,
self.config.pvf_workers_path,
self.config.program_path,
)
.map_err(|e| SubsystemError::with_origin("candidate-validation", e))
Expand All @@ -131,10 +134,11 @@ async fn run<Context>(
metrics: Metrics,
pvf_metrics: polkadot_node_core_pvf::Metrics,
cache_path: PathBuf,
program_path: PathBuf,
workers_path: PathBuf,
program_path: Option<PathBuf>,
) -> SubsystemResult<()> {
let (validation_host, task) = polkadot_node_core_pvf::start(
polkadot_node_core_pvf::Config::new(cache_path, program_path),
polkadot_node_core_pvf::Config::new(cache_path, workers_path, program_path),
pvf_metrics,
);
ctx.spawn_blocking("pvf-validation-host", task.boxed())?;
Expand Down
14 changes: 13 additions & 1 deletion node/core/pvf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ version.workspace = true
authors.workspace = true
edition.workspace = true

[[bin]]
name = "puppet_worker"
path = "bin/puppet_worker.rs"

# TODO: run `cargo udeps`. Currently broken with the builder.
[dependencies]
always-assert = "0.1"
futures = "0.3.21"
Expand All @@ -13,12 +18,17 @@ libc = "0.2.139"
pin-project = "1.0.9"
rand = "0.8.5"
slotmap = "1.0"
tempfile = "3.3.0"
tokio = { version = "1.24.2", features = ["fs", "process"] }

parity-scale-codec = { version = "3.4.0", default-features = false, features = ["derive"] }

polkadot-parachain = { path = "../../../parachain" }
polkadot-core-primitives = { path = "../../../core-primitives" }
polkadot-node-core-pvf-common = { path = "common" }
# Must depend on the workers because the binaries must have been already built.
polkadot-node-core-pvf-execute-worker = { path = "execute-worker" }
polkadot-node-core-pvf-prepare-worker = { path = "prepare-worker" }
polkadot-node-metrics = { path = "../../metrics" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-primitives = { path = "../../../primitives" }
Expand All @@ -34,4 +44,6 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/substrate"
[dev-dependencies]
assert_matches = "1.4.0"
hex-literal = "0.3.4"
tempfile = "3.3.0"

adder = { package = "test-parachain-adder", path = "../../../parachain/test-parachains/adder" }
halt = { package = "test-parachain-halt", path = "../../../parachain/test-parachains/halt" }
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
// 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_worker::decl_puppet_worker_main!();
//! Puppet worker used for integration tests.

polkadot_node_core_pvf::decl_puppet_worker_main!();
Loading