Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update templates and Dockerfile to support Zombienet #587

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,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 --features $FEATURES -p $BINARY
Comment on lines +9 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI the reason to compile all binaries in the first stage was so that we only need to run the first stage once and only compile dependencies once. this would lead to a slightly longer first stage, but you only need to run it once.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we make use of that information? I only see a second stage being used, and we don't, for instance, use the same first stage to also build the mashnet-node. Am I wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We (at least try to) do that here: https://github.com/KILTprotocol/kilt-node/blob/develop/.maintain/build-image.sh
I would need to verify that this works. The last pipeline took ~80min

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this PR breaks this script.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first stage takes around 70 min anyway. But good to know. If that is the case, I will revert this commit before merging the DIP branch in develop.


# ===== 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 && \
Expand Down
3 changes: 3 additions & 0 deletions dip-template/nodes/dip-consumer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ cumulus-relay-chain-interface.workspace = true

[build-dependencies]
substrate-build-script-utils.workspace = true

[features]
default = []
20 changes: 10 additions & 10 deletions dip-template/nodes/dip-consumer/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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<Box<dyn ChainSpec>, String> {
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpecTrait>, 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))?)),
}
}

Expand Down Expand Up @@ -76,7 +76,7 @@ impl SubstrateCli for Cli {
2023
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpecTrait>, String> {
load_spec(id)
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ impl SubstrateCli for RelayChainCli {
2023
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpecTrait>, String> {
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ impl CliConfiguration<Self> for RelayChainCli {
fn prometheus_config(
&self,
default_listen_port: u16,
chain_spec: &Box<dyn ChainSpec>,
chain_spec: &Box<dyn ChainSpecTrait>,
) -> Result<Option<PrometheusConfig>> {
self.base.base.prometheus_config(default_listen_port, chain_spec)
}
Expand Down Expand Up @@ -361,7 +361,7 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.announce_block()
}

fn telemetry_endpoints(&self, chain_spec: &Box<dyn ChainSpec>) -> Result<Option<TelemetryEndpoints>> {
fn telemetry_endpoints(&self, chain_spec: &Box<dyn ChainSpecTrait>) -> Result<Option<TelemetryEndpoints>> {
self.base.base.telemetry_endpoints(chain_spec)
}
}
3 changes: 3 additions & 0 deletions dip-template/nodes/dip-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ cumulus-relay-chain-interface.workspace = true

[build-dependencies]
substrate-build-script-utils.workspace = true

[features]
default = []
20 changes: 10 additions & 10 deletions dip-template/nodes/dip-provider/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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<Box<dyn ChainSpec>, String> {
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpecTrait>, 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))?)),
}
}

Expand Down Expand Up @@ -76,7 +76,7 @@ impl SubstrateCli for Cli {
2023
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpecTrait>, String> {
load_spec(id)
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ impl SubstrateCli for RelayChainCli {
2023
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpecTrait>, String> {
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ impl CliConfiguration<Self> for RelayChainCli {
fn prometheus_config(
&self,
default_listen_port: u16,
chain_spec: &Box<dyn ChainSpec>,
chain_spec: &Box<dyn ChainSpecTrait>,
) -> Result<Option<PrometheusConfig>> {
self.base.base.prometheus_config(default_listen_port, chain_spec)
}
Expand Down Expand Up @@ -361,7 +361,7 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.announce_block()
}

fn telemetry_endpoints(&self, chain_spec: &Box<dyn ChainSpec>) -> Result<Option<TelemetryEndpoints>> {
fn telemetry_endpoints(&self, chain_spec: &Box<dyn ChainSpecTrait>) -> Result<Option<TelemetryEndpoints>> {
self.base.base.telemetry_endpoints(chain_spec)
}
}