Commit 54f38642 authored by clabby's avatar clabby Committed by GitHub

Merge pull request #8608 from ethereum-optimism/cl/ctb/prevent-genesis-proposal

feat(ctb): Prevent an output proposal <= `GENESIS_BLOCK_NUMBER`
parents 3465ca70 b89f32ec
This diff is collapsed.
......@@ -100,8 +100,8 @@
"sourceCodeHash": "0xa995b54dce03ddf5c9c47451bd7181996b91398ad66b54ab0b8cbf582863a33e"
},
"src/dispute/OutputBisectionGame.sol": {
"initCodeHash": "0xd354d78579c42a9f0f8a8c9b5ef04f570fa3bd088f88102b431aca8d48fddaae",
"sourceCodeHash": "0x98f65f2f2f07a525d360eba87e624f1cb44c52326f3b3f2bf7b6ee41a7ec4a2c"
"initCodeHash": "0xe5799a4c06cf02fa1fba61129bd32d1a4b07df737a1f2b429b1acd7160093f0a",
"sourceCodeHash": "0xf95c7b1575988853b10d4ad2219a6031be27278add5073f3e96854f41f75ba62"
},
"src/legacy/DeployerWhitelist.sol": {
"initCodeHash": "0x8de80fb23b26dd9d849f6328e56ea7c173cd9e9ce1f05c9beea559d1720deb3d",
......
......@@ -6,8 +6,6 @@ import { IOutputBisectionGame } from "src/dispute/interfaces/IOutputBisectionGam
import { IInitializable } from "src/dispute/interfaces/IInitializable.sol";
import { IBondManager } from "src/dispute/interfaces/IBondManager.sol";
import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol";
import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
import { BlockOracle } from "src/dispute/BlockOracle.sol";
import { Clone } from "src/libraries/Clone.sol";
import { Types } from "src/libraries/Types.sol";
......@@ -83,8 +81,8 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
bool internal subgameAtRootResolved;
/// @notice Semantic version.
/// @custom:semver 0.0.15
string public constant version = "0.0.15";
/// @custom:semver 0.0.16
string public constant version = "0.0.16";
/// @param _gameType The type ID of the game.
/// @param _absolutePrestate The absolute prestate of the instruction trace.
......@@ -105,9 +103,8 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
Duration _gameDuration,
IBigStepper _vm
) {
// The split depth cannot be greater than or equal to the max game depth, and it must
// be even due to the constraint laid out in `verifyExecBisectionRoot`
if (_splitDepth >= _maxGameDepth || _splitDepth % 2 != 0) revert InvalidSplitDepth();
// The split depth cannot be greater than or equal to the max game depth.
if (_splitDepth >= _maxGameDepth) revert InvalidSplitDepth();
GAME_TYPE = _gameType;
ABSOLUTE_PRESTATE = _absolutePrestate;
......@@ -446,6 +443,13 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
//
// Implicit assumptions:
// - The `gameStatus` state variable defaults to 0, which is `GameStatus.IN_PROGRESS`
//
// Explicit checks:
// - An output root cannot be proposed at or before the genesis block.
// Do not allow the game to be initialized if the root claim corresponds to a block at or before the
// configured genesis block number.
if (l2BlockNumber() <= GENESIS_BLOCK_NUMBER) revert UnexpectedRootClaim(rootClaim());
// Set the game's starting timestamp
createdAt = Timestamp.wrap(uint64(block.timestamp));
......
......@@ -105,9 +105,7 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init {
////////////////////////////////////////////////////////////////
/// @dev Tests that the constructor of the `OutputBisectionGame` reverts when the `_splitDepth`
/// parameter is either:
/// 1. Greater than or equal to the `MAX_GAME_DEPTH`
/// 2. Odd
/// parameter is greater than or equal to the `MAX_GAME_DEPTH`
function test_constructor_wrongArgs_reverts(uint256 _splitDepth) public {
AlphabetVM2 alphabetVM = new AlphabetVM2(ABSOLUTE_PRESTATE);
......@@ -125,22 +123,6 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init {
_gameDuration: Duration.wrap(7 days),
_vm: alphabetVM
});
// Test that the constructor reverts when the `_splitDepth` parameter is odd.
_splitDepth = bound(_splitDepth, 0, 2 ** 3 - 1);
if (_splitDepth % 2 == 0) _splitDepth += 1;
vm.expectRevert(InvalidSplitDepth.selector);
new OutputBisectionGame({
_gameType: GAME_TYPE,
_absolutePrestate: ABSOLUTE_PRESTATE,
_maxGameDepth: 2 ** 3,
_genesisBlockNumber: 0,
_genesisOutputRoot: Hash.wrap(bytes32(0)),
_splitDepth: _splitDepth,
_gameDuration: Duration.wrap(7 days),
_vm: alphabetVM
});
}
/// @dev Tests that the game's root claim is set correctly.
......@@ -176,6 +158,16 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init {
// `IOutputBisectionGame` Implementation Tests //
////////////////////////////////////////////////////////////////
/// @dev Tests that the game cannot be initialized with an output root that commits to <= the configured genesis
/// block number
function testFuzz_initialize_cannotProposeGenesis_reverts(uint256 _blockNumber) public {
_blockNumber = bound(_blockNumber, 0, gameProxy.GENESIS_BLOCK_NUMBER());
Claim claim = _dummyClaim();
vm.expectRevert(abi.encodeWithSelector(UnexpectedRootClaim.selector, claim));
gameProxy = OutputBisectionGame(address(factory.create(GAME_TYPE, claim, abi.encode(_blockNumber))));
}
/// @dev Tests that the game is initialized with the correct data.
function test_initialize_correctData_succeeds() public {
// Assert that the root claim is initialized correctly.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment