Migrate everything to the 2018 edition (#1758)

This commit is contained in:
Stanislav Tkach
2019-02-13 12:45:59 +02:00
committed by Gav Wood
parent a61c218cc3
commit ff5e4ca87e
38 changed files with 75 additions and 116 deletions
-1
View File
@@ -3792,7 +3792,6 @@ dependencies = [
"srml-system 0.1.0",
"substrate-client 0.1.0",
"substrate-consensus-common 0.1.0",
"substrate-executor 0.1.0",
"substrate-keyring 0.1.0",
"substrate-primitives 0.1.0",
"substrate-transaction-pool 0.1.0",
+2 -1
View File
@@ -7,10 +7,11 @@ name = "substrate"
version = "0.10.0"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
edition = "2018"
[dependencies]
error-chain = "0.12"
node-cli = { path = "node/cli" }
cli = { package = "node-cli", path = "node/cli" }
futures = "0.1"
ctrlc = { version = "3.0", features = ["termination"] }
-2
View File
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
extern crate vergen;
use vergen::{ConstantsFlags, generate_cargo_keys};
const ERROR_MSG: &'static str = "Failed to generate metadata files";
-1
View File
@@ -20,7 +20,6 @@ trie = { package = "substrate-trie", path = "../trie", optional = true }
substrate-telemetry = { path = "../telemetry", optional = true }
hash-db = { version = "0.11", optional = true }
kvdb = { git = "https://github.com/paritytech/parity-common", optional = true, rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
@@ -16,7 +16,7 @@
use super::api::BlockBuilder as BlockBuilderApi;
use std::vec::Vec;
use codec::Encode;
use parity_codec::Encode;
use crate::blockchain::HeaderBackend;
use runtime_primitives::traits::{
Header as HeaderT, Hash, Block as BlockT, One, HashFor, ProvideRuntimeApi, ApiRef
+1 -1
View File
@@ -15,7 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use std::{sync::Arc, cmp::Ord, panic::UnwindSafe, result};
use codec::{Encode, Decode};
use parity_codec::{Encode, Decode};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::Block as BlockT;
use state_machine::{
+1 -1
View File
@@ -38,7 +38,7 @@ use crate::runtime_api::{CallRuntimeAt, ConstructRuntimeApi};
use primitives::{Blake2Hasher, H256, ChangesTrieConfiguration, convert_hash, NeverNativeValue};
use primitives::storage::{StorageKey, StorageData};
use primitives::storage::well_known_keys;
use codec::{Encode, Decode};
use parity_codec::{Encode, Decode};
use state_machine::{
DBValue, Backend as StateBackend, CodeExecutor, ChangesTrieAnchorBlockId,
ExecutionStrategy, ExecutionManager, prove_read,
+1 -1
View File
@@ -40,7 +40,7 @@ pub fn construct_genesis_block<
#[cfg(test)]
mod tests {
use super::*;
use codec::{Encode, Decode, Joiner};
use parity_codec::{Encode, Decode, Joiner};
use keyring::Keyring;
use executor::{NativeExecutionDispatch, native_executor_instance};
use state_machine::{execute, OverlayedChanges, ExecutionStrategy, InMemoryChangesTrieStorage};
+1 -1
View File
@@ -18,7 +18,7 @@ use std::collections::BTreeSet;
use std::cmp::{Ord, Ordering};
use kvdb::{KeyValueDB, DBTransaction};
use runtime_primitives::traits::SimpleArithmetic;
use codec::{Encode, Decode};
use parity_codec::{Encode, Decode};
use crate::error;
/// helper wrapper type to keep a list of block hashes ordered
-2
View File
@@ -20,8 +20,6 @@
#![warn(missing_docs)]
#![recursion_limit="128"]
extern crate parity_codec as codec;
#[macro_use]
pub mod runtime_api;
#[cfg(feature = "std")]
@@ -20,7 +20,7 @@
use std::{collections::HashSet, sync::Arc, panic::UnwindSafe, result, marker::PhantomData};
use futures::{IntoFuture, Future};
use codec::{Encode, Decode};
use parity_codec::{Encode, Decode};
use primitives::{H256, Blake2Hasher, convert_hash, NativeOrEncoded};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{As, Block as BlockT, Header as HeaderT};
+1 -1
View File
@@ -33,7 +33,7 @@ pub use runtime_version::{ApiId, RuntimeVersion, ApisVec, create_apis_vec};
pub use rstd::{slice, mem};
#[cfg(feature = "std")]
use rstd::result;
pub use codec::{Encode, Decode};
pub use parity_codec::{Encode, Decode};
#[cfg(feature = "std")]
use crate::error;
use rstd::vec::Vec;
@@ -6,7 +6,7 @@ description = "Generic slots-based utilities for consensus"
edition = "2018"
[dependencies]
parity-codec = "3.0"
codec = { package = "parity-codec", version = "3.0" }
client = { package = "substrate-client", path = "../../../client" }
primitives = { package = "substrate-primitives", path = "../../../primitives" }
runtime_primitives = { package = "sr-primitives", path = "../../../sr-primitives" }
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
extern crate parity_codec as codec;
mod slots;
pub use slots::{Slots, SlotInfo};
@@ -220,7 +218,7 @@ impl SlotDuration {
C: ProvideRuntimeApi,
C::Api: AuraApi<B>,
{
use parity_codec::Decode;
use codec::Decode;
const SLOT_KEY: &[u8] = b"aura_slot_duration";
match client.get_aux(SLOT_KEY)? {
+2 -3
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
futures = "0.1.17"
parity-codec = { version = "3.0" }
codec = { package = "parity-codec", version = "3.0" }
parity-codec-derive = { version = "3.0" }
primitives = { package = "substrate-primitives", path = "../../primitives" }
consensus = { package = "substrate-consensus-common", path = "../common" }
@@ -27,8 +27,7 @@ rhododendron = { version = "0.5.0", features = ["codec"] }
exit-future = "0.1"
[dev-dependencies]
substrate-keyring = { path = "../../keyring" }
substrate-executor = { path = "../../executor" }
keyring = { package = "substrate-keyring", path = "../../keyring" }
[features]
default = ["std"]
-2
View File
@@ -1318,8 +1318,6 @@ mod tests {
use primitives::H256;
use self::keyring::Keyring;
extern crate substrate_keyring as keyring;
type TestBlock = GenericTestBlock<()>;
struct FakeClient {
+1 -1
View File
@@ -1,11 +1,11 @@
[package]
description = "libp2p implementation of the ethcore network library"
edition = "2018"
homepage = "http://parity.io"
license = "GPL-3.0"
name = "substrate-network-libp2p"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
bytes = "0.4"
+5 -4
View File
@@ -2,6 +2,7 @@
name = "sr-api-macros"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[lib]
proc-macro = true
@@ -14,10 +15,10 @@ blake2-rfc = "0.2"
proc-macro-crate = "0.1.3"
[dev-dependencies]
substrate-client = { path = "../client" }
substrate-test-client = { path = "../test-client" }
substrate-state-machine = { path = "../state-machine" }
sr-primitives = { path = "../sr-primitives" }
client = { package = "substrate-client", path = "../client" }
test_client = { package = "substrate-test-client", path = "../test-client" }
state_machine = { package = "substrate-state-machine", path = "../state-machine" }
runtime_primitives = { package = "sr-primitives", path = "../sr-primitives" }
sr-version = { path = "../sr-version" }
substrate-primitives = { path = "../primitives" }
criterion = "0.2"
@@ -14,12 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
#[macro_use]
extern crate criterion;
extern crate substrate_client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
use criterion::Criterion;
use test_client::runtime::TestAPI;
use runtime_primitives::{generic::BlockId, traits::ProvideRuntimeApi};
@@ -20,7 +20,7 @@ mod declaring_own_block {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate sr_primitives as runtime_primitives;
use runtime_primitives::traits::Block as BlockT;
@@ -40,7 +40,7 @@ mod declaring_own_block_with_different_name {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate sr_primitives as runtime_primitives;
use runtime_primitives::traits::Block as BlockT;
@@ -60,7 +60,7 @@ mod adding_self_parameter {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate sr_primitives as runtime_primitives;
decl_runtime_apis! {
@@ -78,7 +78,7 @@ mod adding_at_parameter {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate sr_primitives as runtime_primitives;
decl_runtime_apis! {
@@ -96,7 +96,7 @@ mod invalid_api_version {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate sr_primitives as runtime_primitives;
decl_runtime_apis! {
@@ -115,7 +115,7 @@ mod invalid_api_version_2 {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate sr_primitives as runtime_primitives;
decl_runtime_apis! {
@@ -134,7 +134,7 @@ mod invalid_api_version_3 {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate sr_primitives as runtime_primitives;
decl_runtime_apis! {
@@ -153,7 +153,7 @@ mod missing_block_generic_parameter {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_primitives as primitives;
@@ -191,7 +191,7 @@ mod missing_path_for_trait {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_primitives as primitives;
@@ -229,7 +229,7 @@ mod empty_impl_runtime_apis_call {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_primitives as primitives;
@@ -261,7 +261,7 @@ mod type_reference_in_impl_runtime_apis_call {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_primitives as primitives;
@@ -299,7 +299,7 @@ mod impl_incorrect_method_signature {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_primitives as primitives;
@@ -335,7 +335,7 @@ mod impl_two_traits_with_same_name {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_primitives as primitives;
@@ -383,7 +383,7 @@ mod changed_at_unknown_version {
/*!
```compile_fail
#[macro_use]
extern crate substrate_client;
extern crate client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_primitives as primitives;
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use utils::{
use crate::utils::{
generate_crate_access, generate_hidden_includes, generate_runtime_mod_name_for_trait,
fold_fn_decl_for_client_side, unwrap_or_error, extract_parameter_names_types_and_borrows,
generate_native_call_generator_fn_name, return_type_extract_type,
@@ -241,7 +241,7 @@ fn generate_native_call_generators(decl: &ItemTrait) -> Result<TokenStream> {
let (impl_generics, ty_generics, where_clause) = decl.generics.split_for_impl();
// We need to parse them again, to get an easy access to the actual parameters.
let mut impl_generics: Generics = parse_quote!(#impl_generics);
let impl_generics: Generics = parse_quote!(#impl_generics);
let impl_generics_params = impl_generics.params.iter().map(|p| {
match p {
GenericParam::Type(ref ty) => {
@@ -614,7 +614,7 @@ fn generate_client_side_decls(decls: &[ItemTrait]) -> TokenStream {
let mut result = Vec::new();
for decl in decls {
let mut decl = decl.clone();
let decl = decl.clone();
let crate_ = generate_crate_access(HIDDEN_INCLUDES_ID);
let block_id = quote!( #crate_::runtime_api::BlockId<Block> );
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use utils::{
use crate::utils::{
unwrap_or_error, generate_crate_access, generate_hidden_includes,
generate_runtime_mod_name_for_trait, generate_method_runtime_api_impl_name,
extract_parameter_names_types_and_borrows, generate_native_call_generator_fn_name,
+6 -11
View File
@@ -18,11 +18,6 @@
#![recursion_limit = "512"]
extern crate proc_macro;
extern crate proc_macro2;
extern crate quote;
extern crate syn;
extern crate blake2_rfc;
extern crate proc_macro_crate;
use proc_macro::TokenStream;
@@ -51,13 +46,13 @@ mod compile_fail_tests;
///
/// ```rust
/// #[macro_use]
/// extern crate substrate_client;
/// extern crate client;
/// extern crate sr_version as version;
///
/// use version::create_runtime_str;
/// # extern crate substrate_test_client as test_client;
/// # extern crate sr_primitives as runtime_primitives;
/// # extern crate substrate_primitives as primitives;
/// # extern crate test_client;
/// # extern crate runtime_primitives;
/// # extern crate substrate_primitives;
/// #
/// # use runtime_primitives::traits::GetNodeBlockType;
/// # use test_client::runtime::Block;
@@ -133,7 +128,7 @@ pub fn impl_runtime_apis(input: TokenStream) -> TokenStream {
///
/// ```rust
/// #[macro_use]
/// extern crate substrate_client;
/// extern crate client;
///
/// decl_runtime_apis! {
/// /// Declare the api trait.
@@ -168,7 +163,7 @@ pub fn impl_runtime_apis(input: TokenStream) -> TokenStream {
///
/// ```rust
/// #[macro_use]
/// extern crate substrate_client;
/// extern crate client;
///
/// decl_runtime_apis! {
/// /// Declare the api trait.
@@ -1,13 +1,23 @@
#[macro_use]
extern crate substrate_client as client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_primitives as primitives;
extern crate substrate_test_client as test_client;
// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use runtime_primitives::traits::{GetNodeBlockType, Block as BlockT, AuthorityIdFor};
use runtime_primitives::generic::BlockId;
use client::runtime_api::{self, RuntimeApiInfo};
use client::error::Result;
use client::{error::Result, decl_runtime_apis, impl_runtime_apis};
use test_client::runtime::Block;
/// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType`
@@ -14,11 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
extern crate substrate_client;
extern crate substrate_test_client as test_client;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_state_machine as state_machine;
use test_client::runtime::{TestAPI, DecodeFails};
use runtime_primitives::{generic::BlockId, traits::ProvideRuntimeApi};
use state_machine::ExecutionStrategy;
+2 -5
View File
@@ -158,12 +158,9 @@ impl NativeVersion {
#[cfg(feature = "std")]
mod apis_serialize {
extern crate impl_serde;
extern crate serde;
use super::*;
use self::impl_serde::serialize as bytes;
use self::serde::{Serializer, ser::SerializeTuple};
use impl_serde::serialize as bytes;
use serde::{Serializer, ser::SerializeTuple};
#[derive(Serialize)]
struct ApiId<'a>(
+2 -2
View File
@@ -20,7 +20,7 @@ rstd = { package = "sr-std", path = "../sr-std", default-features = false }
runtime_io = { package = "sr-io", path = "../sr-io", default-features = false }
runtime_primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false }
runtime_version = { package = "sr-version", path = "../sr-version", default-features = false }
srml-support = { path = "../../srml/support", default-features = false }
runtime_support = { package = "srml-support", path = "../../srml/support", default-features = false }
cfg-if = "0.1.6"
[dev-dependencies]
@@ -38,7 +38,7 @@ std = [
"parity-codec/std",
"rstd/std",
"runtime_io/std",
"srml-support/std",
"runtime_support/std",
"primitives/std",
"inherents/std",
"runtime_primitives/std",
-3
View File
@@ -18,9 +18,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#[macro_use]
extern crate srml_support as runtime_support;
#[cfg(feature = "std")] pub mod genesismap;
pub mod system;
@@ -20,6 +20,7 @@
use rstd::prelude::*;
use runtime_io::{storage_root, enumerated_trie_root, storage_changes_root, twox_128};
use runtime_support::storage::{self, StorageValue, StorageMap};
use runtime_support::storage_items;
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256, Digest as DigestT};
use runtime_primitives::generic;
use runtime_primitives::{ApplyError, ApplyOutcome, ApplyResult, transaction_validity::TransactionValidity};
+1 -1
View File
@@ -28,7 +28,7 @@ substrate-executor = { path = "../core/executor" }
substrate-service = { path = "../core/service" }
inherents = { package = "substrate-inherents", path = "../core/inherents" }
transaction-pool = { package = "substrate-transaction-pool", path = "../core/transaction-pool" }
substrate-network = { path = "../core/network" }
network = { package = "substrate-network", path = "../core/network" }
consensus = { package = "substrate-consensus-aura", path = "../core/consensus/aura" }
substrate-client = { path = "../core/client" }
basic-authorship = { package = "substrate-basic-authorship", path = "../core/basic-authorship" }
+2 -6
View File
@@ -6,12 +6,8 @@
#![recursion_limit="256"]
#[cfg(feature = "std")]
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate parity_codec_derive;
use serde_derive::{Serialize, Deserialize};
use parity_codec_derive::{Encode, Decode};
use rstd::prelude::*;
#[cfg(feature = "std")]
use primitives::bytes;
+1
View File
@@ -7,6 +7,7 @@ use substrate_cli::{informant, parse_and_execute, NoCustom};
use substrate_service::{ServiceFactory, Roles as ServiceRoles};
use crate::chain_spec;
use std::ops::Deref;
use log::info;
/// Parse command line arguments into service configuration.
pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()> where
+1 -12
View File
@@ -3,17 +3,6 @@
#![warn(missing_docs)]
#![warn(unused_extern_crates)]
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
#[macro_use]
extern crate substrate_network as network;
#[macro_use]
extern crate substrate_executor;
#[macro_use]
extern crate substrate_service;
mod chain_spec;
mod service;
mod cli;
@@ -33,4 +22,4 @@ fn run() -> cli::error::Result<()> {
cli::run(::std::env::args(), cli::Exit, version)
}
quick_main!(run);
error_chain::quick_main!(run);
+4
View File
@@ -3,6 +3,7 @@
#![warn(unused_extern_crates)]
use std::sync::Arc;
use log::info;
use transaction_pool::{self, txpool::{Pool as TransactionPool}};
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
use substrate_service::{
@@ -16,6 +17,9 @@ use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration, Nothing
use substrate_client as client;
use primitives::ed25519::Pair;
use inherents::InherentDataProviders;
use network::construct_simple_protocol;
use substrate_executor::native_executor_instance;
use substrate_service::construct_service_factory;
pub use substrate_executor::NativeExecutor;
// Our native executor instance.
+1 -5
View File
@@ -20,9 +20,6 @@
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit="256"]
#[macro_use]
extern crate runtime_primitives;
use rstd::prelude::*;
use parity_codec_derive::{Encode, Decode};
#[cfg(feature = "std")]
@@ -37,9 +34,8 @@ use client::{
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
runtime_api as client_api, impl_runtime_apis
};
use runtime_primitives::ApplyResult;
use runtime_primitives::{ApplyResult, generic, create_runtime_str};
use runtime_primitives::transaction_validity::TransactionValidity;
use runtime_primitives::generic;
use runtime_primitives::traits::{
Convert, BlakeTwo256, Block as BlockT, DigestFor, NumberFor, StaticLookup,
};
+1 -8
View File
@@ -18,13 +18,6 @@
#![warn(missing_docs)]
extern crate node_cli as cli;
extern crate ctrlc;
extern crate futures;
#[macro_use]
extern crate error_chain;
use cli::VersionInfo;
use futures::sync::oneshot;
use futures::{future, Future};
@@ -50,7 +43,7 @@ impl cli::IntoExit for Exit {
}
}
quick_main!(run);
error_chain::quick_main!(run);
fn run() -> cli::error::Result<()> {
let version = VersionInfo {