Skip to content

Commit

Permalink
Revert "Auto-Update substrate-parachain-template from polkadot-v1.0.0…
Browse files Browse the repository at this point in the history
… (#187)" (#190)

This reverts commit ef702d9.
  • Loading branch information
Sacha Lansky authored Jul 24, 2023
1 parent ef702d9 commit 5cdaaf8
Show file tree
Hide file tree
Showing 8 changed files with 1,277 additions and 1,264 deletions.
2,103 changes: 1,028 additions & 1,075 deletions Cargo.lock

Large diffs are not rendered by default.

89 changes: 45 additions & 44 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,68 +10,69 @@ edition = "2021"
build = "build.rs"

[dependencies]
clap = { version = "4.3.11", features = ["derive"] }
log = "0.4.19"
clap = { version = "4.2.7", features = ["derive"] }
log = "0.4.17"
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.167", features = ["derive"] }
serde = { version = "1.0.163", features = ["derive"] }
jsonrpsee = { version = "0.16.2", features = ["server"] }

# Local
parachain-template-runtime = { path = "../runtime" }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v1.0.0" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.43" }

# Polkadot
polkadot-cli = { git = "https://github.com/paritytech/polkadot", features = ["rococo-native"] , branch = "release-v1.0.0" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v1.0.0" }
polkadot-cli = { git = "https://github.com/paritytech/polkadot", features = ["rococo-native"] , branch = "release-v0.9.43" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.43" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" }

# Cumulus
cumulus-client-cli = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v1.0.0" }
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v1.0.0" }
cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v1.0.0" }
cumulus-client-service = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v1.0.0" }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v1.0.0" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v1.0.0" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v1.0.0" }
cumulus-client-cli = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.43" }
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.43" }
cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.43" }
cumulus-client-service = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.43" }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.43" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.43" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.43" }
color-print = "0.3.4"

[build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }

[features]
default = []
runtime-benchmarks = [
"try-runtime-cli/try-runtime",
"parachain-template-runtime/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
]
Expand Down
10 changes: 3 additions & 7 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec =
sc_service::GenericChainSpec<parachain_template_runtime::RuntimeGenesisConfig, Extensions>;
sc_service::GenericChainSpec<parachain_template_runtime::GenesisConfig, Extensions>;

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
Expand Down Expand Up @@ -101,7 +101,6 @@ pub fn development_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
1000.into(),
)
},
Expand Down Expand Up @@ -157,7 +156,6 @@ pub fn local_testnet_config() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
1000.into(),
)
},
Expand All @@ -182,10 +180,9 @@ pub fn local_testnet_config() -> ChainSpec {
fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
root: AccountId,
id: ParaId,
) -> parachain_template_runtime::RuntimeGenesisConfig {
parachain_template_runtime::RuntimeGenesisConfig {
) -> parachain_template_runtime::GenesisConfig {
parachain_template_runtime::GenesisConfig {
system: parachain_template_runtime::SystemConfig {
code: parachain_template_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
Expand Down Expand Up @@ -221,6 +218,5 @@ fn testnet_genesis(
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
transaction_payment: Default::default(),
sudo: parachain_template_runtime::SudoConfig { key: Some(root) },
}
}
71 changes: 44 additions & 27 deletions node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
use std::net::SocketAddr;

use codec::Encode;
use cumulus_client_cli::generate_genesis_block;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::{info, warn};
use parachain_template_runtime::Block;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, SharedParams, SubstrateCli,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
};
use sc_service::config::{BasePath, PrometheusConfig};
use sp_runtime::traits::AccountIdConversion;
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};

use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
service::new_partial,
service::{new_partial, ParachainNativeExecutor},
};

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Expand Down Expand Up @@ -60,6 +63,10 @@ impl SubstrateCli for Cli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id)
}

fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
&parachain_template_runtime::VERSION
}
}

impl SubstrateCli for RelayChainCli {
Expand Down Expand Up @@ -96,6 +103,10 @@ impl SubstrateCli for RelayChainCli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
polkadot_cli::Cli::native_runtime_version(chain_spec)
}
}

macro_rules! construct_async_run {
Expand Down Expand Up @@ -164,10 +175,10 @@ pub fn run() -> Result<()> {
},
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
let partials = new_partial(&config)?;

cmd.run(&*config.chain_spec, &*partials.client)
runner.sync_run(|_config| {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::native_runtime_version(&spec).state_version();
cmd.run::<Block>(&*spec, state_version)
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
Expand All @@ -183,7 +194,7 @@ pub fn run() -> Result<()> {
match cmd {
BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, ()>(config))
runner.sync_run(|config| cmd.run::<Block, ParachainNativeExecutor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
Expand Down Expand Up @@ -219,12 +230,15 @@ pub fn run() -> Result<()> {
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use parachain_template_runtime::MILLISECS_PER_BLOCK;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use try_runtime_cli::block_building_info::timestamp_with_aura_info;

let runner = cli.create_runner(cmd)?;

type HostFunctions =
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);
type HostFunctionsOf<E> = ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<E as NativeExecutionDispatch>::ExtendHostFunctions,
>;

// grab the task manager.
let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry);
Expand All @@ -235,7 +249,12 @@ pub fn run() -> Result<()> {
let info_provider = timestamp_with_aura_info(MILLISECS_PER_BLOCK);

runner.async_run(|_| {
Ok((cmd.run::<Block, HostFunctions, _>(Some(info_provider)), task_manager))
Ok((
cmd.run::<Block, HostFunctionsOf<ParachainNativeExecutor>, _>(Some(
info_provider,
)),
task_manager,
))
})
},
#[cfg(not(feature = "try-runtime"))]
Expand All @@ -247,12 +266,11 @@ pub fn run() -> Result<()> {
let collator_options = cli.run.collator_options();

runner.run_node_until_exit(|config| async move {
let hwbench = (!cli.no_hardware_benchmarks)
.then_some(config.database.path().map(|database_path| {
let hwbench = (!cli.no_hardware_benchmarks).then_some(
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
}))
.flatten();
})).flatten();

let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
Expand All @@ -266,26 +284,25 @@ pub fn run() -> Result<()> {
let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(
&id,
);
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(&id);

let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();
let block: Block = generate_genesis_block(&*config.chain_spec, state_version)
.map_err(|e| format!("{:?}", e))?;
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));

let tokio_handle = config.tokio_handle.clone();
let polkadot_config =
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

info!("Parachain Account: {parachain_account}");
info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
info!("Parachain genesis state: {}", genesis_state);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });

if !collator_options.relay_chain_rpc_urls.is_empty() &&
!cli.relay_chain_args.is_empty()
{
warn!(
"Detected relay chain node arguments together with --relay-chain-rpc-url. \
This command starts a minimal Polkadot node that only uses a \
network-related subset of all relay chain CLI options."
);
if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relay_chain_args.is_empty() {
warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options.");
}

crate::service::start_parachain_node(
Expand Down
14 changes: 7 additions & 7 deletions pallets/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v1.0.0" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.43" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" }

[dev-dependencies]
serde = { version = "1.0.163" }
serde = { version = "1.0.132" }

# Substrate
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" }

[features]
default = ["std"]
Expand Down
Loading

0 comments on commit 5cdaaf8

Please sign in to comment.