refactor: optimize event timestamp fetching and enhance escrow transf… - #161
refactor: optimize event timestamp fetching and enhance escrow transf…#161manishdex25 wants to merge 4 commits into
Conversation
|
Warning Review limit reached
Next review available in: 4 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughV5 escrow transfer retrieval now uses adaptive backward log scanning. RPC operations retry transient failures with bounded backoff. Timestamp lookups use cached block results and up to five concurrent workers. ChangesEndorsement-chain retrieval resilience
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant fetchEscrowTransfersV5
participant fetchAllTransfers
participant scanLogsBackward
participant provider
fetchEscrowTransfersV5->>fetchAllTransfers: pass provider
fetchAllTransfers->>provider: resolve escrow address and current block
fetchAllTransfers->>scanLogsBackward: scan escrow address for TokenReceived logs
scanLogsBackward->>provider: request adaptive descending block windows
scanLogsBackward-->>fetchAllTransfers: return ascending logs
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/core/endorsement-chain/fetchLogsChunked.ts`:
- Around line 48-106: Reduce cognitive complexity in scanLogsBackward by
extracting the provider.getLogs request/retry handling and successful-window
chunk-size adaptation into focused helpers. Preserve the existing
range-too-large behavior, transient-error retry limits and delays, empty-chunk
growth logic, and latest-first chunk ordering; keep scanLogsBackward responsible
for traversal and termination.
- Around line 72-75: In the range-too-large handling of fetchLogsChunked, reduce
maxChunkSize to a materially smaller bound based on the rejected chunk instead
of chunkSize - 1, while preserving the MIN_CHUNK_SIZE floor and existing
chunkSize reduction. Add a test covering a provider that rejects ranges above a
fixed limit and verify subsequent requests stay below that limit without
repeated near-size failures.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d5d0cb5e-8ba1-4ddb-8f15-67a2d63cfbe9
📒 Files selected for processing (4)
src/core/endorsement-chain/fetchEscrowTransfer.tssrc/core/endorsement-chain/fetchLogsChunked.tssrc/core/endorsement-chain/retrieveEndorsementChain.tssrc/core/endorsement-chain/useEndorsementChain.ts
…nd chunk size adjustments
|



…er handling
Summary
What is the background of this pull request?
Changes
Issues
What are the related issues or stories?
Summary by CodeRabbit
Performance
Reliability
Bug Fixes