Skip to content

fix: reduce load on RPC nodes#7523

Merged
shoom3301 merged 1 commit into
release/18-05-2026from
fix/rpc-node-consumption
May 19, 2026
Merged

fix: reduce load on RPC nodes#7523
shoom3301 merged 1 commit into
release/18-05-2026from
fix/rpc-node-consumption

Conversation

@shoom3301
Copy link
Copy Markdown
Collaborator

@shoom3301 shoom3301 commented May 18, 2026

Summary

Fix A — apps/cowswap-frontend/.../usePendingTransactionsContext.ts + FinalizeTxUpdater/index.tsx:
Hook now takes hasPendingTxs: boolean; when no pending txs exist, it returns null without calling getTransactionCount. FinalizeTxUpdater passes transactions.length > 0. Behavior unchanged for users with pending txs; eliminates the nonce call for every connected user every block.

Fix B + C — libs/wallet/src/wagmi/config.ts:
Added a single VIEM_CLIENT_TUNING constant spread into both the Safe-iframe createConfig and the WagmiAdapter constructor:

  • batch.multicall: { wait: 130, batchSize: 30_000 } — auto-aggregates singular useReadContract calls into multicall3
  • pollingInterval: 12_000 — overrides viem's 4 s default

I've checked the version before Viem migration, and we were making eth_call with ~24kb payload. Alchemy recommends keeping the payload less then 100kb, so 30kb looks a good trade-off here.

Expected impact

  • eth_blockNumber: ~3× reduction (4 s → 12 s polling)
  • eth_getTransactionCount: ~10–20× reduction (gated on pending txs; most users have none)
  • eth_call: ~5–10× reduction (singular useReadContract calls now batched). Won't reach the full 20× without also addressing D (overlapping balance/allowance pollers).

To Test

  1. Balances loading
  2. On-chain tx finalizing: mined/failed/replaced (approve, wrap/uwrap, eth-flow)

Summary by CodeRabbit

  • Performance
    • Optimized pending transaction detection logic for improved efficiency.
    • Enhanced wallet configuration with improved multicall batching and polling intervals for better network communication.

Review Change Stack

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying swap-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: aaac8e3
Status: ✅  Deploy successful!
Preview URL: https://c54cccd9.swap-dev-5u6.pages.dev
Branch Preview URL: https://fix-rpc-node-consumption.swap-dev-5u6.pages.dev

View logs

@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer-dev Ready Ready Preview May 18, 2026 2:42pm
sdk-tools Ready Ready Preview May 18, 2026 2:42pm
storybook Ready Ready Preview May 18, 2026 2:42pm
swap-dev Ready Ready Preview May 18, 2026 2:42pm
widget-configurator Ready Ready Preview May 18, 2026 2:42pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
cosmos Ignored Ignored May 18, 2026 2:42pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 71c12cda-f5bc-4661-8620-4020089277e7

📥 Commits

Reviewing files that changed from the base of the PR and between 6a26349 and aaac8e3.

📒 Files selected for processing (3)
  • apps/cowswap-frontend/src/modules/onchainTransactions/updaters/FinalizeTxUpdater/hooks/usePendingTransactionsContext.ts
  • apps/cowswap-frontend/src/modules/onchainTransactions/updaters/FinalizeTxUpdater/index.tsx
  • libs/wallet/src/wagmi/config.ts

Walkthrough

This PR introduces conditional optimization for pending transaction context evaluation and configures viem client batching behavior. The pending transactions hook now skips processing when no transactions are pending, and wallet configuration now includes explicit tuning for multicall batching and polling intervals across both Safe and standard configurations.

Changes

Transaction Finalization and Configuration

Layer / File(s) Summary
Pending transaction context optimization
apps/cowswap-frontend/src/modules/onchainTransactions/updaters/FinalizeTxUpdater/hooks/usePendingTransactionsContext.ts, apps/cowswap-frontend/src/modules/onchainTransactions/updaters/FinalizeTxUpdater/index.tsx
Hook signature updated to accept hasPendingTxs: boolean; early return logic now checks this flag to skip async computation when no transactions exist; dependency array updated; call site passes transactions.length > 0.
Viem client tuning configuration
libs/wallet/src/wagmi/config.ts
VIEM_CLIENT_TUNING object added to configure multicall batching parameters (batch.multicall.multicall.wait, batchSize) and polling interval; applied to both Safe-iframe and standard wallet configuration paths; SUPPORTED_REOWN_NETWORKS type cast removed in Safe path.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 A rabbit hops through transactions with newfound grace,
Skipping empty lists at a brisk pace,
While viem's batches align to their tune,
Polling steady beneath the blockchain moon!
Configuration harmonized, efficiency blooms—
The transaction gardens fill waiting rooms. 🌙✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: reduce load on RPC nodes' directly and concisely summarizes the main objective of the changeset, which involves reducing RPC calls through three targeted optimizations.
Description check ✅ Passed The description covers all required template sections: Summary with detailed explanations of changes, testing steps, and background context on performance impact.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rpc-node-consumption

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.

@shoom3301 shoom3301 self-assigned this May 18, 2026
@shoom3301 shoom3301 requested review from a team, Danziger and alfetopito May 18, 2026 14:43
@shoom3301 shoom3301 added the RELEASE Included in the release that is being closed label May 18, 2026
@limitofzero
Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on all chains except ink where I was not able to get a qupte: works fine with Rabby and MM+WC.
As for Safe, was not able to fully test it because of the known issue, so txs are not finalized. But balances were updated there (tested on Base)

@shoom3301 shoom3301 merged commit b841b2c into release/18-05-2026 May 19, 2026
19 of 20 checks passed
@shoom3301 shoom3301 deleted the fix/rpc-node-consumption branch May 19, 2026 08:35
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

RELEASE Included in the release that is being closed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants