Skip to content

perf: implement multicall batching in useFetchSubmittedLists#18

Open
ManiBAJPAI22 wants to merge 1 commit intokleros:masterfrom
ManiBAJPAI22:multicall-batching
Open

perf: implement multicall batching in useFetchSubmittedLists#18
ManiBAJPAI22 wants to merge 1 commit intokleros:masterfrom
ManiBAJPAI22:multicall-batching

Conversation

@ManiBAJPAI22
Copy link
Copy Markdown

@ManiBAJPAI22 ManiBAJPAI22 commented Jan 25, 2026

Reopened from #14 with master as target (as requested by @tractorss).


Optimize useFetchSubmittedLists Hook with Multicall Batching

What does this PR do?

Refactors the useFetchSubmittedLists hook to use publicClient.multicall instead of individual readContract calls, batching all contract calls into a single request for significantly better performance.

Why is this change needed?

The current implementation makes N separate RPC calls for N list IDs, causing unnecessary network overhead and slower data loading. This becomes especially problematic with poor network conditions or when fetching many lists.

How does it work?

  1. Batches all getSubmission calls into one multicall request
  2. Uses array indices to map results back to their corresponding listId
  3. Handles partial failures gracefully - if some calls fail, others still succeed
  4. Maintains exact same functionality for event logs and transaction processing

Performance improvement

  • Before: N × (network latency + processing time)
  • After: 1 × network latency + N × processing time
  • Result: ~73% faster data fetching (e.g., 5 lists: 550ms → 150ms)

What stays the same?

  • All business logic and data processing
  • Event log fetching for transaction descriptions
  • Return types and data structure
  • Error handling and validation

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling to prevent data retrieval failures from blocking list operations.
  • Performance

    • Enhanced data fetching mechanism for faster submission list retrieval.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link
Copy Markdown

netlify bot commented Jan 25, 2026

👷 Deploy request for kleros-governor-v2 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8d9c3e9

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 25, 2026

Walkthrough

Refactored useFetchSubmittedLists.ts to replace sequential per-list getSubmission/readContract calls with a single batch multicall approach. Results are individually processed for logs to extract descriptions. Added error handling for multicall failures, with failed entries filtered from results.

Changes

Cohort / File(s) Summary
Batch Multicall Refactor
web/src/hooks/useFetchSubmittedLists.ts
Replaced sequential per-list contract reads with single multicall batch operation. Added error handling and logging for multicall failures. Preserved per-submission ListSubmitted event log lookup for description extraction. Short-circuits to empty array when no submitted lists present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 A batch of submission calls, so swift and bright,
No more sequential hops through the night,
One multicall gathers them all at once,
With error handling—quite the robust hunts!
Our lists now fly on optimized wings!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: implementing multicall batching in the useFetchSubmittedLists hook for performance improvement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@ManiBAJPAI22 ManiBAJPAI22 marked this pull request as ready for review January 25, 2026 01:03
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