diff --git a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs index 8cdb4406ed7..4c58165dfe6 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v1/mod.rs @@ -49,6 +49,16 @@ where .withdrawal_transactions_per_block_limit, "No queued withdrawal documents found to pool into transactions" ); + // Reading every withdrawal document the chain ever produced, only to + // count them for a log line. Withdrawal documents are never removed, + // so this grows without bound with chain history — measured at 4.8 ms + // a block by height 200,000 on mainnet, and it ran on every block + // that had nothing queued, which is nearly all of them. Do it only + // when the line it feeds will actually be emitted. + if !tracing::enabled!(tracing::Level::DEBUG) { + return Ok(()); + } + let all_documents = self .drive .fetch_oldest_withdrawal_documents(transaction, platform_version)?; @@ -57,7 +67,7 @@ where height = block_info.height, "No withdrawal documents found at all" ); - } else if tracing::enabled!(tracing::Level::DEBUG) { + } else { // Count documents by status let queued_count = all_documents .get(&(withdrawals_contract::WithdrawalStatus::QUEUED as u8))