Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
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
2 changes: 1 addition & 1 deletion client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::{
};
use structopt::StructOpt;

/// The `purge-chain` command used to remove the whole chain: the parachain and the relaychain.
/// The `purge-chain` command used to remove the whole chain: the parachain and the relay chain.
#[derive(Debug, StructOpt)]
pub struct PurgeChainCmd {
/// The base struct of the purge-chain command.
Expand Down
2 changes: 1 addition & 1 deletion client/network/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async fn sync_blocks_from_tip_without_being_connected_to_a_collator() {
let tokio_handle = tokio::runtime::Handle::current();

// start alice
let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, vec![]);
let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, Vec::new());

// start bob
let bob =
Expand Down
2 changes: 1 addition & 1 deletion client/pov-recovery/tests/pov_recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async fn pov_recovery() {
tokio_handle.clone(),
Alice,
|| {},
vec![],
Vec::new(),
);

// Start bob
Expand Down
2 changes: 1 addition & 1 deletion pallets/asset-tx-payment/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl ExtBuilder {
(6, 60 * self.balance_factor),
]
} else {
vec![]
Vec::new()
},
}
.assimilate_storage(&mut t)
Expand Down
4 changes: 2 additions & 2 deletions pallets/collator-selection/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn register_validators<T: Config + session::Config>(count: u32) {
let validators = (0..count).map(|c| validator::<T>(c)).collect::<Vec<_>>();

for (who, keys) in validators {
<session::Pallet<T>>::set_keys(RawOrigin::Signed(who).into(), keys, vec![]).unwrap();
<session::Module<T>>::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new()).unwrap();
}
}

Expand Down Expand Up @@ -160,7 +160,7 @@ benchmarks! {
<session::Pallet<T>>::set_keys(
RawOrigin::Signed(caller.clone()).into(),
keys::<T>(c + 1),
vec![]
Vec::new()
).unwrap();

}: _(RawOrigin::Signed(caller.clone()))
Expand Down
2 changes: 1 addition & 1 deletion pallets/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl From<UintAuthorityId> for MockSessionKeys {
}

