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 all 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,579 changes: 792 additions & 787 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
6 changes: 3 additions & 3 deletions nimbus-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use sp_consensus::{
};
use sc_consensus::{BlockImport, BlockImportParams};
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT, DigestItemFor};
use sp_runtime::{traits::{Block as BlockT, HashFor, Header as HeaderT}, DigestItem};
use std::{marker::PhantomData, sync::Arc, time::Duration};
use tracing::error;
use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore};
Expand Down Expand Up @@ -255,7 +255,7 @@ where
maybe_key
}

pub(crate) fn seal_header<B>(header: &B::Header, keystore: &dyn SyncCryptoStore, type_public_pair: &CryptoTypePublicPair) -> DigestItemFor<B>
pub(crate) fn seal_header<B>(header: &B::Header, keystore: &dyn SyncCryptoStore, type_public_pair: &CryptoTypePublicPair) -> DigestItem
where
B: BlockT,
{
Expand All @@ -280,7 +280,7 @@ where
.try_into()
.expect("signature bytes produced by keystore should be right length");

<DigestItemFor<B> as CompatibleDigestItem>::nimbus_seal(signature)
<DigestItem as CompatibleDigestItem>::nimbus_seal(signature)
}

#[async_trait::async_trait]
Expand Down
4 changes: 2 additions & 2 deletions nimbus-consensus/src/manual_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::sync::Arc;
use sp_keystore::SyncCryptoStorePtr;
use sp_runtime::{
traits::{Block as BlockT, DigestFor},
traits::{Block as BlockT},
generic::{Digest, DigestItem},
};
use sp_core::crypto::Public;
Expand Down Expand Up @@ -52,7 +52,7 @@ where
&self,
parent: &B::Header,
inherents: &InherentData,
) -> Result<DigestFor<B>, Error> {
) -> Result<Digest, Error> {
// Retrieve the relay chain block number to use as the slot number from the parachain inherent
let slot_number = inherents
.get_data::<ParachainInherentData>(&PARACHAIN_INHERENT_IDENTIFIER)
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 @@ -51,9 +50,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_pre_digest(author: NimbusId) -> Self {
DigestItem::PreRuntime(NIMBUS_ENGINE_ID, author.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-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 @@ -87,7 +87,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 @@ -96,12 +96,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 @@ -141,7 +141,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 @@ -155,7 +155,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 @@ -170,7 +170,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 @@ -95,7 +95,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 @@ -170,7 +165,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 @@ -193,10 +188,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 @@ -254,15 +247,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
10 changes: 2 additions & 8 deletions parachain-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,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 @@ -251,7 +251,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 @@ -272,8 +271,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 Expand Up @@ -432,7 +429,6 @@ pub fn start_instant_seal_node(config: Configuration) -> Result<TaskManager, sc_
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
import_queue,
on_demand: None,
block_announce_validator_builder: None,
warp_sync: None,
})?;
Expand Down Expand Up @@ -471,8 +467,6 @@ pub fn start_instant_seal_node(config: Configuration) -> Result<TaskManager, sc_
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
rpc_extensions_builder,
on_demand: None,
remote_blockchain: None,
backend,
system_rpc_tx,
config,
Expand Down Expand Up @@ -520,7 +514,7 @@ pub fn start_instant_seal_node(config: Configuration) -> Result<TaskManager, sc_

task_manager
.spawn_essential_handle()
.spawn_blocking("instant-seal", authorship_future);
.spawn_blocking("instant-seal", None, authorship_future);
};

network_starter.start_network();
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