Commit ec2667bb authored by clabby's avatar clabby

Contract changes

parent 179aea69
...@@ -151,4 +151,4 @@ ...@@ -151,4 +151,4 @@
"initCodeHash": "0xb579792cbef7a862d60190712b3b5bc6b5ec8e2d0d4cc75a4ca9980490e3c238", "initCodeHash": "0xb579792cbef7a862d60190712b3b5bc6b5ec8e2d0d4cc75a4ca9980490e3c238",
"sourceCodeHash": "0xc5d4a62bcb4dfe1844c72d40b21375769004e9dc76f6f293ee1ecb35abe58a92" "sourceCodeHash": "0xc5d4a62bcb4dfe1844c72d40b21375769004e9dc76f6f293ee1ecb35abe58a92"
} }
} }
\ No newline at end of file
...@@ -65,7 +65,7 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver { ...@@ -65,7 +65,7 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
IBondManager public bondManager; IBondManager public bondManager;
/// @inheritdoc IOutputBisectionGame /// @inheritdoc IOutputBisectionGame
Hash public l1Head; Hash public settlementHead;
/// @notice An append-only array of all claims made during the dispute game. /// @notice An append-only array of all claims made during the dispute game.
ClaimData[] public claimData; ClaimData[] public claimData;
...@@ -290,8 +290,8 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver { ...@@ -290,8 +290,8 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
IPreimageOracle oracle = VM.oracle(); IPreimageOracle oracle = VM.oracle();
if (_ident == 1) { if (_ident == 1) {
// Load the L1 head hash // Load the settlement layer head hash
oracle.loadLocalData(_ident, uuid, Hash.unwrap(l1Head), 32, _partOffset); oracle.loadLocalData(_ident, uuid, Hash.unwrap(settlementHead), 32, _partOffset);
} else if (_ident == 2) { } else if (_ident == 2) {
// Load the starting proposal's output root. // Load the starting proposal's output root.
oracle.loadLocalData(_ident, uuid, Claim.unwrap(starting.claim), 32, _partOffset); oracle.loadLocalData(_ident, uuid, Claim.unwrap(starting.claim), 32, _partOffset);
...@@ -301,11 +301,11 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver { ...@@ -301,11 +301,11 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
} else if (_ident == 4) { } else if (_ident == 4) {
// Load the starting proposal's L2 block number as a big-endian uint64 in the // Load the starting proposal's L2 block number as a big-endian uint64 in the
// high order 8 bytes of the word. // high order 8 bytes of the word.
// TODO(clabby): +1? // TODO(clabby): +1? See TODO in natspec of `findStartingAndDisputedOutputs`
oracle.loadLocalData( oracle.loadLocalData(
_ident, _ident,
uuid, uuid,
bytes32(GENESIS_BLOCK_NUMBER + uint256(starting.position.indexAtDepth()) << 0xC0), bytes32(uint256(GENESIS_BLOCK_NUMBER + starting.position.indexAtDepth()) << 0xC0),
8, 8,
_partOffset _partOffset
); );
...@@ -444,11 +444,11 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver { ...@@ -444,11 +444,11 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
}) })
); );
// Persist the L1 head hash of the parent block. // Persist the settlement layer hash of the parent block.
// TODO(clabby): There may be a bug here - Do we just allow the dispute game to be invalid? We can // TODO(clabby): There may be a bug here - Do we just allow the dispute game to be invalid? We can
// always just create another, but it is possible to create a game where the data was not // always just create another, but it is possible to create a game where the data was not
// already available on L1. // already available on the settlement layer.
l1Head = Hash.wrap(blockhash(block.number - 1)); settlementHead = Hash.wrap(blockhash(block.number - 1));
} }
/// @notice Returns the length of the `claimData` array. /// @notice Returns the length of the `claimData` array.
...@@ -497,6 +497,10 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver { ...@@ -497,6 +497,10 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
/// @param _start The index within `claimData` of the claim to start searching from. /// @param _start The index within `claimData` of the claim to start searching from.
/// @return starting_ The starting, agreed upon output root claim. /// @return starting_ The starting, agreed upon output root claim.
/// @return disputed_ The disputed output root claim. /// @return disputed_ The disputed output root claim.
///
/// TODO: This function does not account for the case where the starting output root is the absolute
/// prestate. Need to determine whether or not the first leaf at the split depth is genesis or
/// block #1.
function findStartingAndDisputedOutputs(uint256 _start) function findStartingAndDisputedOutputs(uint256 _start)
internal internal
view view
...@@ -541,6 +545,7 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver { ...@@ -541,6 +545,7 @@ contract OutputBisectionGame is IOutputBisectionGame, Clone, ISemver {
// 2. If it was a defense, the starting output root is `claim`, and the disputed output root is // 2. If it was a defense, the starting output root is `claim`, and the disputed output root is
// elsewhere in the dag (it must commit to the block # index at depth of `outputPos + 1`). // elsewhere in the dag (it must commit to the block # index at depth of `outputPos + 1`).
if (wasAttack) { if (wasAttack) {
// See TODO in natspec.
starting_ = findTraceAncestor(Position.wrap(Position.unwrap(outputPos) - 1), claimIdx); starting_ = findTraceAncestor(Position.wrap(Position.unwrap(outputPos) - 1), claimIdx);
disputed_ = claimData[claimIdx]; disputed_ = claimData[claimIdx];
} else { } else {
......
...@@ -61,11 +61,8 @@ interface IOutputBisectionGame is IDisputeGame { ...@@ -61,11 +61,8 @@ interface IOutputBisectionGame is IDisputeGame {
/// @param _claimIndex The index of the subgame root claim to resolve. /// @param _claimIndex The index of the subgame root claim to resolve.
function resolveClaim(uint256 _claimIndex) external payable; function resolveClaim(uint256 _claimIndex) external payable;
/// @notice An L1 block hash that contains the disputed output root, fetched from the /// @notice An block hash on the settlement layer that contains the disputed output root.
/// `BlockOracle` and verified by referencing the timestamp associated with the function settlementHead() external view returns (Hash settlementHead_);
/// first L2 Output Proposal in the `L2OutputOracle` that contains the disputed
/// L2 block number.
function l1Head() external view returns (Hash l1Head_);
/// @notice The l2BlockNumber of the disputed output root in the `L2OutputOracle`. /// @notice The l2BlockNumber of the disputed output root in the `L2OutputOracle`.
function l2BlockNumber() external view returns (uint256 l2BlockNumber_); function l2BlockNumber() external view returns (uint256 l2BlockNumber_);
......
...@@ -23,8 +23,9 @@ contract OutputBisectionGame_Init is DisputeGameFactory_Init { ...@@ -23,8 +23,9 @@ contract OutputBisectionGame_Init is DisputeGameFactory_Init {
/// @dev The type of the game being tested. /// @dev The type of the game being tested.
GameType internal constant GAME_TYPE = GameType.wrap(0); GameType internal constant GAME_TYPE = GameType.wrap(0);
/// @dev The L2 Block Number for the game's proposed output (the root claim) /// @dev The L2 Block Number for the game's proposed output (the root claim)
uint256 internal constant L2_BLOCK_NUMBER = 0xFFFF; uint256 internal constant L2_BLOCK_NUMBER = 0x0a;
/// @dev The genesis block number configured for the output bisection portion of the game.
uint256 internal constant GENESIS_BLOCK_NUMBER = 0; uint256 internal constant GENESIS_BLOCK_NUMBER = 0;
/// @dev The implementation of the game. /// @dev The implementation of the game.
...@@ -45,15 +46,15 @@ contract OutputBisectionGame_Init is DisputeGameFactory_Init { ...@@ -45,15 +46,15 @@ contract OutputBisectionGame_Init is DisputeGameFactory_Init {
extraData = abi.encode(L2_BLOCK_NUMBER); extraData = abi.encode(L2_BLOCK_NUMBER);
// Deploy an implementation of the fault game // Deploy an implementation of the fault game
gameImpl = new OutputBisectionGame( gameImpl = new OutputBisectionGame({
GAME_TYPE, _gameType: GAME_TYPE,
absolutePrestate, _absolutePrestate: absolutePrestate,
GENESIS_BLOCK_NUMBER, _genesisBlockNumber: GENESIS_BLOCK_NUMBER,
4, _maxGameDepth: 2**3,
2, _splitDepth: 2**2,
Duration.wrap(7 days), _gameDuration: Duration.wrap(7 days),
new AlphabetVM(absolutePrestate) _vm: new AlphabetVM(absolutePrestate)
); });
// Register the game implementation with the factory. // Register the game implementation with the factory.
factory.setImplementation(GAME_TYPE, gameImpl); factory.setImplementation(GAME_TYPE, gameImpl);
// Create a new game. // Create a new game.
...@@ -128,7 +129,7 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init { ...@@ -128,7 +129,7 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init {
assertEq(Timestamp.unwrap(gameProxy.createdAt()), block.timestamp); assertEq(Timestamp.unwrap(gameProxy.createdAt()), block.timestamp);
// Assert that the blockhash provided is correct. // Assert that the blockhash provided is correct.
assertEq(Hash.unwrap(gameProxy.l1Head()), blockhash(block.number - 1)); assertEq(Hash.unwrap(gameProxy.settlementHead()), blockhash(block.number - 1));
} }
/// @dev Tests that a move while the game status is not `IN_PROGRESS` causes the call to revert /// @dev Tests that a move while the game status is not `IN_PROGRESS` causes the call to revert
...@@ -446,15 +447,16 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init { ...@@ -446,15 +447,16 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init {
/// @dev Tests that adding local data with an out of bounds identifier reverts. /// @dev Tests that adding local data with an out of bounds identifier reverts.
function testFuzz_addLocalData_oob_reverts(uint256 _ident) public { function testFuzz_addLocalData_oob_reverts(uint256 _ident) public {
// Get a claim below the split depth so that we can add local data for an execution trace subgame. // Get a claim below the split depth so that we can add local data for an execution trace subgame.
gameProxy.attack(0, Claim.wrap(bytes32(uint256(5)))); for (uint256 i; i < 4; i++) {
gameProxy.attack(1, Claim.wrap(bytes32(uint256(5)))); gameProxy.attack(i, Claim.wrap(bytes32(uint256(5))));
gameProxy.attack(2, ROOT_CLAIM); }
gameProxy.attack(4, ROOT_CLAIM);
// [1, 5] are valid local data identifiers. // [1, 5] are valid local data identifiers.
if (_ident <= 5) _ident = 0; if (_ident <= 5) _ident = 0;
vm.expectRevert(InvalidLocalIdent.selector); vm.expectRevert(InvalidLocalIdent.selector);
gameProxy.addLocalData(_ident, 3, 0); gameProxy.addLocalData(_ident, 5, 0);
} }
/// @dev Helper to get the localized key for an identifier in the context of the game proxy. /// @dev Helper to get the localized key for an identifier in the context of the game proxy.
......
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