Skip to content

Commit 87a3a95

Browse files
various logical tweaks
1 parent d1a1379 commit 87a3a95

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

packages/contracts-bedrock/snapshots/semver-lock.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
"sourceCodeHash": "0x2d21506cc51ebe0b60bcf89883aff5e9b1269567ce44ee779de3d3940e23fb65"
2121
},
2222
"src/L1/OptimismPortal2.sol": {
23-
"initCodeHash": "0x94c880ae1974be774ec956ed2d9f8d71c19ba500d47abe28856ea8a019dc9c3f",
24-
"sourceCodeHash": "0x99ab9155cd18ee2bbab440431923f944a89535670546bfaa01e637eadb0342b8"
23+
"initCodeHash": "0xb906cca6c1d2ef7d783f94d502bbf8704f39488bcbe4b1633f21d5a25f39d750",
24+
"sourceCodeHash": "0x2fa2648a82059eb6fc052254678d3bd2bf7952be83ab53c545c9302df3b9d1a0"
2525
},
2626
"src/L1/OptimismPortalInterop.sol": {
27-
"initCodeHash": "0x529e192525bc0f28b4402439af1defcf5407016b44a3eda2da5a6260b31779e2",
27+
"initCodeHash": "0x92e46899517ecb927a6fea35995ebf6cc534443351d1f5806a7d34c5696c0648",
2828
"sourceCodeHash": "0xc04a7f9c14a13ec3587f5cc351c8e9f27fbbe9f1291a1aba07de29edbeef418a"
2929
},
3030
"src/L1/ProtocolVersions.sol": {
@@ -152,8 +152,8 @@
152152
"sourceCodeHash": "0xb7b0a06cd971c4647247dc19ce997d0c64a73e87c81d30731da9cf9efa1b952a"
153153
},
154154
"src/dispute/AnchorStateRegistry.sol": {
155-
"initCodeHash": "0x8d04e8c4185388170beabec3de6380628d5f41869e96655322685e33c3541dd9",
156-
"sourceCodeHash": "0x27100c19acf49ffa999baf8f5e5dd1e8f8455e65a51c27d2e949220d0a07ac3b"
155+
"initCodeHash": "0xf7b9422d4c0b175aed8fad9ac4e03054625a667cff837a9a13612ec3bb2ee936",
156+
"sourceCodeHash": "0xe355003779215d2c9d8c55e84c3e8b984a2c284da6b222de0874722bc71fe598"
157157
},
158158
"src/dispute/DelayedWETH.sol": {
159159
"initCodeHash": "0xb1f04c9ee86984a157b92a18754c84104e9d4df7a3838633301ca7f557d0220a",

packages/contracts-bedrock/src/L1/OptimismPortal2.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,18 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
308308
// The game type of the dispute game must be the respected game type.
309309
if (gameType.raw() != respectedGameType.raw()) revert InvalidGameType();
310310

311+
// The game type of the DisputeGame must have been the respected game type at creation.
312+
if (!gameProxy.wasRespectedGameTypeWhenCreated()) revert InvalidGameType();
313+
314+
// Creation time must be greater than or equal to the respected game type updated time.
315+
// Games created before this timestamp are not valid and cannot be used to finalize a
316+
// withdrawal, so for user convenience we also prevent them from being used to prove a
317+
// withdrawal.
318+
require(
319+
gameProxy.createdAt().raw() >= respectedGameTypeUpdatedAt,
320+
"OptimismPortal: dispute game created before respected game type was updated"
321+
);
322+
311323
// Verify that the output root can be generated with the elements in the proof.
312324
if (outputRoot.raw() != Hashing.hashOutputRootProof(_outputRootProof)) revert InvalidProof();
313325

packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,12 @@ contract AnchorStateRegistry is Initializable, ISemver {
172172
/// invalidation conditions. The root claim of a proper game IS NOT guaranteed to be
173173
/// valid. The root claim of a proper game CAN BE incorrect and still be a proper game.
174174
/// DO NOT USE THIS FUNCTION ALONE TO DETERMINE IF A ROOT CLAIM IS VALID.
175-
/// @dev Note that it is possible for games to be created when their game type is not the
176-
/// respected game type. We do not consider these games to be Proper Games. isGameProper()
177-
/// can currently guarantee this because the OptimismPortal contract will always set the
178-
/// retirement timestamp whenever the respected game type is updated such that any games
179-
/// created before any update of the respected game type are automatically retired. If
180-
/// this coupling is broken, then we must instead check that the game type *was* the
181-
/// respected game type at the time of the game's creation.
175+
/// @dev Note that isGameProper previously checked that the game type was equal to the
176+
/// respected game type. However, it should be noted that it is possible for a game other
177+
/// than the respected game type to resolve without being invalidated. Since isGameProper
178+
/// exists to determine if a game has (or has not) been invalidated, we now allow any game
179+
/// type to be considered a proper game. We enforce checks on the game type in
180+
/// isGameClaimValid().
182181
/// @param _game The game to check.
183182
/// @return Whether the game is a proper game.
184183
function isGameProper(IDisputeGame _game) public view returns (bool) {
@@ -187,11 +186,6 @@ contract AnchorStateRegistry is Initializable, ISemver {
187186
return false;
188187
}
189188

190-
// Must be respected game type.
191-
if (!isGameRespected(_game)) {
192-
return false;
193-
}
194-
195189
// Must not be blacklisted.
196190
if (isGameBlacklisted(_game)) {
197191
return false;
@@ -232,6 +226,12 @@ contract AnchorStateRegistry is Initializable, ISemver {
232226
return false;
233227
}
234228

229+
// Must be respected.
230+
bool respected = isGameRespected(_game);
231+
if (!respected) {
232+
return false;
233+
}
234+
235235
// Game must be finalized.
236236
bool finalized = isGameFinalized(_game);
237237
if (!finalized) {

packages/contracts-bedrock/test/dispute/AnchorStateRegistry.t.sol

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,7 @@ contract AnchorStateRegistry_IsGameRetired_Test is AnchorStateRegistry_Init {
236236
contract AnchorStateRegistry_IsGameProper_Test is AnchorStateRegistry_Init {
237237
/// @notice Tests that isGameProper will return true if the game meets all conditions.
238238
function test_isGameProper_meetsAllConditions_succeeds() public {
239-
// Mock that the game was respected.
240-
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.wasRespectedGameTypeWhenCreated, ()), abi.encode(true));
241-
239+
// Game will meet all conditions by default.
242240
assertTrue(anchorStateRegistry.isGameProper(gameProxy));
243241
}
244242

@@ -258,7 +256,7 @@ contract AnchorStateRegistry_IsGameProper_Test is AnchorStateRegistry_Init {
258256

259257
/// @notice Tests that isGameProper will return false if the game is not the respected game type.
260258
/// @param _gameType The game type to use for the test.
261-
function testFuzz_isGameProper_isNotRespected_succeeds(GameType _gameType) public {
259+
function testFuzz_isGameProper_anyGameType_succeeds(GameType _gameType) public {
262260
if (_gameType.raw() == gameProxy.gameType().raw()) {
263261
_gameType = GameType.wrap(_gameType.raw() + 1);
264262
}
@@ -268,7 +266,8 @@ contract AnchorStateRegistry_IsGameProper_Test is AnchorStateRegistry_Init {
268266
address(gameProxy), abi.encodeCall(gameProxy.wasRespectedGameTypeWhenCreated, ()), abi.encode(false)
269267
);
270268

271-
assertFalse(anchorStateRegistry.isGameProper(gameProxy));
269+
// Still a proper game.
270+
assertTrue(anchorStateRegistry.isGameProper(gameProxy));
272271
}
273272

274273
/// @notice Tests that isGameProper will return false if the game is blacklisted.

0 commit comments

Comments
 (0)