From ca5ecb6266dff25b73cc76a58a3f055cdfe3886e Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Tue, 16 Jan 2024 19:12:34 +0200 Subject: [PATCH] backend: Extra debug Signed-off-by: Alexandru Vasile --- subxt/src/backend/unstable/mod.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/subxt/src/backend/unstable/mod.rs b/subxt/src/backend/unstable/mod.rs index 7a3a380dbd..b75fa2c015 100644 --- a/subxt/src/backend/unstable/mod.rs +++ b/subxt/src/backend/unstable/mod.rs @@ -477,12 +477,18 @@ impl Backend for UnstableBackend { let mut iter_num = 0; let now = std::time::Instant::now(); + let mut tx_logs = Vec::with_capacity(32); + let mut chainhead_logs = Vec::with_capacity(32); + // Now we can attempt to associate tx events with pinned blocks. let tx_stream = futures::stream::poll_fn(move |cx| { loop { iter_num += 1; if now.elapsed().as_secs() > 120 { - panic!("iter={:#?}", iter_num); + panic!( + "iter_num: {}, tx_logs: {:#?}, chainhead_logs: {:#?}", + iter_num, tx_logs, chainhead_logs + ); } // Bail early if no more tx events; we don't want to keep polling for pinned blocks. @@ -494,6 +500,8 @@ impl Backend for UnstableBackend { if let Poll::Ready(Some(seen_block)) = seen_blocks_sub.poll_next_unpin(cx) { match seen_block { SeenBlock::New(block_ref) => { + chainhead_logs.push((now.elapsed().as_secs(), "new", block_ref.hash())); + // Optimization: once we have a `finalized_hash`, we only care about finalized // block refs now and can avoid bothering to save new blocks. if finalized_hash.is_none() { @@ -503,6 +511,12 @@ impl Backend for UnstableBackend { } SeenBlock::Finalized(block_refs) => { for block_ref in block_refs { + chainhead_logs.push(( + now.elapsed().as_secs(), + "finalized", + block_ref.hash(), + )); + seen_blocks.insert( block_ref.hash(), (SeenBlockMarker::Finalized, block_ref), @@ -543,6 +557,8 @@ impl Backend for UnstableBackend { Poll::Ready(Some(Ok(ev))) => ev, }; + tx_logs.push((now.elapsed().as_secs(), ev.clone())); + // When we get one, map it to the correct format (or for finalized ev, wait for the pinned block): let ev = match ev { rpc_methods::TransactionStatus::Finalized { block } => {