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
4e790847
Commit
4e790847
authored
Jun 20, 2023
by
Inphi
Committed by
inphi
Jun 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update packages/contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
Co-authored-by:
clabby
<
ben@clab.by
>
parent
b36be771
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
FaultDisputeGame.sol
.../contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
+28
-12
No files found.
packages/contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
View file @
4e790847
...
...
@@ -230,28 +230,44 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
claimData[leftMostIndex].position,
MAX_GAME_DEPTH
);
int256 length = int256(claimData.length);
for (int256 i = length - 1; i >= 0; i--) {
ClaimData memory claim = claimData[uint256(i)];
if (LibPosition.depth(claim.position) >= MAX_GAME_DEPTH) {
continue;
for (uint256 i = leftMostIndex; i < type(uint64).max; ) {
// Fetch the claim at the current index.
ClaimData storage claim = claimData[i];
// Decrement the loop counter; If it underflows, we've reached the root
// claim and can stop searching.
unchecked {
--i;
}
if (claim.countered) {
// If the claim is not a dangling node above the bottom of the tree,
// we can skip over it. These nodes are not relevant to the game resolution.
Position claimPos = claim.position;
if (LibPosition.depth(claimPos) == MAX_GAME_DEPTH || claim.countered) {
continue;
}
uint256 traceIndex = LibPosition.rightIndex(claim.position, MAX_GAME_DEPTH);
// If the claim is a dangling node, we can check if it is the left-most
// dangling node we've come across so far. If it is, we can update the
// left-most trace index.
uint256 traceIndex = LibPosition.rightIndex(claimPos, MAX_GAME_DEPTH);
if (traceIndex < leftMostTraceIndex) {
leftMostTraceIndex = traceIndex;
leftMostIndex = i + 1;
}
}
ClaimData memory winner = claimData[leftMostIndex];
if (LibPosition.depth(winner.position) % 2 == 0) {
status = GameStatus.DEFENDER_WINS;
// If the left-most dangling node is at an even depth, the defender wins.
// Otherwise, the challenger wins and the root claim is deemed invalid.
if (LibPosition.depth(claimData[leftMostIndex].position) % 2 == 0) {
status_ = GameStatus.DEFENDER_WINS;
} else {
status = GameStatus.CHALLENGER_WINS;
status
_
= GameStatus.CHALLENGER_WINS;
}
status_ = status;
// Update the game status
status = status_;
emit Resolved(status_);
}
/**
...
...
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