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
41dff4ad
Commit
41dff4ad
authored
Jul 20, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add L2OO output root fetching
parent
25876600
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
104 additions
and
47 deletions
+104
-47
faultdisputegame.go
op-bindings/bindings/faultdisputegame.go
+35
-4
faultdisputegame_more.go
op-bindings/bindings/faultdisputegame_more.go
+1
-1
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+22
-22
Deploy.s.sol
packages/contracts-bedrock/scripts/Deploy.s.sol
+2
-1
PreimageKeyLib.sol
packages/contracts-bedrock/src/cannon/PreimageKeyLib.sol
+1
-5
PreimageOracle.sol
packages/contracts-bedrock/src/cannon/PreimageOracle.sol
+5
-1
FaultDisputeGame.sol
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
+13
-3
IBigStepper.sol
.../contracts-bedrock/src/dispute/interfaces/IBigStepper.sol
+5
-1
FaultDisputeGame.t.sol
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
+20
-9
No files found.
op-bindings/bindings/faultdisputegame.go
View file @
41dff4ad
This diff is collapsed.
Click to expand it.
op-bindings/bindings/faultdisputegame_more.go
View file @
41dff4ad
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/.gas-snapshot
View file @
41dff4ad
...
@@ -85,35 +85,35 @@ FaucetTest:test_nonAdmin_drip_fails() (gas: 262520)
...
@@ -85,35 +85,35 @@ FaucetTest:test_nonAdmin_drip_fails() (gas: 262520)
FaucetTest:test_receive_succeeds() (gas: 17401)
FaucetTest:test_receive_succeeds() (gas: 17401)
FaucetTest:test_withdraw_nonAdmin_reverts() (gas: 13145)
FaucetTest:test_withdraw_nonAdmin_reverts() (gas: 13145)
FaucetTest:test_withdraw_succeeds() (gas: 78359)
FaucetTest:test_withdraw_succeeds() (gas: 78359)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 50
1901
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 50
2209
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 508
725
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 508
989
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 505
444
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 505
730
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 508
601
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 508
887
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 50
7940
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 50
8226
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 500
666
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 500
974
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 507
490
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 507
754
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 504
209
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 504
495
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 505
366
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 505
652
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 504
705
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 504
991
)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17449)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 17449)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 179
17
)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 179
39
)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10293)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10293)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8238)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8238)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 176
47
)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 176
69
)
FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 419
119
)
FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 419
317
)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 263
77
)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 263
99
)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 13338)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 13338)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 1040
32
)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 1040
76
)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 411
30
4)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 411
41
4)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 109
46
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 109
68
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
11
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
33
)
FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 1081
12
)
FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 1081
78
)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 2264
68
)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 2264
90
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 9702)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 9702)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 1106
21
)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 1106
43
)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 21482)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 21482)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 27311)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 27311)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 3987
50
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 3987
94
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8203)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8203)
FeeVault_Test:test_constructor_succeeds() (gas: 18185)
FeeVault_Test:test_constructor_succeeds() (gas: 18185)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 352113)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 352113)
...
...
packages/contracts-bedrock/scripts/Deploy.s.sol
View file @
41dff4ad
...
@@ -698,7 +698,8 @@ contract Deploy is Deployer {
...
@@ -698,7 +698,8 @@ contract Deploy is Deployer {
_absolutePrestate: absolutePrestate,
_absolutePrestate: absolutePrestate,
_maxGameDepth: cfg.faultGameMaxDepth(),
_maxGameDepth: cfg.faultGameMaxDepth(),
_gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())),
_gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())),
_vm: faultVm
_vm: faultVm,
_l2OO: L2OutputOracle(mustGetAddress("L2OutputOracleProxy"))
}));
}));
console.log("DisputeGameFactory: set `FaultDisputeGame` implementation");
console.log("DisputeGameFactory: set `FaultDisputeGame` implementation");
}
}
...
...
packages/contracts-bedrock/src/cannon/PreimageKeyLib.sol
View file @
41dff4ad
...
@@ -36,11 +36,7 @@ library PreimageKeyLib {
...
@@ -36,11 +36,7 @@ library PreimageKeyLib {
/// @notice Computes and returns the key for a global keccak pre-image.
/// @notice Computes and returns the key for a global keccak pre-image.
/// @param _preimage The pre-image.
/// @param _preimage The pre-image.
/// @return key_ The pre-image key.
/// @return key_ The pre-image key.
function keccak256PreimageKey(bytes memory _preimage)
function keccak256PreimageKey(bytes memory _preimage) internal pure returns (bytes32 key_) {
internal
pure
returns (bytes32 key_)
{
assembly {
assembly {
// Grab the size of the `_preimage`
// Grab the size of the `_preimage`
let size := mload(_preimage)
let size := mload(_preimage)
...
...
packages/contracts-bedrock/src/cannon/PreimageOracle.sol
View file @
41dff4ad
...
@@ -71,7 +71,11 @@ contract PreimageOracle {
...
@@ -71,7 +71,11 @@ contract PreimageOracle {
/// │ 4 │ L2 Block Number │
/// │ 4 │ L2 Block Number │
/// │ 5 │ Chain ID │
/// │ 5 │ Chain ID │
/// └────────────┴─────────────────┘
/// └────────────┴─────────────────┘
function loadLocalData(uint256 _ident, bytes32 _word, uint8 _size) external {
function loadLocalData(
uint256 _ident,
bytes32 _word,
uint8 _size
) external {
// Compute the localized key from the given local identifier.
// Compute the localized key from the given local identifier.
bytes32 key = PreimageKeyLib.localizeIdent(_ident);
bytes32 key = PreimageKeyLib.localizeIdent(_ident);
...
...
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
View file @
41dff4ad
...
@@ -6,8 +6,10 @@ import { IFaultDisputeGame } from "./interfaces/IFaultDisputeGame.sol";
...
@@ -6,8 +6,10 @@ import { IFaultDisputeGame } from "./interfaces/IFaultDisputeGame.sol";
import { IInitializable } from "./interfaces/IInitializable.sol";
import { IInitializable } from "./interfaces/IInitializable.sol";
import { IBondManager } from "./interfaces/IBondManager.sol";
import { IBondManager } from "./interfaces/IBondManager.sol";
import { IBigStepper, IPreimageOracle } from "./interfaces/IBigStepper.sol";
import { IBigStepper, IPreimageOracle } from "./interfaces/IBigStepper.sol";
import { L2OutputOracle } from "../L1/L2OutputOracle.sol";
import { Clone } from "../libraries/Clone.sol";
import { Clone } from "../libraries/Clone.sol";
import { Types } from "../libraries/Types.sol";
import { Semver } from "../universal/Semver.sol";
import { Semver } from "../universal/Semver.sol";
import { LibHashing } from "./lib/LibHashing.sol";
import { LibHashing } from "./lib/LibHashing.sol";
import { LibPosition } from "./lib/LibPosition.sol";
import { LibPosition } from "./lib/LibPosition.sol";
...
@@ -33,9 +35,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -33,9 +35,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @notice The duration of the game.
/// @notice The duration of the game.
Duration public immutable GAME_DURATION;
Duration public immutable GAME_DURATION;
/// @notice A
hypervisor
that performs single instruction steps on a fault proof program trace.
/// @notice A
n onchain VM
that performs single instruction steps on a fault proof program trace.
IBigStepper public immutable VM;
IBigStepper public immutable VM;
/// @notice The trusted L2OutputOracle contract.
L2OutputOracle public immutable L2_OUTPUT_ORACLE;
/// @notice The root claim's position is always at gindex 1.
/// @notice The root claim's position is always at gindex 1.
Position internal constant ROOT_POSITION = Position.wrap(1);
Position internal constant ROOT_POSITION = Position.wrap(1);
...
@@ -62,12 +67,14 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -62,12 +67,14 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
Claim _absolutePrestate,
Claim _absolutePrestate,
uint256 _maxGameDepth,
uint256 _maxGameDepth,
Duration _gameDuration,
Duration _gameDuration,
IBigStepper _vm
IBigStepper _vm,
L2OutputOracle _l2oo
) Semver(0, 0, 3) {
) Semver(0, 0, 3) {
ABSOLUTE_PRESTATE = _absolutePrestate;
ABSOLUTE_PRESTATE = _absolutePrestate;
MAX_GAME_DEPTH = _maxGameDepth;
MAX_GAME_DEPTH = _maxGameDepth;
GAME_DURATION = _gameDuration;
GAME_DURATION = _gameDuration;
VM = _vm;
VM = _vm;
L2_OUTPUT_ORACLE = _l2oo;
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
...
@@ -256,7 +263,10 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -256,7 +263,10 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
} else if (_ident == 2) {
} else if (_ident == 2) {
// Load the earliest output root that commits to the passed L2 block number
// Load the earliest output root that commits to the passed L2 block number
// into the game's local context in the preimage oracle.
// into the game's local context in the preimage oracle.
// TODO(clabby): Add an immutable for the L2OO.
Types.OutputProposal memory proposal = L2_OUTPUT_ORACLE.getL2OutputAfter(
l2BlockNumber()
);
oracle.loadLocalData(_ident, proposal.outputRoot, 32);
} else if (_ident == 3) {
} else if (_ident == 3) {
// Load the root claim into the game's local context in the preimage oracle.
// Load the root claim into the game's local context in the preimage oracle.
oracle.loadLocalData(_ident, Claim.unwrap(rootClaim()), 32);
oracle.loadLocalData(_ident, Claim.unwrap(rootClaim()), 32);
...
...
packages/contracts-bedrock/src/dispute/interfaces/IBigStepper.sol
View file @
41dff4ad
...
@@ -39,5 +39,9 @@ interface IBigStepper {
...
@@ -39,5 +39,9 @@ interface IBigStepper {
/// @notice Temporary interface for the `IPreimageOracle`. Remove once we've upgraded
/// @notice Temporary interface for the `IPreimageOracle`. Remove once we've upgraded
/// the cannon contracts to a newer version of solc.
/// the cannon contracts to a newer version of solc.
interface IPreimageOracle {
interface IPreimageOracle {
function loadLocalData(uint256 _ident, bytes32 _word, uint8 _size) external;
function loadLocalData(
uint256 _ident,
bytes32 _word,
uint8 _size
) external;
}
}
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
View file @
41dff4ad
...
@@ -4,8 +4,9 @@ pragma solidity ^0.8.15;
...
@@ -4,8 +4,9 @@ pragma solidity ^0.8.15;
import { Test } from "forge-std/Test.sol";
import { Test } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";
import { Vm } from "forge-std/Vm.sol";
import { DisputeGameFactory_Init } from "./DisputeGameFactory.t.sol";
import { DisputeGameFactory_Init } from "./DisputeGameFactory.t.sol";
import { DisputeGameFactory } from "../src/dispute/DisputeGameFactory.sol";
import { DisputeGameFactory } from "../dispute/DisputeGameFactory.sol";
import { FaultDisputeGame } from "../src/dispute/FaultDisputeGame.sol";
import { FaultDisputeGame } from "../dispute/FaultDisputeGame.sol";
import { L2OutputOracle } from "../L1/L2OutputOracle.sol";
import "../libraries/DisputeTypes.sol";
import "../libraries/DisputeTypes.sol";
import "../libraries/DisputeErrors.sol";
import "../libraries/DisputeErrors.sol";
...
@@ -28,12 +29,14 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
...
@@ -28,12 +29,14 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
function init(Claim rootClaim, Claim absolutePrestate) public {
function init(Claim rootClaim, Claim absolutePrestate) public {
super.setUp();
super.setUp();
// Deploy an implementation of the fault game
// Deploy an implementation of the fault game
gameImpl = new FaultDisputeGame(
gameImpl = new FaultDisputeGame(
absolutePrestate,
absolutePrestate,
4,
4,
Duration.wrap(7 days),
Duration.wrap(7 days),
new AlphabetVM(absolutePrestate)
new AlphabetVM(absolutePrestate),
L2OutputOracle(deployNoop())
);
);
// Register the game implementation with the factory.
// Register the game implementation with the factory.
factory.setImplementation(GAME_TYPE, gameImpl);
factory.setImplementation(GAME_TYPE, gameImpl);
...
@@ -893,12 +896,7 @@ contract AlphabetVM is IBigStepper {
...
@@ -893,12 +896,7 @@ contract AlphabetVM is IBigStepper {
constructor(Claim _absolutePrestate) {
constructor(Claim _absolutePrestate) {
ABSOLUTE_PRESTATE = _absolutePrestate;
ABSOLUTE_PRESTATE = _absolutePrestate;
// Deploy a noop preimage oracle
oracle = IPreimageOracle(deployNoop());
assembly {
mstore(0x00, 0x60016000F3)
let size := 5
sstore(oracle.slot, create(0, sub(0x20, size), size))
}
}
}
/// @inheritdoc IBigStepper
/// @inheritdoc IBigStepper
...
@@ -922,3 +920,16 @@ contract AlphabetVM is IBigStepper {
...
@@ -922,3 +920,16 @@ contract AlphabetVM is IBigStepper {
postState_ = keccak256(abi.encode(traceIndex, claim + 1));
postState_ = keccak256(abi.encode(traceIndex, claim + 1));
}
}
}
}
////////////////////////////////////////////////////////////////
// HELPERS //
////////////////////////////////////////////////////////////////
/// @notice Deploys a noop contract.
function deployNoop() returns (address noop_) {
assembly {
mstore(0x00, 0x60016000F3)
let size := 5
noop_ := create(0, sub(0x20, size), size)
}
}
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