Skip to content

Commit 5216aca

Browse files
feat: incident response improvements
First half of the original incident response improvements PR. Co-authored-by: wildmolasses <[email protected]>
1 parent 3d73ef3 commit 5216aca

25 files changed

+965
-494
lines changed

packages/contracts-bedrock/foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build_info_path = 'artifacts/build-info'
1111
snapshots = 'notarealpath' # workaround for foundry#9477
1212

1313
optimizer = true
14-
optimizer_runs = 999999
14+
optimizer_runs = 5000
1515

1616
extra_output = ['devdoc', 'userdoc', 'metadata', 'storageLayout']
1717
bytecode_hash = 'none'

packages/contracts-bedrock/interfaces/dispute/IAnchorStateRegistry.sol

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { GameType, Hash, OutputRoot } from "src/dispute/lib/Types.sol";
1010

1111
interface IAnchorStateRegistry {
1212
error AnchorStateRegistry_Unauthorized();
13-
error AnchorStateRegistry_ImproperAnchorGame();
1413
error AnchorStateRegistry_InvalidAnchorGame();
1514

1615
event AnchorNotUpdated(IFaultDisputeGame indexed game);
@@ -21,16 +20,26 @@ interface IAnchorStateRegistry {
2120
function anchors(GameType) external view returns (Hash, uint256);
2221
function getAnchorRoot() external view returns (Hash, uint256);
2322
function disputeGameFactory() external view returns (IDisputeGameFactory);
24-
function initialize(ISuperchainConfig _superchainConfig, IDisputeGameFactory _disputeGameFactory, IOptimismPortal2 _portal, OutputRoot memory _startingAnchorRoot) external;
23+
function initialize(
24+
ISuperchainConfig _superchainConfig,
25+
IDisputeGameFactory _disputeGameFactory,
26+
IOptimismPortal2 _portal,
27+
OutputRoot memory _startingAnchorRoot
28+
)
29+
external;
2530
function isGameRegistered(IDisputeGame _game) external view returns (bool);
2631
function isGameBlacklisted(IDisputeGame _game) external view returns (bool);
2732
function isGameRespected(IDisputeGame _game) external view returns (bool);
2833
function isGameRetired(IDisputeGame _game) external view returns (bool);
34+
function isGameResolved(IDisputeGame _game) external view returns (bool);
35+
function isGameBeyondAirgap(IDisputeGame _game) external view returns (bool);
2936
function isGameProper(IDisputeGame _game) external view returns (bool);
37+
function isGameFinalized(IDisputeGame _game) external view returns (bool);
38+
function isGameClaimValid(IDisputeGame _game) external view returns (bool);
3039
function portal() external view returns (IOptimismPortal2);
31-
function setAnchorState(IFaultDisputeGame _game) external;
40+
function respectedGameType() external view returns (GameType);
41+
function setAnchorState(IDisputeGame _game) external;
3242
function superchainConfig() external view returns (ISuperchainConfig);
33-
function tryUpdateAnchorState() external;
3443
function version() external view returns (string memory);
3544

3645
function __constructor__() external;

packages/contracts-bedrock/interfaces/dispute/IDelayedWETH.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ interface IDelayedWETH {
1111

1212
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
1313
event Initialized(uint8 version);
14-
event Unwrap(address indexed src, uint256 wad);
1514

1615
fallback() external payable;
1716
receive() external payable;
1817

1918
function config() external view returns (ISuperchainConfig);
2019
function delay() external view returns (uint256);
20+
function hold(address _guy) external;
2121
function hold(address _guy, uint256 _wad) external;
2222
function initialize(address _owner, ISuperchainConfig _config) external;
2323
function owner() external view returns (address);

packages/contracts-bedrock/interfaces/dispute/IDisputeGame.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ interface IDisputeGame is IInitializable {
1414
function gameCreator() external pure returns (address creator_);
1515
function rootClaim() external pure returns (Claim rootClaim_);
1616
function l1Head() external pure returns (Hash l1Head_);
17+
function l2BlockNumber() external pure returns (uint256 l2BlockNumber_);
1718
function extraData() external pure returns (bytes memory extraData_);
1819
function resolve() external returns (GameStatus status_);
1920
function gameData() external view returns (GameType gameType_, Claim rootClaim_, bytes memory extraData_);
21+
function wasRespectedGameTypeWhenCreated() external view returns (bool);
2022
}

packages/contracts-bedrock/interfaces/dispute/IFaultDisputeGame.sol

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IDelayedWETH } from "interfaces/dispute/IDelayedWETH.sol";
66
import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol";
77
import { IBigStepper } from "interfaces/dispute/IBigStepper.sol";
88
import { Types } from "src/libraries/Types.sol";
9-
import { GameType, Claim, Position, Clock, Hash, Duration } from "src/dispute/lib/Types.sol";
9+
import { GameType, Claim, Position, Clock, Hash, Duration, BondDistributionMode } from "src/dispute/lib/Types.sol";
1010

1111
interface IFaultDisputeGame is IDisputeGame {
1212
struct ClaimData {
@@ -74,13 +74,19 @@ interface IFaultDisputeGame is IDisputeGame {
7474
error UnexpectedRootClaim(Claim rootClaim);
7575
error UnexpectedString();
7676
error ValidStep();
77+
error InvalidBondDistributionMode();
78+
error GameNotFinalized(string reason);
79+
error GameNotResolved();
80+
error ReservedGameType();
7781

7882
event Move(uint256 indexed parentIndex, Claim indexed claim, address indexed claimant);
83+
event GameClosed(BondDistributionMode bondDistributionMode);
7984

8085
function absolutePrestate() external view returns (Claim absolutePrestate_);
8186
function addLocalData(uint256 _ident, uint256 _execLeafIdx, uint256 _partOffset) external;
8287
function anchorStateRegistry() external view returns (IAnchorStateRegistry registry_);
8388
function attack(Claim _disputed, uint256 _parentIndex, Claim _claim) external payable;
89+
function bondDistributionMode() external view returns (BondDistributionMode);
8490
function challengeRootL2Block(Types.OutputRootProof memory _outputRootProof, bytes memory _headerRLP) external;
8591
function claimCredit(address _recipient) external;
8692
function claimData(uint256)
@@ -98,18 +104,21 @@ interface IFaultDisputeGame is IDisputeGame {
98104
function claimDataLen() external view returns (uint256 len_);
99105
function claims(Hash) external view returns (bool);
100106
function clockExtension() external view returns (Duration clockExtension_);
107+
function closeGame() external;
101108
function credit(address) external view returns (uint256);
102109
function defend(Claim _disputed, uint256 _parentIndex, Claim _claim) external payable;
103110
function getChallengerDuration(uint256 _claimIndex) external view returns (Duration duration_);
104111
function getNumToResolve(uint256 _claimIndex) external view returns (uint256 numRemainingChildren_);
105112
function getRequiredBond(Position _position) external view returns (uint256 requiredBond_);
113+
function hasUnlockedCredit(address) external view returns (bool);
106114
function l2BlockNumber() external pure returns (uint256 l2BlockNumber_);
107115
function l2BlockNumberChallenged() external view returns (bool);
108116
function l2BlockNumberChallenger() external view returns (address);
109117
function l2ChainId() external view returns (uint256 l2ChainId_);
110118
function maxClockDuration() external view returns (Duration maxClockDuration_);
111119
function maxGameDepth() external view returns (uint256 maxGameDepth_);
112120
function move(Claim _disputed, uint256 _challengeIndex, Claim _claim, bool _isAttack) external payable;
121+
function refundModeCredit(address) external view returns (uint256);
113122
function resolutionCheckpoints(uint256)
114123
external
115124
view
@@ -124,6 +133,7 @@ interface IFaultDisputeGame is IDisputeGame {
124133
function subgames(uint256, uint256) external view returns (uint256);
125134
function version() external view returns (string memory);
126135
function vm() external view returns (IBigStepper vm_);
136+
function wasRespectedGameTypeWhenCreated() external view returns (bool);
127137
function weth() external view returns (IDelayedWETH weth_);
128138

129139
function __constructor__(GameConstructorParams memory _params) external;

packages/contracts-bedrock/interfaces/dispute/IPermissionedDisputeGame.sol

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.0;
33

44
import { Types } from "src/libraries/Types.sol";
5-
import { Claim, Position, Clock, Hash, Duration } from "src/dispute/lib/Types.sol";
5+
import { Claim, Position, Clock, Hash, Duration, BondDistributionMode } from "src/dispute/lib/Types.sol";
66

77
import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol";
88
import { IDelayedWETH } from "interfaces/dispute/IDelayedWETH.sol";
@@ -63,13 +63,19 @@ interface IPermissionedDisputeGame is IDisputeGame {
6363
error UnexpectedRootClaim(Claim rootClaim);
6464
error UnexpectedString();
6565
error ValidStep();
66+
error InvalidBondDistributionMode();
67+
error GameNotFinalized(string reason);
68+
error GameNotResolved();
69+
error ReservedGameType();
6670

6771
event Move(uint256 indexed parentIndex, Claim indexed claim, address indexed claimant);
72+
event GameClosed(BondDistributionMode bondDistributionMode);
6873

6974
function absolutePrestate() external view returns (Claim absolutePrestate_);
7075
function addLocalData(uint256 _ident, uint256 _execLeafIdx, uint256 _partOffset) external;
7176
function anchorStateRegistry() external view returns (IAnchorStateRegistry registry_);
7277
function attack(Claim _disputed, uint256 _parentIndex, Claim _claim) external payable;
78+
function bondDistributionMode() external view returns (BondDistributionMode);
7379
function challengeRootL2Block(Types.OutputRootProof memory _outputRootProof, bytes memory _headerRLP) external;
7480
function claimCredit(address _recipient) external;
7581
function claimData(uint256)
@@ -87,18 +93,21 @@ interface IPermissionedDisputeGame is IDisputeGame {
8793
function claimDataLen() external view returns (uint256 len_);
8894
function claims(Hash) external view returns (bool);
8995
function clockExtension() external view returns (Duration clockExtension_);
96+
function closeGame() external;
9097
function credit(address) external view returns (uint256);
9198
function defend(Claim _disputed, uint256 _parentIndex, Claim _claim) external payable;
9299
function getChallengerDuration(uint256 _claimIndex) external view returns (Duration duration_);
93100
function getNumToResolve(uint256 _claimIndex) external view returns (uint256 numRemainingChildren_);
94101
function getRequiredBond(Position _position) external view returns (uint256 requiredBond_);
102+
function hasUnlockedCredit(address) external view returns (bool);
95103
function l2BlockNumber() external pure returns (uint256 l2BlockNumber_);
96104
function l2BlockNumberChallenged() external view returns (bool);
97105
function l2BlockNumberChallenger() external view returns (address);
98106
function l2ChainId() external view returns (uint256 l2ChainId_);
99107
function maxClockDuration() external view returns (Duration maxClockDuration_);
100108
function maxGameDepth() external view returns (uint256 maxGameDepth_);
101109
function move(Claim _disputed, uint256 _challengeIndex, Claim _claim, bool _isAttack) external payable;
110+
function refundModeCredit(address) external view returns (uint256);
102111
function resolutionCheckpoints(uint256)
103112
external
104113
view
@@ -113,6 +122,7 @@ interface IPermissionedDisputeGame is IDisputeGame {
113122
function subgames(uint256, uint256) external view returns (uint256);
114123
function version() external view returns (string memory);
115124
function vm() external view returns (IBigStepper vm_);
125+
function wasRespectedGameTypeWhenCreated() external view returns (bool);
116126
function weth() external view returns (IDelayedWETH weth_);
117127

118128
error BadAuth();

packages/contracts-bedrock/snapshots/abi/AnchorStateRegistry.json

Lines changed: 101 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,25 @@
112112
"stateMutability": "nonpayable",
113113
"type": "function"
114114
},
115+
{
116+
"inputs": [
117+
{
118+
"internalType": "contract IDisputeGame",
119+
"name": "_game",
120+
"type": "address"
121+
}
122+
],
123+
"name": "isGameBeyondAirgap",
124+
"outputs": [
125+
{
126+
"internalType": "bool",
127+
"name": "",
128+
"type": "bool"
129+
}
130+
],
131+
"stateMutability": "view",
132+
"type": "function"
133+
},
115134
{
116135
"inputs": [
117136
{
@@ -131,6 +150,54 @@
131150
"stateMutability": "view",
132151
"type": "function"
133152
},
153+
{
154+
"inputs": [
155+
{
156+
"internalType": "contract IDisputeGame",
157+
"name": "_game",
158+
"type": "address"
159+
}
160+
],
161+
"name": "isGameClaimValid",
162+
"outputs": [
163+
{
164+
"internalType": "bool",
165+
"name": "",
166+
"type": "bool"
167+
},
168+
{
169+
"internalType": "string",
170+
"name": "",
171+
"type": "string"
172+
}
173+
],
174+
"stateMutability": "view",
175+
"type": "function"
176+
},
177+
{
178+
"inputs": [
179+
{
180+
"internalType": "contract IDisputeGame",
181+
"name": "_game",
182+
"type": "address"
183+
}
184+
],
185+
"name": "isGameFinalized",
186+
"outputs": [
187+
{
188+
"internalType": "bool",
189+
"name": "",
190+
"type": "bool"
191+
},
192+
{
193+
"internalType": "string",
194+
"name": "",
195+
"type": "string"
196+
}
197+
],
198+
"stateMutability": "view",
199+
"type": "function"
200+
},
134201
{
135202
"inputs": [
136203
{
@@ -169,6 +236,25 @@
169236
"stateMutability": "view",
170237
"type": "function"
171238
},
239+
{
240+
"inputs": [
241+
{
242+
"internalType": "contract IDisputeGame",
243+
"name": "_game",
244+
"type": "address"
245+
}
246+
],
247+
"name": "isGameResolved",
248+
"outputs": [
249+
{
250+
"internalType": "bool",
251+
"name": "",
252+
"type": "bool"
253+
}
254+
],
255+
"stateMutability": "view",
256+
"type": "function"
257+
},
172258
{
173259
"inputs": [
174260
{
@@ -220,10 +306,23 @@
220306
"stateMutability": "view",
221307
"type": "function"
222308
},
309+
{
310+
"inputs": [],
311+
"name": "respectedGameType",
312+
"outputs": [
313+
{
314+
"internalType": "GameType",
315+
"name": "",
316+
"type": "uint32"
317+
}
318+
],
319+
"stateMutability": "view",
320+
"type": "function"
321+
},
223322
{
224323
"inputs": [
225324
{
226-
"internalType": "contract IFaultDisputeGame",
325+
"internalType": "contract IDisputeGame",
227326
"name": "_game",
228327
"type": "address"
229328
}
@@ -246,13 +345,6 @@
246345
"stateMutability": "view",
247346
"type": "function"
248347
},
249-
{
250-
"inputs": [],
251-
"name": "tryUpdateAnchorState",
252-
"outputs": [],
253-
"stateMutability": "nonpayable",
254-
"type": "function"
255-
},
256348
{
257349
"inputs": [],
258350
"name": "version",
@@ -320,4 +412,4 @@
320412
"name": "AnchorStateRegistry_Unauthorized",
321413
"type": "error"
322414
}
323-
]
415+
]

packages/contracts-bedrock/snapshots/abi/DelayedWETH.json

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@
149149
"stateMutability": "nonpayable",
150150
"type": "function"
151151
},
152+
{
153+
"inputs": [
154+
{
155+
"internalType": "address",
156+
"name": "_guy",
157+
"type": "address"
158+
}
159+
],
160+
"name": "hold",
161+
"outputs": [],
162+
"stateMutability": "nonpayable",
163+
"type": "function"
164+
},
152165
{
153166
"inputs": [
154167
{
@@ -497,25 +510,6 @@
497510
"name": "Transfer",
498511
"type": "event"
499512
},
500-
{
501-
"anonymous": false,
502-
"inputs": [
503-
{
504-
"indexed": true,
505-
"internalType": "address",
506-
"name": "src",
507-
"type": "address"
508-
},
509-
{
510-
"indexed": false,
511-
"internalType": "uint256",
512-
"name": "wad",
513-
"type": "uint256"
514-
}
515-
],
516-
"name": "Unwrap",
517-
"type": "event"
518-
},
519513
{
520514
"anonymous": false,
521515
"inputs": [

0 commit comments

Comments
 (0)