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";
contract Deploy is Deployer {
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 {
super.setUp();
......@@ -44,6 +50,7 @@ contract Deploy is Deployer {
console.log("Deployment context: %s", deploymentContext);
}
/// @notice Deploy all of the L1 contracts
function run() public {
console.log("Deploying L1 system");
......@@ -149,18 +156,18 @@ contract Deploy is Deployer {
/// @notice Deploy the L1CrossDomainMessengerProxy
function deployL1CrossDomainMessengerProxy() broadcast() public returns (address) {
AddressManager addressManager = AddressManager(mustGetAddress("AddressManager"));
string memory name = "OVM_L1CrossDomainMessenger";
ResolvedDelegateProxy proxy = new ResolvedDelegateProxy(addressManager, name);
string memory contractName = "OVM_L1CrossDomainMessenger";
ResolvedDelegateProxy proxy = new ResolvedDelegateProxy(addressManager, contractName);
save("L1CrossDomainMessengerProxy", address(proxy));
console.log("L1CrossDomainMessengerProxy deployed at %s", address(proxy));
address addr = addressManager.getAddress(name);
address addr = addressManager.getAddress(contractName);
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);
}
......@@ -569,13 +576,13 @@ contract Deploy is Deployer {
}
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);
if (keccak256(bytes(name)) != keccak256(bytes(implName))) {
proxyAdmin.setImplementationName(l1CrossDomainMessengerProxy, name);
if (keccak256(bytes(contractName)) != keccak256(bytes(implName))) {
proxyAdmin.setImplementationName(l1CrossDomainMessengerProxy, contractName);
}
require(
keccak256(bytes(proxyAdmin.implementationName(l1CrossDomainMessengerProxy))) == keccak256(bytes(name))
keccak256(bytes(proxyAdmin.implementationName(l1CrossDomainMessengerProxy))) == keccak256(bytes(contractName))
);
proxyAdmin.upgradeAndCall({
......
......@@ -34,7 +34,7 @@ struct Artifact {
/// 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
/// 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.
mapping(string => Deployment) internal _namedDeployments;
/// @notice The same as `_namedDeployments` but as an array.
......@@ -66,7 +66,7 @@ contract Deployer is Script {
/// @notice Create the global variables and set up the filesystem
function setUp() public virtual {
string memory root = vm.projectRoot();
deployScript = vm.envOr("DEPLOY_SCRIPT", string("DeployConfig"));
deployScript = vm.envOr("DEPLOY_SCRIPT", name());
deploymentContext = _getDeploymentContext();
string memory deployFile = vm.envOr("DEPLOY_FILE", string("run-latest.json"));
......@@ -147,6 +147,10 @@ contract Deployer is Script {
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.
function newDeployments() external view returns (Deployment[] memory) {
return _newDeployments;
......@@ -236,10 +240,10 @@ contract Deployer is Script {
Deployment[] memory deployments = new Deployment[](names.length);
for (uint256 i; i < names.length; i++) {
string memory name = names[i];
address addr = stdJson.readAddress(json, string.concat("$.", name));
string memory contractName = names[i];
address addr = stdJson.readAddress(json, string.concat("$.", contractName));
deployments[i] = Deployment({
name: name,
name: contractName,
addr: payable(addr)
});
}
......@@ -358,9 +362,9 @@ contract Deployer is Script {
}
/// @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({
json: stdJson.serialize("", name, deployed),
json: stdJson.serialize("", _name, _deployed),
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