Skip to content

Commit da88e4a

Browse files
authored
Update node template to alpha 5 (#27)
* Run release script * Change dependencies to crates.io
1 parent 5b41f0b commit da88e4a

File tree

8 files changed

+3368
-3335
lines changed

8 files changed

+3368
-3335
lines changed

Cargo.lock

+3,225-3,115
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/Cargo.toml

+30-61
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
[build-dependencies]
2-
vergen = '3.0.4'
3-
4-
[build-dependencies.build-script-utils]
5-
git = 'https://github.com/paritytech/substrate.git'
6-
package = 'substrate-build-script-utils'
7-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
8-
version = '2.0.0-alpha.3'
9-
101
[package]
112
authors = ['Anonymous']
123
build = 'build.rs'
@@ -15,98 +6,76 @@ homepage = 'https://substrate.dev'
156
license = 'Unlicense'
167
name = 'node-template'
178
repository = 'https://github.com/paritytech/substrate/'
18-
version = '2.0.0-alpha.3'
9+
version = '2.0.0-alpha.5'
1910

20-
[[bin]]
21-
name = 'node-template'
11+
[build-dependencies]
12+
vergen = '3.0.4'
13+
14+
[build-dependencies.build-script-utils]
15+
package = 'substrate-build-script-utils'
16+
version = '2.0.0-alpha.5'
2217

2318
[dependencies]
2419
futures = '0.3.1'
2520
log = '0.4.8'
2621
structopt = '0.3.8'
2722

2823
[dependencies.grandpa]
29-
git = 'https://github.com/paritytech/substrate.git'
3024
package = 'sc-finality-grandpa'
31-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
32-
version = '0.8.0-alpha.3'
25+
version = '0.8.0-alpha.5'
3326

3427
[dependencies.grandpa-primitives]
35-
git = 'https://github.com/paritytech/substrate.git'
3628
package = 'sp-finality-grandpa'
37-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
38-
version = '2.0.0-alpha.3'
29+
version = '2.0.0-alpha.5'
3930

4031
[dependencies.node-template-runtime]
4132
path = '../runtime'
42-
version = '2.0.0-alpha.3'
33+
version = '2.0.0-alpha.5'
4334

4435
[dependencies.sc-basic-authorship]
45-
git = 'https://github.com/paritytech/substrate.git'
46-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
47-
version = '0.8.0-alpha.3'
36+
version = '0.8.0-alpha.5'
4837

4938
[dependencies.sc-cli]
50-
git = 'https://github.com/paritytech/substrate.git'
51-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
52-
version = '0.8.0-alpha.3'
39+
version = '0.8.0-alpha.5'
5340

5441
[dependencies.sc-client]
55-
git = 'https://github.com/paritytech/substrate.git'
56-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
57-
version = '0.8.0-alpha.3'
42+
version = '0.8.0-alpha.5'
43+
44+
[dependencies.sc-client-api]
45+
version = '2.0.0-alpha.5'
5846

5947
[dependencies.sc-consensus-aura]
60-
git = 'https://github.com/paritytech/substrate.git'
61-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
62-
version = '0.8.0-alpha.3'
48+
version = '0.8.0-alpha.5'
6349

6450
[dependencies.sc-executor]
65-
git = 'https://github.com/paritytech/substrate.git'
66-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
67-
version = '0.8.0-alpha.3'
51+
version = '0.8.0-alpha.5'
6852

6953
[dependencies.sc-network]
70-
git = 'https://github.com/paritytech/substrate.git'
71-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
72-
version = '0.8.0-alpha.3'
54+
version = '0.8.0-alpha.5'
7355

7456
[dependencies.sc-service]
75-
git = 'https://github.com/paritytech/substrate.git'
76-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
77-
version = '0.8.0-alpha.3'
57+
version = '0.8.0-alpha.5'
7858

7959
[dependencies.sc-transaction-pool]
80-
git = 'https://github.com/paritytech/substrate.git'
81-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
82-
version = '2.0.0-alpha.3'
60+
version = '2.0.0-alpha.5'
8361

8462
[dependencies.sp-consensus]
85-
git = 'https://github.com/paritytech/substrate.git'
86-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
87-
version = '0.8.0-alpha.3'
63+
version = '0.8.0-alpha.5'
8864

8965
[dependencies.sp-consensus-aura]
90-
git = 'https://github.com/paritytech/substrate.git'
91-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
92-
version = '0.8.0-alpha.3'
66+
version = '0.8.0-alpha.5'
9367

9468
[dependencies.sp-core]
95-
git = 'https://github.com/paritytech/substrate.git'
96-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
97-
version = '2.0.0-alpha.3'
69+
version = '2.0.0-alpha.5'
9870

9971
[dependencies.sp-inherents]
100-
git = 'https://github.com/paritytech/substrate.git'
101-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
102-
version = '2.0.0-alpha.3'
72+
version = '2.0.0-alpha.5'
10373

10474
[dependencies.sp-runtime]
105-
git = 'https://github.com/paritytech/substrate.git'
106-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
107-
version = '2.0.0-alpha.3'
75+
version = '2.0.0-alpha.5'
10876

10977
[dependencies.sp-transaction-pool]
110-
git = 'https://github.com/paritytech/substrate.git'
111-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
112-
version = '2.0.0-alpha.3'
78+
version = '2.0.0-alpha.5'
79+
80+
[[bin]]
81+
name = 'node-template'

node/src/chain_spec.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use sp_runtime::traits::{Verify, IdentifyAccount};
1212
//const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
1313

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

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

145-
pub fn load_spec(id: &str) -> Result<Option<ChainSpec>, String> {
145+
pub fn load_spec(id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
146146
Ok(match Alternative::from(id) {
147-
Some(spec) => Some(spec.load()?),
148-
None => None,
147+
Some(spec) => Box::new(spec.load()?),
148+
None => Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(id))?),
149149
})
150150
}

