mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 04:11:07 +00:00
Revalidate transactions only on latest best block (#6824)
* Revalidate transactions only on latest best block We should revalidate transactions only on the latest best block and not on any arbitrary block. The revalidation before failed when there were multiple blocks on the height given to the revalidation function, but no block was imported as best block. * Update test-utils/runtime/transaction-pool/src/lib.rs Co-authored-by: Jaco Greeff <jacogr@gmail.com> * Fix tests * Only process best blocks in the transaction pool Co-authored-by: Jaco Greeff <jacogr@gmail.com>
This commit is contained in:
@@ -211,8 +211,7 @@ impl<Api: ChainApi> RevalidationWorker<Api> {
|
||||
mut self,
|
||||
from_queue: TracingUnboundedReceiver<WorkerPayload<Api>>,
|
||||
interval: R,
|
||||
) where R: Send, R::Guard: Send
|
||||
{
|
||||
) where R: Send, R::Guard: Send {
|
||||
let interval = interval.into_stream().fuse();
|
||||
let from_queue = from_queue.fuse();
|
||||
futures::pin_mut!(interval, from_queue);
|
||||
@@ -253,7 +252,7 @@ impl<Api: ChainApi> RevalidationWorker<Api> {
|
||||
if this.members.len() > 0 {
|
||||
log::debug!(
|
||||
target: "txpool",
|
||||
"Updated revalidation queue at {}. Transactions: {:?}",
|
||||
"Updated revalidation queue at {:?}. Transactions: {:?}",
|
||||
this.best_block,
|
||||
this.members,
|
||||
);
|
||||
@@ -298,9 +297,7 @@ where
|
||||
api: Arc<Api>,
|
||||
pool: Arc<Pool<Api>>,
|
||||
interval: R,
|
||||
) -> (Self, Pin<Box<dyn Future<Output=()> + Send>>)
|
||||
where R: Send + 'static, R::Guard: Send
|
||||
{
|
||||
) -> (Self, Pin<Box<dyn Future<Output=()> + Send>>) where R: Send + 'static, R::Guard: Send {
|
||||
let (to_worker, from_queue) = tracing_unbounded("mpsc_revalidation_queue");
|
||||
|
||||
let worker = RevalidationWorker::new(api.clone(), pool.clone());
|
||||
@@ -338,16 +335,22 @@ where
|
||||
/// If queue configured with background worker, this will return immediately.
|
||||
/// If queue configured without background worker, this will resolve after
|
||||
/// revalidation is actually done.
|
||||
pub async fn revalidate_later(&self, at: NumberFor<Api>, transactions: Vec<ExtrinsicHash<Api>>) {
|
||||
pub async fn revalidate_later(
|
||||
&self,
|
||||
at: NumberFor<Api>,
|
||||
transactions: Vec<ExtrinsicHash<Api>>,
|
||||
) {
|
||||
if transactions.len() > 0 {
|
||||
log::debug!(target: "txpool", "Sent {} transactions to revalidation queue", transactions.len());
|
||||
log::debug!(
|
||||
target: "txpool", "Sent {} transactions to revalidation queue",
|
||||
transactions.len(),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(ref to_worker) = self.background {
|
||||
if let Err(e) = to_worker.unbounded_send(WorkerPayload { at, transactions }) {
|
||||
log::warn!(target: "txpool", "Failed to update background worker: {:?}", e);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
let pool = self.pool.clone();
|
||||
let api = self.api.clone();
|
||||
|
||||
Reference in New Issue
Block a user