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
26f490d7
Unverified
Commit
26f490d7
authored
Jun 19, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into cannon
parents
7842c3a7
e8cdf4e4
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
38 deletions
+43
-38
Dockerfile
ops/docker/ci-builder/Dockerfile
+1
-2
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+4
-4
FaultDisputeGame.sol
.../contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
+5
-7
DisputeTypes.sol
...es/contracts-bedrock/contracts/libraries/DisputeTypes.sol
+8
-0
FaultDisputeGame.t.sol
...s/contracts-bedrock/contracts/test/FaultDisputeGame.t.sol
+1
-1
LibClock.t.sol
packages/contracts-bedrock/contracts/test/LibClock.t.sol
+2
-2
LibPosition.t.sol
packages/contracts-bedrock/contracts/test/LibPosition.t.sol
+20
-20
package.json
packages/contracts-bedrock/package.json
+2
-2
No files found.
ops/docker/ci-builder/Dockerfile
View file @
26f490d7
...
@@ -54,8 +54,7 @@ RUN apt-get update && \
...
@@ -54,8 +54,7 @@ RUN apt-get update && \
pip
install
slither-analyzer
==
0.9.3
&&
\
pip
install
slither-analyzer
==
0.9.3
&&
\
go
install
gotest.tools/gotestsum@latest
&&
\
go
install
gotest.tools/gotestsum@latest
&&
\
curl
-sSfL
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh
-s
--
-b
$(
go
env
GOPATH
)
/bin v1.48.0
&&
\
curl
-sSfL
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh
-s
--
-b
$(
go
env
GOPATH
)
/bin v1.48.0
&&
\
curl
-fLSs
https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | bash
&&
\
curl
-fLSs
https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | bash
chmod
+x /usr/local/bin/check-changed
RUN
echo
"downloading solidity compilers"
&&
\
RUN
echo
"downloading solidity compilers"
&&
\
curl
-o
solc-linux-amd64-v0.5.17+commit.d19bba13
-sL
https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.5.17+commit.d19bba13
&&
\
curl
-o
solc-linux-amd64-v0.5.17+commit.d19bba13
-sL
https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.5.17+commit.d19bba13
&&
\
...
...
packages/contracts-bedrock/.gas-snapshot
View file @
26f490d7
...
@@ -32,19 +32,19 @@ DisputeGameFactory_SetImplementation_Test:test_setImplementation_notOwner_revert
...
@@ -32,19 +32,19 @@ 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_Test:test_clockTimeExceeded_reverts() (gas: 264
68
)
FaultDisputeGame_Test:test_clockTimeExceeded_reverts() (gas: 264
74
)
FaultDisputeGame_Test:test_defendRoot_reverts() (gas: 13258)
FaultDisputeGame_Test:test_defendRoot_reverts() (gas: 13258)
FaultDisputeGame_Test:test_duplicateClaim_reverts() (gas: 1033
69
)
FaultDisputeGame_Test:test_duplicateClaim_reverts() (gas: 1033
81
)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17478)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17478)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17859)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17859)
FaultDisputeGame_Test:test_gameDepthExceeded_reverts() (gas: 590
6891
)
FaultDisputeGame_Test:test_gameDepthExceeded_reverts() (gas: 590
7275
)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10337)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10337)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8194)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8194)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 17580)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 17580)
FaultDisputeGame_Test:test_moveAgainstNonexistentParent_reverts() (gas: 24587)
FaultDisputeGame_Test:test_moveAgainstNonexistentParent_reverts() (gas: 24587)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 10945)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 10945)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8191)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8191)
FaultDisputeGame_Test:test_simpleAttack_succeeds() (gas: 10736
1
)
FaultDisputeGame_Test:test_simpleAttack_succeeds() (gas: 10736
7
)
FaultDisputeGame_Test:test_version_succeeds() (gas: 9780)
FaultDisputeGame_Test:test_version_succeeds() (gas: 9780)
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)
...
...
packages/contracts-bedrock/contracts/dispute/FaultDisputeGame.sol
View file @
26f490d7
...
@@ -136,14 +136,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
...
@@ -136,14 +136,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
// Compute the position that the claim commits to. Because the parent's position is already
// Compute the position that the claim commits to. Because the parent's position is already
// known, we can compute the next position by moving left or right depending on whether
// known, we can compute the next position by moving left or right depending on whether
// or not the move is an attack or defense.
// or not the move is an attack or defense.
Position nextPosition = _isAttack
Position nextPosition = _isAttack ? parent.position.attack() : parent.position.defend();
? LibPosition.attack(parent.position)
: LibPosition.defend(parent.position);
// At the leaf nodes of the game, the only option is to run a step to prove or disprove
// At the leaf nodes of the game, the only option is to run a step to prove or disprove
// the above claim. At this depth, the parent claim commits to the state after a single
// the above claim. At this depth, the parent claim commits to the state after a single
// instruction step.
// instruction step.
if (
LibPosition.depth(nextPosition
) >= MAX_GAME_DEPTH) {
if (
nextPosition.depth(
) >= MAX_GAME_DEPTH) {
revert GameDepthExceeded();
revert GameDepthExceeded();
}
}
...
@@ -160,11 +158,11 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
...
@@ -160,11 +158,11 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
Duration nextDuration = Duration.wrap(
Duration nextDuration = Duration.wrap(
uint64(
uint64(
// First, fetch the duration of the grandparent claim.
// First, fetch the duration of the grandparent claim.
Duration.unwrap(
LibClock.duration(grandparentClock
)) +
Duration.unwrap(
grandparentClock.duration(
)) +
// Second, add the difference between the current block timestamp and the
// Second, add the difference between the current block timestamp and the
// parent's clock timestamp.
// parent's clock timestamp.
block.timestamp -
block.timestamp -
Timestamp.unwrap(
LibClock.timestamp(parent.clock
))
Timestamp.unwrap(
parent.clock.timestamp(
))
)
)
);
);
...
@@ -178,7 +176,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
...
@@ -178,7 +176,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone {
Clock nextClock = LibClock.wrap(nextDuration, Timestamp.wrap(uint64(block.timestamp)));
Clock nextClock = LibClock.wrap(nextDuration, Timestamp.wrap(uint64(block.timestamp)));
// Do not allow for a duplicate claim to be made.
// Do not allow for a duplicate claim to be made.
ClaimHash claimHash =
LibHashing.hashClaimPos(_pivot,
nextPosition);
ClaimHash claimHash =
_pivot.hashClaimPos(
nextPosition);
if (claims[claimHash]) {
if (claims[claimHash]) {
revert ClaimAlreadyExists();
revert ClaimAlreadyExists();
}
}
...
...
packages/contracts-bedrock/contracts/libraries/DisputeTypes.sol
View file @
26f490d7
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
pragma solidity ^0.8.15;
import { LibHashing } from "../dispute/lib/LibHashing.sol";
import { LibPosition } from "../dispute/lib/LibPosition.sol";
import { LibClock } from "../dispute/lib/LibClock.sol";
using LibHashing for Claim global;
using LibPosition for Position global;
using LibClock for Clock global;
/**
/**
* @notice A custom type for a generic hash.
* @notice A custom type for a generic hash.
*/
*/
...
...
packages/contracts-bedrock/contracts/test/FaultDisputeGame.t.sol
View file @
26f490d7
...
@@ -247,7 +247,7 @@ contract FaultDisputeGame_Test is DisputeGameFactory_Init {
...
@@ -247,7 +247,7 @@ contract FaultDisputeGame_Test is DisputeGameFactory_Init {
assertEq(parentIndex, 0);
assertEq(parentIndex, 0);
assertEq(countered, false);
assertEq(countered, false);
assertEq(Claim.unwrap(claim), Claim.unwrap(counter));
assertEq(Claim.unwrap(claim), Claim.unwrap(counter));
assertEq(Position.unwrap(position), Position.unwrap(
LibPosition.attack(Position.wrap(1)
)));
assertEq(Position.unwrap(position), Position.unwrap(
Position.wrap(1).attack(
)));
assertEq(
assertEq(
Clock.unwrap(clock),
Clock.unwrap(clock),
Clock.unwrap(LibClock.wrap(Duration.wrap(5), Timestamp.wrap(uint64(block.timestamp))))
Clock.unwrap(LibClock.wrap(Duration.wrap(5), Timestamp.wrap(uint64(block.timestamp))))
...
...
packages/contracts-bedrock/contracts/test/LibClock.t.sol
View file @
26f490d7
...
@@ -14,7 +14,7 @@ contract LibClock_Test is Test {
...
@@ -14,7 +14,7 @@ contract LibClock_Test is Test {
*/
*/
function testFuzz_duration_succeeds(Duration _duration, Timestamp _timestamp) public {
function testFuzz_duration_succeeds(Duration _duration, Timestamp _timestamp) public {
Clock clock = LibClock.wrap(_duration, _timestamp);
Clock clock = LibClock.wrap(_duration, _timestamp);
assertEq(Duration.unwrap(
LibClock.duration(clock
)), Duration.unwrap(_duration));
assertEq(Duration.unwrap(
clock.duration(
)), Duration.unwrap(_duration));
}
}
/**
/**
...
@@ -22,6 +22,6 @@ contract LibClock_Test is Test {
...
@@ -22,6 +22,6 @@ contract LibClock_Test is Test {
*/
*/
function testFuzz_timestamp_succeeds(Duration _duration, Timestamp _timestamp) public {
function testFuzz_timestamp_succeeds(Duration _duration, Timestamp _timestamp) public {
Clock clock = LibClock.wrap(_duration, _timestamp);
Clock clock = LibClock.wrap(_duration, _timestamp);
assertEq(Timestamp.unwrap(
LibClock.timestamp(clock
)), Timestamp.unwrap(_timestamp));
assertEq(Timestamp.unwrap(
clock.timestamp(
)), Timestamp.unwrap(_timestamp));
}
}
}
}
packages/contracts-bedrock/contracts/test/LibPosition.t.sol
View file @
26f490d7
...
@@ -32,7 +32,7 @@ contract LibPosition_Test is Test {
...
@@ -32,7 +32,7 @@ contract LibPosition_Test is Test {
_depth = uint8(bound(_depth, 0, MAX_DEPTH));
_depth = uint8(bound(_depth, 0, MAX_DEPTH));
_indexAtDepth = boundIndexAtDepth(_depth, _indexAtDepth);
_indexAtDepth = boundIndexAtDepth(_depth, _indexAtDepth);
Position position = LibPosition.wrap(_depth, _indexAtDepth);
Position position = LibPosition.wrap(_depth, _indexAtDepth);
assertEq(
LibPosition.depth(position
), _depth);
assertEq(
position.depth(
), _depth);
}
}
/**
/**
...
@@ -42,7 +42,7 @@ contract LibPosition_Test is Test {
...
@@ -42,7 +42,7 @@ contract LibPosition_Test is Test {
_depth = uint8(bound(_depth, 0, MAX_DEPTH));
_depth = uint8(bound(_depth, 0, MAX_DEPTH));
_indexAtDepth = boundIndexAtDepth(_depth, _indexAtDepth);
_indexAtDepth = boundIndexAtDepth(_depth, _indexAtDepth);
Position position = LibPosition.wrap(_depth, _indexAtDepth);
Position position = LibPosition.wrap(_depth, _indexAtDepth);
assertEq(
LibPosition.indexAtDepth(position
), _indexAtDepth);
assertEq(
position.indexAtDepth(
), _indexAtDepth);
}
}
/**
/**
...
@@ -53,10 +53,10 @@ contract LibPosition_Test is Test {
...
@@ -53,10 +53,10 @@ 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);
Position left =
LibPosition.left(position
);
Position left =
position.left(
);
assertEq(
LibPosition.depth(left
), uint64(_depth) + 1);
assertEq(
left.depth(
), uint64(_depth) + 1);
assertEq(
LibPosition.indexAtDepth(left
), _indexAtDepth * 2);
assertEq(
left.indexAtDepth(
), _indexAtDepth * 2);
}
}
/**
/**
...
@@ -68,10 +68,10 @@ contract LibPosition_Test is Test {
...
@@ -68,10 +68,10 @@ 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);
Position right =
LibPosition.right(position
);
Position right =
position.right(
);
assertEq(
LibPosition.depth(right
), _depth + 1);
assertEq(
right.depth(
), _depth + 1);
assertEq(
LibPosition.indexAtDepth(right
), _indexAtDepth * 2 + 1);
assertEq(
right.indexAtDepth(
), _indexAtDepth * 2 + 1);
}
}
/**
/**
...
@@ -82,10 +82,10 @@ contract LibPosition_Test is Test {
...
@@ -82,10 +82,10 @@ 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);
Position parent =
LibPosition.parent(position
);
Position parent =
position.parent(
);
assertEq(
LibPosition.depth(parent
), _depth - 1);
assertEq(
parent.depth(
), _depth - 1);
assertEq(
LibPosition.indexAtDepth(parent
), _indexAtDepth / 2);
assertEq(
parent.indexAtDepth(
), _indexAtDepth / 2);
}
}
/**
/**
...
@@ -105,13 +105,13 @@ contract LibPosition_Test is Test {
...
@@ -105,13 +105,13 @@ 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 =
LibPosition.rightIndex(position,
_maxDepth);
uint64 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 =
LibPosition.right(position
);
position =
position.right(
);
}
}
uint64 _rightIndex =
LibPosition.indexAtDepth(position
);
uint64 _rightIndex =
position.indexAtDepth(
);
assertEq(rightIndex, _rightIndex);
assertEq(rightIndex, _rightIndex);
}
}
...
@@ -127,10 +127,10 @@ contract LibPosition_Test is Test {
...
@@ -127,10 +127,10 @@ 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);
Position attack =
LibPosition.attack(position
);
Position attack =
position.attack(
);
assertEq(
LibPosition.depth(attack
), _depth + 1);
assertEq(
attack.depth(
), _depth + 1);
assertEq(
LibPosition.indexAtDepth(attack
), _indexAtDepth * 2);
assertEq(
attack.indexAtDepth(
), _indexAtDepth * 2);
}
}
/**
/**
...
@@ -145,9 +145,9 @@ contract LibPosition_Test is Test {
...
@@ -145,9 +145,9 @@ 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);
Position defend =
LibPosition.defend(position
);
Position defend =
position.defend(
);
assertEq(
LibPosition.depth(defend
), _depth + 1);
assertEq(
defend.depth(
), _depth + 1);
assertEq(
LibPosition.indexAtDepth(defend
), ((_indexAtDepth / 2) * 2 + 1) * 2);
assertEq(
defend.indexAtDepth(
), ((_indexAtDepth / 2) * 2 + 1) * 2);
}
}
}
}
packages/contracts-bedrock/package.json
View file @
26f490d7
...
@@ -37,10 +37,10 @@
...
@@ -37,10 +37,10 @@
"clean"
:
"rm -rf ./dist ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./src/contract-artifacts.ts ./test-case-generator/fuzz"
,
"clean"
:
"rm -rf ./dist ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./src/contract-artifacts.ts ./test-case-generator/fuzz"
,
"lint:ts:check"
:
"eslint . --max-warnings=0"
,
"lint:ts:check"
:
"eslint . --max-warnings=0"
,
"lint:forge-tests:check"
:
"ts-node scripts/forge-test-names.ts"
,
"lint:forge-tests:check"
:
"ts-node scripts/forge-test-names.ts"
,
"lint:contracts:check"
:
"yarn solhint -f table 'contracts/**/
*.sol' && yarn prettier --check 'contracts/**/*
.sol' && yarn lint:forge-tests:check"
,
"lint:contracts:check"
:
"yarn solhint -f table 'contracts/**/
!(DisputeTypes).sol' && yarn prettier --check 'contracts/**/!(DisputeTypes)
.sol' && yarn lint:forge-tests:check"
,
"lint:check"
:
"yarn lint:contracts:check && yarn lint:ts:check"
,
"lint:check"
:
"yarn lint:contracts:check && yarn lint:ts:check"
,
"lint:ts:fix"
:
"eslint --fix ."
,
"lint:ts:fix"
:
"eslint --fix ."
,
"lint:contracts:fix"
:
"yarn solhint --fix 'contracts/**/
*.sol' && yarn prettier --write 'contracts/**/*
.sol'"
,
"lint:contracts:fix"
:
"yarn solhint --fix 'contracts/**/
!(DisputeTypes).sol' && yarn prettier --write 'contracts/**/!(DisputeTypes)
.sol'"
,
"lint:fix"
:
"yarn lint:contracts:fix && yarn lint:ts:fix"
,
"lint:fix"
:
"yarn lint:contracts:fix && yarn lint:ts:fix"
,
"lint"
:
"yarn lint:fix && yarn lint:check"
,
"lint"
:
"yarn lint:fix && yarn lint:check"
,
"typechain"
:
"typechain --target ethers-v5 --out-dir dist/types --glob 'artifacts/!(build-info)/**/+([a-zA-Z0-9_]).json'"
,
"typechain"
:
"typechain --target ethers-v5 --out-dir dist/types --glob 'artifacts/!(build-info)/**/+([a-zA-Z0-9_]).json'"
,
...
...
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