Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

The crate rename #4223

Merged
merged 7 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 9 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ check-web-wasm:
script:
# WASM support is in progress. As more and more crates support WASM, we
# should add entries here. See https://github.com/paritytech/substrate/issues/2416
- time cargo build --target=wasm32-unknown-unknown -p sr-io
- time cargo build --target=wasm32-unknown-unknown -p sr-primitives
- time cargo build --target=wasm32-unknown-unknown -p sr-std
- time cargo build --target=wasm32-unknown-unknown -p substrate-client
- time cargo build --target=wasm32-unknown-unknown -p substrate-consensus-aura
- time cargo build --target=wasm32-unknown-unknown -p substrate-consensus-babe
- time cargo build --target=wasm32-unknown-unknown -p substrate-consensus-common
- time cargo build --target=wasm32-unknown-unknown -p substrate-telemetry
- time cargo build --target=wasm32-unknown-unknown -p sp-io
- time cargo build --target=wasm32-unknown-unknown -p sp-runtime
- time cargo build --target=wasm32-unknown-unknown -p sp-std
- time cargo build --target=wasm32-unknown-unknown -p sc-client
- time cargo build --target=wasm32-unknown-unknown -p sc-consensus-aura
- time cargo build --target=wasm32-unknown-unknown -p sc-consensus-babe
- time cargo build --target=wasm32-unknown-unknown -p sp-consensus
- time cargo build --target=wasm32-unknown-unknown -p sc-telemetry
# Note: the command below is a bit weird because several Cargo issues prevent us from compiling the node in a more straight-forward way.
- time cargo build --manifest-path=bin/node/cli/Cargo.toml --no-default-features --features "browser" --target=wasm32-unknown-unknown
- sccache -s
Expand Down Expand Up @@ -369,7 +369,7 @@ check_polkadot:
- git grep -l "polkadot-master" | grep toml | xargs sed -i "s/branch.*=.*\"polkadot-master\"/rev = \"$COMMIT_HASH\"/; s~https://github.com/paritytech/substrate~file://$SUBSTRATE_PATH~; s/,\s*}/ }/"
# Make sure 'Cargo.lock' matches 'Cargo.toml'. It's enough to update one
# package, others are updated along the way.
- cargo update -p sr-io
- cargo update -p sp-io
# Check whether Polkadot 'master' branch builds with this Substrate commit.
- time cargo check
- cd -
Expand Down
112 changes: 112 additions & 0 deletions .maintain/rename-crates-for-2.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash

function rust_rename() {
sed -i "s/$1/$2/g" `grep -Rl --include="*.rs" --include="*.stderr" "$1" *` > /dev/null
}

function cargo_rename() {
find . -name "Cargo.toml" -exec sed -i "s/\(^\|[^\/]\)$1/\1$2/g" {} \;
}

function rename_gitlabci() {
sed -i "s/$1/$2/g" .gitlab-ci.yml
}

function rename() {
old=$(echo $1 | cut -f1 -d\ );
new=$(echo $1 | cut -f2 -d\ );

echo "Renaming $old to $new"
# rename in Cargo.tomls
cargo_rename $old $new
rename_gitlabci $old $new
# and it appears, we have the same syntax in rust files
rust_rename $old $new

# but generally we have the snail case syntax in rust files
old=$(echo $old | sed s/-/_/g );
new=$(echo $new | sed s/-/_/g );

echo " > $old to $new"
rust_rename $old $new
}

