Skip to content

feat(watcher): count the RPC requests of each poll - #46

Merged
frontendphil merged 1 commit into
mainfrom
rpc-call-counter
Nov 27, 2026
Merged

frontendphil merged 1 commit into
mainfrom
rpc-call-counter

Conversation

@frontendphil

Copy link
Copy Markdown
Contributor

The RPC load has grown with the first test users. Before changing how the watcher polls, this measures where the requests go.

What it does

  • Rpc can count its requests by method. Every try counts, including a failed one that falls back to the next endpoint, since each try is a request the provider sees.
  • Each --all poll counts the search (network scan and checks of new Delays) apart from the vault reads, and logs one line:
    rpc: 23 requests (search 5, 1 Chronobox read 18): eth_call 12, eth_getLogs 3, eth_blockNumber 2, …
  • The poll result, and so the last-poll note in Redis, carries rpc: { scan, vaults, read } per network. /api/health is public and unchanged.
  • The search uses its own probe for each poll, so a bot question that reads a vault at the same time does not end up in the poll's numbers. Bot and email reads are not counted yet.

What to look for after deploy: whether vaults grows with the number of vaults that have something waiting (the suspected cause: each one is re-read in full every minute, about 30 requests per read with a guardian).

Tests: a new service test checks that scan + vaults matches exactly the requests the mock RPC received, and that the log line matches. All 91 watcher tests pass, and tsc and the build are clean.

🤖 Generated with Claude Code

@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 11:59am UTC
chronobox-watcher Ready Ready Preview Nov 27, 2026 11:59am UTC

Request Review

frontendphil added a commit that referenced this pull request Nov 27, 2026
…hole chain (#47)

* test(fork): hint the creation block, so the fork never searches the whole chain

Without a block hint, inspect() reads the logs of a Roles modifier from
block 0. On a fork, anvil forwards the part before the fork block to the
forked RPC, which then searches the whole of mainnet for an address that
exists only on the fork: 3 to 8 seconds for each new Chronobox, and much
more when the public gateway is slow (test:fork took 5m25s on #46).

The fork tests now pass a hint: everything they make comes after the head
at their start. A wrong hint cannot hide a history (the app reads again
from block 0 when the start is missing), and fork.ts still checks that
fallback with a hint that is too late.

Locally, from a cold fork: test:fork 65s -> 18s, guardian 39s -> 12s,
deposit 22s -> 10s, alerts 9s -> 6s.

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

* test(fork): answer the pre-fork part of the block-0 reads locally

The two pauses in test:fork were the reads from block 0 that stayed on
purpose:

- 9b: without logs, the app searches the deploy block with eth_getCode
  at old blocks (21 upstream requests), and a hint that is too late makes
  it read the history again from block 0 (one whole-chain search).
- 10a: its hints returned null, though the step only needs a chainId.

10a now uses the fork's hint. 9b reads through madeAfter(): for the Roles
modifier that the test made on the fork, it answers the part before the
fork itself (no code, no logs) instead of anvil asking the forked RPC.
The app sends the same requests, and 9b now also checks that the history
was read from the remembered block and then from block 0.

test:fork from a cold fork: 18s -> 16s, and no eth_getLogs goes upstream.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Each poll logs one line with its requests to the RPC, split into the
search (scan and new Delays) and the reads of the vaults, by method:

  rpc: 23 requests (search 5, 1 Chronobox read 18): eth_call 12, ...

The poll result (and the last-poll note in Redis) carries the totals as
`rpc: { scan, vaults, read }`. /api/health is unchanged.

This measures where the RPC load comes from before we reduce it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frontendphil
frontendphil merged commit ab482a2 into main Nov 27, 2026
7 checks passed
@frontendphil
frontendphil deleted the rpc-call-counter branch November 27, 2026 12:01
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