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
a0dbcce7
Commit
a0dbcce7
authored
Jul 31, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start l1 head loading spike
parent
5bf5f9a8
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
249 additions
and
71 deletions
+249
-71
disputegamefactory.go
op-bindings/bindings/disputegamefactory.go
+1
-1
disputegamefactory_more.go
op-bindings/bindings/disputegamefactory_more.go
+1
-1
faultdisputegame.go
op-bindings/bindings/faultdisputegame.go
+66
-4
faultdisputegame_more.go
op-bindings/bindings/faultdisputegame_more.go
+1
-1
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+31
-30
Deploy.s.sol
packages/contracts-bedrock/scripts/Deploy.s.sol
+21
-23
semver-lock.json
packages/contracts-bedrock/semver-lock.json
+0
-1
BlockHashOracle.sol
packages/contracts-bedrock/src/dispute/BlockHashOracle.sol
+37
-0
FaultDisputeGame.sol
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
+20
-7
IFaultDisputeGame.sol
...acts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol
+3
-1
DisputeErrors.sol
packages/contracts-bedrock/src/libraries/DisputeErrors.sol
+11
-0
BlockHashOracle.t.sol
packages/contracts-bedrock/test/BlockHashOracle.t.sol
+46
-0
FaultDisputeGame.t.sol
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
+11
-2
No files found.
op-bindings/bindings/disputegamefactory.go
View file @
a0dbcce7
This diff is collapsed.
Click to expand it.
op-bindings/bindings/disputegamefactory_more.go
View file @
a0dbcce7
This diff is collapsed.
Click to expand it.
op-bindings/bindings/faultdisputegame.go
View file @
a0dbcce7
This diff is collapsed.
Click to expand it.
op-bindings/bindings/faultdisputegame_more.go
View file @
a0dbcce7
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/.gas-snapshot
View file @
a0dbcce7
...
@@ -16,6 +16,7 @@ AssetReceiverTest:test_withdrawETHwithAmount_unauthorized_reverts() (gas: 10738)
...
@@ -16,6 +16,7 @@ AssetReceiverTest:test_withdrawETHwithAmount_unauthorized_reverts() (gas: 10738)
AttestationStationTest:test_attest_bulk_succeeds() (gas: 703740)
AttestationStationTest:test_attest_bulk_succeeds() (gas: 703740)
AttestationStationTest:test_attest_individual_succeeds() (gas: 632078)
AttestationStationTest:test_attest_individual_succeeds() (gas: 632078)
AttestationStationTest:test_attest_single_succeeds() (gas: 651316)
AttestationStationTest:test_attest_single_succeeds() (gas: 651316)
BlockHashOracle_Test:test_load_reverts() (gas: 10436)
Bytes_slice_Test:test_slice_acrossMultipleWords_works() (gas: 9413)
Bytes_slice_Test:test_slice_acrossMultipleWords_works() (gas: 9413)
Bytes_slice_Test:test_slice_acrossWords_works() (gas: 1430)
Bytes_slice_Test:test_slice_acrossWords_works() (gas: 1430)
Bytes_slice_Test:test_slice_fromNonZeroIdx_works() (gas: 17240)
Bytes_slice_Test:test_slice_fromNonZeroIdx_works() (gas: 17240)
...
@@ -85,36 +86,36 @@ FaucetTest:test_nonAdmin_drip_fails() (gas: 262520)
...
@@ -85,36 +86,36 @@ 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
1957
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 50
2154
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 508
759
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 508
940
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 505
478
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 505
653
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 508
657
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 508
860
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 50
7974
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 50
8149
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 500
722
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 500
919
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 507
524
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 507
705
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 504
243
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 504
418
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 505
422
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 505
625
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 504
739
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 504
914
)
FaultDisputeGame_Test:test_extraData_succeeds() (gas:
1740
4)
FaultDisputeGame_Test:test_extraData_succeeds() (gas:
2551
4)
FaultDisputeGame_Test:test_gameData_succeeds() (gas:
17939
)
FaultDisputeGame_Test:test_gameData_succeeds() (gas:
26005
)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10
315
)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10
299
)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 82
60
)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 82
88
)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 1762
4
)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 1762
7
)
FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 419
180
)
FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 419
219
)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 2642
1
)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 2642
7
)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 133
60
)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 133
44
)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 1041
20
)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 1041
32
)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 4115
46
)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 4115
59
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 110
12
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 110
46
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
7
7)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
6
7)
FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 1081
10
)
FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 1081
22
)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 2265
11
)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 2265
57
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 96
57
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 96
85
)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 110
642
)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 110
704
)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 214
37
)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 214
65
)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 27
288
)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 27
344
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 3988
59
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 3988
95
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 82
25
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 82
53
)
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)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2950320)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2950320)
...
...
packages/contracts-bedrock/scripts/Deploy.s.sol
View file @
a0dbcce7
...
@@ -9,30 +9,28 @@ import { stdJson } from "forge-std/StdJson.sol";
...
@@ -9,30 +9,28 @@ import { stdJson } from "forge-std/StdJson.sol";
import { Deployer } from "./Deployer.sol";
import { Deployer } from "./Deployer.sol";
import { DeployConfig } from "./DeployConfig.s.sol";
import { DeployConfig } from "./DeployConfig.s.sol";
import { ProxyAdmin } from "../src/universal/ProxyAdmin.sol";
import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
import { AddressManager } from "../src/legacy/AddressManager.sol";
import { AddressManager } from "src/legacy/AddressManager.sol";
import { Proxy } from "../src/universal/Proxy.sol";
import { Proxy } from "src/universal/Proxy.sol";
import { L1StandardBridge } from "../src/L1/L1StandardBridge.sol";
import { L1StandardBridge } from "src/L1/L1StandardBridge.sol";
import { OptimismPortal } from "../src/L1/OptimismPortal.sol";
import { OptimismPortal } from "src/L1/OptimismPortal.sol";
import { L1ChugSplashProxy } from "../src/legacy/L1ChugSplashProxy.sol";
import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol";
import { ResolvedDelegateProxy } from "../src/legacy/ResolvedDelegateProxy.sol";
import { ResolvedDelegateProxy } from "src/legacy/ResolvedDelegateProxy.sol";
import { L1CrossDomainMessenger } from "../src/L1/L1CrossDomainMessenger.sol";
import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol";
import { L2OutputOracle } from "../src/L1/L2OutputOracle.sol";
import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
import { OptimismMintableERC20Factory } from "../src/universal/OptimismMintableERC20Factory.sol";
import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC20Factory.sol";
import { SystemConfig } from "../src/L1/SystemConfig.sol";
import { SystemConfig } from "src/L1/SystemConfig.sol";
import { ResourceMetering } from "../src/L1/ResourceMetering.sol";
import { ResourceMetering } from "src/L1/ResourceMetering.sol";
import { Constants } from "../src/libraries/Constants.sol";
import { Constants } from "src/libraries/Constants.sol";
import { DisputeGameFactory } from "../src/dispute/DisputeGameFactory.sol";
import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { FaultDisputeGame } from "../src/dispute/FaultDisputeGame.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { PreimageOracle } from "../src/cannon/PreimageOracle.sol";
import { BlockHashOracle } from "src/dispute/BlockHashOracle.sol";
import { MIPS } from "../src/cannon/MIPS.sol";
import { L1ERC721Bridge } from "src/L1/L1ERC721Bridge.sol";
import { L1ERC721Bridge } from "../src/L1/L1ERC721Bridge.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
import { Predeploys } from "../src/libraries/Predeploys.sol";
import { Chains } from "./Chains.sol";
import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol";
import { IBigStepper } from "../src/dispute/interfaces/IBigStepper.sol";
import { AlphabetVM } from "../test/FaultDisputeGame.t.sol";
import { AlphabetVM } from "../test/FaultDisputeGame.t.sol";
import "
../
src/libraries/DisputeTypes.sol";
import "src/libraries/DisputeTypes.sol";
/// @title Deploy
/// @title Deploy
/// @notice Script used to deploy a bedrock system. The entire system is deployed within the `run` function.
/// @notice Script used to deploy a bedrock system. The entire system is deployed within the `run` function.
...
...
packages/contracts-bedrock/semver-lock.json
View file @
a0dbcce7
...
@@ -26,4 +26,3 @@
...
@@ -26,4 +26,3 @@
"src/universal/OptimismMintableERC20Factory.sol"
:
"0x1d48aaec29c6732e5d25652a568c4f58a9606656711a14ef98c7cdd5768d9677"
,
"src/universal/OptimismMintableERC20Factory.sol"
:
"0x1d48aaec29c6732e5d25652a568c4f58a9606656711a14ef98c7cdd5768d9677"
,
"src/universal/OptimismMintableERC721.sol"
:
"0x72c9c204caddf5a48b6a704621363926714162c2453392b922091d80aa73924f"
,
"src/universal/OptimismMintableERC721.sol"
:
"0x72c9c204caddf5a48b6a704621363926714162c2453392b922091d80aa73924f"
,
"src/universal/OptimismMintableERC721Factory.sol"
:
"0x138d1cecb3c0daa85c73617a1c5d0956544bf65153c13dc11529a71f4b70fb3b"
"src/universal/OptimismMintableERC721Factory.sol"
:
"0x138d1cecb3c0daa85c73617a1c5d0956544bf65153c13dc11529a71f4b70fb3b"
}
\ No newline at end of file
packages/contracts-bedrock/src/dispute/BlockHashOracle.sol
0 → 100644
View file @
a0dbcce7
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import "../libraries/DisputeTypes.sol";
import "../libraries/DisputeErrors.sol";
/// @title BlockHashOracle
/// @notice Stores a map of block numbers => block hashes for use in dispute resolution
contract BlockHashOracle {
/// @notice Maps block numbers to block hashes
mapping(uint256 => Hash) internal blockHashes;
/// @notice Loads a block hash for a given block number, assuming that the block number
/// has been stored in the oracle.
/// @param _blockNumber The block number to load the block hash for.
/// @return blockHash_ The block hash for the given block number.
function load(uint256 _blockNumber) external view returns (Hash blockHash_) {
blockHash_ = blockHashes[_blockNumber];
if (Hash.unwrap(blockHash_) == 0) {
revert BlockHashNotPresent();
}
}
/// @notice Stores a block hash for a given block number, assuming that the block number
/// is within the acceptable range of [tip - 256, tip].
/// @param _blockNumber The block number to persist the block hash for.
function store(uint256 _blockNumber) external {
bytes32 blockHash = blockhash(_blockNumber);
if (blockHash == bytes32(0)) {
revert BlockNumberOOB();
}
blockHashes[_blockNumber] = Hash.wrap(blockHash);
}
}
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
View file @
a0dbcce7
...
@@ -7,6 +7,7 @@ import { IInitializable } from "./interfaces/IInitializable.sol";
...
@@ -7,6 +7,7 @@ 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 { L2OutputOracle } from "../L1/L2OutputOracle.sol";
import { BlockHashOracle } from "./BlockHashOracle.sol";
import { Clone } from "../libraries/Clone.sol";
import { Clone } from "../libraries/Clone.sol";
import { Types } from "../libraries/Types.sol";
import { Types } from "../libraries/Types.sol";
...
@@ -41,6 +42,10 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -41,6 +42,10 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @notice The trusted L2OutputOracle contract.
/// @notice The trusted L2OutputOracle contract.
L2OutputOracle public immutable L2_OUTPUT_ORACLE;
L2OutputOracle public immutable L2_OUTPUT_ORACLE;
/// @notice The block hash oracle, used for loading block hashes further back
/// than the `BLOCKHASH` opcode allows.
BlockHashOracle public immutable BLOCK_HASH_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);
...
@@ -68,19 +73,21 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -68,19 +73,21 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @param _vm An onchain VM that performs single instruction steps on a fault proof program
/// @param _vm An onchain VM that performs single instruction steps on a fault proof program
/// trace.
/// trace.
/// @param _l2oo The trusted L2OutputOracle contract.
/// @param _l2oo The trusted L2OutputOracle contract.
/// @custom:semver 0.0.
4
/// @custom:semver 0.0.
5
constructor(
constructor(
Claim _absolutePrestate,
Claim _absolutePrestate,
uint256 _maxGameDepth,
uint256 _maxGameDepth,
Duration _gameDuration,
Duration _gameDuration,
IBigStepper _vm,
IBigStepper _vm,
L2OutputOracle _l2oo
L2OutputOracle _l2oo,
) Semver(0, 0, 4) {
BlockHashOracle _blockHashOracle
) Semver(0, 0, 5) {
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;
L2_OUTPUT_ORACLE = _l2oo;
BLOCK_HASH_ORACLE = _blockHashOracle;
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
...
@@ -294,6 +301,11 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -294,6 +301,11 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
l2BlockNumber_ = _getArgUint256(0x20);
l2BlockNumber_ = _getArgUint256(0x20);
}
}
/// @inheritdoc IFaultDisputeGame
function l1BlockNumber() public pure returns (uint256 l1BlockNumber_) {
l1BlockNumber_ = _getArgUint256(0x40);
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// `IDisputeGame` impl //
// `IDisputeGame` impl //
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
...
@@ -384,8 +396,9 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -384,8 +396,9 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @inheritdoc IDisputeGame
/// @inheritdoc IDisputeGame
function extraData() public pure returns (bytes memory extraData_) {
function extraData() public pure returns (bytes memory extraData_) {
// The extra data starts at the second word within the cwia calldata.
// The extra data starts at the second word within the cwia calldata and
extraData_ = _getArgDynBytes(0x20, 0x20);
// is 64 bytes long.
extraData_ = _getArgDynBytes(0x20, 0x40);
}
}
/// @inheritdoc IDisputeGame
/// @inheritdoc IDisputeGame
...
@@ -425,8 +438,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
...
@@ -425,8 +438,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
})
})
);
);
// Set the L1 head hash
at the time of the game's creation
.
// Set the L1 head hash
to the block hash of the L1 block number provided
.
l1Head =
Hash.wrap(blockhash(block.number - 1
));
l1Head =
BLOCK_HASH_ORACLE.load(_getArgUint256(0x40
));
}
}
/// @notice Returns the length of the `claimData` array.
/// @notice Returns the length of the `claimData` array.
...
...
packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol
View file @
a0dbcce7
...
@@ -63,6 +63,8 @@ interface IFaultDisputeGame is IDisputeGame {
...
@@ -63,6 +63,8 @@ interface IFaultDisputeGame is IDisputeGame {
/// @notice The l2BlockNumber that the `rootClaim` commits to. The trace being bisected within
/// @notice The l2BlockNumber that the `rootClaim` commits to. The trace being bisected within
/// the game is from `l2BlockNumber - 1` -> `l2BlockNumber`.
/// the game is from `l2BlockNumber - 1` -> `l2BlockNumber`.
/// @return l2BlockNumber_ The l2BlockNumber that the `rootClaim` commits to.
function l2BlockNumber() external view returns (uint256 l2BlockNumber_);
function l2BlockNumber() external view returns (uint256 l2BlockNumber_);
/// @notice The l1BlockNumber that Cannon was ran from to generate the root claim.
function l1BlockNumber() external view returns (uint256 l1BlockNumber_);
}
}
packages/contracts-bedrock/src/libraries/DisputeErrors.sol
View file @
a0dbcce7
...
@@ -72,3 +72,14 @@ error AlreadyChallenged();
...
@@ -72,3 +72,14 @@ error AlreadyChallenged();
/// @notice Thrown when a function that is protected by the `onlyOwner` modifier
/// @notice Thrown when a function that is protected by the `onlyOwner` modifier
/// is called from an account other than the owner.
/// is called from an account other than the owner.
error NotOwner();
error NotOwner();
////////////////////////////////////////////////////////////////
// `BlockHashOracle.sol` Errors //
////////////////////////////////////////////////////////////////
/// @notice Thrown when a block that is out of the range of the `BLOCKHASH` opcode
/// is attempted to be loaded.
error BlockNumberOOB();
/// @notice Thrown when a block hash is attempted to be loaded that has not been stored.
error BlockHashNotPresent();
packages/contracts-bedrock/test/BlockHashOracle.t.sol
0 → 100644
View file @
a0dbcce7
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { BlockHashOracle } from "src/dispute/BlockHashOracle.sol";
import "src/libraries/DisputeTypes.sol";
import "src/libraries/DisputeErrors.sol";
contract BlockHashOracle_Test is Test {
BlockHashOracle oracle;
function setUp() public {
oracle = new BlockHashOracle();
vm.roll(block.number + 255);
}
/// @notice Tests that loading a block hash for a block number within the range of the
/// `BLOCKHASH` opcode succeeds.
function testFuzz_store_succeeds(uint256 _blockNumber) public {
_blockNumber = bound(_blockNumber, 0, 255);
oracle.store(_blockNumber);
assertEq(Hash.unwrap(oracle.load(_blockNumber)), blockhash(_blockNumber));
}
/// @notice Tests that loading a block hash for a block number outside the range of the
/// `BLOCKHASH` opcode fails.
function testFuzz_store_reverts(uint256 _blockNumber) public {
// Fast forward another 256 blocks.
vm.roll(block.number + 256);
// Bound the block number to the set { 0, ..., 255 } ∪ { 512, ..., type(uint256).max }
_blockNumber = _blockNumber % 2 == 0
? bound(_blockNumber, 0, 255)
: bound(_blockNumber, 512, type(uint256).max);
// Attempt to load the block hash, which should fail.
vm.expectRevert(BlockNumberOOB.selector);
oracle.store(_blockNumber);
}
/// @notice Tests that the `load` function reverts if the block hash for the given block
/// number has not been stored.
function test_load_reverts() public {
vm.expectRevert(BlockHashNotPresent.selector);
oracle.load(0);
}
}
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
View file @
a0dbcce7
...
@@ -7,6 +7,7 @@ import { DisputeGameFactory_Init } from "./DisputeGameFactory.t.sol";
...
@@ -7,6 +7,7 @@ import { DisputeGameFactory_Init } from "./DisputeGameFactory.t.sol";
import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { DisputeGameFactory } from "src/dispute/DisputeGameFactory.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
import { BlockHashOracle } from "src/dispute/BlockHashOracle.sol";
import "src/libraries/DisputeTypes.sol";
import "src/libraries/DisputeTypes.sol";
import "src/libraries/DisputeErrors.sol";
import "src/libraries/DisputeErrors.sol";
...
@@ -16,7 +17,7 @@ import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper
...
@@ -16,7 +17,7 @@ import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper
contract FaultDisputeGame_Init is DisputeGameFactory_Init {
contract FaultDisputeGame_Init is DisputeGameFactory_Init {
/// @dev The extra data passed to the game for initialization.
/// @dev The extra data passed to the game for initialization.
bytes internal constant EXTRA_DATA = abi.encode(1);
bytes internal constant EXTRA_DATA = abi.encode(1
, 0
);
/// @dev The type of the game being tested.
/// @dev The type of the game being tested.
GameType internal constant GAME_TYPE = GameType.wrap(0);
GameType internal constant GAME_TYPE = GameType.wrap(0);
...
@@ -30,13 +31,21 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
...
@@ -30,13 +31,21 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
function init(Claim rootClaim, Claim absolutePrestate) public {
function init(Claim rootClaim, Claim absolutePrestate) public {
super.setUp();
super.setUp();
// Advance the block number by 1.
vm.roll(block.number + 1);
// Deploy a new block hash oracle and store the block hash for the genesis block.
BlockHashOracle blockHashOracle = new BlockHashOracle();
blockHashOracle.store(0);
// 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())
L2OutputOracle(deployNoop()),
blockHashOracle
);
);
// Register the game implementation with the factory.
// Register the game implementation with the factory.
factory.setImplementation(GAME_TYPE, gameImpl);
factory.setImplementation(GAME_TYPE, gameImpl);
...
...
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