TO_RENAME=(
# OLD-CRATE-NAME NEW-CRATE-NAME

# PRIMITIVES
"substrate-application-crypto sc-application-crypto"
"substrate-authority-discovery-primitives sp-authority-discovery"
"substrate-block-builder-runtime-api sp-block-builder"
"substrate-consensus-aura-primitives sp-consensus-aura"
"substrate-consensus-babe-primitives sp-consensus-babe"
"substrate-consensus-common sp-consensus"
"substrate-consensus-pow-primitives sp-consensus-pow"
"substrate-primitives sp-core"
"substrate-debug-derive sp-debug-derive"
"substrate-primitives-storage sp-storage"
"substrate-externalities sp-externalities"
"substrate-finality-grandpa-primitives sp-finality-granpda"
"substrate-inherents sp-inherents"
"substrate-keyring sp-keyring"
"substrate-offchain-primitives sp-offchain"
"substrate-panic-handler sp-panic-handler"
"substrate-phragmen sp-phragmen"
"substrate-rpc-primitives sp-rpc"
"substrate-runtime-interface sp-runtime-interface"
"substrate-runtime-interface-proc-macro sp-runtime-interface-proc-macro"
"substrate-runtime-interface-test-wasm sp-runtime-interface-test-wasm"
"substrate-serializer sp-serializer"
"substrate-session sp-sesssion"
"sr-api sp-api"
"sr-api-proc-macro sp-api-proc-macro"
"sr-api-test sp-api-test"
"sr-arithmetic sp-arithmetic"
"sr-arithmetic-fuzzer sp-arithmetic-fuzzer"
"sr-io sp-io"
"sr-primitives sp-runtime"
"sr-sandbox sp-sandbox"
"sr-staking-primitives sp-staking"
"sr-std sp-std"
"sr-version sp-version"
"substrate-state-machine sp-state-machine"
"substrate-transaction-pool-runtime-api sp-transaction-pool"
gnunicorn marked this conversation as resolved.
Show resolved Hide resolved
"substrate-trie sp-trie"
"substrate-wasm-interface sp-wasm-interface"

# # CLIENT
"substrate-client sc-client"
"substrate-client-api sc-api"
"substrate-authority-discovery sc-authority-discovery"
"substrate-basic-authorship sc-basic-authority"
"substrate-block-builder sc-block-builder"
"substrate-chain-spec sc-chain-spec"
"substrate-chain-spec-derive sc-chain-spec-derive"
"substrate-cli sc-cli"
"substrate-consensus-aura sc-consensus-aura"
"substrate-consensus-babe sc-consensus-babe"
"substrate-consensus-pow sc-consensus-pow"
"substrate-consensus-slots sc-consensus-slots"
"substrate-consensus-uncles sc-consensus-uncles"
"substrate-client-db sc-database"
"substrate-executor sc-executor"
"substrate-runtime-test sc-runtime-test"
"substrate-finality-grandpa sc-finality-grandpa"
"substrate-keystore sc-keystore"
"substrate-network sc-network"
"substrate-offchain sc-offchain"
"substrate-peerset sc-peerset"
"substrate-rpc-servers sc-rpc-server"
"substrate-rpc sc-rpc"
"substrate-service sc-service"
"substrate-service-test sc-service-test"
"substrate-state-db sc-state-db"
"substrate-telemetry sc-telemetry"
"substrate-tracing sc-transaction"
gnunicorn marked this conversation as resolved.
Show resolved Hide resolved

);

for rule in "${TO_RENAME[@]}"
do
rename "$rule";
done
30 changes: 15 additions & 15 deletions bin/node-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ tokio = "0.1.22"
parking_lot = "0.9.0"
codec = { package = "parity-scale-codec", version = "1.0.0" }
trie-root = "0.15.2"
sr-io = { path = "../../primitives/sr-io" }
substrate-cli = { path = "../../client/cli" }
primitives = { package = "substrate-primitives", path = "../../primitives/core" }
substrate-executor = { path = "../../client/executor" }
substrate-service = { path = "../../client/service" }
inherents = { package = "substrate-inherents", path = "../../primitives/inherents" }
sp-io = { path = "../../primitives/sr-io" }
sc-cli = { path = "../../client/cli" }
primitives = { package = "sp-core", path = "../../primitives/core" }
sc-executor = { path = "../../client/executor" }
sc-service = { path = "../../client/service" }
inherents = { package = "sp-inherents", path = "../../primitives/inherents" }
txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" }
txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" }
network = { package = "substrate-network", path = "../../client/network" }
aura = { package = "substrate-consensus-aura", path = "../../client/consensus/aura" }
aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../primitives/consensus/aura" }
consensus-common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" }
grandpa = { package = "substrate-finality-grandpa", path = "../../client/finality-grandpa" }
grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" }
substrate-client = { path = "../../client/" }
network = { package = "sc-network", path = "../../client/network" }
aura = { package = "sc-consensus-aura", path = "../../client/consensus/aura" }
aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura" }
consensus-common = { package = "sp-consensus", path = "../../primitives/consensus/common" }
grandpa = { package = "sc-finality-grandpa", path = "../../client/finality-grandpa" }
grandpa-primitives = { package = "sp-finality-granpda", path = "../../primitives/finality-grandpa" }
sc-client = { path = "../../client/" }
runtime = { package = "node-template-runtime", path = "runtime" }
sr-primitives = { path = "../../primitives/sr-primitives" }
basic-authorship = { package = "substrate-basic-authorship", path = "../../client/basic-authorship"}
sp-runtime = { path = "../../primitives/sr-primitives" }
basic-authorship = { package = "sc-basic-authority", path = "../../client/basic-authorship"}

