Skip to content

Commit

Permalink
fix: etching in fuzzing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
blmalone committed Sep 13, 2024
1 parent b8f36c1 commit 08ff8b2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
23 changes: 12 additions & 11 deletions packages/contracts-bedrock/scripts/DeployImplementations.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity 0.8.15;

import { Script } from "forge-std/Script.sol";
import "forge-std/console.sol";

import { LibString } from "@solady/utils/LibString.sol";

Expand Down Expand Up @@ -191,8 +192,8 @@ contract DeployImplementationsOutput is Script {
DeployUtils.assertValidContractAddresses(addrs);
}

function opsm() public view returns (OPStackManager) {
DeployUtils.assertValidContractAddress(address(_opsm));
function opsm() public returns (OPStackManager) {
DeployUtils.assertValidContractAddress(address(outputs.opsm));
// We prank as the zero address due to the Proxy's `proxyCallIfNotAdmin` modifier.
vm.prank(address(0));
DeployUtils.assertEIP1967Implementation(address(_opsm));
Expand Down Expand Up @@ -311,22 +312,22 @@ contract DeployImplementations is Script {
{
SuperchainConfig superchainConfigProxy = _dii.superchainConfigProxy();
ProtocolVersions protocolVersionsProxy = _dii.protocolVersionsProxy();
ProxyAdmin proxyAdmin = _dii.superchainProxyAdmin();
address proxyAdminOwner = proxyAdmin.owner();

// In this case, DeployImplementations script needs to deploy a proxy contract and the opsm contract.
// To deploy a proxy contract, you need to know the proxy admin.
// However, this proxy admin is not deployed until the OPStackManager.
// Not using blueprint because we don't have access to l2ChainId.

// Setting proxy admin to msg.sender because ProxyAdmin is not deployed yet.
vm.broadcast(msg.sender);
Proxy proxy = new Proxy(address(_dii.superchainProxyAdmin()));
vm.startBroadcast(proxyAdminOwner);
Proxy proxy = new Proxy(address(proxyAdmin));
OPStackManager opsm = new OPStackManager({
_superchainConfig: superchainConfigProxy,
_protocolVersions: protocolVersionsProxy,
_blueprints: blueprints
});
proxy.upgradeTo(address(opsm));
vm.stopBroadcast();

// We broadcast as the proxyAdminOwner address due to the ProxyAdmin's `onlyOwner` modifier.
vm.broadcast(proxyAdminOwner);
proxyAdmin.upgrade(payable(proxy), address(opsm));

opsmProxy_ = OPStackManager(address(proxy));
}

Expand Down
9 changes: 1 addition & 8 deletions packages/contracts-bedrock/scripts/libraries/DeployUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,11 @@ library DeployUtils {
require(_who.code.length > 0, string.concat("DeployUtils: no code at ", LibString.toHexStringChecksummed(_who)));
}

function assertEIP1967ImplementationSet(address _proxy) internal {
function assertEIP1967Implementation(address _proxy) internal {
address implementation = Proxy(payable(_proxy)).implementation();
assertValidContractAddress(implementation);
}

function assertEIP1967Implementation(address _proxy) internal view {
(bool success, bytes memory result) = _proxy.staticcall(abi.encodeWithSignature("implementation()"));
require(success, "DeployUtils: EIP1967 implementation check failed");
address implementation = abi.decode(result, (address));
assertValidContractAddress(implementation);
}

function assertValidContractAddresses(address[] memory _addrs) internal view {
// Assert that all addresses are non-zero and have code.
// We use LibString to avoid the need for adding cheatcodes to this contract.
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts-bedrock/test/DeployImplementations.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ contract DeployImplementations_Test is Test {
release = string(bytes.concat(hash(_seed, 5)));
superchainConfigProxy = SuperchainConfig(address(uint160(uint256(hash(_seed, 6)))));
protocolVersionsProxy = ProtocolVersions(address(uint160(uint256(hash(_seed, 7)))));
// Must configure the ProxyAdmin contract.
ProxyAdmin proxyAdmin = new ProxyAdmin(msg.sender);
_input.superchainProxyAdmin = proxyAdmin;
vm.etch(address(_input.superchainProxyAdmin), address(proxyAdmin).code);

dii.set(dii.withdrawalDelaySeconds.selector, withdrawalDelaySeconds);
dii.set(dii.minProposalSizeBytes.selector, minProposalSizeBytes);
Expand Down

0 comments on commit 08ff8b2

Please sign in to comment.