Skip to content

perf(watcher): reuse the poll's chain data and proxy cache in every vault read - #49

Merged
frontendphil merged 1 commit into
mainfrom
share-poll-chain-data
Nov 27, 2026
Merged

frontendphil merged 1 commit into
mainfrom
share-poll-chain-data

Conversation

@frontendphil

Copy link
Copy Markdown
Contributor

The counter from #46 shows 86 RPC requests a minute in production: 24 for the network searches and 62 for re-reading 3 vaults (16 per read on Ethereum, 23 on Gnosis). This is the quick win from that analysis.

What changes

  • One head per poll. The search already reads eth_chainId, eth_blockNumber and the head block. It now hands them to the vault reads, which no longer ask again. That's 3 requests less per vault read.
  • A proxy cache that lasts. proxyKinds (is this address a Delay or Roles proxy?) moves to the AllWatcher and is kept across reads and polls, so the eth_getCode calls for known modules happen once. Proxy code never changes. Addresses that are not a proxy yet (for example a Recovery Delay that wasn't deployed) are still never cached.
  • Never back to an older block. If a bot or email question read a vault at a later block during the poll, that vault's read fetches the head itself.

Trade-off: all vault reads in a poll use the head from the start of the poll, at most about 60s old (POLL_BUDGET_SECONDS). Every read is still pinned to one block, so it stays consistent, and the next poll covers everything after that block.

Expected effect: vault reads should drop from 16/23 to about 11–13/18–20 requests. The rpc: log line will show the real numbers in the first polls after deploy.

Tests: 92 watcher tests pass, tsc and the build are clean.

  • The service test checks that a poll that reads a vault sends eth_chainId and eth_blockNumber once each.
  • A new watcher test checks that a read given the poll's head asks nothing about the chain, and that a read given a head older than its last read fetches the head and saves the newer block. With the guard removed, that test fails.

🤖 Generated with Claude Code

…ault read

Each vault read asked the RPC again for the chain id, the head block and
its timestamp, which the search of the poll had just read, and started
with an empty cache of the Delay and Roles proxies. In production that
was 3 to 5 of the 16 to 23 requests of each read, every minute.

- The search hands its chain id, head and head timestamp to the reads of
  the vaults: one head for the whole poll.
- The proxy cache belongs to the network watcher and lives across reads
  and polls. Proxy code does not change; "other" is still never cached.
- A vault that a question of the bot read at a later block than the
  poll's head reads the head itself, so its state never goes back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
chronobox Ready Ready Preview Nov 27, 2026 12:15pm UTC
chronobox-watcher Ready Ready Preview Nov 27, 2026 12:15pm UTC

Request Review

@frontendphil
frontendphil merged commit f01474f into main Nov 27, 2026
7 checks passed
@frontendphil
frontendphil deleted the share-poll-chain-data branch November 27, 2026 12:17
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