Commit f51a5553 authored by clabby's avatar clabby

Consolidate events

parent 21678e30
...@@ -27,19 +27,19 @@ CrossDomainOwnable_Test:test_onlyOwner_notOwner_reverts() (gas: 10597) ...@@ -27,19 +27,19 @@ CrossDomainOwnable_Test:test_onlyOwner_notOwner_reverts() (gas: 10597)
CrossDomainOwnable_Test:test_onlyOwner_succeeds() (gas: 34883) CrossDomainOwnable_Test:test_onlyOwner_succeeds() (gas: 34883)
DeployerWhitelist_Test:test_owner_succeeds() (gas: 7582) DeployerWhitelist_Test:test_owner_succeeds() (gas: 7582)
DeployerWhitelist_Test:test_storageSlots_succeeds() (gas: 33395) DeployerWhitelist_Test:test_storageSlots_succeeds() (gas: 33395)
DisputeGameFactory_Test:test_owner_succeeds() (gas: 7627) DisputeGameFactory_Test:test_owner_succeeds() (gas: 12610)
DisputeGameFactory_Test:test_setImplementation_notOwner_reverts() (gas: 11077) DisputeGameFactory_Test:test_setImplementation_notOwner_reverts() (gas: 16099)
DisputeGameFactory_Test:test_setImplementation_succeeds() (gas: 38320) DisputeGameFactory_Test:test_setImplementation_succeeds() (gas: 44302)
DisputeGameFactory_Test:test_transferOwnership_notOwner_reverts() (gas: 10979) DisputeGameFactory_Test:test_transferOwnership_notOwner_reverts() (gas: 15974)
DisputeGameFactory_Test:test_transferOwnership_succeeds() (gas: 13225) DisputeGameFactory_Test:test_transferOwnership_succeeds() (gas: 18694)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17456) FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17456)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17882) FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17882)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10315) FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10315)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8237) FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8237)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 17602) FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 17602)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8213) FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8213)
FaultDisputeGame_Test:test_simpleAttack_succeeds() (gas: 105905) FaultDisputeGame_Test:test_simpleAttack_succeeds() (gas: 105058)
FaultDisputeGame_Test:test_version_succeeds() (gas: 9736) FaultDisputeGame_Test:test_version_succeeds() (gas: 9758)
FeeVault_Test:test_constructor_succeeds() (gas: 18185) FeeVault_Test:test_constructor_succeeds() (gas: 18185)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 352135) GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 352135)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2950342) GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2950342)
......
...@@ -31,10 +31,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone { ...@@ -31,10 +31,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
/** /**
* @notice The max depth of the game. * @notice The max depth of the game.
* @dev TODO: Update this to the value that we will use in prod. Do we want to have the factory
* set this value? Should it be a constant?
*/ */
uint256 internal constant MAX_GAME_DEPTH = 4; uint256 internal constant MAX_GAME_DEPTH = 63;
/** /**
* @notice The duration of the game. * @notice The duration of the game.
...@@ -62,14 +60,6 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone { ...@@ -62,14 +60,6 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
*/ */
IBondManager public bondManager; IBondManager public bondManager;
/**
* @notice The left most, deepest position found during the resolution phase.
* @dev Defaults to the position of the root claim, but will be set during the resolution
* phase to the left most, deepest position found (if any qualify.)
* @dev TODO: Consider removing this if games can be resolved within a single block reliably.
*/
Position public leftMostPosition;
/** /**
* @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.
*/ */
...@@ -216,11 +206,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone { ...@@ -216,11 +206,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
); );
// Emit the appropriate event for the attack or defense. // Emit the appropriate event for the attack or defense.
if (isAttack) { emit Move(challengeIndex, pivot, msg.sender);
emit Attack(challengeIndex, pivot, msg.sender);
} else {
emit Defend(challengeIndex, pivot, msg.sender);
}
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -238,42 +224,14 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone { ...@@ -238,42 +224,14 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
* @inheritdoc IDisputeGame * @inheritdoc IDisputeGame
*/ */
function createdAt() external view returns (Timestamp _createdAt) { function createdAt() external view returns (Timestamp _createdAt) {
return gameStart; _createdAt = gameStart;
} }
/** /**
* @inheritdoc IDisputeGame * @inheritdoc IDisputeGame
*/ */
function resolve() external returns (GameStatus _status) { function resolve() external returns (GameStatus _status) {
// The game may only be resolved if it is currently in progress. // TODO - Resolve the game
if (status != GameStatus.IN_PROGRESS) {
revert GameNotInProgress();
}
// TODO: Block the game from being resolved if the preconditions for resolution have not
// been met.
// Fetch the final index of the claim data DAG.
uint256 i = claimData.length - 1;
// Store a variable on the stack to keep track of the left most, deepest claim found during
// the search.
Position leftMost;
// TODO - Resolution
// If the depth of the left most, deepest dangling claim is odd, the root was attacked
// successfully and the defender wins. Otherwise, the challenger wins.
if (LibPosition.depth(leftMost) % 2 == 0) {
_status = GameStatus.DEFENDER_WINS;
} else {
_status = GameStatus.CHALLENGER_WINS;
}
// Emit the `Resolved` event.
emit Resolved(_status);
// Store the resolved status of the game.
status = _status;
} }
/** /**
...@@ -316,6 +274,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone { ...@@ -316,6 +274,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
function initialize() external { function initialize() external {
// Set the game start // Set the game start
gameStart = Timestamp.wrap(uint64(block.timestamp)); gameStart = Timestamp.wrap(uint64(block.timestamp));
// Set the game status
status = GameStatus.IN_PROGRESS;
// Set the root claim // Set the root claim
claimData.push( claimData.push(
...@@ -332,7 +292,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone { ...@@ -332,7 +292,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
/** /**
* @inheritdoc IVersioned * @inheritdoc IVersioned
*/ */
function version() external pure override returns (string memory) { function version() external pure override returns (string memory _version) {
return VERSION; _version = VERSION;
} }
} }
...@@ -24,22 +24,12 @@ interface IFaultDisputeGame is IDisputeGame { ...@@ -24,22 +24,12 @@ interface IFaultDisputeGame is IDisputeGame {
} }
/** /**
* @notice Emitted when a subclaim is disagreed upon by `claimant` * @notice Emitted when a new claim is added to the DAG by `claimant`
* @dev Disagreeing with a subclaim is akin to attacking it.
* @param parentIndex The index within the `claimData` array of the parent claim * @param parentIndex The index within the `claimData` array of the parent claim
* @param pivot The claim for the following pivot (disagreement = go left) * @param pivot The claim being added
* @param claimant The address of the claimant * @param claimant The address of the claimant
*/ */
event Attack(uint256 indexed parentIndex, Claim indexed pivot, address indexed claimant); event Move(uint256 indexed parentIndex, Claim indexed pivot, address indexed claimant);
/**
* @notice Emitted when a subclaim is agreed upon by `claimant`
* @dev Agreeing with a subclaim is akin to defending it.
* @param parentIndex The index within the `claimData` array of the parent claim
* @param pivot The claim for the following pivot (agreement = go right)
* @param claimant The address of the claimant
*/
event Defend(uint256 indexed parentIndex, Claim indexed pivot, address indexed claimant);
/** /**
* Attack a disagreed upon `Claim`. * Attack a disagreed upon `Claim`.
......
...@@ -42,7 +42,8 @@ contract FaultDisputeGame_Test is Test { ...@@ -42,7 +42,8 @@ contract FaultDisputeGame_Test is Test {
function setUp() public { function setUp() public {
// Deploy a new dispute game factory. // Deploy a new dispute game factory.
factory = new DisputeGameFactory(address(this)); factory = new DisputeGameFactory();
factory.initialize(address(this));
// Deploy an implementation of the fault game // Deploy an implementation of the fault game
gameImpl = new FaultDisputeGame(); gameImpl = new FaultDisputeGame();
// Register the game implementation with the factory. // Register the game implementation with the factory.
......
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