Commit e7a945e8 authored by Mark Tyneway's avatar Mark Tyneway

forge-deploy: cleanup

parent af984d60
...@@ -34,6 +34,12 @@ import { Predeploys } from "../contracts/libraries/Predeploys.sol"; ...@@ -34,6 +34,12 @@ import { Predeploys } from "../contracts/libraries/Predeploys.sol";
contract Deploy is Deployer { contract Deploy is Deployer {
DeployConfig cfg; DeployConfig cfg;
/// @notice The name of the script, used to ensure the right deploy artifacts
/// are used.
function name() public pure override returns (string memory) {
return "Deploy";
}
function setUp() public override { function setUp() public override {
super.setUp(); super.setUp();
...@@ -44,6 +50,7 @@ contract Deploy is Deployer { ...@@ -44,6 +50,7 @@ contract Deploy is Deployer {
console.log("Deployment context: %s", deploymentContext); console.log("Deployment context: %s", deploymentContext);
} }
/// @notice Deploy all of the L1 contracts
function run() public { function run() public {
console.log("Deploying L1 system"); console.log("Deploying L1 system");
...@@ -149,18 +156,18 @@ contract Deploy is Deployer { ...@@ -149,18 +156,18 @@ contract Deploy is Deployer {
/// @notice Deploy the L1CrossDomainMessengerProxy /// @notice Deploy the L1CrossDomainMessengerProxy
function deployL1CrossDomainMessengerProxy() broadcast() public returns (address) { function deployL1CrossDomainMessengerProxy() broadcast() public returns (address) {
AddressManager addressManager = AddressManager(mustGetAddress("AddressManager")); AddressManager addressManager = AddressManager(mustGetAddress("AddressManager"));
string memory name = "OVM_L1CrossDomainMessenger"; string memory contractName = "OVM_L1CrossDomainMessenger";
ResolvedDelegateProxy proxy = new ResolvedDelegateProxy(addressManager, name); ResolvedDelegateProxy proxy = new ResolvedDelegateProxy(addressManager, contractName);
save("L1CrossDomainMessengerProxy", address(proxy)); save("L1CrossDomainMessengerProxy", address(proxy));
console.log("L1CrossDomainMessengerProxy deployed at %s", address(proxy)); console.log("L1CrossDomainMessengerProxy deployed at %s", address(proxy));
address addr = addressManager.getAddress(name); address addr = addressManager.getAddress(contractName);
if (addr != address(proxy)) { if (addr != address(proxy)) {
addressManager.setAddress(name, address(proxy)); addressManager.setAddress(contractName, address(proxy));
} }
require(addressManager.getAddress(name) == address(proxy)); require(addressManager.getAddress(contractName) == address(proxy));
return address(proxy); return address(proxy);
} }
...@@ -569,13 +576,13 @@ contract Deploy is Deployer { ...@@ -569,13 +576,13 @@ contract Deploy is Deployer {
} }
require(uint256(proxyAdmin.proxyType(l1CrossDomainMessengerProxy)) == uint256(ProxyAdmin.ProxyType.RESOLVED)); require(uint256(proxyAdmin.proxyType(l1CrossDomainMessengerProxy)) == uint256(ProxyAdmin.ProxyType.RESOLVED));
string memory name = "OVM_L1CrossDomainMessenger"; string memory contractName = "OVM_L1CrossDomainMessenger";
string memory implName = proxyAdmin.implementationName(l1CrossDomainMessenger); string memory implName = proxyAdmin.implementationName(l1CrossDomainMessenger);
if (keccak256(bytes(name)) != keccak256(bytes(implName))) { if (keccak256(bytes(contractName)) != keccak256(bytes(implName))) {
proxyAdmin.setImplementationName(l1CrossDomainMessengerProxy, name); proxyAdmin.setImplementationName(l1CrossDomainMessengerProxy, contractName);
} }
require( require(
keccak256(bytes(proxyAdmin.implementationName(l1CrossDomainMessengerProxy))) == keccak256(bytes(name)) keccak256(bytes(proxyAdmin.implementationName(l1CrossDomainMessengerProxy))) == keccak256(bytes(contractName))
); );
proxyAdmin.upgradeAndCall({ proxyAdmin.upgradeAndCall({
......
...@@ -34,7 +34,7 @@ struct Artifact { ...@@ -34,7 +34,7 @@ struct Artifact {
/// When a contract is deployed, call the `save` function to write its name and /// When a contract is deployed, call the `save` function to write its name and
/// contract address to disk. Then the `sync` function can be called to generate /// contract address to disk. Then the `sync` function can be called to generate
/// hardhat deploy style artifacts. Forked from `forge-deploy`. /// hardhat deploy style artifacts. Forked from `forge-deploy`.
contract Deployer is Script { abstract contract Deployer is Script {
/// @notice The set of deployments that have been done during execution. /// @notice The set of deployments that have been done during execution.
mapping(string => Deployment) internal _namedDeployments; mapping(string => Deployment) internal _namedDeployments;
/// @notice The same as `_namedDeployments` but as an array. /// @notice The same as `_namedDeployments` but as an array.
...@@ -66,7 +66,7 @@ contract Deployer is Script { ...@@ -66,7 +66,7 @@ contract Deployer is Script {
/// @notice Create the global variables and set up the filesystem /// @notice Create the global variables and set up the filesystem
function setUp() public virtual { function setUp() public virtual {
string memory root = vm.projectRoot(); string memory root = vm.projectRoot();
deployScript = vm.envOr("DEPLOY_SCRIPT", string("DeployConfig")); deployScript = vm.envOr("DEPLOY_SCRIPT", name());
deploymentContext = _getDeploymentContext(); deploymentContext = _getDeploymentContext();
string memory deployFile = vm.envOr("DEPLOY_FILE", string("run-latest.json")); string memory deployFile = vm.envOr("DEPLOY_FILE", string("run-latest.json"));
...@@ -147,6 +147,10 @@ contract Deployer is Script { ...@@ -147,6 +147,10 @@ contract Deployer is Script {
vm.removeFile(tempDeploymentsPath); vm.removeFile(tempDeploymentsPath);
} }
/// @notice Returns the name of the deployment script. Children contracts
/// must implement this to ensure that the deploy artifacts can be found.
function name() public virtual pure returns (string memory);
/// @notice Returns all of the deployments done in the current context. /// @notice Returns all of the deployments done in the current context.
function newDeployments() external view returns (Deployment[] memory) { function newDeployments() external view returns (Deployment[] memory) {
return _newDeployments; return _newDeployments;
...@@ -236,10 +240,10 @@ contract Deployer is Script { ...@@ -236,10 +240,10 @@ contract Deployer is Script {
Deployment[] memory deployments = new Deployment[](names.length); Deployment[] memory deployments = new Deployment[](names.length);
for (uint256 i; i < names.length; i++) { for (uint256 i; i < names.length; i++) {
string memory name = names[i]; string memory contractName = names[i];
address addr = stdJson.readAddress(json, string.concat("$.", name)); address addr = stdJson.readAddress(json, string.concat("$.", contractName));
deployments[i] = Deployment({ deployments[i] = Deployment({
name: name, name: contractName,
addr: payable(addr) addr: payable(addr)
}); });
} }
...@@ -358,9 +362,9 @@ contract Deployer is Script { ...@@ -358,9 +362,9 @@ contract Deployer is Script {
} }
/// @notice Adds a deployment to the temp deployments file /// @notice Adds a deployment to the temp deployments file
function _writeTemp(string memory name, address deployed) internal { function _writeTemp(string memory _name, address _deployed) internal {
vm.writeJson({ vm.writeJson({
json: stdJson.serialize("", name, deployed), json: stdJson.serialize("", _name, _deployed),
path: tempDeploymentsPath path: tempDeploymentsPath
}); });
} }
......
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