From 9c34bd3a2d43ee7506d31775bb8687c38525c223 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Wed, 22 Nov 2023 13:29:41 +0100 Subject: [PATCH 1/4] Update build-chainspec command to include empty strings because of Zombienet --- Dockerfile | 11 +++++----- .../nodes/dip-consumer/src/command.rs | 20 +++++++++---------- .../nodes/dip-provider/src/command.rs | 20 +++++++++---------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index c64f906b8e..620b71d077 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,20 +5,21 @@ FROM paritytech/ci-unified:bullseye-1.70.0 as builder WORKDIR /build -ARG FEATURES=default +ARG BINARY=kilt-parachain COPY . . -RUN cargo build --locked --release --features $FEATURES +RUN cargo build --locked --release -p $BINARY # ===== SECOND STAGE ====== FROM docker.io/library/ubuntu:20.04 -LABEL description="This is the 2nd stage: a very small image where we copy the kilt-parachain binary." -ARG NODE_TYPE=kilt-parachain +ARG BINARY=kilt-parachain -COPY --from=builder /build/target/release/$NODE_TYPE /usr/local/bin/node-executable +LABEL description="This is the 2nd stage: a very small image where we copy the ${BINARY} binary." + +COPY --from=builder /build/target/release/$BINARY /usr/local/bin/node-executable RUN useradd -m -u 1000 -U -s /bin/sh -d /node node && \ mkdir -p /node/.local/share/node && \ diff --git a/dip-template/nodes/dip-consumer/src/command.rs b/dip-template/nodes/dip-consumer/src/command.rs index e560839502..e857af5da7 100644 --- a/dip-template/nodes/dip-consumer/src/command.rs +++ b/dip-template/nodes/dip-consumer/src/command.rs @@ -21,8 +21,8 @@ use std::{fs::create_dir_all, net::SocketAddr}; use cumulus_primitives_core::ParaId; use log::{info, warn}; use sc_cli::{ - ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, LoggerBuilder, - NetworkParams, Result, SharedParams, SubstrateCli, + ChainSpec as ChainSpecTrait, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, + LoggerBuilder, NetworkParams, Result, SharedParams, SubstrateCli, }; use sc_service::{ config::{BasePath, PrometheusConfig}, @@ -33,15 +33,15 @@ use sc_telemetry::TelemetryEndpoints; use sp_runtime::traits::AccountIdConversion; use crate::{ - chain_spec::{development_config, Extensions}, + chain_spec::{development_config, ChainSpec, Extensions}, cli::{Cli, RelayChainCli, Subcommand}, service::{new_partial, start_parachain_node}, }; -fn load_spec(id: &str) -> std::result::Result, String> { +fn load_spec(id: &str) -> std::result::Result, String> { match id { - "dev" => Ok(Box::new(development_config())), - _ => Err("Unrecognized spec ID.".into()), + "dev" | "" => Ok(Box::new(development_config())), + path => Ok(Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(path))?)), } } @@ -76,7 +76,7 @@ impl SubstrateCli for Cli { 2023 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { load_spec(id) } } @@ -112,7 +112,7 @@ impl SubstrateCli for RelayChainCli { 2023 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) } } @@ -289,7 +289,7 @@ impl CliConfiguration for RelayChainCli { fn prometheus_config( &self, default_listen_port: u16, - chain_spec: &Box, + chain_spec: &Box, ) -> Result> { self.base.base.prometheus_config(default_listen_port, chain_spec) } @@ -361,7 +361,7 @@ impl CliConfiguration for RelayChainCli { self.base.base.announce_block() } - fn telemetry_endpoints(&self, chain_spec: &Box) -> Result> { + fn telemetry_endpoints(&self, chain_spec: &Box) -> Result> { self.base.base.telemetry_endpoints(chain_spec) } } diff --git a/dip-template/nodes/dip-provider/src/command.rs b/dip-template/nodes/dip-provider/src/command.rs index 6e508956e0..f32dd81232 100644 --- a/dip-template/nodes/dip-provider/src/command.rs +++ b/dip-template/nodes/dip-provider/src/command.rs @@ -21,8 +21,8 @@ use std::{fs::create_dir_all, net::SocketAddr}; use cumulus_primitives_core::ParaId; use log::{info, warn}; use sc_cli::{ - ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, LoggerBuilder, - NetworkParams, Result, SharedParams, SubstrateCli, + ChainSpec as ChainSpecTrait, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, + LoggerBuilder, NetworkParams, Result, SharedParams, SubstrateCli, }; use sc_service::{ config::{BasePath, PrometheusConfig}, @@ -33,15 +33,15 @@ use sc_telemetry::TelemetryEndpoints; use sp_runtime::traits::AccountIdConversion; use crate::{ - chain_spec::{development_config, Extensions}, + chain_spec::{development_config, ChainSpec, Extensions}, cli::{Cli, RelayChainCli, Subcommand}, service::{new_partial, start_parachain_node}, }; -fn load_spec(id: &str) -> std::result::Result, String> { +fn load_spec(id: &str) -> std::result::Result, String> { match id { - "dev" => Ok(Box::new(development_config())), - _ => Err("Unrecognized spec ID.".into()), + "dev" | "" => Ok(Box::new(development_config())), + path => Ok(Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(path))?)), } } @@ -76,7 +76,7 @@ impl SubstrateCli for Cli { 2023 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { load_spec(id) } } @@ -112,7 +112,7 @@ impl SubstrateCli for RelayChainCli { 2023 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) } } @@ -289,7 +289,7 @@ impl CliConfiguration for RelayChainCli { fn prometheus_config( &self, default_listen_port: u16, - chain_spec: &Box, + chain_spec: &Box, ) -> Result> { self.base.base.prometheus_config(default_listen_port, chain_spec) } @@ -361,7 +361,7 @@ impl CliConfiguration for RelayChainCli { self.base.base.announce_block() } - fn telemetry_endpoints(&self, chain_spec: &Box) -> Result> { + fn telemetry_endpoints(&self, chain_spec: &Box) -> Result> { self.base.base.telemetry_endpoints(chain_spec) } } From 4fb1954f692eeee7a715fbdd93675ed3177ad3a9 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Thu, 23 Nov 2023 11:54:45 +0100 Subject: [PATCH 2/4] Fix Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 620b71d077..ace5ce348b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,12 @@ FROM paritytech/ci-unified:bullseye-1.70.0 as builder WORKDIR /build +ARG FEATURES=default ARG BINARY=kilt-parachain COPY . . -RUN cargo build --locked --release -p $BINARY +RUN cargo build --locked --release --features $FEATURES -p $BINARY # ===== SECOND STAGE ====== From 12f018c5fcdc1e6497a0f733970e58bc0eba9065 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Thu, 23 Nov 2023 11:58:21 +0100 Subject: [PATCH 3/4] Add deafult features to template nodes --- dip-template/nodes/dip-consumer/Cargo.toml | 3 +++ dip-template/nodes/dip-provider/Cargo.toml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dip-template/nodes/dip-consumer/Cargo.toml b/dip-template/nodes/dip-consumer/Cargo.toml index b48e55d0db..2937dee83f 100644 --- a/dip-template/nodes/dip-consumer/Cargo.toml +++ b/dip-template/nodes/dip-consumer/Cargo.toml @@ -68,3 +68,6 @@ cumulus-relay-chain-interface.workspace = true [build-dependencies] substrate-build-script-utils.workspace = true + +[features] +default = [] diff --git a/dip-template/nodes/dip-provider/Cargo.toml b/dip-template/nodes/dip-provider/Cargo.toml index 0bc866dddf..b9d134dbc7 100644 --- a/dip-template/nodes/dip-provider/Cargo.toml +++ b/dip-template/nodes/dip-provider/Cargo.toml @@ -68,3 +68,6 @@ cumulus-relay-chain-interface.workspace = true [build-dependencies] substrate-build-script-utils.workspace = true + +[features] +default = [] From 415aa0779b2cf3ef154d2a3ff7cd1bf61809d9e3 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 27 Nov 2023 09:48:34 +0100 Subject: [PATCH 4/4] Revert ChainSpec trait renaming --- .../nodes/dip-consumer/src/command.rs | 20 ++++++++++--------- .../nodes/dip-provider/src/command.rs | 20 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/dip-template/nodes/dip-consumer/src/command.rs b/dip-template/nodes/dip-consumer/src/command.rs index e857af5da7..7d5809ceda 100644 --- a/dip-template/nodes/dip-consumer/src/command.rs +++ b/dip-template/nodes/dip-consumer/src/command.rs @@ -21,8 +21,8 @@ use std::{fs::create_dir_all, net::SocketAddr}; use cumulus_primitives_core::ParaId; use log::{info, warn}; use sc_cli::{ - ChainSpec as ChainSpecTrait, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, - LoggerBuilder, NetworkParams, Result, SharedParams, SubstrateCli, + ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, LoggerBuilder, + NetworkParams, Result, SharedParams, SubstrateCli, }; use sc_service::{ config::{BasePath, PrometheusConfig}, @@ -33,15 +33,17 @@ use sc_telemetry::TelemetryEndpoints; use sp_runtime::traits::AccountIdConversion; use crate::{ - chain_spec::{development_config, ChainSpec, Extensions}, + chain_spec::{development_config, ChainSpec as ConsumerChainSpec, Extensions}, cli::{Cli, RelayChainCli, Subcommand}, service::{new_partial, start_parachain_node}, }; -fn load_spec(id: &str) -> std::result::Result, String> { +fn load_spec(id: &str) -> std::result::Result, String> { match id { "dev" | "" => Ok(Box::new(development_config())), - path => Ok(Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(path))?)), + path => Ok(Box::new(ConsumerChainSpec::from_json_file(std::path::PathBuf::from( + path, + ))?)), } } @@ -76,7 +78,7 @@ impl SubstrateCli for Cli { 2023 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { load_spec(id) } } @@ -112,7 +114,7 @@ impl SubstrateCli for RelayChainCli { 2023 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) } } @@ -289,7 +291,7 @@ impl CliConfiguration for RelayChainCli { fn prometheus_config( &self, default_listen_port: u16, - chain_spec: &Box, + chain_spec: &Box, ) -> Result> { self.base.base.prometheus_config(default_listen_port, chain_spec) } @@ -361,7 +363,7 @@ impl CliConfiguration for RelayChainCli { self.base.base.announce_block() } - fn telemetry_endpoints(&self, chain_spec: &Box) -> Result> { + fn telemetry_endpoints(&self, chain_spec: &Box) -> Result> { self.base.base.telemetry_endpoints(chain_spec) } } diff --git a/dip-template/nodes/dip-provider/src/command.rs b/dip-template/nodes/dip-provider/src/command.rs index f32dd81232..ca4f66d478 100644 --- a/dip-template/nodes/dip-provider/src/command.rs +++ b/dip-template/nodes/dip-provider/src/command.rs @@ -21,8 +21,8 @@ use std::{fs::create_dir_all, net::SocketAddr}; use cumulus_primitives_core::ParaId; use log::{info, warn}; use sc_cli::{ - ChainSpec as ChainSpecTrait, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, - LoggerBuilder, NetworkParams, Result, SharedParams, SubstrateCli, + ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, LoggerBuilder, + NetworkParams, Result, SharedParams, SubstrateCli, }; use sc_service::{ config::{BasePath, PrometheusConfig}, @@ -33,15 +33,17 @@ use sc_telemetry::TelemetryEndpoints; use sp_runtime::traits::AccountIdConversion; use crate::{ - chain_spec::{development_config, ChainSpec, Extensions}, + chain_spec::{development_config, ChainSpec as ProviderChainSpec, Extensions}, cli::{Cli, RelayChainCli, Subcommand}, service::{new_partial, start_parachain_node}, }; -fn load_spec(id: &str) -> std::result::Result, String> { +fn load_spec(id: &str) -> std::result::Result, String> { match id { "dev" | "" => Ok(Box::new(development_config())), - path => Ok(Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(path))?)), + path => Ok(Box::new(ProviderChainSpec::from_json_file(std::path::PathBuf::from( + path, + ))?)), } } @@ -76,7 +78,7 @@ impl SubstrateCli for Cli { 2023 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { load_spec(id) } } @@ -112,7 +114,7 @@ impl SubstrateCli for RelayChainCli { 2023 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) } } @@ -289,7 +291,7 @@ impl CliConfiguration for RelayChainCli { fn prometheus_config( &self, default_listen_port: u16, - chain_spec: &Box, + chain_spec: &Box, ) -> Result> { self.base.base.prometheus_config(default_listen_port, chain_spec) } @@ -361,7 +363,7 @@ impl CliConfiguration for RelayChainCli { self.base.base.announce_block() } - fn telemetry_endpoints(&self, chain_spec: &Box) -> Result> { + fn telemetry_endpoints(&self, chain_spec: &Box) -> Result> { self.base.base.telemetry_endpoints(chain_spec) } }