parameter_types! {
pub static SessionHandlerCollators: Vec<u64> = vec![];
pub static SessionHandlerCollators: Vec<u64> = Vec::new();
pub static SessionChangeBlock: u64 = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/collator-selection/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fn register_as_candidate_works() {
// given
assert_eq!(CollatorSelection::desired_candidates(), 2);
assert_eq!(CollatorSelection::candidacy_bond(), 10);
assert_eq!(CollatorSelection::candidates(), vec![]);
assert_eq!(CollatorSelection::candidates(), Vec::new());
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);

// take two endowed, non-invulnerables accounts.
Expand Down
4 changes: 2 additions & 2 deletions pallets/dmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ mod tests {
Xcm(vec![Transact {
origin_type: OriginKind::Native,
require_weight_at_most: weight,
call: vec![].into(),
call: Vec::new().into(),
}])
}

Expand Down Expand Up @@ -506,7 +506,7 @@ mod tests {
new_test_ext().execute_with(|| {
let weight_used = handle_messages(&[], 1000);
assert_eq!(weight_used, 0);
assert_eq!(take_trace(), vec![]);
assert_eq!(take_trace(), Vec::new());
assert!(queue_is_empty());
});
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ pub mod pallet {
if let Ok(hash) = Self::validate_authorized_upgrade(code) {
return Ok(ValidTransaction {
priority: 100,
requires: vec![],
requires: Vec::new(),
provides: vec![hash.as_ref().to_vec()],
longevity: TransactionLongevity::max_value(),
propagate: true,
Expand Down Expand Up @@ -1008,7 +1008,7 @@ pub trait CheckInherents<Block: BlockT> {
) -> frame_support::inherent::CheckInherentsResult;
}

/// Implements [`BlockNumberProvider`] that returns relaychain block number fetched from
/// Implements [`BlockNumberProvider`] that returns relay chain block number fetched from
/// validation data.
/// NTOE: When validation data is not available (e.g. within on_initialize), 0 will be returned.
pub struct RelaychainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);
Expand Down
8 changes: 4 additions & 4 deletions pallets/parachain-system/src/validate_block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn validate_block_no_extra_extrinsics() {

let (client, parent_head) = create_test_client();
let TestBlockData { block, validation_data } =
build_block_with_witness(&client, vec![], parent_head.clone(), Default::default());
build_block_with_witness(&client, Vec::new(), parent_head.clone(), Default::default());
let header = block.header().clone();

let res_header =
Expand Down Expand Up @@ -133,7 +133,7 @@ fn validate_block_invalid_parent_hash() {
if env::var("RUN_TEST").is_ok() {
let (client, parent_head) = create_test_client();
let TestBlockData { block, validation_data } =
build_block_with_witness(&client, vec![], parent_head.clone(), Default::default());
build_block_with_witness(&client, Vec::new(), parent_head.clone(), Default::default());
let (mut header, extrinsics, witness) = block.deconstruct();
header.set_parent_hash(Hash::from_low_u64_be(1));

Expand All @@ -159,7 +159,7 @@ fn validate_block_fails_on_invalid_validation_data() {
if env::var("RUN_TEST").is_ok() {
let (client, parent_head) = create_test_client();
let TestBlockData { block, .. } =
build_block_with_witness(&client, vec![], parent_head.clone(), Default::default());
build_block_with_witness(&client, Vec::new(), parent_head.clone(), Default::default());

call_validate_block(parent_head, block, Hash::random()).unwrap_err();
} else {
Expand All @@ -184,7 +184,7 @@ fn check_inherent_fails_on_validate_block_as_expected() {

let TestBlockData { block, validation_data } = build_block_with_witness(
&client,
vec![],
Vec::new(),
parent_head.clone(),
RelayStateSproofBuilder { current_slot: 1337.into(), ..Default::default() },
);
Expand Down
18 changes: 13 additions & 5 deletions parachain-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

A new [Cumulus](https://github.com/paritytech/cumulus/)-based Substrate node, ready for hacking ☁️..

This project is a fork of the [Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template)
This project is originally a fork of the
[Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template)
modified to include dependencies required for registering this node as a **parathread** or
**parachain** to the Rococo **relay chain**.
Rococo is [Polkadot's parachain testnet](https://polkadot.network/blog/introducing-rococo-polkadots-parachain-testnet/) 👑.
**parachain** to a **relay chain**.

The stand-alone version of this template is hosted on the
[Substrate Devhub Parachain Template](https://github.com/substrate-developer-hub/substrate-parachain-template/)
for each release of Polkadot. It is generated directly to the upstream
[Parachain Template in Cumulus](https://github.com/paritytech/cumulus/tree/master/parachain-template)
at each release branch using the
[Substrate Template Generator](https://github.com/paritytech/substrate-template-generator/).

👉 Learn more about parachains [here](https://wiki.polkadot.network/docs/learn-parachains), and
parathreads [here](https://wiki.polkadot.network/docs/learn-parathreads).

To learn about how to actually use the template to hack together your own parachain check out the
`README` from the [`substrate-parachain-template` repository](https://github.com/substrate-developer-hub/substrate-parachain-template/).

🧙 Learn about how to use this template and run your own parachain testnet for it in the
[Devhub Cumulus Tutorial](https://docs.substrate.io/tutorials/v3/cumulus/start-relay/).
17 changes: 8 additions & 9 deletions parachain-template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub type ChainSpec =
sc_service::GenericChainSpec<parachain_template_runtime::GenesisConfig, Extensions>;

/// Helper function to generate a crypto pair from seed
pub fn get_pair_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
Expand Down Expand Up @@ -40,15 +40,15 @@ type AccountPublic = <Signature as Verify>::Signer;
///
/// This function's return type must always match the session keys of the chain in tuple format.
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
get_pair_from_seed::<AuraId>(seed)
get_public_from_seed::<AuraId>(seed)
}

/// Helper function to generate an account ID from seed
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_pair_from_seed::<TPublic>(seed)).into_account()
AccountPublic::from(get_public_from_seed::<TPublic>(seed)).into_account()
}

/// Generate the session keys from individual elements.
Expand All @@ -61,7 +61,7 @@ pub fn template_session_keys(keys: AuraId) -> parachain_template_runtime::Sessio
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());
properties.insert("tokenSymbol".into(), "UNIT".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());

Expand Down Expand Up @@ -101,7 +101,7 @@ pub fn development_config() -> ChainSpec {
1000.into(),
)
},
vec![],
Vec::new(),
None,
None,
None,
Expand All @@ -115,7 +115,7 @@ pub fn development_config() -> 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());
properties.insert("tokenSymbol".into(), "UNIT".into());
properties.insert("tokenDecimals".into(), 12.into());
properties.insert("ss58Format".into(), 42.into());

Expand Down Expand Up @@ -156,7 +156,7 @@ pub fn local_testnet_config() -> ChainSpec {
)
},
// Bootnodes
vec![],
Vec::new(),
// Telemetry
None,
// Protocol ID
Expand Down Expand Up @@ -194,8 +194,7 @@ fn testnet_genesis(
},
session: parachain_template_runtime::SessionConfig {
keys: invulnerables
.iter()
.cloned()
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
Expand Down
6 changes: 3 additions & 3 deletions parachain-template/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct ExportGenesisStateCommand {
pub raw: bool,

/// The name of the chain for that the genesis state should be exported.
#[structopt(long, conflicts_with = "parachain-id")]
#[structopt(long)]
pub chain: Option<String>,
}

Expand Down Expand Up @@ -84,9 +84,9 @@ pub struct Cli {
#[structopt(flatten)]
pub run: cumulus_client_cli::RunCmd,

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

#[derive(Debug)]
Expand Down
20 changes: 9 additions & 11 deletions parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,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 Down Expand Up @@ -79,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 @@ -168,7 +166,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 Down Expand Up @@ -245,11 +243,11 @@ pub fn run() -> Result<()> {
runner.run_node_until_exit(|config| async move {
let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
.map(|e| e.para_id)
.ok_or_else(|| "Could not find parachain extension for chain-spec.")?;
.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(para_id);
Expand Down
2 changes: 1 addition & 1 deletion parachain-template/node/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Substrate Node CLI library.
//! Substrate Parachain Node Template CLI

#![warn(missing_docs)]

Expand Down
Loading