From a846b7460465ddcb70450359b0c92a1be59afb2f Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 26 Sep 2023 23:25:46 +0200
Subject: [PATCH 01/40] Bump directories from 4.0.1 to 5.0.1 (#1656)
Bumps [directories](https://github.com/soc/directories-rs) from 4.0.1 to
5.0.1.
Commits
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=directories&package-manager=cargo&previous-version=4.0.1&new-version=5.0.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore ` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore ` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore ` will
remove the ignore condition of the specified dependency and ignore
conditions
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
Cargo.lock | 17 ++++++++++++-----
substrate/client/service/Cargo.toml | 2 +-
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index dade37f9a02..683289adb45 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4367,9 +4367,9 @@ dependencies = [
[[package]]
name = "directories"
-version = "4.0.1"
+version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210"
+checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35"
dependencies = [
"dirs-sys",
]
@@ -4386,13 +4386,14 @@ dependencies = [
[[package]]
name = "dirs-sys"
-version = "0.3.7"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
+checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
dependencies = [
"libc",
+ "option-ext",
"redox_users",
- "winapi",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -8694,6 +8695,12 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
+[[package]]
+name = "option-ext"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
+
[[package]]
name = "orchestra"
version = "0.3.3"
diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml
index ccf23bc8994..2386bebf24d 100644
--- a/substrate/client/service/Cargo.toml
+++ b/substrate/client/service/Cargo.toml
@@ -80,7 +80,7 @@ tracing-futures = { version = "0.2.4" }
async-trait = "0.1.57"
tokio = { version = "1.22.0", features = ["time", "rt-multi-thread", "parking_lot"] }
tempfile = "3.1.0"
-directories = "4.0.1"
+directories = "5.0.1"
static_init = "1.0.3"
[dev-dependencies]
--
GitLab
From ab3a3bc2786673bfda47646a20f871b8a2e4d59d Mon Sep 17 00:00:00 2001
From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
Date: Wed, 27 Sep 2023 11:58:39 +0200
Subject: [PATCH 02/40] `BlockId` removal: `tx-pool` refactor (#1678)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
It changes following APIs:
- trait `ChainApi`
-- `validate_transaction`
- trait `TransactionPool`
--`submit_at`
--`submit_one`
--`submit_and_watch`
and some implementation details, in particular:
- impl `Pool`
--`submit_at`
--`resubmit_at`
--`submit_one`
--`submit_and_watch`
--`prune_known`
--`prune`
--`prune_tags`
--`resolve_block_number`
--`verify`
--`verify_one`
- revalidation queue
All tests are also adjusted.
---------
Co-authored-by: command-bot <>
Co-authored-by: Bastian Köcher
---
.../service/benches/transaction_throughput.rs | 4 +-
substrate/bin/node/bench/src/construct.rs | 8 +-
substrate/bin/node/bench/src/txpool.rs | 6 +-
.../bin/node/cli/benches/transaction_pool.rs | 4 +-
.../basic-authorship/src/basic_authorship.rs | 47 +-
.../client/consensus/manual-seal/src/lib.rs | 23 +-
.../src/transaction/transaction.rs | 8 +-
substrate/client/rpc/src/author/mod.rs | 30 +-
substrate/client/service/src/lib.rs | 14 +-
substrate/client/service/test/src/lib.rs | 11 +-
.../client/transaction-pool/api/src/lib.rs | 11 +-
.../client/transaction-pool/benches/basics.rs | 37 +-
substrate/client/transaction-pool/src/api.rs | 27 +-
.../client/transaction-pool/src/graph/pool.rs | 168 +++---
substrate/client/transaction-pool/src/lib.rs | 44 +-
.../transaction-pool/src/revalidation.rs | 109 +++-
.../client/transaction-pool/src/tests.rs | 20 +-
.../client/transaction-pool/tests/pool.rs | 480 ++++++++++--------
.../runtime/transaction-pool/src/lib.rs | 12 +-
substrate/utils/frame/rpc/system/src/lib.rs | 6 +-
20 files changed, 609 insertions(+), 460 deletions(-)
diff --git a/cumulus/test/service/benches/transaction_throughput.rs b/cumulus/test/service/benches/transaction_throughput.rs
index 83981a91d46..81ecc84db7b 100644
--- a/cumulus/test/service/benches/transaction_throughput.rs
+++ b/cumulus/test/service/benches/transaction_throughput.rs
@@ -21,7 +21,7 @@ use cumulus_test_runtime::{AccountId, BalancesCall, ExistentialDeposit, SudoCall
use futures::{future, StreamExt};
use sc_transaction_pool_api::{TransactionPool as _, TransactionSource, TransactionStatus};
use sp_core::{crypto::Pair, sr25519};
-use sp_runtime::{generic::BlockId, OpaqueExtrinsic};
+use sp_runtime::OpaqueExtrinsic;
use cumulus_primitives_core::ParaId;
use cumulus_test_service::{
@@ -117,7 +117,7 @@ async fn submit_tx_and_wait_for_inclusion(
let best_hash = client.chain_info().best_hash;
let mut watch = tx_pool
- .submit_and_watch(&BlockId::Hash(best_hash), TransactionSource::External, tx.clone())
+ .submit_and_watch(best_hash, TransactionSource::External, tx.clone())
.await
.expect("Submits tx to pool")
.fuse();
diff --git a/substrate/bin/node/bench/src/construct.rs b/substrate/bin/node/bench/src/construct.rs
index f14f89fcd3a..23d0a0cc1ee 100644
--- a/substrate/bin/node/bench/src/construct.rs
+++ b/substrate/bin/node/bench/src/construct.rs
@@ -35,7 +35,7 @@ use sc_transaction_pool_api::{
};
use sp_consensus::{Environment, Proposer};
use sp_inherents::InherentDataProvider;
-use sp_runtime::{generic::BlockId, traits::NumberFor, OpaqueExtrinsic};
+use sp_runtime::{traits::NumberFor, OpaqueExtrinsic};
use crate::{
common::SizeType,
@@ -233,7 +233,7 @@ impl sc_transaction_pool_api::TransactionPool for Transactions {
/// Returns a future that imports a bunch of unverified transactions to the pool.
fn submit_at(
&self,
- _at: &BlockId,
+ _at: Self::Hash,
_source: TransactionSource,
_xts: Vec>,
) -> PoolFuture>, Self::Error> {
@@ -243,7 +243,7 @@ impl sc_transaction_pool_api::TransactionPool for Transactions {
/// Returns a future that imports one unverified transaction to the pool.
fn submit_one(
&self,
- _at: &BlockId,
+ _at: Self::Hash,
_source: TransactionSource,
_xt: TransactionFor,
) -> PoolFuture, Self::Error> {
@@ -252,7 +252,7 @@ impl sc_transaction_pool_api::TransactionPool for Transactions {
fn submit_and_watch(
&self,
- _at: &BlockId,
+ _at: Self::Hash,
_source: TransactionSource,
_xt: TransactionFor,
) -> PoolFuture>>, Self::Error> {
diff --git a/substrate/bin/node/bench/src/txpool.rs b/substrate/bin/node/bench/src/txpool.rs
index a3524ac5bc8..e56bb559a7b 100644
--- a/substrate/bin/node/bench/src/txpool.rs
+++ b/substrate/bin/node/bench/src/txpool.rs
@@ -27,7 +27,6 @@ use node_testing::bench::{BenchDb, BlockType, DatabaseType, KeyTypes};
use sc_transaction_pool::BasicPool;
use sc_transaction_pool_api::{TransactionPool, TransactionSource};
-use sp_runtime::generic::BlockId;
use crate::core::{self, Mode, Path};
@@ -58,10 +57,11 @@ impl core::BenchmarkDescription for PoolBenchmarkDescription {
impl core::Benchmark for PoolBenchmark {
fn run(&mut self, mode: Mode) -> std::time::Duration {
let context = self.database.create_context();
+ let genesis_hash = context.client.chain_info().genesis_hash;
let _ = context
.client
- .runtime_version_at(context.client.chain_info().genesis_hash)
+ .runtime_version_at(genesis_hash)
.expect("Failed to get runtime version")
.spec_version;
@@ -90,7 +90,7 @@ impl core::Benchmark for PoolBenchmark {
let start = std::time::Instant::now();
let submissions = generated_transactions
.into_iter()
- .map(|tx| txpool.submit_one(&BlockId::Number(0), TransactionSource::External, tx));
+ .map(|tx| txpool.submit_one(genesis_hash, TransactionSource::External, tx));
futures::executor::block_on(futures::future::join_all(submissions));
let elapsed = start.elapsed();
diff --git a/substrate/bin/node/cli/benches/transaction_pool.rs b/substrate/bin/node/cli/benches/transaction_pool.rs
index d3e8c02a958..d21edc55bba 100644
--- a/substrate/bin/node/cli/benches/transaction_pool.rs
+++ b/substrate/bin/node/cli/benches/transaction_pool.rs
@@ -34,7 +34,7 @@ use sc_transaction_pool::PoolLimit;
use sc_transaction_pool_api::{TransactionPool as _, TransactionSource, TransactionStatus};
use sp_core::{crypto::Pair, sr25519};
use sp_keyring::Sr25519Keyring;
-use sp_runtime::{generic::BlockId, OpaqueExtrinsic};
+use sp_runtime::OpaqueExtrinsic;
use tokio::runtime::Handle;
fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
@@ -191,7 +191,7 @@ async fn submit_tx_and_wait_for_inclusion(
let best_hash = client.chain_info().best_hash;
let mut watch = tx_pool
- .submit_and_watch(&BlockId::Hash(best_hash), TransactionSource::External, tx.clone())
+ .submit_and_watch(best_hash, TransactionSource::External, tx.clone())
.await
.expect("Submits tx to pool")
.fuse();
diff --git a/substrate/client/basic-authorship/src/basic_authorship.rs b/substrate/client/basic-authorship/src/basic_authorship.rs
index b3a8f0d8970..0fb61b6fab1 100644
--- a/substrate/client/basic-authorship/src/basic_authorship.rs
+++ b/substrate/client/basic-authorship/src/basic_authorship.rs
@@ -642,8 +642,8 @@ mod tests {
client.clone(),
);
- block_on(txpool.submit_at(&BlockId::number(0), SOURCE, vec![extrinsic(0), extrinsic(1)]))
- .unwrap();
+ let hashof0 = client.info().genesis_hash;
+ block_on(txpool.submit_at(hashof0, SOURCE, vec![extrinsic(0), extrinsic(1)])).unwrap();
block_on(
txpool.maintain(chain_event(
@@ -658,7 +658,7 @@ mod tests {
let cell = Mutex::new((false, time::Instant::now()));
let proposer = proposer_factory.init_with_now(
- &client.expect_header(client.info().genesis_hash).unwrap(),
+ &client.expect_header(hashof0).unwrap(),
Box::new(move || {
let mut value = cell.lock();
if !value.0 {
@@ -736,7 +736,7 @@ mod tests {
let genesis_hash = client.info().best_hash;
- block_on(txpool.submit_at(&BlockId::number(0), SOURCE, vec![extrinsic(0)])).unwrap();
+ block_on(txpool.submit_at(genesis_hash, SOURCE, vec![extrinsic(0)])).unwrap();
block_on(
txpool.maintain(chain_event(
@@ -800,7 +800,7 @@ mod tests {
};
block_on(txpool.submit_at(
- &BlockId::number(0),
+ client.info().genesis_hash,
SOURCE,
vec![medium(0), medium(1), huge(2), medium(3), huge(4), medium(5), medium(6)],
))
@@ -897,9 +897,8 @@ mod tests {
spawner.clone(),
client.clone(),
);
- let genesis_header = client
- .expect_header(client.info().genesis_hash)
- .expect("there should be header");
+ let genesis_hash = client.info().genesis_hash;
+ let genesis_header = client.expect_header(genesis_hash).expect("there should be header");
let extrinsics_num = 5;
let extrinsics = std::iter::once(
@@ -922,7 +921,7 @@ mod tests {
.sum::() +
Vec::::new().encoded_size();
- block_on(txpool.submit_at(&BlockId::number(0), SOURCE, extrinsics.clone())).unwrap();
+ block_on(txpool.submit_at(genesis_hash, SOURCE, extrinsics.clone())).unwrap();
block_on(txpool.maintain(chain_event(genesis_header.clone())));
@@ -999,6 +998,7 @@ mod tests {
spawner.clone(),
client.clone(),
);
+ let genesis_hash = client.info().genesis_hash;
let tiny = |nonce| {
ExtrinsicBuilder::new_fill_block(Perbill::from_parts(TINY)).nonce(nonce).build()
@@ -1011,7 +1011,7 @@ mod tests {
block_on(
txpool.submit_at(
- &BlockId::number(0),
+ genesis_hash,
SOURCE,
// add 2 * MAX_SKIPPED_TRANSACTIONS that exhaust resources
(0..MAX_SKIPPED_TRANSACTIONS * 2)
@@ -1024,13 +1024,9 @@ mod tests {
)
.unwrap();
- block_on(
- txpool.maintain(chain_event(
- client
- .expect_header(client.info().genesis_hash)
- .expect("there should be header"),
- )),
- );
+ block_on(txpool.maintain(chain_event(
+ client.expect_header(genesis_hash).expect("there should be header"),
+ )));
assert_eq!(txpool.ready().count(), MAX_SKIPPED_TRANSACTIONS * 3);
let mut proposer_factory =
@@ -1038,7 +1034,7 @@ mod tests {
let cell = Mutex::new(time::Instant::now());
let proposer = proposer_factory.init_with_now(
- &client.expect_header(client.info().genesis_hash).unwrap(),
+ &client.expect_header(genesis_hash).unwrap(),
Box::new(move || {
let mut value = cell.lock();
let old = *value;
@@ -1071,6 +1067,7 @@ mod tests {
spawner.clone(),
client.clone(),
);
+ let genesis_hash = client.info().genesis_hash;
let tiny = |who| {
ExtrinsicBuilder::new_fill_block(Perbill::from_parts(TINY))
@@ -1086,7 +1083,7 @@ mod tests {
block_on(
txpool.submit_at(
- &BlockId::number(0),
+ genesis_hash,
SOURCE,
(0..MAX_SKIPPED_TRANSACTIONS + 2)
.into_iter()
@@ -1098,13 +1095,9 @@ mod tests {
)
.unwrap();
- block_on(
- txpool.maintain(chain_event(
- client
- .expect_header(client.info().genesis_hash)
- .expect("there should be header"),
- )),
- );
+ block_on(txpool.maintain(chain_event(
+ client.expect_header(genesis_hash).expect("there should be header"),
+ )));
assert_eq!(txpool.ready().count(), MAX_SKIPPED_TRANSACTIONS * 2 + 4);
let mut proposer_factory =
@@ -1114,7 +1107,7 @@ mod tests {
let cell = Arc::new(Mutex::new((0, time::Instant::now())));
let cell2 = cell.clone();
let proposer = proposer_factory.init_with_now(
- &client.expect_header(client.info().genesis_hash).unwrap(),
+ &client.expect_header(genesis_hash).unwrap(),
Box::new(move || {
let mut value = cell.lock();
let (called, old) = *value;
diff --git a/substrate/client/consensus/manual-seal/src/lib.rs b/substrate/client/consensus/manual-seal/src/lib.rs
index 1e5db966e66..41cd5f3127e 100644
--- a/substrate/client/consensus/manual-seal/src/lib.rs
+++ b/substrate/client/consensus/manual-seal/src/lib.rs
@@ -351,7 +351,7 @@ mod tests {
use sc_transaction_pool::{BasicPool, FullChainApi, Options, RevalidationType};
use sc_transaction_pool_api::{MaintainedTransactionPool, TransactionPool, TransactionSource};
use sp_inherents::InherentData;
- use sp_runtime::generic::{BlockId, Digest, DigestItem};
+ use sp_runtime::generic::{Digest, DigestItem};
use substrate_test_runtime_client::{
AccountKeyring::*, DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt,
};
@@ -400,10 +400,11 @@ mod tests {
let client = Arc::new(client);
let spawner = sp_core::testing::TaskExecutor::new();
let genesis_hash = client.info().genesis_hash;
+ let pool_api = Arc::new(FullChainApi::new(client.clone(), None, &spawner.clone()));
let pool = Arc::new(BasicPool::with_revalidation_type(
Options::default(),
true.into(),
- api(),
+ pool_api,
None,
RevalidationType::Full,
spawner.clone(),
@@ -444,7 +445,7 @@ mod tests {
rt.block_on(future);
});
// submit a transaction to pool.
- let result = pool.submit_one(&BlockId::Number(0), SOURCE, uxt(Alice, 0)).await;
+ let result = pool.submit_one(genesis_hash, SOURCE, uxt(Alice, 0)).await;
// assert that it was successfully imported
assert!(result.is_ok());
// assert that the background task returns ok
@@ -475,10 +476,11 @@ mod tests {
let client = Arc::new(client);
let spawner = sp_core::testing::TaskExecutor::new();
let genesis_hash = client.info().genesis_hash;
+ let pool_api = Arc::new(FullChainApi::new(client.clone(), None, &spawner.clone()));
let pool = Arc::new(BasicPool::with_revalidation_type(
Options::default(),
true.into(),
- api(),
+ pool_api,
None,
RevalidationType::Full,
spawner.clone(),
@@ -535,7 +537,7 @@ mod tests {
let mut finality_stream = client.finality_notification_stream();
// submit a transaction to pool.
- let result = pool.submit_one(&BlockId::Number(0), SOURCE, uxt(Alice, 0)).await;
+ let result = pool.submit_one(genesis_hash, SOURCE, uxt(Alice, 0)).await;
// assert that it was successfully imported
assert!(result.is_ok());
// assert that the background task returns ok
@@ -571,10 +573,11 @@ mod tests {
let client = Arc::new(client);
let spawner = sp_core::testing::TaskExecutor::new();
let genesis_hash = client.info().genesis_hash;
+ let pool_api = Arc::new(FullChainApi::new(client.clone(), None, &spawner.clone()));
let pool = Arc::new(BasicPool::with_revalidation_type(
Options::default(),
true.into(),
- api(),
+ pool_api,
None,
RevalidationType::Full,
spawner.clone(),
@@ -602,7 +605,7 @@ mod tests {
rt.block_on(future);
});
// submit a transaction to pool.
- let result = pool.submit_one(&BlockId::Number(0), SOURCE, uxt(Alice, 0)).await;
+ let result = pool.submit_one(genesis_hash, SOURCE, uxt(Alice, 0)).await;
// assert that it was successfully imported
assert!(result.is_ok());
let (tx, rx) = futures::channel::oneshot::channel();
@@ -688,7 +691,7 @@ mod tests {
rt.block_on(future);
});
// submit a transaction to pool.
- let result = pool.submit_one(&BlockId::Number(0), SOURCE, uxt(Alice, 0)).await;
+ let result = pool.submit_one(genesis_hash, SOURCE, uxt(Alice, 0)).await;
// assert that it was successfully imported
assert!(result.is_ok());
@@ -719,7 +722,7 @@ mod tests {
}
);
- assert!(pool.submit_one(&BlockId::Number(1), SOURCE, uxt(Alice, 1)).await.is_ok());
+ assert!(pool.submit_one(created_block.hash, SOURCE, uxt(Alice, 1)).await.is_ok());
let header = client.header(created_block.hash).expect("db error").expect("imported above");
assert_eq!(header.number, 1);
@@ -741,7 +744,7 @@ mod tests {
.is_ok());
assert_matches::assert_matches!(rx1.await.expect("should be no error receiving"), Ok(_));
- assert!(pool.submit_one(&BlockId::Number(1), SOURCE, uxt(Bob, 0)).await.is_ok());
+ assert!(pool.submit_one(created_block.hash, SOURCE, uxt(Bob, 0)).await.is_ok());
let (tx2, rx2) = futures::channel::oneshot::channel();
assert!(sink
.send(EngineCommand::SealNewBlock {
diff --git a/substrate/client/rpc-spec-v2/src/transaction/transaction.rs b/substrate/client/rpc-spec-v2/src/transaction/transaction.rs
index 44f4bd36c8b..fe16310aeff 100644
--- a/substrate/client/rpc-spec-v2/src/transaction/transaction.rs
+++ b/substrate/client/rpc-spec-v2/src/transaction/transaction.rs
@@ -46,7 +46,7 @@ use std::sync::Arc;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_core::Bytes;
-use sp_runtime::{generic, traits::Block as BlockT};
+use sp_runtime::traits::Block as BlockT;
use codec::Decode;
use futures::{FutureExt, StreamExt, TryFutureExt};
@@ -110,11 +110,7 @@ where
let submit = self
.pool
- .submit_and_watch(
- &generic::BlockId::hash(best_block_hash),
- TX_SOURCE,
- decoded_extrinsic,
- )
+ .submit_and_watch(best_block_hash, TX_SOURCE, decoded_extrinsic)
.map_err(|e| {
e.into_pool_error()
.map(Error::from)
diff --git a/substrate/client/rpc/src/author/mod.rs b/substrate/client/rpc/src/author/mod.rs
index feee22641ef..55d0a504aa6 100644
--- a/substrate/client/rpc/src/author/mod.rs
+++ b/substrate/client/rpc/src/author/mod.rs
@@ -41,7 +41,7 @@ use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_core::Bytes;
use sp_keystore::{KeystoreExt, KeystorePtr};
-use sp_runtime::{generic, traits::Block as BlockT};
+use sp_runtime::traits::Block as BlockT;
use sp_session::SessionKeys;
use self::error::{Error, Result};
@@ -97,15 +97,12 @@ where
Err(err) => return Err(Error::Client(Box::new(err)).into()),
};
let best_block_hash = self.client.info().best_hash;
- self.pool
- .submit_one(&generic::BlockId::hash(best_block_hash), TX_SOURCE, xt)
- .await
- .map_err(|e| {
- e.into_pool_error()
- .map(|e| Error::Pool(e))
- .unwrap_or_else(|e| Error::Verification(Box::new(e)))
- .into()
- })
+ self.pool.submit_one(best_block_hash, TX_SOURCE, xt).await.map_err(|e| {
+ e.into_pool_error()
+ .map(|e| Error::Pool(e))
+ .unwrap_or_else(|e| Error::Verification(Box::new(e)))
+ .into()
+ })
}
fn insert_key(&self, key_type: String, suri: String, public: Bytes) -> RpcResult<()> {
@@ -191,14 +188,11 @@ where
},
};
- let submit = self
- .pool
- .submit_and_watch(&generic::BlockId::hash(best_block_hash), TX_SOURCE, dxt)
- .map_err(|e| {
- e.into_pool_error()
- .map(error::Error::from)
- .unwrap_or_else(|e| error::Error::Verification(Box::new(e)))
- });
+ let submit = self.pool.submit_and_watch(best_block_hash, TX_SOURCE, dxt).map_err(|e| {
+ e.into_pool_error()
+ .map(error::Error::from)
+ .unwrap_or_else(|e| error::Error::Verification(Box::new(e)))
+ });
let fut = async move {
let stream = match submit.await {
diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs
index cd720e1c1e0..ff9eb982b86 100644
--- a/substrate/client/service/src/lib.rs
+++ b/substrate/client/service/src/lib.rs
@@ -48,10 +48,7 @@ use sc_network_sync::SyncingService;
use sc_utils::mpsc::TracingUnboundedReceiver;
use sp_blockchain::HeaderMetadata;
use sp_consensus::SyncOracle;
-use sp_runtime::{
- generic::BlockId,
- traits::{Block as BlockT, Header as HeaderT},
-};
+use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
pub use self::{
builder::{
@@ -481,10 +478,8 @@ where
},
};
- let best_block_id = BlockId::hash(self.client.info().best_hash);
-
let import_future = self.pool.submit_one(
- &best_block_id,
+ self.client.info().best_hash,
sc_transaction_pool_api::TransactionSource::External,
uxt,
);
@@ -549,10 +544,9 @@ mod tests {
to: AccountKeyring::Bob.into(),
}
.into_unchecked_extrinsic();
- block_on(pool.submit_one(&BlockId::hash(best.hash()), source, transaction.clone()))
- .unwrap();
+ block_on(pool.submit_one(best.hash(), source, transaction.clone())).unwrap();
block_on(pool.submit_one(
- &BlockId::hash(best.hash()),
+ best.hash(),
source,
ExtrinsicBuilder::new_call_do_not_propagate().nonce(1).build(),
))
diff --git a/substrate/client/service/test/src/lib.rs b/substrate/client/service/test/src/lib.rs
index 38a811acc74..9700c7643c4 100644
--- a/substrate/client/service/test/src/lib.rs
+++ b/substrate/client/service/test/src/lib.rs
@@ -34,7 +34,6 @@ use sc_service::{
RuntimeGenesis, SpawnTaskHandle, TaskManager,
};
use sc_transaction_pool_api::TransactionPool;
-use sp_api::BlockId;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block as BlockT;
use std::{iter, net::Ipv4Addr, pin::Pin, sync::Arc, task::Context, time::Duration};
@@ -501,15 +500,13 @@ pub fn sync(
info!("Checking extrinsic propagation");
let first_service = network.full_nodes[0].1.clone();
let first_user_data = &network.full_nodes[0].2;
- let best_block = BlockId::number(first_service.client().info().best_number);
+ let best_block = first_service.client().info().best_hash;
let extrinsic = extrinsic_factory(&first_service, first_user_data);
let source = sc_transaction_pool_api::TransactionSource::External;
- futures::executor::block_on(first_service.transaction_pool().submit_one(
- &best_block,
- source,
- extrinsic,
- ))
+ futures::executor::block_on(
+ first_service.transaction_pool().submit_one(best_block, source, extrinsic),
+ )
.expect("failed to submit extrinsic");
network.run_until_all_full(|_index, service| service.transaction_pool().ready().count() == 1);
diff --git a/substrate/client/transaction-pool/api/src/lib.rs b/substrate/client/transaction-pool/api/src/lib.rs
index 73cc513708d..a795917528f 100644
--- a/substrate/client/transaction-pool/api/src/lib.rs
+++ b/substrate/client/transaction-pool/api/src/lib.rs
@@ -26,10 +26,7 @@ use codec::Codec;
use futures::{Future, Stream};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use sp_core::offchain::TransactionPoolExt;
-use sp_runtime::{
- generic::BlockId,
- traits::{Block as BlockT, Member, NumberFor},
-};
+use sp_runtime::traits::{Block as BlockT, Member, NumberFor};
use std::{collections::HashMap, hash::Hash, marker::PhantomData, pin::Pin, sync::Arc};
const LOG_TARGET: &str = "txpool::api";
@@ -202,7 +199,7 @@ pub trait TransactionPool: Send + Sync {
/// Returns a future that imports a bunch of unverified transactions to the pool.
fn submit_at(
&self,
- at: &BlockId,
+ at: ::Hash,
source: TransactionSource,
xts: Vec>,
) -> PoolFuture, Self::Error>>, Self::Error>;
@@ -210,7 +207,7 @@ pub trait TransactionPool: Send + Sync {
/// Returns a future that imports one unverified transaction to the pool.
fn submit_one(
&self,
- at: &BlockId,
+ at: ::Hash,
source: TransactionSource,
xt: TransactionFor,
) -> PoolFuture, Self::Error>;
@@ -219,7 +216,7 @@ pub trait TransactionPool: Send + Sync {
/// pool.
fn submit_and_watch(
&self,
- at: &BlockId,
+ at: ::Hash,
source: TransactionSource,
xt: TransactionFor,
) -> PoolFuture>>, Self::Error>;
diff --git a/substrate/client/transaction-pool/benches/basics.rs b/substrate/client/transaction-pool/benches/basics.rs
index d114acc343d..0caf00bf295 100644
--- a/substrate/client/transaction-pool/benches/basics.rs
+++ b/substrate/client/transaction-pool/benches/basics.rs
@@ -33,6 +33,7 @@ use sp_runtime::{
ValidTransaction,
},
};
+use std::sync::Arc;
use substrate_test_runtime::{AccountId, Block, Extrinsic, ExtrinsicBuilder, TransferData, H256};
#[derive(Clone, Debug, Default)]
@@ -61,7 +62,7 @@ impl ChainApi for TestApi {
fn validate_transaction(
&self,
- at: &BlockId,
+ at: ::Hash,
_source: TransactionSource,
uxt: ::Extrinsic,
) -> Self::ValidationFuture {
@@ -70,7 +71,7 @@ impl ChainApi for TestApi {
let nonce = transfer.nonce;
let from = transfer.from;
- match self.block_id_to_number(at) {
+ match self.block_id_to_number(&BlockId::Hash(at)) {
Ok(Some(num)) if num > 5 => return ready(Ok(Err(InvalidTransaction::Stale.into()))),
_ => {},
}
@@ -94,6 +95,8 @@ impl ChainApi for TestApi {
) -> Result