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
a7111f0f
Commit
a7111f0f
authored
Jun 21, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review changes
parent
f5191dc8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
29 deletions
+29
-29
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+8
-8
FaultDisputeGame.sol
.../contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
+11
-10
IFaultDisputeGame.sol
...edrock/contracts/dispute/interfaces/IFaultDisputeGame.sol
+2
-2
FaultDisputeGame.t.sol
...s/contracts-bedrock/contracts/test/FaultDisputeGame.t.sol
+8
-9
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
a7111f0f
...
...
@@ -32,12 +32,12 @@ DisputeGameFactory_SetImplementation_Test:test_setImplementation_notOwner_revert
DisputeGameFactory_SetImplementation_Test:test_setImplementation_succeeds() (gas: 44243)
DisputeGameFactory_TransferOwnership_Test:test_transferOwnership_notOwner_reverts() (gas: 15950)
DisputeGameFactory_TransferOwnership_Test:test_transferOwnership_succeeds() (gas: 18642)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 49
1297
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot:test_resolvesCorrectly_succeeds() (gas: 4
8457
2)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 4
88105
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot:test_resolvesCorrectly_succeeds() (gas: 48
138
0)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 49
7412
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot:test_resolvesCorrectly_succeeds() (gas: 4
9045
2)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 4
94220
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot:test_resolvesCorrectly_succeeds() (gas: 48
726
0)
FaultDisputeGame_Test:test_clockTimeExceeded_reverts() (gas: 26444)
FaultDisputeGame_Test:test_defendRoot_reverts() (gas: 132
58
)
FaultDisputeGame_Test:test_defendRoot_reverts() (gas: 132
81
)
FaultDisputeGame_Test:test_duplicateClaim_reverts() (gas: 103343)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17478)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17881)
...
...
@@ -45,13 +45,13 @@ FaultDisputeGame_Test:test_gameDepthExceeded_reverts() (gas: 407234)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10359)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8216)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 17669)
FaultDisputeGame_Test:test_moveAgainstNonexistentParent_reverts() (gas: 246
10
)
FaultDisputeGame_Test:test_moveAgainstNonexistentParent_reverts() (gas: 246
33
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 10901)
FaultDisputeGame_Test:test_resolve_challengeContested() (gas: 221
594
)
FaultDisputeGame_Test:test_resolve_challengeContested() (gas: 221
617
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 9657)
FaultDisputeGame_Test:test_resolve_rootContested() (gas: 106539)
FaultDisputeGame_Test:test_resolve_rootUncontested() (gas: 20173)
FaultDisputeGame_Test:test_resolve_teamDeathmatch() (gas: 392
370
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch() (gas: 392
416
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8225)
FaultDisputeGame_Test:test_simpleAttack_succeeds() (gas: 107438)
FaultDisputeGame_Test:test_version_succeeds() (gas: 9802)
...
...
packages/contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
View file @
a7111f0f
...
...
@@ -29,11 +29,6 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
*/
string internal constant VERSION = "0.0.2";
/**
* @notice The max depth of the game.
*/
uint256 internal constant MAX_GAME_DEPTH = 4;
/**
* @notice The duration of the game.
* @dev TODO: Account for resolution buffer. (?)
...
...
@@ -47,10 +42,15 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
/**
* @notice The absolute prestate of the instruction trace. This is a constant that is defined
* by the program that is being used to execute the trace
, in this case, Cannon
.
* by the program that is being used to execute the trace.
*/
Claim public immutable ABSOLUTE_PRESTATE;
/**
* @notice The max depth of the game.
*/
uint256 public immutable MAX_GAME_DEPTH;
/**
* @notice The starting timestamp of the game
*/
...
...
@@ -79,8 +79,9 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
/**
* @param _absolutePrestate The absolute prestate of the instruction trace.
*/
constructor(Claim _absolutePrestate) {
constructor(Claim _absolutePrestate
, uint256 _maxGameDepth
) {
ABSOLUTE_PRESTATE = _absolutePrestate;
MAX_GAME_DEPTH = _maxGameDepth;
}
////////////////////////////////////////////////////////////////
...
...
@@ -106,7 +107,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
*/
function step(
uint256 _stateIndex,
uint256 _
parent
Index,
uint256 _
claim
Index,
bool _isAttack,
bytes calldata,
bytes calldata
...
...
@@ -117,7 +118,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
}
// Get the parent. If it does not exist, the call will revert with OOB.
ClaimData storage parent = claimData[_
parent
Index];
ClaimData storage parent = claimData[_
claim
Index];
// Pull the parent position out of storage.
Position parentPos = parent.position;
...
...
@@ -136,7 +137,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
// If the step position's index at depth is 0, the prestate is the absolute prestate
// and the post state is the parent claim.
preStateClaim = ABSOLUTE_PRESTATE;
postStateClaim = claimData[_
parent
Index].claim;
postStateClaim = claimData[_
claim
Index].claim;
} else {
Position preStatePos;
if (_isAttack) {
...
...
packages/contracts-bedrock/contracts/dispute/interfaces/IFaultDisputeGame.sol
View file @
a7111f0f
...
...
@@ -52,14 +52,14 @@ interface IFaultDisputeGame is IDisputeGame {
* processor contract should be generic enough such that we can use different
* fault proof VMs (MIPS, RiscV5, etc.)
* @param _stateIndex The index of the pre/post state of the step within `claimData`.
* @param _
parentIndex The index of the parent
claim within `claimData`.
* @param _
claimIndex The index of the challenged
claim within `claimData`.
* @param _isAttack Whether or not the step is an attack or a defense.
* @param _stateData The stateData of the step is the preimage of the claim @ `prestateIndex`
* @param _proof Proof to access memory leaf nodes in the VM.
*/
function step(
uint256 _stateIndex,
uint256 _
parent
Index,
uint256 _
claim
Index,
bool _isAttack,
bytes calldata _stateData,
bytes calldata _proof
...
...
packages/contracts-bedrock/contracts/test/FaultDisputeGame.t.sol
View file @
a7111f0f
...
...
@@ -40,7 +40,7 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
function init(Claim rootClaim, Claim absolutePrestate) public {
super.setUp();
// Deploy an implementation of the fault game
gameImpl = new FaultDisputeGame(absolutePrestate);
gameImpl = new FaultDisputeGame(absolutePrestate
, 4
);
// Register the game implementation with the factory.
factory.setImplementation(GAME_TYPE, gameImpl);
// Create a new game.
...
...
@@ -353,14 +353,13 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
* `play` function can be overridden to change this behavior.
*/
contract GamePlayer {
uint256 internal constant MAX_DEPTH = 4;
bool public failedToStep;
FaultDisputeGame public gameProxy;
GamePlayer internal counterParty;
Vm internal vm;
bytes internal trace;
uint256 internal maxDepth;
/**
* @notice Initializes the player
...
...
@@ -373,11 +372,11 @@ contract GamePlayer {
gameProxy = _gameProxy;
counterParty = _counterParty;
vm = _vm;
maxDepth = _gameProxy.MAX_GAME_DEPTH();
}
/**
* @notice Perform the next move in the game.
* @dev This is very janky atm.
*/
function play(uint256 _parentIndex) public virtual {
// Grab the claim data at the parent index.
...
...
@@ -429,7 +428,7 @@ contract GamePlayer {
}
// If we are past the maximum depth, break the recursion and step.
if (movePos.depth() >
MAX_DEPTH
) {
if (movePos.depth() >
maxDepth
) {
// Perform a step.
uint256 stateIndex;
// First, we need to find the pre/post state index depending on whether we
...
...
@@ -444,7 +443,7 @@ contract GamePlayer {
// Walk up until the valid position that commits to the prestate's
// trace index is found.
while (
Position.unwrap(statePos.parent().rightIndex(
MAX_DEPTH
)) ==
Position.unwrap(statePos.parent().rightIndex(
maxDepth
)) ==
Position.unwrap(statePos)
) {
statePos = statePos.parent().parent().parent();
...
...
@@ -473,7 +472,7 @@ contract GamePlayer {
}
} else {
// Find the trace index that our next claim must commit to.
uint256 traceIndex = movePos.rightIndex(
MAX_DEPTH
).indexAtDepth();
uint256 traceIndex = movePos.rightIndex(
maxDepth
).indexAtDepth();
// Grab the claim that we need to make from the helper.
Claim ourClaim = claimAt(traceIndex);
...
...
@@ -511,7 +510,7 @@ contract GamePlayer {
* @notice Returns the player's claim that commits to a given gindex.
*/
function claimAt(Position _position) internal view returns (Claim claim_) {
return claimAt(_position.rightIndex(
MAX_DEPTH
).indexAtDepth());
return claimAt(_position.rightIndex(
maxDepth
).indexAtDepth());
}
/**
...
...
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