Verify an escape hatch exit proof
A proof is only worth the root it is checked against, so verify in this order: recompute the leaf from
the message, rebuild the root from the branch, and confirm that root is the one the L1 contract
actually recognises — a locally valid proof against a stale or disputed root is a trap.
Procedure
Recompute the withdrawal leaf exactly as the bridge contract hashes it. Getting the field order or
abi-encoding wrong makes a valid proof fail. For OP Stack:
# leaf = keccak256(abi.encodeWithSignature("WithdrawalTransaction(...)", nonce,sender,target,value,gasLimit,data))
cast keccak $(cast abi-encode "f(uint256,address,address,uint256,uint256,bytes)" \
$NONCE $SENDER $TARGET $VALUE $GASLIMIT $DATA)
Rebuild the root from the sibling branch. Walk the merkle proof, hashing pairs with the ordering
the contract expects (OP uses sorted-pair hashing). Compare against the claimed output root.
# python: for h in proof: leaf = keccak(sorted(leaf,h))
Confirm the output root is the canonical, final one on L1 — not merely one you were handed.
Read it from the output oracle or dispute game by index:
cast call $L2_OUTPUT_ORACLE "getL2Output(uint256)(bytes32,uint128,uint128)" $INDEX --rpc-url $L1RPC
Arbitrum: read Rollup.rollupBlockHash / the committed assertion via Outbox after the rollup
block is confirmed.
Check the proof has not already been used and is still valid. Read the portal's record:
cast call $OPTIMISM_PORTAL "provenWithdrawals(bytes32)(bytes32,uint128,uint128)" $WITHDRAWAL_HASH --rpc-url $L1RPC
A nonzero timestamp with a different root than the current oracle output means the proof is stale
and must be re-proved against the newer root.
Confirm the challenge window state. An OP withdrawal cannot be finalised until the 7-day challenge
period on the referenced output has elapsed; a disputed game makes the root unusable.
Only now hand the proof to finalizeWithdrawalTransaction (OP) or Outbox.executeTransaction
(Arbitrum). If step 3 or 4 fails, do not submit — regenerate against a fresh root.
Pitfalls
- Verifying the proof against a root fetched from the wrong oracle or a superseded index; the proof is
internally consistent and still fails on-chain.
- Hashing the leaf with the wrong field order or a missing selector; bridge contracts are unforgiving
and the error surfaces only as an opaque revert.
- Reusing a proof whose
provenWithdrawals entry already exists against a now-superseded root.
- Trusting a proof supplied by a counterparty without re-deriving the leaf yourself.
- Ignoring that a game disputed during the window freezes finalisation even though the proof is valid.
Verification
cast call $OPTIMISM_PORTAL "provenWithdrawals(bytes32)(bytes32,uint128,uint128)" $WITHDRAWAL_HASH --rpc-url $L1RPC
cast call $L2_OUTPUT_ORACLE "getL2Output(uint256)(bytes32,uint128,uint128)" $INDEX --rpc-url $L1RPC
# proof's root == oracle output root, and timestamp + 604800 <= now
Report the recomputed leaf, the root you derived, the canonical root from the oracle, and whether the
challenge period has elapsed.
1---2name: verify-escape-hatch-exit-proof3description: Use when validating that a withdrawal or exit proof against an L1 bridge contract is well-formed and matches the canonical L2 state before you trust or submit it.4metadata:5 source: https://skillmd.com/skills/jiayaoqijia/verify-escape-hatch-exit-proof6---78# Verify an escape hatch exit proof910A proof is only worth the root it is checked against, so verify in this order: recompute the leaf from11the message, rebuild the root from the branch, and confirm that root is the one the L1 contract12actually recognises — a locally valid proof against a stale or disputed root is a trap.1314## Procedure15161. Recompute the withdrawal leaf exactly as the bridge contract hashes it. Getting the field order or17 abi-encoding wrong makes a valid proof fail. For OP Stack:1819 # leaf = keccak256(abi.encodeWithSignature("WithdrawalTransaction(...)", nonce,sender,target,value,gasLimit,data))20 cast keccak $(cast abi-encode "f(uint256,address,address,uint256,uint256,bytes)" \21 $NONCE $SENDER $TARGET $VALUE $GASLIMIT $DATA)22232. Rebuild the root from the sibling branch. Walk the merkle proof, hashing pairs with the ordering24 the contract expects (OP uses sorted-pair hashing). Compare against the claimed output root.2526 # python: for h in proof: leaf = keccak(sorted(leaf,h))27283. Confirm the output root is the canonical, final one on L1 — not merely one you were handed.29 Read it from the output oracle or dispute game by index:3031 cast call $L2_OUTPUT_ORACLE "getL2Output(uint256)(bytes32,uint128,uint128)" $INDEX --rpc-url $L1RPC3233 Arbitrum: read `Rollup.rollupBlockHash` / the committed assertion via `Outbox` after the rollup34 block is confirmed.35364. Check the proof has not already been used and is still valid. Read the portal's record:3738 cast call $OPTIMISM_PORTAL "provenWithdrawals(bytes32)(bytes32,uint128,uint128)" $WITHDRAWAL_HASH --rpc-url $L1RPC3940 A nonzero timestamp with a different root than the current oracle output means the proof is stale41 and must be re-proved against the newer root.42435. Confirm the challenge window state. An OP withdrawal cannot be finalised until the 7-day challenge44 period on the referenced output has elapsed; a disputed game makes the root unusable.45466. Only now hand the proof to `finalizeWithdrawalTransaction` (OP) or `Outbox.executeTransaction`47 (Arbitrum). If step 3 or 4 fails, do not submit — regenerate against a fresh root.4849## Pitfalls5051- Verifying the proof against a root fetched from the wrong oracle or a superseded index; the proof is52 internally consistent and still fails on-chain.53- Hashing the leaf with the wrong field order or a missing selector; bridge contracts are unforgiving54 and the error surfaces only as an opaque revert.55- Reusing a proof whose `provenWithdrawals` entry already exists against a now-superseded root.56- Trusting a proof supplied by a counterparty without re-deriving the leaf yourself.57- Ignoring that a game disputed during the window freezes finalisation even though the proof is valid.5859## Verification6061 cast call $OPTIMISM_PORTAL "provenWithdrawals(bytes32)(bytes32,uint128,uint128)" $WITHDRAWAL_HASH --rpc-url $L1RPC62 cast call $L2_OUTPUT_ORACLE "getL2Output(uint256)(bytes32,uint128,uint128)" $INDEX --rpc-url $L1RPC63 # proof's root == oracle output root, and timestamp + 604800 <= now6465Report the recomputed leaf, the root you derived, the canonical root from the oracle, and whether the66challenge period has elapsed.