Commit f4c454d1 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: cleanup deploy script

Use a standard modifier to skip deploying contracts to non devnet
networks. Simplifies the code, removes branching, ensures that
the contracts are always deployed as expected.
parent a9dcc0b1
...@@ -109,6 +109,14 @@ contract Deploy is Deployer { ...@@ -109,6 +109,14 @@ contract Deploy is Deployer {
vm.stopBroadcast(); vm.stopBroadcast();
} }
/// @notice Modifier that will only allow a function to be called on devnet.
modifier onlyDevnet() internal view returns (bool) {
uint256 chainid = block.chainid;
if chaind != Chains.LocalDevnet && chainid != Chains.GethDevnet {
_;
}
}
/// @notice Deploy the AddressManager /// @notice Deploy the AddressManager
function deployAddressManager() broadcast() public returns (address) { function deployAddressManager() broadcast() public returns (address) {
AddressManager manager = new AddressManager(); AddressManager manager = new AddressManager();
...@@ -250,8 +258,7 @@ contract Deploy is Deployer { ...@@ -250,8 +258,7 @@ contract Deploy is Deployer {
} }
/// @notice Deploy the DisputeGameFactoryProxy /// @notice Deploy the DisputeGameFactoryProxy
function deployDisputeGameFactoryProxy() broadcast() public returns (address) { function deployDisputeGameFactoryProxy() onlyDevnet broadcast() public returns (address) {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
address proxyAdmin = mustGetAddress("ProxyAdmin"); address proxyAdmin = mustGetAddress("ProxyAdmin");
Proxy proxy = new Proxy({ Proxy proxy = new Proxy({
_admin: proxyAdmin _admin: proxyAdmin
...@@ -265,8 +272,6 @@ contract Deploy is Deployer { ...@@ -265,8 +272,6 @@ contract Deploy is Deployer {
return address(proxy); return address(proxy);
} }
return address(0);
}
/// @notice Deploy the L1CrossDomainMessenger /// @notice Deploy the L1CrossDomainMessenger
function deployL1CrossDomainMessenger() broadcast() public returns (address) { function deployL1CrossDomainMessenger() broadcast() public returns (address) {
...@@ -351,40 +356,37 @@ contract Deploy is Deployer { ...@@ -351,40 +356,37 @@ contract Deploy is Deployer {
} }
/// @notice Deploy the DisputeGameFactory /// @notice Deploy the DisputeGameFactory
function deployDisputeGameFactory() broadcast() public returns (address) { function deployDisputeGameFactory() onlyDevnet broadcast() public returns (address) {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
DisputeGameFactory factory = new DisputeGameFactory(); DisputeGameFactory factory = new DisputeGameFactory();
save("DisputeGameFactory", address(factory)); save("DisputeGameFactory", address(factory));
console.log("DisputeGameFactory deployed at %s", address(factory)); console.log("DisputeGameFactory deployed at %s", address(factory));
return address(factory); return address(factory);
} }
return address(0);
}
/// @notice Deploy the PreimageOracle /// @notice Deploy the PreimageOracle
function deployPreimageOracle() broadcast() public returns (address) { function deployPreimageOracle() onlyDevnet broadcast() public returns (address) {
if (block.chainid == 900) {
PreimageOracle preimageOracle = new PreimageOracle(); PreimageOracle preimageOracle = new PreimageOracle();
save("PreimageOracle", address(preimageOracle)); save("PreimageOracle", address(preimageOracle));
console.log("PreimageOracle deployed at %s", address(preimageOracle)); console.log("PreimageOracle deployed at %s", address(preimageOracle));
string memory version = preimageOracle.version();
console.log("PreimageOracle version: %s", version);
return address(preimageOracle); return address(preimageOracle);
} }
return address(0);
}
/// @notice Deploy Mips /// @notice Deploy Mips
function deployMips() broadcast() public returns (address) { function deployMips() onlyDevnet broadcast() public returns (address) {
if (block.chainid == 900) {
MIPS mips = new MIPS(); MIPS mips = new MIPS();
save("Mips", address(mips)); save("Mips", address(mips));
console.log("Mips deployed at %s", address(mips)); console.log("MIPS deployed at %s", address(mips));
string memory version = mips.version();
console.log("MIPS version: %s", version);
return address(mips); return address(mips);
} }
return address(0);
}
/// @notice Deploy the SystemConfig /// @notice Deploy the SystemConfig
function deploySystemConfig() broadcast() public returns (address) { function deploySystemConfig() broadcast() public returns (address) {
...@@ -470,8 +472,7 @@ contract Deploy is Deployer { ...@@ -470,8 +472,7 @@ contract Deploy is Deployer {
} }
/// @notice Initialize the DisputeGameFactory /// @notice Initialize the DisputeGameFactory
function initializeDisputeGameFactory() broadcast() public { function initializeDisputeGameFactory() onlyDevnet broadcast() public {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin")); ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
address disputeGameFactoryProxy = mustGetAddress("DisputeGameFactoryProxy"); address disputeGameFactoryProxy = mustGetAddress("DisputeGameFactoryProxy");
address disputeGameFactory = mustGetAddress("DisputeGameFactory"); address disputeGameFactory = mustGetAddress("DisputeGameFactory");
...@@ -488,7 +489,6 @@ contract Deploy is Deployer { ...@@ -488,7 +489,6 @@ contract Deploy is Deployer {
string memory version = DisputeGameFactory(disputeGameFactoryProxy).version(); string memory version = DisputeGameFactory(disputeGameFactoryProxy).version();
console.log("DisputeGameFactory version: %s", version); console.log("DisputeGameFactory version: %s", version);
} }
}
/// @notice Initialize the SystemConfig /// @notice Initialize the SystemConfig
function initializeSystemConfig() broadcast() public { function initializeSystemConfig() broadcast() public {
...@@ -704,8 +704,7 @@ contract Deploy is Deployer { ...@@ -704,8 +704,7 @@ 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() broadcast() public { function transferDisputeGameFactoryOwnership() onlyDevnet broadcast() public {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")); DisputeGameFactory disputeGameFactory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
address owner = disputeGameFactory.owner(); address owner = disputeGameFactory.owner();
address finalSystemOwner = cfg.finalSystemOwner(); address finalSystemOwner = cfg.finalSystemOwner();
...@@ -714,11 +713,9 @@ contract Deploy is Deployer { ...@@ -714,11 +713,9 @@ contract Deploy is Deployer {
console.log("DisputeGameFactory ownership transferred to: %s", finalSystemOwner); console.log("DisputeGameFactory ownership transferred to: %s", 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() broadcast() public { function setFaultGameImplementation() onlyDevnet broadcast() public {
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")); DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
Claim absolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())); Claim absolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
IBigStepper faultVm = IBigStepper(new AlphabetVM(absolutePrestate)); IBigStepper faultVm = IBigStepper(new AlphabetVM(absolutePrestate));
...@@ -733,6 +730,5 @@ contract Deploy is Deployer { ...@@ -733,6 +730,5 @@ contract Deploy is Deployer {
console.log("DisputeGameFactory: set `FaultDisputeGame` implementation"); console.log("DisputeGameFactory: set `FaultDisputeGame` implementation");
} }
} }
}
} }
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