txpool: don't maintain the pool during major sync (#13004)

* txpool: don't maintain the pool during major sync

Fix shall prevent from wasting the CPU during the major sync. No actions
are actually required in transaction pool during the major sync.

Fixes: #12903

* passing sync_oracle to maintain method

* fixed: builder, txpool tests

* do not maintain tx-pool if node gone out of sync

* EnactmentAction: all logic moved to EnactmentState

Tests to be done.

* maintain guard logic moved directly to MaintainedTransactionPool

* minor fixes

* EnactmentAction: all logic moved to EnactmentState (again)

* SyncOracle fixes here and there

* Update client/transaction-pool/src/enactment_state.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update client/transaction-pool/src/enactment_state.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* sync_oracle removed

* spelling + fmt + doc

* Review suggestions applied

* log::info -> debug

* Update client/transaction-pool/src/enactment_state.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* ".git/.scripts/commands/fmt/fmt.sh"

Co-authored-by: parity-processbot <>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Michal Kucharczyk
2023-01-16 23:15:22 +01:00
committed by GitHub
parent 21141f5d4c
commit 5134dabb4a
4 changed files with 145 additions and 56 deletions
+10 -4
View File
@@ -33,7 +33,7 @@ mod tests;
pub use crate::api::FullChainApi;
use async_trait::async_trait;
use enactment_state::EnactmentState;
use enactment_state::{EnactmentAction, EnactmentState};
use futures::{
channel::oneshot,
future::{self, ready},
@@ -732,16 +732,22 @@ where
)),
}
};
let block_id_to_number =
|hash| self.api.block_id_to_number(&BlockId::Hash(hash)).map_err(|e| format!("{}", e));
let result = self.enactment_state.lock().update(&event, &compute_tree_route);
let result =
self.enactment_state
.lock()
.update(&event, &compute_tree_route, &block_id_to_number);
match result {
Err(msg) => {
log::debug!(target: "txpool", "{msg}");
self.enactment_state.lock().force_update(&event);
},
Ok(None) => {},
Ok(Some(tree_route)) => {
Ok(EnactmentAction::Skip) => return,
Ok(EnactmentAction::HandleFinalization) => {},
Ok(EnactmentAction::HandleEnactment(tree_route)) => {
self.handle_enactment(tree_route).await;
},
};