Skip to content

fix: re-fetch missing transaction info#134

Merged
MicBun merged 1 commit intomainfrom
fetchTransactionDataAll
Oct 29, 2025
Merged

fix: re-fetch missing transaction info#134
MicBun merged 1 commit intomainfrom
fetchTransactionDataAll

Conversation

@MicBun
Copy link
Copy Markdown
Member

@MicBun MicBun commented Oct 29, 2025

resolves: https://github.com/trufnetwork/trufscan/issues/99

Summary by CodeRabbit

  • Bug Fixes
    • Improved transaction fetching reliability through iterative retry logic with automatic missing block recovery.
    • Enhanced error handling with detailed warnings for fetch and parsing failures.
    • Optimized block-to-transaction mapping for improved data consistency.

@MicBun MicBun requested a review from outerlook October 29, 2025 08:37
@MicBun MicBun self-assigned this Oct 29, 2025
@holdex
Copy link
Copy Markdown

holdex bot commented Oct 29, 2025

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 6h 30min Update time Oct 29, 2025, 6:15 PM

@holdex
Copy link
Copy Markdown

holdex bot commented Oct 29, 2025

Bug Report Checklist

Status Commit Link Bug Author
❌ Not Submitted

@MicBun, please use git blame and specify the link to the commit link that has introduced this bug.

Send the following message in this PR: `@pr-time-tracker bug commit [link](url) && bug author @name`

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 29, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The PR refactors transaction fetching in getLastTransactions.ts by replacing a single bulk-range indexer query with an iterative multi-attempt strategy that includes missing-block tracking, per-iteration range calculations, descending-order queries, and enhanced error handling.

Changes

Cohort / File(s) Summary
Transaction Fetching Refactor
src/client/getLastTransactions.ts
Replaced single bulk-range query with iterative bulk-range strategy (up to three attempts); added missing-block tracking and per-iteration min/max range calculations; introduced descending-order queries; enhanced error handling with fetch/parse failure warnings; modified block-to-transaction map to only update when height entry is missing; added early-exit logic for no-progress scenarios

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Function as getLastTransactions()
    participant Indexer
    participant BlockMap as blockToTx Map
    
    Client->>Function: Request transactions
    Note over Function: Initialize missing blocks set
    
    loop Iterative fetches (max 3 attempts)
        Function->>Function: Calculate range<br/>(min/max from missing blocks)
        alt Blocks remaining
            Function->>Indexer: Query range (descending)
            alt Success
                Indexer-->>Function: Transactions batch
                Function->>Function: Parse results
                Note over Function: Track new missing blocks
            else Fetch/Parse Error
                Function->>Function: Log warning
            end
            
            alt Progress made
                Function->>BlockMap: Update entries<br/>(only if height missing)
            else No progress
                Function->>Function: Break early
            end
        else All blocks found
            Function->>Function: Exit loop
        end
    end
    
    Function->>BlockMap: Final mapping step
    Function-->>Client: Return transactions
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • Logic density: Iterative retry mechanism with state tracking across multiple attempts requires careful verification of loop conditions and early-exit logic
  • Error handling paths: Multiple failure points (fetch failures, parse errors) with warning logging need validation
  • Map update semantics: Changed logic for updating blockToTx only on missing entries requires verification against intended deduplication behavior
  • Range calculations: Per-iteration min/max recalculation based on missing blocks needs validation for correctness across iterations

Possibly related PRs

  • #133: Prior refactor that replaced per-block RPCs with single range query using indexer stamp_ms; this PR further enhances with iterative fetching and missing-block tracking

Suggested reviewers

  • outerlook

Poem

🐰 Hoppy fetch, fetch, fetch—no stone left unturned,
Missing blocks tracked as we learn and learn,
Iterative wisdom, with queries that dance,
Descending through ranges with each second chance,
Error-aware whispers keep watchers at ease,
Transaction retrieval, now aims to please! 🌿✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fetchTransactionDataAll

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cca416d and 7a3445e.

📒 Files selected for processing (1)
  • src/client/getLastTransactions.ts (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MicBun
Copy link
Copy Markdown
Member Author

MicBun commented Oct 29, 2025

merge immediately: needs to be implemented in trufscan

@MicBun MicBun merged commit 05730ab into main Oct 29, 2025
2 of 5 checks passed
@MicBun MicBun deleted the fetchTransactionDataAll branch October 29, 2025 08:38
@MicBun MicBun changed the title fix: re-fetch missing some transaction info fix: re-fetch missing transaction info Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant