Skip to content

Commit

Permalink
Merge pull request #259 from luguslabs/multi
Browse files Browse the repository at this point in the history
#258 Upgrade to substrate 2.0 and subkey 2.0
  • Loading branch information
branciard authored Oct 17, 2020
2 parents 08810c8 + d611cee commit 1b5ac03
Show file tree
Hide file tree
Showing 38 changed files with 909 additions and 918 deletions.
1,121 changes: 598 additions & 523 deletions chain/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt-get -y update; \
cmake pkg-config libssl-dev git gcc build-essential clang libclang-dev curl ca-certificates
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup update nightly && rustup target add wasm32-unknown-unknown --toolchain nightly
RUN rustup update nightly-2020-10-06 && rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-06
RUN cargo build --release
RUN ./target/release/archipel build-spec --disable-default-bootnode --chain local > archipelTemplateSpec.json
RUN ./target/release/archipel build-spec --disable-default-bootnode --chain local --raw > archipelTemplateSpecRaw.json
Expand Down
8 changes: 4 additions & 4 deletions chain/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,31 @@ then
exit 1
fi

ARCHIPEL_SS58_ADDRESS_ED25519=$(subkey inspect-key --scheme Ed25519 "$ARCHIPEL_KEY_SEED" | grep SS58 | cut -d":" -f2 | sed -e 's/^[[:space:]]*//')
ARCHIPEL_SS58_ADDRESS_ED25519=$(subkey inspect --scheme Ed25519 "$ARCHIPEL_KEY_SEED" | grep SS58 | cut -d":" -f2 | sed -e 's/^[[:space:]]*//')

if [ -z "$ARCHIPEL_SS58_ADDRESS_ED25519" ]
then
echo "\$ARCHIPEL_SS58_ADDRESS_ED25519 no found using subkey"
exit 1
fi

ARCHIPEL_SS58_ADDRESS_SR25519=$(subkey inspect-key --scheme Sr25519 "$ARCHIPEL_KEY_SEED" | grep SS58 | cut -d":" -f2 | sed -e 's/^[[:space:]]*//')
ARCHIPEL_SS58_ADDRESS_SR25519=$(subkey inspect --scheme Sr25519 "$ARCHIPEL_KEY_SEED" | grep SS58 | cut -d":" -f2 | sed -e 's/^[[:space:]]*//')

if [ -z "$ARCHIPEL_SS58_ADDRESS_SR25519" ]
then
echo "\$ARCHIPEL_SS58_ADDRESS_SR25519 no found using subkey"
exit 1
fi

ARCHIPEL_PUBLIC_KEY_ED25519=$(subkey inspect-key --scheme Ed25519 "$ARCHIPEL_KEY_SEED" | grep Public | cut -d":" -f2 | sed -e 's/^[[:space:]]*//')
ARCHIPEL_PUBLIC_KEY_ED25519=$(subkey inspect --scheme Ed25519 "$ARCHIPEL_KEY_SEED" | grep Public | cut -d":" -f2 | sed -e 's/^[[:space:]]*//')

if [ -z "$ARCHIPEL_PUBLIC_KEY_ED25519" ]
then
echo "\$ARCHIPEL_PUBLIC_KEY_ED25519 no found using subkey"
exit 1
fi

ARCHIPEL_PUBLIC_KEY_SR25519=$(subkey inspect-key --scheme Sr25519 "$ARCHIPEL_KEY_SEED" | grep Public | cut -d":" -f2 | sed -e 's/^[[:space:]]*//')
ARCHIPEL_PUBLIC_KEY_SR25519=$(subkey inspect --scheme Sr25519 "$ARCHIPEL_KEY_SEED" | grep Public | cut -d":" -f2 | sed -e 's/^[[:space:]]*//')
if [ -z "$ARCHIPEL_PUBLIC_KEY_SR25519" ]
then
echo "\$ARCHIPEL_PUBLIC_KEY_SR25519 no found using subkey"
Expand Down
163 changes: 37 additions & 126 deletions chain/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,140 +7,51 @@ homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'archipel'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '2.0.0-rc6'
version = '2.0.0'

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']

[[bin]]
name = 'archipel'

[dependencies.node-archipel-runtime]
path = '../runtime'
version = '2.0.0-rc6'
[dependencies.pallet-transaction-payment-rpc]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sc-basic-authorship]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-cli]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-client-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sc-consensus]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-executor]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-rpc]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sc-rpc-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-service]
features = ['wasmtime']
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sc-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-api]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-block-builder]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-blockchain]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-consensus]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sp-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '0.8.0-rc6'

[dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-finality-grandpa]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-inherents]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.sp-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'

[dependencies.substrate-frame-rpc-system]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'
[build-dependencies]
substrate-build-script-utils = '2.0.0'

[dependencies]
jsonrpc-core = '14.0.3'
jsonrpc-core = '15.0.0'
structopt = '0.3.8'

