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
29480e23
Commit
29480e23
authored
Jun 26, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose `move` & add `claimDataLen`
parent
c9395875
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
36 deletions
+36
-36
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+23
-23
FaultDisputeGame.sol
.../contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
+9
-4
FaultDisputeGame.t.sol
...s/contracts-bedrock/contracts/test/FaultDisputeGame.t.sol
+4
-9
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
29480e23
...
@@ -32,30 +32,30 @@ DisputeGameFactory_SetImplementation_Test:test_setImplementation_notOwner_revert
...
@@ -32,30 +32,30 @@ DisputeGameFactory_SetImplementation_Test:test_setImplementation_notOwner_revert
DisputeGameFactory_SetImplementation_Test:test_setImplementation_succeeds() (gas: 44243)
DisputeGameFactory_SetImplementation_Test:test_setImplementation_succeeds() (gas: 44243)
DisputeGameFactory_TransferOwnership_Test:test_transferOwnership_notOwner_reverts() (gas: 15950)
DisputeGameFactory_TransferOwnership_Test:test_transferOwnership_notOwner_reverts() (gas: 15950)
DisputeGameFactory_TransferOwnership_Test:test_transferOwnership_succeeds() (gas: 18642)
DisputeGameFactory_TransferOwnership_Test:test_transferOwnership_succeeds() (gas: 18642)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas:
502842
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas:
498826
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 50
4699
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 50
0705
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot:test_resolvesCorrectly_succeeds() (gas: 4
92706
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot:test_resolvesCorrectly_succeeds() (gas: 4
88169
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas:
501717
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas:
497701
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas:
503574
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas:
499580
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot:test_resolvesCorrectly_succeeds() (gas: 4
91581
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot:test_resolvesCorrectly_succeeds() (gas: 4
87044
)
FaultDisputeGame_Test:test_defendRoot_invalidMove_reverts() (gas: 132
50
)
FaultDisputeGame_Test:test_defendRoot_invalidMove_reverts() (gas: 132
94
)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 174
48
)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 174
26
)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17873)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17873)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 103
37
)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 103
15
)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 82
16
)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 82
38
)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 17
691
)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 17
713
)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 264
10
)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 264
32
)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 1032
31
)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 1032
75
)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 40
7967
)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 40
8100
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 109
23
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 109
68
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
32
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
98
)
FaultDisputeGame_Test:test_resolve_challengeContested() (gas: 221
068
)
FaultDisputeGame_Test:test_resolve_challengeContested() (gas: 221
135
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 96
57
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 96
35
)
FaultDisputeGame_Test:test_resolve_rootContested() (gas: 1061
20
)
FaultDisputeGame_Test:test_resolve_rootContested() (gas: 1061
43
)
FaultDisputeGame_Test:test_resolve_rootUncontested() (gas: 2362
4
)
FaultDisputeGame_Test:test_resolve_rootUncontested() (gas: 2362
5
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch() (gas: 391
731
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch() (gas: 391
864
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8
203
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8
159
)
FaultDisputeGame_Test:test_simpleAttack_succeeds() (gas: 1073
22
)
FaultDisputeGame_Test:test_simpleAttack_succeeds() (gas: 1073
88
)
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 @
29480e23
...
@@ -72,12 +72,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -72,12 +72,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @inheritdoc IFaultDisputeGame
/// @inheritdoc IFaultDisputeGame
function attack(uint256 _parentIndex, Claim _pivot) external payable {
function attack(uint256 _parentIndex, Claim _pivot) external payable {
_
move(_parentIndex, _pivot, true);
move(_parentIndex, _pivot, true);
}
}
/// @inheritdoc IFaultDisputeGame
/// @inheritdoc IFaultDisputeGame
function defend(uint256 _parentIndex, Claim _pivot) external payable {
function defend(uint256 _parentIndex, Claim _pivot) external payable {
_
move(_parentIndex, _pivot, false);
move(_parentIndex, _pivot, false);
}
}
/// @inheritdoc IFaultDisputeGame
/// @inheritdoc IFaultDisputeGame
...
@@ -162,11 +162,11 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -162,11 +162,11 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @param _challengeIndex The index of the claim being moved against.
/// @param _challengeIndex The index of the claim being moved against.
/// @param _pivot The claim at the next logical position in the game.
/// @param _pivot The claim at the next logical position in the game.
/// @param _isAttack Whether or not the move is an attack or defense.
/// @param _isAttack Whether or not the move is an attack or defense.
function
_
move(
function move(
uint256 _challengeIndex,
uint256 _challengeIndex,
Claim _pivot,
Claim _pivot,
bool _isAttack
bool _isAttack
)
internal
{
)
public
{
// Moves cannot be made unless the game is currently in progress.
// Moves cannot be made unless the game is currently in progress.
if (status != GameStatus.IN_PROGRESS) {
if (status != GameStatus.IN_PROGRESS) {
revert GameNotInProgress();
revert GameNotInProgress();
...
@@ -254,6 +254,11 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -254,6 +254,11 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
l2BlockNumber_ = _getArgUint256(0x20);
l2BlockNumber_ = _getArgUint256(0x20);
}
}
/// @notice Returns the length of the `claimData` array.
function claimDataLen() external view returns (uint256 len_) {
len_ = claimData.length;
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// `IDisputeGame` impl //
// `IDisputeGame` impl //
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
...
...
packages/contracts-bedrock/contracts/test/FaultDisputeGame.t.sol
View file @
29480e23
...
@@ -391,7 +391,7 @@ contract GamePlayer {
...
@@ -391,7 +391,7 @@ contract GamePlayer {
// Now, search for the index of the claim that commits to the prestate's trace
// Now, search for the index of the claim that commits to the prestate's trace
// index.
// index.
uint256 len = claimDataLen();
uint256 len =
gameProxy.
claimDataLen();
for (uint256 i = 0; i < len; i++) {
for (uint256 i = 0; i < len; i++) {
(, , , Position pos, ) = gameProxy.claimData(i);
(, , , Position pos, ) = gameProxy.claimData(i);
if (Position.unwrap(pos) == Position.unwrap(statePos)) {
if (Position.unwrap(pos) == Position.unwrap(statePos)) {
...
@@ -424,7 +424,7 @@ contract GamePlayer {
...
@@ -424,7 +424,7 @@ contract GamePlayer {
// Attack the parent claim.
// Attack the parent claim.
gameProxy.attack(_parentIndex, ourClaim);
gameProxy.attack(_parentIndex, ourClaim);
// Call out to our counter party to respond.
// Call out to our counter party to respond.
counterParty.play(claimDataLen() - 1);
counterParty.play(
gameProxy.
claimDataLen() - 1);
// If we have a second move position, attack the grandparent.
// If we have a second move position, attack the grandparent.
if (Position.unwrap(movePos2) != 0) {
if (Position.unwrap(movePos2) != 0) {
...
@@ -432,22 +432,17 @@ contract GamePlayer {
...
@@ -432,22 +432,17 @@ contract GamePlayer {
Claim ourGrandparentClaim = claimAt(grandparentPos.move(true));
Claim ourGrandparentClaim = claimAt(grandparentPos.move(true));
gameProxy.attack(grandparentIndex, ourGrandparentClaim);
gameProxy.attack(grandparentIndex, ourGrandparentClaim);
counterParty.play(claimDataLen() - 1);
counterParty.play(
gameProxy.
claimDataLen() - 1);
}
}
} else {
} else {
// Defend the parent claim.
// Defend the parent claim.
gameProxy.defend(_parentIndex, ourClaim);
gameProxy.defend(_parentIndex, ourClaim);
// Call out to our counter party to respond.
// Call out to our counter party to respond.
counterParty.play(claimDataLen() - 1);
counterParty.play(
gameProxy.
claimDataLen() - 1);
}
}
}
}
}
}
/// @notice Returns the length of the claim data array.
function claimDataLen() internal view returns (uint256 len_) {
return uint256(vm.load(address(gameProxy), bytes32(uint256(1))));
}
/// @notice Returns the state at the trace index within the player's trace.
/// @notice Returns the state at the trace index within the player's trace.
function traceAt(Position _position) public view returns (uint256 state_) {
function traceAt(Position _position) public view returns (uint256 state_) {
return traceAt(_position.traceIndex(maxDepth));
return traceAt(_position.traceIndex(maxDepth));
...
...
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