Commit b2b620fb authored by clabby's avatar clabby

Deploy `FaultDisputeGame` with `MIPS` backend on devnet

parent 79e4aa45
...@@ -262,17 +262,21 @@ contract Deploy is Deployer { ...@@ -262,17 +262,21 @@ contract Deploy is Deployer {
/// @notice Deploy the DisputeGameFactoryProxy /// @notice Deploy the DisputeGameFactoryProxy
function deployDisputeGameFactoryProxy() onlyDevnet broadcast() public returns (address) { function deployDisputeGameFactoryProxy() onlyDevnet broadcast() public returns (address) {
address proxyAdmin = mustGetAddress("ProxyAdmin"); address proxyAdmin = mustGetAddress("ProxyAdmin");
Proxy proxy = new Proxy({
_admin: proxyAdmin
});
address admin = address(uint160(uint256(vm.load(address(proxy), OWNER_KEY)))); string[2] memory contractNames = ["DisputeGameFactoryProxy", "MIPSDisputeGameFactoryProxy"];
require(admin == proxyAdmin); for (uint256 i; i < contractNames.length; i++) {
Proxy proxy = new Proxy({
_admin: proxyAdmin
});
save("DisputeGameFactoryProxy", address(proxy)); address admin = address(uint160(uint256(vm.load(address(proxy), OWNER_KEY))));
console.log("DisputeGameFactoryProxy deployed at %s", address(proxy)); require(admin == proxyAdmin);
return address(proxy); save(contractNames[i], address(proxy));
console.log("%s deployed at %s", contractNames[i], address(proxy));
}
return mustGetAddress(contractNames[0]);
} }
/// @notice Deploy the L1CrossDomainMessenger /// @notice Deploy the L1CrossDomainMessenger
...@@ -363,6 +367,10 @@ contract Deploy is Deployer { ...@@ -363,6 +367,10 @@ contract Deploy is Deployer {
save("DisputeGameFactory", address(factory)); save("DisputeGameFactory", address(factory));
console.log("DisputeGameFactory deployed at %s", 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); return address(factory);
} }
...@@ -479,20 +487,26 @@ contract Deploy is Deployer { ...@@ -479,20 +487,26 @@ contract Deploy is Deployer {
/// @notice Initialize the DisputeGameFactory /// @notice Initialize the DisputeGameFactory
function initializeDisputeGameFactory() onlyDevnet broadcast() public { function initializeDisputeGameFactory() onlyDevnet broadcast() public {
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin")); ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
address disputeGameFactoryProxy = mustGetAddress("DisputeGameFactoryProxy"); string[2][2] memory contractNames = [
address disputeGameFactory = mustGetAddress("DisputeGameFactory"); ["DisputeGameFactoryProxy", "DisputeGameFactory"],
["MIPSDisputeGameFactoryProxy", "MIPSDisputeGameFactory"]
proxyAdmin.upgradeAndCall({ ];
_proxy: payable(disputeGameFactoryProxy), for (uint256 i; i < contractNames.length; i++) {
_implementation: disputeGameFactory, address disputeGameFactoryProxy = mustGetAddress(contractNames[i][0]);
_data: abi.encodeCall( address disputeGameFactory = mustGetAddress(contractNames[i][1]);
DisputeGameFactory.initialize,
(msg.sender) proxyAdmin.upgradeAndCall({
) _proxy: payable(disputeGameFactoryProxy),
}); _implementation: disputeGameFactory,
_data: abi.encodeCall(
DisputeGameFactory.initialize,
(msg.sender)
)
});
string memory version = DisputeGameFactory(disputeGameFactoryProxy).version(); string memory version = DisputeGameFactory(disputeGameFactoryProxy).version();
console.log("DisputeGameFactory version: %s", version); console.log("%s version: %s", contractNames[i][1], version);
}
} }
/// @notice Initialize the SystemConfig /// @notice Initialize the SystemConfig
...@@ -710,30 +724,37 @@ contract Deploy is Deployer { ...@@ -710,30 +724,37 @@ contract Deploy is Deployer {
/// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner /// @notice Transfer ownership of the DisputeGameFactory contract to the final system owner
function transferDisputeGameFactoryOwnership() onlyDevnet broadcast() public { function transferDisputeGameFactoryOwnership() onlyDevnet broadcast() public {
DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")); string[2] memory contractNames = ["DisputeGameFactoryProxy", "MIPSDisputeGameFactoryProxy"];
address owner = disputeGameFactory.owner(); for (uint256 i; i < contractNames.length; i++) {
address finalSystemOwner = cfg.finalSystemOwner(); DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress(contractNames[i]));
if (owner != finalSystemOwner) { address owner = disputeGameFactory.owner();
disputeGameFactory.transferOwnership(finalSystemOwner); address finalSystemOwner = cfg.finalSystemOwner();
console.log("DisputeGameFactory ownership transferred to: %s", finalSystemOwner); if (owner != finalSystemOwner) {
disputeGameFactory.transferOwnership(finalSystemOwner);
console.log("%s ownership transferred to: %s", contractNames[i], finalSystemOwner);
}
} }
} }
/// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory` /// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory`
function setFaultGameImplementation() onlyDevnet broadcast() public { function setFaultGameImplementation() onlyDevnet broadcast() public {
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")); string[2] memory contractNames = ["DisputeGameFactoryProxy", "MIPSDisputeGameFactoryProxy"];
Claim absolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
IBigStepper faultVm = IBigStepper(new AlphabetVM(absolutePrestate)); for (uint256 i; i < contractNames.length; i++) {
if (address(factory.gameImpls(GameTypes.FAULT)) == address(0)) { DisputeGameFactory factory = DisputeGameFactory(mustGetAddress(contractNames[i]));
factory.setImplementation(GameTypes.FAULT, new FaultDisputeGame({ Claim absolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
_absolutePrestate: absolutePrestate, IBigStepper faultVm = IBigStepper(i == 0 ? address(new AlphabetVM(absolutePrestate)) : mustGetAddress("Mips"));
_maxGameDepth: cfg.faultGameMaxDepth(), if (address(factory.gameImpls(GameTypes.FAULT)) == address(0)) {
_gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())), factory.setImplementation(GameTypes.FAULT, new FaultDisputeGame({
_vm: faultVm, _absolutePrestate: absolutePrestate,
_l2oo: L2OutputOracle(mustGetAddress("L2OutputOracleProxy")), _maxGameDepth: i == 0 ? 4 : cfg.faultGameMaxDepth(), // The max depth of the alphabet game is always 4
_blockOracle: BlockOracle(mustGetAddress("BlockOracle")) _gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())),
})); _vm: faultVm,
console.log("DisputeGameFactory: set `FaultDisputeGame` implementation"); _l2oo: L2OutputOracle(mustGetAddress("L2OutputOracleProxy")),
_blockOracle: BlockOracle(mustGetAddress("BlockOracle"))
}));
console.log("%s: set `FaultDisputeGame` implementation", contractNames[i]);
}
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment