Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Update {Cumulus, Polkadot, Substrate} #28

Merged
merged 7 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
1,598 changes: 815 additions & 783 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nimbus-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "nimbus-consensus"
description = "Client-side worker for the Nimbus family of slot-based consensus algorithms"
version = "0.1.0"
edition = "2018"
edition = "2021"

[dependencies]
# Substrate deps
Expand Down
4 changes: 2 additions & 2 deletions nimbus-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use tracing::error;
use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore};
use sp_core::crypto::Public;
use sp_std::convert::TryInto;
use nimbus_primitives::{AuthorFilterAPI, NimbusApi, NIMBUS_KEY_ID, NimbusId};
use nimbus_primitives::{AuthorFilterAPI, NimbusApi, NIMBUS_KEY_ID, NimbusId, digests::CompatibleDigestItem};
mod import_queue;

const LOG_TARGET: &str = "filtering-consensus";
Expand Down Expand Up @@ -315,7 +315,7 @@ where
.clone()
.try_into().ok()?;

let sig_digest = <sp_runtime::traits::DigestItemFor<B> as nimbus_primitives::digests::CompatibleDigestItem>::nimbus_seal(signature);
let sig_digest = <sp_runtime::DigestItem as CompatibleDigestItem>::nimbus_seal(signature);

let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header.clone());
block_import_params.post_digests.push(sig_digest.clone());
Expand Down
2 changes: 1 addition & 1 deletion nimbus-primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
authors = ["PureStake"]
edition = "2018"
edition = "2021"
name = "nimbus-primitives"
version = "0.1.0"
description = "Primitive types and traites used in the nimbus consensus framework"
Expand Down
7 changes: 2 additions & 5 deletions nimbus-primitives/src/digests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

use crate::{NIMBUS_ENGINE_ID, NimbusSignature, NimbusId};
use sp_runtime::generic::DigestItem;
use parity_scale_codec::{Encode, Codec};
use sp_std::fmt::Debug;
use parity_scale_codec::Encode;

/// A digest item which is usable with aura consensus.
pub trait CompatibleDigestItem: Sized {
Expand All @@ -43,9 +42,7 @@ pub trait CompatibleDigestItem: Sized {
fn as_nimbus_consensus_digest(&self) -> Option<NimbusId>;
}

impl<Hash> CompatibleDigestItem for DigestItem<Hash> where
Hash: Debug + Send + Sync + Eq + Clone + Codec + 'static
{
impl CompatibleDigestItem for DigestItem {
fn nimbus_seal(signature: NimbusSignature) -> Self {
DigestItem::Seal(NIMBUS_ENGINE_ID, signature.encode())
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/aura-style-filter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
authors = ["PureStake"]
edition = "2018"
edition = "2021"
name = "pallet-aura-style-filter"
version = "0.1.0"

Expand Down
2 changes: 1 addition & 1 deletion pallets/author-inherent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "pallet-author-inherent"
version = "0.1.0"
description = "Inject the block author via an inherent, and persist it via a Consensus digest"
authors = ["PureStake"]
edition = "2018"
edition = "2021"
license = 'GPL-3.0-only'

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion pallets/author-inherent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub mod pallet {
Author::<T>::put(&account);

// Add a consensus digest so the client-side worker can verify the block is signed by the right person.
frame_system::Pallet::<T>::deposit_log(DigestItem::<T::Hash>::Consensus(
frame_system::Pallet::<T>::deposit_log(DigestItem::Consensus(
NIMBUS_ENGINE_ID,
author.encode(),
));
Expand Down
2 changes: 1 addition & 1 deletion pallets/author-slot-filter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
authors = ["PureStake"]
edition = "2018"
edition = "2021"
name = "pallet-author-slot-filter"
version = "0.1.0"

Expand Down
2 changes: 1 addition & 1 deletion parachain-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "A new Cumulus FRAME-based Substrate Node, ready for hacking toget
license = "Unlicense"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/cumulus/"
edition = "2018"
edition = "2021"
build = "build.rs"

[package.metadata.docs.rs]
Expand Down
13 changes: 6 additions & 7 deletions parachain-template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ where
AccountPublic::from(get_pair_from_seed::<TPublic>(seed)).into_account()
}

pub fn development_config(id: ParaId) -> ChainSpec {
pub fn development_config() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "ROC".into());
Expand Down Expand Up @@ -91,7 +91,7 @@ pub fn development_config(id: ParaId) -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
id,
1000.into(),
)
},
vec![],
Expand All @@ -100,12 +100,12 @@ pub fn development_config(id: ParaId) -> ChainSpec {
None,
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: id.into(),
para_id: 1000,
},
)
}

pub fn local_testnet_config(id: ParaId) -> ChainSpec {
pub fn local_testnet_config() -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "ROC".into());
Expand Down Expand Up @@ -145,7 +145,7 @@ pub fn local_testnet_config(id: ParaId) -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
id,
1000.into(),
)
},
// Bootnodes
Expand All @@ -159,7 +159,7 @@ pub fn local_testnet_config(id: ParaId) -> ChainSpec {
// Extensions
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: id.into(),
para_id: 1000,
},
)
}
Expand All @@ -174,7 +174,6 @@ fn testnet_genesis(
code: parachain_template_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
changes_trie_config: Default::default(),
},
balances: parachain_template_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
Expand Down
2 changes: 1 addition & 1 deletion parachain-template/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub struct Cli {

/// Relaychain arguments
#[structopt(raw = true)]
pub relaychain_args: Vec<String>,
pub relay_chain_args: Vec<String>,
}

#[derive(Debug)]
Expand Down
44 changes: 19 additions & 25 deletions parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::Block as BlockT;
use std::{io::Write, net::SocketAddr};

fn load_spec(
id: &str,
para_id: ParaId,
) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config(para_id)),
"template-rococo" => Box::new(chain_spec::local_testnet_config(para_id)),
"" | "local" => Box::new(chain_spec::local_testnet_config(para_id)),
"dev" => Box::new(chain_spec::development_config()),
"template-rococo" => Box::new(chain_spec::local_testnet_config()),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}
Expand All @@ -40,13 +37,11 @@ impl SubstrateCli for Cli {
}

fn description() -> String {
format!(
"Parachain Collator Template\n\nThe command-line arguments provided first will be \
"Parachain Collator Template\n\nThe command-line arguments provided first will be \
passed to the parachain node, while the arguments provided after -- will be passed \
to the relaychain node.\n\n\
{} [parachain-args] -- [relaychain-args]",
Self::executable_name()
)
to the relay chain node.\n\n\
parachain-collator <parachain-args> -- <relay-chain-args>"
.into()
}

fn author() -> String {
Expand All @@ -62,7 +57,7 @@ impl SubstrateCli for Cli {
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id, self.run.parachain_id.unwrap_or(2000).into())
load_spec(id)
}

fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
Expand All @@ -82,8 +77,8 @@ impl SubstrateCli for RelayChainCli {
fn description() -> String {
"Parachain Collator Template\n\nThe command-line arguments provided first will be \
passed to the parachain node, while the arguments provided after -- will be passed \
to the relaychain node.\n\n\
parachain-collator [parachain-args] -- [relaychain-args]"
to the relay chain node.\n\n\
parachain-collator <parachain-args> -- <relay-chain-args>"
.into()
}

Expand Down Expand Up @@ -169,7 +164,7 @@ pub fn run() -> Result<()> {
runner.sync_run(|config| {
let polkadot_cli = RelayChainCli::new(
&config,
[RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()),
[RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()),
);

let polkadot_config = SubstrateCli::create_configuration(
Expand All @@ -192,10 +187,8 @@ pub fn run() -> Result<()> {
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
let _ = builder.init();

let block: Block = generate_genesis_block(&load_spec(
&params.chain.clone().unwrap_or_default(),
params.parachain_id.unwrap_or(2000).into(),
)?)?;
let block: Block =
generate_genesis_block(&load_spec(&params.chain.clone().unwrap_or_default())?)?;
let raw_header = block.header().encode();
let output_buf = if params.raw {
raw_header
Expand Down Expand Up @@ -246,15 +239,16 @@ pub fn run() -> Result<()> {
let runner = cli.create_runner(&cli.run.normalize())?;

runner.run_node_until_exit(|config| async move {
let para_id =
chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id);
let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
.ok_or_else(|| "Could not find parachain ID in chain-spec.")?;

let polkadot_cli = RelayChainCli::new(
&config,
[RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()),
[RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()),
);

let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(2000));
let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
Expand Down
5 changes: 1 addition & 4 deletions parachain-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ where
let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());

let telemetry = telemetry.map(|(worker, telemetry)| {
task_manager.spawn_handle().spawn("telemetry", worker.run());
task_manager.spawn_handle().spawn("telemetry", None, worker.run());
telemetry
});

Expand Down Expand Up @@ -243,7 +243,6 @@ where
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
import_queue: import_queue.clone(),
on_demand: None,
block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),
warp_sync: None,
})?;
Expand All @@ -264,8 +263,6 @@ where
};

sc_service::spawn_tasks(sc_service::SpawnTasksParams {
on_demand: None,
remote_blockchain: None,
rpc_extensions_builder,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
Expand Down
2 changes: 1 addition & 1 deletion parachain-template/pallets/template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.1.0"
license = "Unlicense"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/substrate/"
edition = "2018"
edition = "2021"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down
2 changes: 1 addition & 1 deletion parachain-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "A new Cumulus FRAME-based Substrate Runtime, ready for hacking to
license = "Unlicense"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/cumulus/"
edition = "2018"
edition = "2021"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down