[build-dependencies]
vergen = "3.0.4"
Expand Down
28 changes: 14 additions & 14 deletions bin/node-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ edition = "2018"

[dependencies]
aura = { package = "pallet-aura", path = "../../../frame/aura", default-features = false }
aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../../primitives/consensus/aura", default-features = false }
aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false }
balances = { package = "pallet-balances", path = "../../../frame/balances", default-features = false }
block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api", default-features = false}
block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false}
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false }
grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa", default-features = false }
indices = { package = "pallet-indices", path = "../../../frame/indices", default-features = false }
inherents = { package = "substrate-inherents", path = "../../../primitives/inherents", default-features = false}
offchain-primitives = { package = "substrate-offchain-primitives", path = "../../../primitives/offchain", default-features = false }
primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false }
inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false}
offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false }
primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false }
randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip", default-features = false }
rstd = { package = "sr-std", path = "../../../primitives/sr-std", default-features = false }
runtime-io = { package = "sr-io", path = "../../../primitives/sr-io", default-features = false }
rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-features = false }
runtime-io = { package = "sp-io", path = "../../../primitives/sr-io", default-features = false }
safe-mix = { version = "1.0.0", default-features = false }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
sr-api = { path = "../../../primitives/sr-api", default-features = false }
sr-primitives = { path = "../../../primitives/sr-primitives", default-features = false }
substrate-session = { path = "../../../primitives/session", default-features = false }
sp-api = { path = "../../../primitives/sr-api", default-features = false }
sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false }
sp-sesssion = { path = "../../../primitives/session", default-features = false }
sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false }
support = { package = "frame-support", path = "../../../frame/support", default-features = false }
system = { package = "frame-system", path = "../../../frame/system", default-features = false }
timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false }
transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false }
txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false }
version = { package = "sr-version", path = "../../../primitives/sr-version", default-features = false }
version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false }

