Skip to content

Commit

Permalink
Update node template to alpha 5 (#27)
Browse files Browse the repository at this point in the history
* Run release script

* Change dependencies to crates.io
  • Loading branch information
JoshOrndorff authored Mar 25, 2020
1 parent 5b41f0b commit da88e4a
Show file tree
Hide file tree
Showing 8 changed files with 3,368 additions and 3,335 deletions.
6,340 changes: 3,225 additions & 3,115 deletions Cargo.lock

Large diffs are not rendered by default.

91 changes: 30 additions & 61 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
[build-dependencies]
vergen = '3.0.4'

[build-dependencies.build-script-utils]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-build-script-utils'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'

[package]
authors = ['Anonymous']
build = 'build.rs'
Expand All @@ -15,98 +6,76 @@ homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'node-template'
repository = 'https://github.com/paritytech/substrate/'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[[bin]]
name = 'node-template'
[build-dependencies]
vergen = '3.0.4'

[build-dependencies.build-script-utils]
package = 'substrate-build-script-utils'
version = '2.0.0-alpha.5'

[dependencies]
futures = '0.3.1'
log = '0.4.8'
structopt = '0.3.8'

[dependencies.grandpa]
git = 'https://github.com/paritytech/substrate.git'
package = 'sc-finality-grandpa'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.grandpa-primitives]
git = 'https://github.com/paritytech/substrate.git'
package = 'sp-finality-grandpa'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dependencies.node-template-runtime]
path = '../runtime'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dependencies.sc-basic-authorship]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sc-cli]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sc-client]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sc-client-api]
version = '2.0.0-alpha.5'

[dependencies.sc-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sc-executor]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sc-network]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sc-service]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sc-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dependencies.sp-consensus]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sp-consensus-aura]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '0.8.0-alpha.3'
version = '0.8.0-alpha.5'

[dependencies.sp-core]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dependencies.sp-inherents]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dependencies.sp-runtime]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dependencies.sp-transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[[bin]]
name = 'node-template'
8 changes: 4 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use sp_runtime::traits::{Verify, IdentifyAccount};
//const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::ChainSpec<GenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;

/// The chain specification option. This is expected to come in from the CLI and
/// is little more than one of a number of alternatives which can easily be converted
Expand Down Expand Up @@ -142,9 +142,9 @@ fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
}
}

pub fn load_spec(id: &str) -> Result<Option<ChainSpec>, String> {
pub fn load_spec(id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match Alternative::from(id) {
Some(spec) => Some(spec.load()?),
None => None,
Some(spec) => Box::new(spec.load()?),
None => Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(id))?),
})
}
35 changes: 22 additions & 13 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
use std::sync::Arc;
use std::time::Duration;
use sc_client::LongestChain;
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
use sc_client_api::ExecutorProvider;
use node_template_runtime::{self, opaque::Block, RuntimeApi};
use sc_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
use sp_inherents::InherentDataProviders;
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider};

// Our native executor instance.
native_executor_instance!(
Expand All @@ -24,6 +25,7 @@ native_executor_instance!(
/// be able to perform chain operations.
macro_rules! new_full_start {
($config:expr) => {{
use std::sync::Arc;
let mut import_setup = None;
let inherent_data_providers = sp_inherents::InherentDataProviders::new();

Expand All @@ -42,7 +44,7 @@ macro_rules! new_full_start {
.ok_or_else(|| sc_service::Error::SelectChainRequired)?;

let (grandpa_block_import, grandpa_link) =
grandpa::block_import(client.clone(), &*client, select_chain)?;
grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?;

let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
grandpa_block_import.clone(), client.clone(),
Expand All @@ -67,7 +69,7 @@ macro_rules! new_full_start {
}

/// Builds a new service for a full client.
pub fn new_full(config: Configuration<GenesisConfig>)
pub fn new_full(config: Configuration)
-> Result<impl AbstractService, ServiceError>
{
let is_authority = config.roles.is_authority();
Expand All @@ -87,9 +89,11 @@ pub fn new_full(config: Configuration<GenesisConfig>)
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");

let service = builder
.with_finality_proof_provider(|client, backend|
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
)?
.with_finality_proof_provider(|client, backend| {
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build()?;

if participates_in_consensus {
Expand Down Expand Up @@ -154,9 +158,9 @@ pub fn new_full(config: Configuration<GenesisConfig>)
link: grandpa_link,
network: service.network(),
inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: service.prometheus_registry()
};

// the GRANDPA voter task is considered infallible, i.e.
Expand All @@ -177,7 +181,7 @@ pub fn new_full(config: Configuration<GenesisConfig>)
}

/// Builds a new service for a light client.
pub fn new_light(config: Configuration<GenesisConfig>)
pub fn new_light(config: Configuration)
-> Result<impl AbstractService, ServiceError>
{
let inherent_data_providers = InherentDataProviders::new();
Expand All @@ -201,7 +205,10 @@ pub fn new_light(config: Configuration<GenesisConfig>)
.map(|fetcher| fetcher.checker().clone())
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
let grandpa_block_import = grandpa::light_block_import(
client.clone(), backend, &*client.clone(), Arc::new(fetch_checker),
client.clone(),
backend,
&(client.clone() as Arc<_>),
Arc::new(fetch_checker),
)?;
let finality_proof_import = grandpa_block_import.clone();
let finality_proof_request_builder =
Expand All @@ -218,8 +225,10 @@ pub fn new_light(config: Configuration<GenesisConfig>)

Ok((import_queue, finality_proof_request_builder))
})?
.with_finality_proof_provider(|client, backend|
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
)?
.with_finality_proof_provider(|client, backend| {
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build()
}
61 changes: 26 additions & 35 deletions pallets/template/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,3 @@
[dev-dependencies.sp-core]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'

[dev-dependencies.sp-io]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'

[dev-dependencies.sp-runtime]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'

[features]
default = ['std']
std = [
'codec/std',
'frame-support/std',
'safe-mix/std',
'system/std',
]

[package]
authors = ['Anonymous']
description = 'FRAME pallet template'
Expand All @@ -33,26 +6,44 @@ homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'pallet-template'
repository = 'https://github.com/paritytech/substrate/'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '1.0.0'
version = '1.2.0'

[dependencies.frame-support]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dependencies.safe-mix]
default-features = false
version = '1.0.0'

[dependencies.system]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'frame-system'
rev = '013c1ee167354a08283fb69915fda56a62fee943'
version = '2.0.0-alpha.3'
version = '2.0.0-alpha.5'

[dev-dependencies.sp-core]
default-features = false
version = '2.0.0-alpha.5'

[dev-dependencies.sp-io]
default-features = false
version = '2.0.0-alpha.5'

[dev-dependencies.sp-runtime]
default-features = false
version = '2.0.0-alpha.5'

[features]
default = ['std']
std = [
'codec/std',
'frame-support/std',
'safe-mix/std',
'system/std',
]
3 changes: 3 additions & 0 deletions pallets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub trait Trait: system::Trait {

// This pallet's storage items.
decl_storage! {
// It is important to update your storage name so that your pallet's
// storage items are isolated from other pallets.
// ---------------------------------vvvvvvvvvvvvvv
trait Store for Module<T: Trait> as TemplateModule {
// Just a dummy storage item.
// Here we are declaring a StorageValue, `Something` as a Option<u32>
Expand Down
Loading

0 comments on commit da88e4a

Please sign in to comment.