mirror of
https://github.com/hanzoai/viem.git
synced 2026-10-30 19:36:39 +00:00
* feat(op-stack): add super dispute game type helpers * feat(op-stack): track super-root usage on dispute games * feat(op-stack): add L2 timestamp block lookup utility * fix(op-stack): resolve super game timestamps when proving withdrawals * feat(op-stack): allow L2 timestamps for prove readiness checks * docs(op-stack): document super-root withdrawal anchors * feat(examples): add super withdrawal devnet example Add an OP Stack super-root withdrawal example and configure it to run against the local source tree for devnet validation. The example validates Portal, DisputeGameFactory, and L2 chain alignment, configures Multicall3 for custom L1 chains, and allows explicit initiate-withdrawal gas for local OP devnets. * chore: add op-stack super root changeset --------- Co-authored-by: wwared <[email protected]> Co-authored-by: jxom <[email protected]>
2.0 KiB
2.0 KiB
OP Stack Super Withdrawal Example
Manual end-to-end withdrawal verification for OP Stack devnets. The same script can run against:
- A pre-super-roots devnet where the respected Portal game type uses legacy L2 block-number anchors.
- A post-super-roots devnet where the respected Portal game type uses L2 timestamp anchors.
This example is intentionally not wired into CI. It requires external devnets, funded accounts, and devnet finalization timings short enough for manual runs.
Run
pnpm --filter example-op-stack-super-withdrawal dev
Environment
Required for both legacy and super-root devnets:
export L1_RPC_URL=http://127.0.0.1:8545
export L2_RPC_URL=http://127.0.0.1:9545
export L1_CHAIN_ID=900
export L2_CHAIN_ID=901
export PRIVATE_KEY=0x...
export PORTAL_ADDRESS=0x...
export DISPUTE_GAME_FACTORY_ADDRESS=0x...
Required only for legacy Portal/L2OutputOracle devnets:
export L2_OUTPUT_ORACLE_ADDRESS=0x...
Optional:
export WITHDRAWAL_AMOUNT_WEI=1000
What It Does
The script:
- Builds initiate-withdrawal parameters.
- Initiates the withdrawal on L2.
- Waits for the L2 transaction receipt.
- Reads the Portal version and respected game type to determine whether the devnet uses super roots.
- Reads the L2 receipt block timestamp and passes it as
l2TimestamptowaitToProveonly for super-root devnets. - Builds prove-withdrawal parameters from the returned dispute game.
- Proves the withdrawal on L1.
- Waits for the L1 prove transaction receipt.
- Waits until the withdrawal can be finalized.
- Finalizes the withdrawal on L1.
- Waits for the L1 finalize transaction receipt and logs the L1 balance delta.
For non-super devnets, the script keeps using the receipt L2 block number for
prove readiness. For post-super-roots devnets, l2Timestamp becomes the L1-side
anchor used to find the correct dispute game, and buildProveWithdrawal
resolves that timestamp back to an L2 block number for the proof RPC calls.