-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mock dispute game factory / OP stack devnet script
- Loading branch information
Showing
12 changed files
with
146 additions
and
8 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# Devnet Specs: https://github.com/ethereum-optimism/optimism/blob/develop/specs/meta/devnet.md | ||
|
||
export OP_CHALLENGER_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" | ||
export OP_CHALLENGER_KEY="ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" | ||
export OP_CHALLENGER_L1_WS="ws://127.0.0.1:8546" | ||
export OP_CHALLENGER_TRUSTED_OP_NODE_RPC="http://localhost:7545" | ||
export OP_CHALLENGER_L2OO="0x6900000000000000000000000000000000000000" | ||
|
||
# TODO | ||
export OP_CHALLENGER_DGF="0x0000000000000000000000000000000000000000" | ||
# Paste the DisputeGameFactory env variable logged by `start_devnet.sh` here. | ||
|
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,3 @@ | ||
[submodule "testdata/mock-dgf/lib/forge-std"] | ||
path = testdata/mock-dgf/lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std |
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,19 @@ | ||
#!/bin/bash | ||
|
||
# Set up environment variables | ||
source .env.devnet | ||
|
||
# Change accordingly | ||
MONOREPO_DIR="$HOME/dev/optimism/monorepo" | ||
|
||
# Boot up the devnet | ||
(cd $MONOREPO_DIR && make devnet-up) | ||
|
||
# Deploy the mock dispute game contract | ||
(cd ./testdata/mock-dgf && forge script script/DeployMocks.s.sol --rpc-url http://localhost:8545 --private-key $OP_CHALLENGER_KEY --broadcast) | ||
|
||
echo "----------------------------------------------------------------" | ||
echo " - Paste the environment variable logged by the forge script" | ||
echo " - into the \`.env.devnet\` file and then source it again before" | ||
echo " - running the \`op-challenger\`." | ||
echo "----------------------------------------------------------------" |
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,3 @@ | ||
# `testdata` | ||
|
||
Various periphery components used for testing the `op-challenger`. |
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,14 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env |
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,7 @@ | ||
[profile.default] | ||
src = 'src' | ||
out = 'out' | ||
libs = ['lib'] | ||
|
||
[fmt] | ||
bracket_spacing = true |
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,18 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import "forge-std/Script.sol"; | ||
import { MockDisputeGameFactory } from "src/MockDisputeGameFactory.sol"; | ||
import { MockDisputeGame_OutputAttestation } from "src/MockDisputeGame_OutputAttestation.sol"; | ||
|
||
/// @notice This script deploys the mock dispute game factory. | ||
contract DeployMocks is Script { | ||
function run() public { | ||
// Deploy the mock dispute game factory | ||
vm.broadcast(); | ||
MockDisputeGameFactory mock = new MockDisputeGameFactory(); | ||
|
||
// Write the address to the devnet ENV | ||
console.log(string.concat("ENV Variable: export OP_CHALLENGER_DGF=\"", vm.toString(address(mock)), "\"")); | ||
} | ||
} |
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,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { MockDisputeGame_OutputAttestation } from "./MockDisputeGame_OutputAttestation.sol"; | ||
|
||
/// @notice The type of proof system being used. | ||
enum GameType { | ||
/// @dev The game will use a `IDisputeGame` implementation that utilizes fault proofs. | ||
FAULT, | ||
/// @dev The game will use a `IDisputeGame` implementation that utilizes validity proofs. | ||
VALIDITY, | ||
/// @dev The game will use a `IDisputeGame` implementation that utilizes attestation proofs. | ||
ATTESTATION | ||
} | ||
|
||
/// @notice A `Claim` type represents a 32 byte hash or other unique identifier for a claim about | ||
/// a certain piece of information. | ||
/// @dev For the `FAULT` `GameType`, this will be a root of the merklized state of the fault proof | ||
/// program at the end of the state transition. | ||
/// For the `ATTESTATION` `GameType`, this will be an output root. | ||
type Claim is bytes32; | ||
|
||
/// @title MockDisputeGameFactory | ||
/// @dev This contract is used for testing the `op-challenger`'s `OutputAttestationDriver` | ||
/// on a local devnet. | ||
contract MockDisputeGameFactory { | ||
event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim); | ||
|
||
/// @notice Creates a new DisputeGame proxy contract. | ||
/// @param gameType The type of the DisputeGame - used to decide the proxy implementation | ||
/// @param rootClaim The root claim of the DisputeGame. | ||
/// @param extraData Any extra data that should be provided to the created dispute game. | ||
function create(GameType gameType, Claim rootClaim, bytes calldata extraData) external returns (MockDisputeGame_OutputAttestation mock) { | ||
mock = new MockDisputeGame_OutputAttestation(); | ||
emit DisputeGameCreated(address(mock), gameType, rootClaim); | ||
extraData; // Unused | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
testdata/mock-dgf/src/MockDisputeGame_OutputAttestation.sol
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,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
/// @title MockDisputeGame_OutputAttestation | ||
/// @dev This contract is used for testing the `op-challenger`'s `OutputAttestationDriver` | ||
/// on a local devnet. | ||
contract MockDisputeGame_OutputAttestation { | ||
function challenge(bytes calldata _signature) external { | ||
// Do nothing | ||
} | ||
} |
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,23 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import "forge-std/Test.sol"; | ||
import { MockDisputeGameFactory, GameType, Claim } from "src/MockDisputeGameFactory.sol"; | ||
|
||
contract MocksTest is Test { | ||
MockDisputeGameFactory factory; | ||
|
||
event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim); | ||
|
||
function setUp() public { | ||
factory = new MockDisputeGameFactory(); | ||
} | ||
|
||
function testCreate(uint8 gameType, Claim rootClaim, bytes calldata extraData) external { | ||
vm.assume(gameType <= 2); | ||
|
||
vm.expectEmit(false, true, true, false); | ||
emit DisputeGameCreated(address(0), GameType(gameType), rootClaim); | ||
factory.create(GameType(gameType), rootClaim, extraData); | ||
} | ||
} |