Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
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
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions core/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ where
config.disable_grandpa = cli.no_grandpa;
config.grandpa_voter = cli.grandpa_voter;


let is_dev = cli.shared_params.dev;

let client_id = config.client_id();
Expand All @@ -462,16 +461,10 @@ where
cli.pool_config,
)?;

if let Some(key) = cli.key {
config.keys.push(key);
}

if cli.shared_params.dev && cli.keyring.account.is_none() {
config.keys.push("//Alice".into());
}

if let Some(account) = cli.keyring.account {
config.keys.push(format!("//{}", account));
if cli.shared_params.dev {
config.dev_key_seed = cli.keyring.account
.map(|a| format!("//{}", a))
.or_else(|| Some("//Alice".into()));
}

let rpc_interface: &str = if cli.rpc_external { "0.0.0.0" } else { "127.0.0.1" };
Expand Down
7 changes: 2 additions & 5 deletions core/cli/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,6 @@ pub struct RunCmd {
#[structopt(long = "keystore-path", value_name = "PATH", parse(from_os_str))]
pub keystore_path: Option<PathBuf>,

/// Specify additional key seed
#[structopt(long = "key", value_name = "STRING")]
pub key: Option<String>,

/// Enable validator mode
#[structopt(long = "validator")]
pub validator: bool,
Expand Down Expand Up @@ -443,7 +439,7 @@ lazy_static::lazy_static! {
let conflicts_with = keyring::Sr25519Keyring::iter()
.filter(|b| a != *b)
.map(|b| b.to_string().to_lowercase())
.chain(["name", "key"].iter().map(ToString::to_string))
.chain(["name"].iter().map(ToString::to_string))
.collect::<Vec<_>>();
let name = a.to_string().to_lowercase();

Expand Down Expand Up @@ -485,6 +481,7 @@ impl AugmentClap for Keyring {
.long(&a.name)
.help(&a.help)
.conflicts_with_all(&conflicts_with_strs)
.requires("dev")
.takes_value(false)
)
})
Expand Down
79 changes: 53 additions & 26 deletions core/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{
marker::PhantomData, collections::{HashSet, BTreeMap, HashMap}, sync::Arc,
panic::UnwindSafe, result, cell::RefCell, rc::Rc,
};
use crate::error::Error;
use log::{info, trace, warn};
use futures::channel::mpsc;
use parking_lot::{Mutex, RwLock};
use primitives::NativeOrEncoded;
Expand All @@ -47,40 +47,53 @@ use crate::runtime_api::{
};
use primitives::{
Blake2Hasher, H256, ChangesTrieConfiguration, convert_hash,
NeverNativeValue, ExecutionContext
NeverNativeValue, ExecutionContext,
storage::{StorageKey, StorageData, well_known_keys}, NativeOrEncoded
};
use substrate_telemetry::{telemetry, SUBSTRATE_INFO};
use runtime_primitives::{
Justification, BuildStorage,
generic::{BlockId, SignedBlock, DigestItem},
traits::{
Block as BlockT, Header as HeaderT, Zero, NumberFor, CurrentHeight,
BlockNumberToHash, ApiRef, ProvideRuntimeApi,
SaturatedConversion, One, DigestFor,
},
};
use primitives::storage::{StorageKey, StorageData};
use primitives::storage::well_known_keys;
use parity_codec::{Encode, Decode};
use state_machine::{
DBValue, Backend as StateBackend, CodeExecutor, ChangesTrieAnchorBlockId,
ExecutionStrategy, ExecutionManager, prove_read, prove_child_read,
ChangesTrieRootsStorage, ChangesTrieStorage,
key_changes, key_changes_proof, OverlayedChanges, NeverOffchainExt,
};
use hash_db::Hasher;

use crate::backend::{
self, BlockImportOperation, PrunableStateChangesTrieStorage,
StorageCollection, ChildStorageCollection
};
use crate::blockchain::{
self, Info as ChainInfo, Backend as ChainBackend,
HeaderBackend as ChainHeaderBackend, ProvideCache, Cache,
};
use crate::call_executor::{CallExecutor, LocalCallExecutor};
use executor::{RuntimeVersion, RuntimeInfo};
use crate::notifications::{StorageNotifications, StorageEventStream};
use crate::light::{call_executor::prove_execution, fetcher::ChangesProof};
use crate::cht;
use crate::error;
use crate::in_mem;
use crate::block_builder::{self, api::BlockBuilder as BlockBuilderAPI};
use crate::genesis;
use substrate_telemetry::{telemetry, SUBSTRATE_INFO};

use log::{info, trace, warn};
use consensus::{
Error as ConsensusError, BlockImportParams,
ImportResult, BlockOrigin, ForkChoiceStrategy,
well_known_cache_keys::Id as CacheKeyId,
SelectChain, self,
};

use crate::{
runtime_api::{
CallRuntimeAt, ConstructRuntimeApi, Core as CoreApi, ProofRecorder,
InitializeBlock,
},
backend::{
self, BlockImportOperation, PrunableStateChangesTrieStorage,
StorageCollection, ChildStorageCollection
},
blockchain::{
self, Info as ChainInfo, Backend as ChainBackend,
HeaderBackend as ChainHeaderBackend, ProvideCache, Cache,
},
call_executor::{CallExecutor, LocalCallExecutor},
notifications::{StorageNotifications, StorageEventStream},
light::{call_executor::prove_execution, fetcher::ChangesProof},
block_builder::{self, api::BlockBuilder as BlockBuilderAPI},
error::Error,
cht, error, in_mem, genesis
};

/// Type that implements `futures::Stream` of block import events.
pub type ImportNotifications<Block> = mpsc::UnboundedReceiver<BlockImportNotification<Block>>;
Expand Down Expand Up @@ -291,6 +304,20 @@ pub fn new_with_backend<B, E, Block, S, RA>(
Client::new(backend, call_executor, build_genesis_storage, Default::default())
}

/// Figure out the block type for a given type (for now, just a `Client`).
pub trait BlockOf {
/// The type of the block.
type Type: BlockT<Hash=H256>;
}

impl<B, E, Block, RA> BlockOf for Client<B, E, Block, RA> where
B: backend::Backend<Block, Blake2Hasher>,
E: CallExecutor<Block, Blake2Hasher>,
Block: BlockT<Hash=H256>,
{
type Type = Block;
}

impl<B, E, Block, RA> Client<B, E, Block, RA> where
B: backend::Backend<Block, Blake2Hasher>,
E: CallExecutor<Block, Blake2Hasher>,
Expand Down
2 changes: 1 addition & 1 deletion core/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub use crate::client::{
new_in_mem,
BlockBody, BlockStatus, ImportNotifications, FinalityNotifications, BlockchainEvents,
BlockImportNotification, Client, ClientInfo, ExecutionStrategies, FinalityNotification,
LongestChain,
LongestChain, BlockOf,
utils,
};
#[cfg(feature = "std")]
Expand Down
1 change: 1 addition & 0 deletions core/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ inherents = { package = "substrate-inherents", path = "../../inherents" }
srml-aura = { path = "../../../srml/aura" }
client = { package = "substrate-client", path = "../../client" }
substrate-telemetry = { path = "../../telemetry" }
substrate-keystore = { path = "../../keystore" }
consensus_common = { package = "substrate-consensus-common", path = "../common" }
sr-primitives = { path = "../../sr-primitives" }
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] }
Expand Down
34 changes: 34 additions & 0 deletions core/consensus/aura/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,40 @@ use substrate_client::decl_runtime_apis;
use rstd::vec::Vec;
use sr_primitives::ConsensusEngineId;

