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
a8941d5a
Commit
a8941d5a
authored
Jun 20, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`LibPosition::rightIndex` update
parent
b4d628a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
8 deletions
+7
-8
FaultDisputeGame.sol
.../contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
+4
-4
LibPosition.sol
...s/contracts-bedrock/contracts/dispute/lib/LibPosition.sol
+1
-1
LibPosition.t.sol
packages/contracts-bedrock/contracts/test/LibPosition.t.sol
+2
-3
No files found.
packages/contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
View file @
a8941d5a
...
@@ -154,7 +154,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
...
@@ -154,7 +154,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
}
}
// Assert that the given prestate commits to the instruction at `gindex - 1`.
// Assert that the given prestate commits to the instruction at `gindex - 1`.
if (
preStatePos.rightIndex(MAX_GAME_DEPTH
) != Position.unwrap(stepPos) - 1) {
if (
Position.unwrap(preStatePos.rightIndex(MAX_GAME_DEPTH)
) != Position.unwrap(stepPos) - 1) {
revert InvalidPrestate();
revert InvalidPrestate();
}
}
}
}
...
@@ -304,7 +304,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
...
@@ -304,7 +304,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
// Search for the left-most dangling non-bottom node
// Search for the left-most dangling non-bottom node
// The most recent claim is always a dangling, non-bottom node so we start with that
// The most recent claim is always a dangling, non-bottom node so we start with that
uint256 leftMostIndex = claimData.length - 1;
uint256 leftMostIndex = claimData.length - 1;
uint256
leftMostTraceIndex = claimData[leftMostIndex].position.rightIndex(MAX_GAME_DEPTH);
Position
leftMostTraceIndex = claimData[leftMostIndex].position.rightIndex(MAX_GAME_DEPTH);
for (uint256 i = leftMostIndex; i < type(uint64).max; ) {
for (uint256 i = leftMostIndex; i < type(uint64).max; ) {
// Fetch the claim at the current index.
// Fetch the claim at the current index.
ClaimData storage claim = claimData[i];
ClaimData storage claim = claimData[i];
...
@@ -325,8 +325,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
...
@@ -325,8 +325,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
// If the claim is a dangling node, we can check if it is the left-most
// 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
// dangling node we've come across so far. If it is, we can update the
// left-most trace index.
// left-most trace index.
uint256
traceIndex = claimPos.rightIndex(MAX_GAME_DEPTH);
Position
traceIndex = claimPos.rightIndex(MAX_GAME_DEPTH);
if (
traceIndex < leftMostTraceIndex
) {
if (
Position.unwrap(traceIndex) < Position.unwrap(leftMostTraceIndex)
) {
leftMostTraceIndex = traceIndex;
leftMostTraceIndex = traceIndex;
leftMostIndex = i + 1;
leftMostIndex = i + 1;
}
}
...
...
packages/contracts-bedrock/contracts/dispute/lib/LibPosition.sol
View file @
a8941d5a
...
@@ -99,7 +99,7 @@ library LibPosition {
...
@@ -99,7 +99,7 @@ library LibPosition {
function rightIndex(
function rightIndex(
Position _position,
Position _position,
uint256 _maxDepth
uint256 _maxDepth
) internal pure returns (
uint64
rightIndex_) {
) internal pure returns (
Position
rightIndex_) {
uint256 msb = depth(_position);
uint256 msb = depth(_position);
assembly {
assembly {
switch eq(msb, _maxDepth)
switch eq(msb, _maxDepth)
...
...
packages/contracts-bedrock/contracts/test/LibPosition.t.sol
View file @
a8941d5a
...
@@ -105,15 +105,14 @@ contract LibPosition_Test is Test {
...
@@ -105,15 +105,14 @@ contract LibPosition_Test is Test {
_indexAtDepth = boundIndexAtDepth(_depth, _indexAtDepth);
_indexAtDepth = boundIndexAtDepth(_depth, _indexAtDepth);
Position position = LibPosition.wrap(_depth, _indexAtDepth);
Position position = LibPosition.wrap(_depth, _indexAtDepth);
uint64
rightIndex = position.rightIndex(_maxDepth);
Position
rightIndex = position.rightIndex(_maxDepth);
// Find the deepest, rightmost index in Solidity rather than Yul
// Find the deepest, rightmost index in Solidity rather than Yul
for (uint256 i = _depth; i < _maxDepth; ++i) {
for (uint256 i = _depth; i < _maxDepth; ++i) {
position = position.right();
position = position.right();
}
}
uint64 _rightIndex = position.indexAtDepth();
assertEq(
rightIndex, _rightIndex
);
assertEq(
Position.unwrap(rightIndex), Position.unwrap(position)
);
}
}
/**
/**
...
...
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