[build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" }
Expand All @@ -54,9 +54,9 @@ std = [
"runtime-io/std",
"safe-mix/std",
"serde",
"sr-api/std",
"sr-primitives/std",
"substrate-session/std",
"sp-api/std",
"sp-runtime/std",
"sp-sesssion/std",
"sudo/std",
"support/std",
"system/std",
Expand Down
18 changes: 9 additions & 9 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

use rstd::prelude::*;
use primitives::OpaqueMetadata;
use sr_primitives::{
use sp_runtime::{
ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
impl_opaque_keys, MultiSignature
};
use sr_primitives::traits::{
use sp_runtime::traits::{
NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount
};
use sr_api::impl_runtime_apis;
use sp_api::impl_runtime_apis;
use aura_primitives::sr25519::AuthorityId as AuraId;
use grandpa::AuthorityList as GrandpaAuthorityList;
use grandpa::fg_primitives;
Expand All @@ -27,10 +27,10 @@ use version::NativeVersion;

// A few exports that help ease life for downstream crates.
#[cfg(any(feature = "std", test))]
pub use sr_primitives::BuildStorage;
pub use sp_runtime::BuildStorage;
pub use timestamp::Call as TimestampCall;
pub use balances::Call as BalancesCall;
pub use sr_primitives::{Permill, Perbill};
pub use sp_runtime::{Permill, Perbill};
pub use support::{
StorageValue, construct_runtime, parameter_types,
traits::Randomness,
Expand Down Expand Up @@ -73,7 +73,7 @@ mod template;
pub mod opaque {
use super::*;

pub use sr_primitives::OpaqueExtrinsic as UncheckedExtrinsic;
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;

/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
Expand Down Expand Up @@ -283,7 +283,7 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExt
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;

impl_runtime_apis! {
impl sr_api::Core<Block> for Runtime {
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
}
Expand All @@ -297,7 +297,7 @@ impl_runtime_apis! {
}
}

impl sr_api::Metadata<Block> for Runtime {
impl sp_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
}
Expand Down Expand Up @@ -350,7 +350,7 @@ impl_runtime_apis! {
}
}

impl substrate_session::SessionKeys<Block> for Runtime {
impl sp_sesssion::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
opaque::SessionKeys::generate(seed)
}
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/runtime/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod tests {

use primitives::H256;
use support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight};
use sr_primitives::{
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,
};

Expand Down
6 changes: 3 additions & 3 deletions bin/node-template/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use runtime::{
};
use aura_primitives::sr25519::{AuthorityId as AuraId};
use grandpa_primitives::{AuthorityId as GrandpaId};
use substrate_service;
use sr_primitives::traits::{Verify, IdentifyAccount};
use sc_service;
use sp_runtime::traits::{Verify, IdentifyAccount};

// Note this is the URL for the telemetry server
//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 = substrate_service::ChainSpec<GenesisConfig>;
pub type ChainSpec = sc_service::ChainSpec<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
6 changes: 3 additions & 3 deletions bin/node-template/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::service;
use futures::{future::{select, Map}, FutureExt, TryFutureExt, channel::oneshot, compat::Future01CompatExt};
use std::cell::RefCell;
use tokio::runtime::Runtime;
pub use substrate_cli::{VersionInfo, IntoExit, error};
use substrate_cli::{display_role, informant, parse_and_prepare, ParseAndPrepare, NoCustom};
use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration};
pub use sc_cli::{VersionInfo, IntoExit, error};
use sc_cli::{display_role, informant, parse_and_prepare, ParseAndPrepare, NoCustom};
use sc_service::{AbstractService, Roles as ServiceRoles, Configuration};
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
use crate::chain_spec;
use log::info;
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod chain_spec;
mod service;
mod cli;

pub use substrate_cli::{VersionInfo, IntoExit, error};
pub use sc_cli::{VersionInfo, IntoExit, error};

fn main() -> Result<(), cli::error::Error> {
let version = VersionInfo {
Expand Down
14 changes: 7 additions & 7 deletions bin/node-template/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

use std::sync::Arc;
use std::time::Duration;
use substrate_client::LongestChain;
use sc_client::LongestChain;
use runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
use sc_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
use inherents::InherentDataProviders;
use network::{construct_simple_protocol};
use substrate_executor::native_executor_instance;
pub use substrate_executor::NativeExecutor;
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use basic_authorship;
Expand All @@ -34,11 +34,11 @@ macro_rules! new_full_start {
let mut import_setup = None;
let inherent_data_providers = inherents::InherentDataProviders::new();

let builder = substrate_service::ServiceBuilder::new_full::<
let builder = sc_service::ServiceBuilder::new_full::<
runtime::opaque::Block, runtime::RuntimeApi, crate::service::Executor
>($config)?
.with_select_chain(|_config, backend| {
Ok(substrate_client::LongestChain::new(backend.clone()))
Ok(sc_client::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client, _fetcher| {
let pool_api = txpool::FullChainApi::new(client.clone());
Expand All @@ -49,7 +49,7 @@ macro_rules! new_full_start {
})?
.with_import_queue(|_config, client, mut select_chain, transaction_pool| {
let select_chain = select_chain.take()
.ok_or_else(|| substrate_service::Error::SelectChainRequired)?;
.ok_or_else(|| sc_service::Error::SelectChainRequired)?;

let (grandpa_block_import, grandpa_link) =
grandpa::block_import::<_, _, _, runtime::RuntimeApi, _>(
Expand Down
Loading