Skip to content

Commit

Permalink
tracing_log_xt improvements, log_xt removed from fork-aware-txpool
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkucharczyk committed Jan 29, 2025
1 parent 2102068 commit f617182
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions substrate/client/transaction-pool/src/common/tracing_log_xt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ macro_rules! log_xt {
tracing::event!(
$level,
target = $target,
message = $text_with_format,
tx_hash = format!("{:?}", tx)
tx_hash = format!("{:?}", tx),
$text_with_format,
);
}
};
Expand All @@ -30,8 +30,8 @@ macro_rules! log_xt {
tracing::event!(
$level,
target = $target,
message = $text_with_format,
tx_hash = format!("{:?}", tx),
$text_with_format,
$($arg),*
);
}
Expand All @@ -41,9 +41,9 @@ macro_rules! log_xt {
tracing::event!(
$level,
target = $target,
message = $text_with_format,
tx_hash = format!("{:?}", tx.0),
some_value = format!("{:?}", tx.1)
$text_with_format,
tx.1
);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ where
log_xt_trace!(
target: LOG_TARGET,
xts.clone(),
"[{:?}] dropped_watcher: finalized xt removed"
"dropped_watcher: finalized xt removed"
);
xts.iter().for_each(|xt| {
self.ready_transaction_views.remove(xt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ where
views = self.active_views_count(),
"fatp::submit_at"
);
log_xt_trace!(target: LOG_TARGET, xts.iter().map(|xt| self.tx_hash(xt)), "[{:?}] fatp::submit_at");
log_xt_trace!(target: LOG_TARGET, xts.iter().map(|xt| self.tx_hash(xt)), "fatp::submit_at");
let xts = xts.into_iter().map(Arc::from).collect::<Vec<_>>();
let mempool_results = self.mempool.extend_unwatched(source, &xts);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ where
count = finalized_xts.len(),
"purge_finalized_transactions"
);
log_xt_trace!(target: LOG_TARGET, finalized_xts, "[{:?}] purged finalized transactions");
log_xt_trace!(target: LOG_TARGET, finalized_xts, "purged finalized transactions");
let mut transactions = self.transactions.write();
finalized_xts.iter().for_each(|t| {
transactions.remove(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use super::metrics::MetricsLink as PrometheusMetrics;
use crate::{
common::log_xt::log_xt_trace,
common::tracing_log_xt::log_xt_trace,
graph::{
self, base_pool::TimedTransactionSource, watcher::Watcher, ExtrinsicFor, ExtrinsicHash,
IsValidator, ValidatedPoolSubmitOutcome, ValidatedTransaction, ValidatedTransactionFor,
Expand Down Expand Up @@ -161,7 +161,7 @@ where
) -> Vec<Result<ValidatedPoolSubmitOutcome<ChainApi>, ChainApi::Error>> {
if tracing::enabled!(target: LOG_TARGET, tracing::Level::TRACE) {
let xts = xts.into_iter().collect::<Vec<_>>();
log_xt_trace!(target: LOG_TARGET, xts.iter().map(|(_,xt)| self.pool.validated_pool().api().hash_and_length(xt).0), "[{:?}] view::submit_many at:{}", self.at.hash);
log_xt_trace!(target: LOG_TARGET, xts.iter().map(|(_,xt)| self.pool.validated_pool().api().hash_and_length(xt).0), "view::submit_many at:{}", self.at.hash);
self.pool.submit_at(&self.at, xts).await
} else {
self.pool.submit_at(&self.at, xts).await
Expand Down Expand Up @@ -327,7 +327,7 @@ where
took = ?revalidation_duration,
"view::revalidate"
);
log_xt_trace!(data:tuple, target:LOG_TARGET, validation_results.iter().map(|x| (x.1, &x.0)), "[{:?}] view::revalidateresult: {:?}");
log_xt_trace!(data:tuple, target:LOG_TARGET, validation_results.iter().map(|x| (x.1, &x.0)), "view::revalidate result: {:?}");

for (validation_result, tx_hash, tx) in validation_results {
match validation_result {
Expand Down
4 changes: 2 additions & 2 deletions substrate/client/transaction-pool/src/graph/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use sp_runtime::transaction_validity::TransactionTag as Tag;
use std::time::Instant;

use super::base_pool::Transaction;
use crate::{common::log_xt::log_xt_trace, LOG_TARGET};
use crate::{common::tracing_log_xt::log_xt_trace, LOG_TARGET};

/// Transaction with partially satisfied dependencies.
pub struct WaitingTransaction<Hash, Ex> {
Expand Down Expand Up @@ -184,7 +184,7 @@ impl<Hash: hash::Hash + Eq + Clone + std::fmt::Debug, Ex: std::fmt::Debug>
})
.collect::<Vec<_>>();

log_xt_trace!(target: LOG_TARGET, &pruned, "[{:?}] FutureTransactions: removed while pruning tags.");
log_xt_trace!(target: LOG_TARGET, &pruned, "FutureTransactions: removed while pruning tags.");
self.remove(&pruned)
}

Expand Down
4 changes: 2 additions & 2 deletions substrate/client/transaction-pool/src/graph/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::{common::log_xt::log_xt_trace, LOG_TARGET};
use crate::{common::tracing_log_xt::log_xt_trace, LOG_TARGET};
use futures::{channel::mpsc::Receiver, Future};
use indexmap::IndexMap;
use sc_transaction_pool_api::error;
Expand Down Expand Up @@ -395,7 +395,7 @@ impl<B: ChainApi> Pool<B> {

let pruned_hashes = reverified_transactions.keys().map(Clone::clone).collect::<Vec<_>>();
log::debug!(target: LOG_TARGET, "Pruning at {:?}. Resubmitting transactions: {}, reverification took: {:?}", &at, reverified_transactions.len(), now.elapsed());
log_xt_trace!(data: tuple, target: LOG_TARGET, &reverified_transactions, "[{:?}] Resubmitting transaction: {:?}");
log_xt_trace!(data: tuple, target: LOG_TARGET, &reverified_transactions, "Resubmitting transaction: {:?}");

// And finally - submit reverified transactions back to the pool
self.validated_pool.resubmit_pruned(
Expand Down
4 changes: 2 additions & 2 deletions substrate/client/transaction-pool/src/graph/validated_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::{
sync::Arc,
};

use crate::{common::log_xt::log_xt_trace, LOG_TARGET};
use crate::{common::tracing_log_xt::log_xt_trace, LOG_TARGET};
use futures::channel::mpsc::{channel, Sender};
use parking_lot::{Mutex, RwLock};
use sc_transaction_pool_api::{error, PoolStatus, ReadyTransactions, TransactionPriority};
Expand Down Expand Up @@ -706,7 +706,7 @@ impl<B: ChainApi> ValidatedPool<B> {
let invalid = self.pool.write().remove_subtree(hashes);

log::trace!(target: LOG_TARGET, "Removed invalid transactions: {:?}", invalid.len());
log_xt_trace!(target: LOG_TARGET, invalid.iter().map(|t| t.hash), "{:?} Removed invalid transaction");
log_xt_trace!(target: LOG_TARGET, invalid.iter().map(|t| t.hash), "Removed invalid transaction");

let mut listener = self.listener.write();
for tx in &invalid {
Expand Down

0 comments on commit f617182

Please sign in to comment.