Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
f51a5553
Commit
f51a5553
authored
Jun 14, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate events
parent
21678e30
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
69 deletions
+20
-69
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+7
-7
FaultDisputeGame.sol
.../contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
+8
-48
IFaultDisputeGame.sol
...edrock/contracts/dispute/interfaces/IFaultDisputeGame.sol
+3
-13
FaultDisputeGame.t.sol
...s/contracts-bedrock/contracts/test/FaultDisputeGame.t.sol
+2
-1
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
f51a5553
...
@@ -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: 1
1077
)
DisputeGameFactory_Test:test_setImplementation_notOwner_reverts() (gas: 1
6099
)
DisputeGameFactory_Test:test_setImplementation_succeeds() (gas:
38320
)
DisputeGameFactory_Test:test_setImplementation_succeeds() (gas:
44302
)
DisputeGameFactory_Test:test_transferOwnership_notOwner_reverts() (gas: 1
0979
)
DisputeGameFactory_Test:test_transferOwnership_notOwner_reverts() (gas: 1
5974
)
DisputeGameFactory_Test:test_transferOwnership_succeeds() (gas: 1
3225
)
DisputeGameFactory_Test:test_transferOwnership_succeeds() (gas: 1
8694
)
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: 105
905
)
FaultDisputeGame_Test:test_simpleAttack_succeeds() (gas: 105
058
)
FaultDisputeGame_Test:test_version_succeeds() (gas: 97
36
)
FaultDisputeGame_Test:test_version_succeeds() (gas: 97
58
)
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)
...
...
packages/contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
View file @
f51a5553
...
@@ -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;
}
}
}
}
packages/contracts-bedrock/contracts/dispute/interfaces/IFaultDisputeGame.sol
View file @
f51a5553
...
@@ -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`.
...
...
packages/contracts-bedrock/contracts/test/FaultDisputeGame.t.sol
View file @
f51a5553
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment