-
-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(op-stack): fault proofs (#1994)
* parent 6ef4ac1 author Will Cory <willcory@Wills-MacBook-Pro.local> 1709088652 -0800 committer Will Cory <willcory@Wills-MacBook-Pro.local> 1710517178 -0700 Add portalVersion action to viem/opstack add test client for tevm matching anvil client pnpm i @tevm/server upgrade to versions of @tevm/opstack that don't have deps related bugs REVERTME temporary hack to make foundry work on my machine add the test and portal version action update based on comments add test client, rename createL1Client, and move to opstack test utils bun i @tevm/opstack add test client for tevm matching anvil client pnpm i @tevm/server upgrade to versions of @tevm/opstack that don't have deps related bugs REVERTME temporary hack to make foundry work on my machine add the test and portal version action feat: Add forwards compatability to getWithdrawalStatus first version of things feat: Update waitForNextL2Output fix broken lint update getTimeToFinalize add a comment complete and squash * replace test with optimism devnet test * WIP * fix: Build * fix: lint * op devnet script * add address * chore: refactor * rename * rename * exports * remove * refactor * ci: trigger * ci: env * test * docs * feat: getL2Output backwards compat * fix: type * test: up * update sidebar * chore: changeset --------- Co-authored-by: Will Cory <willcory@Wills-MacBook-Pro.local> Co-authored-by: Will Cory <willcory10@gmail.com>
- Loading branch information
1 parent
5a01527
commit 119aea6
Showing
51 changed files
with
3,646 additions
and
268 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"viem": minor | ||
--- | ||
|
||
Added support for [Fault Proofs on OP Stack](https://docs.optimism.io/stack/protocol/fault-proofs/overview), and new actions: | ||
|
||
- [`getGame`](https://viem.sh/op-stack/actions/getGame) (supersedes `getL2Output`) | ||
- `getGames` | ||
- [`getTimeToNextGame`](https://viem.sh/op-stack/actions/getTimeToNextGame) (supersedes `getTimeToNextL2Output`) | ||
- [`waitForNextGame`](https://viem.sh/op-stack/actions/waitForNextGame) (supersedes `waitForNextL2Output`) | ||
|
||
> Note: The above actions are only compatible with OP Stack chains which have upgraded to Fault Proofs. |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
outline: deep | ||
description: Retrieves a valid dispute game on an L2 that occurred after a provided L2 block number. | ||
--- | ||
|
||
# getGame | ||
|
||
Retrieves a valid dispute game on an L2 that occurred after a provided L2 block number. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. | ||
|
||
:::info | ||
This Action is only compatible with OP Stack chains that have upgraded to [Fault Proofs](https://docs.optimism.io/stack/protocol/fault-proofs/overview) and have a deployed [DisputeGameFactoryProxy contract](https://github.com/ethereum-optimism/superchain-registry/blob/main/superchain/extra/addresses/addresses.json). | ||
::: | ||
|
||
## Usage | ||
|
||
:::code-group | ||
|
||
```ts [example.ts] | ||
import { optimism } from 'viem/chains' | ||
import { account, publicClientL1 } from './config' | ||
|
||
const game = await publicClientL1.getGame({ // [!code hl] | ||
l2BlockNumber: 69420n, // [!code hl] | ||
targetChain: optimism, // [!code hl] | ||
}) // [!code hl] | ||
``` | ||
|
||
```ts [config.ts] | ||
import { createPublicClient, custom, http } from 'viem' | ||
import { mainnet, optimism } from 'viem/chains' | ||
import { publicActionsL1 } from 'viem/op-stack' | ||
|
||
export const publicClientL1 = createPublicClient({ | ||
chain: mainnet, | ||
transport: http() | ||
}).extend(publicActionsL1()) | ||
``` | ||
|
||
::: | ||
|
||
## Returns | ||
|
||
`GetGameReturnType` | ||
|
||
A valid dispute game. | ||
|
||
## Parameters | ||
|
||
### l2BlockNumber | ||
|
||
- **Type:** `bigint` | ||
|
||
The L2 block number. | ||
|
||
```ts | ||
const game = await publicClientL1.getGame({ | ||
l2BlockNumber: 69420n, // [!code focus] | ||
targetChain: optimism, | ||
}) | ||
``` | ||
|
||
### targetChain | ||
|
||
- **Type:** [`Chain`](/docs/glossary/types#chain) | ||
|
||
The L2 chain. | ||
|
||
```ts | ||
const game = await publicClientL1.getGame({ | ||
l2BlockNumber, | ||
targetChain: optimism, // [!code focus] | ||
}) | ||
``` | ||
|
||
### disputeGameFactoryAddress (optional) | ||
|
||
- **Type:** `Address` | ||
- **Default:** `targetChain.contracts.disputeGameFactory[chainId].address` | ||
|
||
The address of the [`DisputeGameFactory` contract](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/dispute/DisputeGameFactory.sol). Defaults to the `DisputeGameFactory` contract specified on the `targetChain`. | ||
|
||
If a `disputeGameFactoryAddress` is provided, the `targetChain` parameter becomes optional. | ||
|
||
```ts | ||
const game = await publicClientL1.getGame({ | ||
l2BlockNumber, | ||
disputeGameFactoryAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed' // [!code focus] | ||
}) | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
--- | ||
outline: deep | ||
description: Retrieves dispute games for an L2. | ||
--- | ||
|
||
# getGames | ||
|
||
Retrieves dispute games for an L2. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. | ||
|
||
:::info | ||
This Action is only compatible with OP Stack chains that have upgraded to [Fault Proofs](https://docs.optimism.io/stack/protocol/fault-proofs/overview) and have a deployed [DisputeGameFactoryProxy contract](https://github.com/ethereum-optimism/superchain-registry/blob/main/superchain/extra/addresses/addresses.json). | ||
::: | ||
|
||
## Usage | ||
|
||
:::code-group | ||
|
||
```ts [example.ts] | ||
import { optimism } from 'viem/chains' | ||
import { account, publicClientL1 } from './config' | ||
|
||
const games = await publicClientL1.getGames({ // [!code hl] | ||
targetChain: optimism, // [!code hl] | ||
}) // [!code hl] | ||
``` | ||
|
||
```ts [config.ts] | ||
import { createPublicClient, custom, http } from 'viem' | ||
import { mainnet, optimism } from 'viem/chains' | ||
import { publicActionsL1 } from 'viem/op-stack' | ||
|
||
export const publicClientL1 = createPublicClient({ | ||
chain: mainnet, | ||
transport: http() | ||
}).extend(publicActionsL1()) | ||
``` | ||
|
||
::: | ||
|
||
## Returns | ||
|
||
`GetGamesReturnType` | ||
|
||
Dispute games. | ||
|
||
## Parameters | ||
|
||
### targetChain | ||
|
||
- **Type:** [`Chain`](/docs/glossary/types#chain) | ||
|
||
The L2 chain. | ||
|
||
```ts | ||
const games = await publicClientL1.getGames({ | ||
l2BlockNumber, | ||
targetChain: optimism, // [!code focus] | ||
}) | ||
``` | ||
|
||
### disputeGameFactoryAddress (optional) | ||
|
||
- **Type:** `Address` | ||
- **Default:** `targetChain.contracts.disputeGameFactory[chainId].address` | ||
|
||
The address of the [`DisputeGameFactory` contract](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/dispute/DisputeGameFactory.sol). Defaults to the `DisputeGameFactory` contract specified on the `targetChain`. | ||
|
||
If a `disputeGameFactoryAddress` is provided, the `targetChain` parameter becomes optional. | ||
|
||
```ts | ||
const games = await publicClientL1.getGames({ | ||
l2BlockNumber, | ||
disputeGameFactoryAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed' // [!code focus] | ||
}) | ||
``` | ||
|
||
### l2BlockNumber (optional) | ||
|
||
- **Type:** `bigint` | ||
|
||
The L2 block number. | ||
|
||
```ts | ||
const games = await publicClientL1.getGames({ | ||
l2BlockNumber: 69420n, // [!code focus] | ||
targetChain: optimism, | ||
}) | ||
``` | ||
|
||
### limit (optional) | ||
|
||
- **Type:** `number` | ||
- **Default:** `100` | ||
|
||
Limit of games to extract. | ||
|
||
```ts | ||
const games = await publicClientL1.getGames({ | ||
limit: 10, // [!code focus] | ||
targetChain: optimism, | ||
}) | ||
``` | ||
|
||
### portalAddress (optional) | ||
|
||
- **Type:** `Address` | ||
- **Default:** `targetChain.contracts.portal[chainId].address` | ||
|
||
The address of the [`Portal` contract](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L1/OptimismPortal2.sol). Defaults to the `Portal` contract specified on the `targetChain`. | ||
|
||
If a `portalAddress` is provided, the `targetChain` parameter becomes optional. | ||
|
||
```ts | ||
const games = await publicClientL1.getGames({ | ||
l2BlockNumber, | ||
portalAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed' // [!code focus] | ||
}) | ||
``` |
This file contains 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
Oops, something went wrong.