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

Commit

Permalink
Merge branch 'master' into sassafras-primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Aug 18, 2023
2 parents 35b310a + 0cdf702 commit f2d8a64
Show file tree
Hide file tree
Showing 189 changed files with 6,152 additions and 4,513 deletions.
1,534 changes: 1,213 additions & 321 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions bin/node-template/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ pub enum Subcommand {
#[command(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// Try some command against runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),

/// Try some command against runtime state. Note: `try-runtime` feature must be enabled.
#[cfg(not(feature = "try-runtime"))]
/// Try-runtime has migrated to a standalone CLI
/// (<https://github.com/paritytech/try-runtime-cli>). The subcommand exists as a stub and
/// deprecation notice. It will be removed entirely some time after Janurary 2024.
TryRuntime,

/// Db meta columns information.
Expand Down
26 changes: 1 addition & 25 deletions bin/node-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ use sc_cli::SubstrateCli;
use sc_service::PartialComponents;
use sp_keyring::Sr25519Keyring;

#[cfg(feature = "try-runtime")]
use try_runtime_cli::block_building_info::timestamp_with_aura_info;

impl SubstrateCli for Cli {
fn impl_name() -> String {
"Substrate Node".into()
Expand Down Expand Up @@ -172,28 +169,7 @@ pub fn run() -> sc_cli::Result<()> {
})
},
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use crate::service::ExecutorDispatch;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
// we don't need any of the components of new_partial, just a runtime, or a task
// manager to do `async_run`.
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;
let info_provider = timestamp_with_aura_info(6000);

Ok((
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
>, _>(Some(info_provider)),
task_manager,
))
})
},
Some(Subcommand::TryRuntime) => Err(try_runtime_cli::DEPRECATION_NOTICE.into()),
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \
You can enable it with `--features try-runtime`."
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn new_partial(
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_consensus_grandpa::GrandpaBlockImport<
Expand Down
2 changes: 1 addition & 1 deletion bin/node-template/pallets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub mod pallet {
// Read a value from storage.
match <Something<T>>::get() {
// Return an error if the value has not been set.
None => return Err(Error::<T>::NoneValue.into()),
None => Err(Error::<T>::NoneValue.into()),
Some(old) => {
// Increment the value read from storage; will error in the event of overflow.
let new = old.checked_add(1).ok_or(Error::<T>::StorageOverflow)?;
Expand Down
9 changes: 1 addition & 8 deletions bin/node/cli/benches/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
offchain_worker: OffchainWorkerConfig { enabled: true, indexing_enabled: false },
force_authoring: false,
disable_grandpa: false,
disable_beefy: false,
dev_key_seed: Some(Sr25519Keyring::Alice.to_seed()),
tracing_targets: None,
tracing_receiver: Default::default(),
Expand All @@ -113,13 +112,7 @@ fn extrinsic_set_time(now: u64) -> OpaqueExtrinsic {
.into()
}

fn import_block(
mut client: &FullClient,
built: BuiltBlock<
node_primitives::Block,
<FullClient as sp_api::CallApiAt<node_primitives::Block>>::StateBackend,
>,
) {
fn import_block(mut client: &FullClient, built: BuiltBlock<node_primitives::Block>) {
let mut params = BlockImportParams::new(BlockOrigin::File, built.block.header);
params.state_action =
StateAction::ApplyChanges(sc_consensus::StorageChanges::Changes(built.storage_changes));
Expand Down
1 change: 0 additions & 1 deletion bin/node/cli/benches/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
offchain_worker: OffchainWorkerConfig { enabled: true, indexing_enabled: false },
force_authoring: false,
disable_grandpa: false,
disable_beefy: false,
dev_key_seed: Some(Sr25519Keyring::Alice.to_seed()),
tracing_targets: None,
tracing_receiver: Default::default(),
Expand Down
4 changes: 2 additions & 2 deletions bin/node/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ mod cli {
rerun_if_git_head_changed();
}

/// Build shell completion scripts for all known shells
/// Build shell completion scripts for all known shells.
fn build_shell_completion() {
for shell in Shell::value_variants() {
build_completion(shell);
}
}

/// Build the shell auto-completion for a given Shell
/// Build the shell auto-completion for a given Shell.
fn build_completion(shell: &Shell) {
let outdir = match env::var_os("OUT_DIR") {
None => return,
Expand Down
6 changes: 3 additions & 3 deletions bin/node/cli/doc/shell-completion.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

== Shell completion

The Substrate cli command supports shell auto-completion. For this to work, you will need to run the completion script matching you build and system.
The Substrate cli command supports shell auto-completion. For this to work, you will need to run the completion script matching your build and system.

Assuming you built a release version using `cargo build --release` and use `bash` run the following:

Expand All @@ -15,7 +15,7 @@ You can find completion scripts for:
- elvish
- powershell

To make this change persistent, you can proceed as follow:
To make this change persistent, you can proceed as follows:

.First install

Expand All @@ -30,7 +30,7 @@ source $HOME/.bash_profile

.Update

When you build a new version of Substrate, the following will ensure you auto-completion script matches the current binary:
When you build a new version of Substrate, the following will ensure your auto-completion script matches the current binary:

[source, shell]
----
Expand Down
16 changes: 8 additions & 8 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,22 @@ pub fn staging_testnet_config() -> ChainSpec {
)
}

/// Helper function to generate a crypto pair from seed
/// Helper function to generate a crypto pair from seed.
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
}

/// Helper function to generate an account ID from seed
/// Helper function to generate an account ID from seed.
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}

/// Helper function to generate stash, controller and session key from seed
/// Helper function to generate stash, controller and session key from seed.
pub fn authority_keys_from_seed(
seed: &str,
) -> (AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId) {
Expand All @@ -228,7 +228,7 @@ pub fn authority_keys_from_seed(
)
}

/// Helper function to create RuntimeGenesisConfig for testing
/// Helper function to create RuntimeGenesisConfig for testing.
pub fn testnet_genesis(
initial_authorities: Vec<(
AccountId,
Expand Down Expand Up @@ -377,7 +377,7 @@ fn development_config_genesis() -> RuntimeGenesisConfig {
)
}

/// Development config (single validator Alice)
/// Development config (single validator Alice).
pub fn development_config() -> ChainSpec {
ChainSpec::from_genesis(
"Development",
Expand All @@ -402,7 +402,7 @@ fn local_testnet_genesis() -> RuntimeGenesisConfig {
)
}

/// Local testnet config (multivalidator Alice + Bob)
/// Local testnet config (multivalidator Alice + Bob).
pub fn local_testnet_config() -> ChainSpec {
ChainSpec::from_genesis(
"Local Testnet",
Expand Down Expand Up @@ -434,7 +434,7 @@ pub(crate) mod tests {
)
}

/// Local testnet config (single validator - Alice)
/// Local testnet config (single validator - Alice).
pub fn integration_test_config_with_single_authority() -> ChainSpec {
ChainSpec::from_genesis(
"Integration Test",
Expand All @@ -450,7 +450,7 @@ pub(crate) mod tests {
)
}

/// Local testnet config (multivalidator Alice + Bob)
/// Local testnet config (multivalidator Alice + Bob).
pub fn integration_test_config_with_two_authorities() -> ChainSpec {
ChainSpec::from_genesis(
"Integration Test",
Expand Down
9 changes: 3 additions & 6 deletions bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@ pub enum Subcommand {
#[command(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// Try some command against runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),

/// Try some command against runtime state. Note: `try-runtime` feature must be enabled.
#[cfg(not(feature = "try-runtime"))]
/// Try-runtime has migrated to a standalone CLI
/// (<https://github.com/paritytech/try-runtime-cli>). The subcommand exists as a stub and
/// deprecation notice. It will be removed entirely some time after Janurary 2024.
TryRuntime,

/// Key management cli utilities
Expand Down
29 changes: 1 addition & 28 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ use sp_keyring::Sr25519Keyring;

use std::sync::Arc;

#[cfg(feature = "try-runtime")]
use {
kitchensink_runtime::constants::time::SLOT_DURATION,
try_runtime_cli::block_building_info::substrate_info,
};

impl SubstrateCli for Cli {
fn impl_name() -> String {
"Substrate Node".into()
Expand Down Expand Up @@ -227,28 +221,7 @@ pub fn run() -> Result<()> {
})
},
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
// we don't need any of the components of new_partial, just a runtime, or a task
// manager to do `async_run`.
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;

let info_provider = substrate_info(SLOT_DURATION);

Ok((
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
>, _>(Some(info_provider)),
task_manager,
))
})
},
Some(Subcommand::TryRuntime) => Err(try_runtime_cli::DEPRECATION_NOTICE.into()),
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \
You can enable it with `--features try-runtime`."
Expand Down
4 changes: 2 additions & 2 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
type FullGrandpaBlockImport =
grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>;

/// The transaction pool type defintion.
/// The transaction pool type definition.
pub type TransactionPool = sc_transaction_pool::FullPool<Block, FullClient>;

/// The minimum period of blocks on which justifications will be
Expand Down Expand Up @@ -140,7 +140,7 @@ pub fn new_partial(
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
impl Fn(
Expand Down
3 changes: 0 additions & 3 deletions bin/node/testing/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ pub type Client = client::Client<
kitchensink_runtime::RuntimeApi,
>;

/// Transaction for kitchensink-runtime.
pub type Transaction = sc_client_api::backend::TransactionFor<Backend, node_primitives::Block>;

/// Genesis configuration parameters for `TestClient`.
#[derive(Default)]
pub struct GenesisParameters;
Expand Down
10 changes: 2 additions & 8 deletions client/api/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,11 @@ use sp_storage::{ChildInfo, StorageData, StorageKey};

use crate::{blockchain::Backend as BlockchainBackend, UsageInfo};

pub use sp_state_machine::{Backend as StateBackend, KeyValueStates};
pub use sp_state_machine::{Backend as StateBackend, BackendTransaction, KeyValueStates};

/// Extracts the state backend type for the given backend.
pub type StateBackendFor<B, Block> = <B as Backend<Block>>::State;

/// Extracts the transaction for the given state backend.
pub type TransactionForSB<B, Block> = <B as StateBackend<HashingFor<Block>>>::Transaction;

/// Extracts the transaction for the given backend.
pub type TransactionFor<B, Block> = TransactionForSB<StateBackendFor<B, Block>, Block>;

/// Describes which block import notification stream should be notified.
#[derive(Debug, Clone, Copy)]
pub enum ImportNotificationAction {
Expand Down Expand Up @@ -181,7 +175,7 @@ pub trait BlockImportOperation<Block: BlockT> {
/// Inject storage data into the database.
fn update_db_storage(
&mut self,
update: TransactionForSB<Self::State, Block>,
update: BackendTransaction<HashingFor<Block>>,
) -> sp_blockchain::Result<()>;

/// Set genesis state. If `commit` is `false` the state is saved in memory, but is not written
Expand Down
9 changes: 2 additions & 7 deletions client/api/src/call_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use sp_state_machine::{OverlayedChanges, StorageProof};
use std::cell::RefCell;

use crate::execution_extensions::ExecutionExtensions;
use sp_api::{ProofRecorder, StorageTransactionCache};
use sp_api::{HashingFor, ProofRecorder};

/// Executor Provider
pub trait ExecutorProvider<Block: BlockT> {
Expand Down Expand Up @@ -72,12 +72,7 @@ pub trait CallExecutor<B: BlockT>: RuntimeVersionOf {
at_hash: B::Hash,
method: &str,
call_data: &[u8],
changes: &RefCell<OverlayedChanges>,
storage_transaction_cache: Option<
&RefCell<
StorageTransactionCache<B, <Self::Backend as crate::backend::Backend<B>>::State>,
>,
>,
changes: &RefCell<OverlayedChanges<HashingFor<B>>>,
proof_recorder: &Option<ProofRecorder<B>>,
call_context: CallContext,
extensions: &RefCell<Extensions>,
Expand Down
10 changes: 4 additions & 6 deletions client/api/src/in_mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use sp_runtime::{
Justification, Justifications, StateVersion, Storage,
};
use sp_state_machine::{
Backend as StateBackend, ChildStorageCollection, InMemoryBackend, IndexOperation,
StorageCollection,
Backend as StateBackend, BackendTransaction, ChildStorageCollection, InMemoryBackend,
IndexOperation, StorageCollection,
};
use std::{
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -480,9 +480,7 @@ impl<Block: BlockT> backend::AuxStore for Blockchain<Block> {
pub struct BlockImportOperation<Block: BlockT> {
pending_block: Option<PendingBlock<Block>>,
old_state: InMemoryBackend<HashingFor<Block>>,
new_state: Option<
<InMemoryBackend<HashingFor<Block>> as StateBackend<HashingFor<Block>>>::Transaction,
>,
new_state: Option<BackendTransaction<HashingFor<Block>>>,
aux: Vec<(Vec<u8>, Option<Vec<u8>>)>,
finalized_blocks: Vec<(Block::Hash, Option<Justification>)>,
set_head: Option<Block::Hash>,
Expand Down Expand Up @@ -540,7 +538,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio

fn update_db_storage(
&mut self,
update: <InMemoryBackend<HashingFor<Block>> as StateBackend<HashingFor<Block>>>::Transaction,
update: BackendTransaction<HashingFor<Block>>,
) -> sp_blockchain::Result<()> {
self.new_state = Some(update);
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions client/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features =
futures = "0.3.21"
futures-timer = "3.0.1"
ip_network = "0.4.1"
libp2p = { version = "0.52.1", features = ["kad", "ed25519"] }
multihash-codetable = { version = "0.1.0", features = ["sha2", "digest"] }
libp2p = { version = "0.51.3", features = ["kad", "ed25519"] }
multihash = { version = "0.17.0", default-features = false, features = ["std", "sha2"] }
log = "0.4.17"
prost = "0.11"
rand = "0.8.5"
Expand Down
Loading

0 comments on commit f2d8a64

Please sign in to comment.