Skip to content

perf: read the game and finalized state early in getWithdrawalStatus - #5530

Closed
jxom wants to merge 2 commits into
mainfrom
perf/op-stack-withdrawal-status-concurrency
Closed

jxom wants to merge 2 commits into
mainfrom
perf/op-stack-withdrawal-status-concurrency

Conversation

@jxom

@jxom jxom commented Nov 16, 2026

Copy link
Copy Markdown
Member

On Portal v3+, getWithdrawalStatus looked up the proof submitter (numProofSubmitters, then proofSubmitters) before it started the dispute game lookup and finalizedWithdrawals, although neither depends on the proof submitter. They now start right after the portal version.

Effect

Real in-process node:http JSON-RPC server adding 50 ms per request, canned Portal v3 responses, real Viem client over http(url).

main this PR
getWithdrawalStatus (Portal v3+) 360 ms, 11 requests, depth 7 258 ms, 11 requests, depth 5

Behavior

  • The game lookup and finalizedWithdrawals are still read through Promise.allSettled, and the results are checked in the same order, so the returned status and thrown errors are unchanged. Both promises have .catch(() => {}) attached when they are created.
  • Portal < v3 is unchanged.

Tests

  • New test: a createRpcProxy server answers every contract read (including the aggregate3 multicall for l2SequenceNumber) after 20 ms and records each read's depth. The snapshot shows depth 5; on main it is 7, so the test fails there.
  • The op-stack tests are excluded from every Vitest project in test/vitest.config.ts, so this test does not run in CI. I ran the file locally with the exclusion removed: the new test passes, and 5 fork-based tests (ready-to-finalize, ready-to-prove (U16), waiting-to-finalize, waiting-to-finalize (U16), waiting-to-prove (U16)) fail the same way on main.

On Portal v3+, getWithdrawalStatus looked up the proof submitter before
starting the dispute game lookup and the finalizedWithdrawals read,
although neither depends on it. They now start right after the portal
version, and their results are still read through Promise.allSettled in
the same order, so the returned status and errors are unchanged.

Co-authored-by: jxom <[email protected]>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1e1b3-ba60-755b-bfd0-1a31a4a5bf1e
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
viem Error Error Nov 16, 2026 1:15am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 94e8d19

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T01:12:50.548264Z 94e8d19 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3dc3e7618e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

})

expect(status).toMatchInlineSnapshot(`"ready-to-finalize"`)
expect(rounds.map((names) => names.sort())).toMatchInlineSnapshot(`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Assert concurrency behavior without snapshotting call tracking

The new assertion snapshots which RPC functions ran in each recorded round, contrary to the repository's explicit requirement to test observable outputs rather than function invocation tracking. It also couples the test to the exact internal read sequence, so harmless batching or lookup changes can fail it without regressing concurrency. Rework the ephemeral server to gate responses on concurrent progress and assert the resulting withdrawal status instead of snapshotting the invocation trace.

AGENTS.md reference: AGENTS.md:L204-L208

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Keeping this. Recording which requests overlap through a real http transport is how the concurrency rule for these changes is enforced (same approach as the landed #5505 tests). The result alone can't tell a concurrent implementation from a sequential one, since both return the same value. The snapshot records rounds of requests, not hook invocations, so it fails exactly when a waterfall comes back.

http,
pad,
toFunctionSelector,
} from '../../index.js'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Import the new public test APIs through package entrypoints

The newly added public API imports come from ../../index.js, bypassing the package-entrypoint coverage required by the repository's testing conventions. Import these helpers and types from viem instead; the rule explicitly reserves relative imports for internal or non-exported members and chain definitions. This ensures the test exercises the supported consumer-facing export path.

AGENTS.md reference: AGENTS.md:L188-L193

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 94e8d19: the new public imports, including multicall3Abi, now come from 'viem'.

@github-actions

Copy link
Copy Markdown
Contributor

Published [email protected] under the pr-5530 dist-tag, which follows this pull request until it closes.

pnpm add viem@pr-5530
pnpm add [email protected]

jxom commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

Bundled into #5543 as its own commit, so this PR is superseded. Closing in favour of the bundle.

@jxom jxom closed this Nov 16, 2026

This branch had an error being deployed

1 failed deployment
Preview — 94e8d194 Deployed Nov 16, 2026 by vercel[bot]
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.

2 participants