Repository navigation
test(fork): hint the creation block, so the fork never searches the whole chain - #47
Merged
Merged
Conversation
…hole 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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
frontendphil
added a commit
that referenced
this pull request
Nov 27, 2026
test:fork:recovery and test:fork:recovery-alerts ran only by hand. With the block hints of #47 they take about 10 s each, so CI runs them after the other fork suites, on the same fork. All six passed in that order locally. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fork job takes about 2½ minutes on a good day. On #46,
test:forkalone took 5m25s.Why it was slow
I put a logging proxy between anvil and the Tenderly gateway. Most of the upstream time went to
eth_getLogsfrom block0x0:eth_getLogstest:forktest:fork:guardiantest:fork:deposittest:fork:alertsWithout a block hint,
inspect()reads the Roles modifier's logs from block 0. Anvil forwards the part before the fork block upstream, and the gateway then searches all of mainnet for an address that exists only on the fork. That takes 3–8s per new Chronobox, and much longer when the public gateway is slow.The change (tests only, no app code)
test/fork-hints.ts: aBlockHintsthat says "made after the current head". Each fork suite takes it before its snapshot and passes it to everyinspectcall that had no hint.verifyCancelPermission).fork.tsstill checks that path with its hint that is too late.madeAfter()answers the part before the fork for that one Roles modifier itself (no code, no logs), because the test made it on the fork. The app sends the same requests, and 9b now also asserts that it read from the remembered block and then from block0x0.chainId: 1on its hints, notget: () => null, so it uses the fork's hint.chainIdon the hint, so no passed history is cached between reads. Everyinspectstill verifies the full history.Result, locally, each suite from a cold fork, with no
eth_getLogsleft going upstream:test:fork65s → 16s, guardian 39s → 12s, deposit 22s → 10s, alerts 9s → 6s. That's 135s → 44s overall. The recovery suites (not in CI) pass too.🤖 Generated with Claude Code