github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/src/dispute/PermissionedDisputeGame.sol (about) 1 // SPDX-License-Identifier: MIT 2 pragma solidity 0.8.15; 3 4 import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; 5 import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; 6 import { FaultDisputeGame, IFaultDisputeGame, IBigStepper, IInitializable } from "src/dispute/FaultDisputeGame.sol"; 7 import "src/libraries/DisputeTypes.sol"; 8 import "src/libraries/DisputeErrors.sol"; 9 10 /// @title PermissionedDisputeGame 11 /// @notice PermissionedDisputeGame is a contract that inherits from `FaultDisputeGame`, and contains two roles: 12 /// - The `challenger` role, which is allowed to challenge a dispute. 13 /// - The `proposer` role, which is allowed to create proposals and participate in their game. 14 /// This contract exists as a way for networks to support the fault proof iteration of the OptimismPortal 15 /// contract without needing to support a fully permissionless system. Permissionless systems can introduce 16 /// costs that certain networks may not wish to support. This contract can also be used as a fallback mechanism 17 /// in case of a failure in the permissionless fault proof system in the stage one release. 18 contract PermissionedDisputeGame is FaultDisputeGame { 19 /// @notice The proposer role is allowed to create proposals and participate in the dispute game. 20 address internal immutable PROPOSER; 21 22 /// @notice The challenger role is allowed to participate in the dispute game. 23 address internal immutable CHALLENGER; 24 25 /// @notice Modifier that gates access to the `challenger` and `proposer` roles. 26 modifier onlyAuthorized() { 27 if (!(msg.sender == PROPOSER || msg.sender == CHALLENGER)) { 28 revert BadAuth(); 29 } 30 _; 31 } 32 33 /// @param _gameType The type ID of the game. 34 /// @param _absolutePrestate The absolute prestate of the instruction trace. 35 /// @param _maxGameDepth The maximum depth of bisection. 36 /// @param _splitDepth The final depth of the output bisection portion of the game. 37 /// @param _gameDuration The duration of the game. 38 /// @param _vm An onchain VM that performs single instruction steps on an FPP trace. 39 /// @param _weth WETH contract for holding ETH. 40 /// @param _anchorStateRegistry The contract that stores the anchor state for each game type. 41 /// @param _l2ChainId Chain ID of the L2 network this contract argues about. 42 /// @param _proposer Address that is allowed to create instances of this contract. 43 /// @param _challenger Address that is allowed to challenge instances of this contract. 44 constructor( 45 GameType _gameType, 46 Claim _absolutePrestate, 47 uint256 _maxGameDepth, 48 uint256 _splitDepth, 49 Duration _gameDuration, 50 IBigStepper _vm, 51 IDelayedWETH _weth, 52 IAnchorStateRegistry _anchorStateRegistry, 53 uint256 _l2ChainId, 54 address _proposer, 55 address _challenger 56 ) 57 FaultDisputeGame( 58 _gameType, 59 _absolutePrestate, 60 _maxGameDepth, 61 _splitDepth, 62 _gameDuration, 63 _vm, 64 _weth, 65 _anchorStateRegistry, 66 _l2ChainId 67 ) 68 { 69 PROPOSER = _proposer; 70 CHALLENGER = _challenger; 71 } 72 73 /// @inheritdoc IFaultDisputeGame 74 function step( 75 uint256 _claimIndex, 76 bool _isAttack, 77 bytes calldata _stateData, 78 bytes calldata _proof 79 ) 80 public 81 override 82 onlyAuthorized 83 { 84 super.step(_claimIndex, _isAttack, _stateData, _proof); 85 } 86 87 /// @notice Generic move function, used for both `attack` and `defend` moves. 88 /// @param _challengeIndex The index of the claim being moved against. 89 /// @param _claim The claim at the next logical position in the game. 90 /// @param _isAttack Whether or not the move is an attack or defense. 91 function move(uint256 _challengeIndex, Claim _claim, bool _isAttack) public payable override onlyAuthorized { 92 super.move(_challengeIndex, _claim, _isAttack); 93 } 94 95 /// @inheritdoc IInitializable 96 function initialize() public payable override { 97 // The creator of the dispute game must be the proposer EOA. 98 if (tx.origin != PROPOSER) revert BadAuth(); 99 100 // Fallthrough initialization. 101 super.initialize(); 102 } 103 }