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
4c188bae
Commit
4c188bae
authored
Aug 04, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow `FaultDisputeGame` to be deployed with different game types
patch
parent
55012af6
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
61 additions
and
69 deletions
+61
-69
faultdisputegame.go
op-bindings/bindings/faultdisputegame.go
+10
-10
faultdisputegame_more.go
op-bindings/bindings/faultdisputegame_more.go
+1
-1
abi_test.go
op-challenger/fault/abi_test.go
+1
-0
deploy.go
op-e2e/e2eutils/disputegame/deploy.go
+1
-0
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+1
-1
Deploy.s.sol
packages/contracts-bedrock/scripts/Deploy.s.sol
+34
-51
semver-lock.json
packages/contracts-bedrock/semver-lock.json
+1
-1
FaultDisputeGame.sol
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
+9
-3
IDisputeGame.sol
...contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol
+2
-2
FaultDisputeGame.t.sol
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
+1
-0
No files found.
op-bindings/bindings/faultdisputegame.go
View file @
4c188bae
This diff is collapsed.
Click to expand it.
op-bindings/bindings/faultdisputegame_more.go
View file @
4c188bae
This diff is collapsed.
Click to expand it.
op-challenger/fault/abi_test.go
View file @
4c188bae
...
...
@@ -36,6 +36,7 @@ func setupFaultDisputeGame() (common.Address, *bind.TransactOpts, *backends.Simu
_
,
_
,
contract
,
err
:=
bindings
.
DeployFaultDisputeGame
(
opts
,
backend
,
uint8
(
0
),
// Game Type ID
[
32
]
byte
{
0x01
},
// Absolute Prestate Claim
big
.
NewInt
(
15
),
// Max Game Depth
uint64
(
604800
),
// 7 days
...
...
op-e2e/e2eutils/disputegame/deploy.go
View file @
4c188bae
...
...
@@ -69,6 +69,7 @@ func deployDisputeGameContracts(require *require.Assertions, ctx context.Context
_
,
tx
,
_
,
err
=
bindings
.
DeployFaultDisputeGame
(
opts
,
client
,
uint8
(
0
),
alphabetVMAbsolutePrestateClaim
,
big
.
NewInt
(
alphabetGameDepth
),
gameDuration
,
...
...
packages/contracts-bedrock/.gas-snapshot
View file @
4c188bae
...
...
@@ -100,7 +100,7 @@ FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeed
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 32354)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 32806)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10388)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 82
66
)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 82
72
)
FaultDisputeGame_Test:test_initialize_correctData_succeeds() (gas: 57716)
FaultDisputeGame_Test:test_initialize_firstOutput_reverts() (gas: 210532)
FaultDisputeGame_Test:test_initialize_l1HeadTooOld_reverts() (gas: 228402)
...
...
packages/contracts-bedrock/scripts/Deploy.s.sol
View file @
4c188bae
...
...
@@ -262,21 +262,17 @@ contract Deploy is Deployer {
/// @notice Deploy the DisputeGameFactoryProxy
function deployDisputeGameFactoryProxy() onlyDevnet broadcast() public returns (address) {
address proxyAdmin = mustGetAddress("ProxyAdmin");
Proxy proxy = new Proxy({
_admin: proxyAdmin
});
string[2] memory contractNames = ["DisputeGameFactoryProxy", "MIPSDisputeGameFactoryProxy"];
for (uint256 i; i < contractNames.length; i++) {
Proxy proxy = new Proxy({
_admin: proxyAdmin
});
address admin = address(uint160(uint256(vm.load(address(proxy), OWNER_KEY))));
require(admin == proxyAdmin);
address admin = address(uint160(uint256(vm.load(address(proxy), OWNER_KEY))));
require(admin == proxyAdmin);
save(contractNames[i], address(proxy));
console.log("%s deployed at %s", contractNames[i], address(proxy));
}
save("DisputeGameFactoryProxy", address(proxy));
console.log("DisputeGameFactoryProxy deployed at %s", address(proxy));
return
mustGetAddress(contractNames[0]
);
return
address(proxy
);
}
/// @notice Deploy the L1CrossDomainMessenger
...
...
@@ -367,10 +363,6 @@ contract Deploy is Deployer {
save("DisputeGameFactory", address(factory));
console.log("DisputeGameFactory deployed at %s", address(factory));
DisputeGameFactory mipsFactory = new DisputeGameFactory();
save("MIPSDisputeGameFactory", address(mipsFactory));
console.log("MIPSDisputeGameFactory deployed at %s", address(mipsFactory));
return address(factory);
}
...
...
@@ -487,26 +479,20 @@ contract Deploy is Deployer {
/// @notice Initialize the DisputeGameFactory
function initializeDisputeGameFactory() onlyDevnet broadcast() public {
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
string[2][2] memory contractNames = [
["DisputeGameFactoryProxy", "DisputeGameFactory"],
["MIPSDisputeGameFactoryProxy", "MIPSDisputeGameFactory"]
];
for (uint256 i; i < contractNames.length; i++) {
address disputeGameFactoryProxy = mustGetAddress(contractNames[i][0]);
address disputeGameFactory = mustGetAddress(contractNames[i][1]);
proxyAdmin.upgradeAndCall({
_proxy: payable(disputeGameFactoryProxy),
_implementation: disputeGameFactory,
_data: abi.encodeCall(
DisputeGameFactory.initialize,
(msg.sender)
)
});
address disputeGameFactoryProxy = mustGetAddress("DisputeGameFactoryProxy");
address disputeGameFactory = mustGetAddress("DisputeGameFactory");
string memory version = DisputeGameFactory(disputeGameFactoryProxy).version();
console.log("%s version: %s", contractNames[i][1], version);
}
proxyAdmin.upgradeAndCall({
_proxy: payable(disputeGameFactoryProxy),
_implementation: disputeGameFactory,
_data: abi.encodeCall(
DisputeGameFactory.initialize,
(msg.sender)
)
});
string memory version = DisputeGameFactory(disputeGameFactoryProxy).version();
console.log("DisputeGameFactory version: %s", version);
}
/// @notice Initialize the SystemConfig
...
...
@@ -724,15 +710,12 @@ contract Deploy is Deployer {
/// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner
function transferDisputeGameFactoryOwnership() onlyDevnet broadcast() public {
string[2] memory contractNames = ["DisputeGameFactoryProxy", "MIPSDisputeGameFactoryProxy"];
for (uint256 i; i < contractNames.length; i++) {
DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress(contractNames[i]));
address owner = disputeGameFactory.owner();
address finalSystemOwner = cfg.finalSystemOwner();
if (owner != finalSystemOwner) {
disputeGameFactory.transferOwnership(finalSystemOwner);
console.log("%s ownership transferred to: %s", contractNames[i], finalSystemOwner);
}
DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
address owner = disputeGameFactory.owner();
address finalSystemOwner = cfg.finalSystemOwner();
if (owner != finalSystemOwner) {
disputeGameFactory.transferOwnership(finalSystemOwner);
console.log("DisputeGameFactory ownership transferred to: %s", finalSystemOwner);
}
}
...
...
@@ -752,14 +735,14 @@ contract Deploy is Deployer {
mipsAbsolutePrestate = abi.decode(vm.ffi(commands), (bytes32));
console.log("Absolute prestate: %s", vm.toString(mipsAbsolutePrestate));
string[2] memory contractNames = ["DisputeGameFactoryProxy", "MIPSDisputeGameFactoryProxy"];
for (uint256 i; i < contractNames.length; i++) {
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress(contractNames[i]));
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
for (uint8 i; i < 2; i++) {
Claim absolutePrestate = Claim.wrap(i == 0 ? bytes32(cfg.faultGameAbsolutePrestate()) : mipsAbsolutePrestate);
IBigStepper faultVm = IBigStepper(i == 0 ? address(new AlphabetVM(absolutePrestate)) : mustGetAddress("Mips"));
if (address(factory.gameImpls(GameTypes.FAULT)) == address(0)) {
factory.setImplementation(GameTypes.FAULT, new FaultDisputeGame({
GameType gameType = GameType.wrap(i);
if (address(factory.gameImpls(gameType)) == address(0)) {
factory.setImplementation(gameType, new FaultDisputeGame({
_gameType: gameType,
_absolutePrestate: absolutePrestate,
_maxGameDepth: i == 0 ? 4 : cfg.faultGameMaxDepth(), // The max depth of the alphabet game is always 4
_gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())),
...
...
@@ -767,7 +750,7 @@ contract Deploy is Deployer {
_l2oo: L2OutputOracle(mustGetAddress("L2OutputOracleProxy")),
_blockOracle: BlockOracle(mustGetAddress("BlockOracle"))
}));
console.log("
%s: set `FaultDisputeGame` implementation", contractNames[i]
);
console.log("
DisputeGameFactoryProxy: set `FaultDisputeGame` implementation (Backend: %s | GameType: %s)", i == 0 ? "AlphabetVM" : "MIPS", vm.toString(i)
);
}
}
}
...
...
packages/contracts-bedrock/semver-lock.json
View file @
4c188bae
...
...
@@ -14,7 +14,7 @@
"src/L2/L2StandardBridge.sol"
:
"0x73a4fea3dca8ac7d7ba32e38aadeb69bd344042666a40a75e8c28849f01999e5"
,
"src/L2/L2ToL1MessagePasser.sol"
:
"0xed800b600cb3f67e18a1ab10750e3934a8b3e42178f422bcacfde770a6e8e8bd"
,
"src/L2/SequencerFeeVault.sol"
:
"0xd57c143b1f042400430b991b806bf971628e6980406c751e82d19ae80eeb4e8d"
,
"src/dispute/FaultDisputeGame.sol"
:
"0x
53ef150202f3e22dd0bd92a520c4eaa95752f5fd9d6b22f56d27958b71bb23ec
"
,
"src/dispute/FaultDisputeGame.sol"
:
"0x
01b3770e4d056550e71b4b9e9ada5401de98668d0a1e0ff336ed8f73a0127e99
"
,
"src/legacy/DeployerWhitelist.sol"
:
"0x5e80f7b13ef73f06c63bd9b118a49da1ff06a5c0fcf8067b5a3365d731c23765"
,
"src/legacy/L1BlockNumber.sol"
:
"0x84cc587148de5920dfcd19da44d28e769f0e4d08ca2bcc93f18aa78c6cc2ebe6"
,
"src/legacy/LegacyMessagePasser.sol"
:
"0x2692b50b227e5f75a53439c0cf303498edfd4fc087555b3fc9bc4bceb518229b"
,
...
...
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
View file @
4c188bae
...
...
@@ -46,6 +46,9 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// than the `BLOCKHASH` opcode allows as well as their estimated timestamps.
BlockOracle public immutable BLOCK_ORACLE;
/// @notice The game type ID
GameType internal immutable GAME_TYPE;
/// @notice The root claim's position is always at gindex 1.
Position internal constant ROOT_POSITION = Position.wrap(1);
...
...
@@ -72,6 +75,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @notice An internal mapping to allow for constant-time lookups of existing claims.
mapping(ClaimHash => bool) internal claims;
/// @param _gameType The type ID of the game.
/// @param _absolutePrestate The absolute prestate of the instruction trace.
/// @param _maxGameDepth The maximum depth of bisection.
/// @param _gameDuration The duration of the game.
...
...
@@ -83,6 +87,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// timestamps.
/// @custom:semver 0.0.6
constructor(
GameType _gameType,
Claim _absolutePrestate,
uint256 _maxGameDepth,
Duration _gameDuration,
...
...
@@ -90,6 +95,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
L2OutputOracle _l2oo,
BlockOracle _blockOracle
) Semver(0, 0, 6) {
GAME_TYPE = _gameType;
ABSOLUTE_PRESTATE = _absolutePrestate;
MAX_GAME_DEPTH = _maxGameDepth;
GAME_DURATION = _gameDuration;
...
...
@@ -332,8 +338,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
////////////////////////////////////////////////////////////////
/// @inheritdoc IDisputeGame
function gameType() public
pure
override returns (GameType gameType_) {
gameType_ = G
ameTypes.FAULT
;
function gameType() public
view
override returns (GameType gameType_) {
gameType_ = G
AME_TYPE
;
}
/// @inheritdoc IDisputeGame
...
...
@@ -425,7 +431,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @inheritdoc IDisputeGame
function gameData()
external
pure
view
returns (
GameType gameType_,
Claim rootClaim_,
...
...
packages/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol
View file @
4c188bae
...
...
@@ -25,7 +25,7 @@ interface IDisputeGame is IInitializable {
/// @dev The reference impl should be entirely different depending on the type (fault, validity)
/// i.e. The game type should indicate the security model.
/// @return gameType_ The type of proof system being used.
function gameType() external
pure
returns (GameType gameType_);
function gameType() external
view
returns (GameType gameType_);
/// @notice Getter for the root claim.
/// @dev `clones-with-immutable-args` argument #1
...
...
@@ -58,7 +58,7 @@ interface IDisputeGame is IInitializable {
/// @return extraData_ Any extra data supplied to the dispute game contract by the creator.
function gameData()
external
pure
view
returns (
GameType gameType_,
Claim rootClaim_,
...
...
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
View file @
4c188bae
...
...
@@ -60,6 +60,7 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
// Deploy an implementation of the fault game
gameImpl = new FaultDisputeGame(
GAME_TYPE,
absolutePrestate,
4,
Duration.wrap(7 days),
...
...
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