-
Notifications
You must be signed in to change notification settings - Fork 128
add new template for addGameType #1253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c749343
add new template for addGameType
Wazabie e942da4
Update AddGameTypeTemplate.sol
Wazabie ed7458e
Update AddGameTypeTemplate.sol
Wazabie db3bbbb
Update AddGameTypeTemplate.sol
Wazabie 0ea351c
Update AddGameTypeTemplate.sol
Wazabie 54a0db8
Update Regression.t.sol
Wazabie 78c4cc8
Update AddGameTypeTemplate.sol
Wazabie 84102e0
Update AddGameTypeTemplate.sol
Wazabie 48ca62f
Update AddGameTypeTemplate.sol
Wazabie b10dac8
Update AddGameTypeTemplate.sol
Wazabie 77ba44d
Delete AddGameTypeTemplate.toml
Wazabie b2e2930
Add safe name depth to env file
Wazabie 84a9073
Update with sony sepolia data in example task
Wazabie b6e36a2
Update imports
Wazabie 44d5624
Update AddGameTypeTemplate.sol
Wazabie 5cdbbeb
Merge branch 'main' into add-game-type
Wazabie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,147 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.15; | ||
|
|
||
| import {VmSafe} from "forge-std/Vm.sol"; | ||
| import {stdToml} from "forge-std/StdToml.sol"; | ||
|
|
||
| import {OPCMTaskBase} from "src/tasks/types/OPCMTaskBase.sol"; | ||
| import {SuperchainAddressRegistry} from "src/SuperchainAddressRegistry.sol"; | ||
| import {Action} from "src/libraries/MultisigTypes.sol"; | ||
|
|
||
| import {GameType, Claim, Duration} from "@eth-optimism-bedrock/src/dispute/lib/Types.sol"; | ||
| import { | ||
| IOPContractsManager, | ||
| IDisputeGameFactory, | ||
| IFaultDisputeGame, | ||
| IBigStepper, | ||
| IProxyAdmin, | ||
| IDelayedWETH, | ||
| ISystemConfig | ||
| } from "@eth-optimism-bedrock/interfaces/L1/IOPContractsManager.sol"; | ||
|
|
||
| /// @title AddGameTypeTemplate | ||
| /// @notice This template is used to add a game type to the DisputeGameFactory contract. | ||
| contract AddGameTypeTemplate is OPCMTaskBase { | ||
| using stdToml for string; | ||
|
|
||
| /// @notice Struct that extends the original AddGameInput struct and includes the chain id. | ||
| /// Notably the fields here are also in alphabetical order, this is required because of | ||
| /// the way that Foundry parses TOML data. This MUST be kept in alphabetical order. If | ||
| /// you are adding a new field, you MUST make sure it's in order. Seriously. | ||
| struct AddGameInputWithChainId { | ||
| uint256 chainId; | ||
| IDelayedWETH delayedWETH; | ||
| Claim disputeAbsolutePrestate; | ||
| Duration disputeClockExtension; | ||
| GameType disputeGameType; | ||
| Duration disputeMaxClockDuration; | ||
| uint256 disputeMaxGameDepth; | ||
| uint256 disputeSplitDepth; | ||
| uint256 initialBond; | ||
| bool permissioned; | ||
| IProxyAdmin proxyAdmin; | ||
| string saltMixer; | ||
| ISystemConfig systemConfig; | ||
| IBigStepper vm; | ||
| } | ||
|
|
||
| /// @notice Mapping of chain ID to configuration for the task. | ||
| mapping(uint256 => AddGameInputWithChainId) private cfg; | ||
|
|
||
| /// @notice Address of the OPCM contract. | ||
| address private OPCM; | ||
|
|
||
| /// @notice Returns string identifiers for addresses that are expected to have their storage written to. | ||
| function _taskStorageWrites() internal view virtual override returns (string[] memory) { | ||
| string[] memory storageWrites = new string[](1); | ||
| storageWrites[0] = "DisputeGameFactoryProxy"; | ||
| return storageWrites; | ||
| } | ||
|
|
||
| /// @notice Sets up the template with implementation configurations from a TOML file. | ||
| function _templateSetup(string memory taskConfigFilePath, address rootSafe) internal override { | ||
| super._templateSetup(taskConfigFilePath, rootSafe); | ||
| string memory tomlContent = vm.readFile(taskConfigFilePath); | ||
|
|
||
| // Load configuration. | ||
| AddGameInputWithChainId[] memory configs = | ||
| abi.decode(tomlContent.parseRaw(".configs"), (AddGameInputWithChainId[])); | ||
| for (uint256 i = 0; i < configs.length; i++) { | ||
| cfg[configs[i].chainId] = configs[i]; | ||
| } | ||
|
Wazabie marked this conversation as resolved.
Wazabie marked this conversation as resolved.
|
||
|
|
||
| // Load OPCM address. | ||
| OPCM = tomlContent.readAddress(".addresses.OPCM"); | ||
| require(OPCM != address(0), "OPCM not set"); | ||
|
Wazabie marked this conversation as resolved.
|
||
| vm.label(OPCM, "OPCM"); | ||
|
|
||
| // Set OPCM as the target for delegatecalls. | ||
| OPCM_TARGETS = new address[](1); | ||
| OPCM_TARGETS[0] = OPCM; | ||
| } | ||
|
|
||
| /// @notice Write the calls that you want to execute for the task. | ||
| function _build(address) internal override { | ||
| // Iterate over the chains pull out the configs. | ||
| SuperchainAddressRegistry.ChainInfo[] memory chains = superchainAddrRegistry.getChains(); | ||
| IOPContractsManager.AddGameInput[] memory configs = new IOPContractsManager.AddGameInput[](chains.length); | ||
|
Wazabie marked this conversation as resolved.
|
||
| for (uint256 i = 0; i < chains.length; i++) { | ||
| uint256 chainId = chains[i].chainId; | ||
| configs[i] = _toAddGameInput(cfg[chainId]); | ||
| } | ||
|
Wazabie marked this conversation as resolved.
|
||
|
|
||
| // Delegatecall the OPCM.addGameType() function. | ||
| (bool success,) = OPCM.delegatecall(abi.encodeCall(IOPContractsManager.addGameType, (configs))); | ||
| require(success, "AddGameType: failed to add game type"); | ||
|
Wazabie marked this conversation as resolved.
|
||
| } | ||
|
|
||
| /// @notice This method performs all validations and assertions that verify the calls executed as expected. | ||
| function _validate(VmSafe.AccountAccess[] memory, Action[] memory, address) internal view override { | ||
| // Iterate over the chains and validate the respected game type. | ||
| SuperchainAddressRegistry.ChainInfo[] memory chains = superchainAddrRegistry.getChains(); | ||
| for (uint256 i = 0; i < chains.length; i++) { | ||
| uint256 chainId = chains[i].chainId; | ||
| address factoryAddress = superchainAddrRegistry.getAddress("DisputeGameFactoryProxy", chainId); | ||
| IDisputeGameFactory factory = IDisputeGameFactory(factoryAddress); | ||
| IFaultDisputeGame game = IFaultDisputeGame(address(factory.gameImpls(cfg[chainId].disputeGameType))); | ||
|
Wazabie marked this conversation as resolved.
Wazabie marked this conversation as resolved.
|
||
|
|
||
| // Assert that everything is as expected. | ||
| assertEq(address(game.weth()), address(cfg[chainId].delayedWETH)); | ||
| assertEq(game.gameType().raw(), cfg[chainId].disputeGameType.raw()); | ||
| assertEq(game.absolutePrestate().raw(), cfg[chainId].disputeAbsolutePrestate.raw()); | ||
| assertEq(game.maxGameDepth(), cfg[chainId].disputeMaxGameDepth); | ||
| assertEq(game.splitDepth(), cfg[chainId].disputeSplitDepth); | ||
| assertEq(game.clockExtension().raw(), cfg[chainId].disputeClockExtension.raw()); | ||
| assertEq(game.maxClockDuration().raw(), cfg[chainId].disputeMaxClockDuration.raw()); | ||
|
|
||
| // Assert that the bond is set correctly. | ||
| assertEq(factory.initBonds(cfg[chainId].disputeGameType), cfg[chainId].initialBond); | ||
| } | ||
| } | ||
|
|
||
| /// @notice Override to return a list of addresses that should not be checked for code length. | ||
| function _getCodeExceptions() internal view virtual override returns (address[] memory) {} | ||
|
Wazabie marked this conversation as resolved.
|
||
|
|
||
| /// @notice Converts the AddGameInputWithChainId struct to the AddGameInput struct. | ||
| function _toAddGameInput(AddGameInputWithChainId memory _input) | ||
| internal | ||
| pure | ||
| returns (IOPContractsManager.AddGameInput memory) | ||
| { | ||
| return IOPContractsManager.AddGameInput({ | ||
| saltMixer: _input.saltMixer, | ||
| systemConfig: _input.systemConfig, | ||
| proxyAdmin: _input.proxyAdmin, | ||
| delayedWETH: _input.delayedWETH, | ||
| disputeGameType: _input.disputeGameType, | ||
| disputeAbsolutePrestate: _input.disputeAbsolutePrestate, | ||
| disputeMaxGameDepth: _input.disputeMaxGameDepth, | ||
| disputeSplitDepth: _input.disputeSplitDepth, | ||
| disputeClockExtension: _input.disputeClockExtension, | ||
| disputeMaxClockDuration: _input.disputeMaxClockDuration, | ||
| initialBond: _input.initialBond, | ||
| vm: _input.vm, | ||
| permissioned: _input.permissioned | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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,2 @@ | ||
| FORK_BLOCK_NUMBER=9431469 | ||
| NESTED_SAFE_NAME_DEPTH_1=foundation |
This file contains hidden or 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,24 @@ | ||
| templateName = "AddGameTypeTemplate" | ||
|
|
||
| l2chains = [ | ||
| {name = "Soneium Testnet Minato", chainId = 1946}, | ||
| ] | ||
|
|
||
| [[configs]] | ||
| chainId = 1946 | ||
| saltMixer = "this is a salt mixer" | ||
| systemConfig = "0x4Ca9608Fef202216bc21D543798ec854539bAAd3" | ||
| proxyAdmin = "0xff9d236641962Cebf9DBFb54E7b8e91F99f10Db0" | ||
| delayedWETH = "0xB39c1730DFF54f25F9e45667c119e0a8FeE73156" | ||
| disputeGameType = 0 | ||
| disputeAbsolutePrestate = "0x0339db503776757491b9f3038bf6f1d37b7988a2f75e823fe2656c1352ef2f91" | ||
| disputeMaxGameDepth = 73 | ||
| disputeSplitDepth = 30 | ||
| disputeClockExtension = 10800 | ||
| disputeMaxClockDuration = 302400 | ||
| initialBond = 80000000000000000 | ||
| vm = "0x07babe08ee4d07dba236530183b24055535a7011" | ||
| permissioned = false | ||
|
|
||
| [addresses] | ||
| OPCM = "0x3bb6437aba031afbf9cb3538fa064161e2bf2d78" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.