node/src/service.rs

+22-13
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
use std::sync::Arc;
44
use std::time::Duration;
55
use sc_client::LongestChain;
6-
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
6+
use sc_client_api::ExecutorProvider;
7+
use node_template_runtime::{self, opaque::Block, RuntimeApi};
78
use sc_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
89
use sp_inherents::InherentDataProviders;
910
use sc_executor::native_executor_instance;
1011
pub use sc_executor::NativeExecutor;
1112
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
12-
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
13+
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider};
1314

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

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

4446
let (grandpa_block_import, grandpa_link) =
45-
grandpa::block_import(client.clone(), &*client, select_chain)?;
47+
grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?;
4648

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

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

8991
let service = builder
90-
.with_finality_proof_provider(|client, backend|
91-
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
92-
)?
92+
.with_finality_proof_provider(|client, backend| {
93+
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
94+
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
95+
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
96+
})?
9397
.build()?;
9498

9599
if participates_in_consensus {
@@ -154,9 +158,9 @@ pub fn new_full(config: Configuration<GenesisConfig>)
154158
link: grandpa_link,
155159
network: service.network(),
156160
inherent_data_providers: inherent_data_providers.clone(),
157-
on_exit: service.on_exit(),
158161
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
159162
voting_rule: grandpa::VotingRulesBuilder::default().build(),
163+
prometheus_registry: service.prometheus_registry()
160164
};
161165

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

179183
/// Builds a new service for a light client.
180-
pub fn new_light(config: Configuration<GenesisConfig>)
184+
pub fn new_light(config: Configuration)
181185
-> Result<impl AbstractService, ServiceError>
182186
{
183187
let inherent_data_providers = InherentDataProviders::new();
@@ -201,7 +205,10 @@ pub fn new_light(config: Configuration<GenesisConfig>)
201205
.map(|fetcher| fetcher.checker().clone())
202206
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
203207
let grandpa_block_import = grandpa::light_block_import(
204-
client.clone(), backend, &*client.clone(), Arc::new(fetch_checker),
208+
client.clone(),
209+
backend,
210+
&(client.clone() as Arc<_>),
211+
Arc::new(fetch_checker),
205212
)?;
206213
let finality_proof_import = grandpa_block_import.clone();
207214
let finality_proof_request_builder =
@@ -218,8 +225,10 @@ pub fn new_light(config: Configuration<GenesisConfig>)
218225

219226
Ok((import_queue, finality_proof_request_builder))
220227
})?
221-
.with_finality_proof_provider(|client, backend|
222-
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
223-
)?
228+
.with_finality_proof_provider(|client, backend| {
229+
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
230+
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
231+
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
232+
})?
224233
.build()
225234
}

pallets/template/Cargo.toml

+26-35
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,3 @@
1-
[dev-dependencies.sp-core]
2-
default-features = false
3-
git = 'https://github.com/paritytech/substrate.git'
4-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
5-
version = '2.0.0-alpha.3'
6-
7-
[dev-dependencies.sp-io]
8-
default-features = false
9-
git = 'https://github.com/paritytech/substrate.git'
10-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
11-
version = '2.0.0-alpha.3'
12-
13-
[dev-dependencies.sp-runtime]
14-
default-features = false
15-
git = 'https://github.com/paritytech/substrate.git'
16-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
17-
version = '2.0.0-alpha.3'
18-
19-
[features]
20-
default = ['std']
21-
std = [
22-
'codec/std',
23-
'frame-support/std',
24-
'safe-mix/std',
25-
'system/std',
26-
]
27-
281
[package]
292
authors = ['Anonymous']
303
description = 'FRAME pallet template'
@@ -33,26 +6,44 @@ homepage = 'https://substrate.dev'
336
license = 'Unlicense'
347
name = 'pallet-template'
358
repository = 'https://github.com/paritytech/substrate/'
36-
version = '2.0.0-alpha.3'
9+
version = '2.0.0-alpha.5'
10+
3711
[dependencies.codec]
3812
default-features = false
3913
features = ['derive']
4014
package = 'parity-scale-codec'
41-
version = '1.0.0'
15+
version = '1.2.0'
4216

4317
[dependencies.frame-support]
4418
default-features = false
45-
git = 'https://github.com/paritytech/substrate.git'
46-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
47-
version = '2.0.0-alpha.3'
19+
version = '2.0.0-alpha.5'
4820

4921
[dependencies.safe-mix]
5022
default-features = false
5123
version = '1.0.0'
5224

5325
[dependencies.system]
5426
default-features = false
55-
git = 'https://github.com/paritytech/substrate.git'
5627
package = 'frame-system'
57-
rev = '013c1ee167354a08283fb69915fda56a62fee943'
58-
version = '2.0.0-alpha.3'
28+
version = '2.0.0-alpha.5'
29+
30+
[dev-dependencies.sp-core]
31+
default-features = false
32+
version = '2.0.0-alpha.5'
33+
34+
[dev-dependencies.sp-io]
35+
default-features = false
36+
version = '2.0.0-alpha.5'
37+
38+
[dev-dependencies.sp-runtime]
39+
default-features = false
40+
version = '2.0.0-alpha.5'
41+
42+
[features]
43+
default = ['std']
44+
std = [
45+
'codec/std',
46+
'frame-support/std',
47+
'safe-mix/std',
48+
'system/std',
49+
]

pallets/template/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ pub trait Trait: system::Trait {
2828

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

0 commit comments

Comments
 (0)