[build-dependencies.substrate-build-script-utils]
git = 'https://github.com/paritytech/substrate.git'
tag = 'v2.0.0-rc6'
version = '2.0.0-rc6'
# local dependencies
node-archipel-runtime = { path = '../runtime', version = '2.0.0' }

# Substrate dependencies
frame-benchmarking = '2.0.0'
frame-benchmarking-cli = '2.0.0'
pallet-transaction-payment-rpc = '2.0.0'
sc-basic-authorship = '0.8.0'
sc-cli = { features = ['wasmtime'], version = '0.8.0' }
sc-client-api = '2.0.0'
sc-consensus = '0.8.0'
sc-consensus-aura = '0.8.0'
sc-executor = { features = ['wasmtime'], version = '0.8.0' }
sc-finality-grandpa = '0.8.0'
sc-rpc = '2.0.0'
sc-rpc-api = '0.8.0'
sc-service = { features = ['wasmtime'], version = '0.8.0' }
sc-transaction-pool = '2.0.0'
sp-api = '2.0.0'
sp-block-builder = '2.0.0'
sp-blockchain = '2.0.0'
sp-consensus = '0.8.0'
sp-consensus-aura = '0.8.0'
sp-core = '2.0.0'
sp-finality-grandpa = '2.0.0'
sp-inherents = '2.0.0'
sp-runtime = '2.0.0'
sp-transaction-pool = '2.0.0'
substrate-frame-rpc-system = '2.0.0'

[features]
default = []
runtime-benchmarks = ['node-archipel-runtime/runtime-benchmarks']
2 changes: 1 addition & 1 deletion chain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sp_core::{Pair, Public, sr25519};
use node_archipel_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
SudoConfig, SystemConfig, WASM_BINARY, Signature
SudoConfig, SystemConfig, WASM_BINARY, Signature
};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_finality_grandpa::AuthorityId as GrandpaId;
Expand Down
32 changes: 30 additions & 2 deletions chain/node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sc_cli::{RunCmd, Subcommand};
use structopt::StructOpt;
use sc_cli::RunCmd;

#[derive(Debug, StructOpt)]
pub struct Cli {
Expand All @@ -8,4 +8,32 @@ pub struct Cli {

#[structopt(flatten)]
pub run: RunCmd,
}
}

#[derive(Debug, StructOpt)]
pub enum Subcommand {
/// Build a chain specification.
BuildSpec(sc_cli::BuildSpecCmd),

/// Validate blocks.
CheckBlock(sc_cli::CheckBlockCmd),

/// Export blocks.
ExportBlocks(sc_cli::ExportBlocksCmd),

/// Export the state of a given block into a chain spec.
ExportState(sc_cli::ExportStateCmd),

/// Import blocks.
ImportBlocks(sc_cli::ImportBlocksCmd),

/// Remove the whole chain.
PurgeChain(sc_cli::PurgeChainCmd),

/// Revert the chain to a previous state.
Revert(sc_cli::RevertCmd),

/// The custom benchmark subcommmand benchmarking runtime pallets.
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}
75 changes: 62 additions & 13 deletions chain/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::chain_spec;
use crate::cli::Cli;
use crate::service;
use crate::{chain_spec, service};
use crate::cli::{Cli, Subcommand};
use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec};
use sc_service::PartialComponents;
use crate::service::new_partial;
use node_archipel_runtime::Block;

impl SubstrateCli for Cli {
fn impl_name() -> String {
Expand Down Expand Up @@ -66,15 +65,65 @@ impl SubstrateCli for Cli {
pub fn run() -> sc_cli::Result<()> {
let cli = Cli::from_args();

match cli.subcommand {
Some(ref subcommand) => {
let runner = cli.create_runner(subcommand)?;
runner.run_subcommand(subcommand, |config| {
let PartialComponents { client, backend, task_manager, import_queue, .. }
= new_partial(&config)?;
Ok((client, backend, import_queue, task_manager))
match &cli.subcommand {
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
},
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
})
}
},
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, config.database), task_manager))
})
},
Some(Subcommand::ExportState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, config.chain_spec), task_manager))
})
},
Some(Subcommand::ImportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, import_queue, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, import_queue), task_manager))
})
},
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.database))
},
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let PartialComponents { client, task_manager, backend, ..}
= service::new_partial(&config)?;
Ok((cmd.run(client, backend), task_manager))
})
},
Some(Subcommand::Benchmark(cmd)) => {
if cfg!(feature = "runtime-benchmarks") {
let runner = cli.create_runner(cmd)?;

runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`.".into())
}
},
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| match config.role {
Expand All @@ -83,4 +132,4 @@ pub fn run() -> sc_cli::Result<()> {
})
}
}
}
}
Loading

0 comments on commit 1b5ac03

Please sign in to comment.