mod app_sr25519 {
use substrate_primitives::{app_crypto, crypto::key_types::AURA, sr25519};
app_crypto!(sr25519::Pair, sr25519::Public, sr25519::Signature, AURA);
}

pub mod sr25519 {
/// An Aura authority keypair using S/R 25519 as its crypto.
#[cfg(feature = "std")]
pub type AuthorityPair = super::app_sr25519::Pair;

/// An Aura authority signature using S/R 25519 as its crypto.
pub type AuthoritySignature = super::app_sr25519::Signature;

/// An Aura authority identifier using S/R 25519 as its crypto.
pub type AuthorityId = super::app_sr25519::Public;
}

mod app_ed25519 {
use substrate_primitives::{app_crypto, crypto::key_types::AURA, ed25519};
app_crypto!(ed25519::Pair, ed25519::Public, ed25519::Signature, AURA);
}

pub mod ed25519 {
/// An Aura authority keypair using Ed25519 as its crypto.
#[cfg(feature = "std")]
pub type AuthorityPair = super::app_ed25519::Pair;

/// An Aura authority signature using Ed25519 as its crypto.
pub type AuthoritySignature = super::app_ed25519::Signature;

/// An Aura authority identifier using Ed25519 as its crypto.
pub type AuthorityId = super::app_ed25519::Public;
}

/// The `ConsensusEngineId` of AuRa.
pub const AURA_ENGINE_ID: ConsensusEngineId = [b'a', b'u', b'r', b'a'];

Expand Down
Loading