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

Commit

Permalink
Companion for Substrate#14612 (#7536)
Browse files Browse the repository at this point in the history
* Companion for reworking the storage transaction cache

* Cargo lock

* Fixes

* update lockfile for {"substrate"}

---------

Co-authored-by: parity-processbot <>
  • Loading branch information
bkchr committed Aug 17, 2023
1 parent eb7078c commit 046c43b
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 210 deletions.
372 changes: 186 additions & 186 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion node/service/Cargo.toml
Expand Up @@ -53,7 +53,6 @@ sp-session = { git = "https://github.com/paritytech/substrate", branch = "master
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
14 changes: 3 additions & 11 deletions node/service/src/lib.rs
Expand Up @@ -56,7 +56,6 @@ use {
sc_client_api::BlockBackend,
sc_transaction_pool_api::OffchainTransactionPoolFactory,
sp_core::traits::SpawnNamed,
sp_trie::PrefixedMemoryDB,
};

use polkadot_node_subsystem_util::database::Database;
Expand Down Expand Up @@ -475,7 +474,7 @@ fn new_partial<ChainSelection>(
FullClient,
FullBackend,
ChainSelection,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
impl Fn(
Expand Down Expand Up @@ -1321,15 +1320,8 @@ macro_rules! chain_ops {
pub fn new_chain_ops(
config: &mut Configuration,
jaeger_agent: Option<std::net::SocketAddr>,
) -> Result<
(
Arc<FullClient>,
Arc<FullBackend>,
sc_consensus::BasicQueue<Block, PrefixedMemoryDB<BlakeTwo256>>,
TaskManager,
),
Error,
> {
) -> Result<(Arc<FullClient>, Arc<FullBackend>, sc_consensus::BasicQueue<Block>, TaskManager), Error>
{
config.keystore = service::config::KeystoreConfig::InMemory;

if config.chain_spec.is_rococo() ||
Expand Down
2 changes: 1 addition & 1 deletion utils/staking-miner/Cargo.toml
Expand Up @@ -25,7 +25,7 @@ remote-externalities = { git = "https://github.com/paritytech/substrate", branch
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
2 changes: 1 addition & 1 deletion utils/staking-miner/src/dry_run.rs
Expand Up @@ -120,7 +120,7 @@ macro_rules! dry_run_cmd_for { ($runtime:ident) => { paste::paste! {
} else {
Default::default()
};
let mut ext = crate::create_election_ext::<Runtime, Block>(rpc.clone(), config.at, pallets).await?;
let mut ext = crate::create_election_ext::<Runtime>(rpc.clone(), config.at, pallets).await?;
if config.force_snapshot {
force_create_snapshot::<Runtime>(&mut ext)?;
};
Expand Down
2 changes: 1 addition & 1 deletion utils/staking-miner/src/emergency_solution.rs
Expand Up @@ -28,7 +28,7 @@ macro_rules! emergency_solution_cmd_for { ($runtime:ident) => { paste::paste! {
) -> Result<(), Error<$crate::[<$runtime _runtime_exports>]::Runtime>> {
use $crate::[<$runtime _runtime_exports>]::*;

let mut ext = crate::create_election_ext::<Runtime, Block>(client, config.at, vec![]).await?;
let mut ext = crate::create_election_ext::<Runtime>(client, config.at, vec![]).await?;
let raw_solution = crate::mine_with::<Runtime>(&config.solver, &mut ext, false)?;

ext.execute_with(|| {
Expand Down
11 changes: 4 additions & 7 deletions utils/staking-miner/src/main.rs
Expand Up @@ -56,7 +56,6 @@ use runtime_versions::RuntimeVersions;
use signal_hook::consts::signal::*;
use signal_hook_tokio::Signals;
use sp_npos_elections::BalancingConfig;
use sp_runtime::{traits::Block as BlockT, DeserializeOwned};
use std::{ops::Deref, sync::Arc, time::Duration};
use tracing_subscriber::{fmt, EnvFilter};

Expand Down Expand Up @@ -295,15 +294,13 @@ frame_support::parameter_types! {

/// Build the Ext at hash with all the data of `ElectionProviderMultiPhase` and any additional
/// pallets.
async fn create_election_ext<T, B>(
async fn create_election_ext<T>(
client: SharedRpcClient,
at: Option<B::Hash>,
at: Option<Hash>,
additional: Vec<String>,
) -> Result<Ext, Error<T>>
where
T: EPM::Config,
B: BlockT + DeserializeOwned,
B::Header: DeserializeOwned,
{
use frame_support::{storage::generator::StorageMap, traits::PalletInfo};
use sp_core::hashing::twox_128;
Expand All @@ -312,7 +309,7 @@ where
.expect("Pallet always has name; qed.")
.to_string()];
pallets.extend(additional);
Builder::<B>::new()
Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: Transport::Uri(client.uri().to_owned()),
at,
Expand All @@ -323,7 +320,7 @@ where
}))
.build()
.await
.map_err(|why| Error::RemoteExternalities(why))
.map_err(|why| Error::<T>::RemoteExternalities(why))
.map(|rx| rx.inner_ext)
}

Expand Down
2 changes: 1 addition & 1 deletion utils/staking-miner/src/monitor.rs
Expand Up @@ -259,7 +259,7 @@ macro_rules! monitor_cmd_for { ($runtime:tt) => { paste::paste! {

let _lock = submit_lock.lock().await;

let mut ext = match crate::create_election_ext::<Runtime, Block>(rpc.clone(), Some(hash), vec![]).await {
let mut ext = match crate::create_election_ext::<Runtime>(rpc.clone(), Some(hash), vec![]).await {
Ok(ext) => ext,
Err(err) => {
log::debug!(target: LOG_TARGET, "Skipping block {}; {}", at.number, err);
Expand Down
4 changes: 3 additions & 1 deletion utils/staking-miner/src/prelude.rs
Expand Up @@ -32,6 +32,8 @@ pub type Nonce = core_primitives::Nonce;
pub type Hash = core_primitives::Hash;
/// The header type. We re-export it here, but we can easily get it from block as well.
pub type Header = core_primitives::Header;
/// The block type.
pub type Block = core_primitives::Block;

pub use sp_runtime::traits::{Block as BlockT, Header as HeaderT};

Expand All @@ -44,7 +46,7 @@ pub const LOG_TARGET: &str = "staking-miner";
pub use pallet_election_provider_multi_phase as EPM;

/// The externalities type.
pub type Ext = sp_io::TestExternalities;
pub type Ext = sp_state_machine::TestExternalities<sp_runtime::traits::HashingFor<Block>>;

/// The key pair type being used. We "strongly" assume sr25519 for simplicity.
pub type Pair = sp_core::sr25519::Pair;
Expand Down

0 comments on commit 046c43b

Please sign in to comment.