Skip to content

Commit

Permalink
feat: Fix contract labels and make more explicit
Browse files Browse the repository at this point in the history
Fixes #13391
  • Loading branch information
maurelian committed Jan 6, 2025
1 parent d32c41e commit a969e4b
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 82 deletions.
7 changes: 6 additions & 1 deletion packages/contracts-bedrock/scripts/Artifacts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ abstract contract Artifacts {

/// @notice Returns the value of the internal `_initialized` storage slot for a given contract.
function loadInitializedSlot(string memory _contractName) public returns (uint8 initialized_) {
address contractAddress = mustGetAddress(_contractName);
string memory lookupName = _contractName;
// If the contract name does not end in Proxy, add Impl to the end.
if (!LibString.endsWith(_contractName, "Proxy")) {
lookupName = string.concat(_contractName, "Impl");
}
address contractAddress = mustGetAddress(lookupName);

// Check if the contract name ends with `Proxy` and, if so override the contract name which is used to
// retrieve the storage layout.
Expand Down
73 changes: 37 additions & 36 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@ contract Deploy is Deployer {
/// @notice Returns the impl addresses, not reverting if any are unset.
function _impls() internal view returns (Types.ContractSet memory proxies_) {
proxies_ = Types.ContractSet({
L1CrossDomainMessenger: getAddress("L1CrossDomainMessenger"),
L1StandardBridge: getAddress("L1StandardBridge"),
L2OutputOracle: getAddress("L2OutputOracle"),
DisputeGameFactory: getAddress("DisputeGameFactory"),
DelayedWETH: getAddress("DelayedWETH"),
PermissionedDelayedWETH: getAddress("PermissionedDelayedWETH"),
AnchorStateRegistry: getAddress("AnchorStateRegistry"),
OptimismMintableERC20Factory: getAddress("OptimismMintableERC20Factory"),
OptimismPortal: getAddress("OptimismPortal2"),
SystemConfig: getAddress("SystemConfig"),
L1ERC721Bridge: getAddress("L1ERC721Bridge"),
ProtocolVersions: getAddress("ProtocolVersions"),
SuperchainConfig: getAddress("SuperchainConfig")
L1CrossDomainMessenger: getAddress("L1CrossDomainMessengerImpl"),
L1StandardBridge: getAddress("L1StandardBridgeImpl"),
L2OutputOracle: getAddress("L2OutputOracleImpl"),
DisputeGameFactory: getAddress("DisputeGameFactoryImpl"),
DelayedWETH: getAddress("DelayedWETHImpl"),
PermissionedDelayedWETH: getAddress("PermissionedDelayedWETHImpl"),
AnchorStateRegistry: getAddress("AnchorStateRegistryImpl"),
OptimismMintableERC20Factory: getAddress("OptimismMintableERC20FactoryImpl"),
OptimismPortal: getAddress("OptimismPortalImpl"),
SystemConfig: getAddress("SystemConfigImpl"),
L1ERC721Bridge: getAddress("L1ERC721BridgeImpl"),
ProtocolVersions: getAddress("ProtocolVersionsImpl"),
SuperchainConfig: getAddress("SuperchainConfigImpl")
});
}

Expand All @@ -170,11 +170,11 @@ contract Deploy is Deployer {
console.log("Deploying a fresh OP Stack with existing SuperchainConfig and ProtocolVersions");

IProxy scProxy = IProxy(_superchainConfigProxy);
save("SuperchainConfig", scProxy.implementation());
save("SuperchainConfigImpl", scProxy.implementation());
save("SuperchainConfigProxy", _superchainConfigProxy);

IProxy pvProxy = IProxy(_protocolVersionsProxy);
save("ProtocolVersions", pvProxy.implementation());
save("ProtocolVersionsImpl", pvProxy.implementation());
save("ProtocolVersionsProxy", _protocolVersionsProxy);

_run({ _needsSuperchain: false });
Expand Down Expand Up @@ -258,21 +258,21 @@ contract Deploy is Deployer {
ds.run(dsi, dso);
save("SuperchainProxyAdmin", address(dso.superchainProxyAdmin()));
save("SuperchainConfigProxy", address(dso.superchainConfigProxy()));
save("SuperchainConfig", address(dso.superchainConfigImpl()));
save("SuperchainConfigImpl", address(dso.superchainConfigImpl()));
save("ProtocolVersionsProxy", address(dso.protocolVersionsProxy()));
save("ProtocolVersions", address(dso.protocolVersionsImpl()));
save("ProtocolVersionsImpl", address(dso.protocolVersionsImpl()));

// First run assertions for the ProtocolVersions and SuperchainConfig proxy contracts.
Types.ContractSet memory contracts = _proxies();
ChainAssertions.checkProtocolVersions({ _contracts: contracts, _cfg: cfg, _isProxy: true });
ChainAssertions.checkSuperchainConfig({ _contracts: contracts, _cfg: cfg, _isProxy: true, _isPaused: false });

// Then replace the ProtocolVersions proxy with the implementation address and run assertions on it.
contracts.ProtocolVersions = mustGetAddress("ProtocolVersions");
contracts.ProtocolVersions = mustGetAddress("ProtocolVersionsImpl");
ChainAssertions.checkProtocolVersions({ _contracts: contracts, _cfg: cfg, _isProxy: false });

// Finally replace the SuperchainConfig proxy with the implementation address and run assertions on it.
contracts.SuperchainConfig = mustGetAddress("SuperchainConfig");
contracts.SuperchainConfig = mustGetAddress("SuperchainConfigImpl");
ChainAssertions.checkSuperchainConfig({ _contracts: contracts, _cfg: cfg, _isPaused: false, _isProxy: false });
}

Expand Down Expand Up @@ -304,19 +304,19 @@ contract Deploy is Deployer {
}
di.run(dii, dio);

save("L1CrossDomainMessenger", address(dio.l1CrossDomainMessengerImpl()));
save("OptimismMintableERC20Factory", address(dio.optimismMintableERC20FactoryImpl()));
save("SystemConfig", address(dio.systemConfigImpl()));
save("L1StandardBridge", address(dio.l1StandardBridgeImpl()));
save("L1ERC721Bridge", address(dio.l1ERC721BridgeImpl()));
save("L1CrossDomainMessengerImpl", address(dio.l1CrossDomainMessengerImpl()));
save("OptimismMintableERC20FactoryImpl", address(dio.optimismMintableERC20FactoryImpl()));
save("SystemConfigImpl", address(dio.systemConfigImpl()));
save("L1StandardBridgeImpl", address(dio.l1StandardBridgeImpl()));
save("L1ERC721BridgeImpl", address(dio.l1ERC721BridgeImpl()));

// Fault proofs
save("OptimismPortal", address(dio.optimismPortalImpl()));
save("OptimismPortal2", address(dio.optimismPortalImpl()));
save("DisputeGameFactory", address(dio.disputeGameFactoryImpl()));
save("DelayedWETH", address(dio.delayedWETHImpl()));
save("PreimageOracle", address(dio.preimageOracleSingleton()));
save("Mips", address(dio.mipsSingleton()));
save("OptimismPortalImpl", address(dio.optimismPortalImpl()));
save("OptimismPortal2Impl", address(dio.optimismPortalImpl()));
save("DisputeGameFactoryImpl", address(dio.disputeGameFactoryImpl()));
save("DelayedWETHImpl", address(dio.delayedWETHImpl()));
save("PreimageOracleSingleton", address(dio.preimageOracleSingleton()));
save("MipsSingleton", address(dio.mipsSingleton()));
save("OPContractsManager", address(dio.opcm()));

Types.ContractSet memory contracts = _impls();
Expand All @@ -343,7 +343,7 @@ contract Deploy is Deployer {
ChainAssertions.checkOPContractsManager({
_contracts: contracts,
_opcm: OPContractsManager(mustGetAddress("OPContractsManager")),
_mips: IMIPS(mustGetAddress("Mips"))
_mips: IMIPS(mustGetAddress("MipsSingleton"))
});
if (_isInterop) {
ChainAssertions.checkSystemConfigInterop({ _contracts: contracts, _cfg: cfg, _isProxy: false });
Expand Down Expand Up @@ -376,7 +376,7 @@ contract Deploy is Deployer {
save("DisputeGameFactoryProxy", address(deployOutput.disputeGameFactoryProxy));
save("PermissionedDelayedWETHProxy", address(deployOutput.delayedWETHPermissionedGameProxy));
save("AnchorStateRegistryProxy", address(deployOutput.anchorStateRegistryProxy));
save("AnchorStateRegistry", address(deployOutput.anchorStateRegistryImpl));
save("AnchorStateRegistryImpl", address(deployOutput.anchorStateRegistryImpl));
save("PermissionedDisputeGame", address(deployOutput.permissionedDisputeGame));
save("OptimismPortalProxy", address(deployOutput.optimismPortalProxy));
save("OptimismPortal2Proxy", address(deployOutput.optimismPortalProxy));
Expand All @@ -391,7 +391,7 @@ contract Deploy is Deployer {
permissionlessGameImpl == address(0),
"Deploy: The PermissionlessDelayedWETH is already set by the OPCM, it is no longer necessary to deploy it separately."
);
address delayedWETHImpl = mustGetAddress("DelayedWETH");
address delayedWETHImpl = mustGetAddress("DelayedWETHImpl");
address delayedWETHPermissionlessGameProxy = deployERC1967ProxyWithOwner("DelayedWETHProxy", msg.sender);
vm.broadcast(msg.sender);
IProxy(payable(delayedWETHPermissionlessGameProxy)).upgradeToAndCall({
Expand Down Expand Up @@ -481,6 +481,7 @@ contract Deploy is Deployer {
_save: this,
_salt: _implSalt(),
_name: "DataAvailabilityChallenge",
_nick: "DataAvailabilityChallengeImpl",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IDataAvailabilityChallenge.__constructor__, ()))
})
);
Expand All @@ -495,7 +496,7 @@ contract Deploy is Deployer {
function initializeSystemConfig() public broadcast {
console.log("Upgrading and initializing SystemConfig proxy");
address systemConfigProxy = mustGetAddress("SystemConfigProxy");
address systemConfig = mustGetAddress("SystemConfig");
address systemConfig = mustGetAddress("SystemConfigImpl");

bytes32 batcherHash = bytes32(uint256(uint160(cfg.batchSenderAddress())));

Expand Down Expand Up @@ -543,7 +544,7 @@ contract Deploy is Deployer {
function initializeDataAvailabilityChallenge() public broadcast {
console.log("Upgrading and initializing DataAvailabilityChallenge proxy");
address dataAvailabilityChallengeProxy = mustGetAddress("DataAvailabilityChallengeProxy");
address dataAvailabilityChallenge = mustGetAddress("DataAvailabilityChallenge");
address dataAvailabilityChallenge = mustGetAddress("DataAvailabilityChallengeImpl");

address finalSystemOwner = cfg.finalSystemOwner();
uint256 daChallengeWindow = cfg.daChallengeWindow();
Expand Down Expand Up @@ -727,7 +728,7 @@ contract Deploy is Deployer {
splitDepth: cfg.faultGameSplitDepth(),
clockExtension: Duration.wrap(uint64(cfg.faultGameClockExtension())),
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())),
vm: IBigStepper(mustGetAddress("Mips")),
vm: IBigStepper(mustGetAddress("MipsSingleton")),
weth: weth,
anchorStateRegistry: IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
l2ChainId: cfg.l2ChainID()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ contract DeployOwnership is Deploy {
safeConfig: SafeConfig({ threshold: 1, owners: exampleGuardianOwners }),
deputyGuardianModuleConfig: DeputyGuardianModuleConfig({
deputyGuardian: mustGetAddress("FoundationOperationsSafe"),
superchainConfig: ISuperchainConfig(mustGetAddress("SuperchainConfig"))
superchainConfig: ISuperchainConfig(mustGetAddress("SuperchainConfigImpl"))
})
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-bedrock/snapshots/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 5644
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076577)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467041)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512790)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72667)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72667)
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/test/L1/ProtocolVersions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init {
skipIfForkTest(
"ProtocolVersions_Initialize_Test: cannot test initialization on forked network against hardhat config"
);
IProtocolVersions protocolVersionsImpl = IProtocolVersions(deploy.mustGetAddress("ProtocolVersions"));
IProtocolVersions protocolVersionsImpl = IProtocolVersions(deploy.mustGetAddress("ProtocolVersionsImpl"));
address owner = deploy.cfg().finalSystemOwner();

assertEq(ProtocolVersion.unwrap(protocolVersions.required()), ProtocolVersion.unwrap(required));
Expand All @@ -42,7 +42,7 @@ contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init {

/// @dev Ensures that the events are emitted during initialization.
function test_initialize_events_succeeds() external {
IProtocolVersions protocolVersionsImpl = IProtocolVersions(deploy.mustGetAddress("ProtocolVersions"));
IProtocolVersions protocolVersionsImpl = IProtocolVersions(deploy.mustGetAddress("ProtocolVersionsImpl"));

// Wipe out the initialized slot so the proxy can be initialized again
vm.store(address(protocolVersions), bytes32(0), bytes32(0));
Expand Down
10 changes: 5 additions & 5 deletions packages/contracts-bedrock/test/setup/ForkLive.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ contract ForkLive is Deployer {
// Bridge contracts
address optimismPortal = vm.parseTomlAddress(opToml, ".addresses.OptimismPortalProxy");
save("OptimismPortalProxy", optimismPortal);
save("OptimismPortal", EIP1967Helper.getImplementation(optimismPortal));
save("OptimismPortal2", EIP1967Helper.getImplementation(optimismPortal));
save("OptimismPortalImpl", EIP1967Helper.getImplementation(optimismPortal));
save("OptimismPortal2Impl", EIP1967Helper.getImplementation(optimismPortal));

address addressManager = vm.parseTomlAddress(opToml, ".addresses.AddressManager");
save("AddressManager", addressManager);
save("L1CrossDomainMessenger", IAddressManager(addressManager).getAddress("OVM_L1CrossDomainMessenger"));
save("L1CrossDomainMessengerImpl", IAddressManager(addressManager).getAddress("OVM_L1CrossDomainMessenger"));
save("L1CrossDomainMessengerProxy", vm.parseTomlAddress(opToml, ".addresses.L1CrossDomainMessengerProxy"));
saveProxyAndImpl("OptimismMintableERC20Factory", opToml, ".addresses.OptimismMintableERC20FactoryProxy");
saveProxyAndImpl("L1StandardBridge", opToml, ".addresses.L1StandardBridgeProxy");
Expand All @@ -84,7 +84,7 @@ contract ForkLive is Deployer {

// Fault proof non-proxied contracts
save("PreimageOracle", vm.parseTomlAddress(opToml, ".addresses.PreimageOracle"));
save("Mips", vm.parseTomlAddress(opToml, ".addresses.MIPS"));
save("MipsSingleton", vm.parseTomlAddress(opToml, ".addresses.MIPS"));
IDisputeGameFactory disputeGameFactory = IDisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
save("FaultDisputeGame", vm.parseTomlAddress(opToml, ".addresses.FaultDisputeGame"));
// The PermissionedDisputeGame and PermissionedDelayedWETHProxy are not listed in the registry for OP, so we
Expand All @@ -104,6 +104,6 @@ contract ForkLive is Deployer {
save(string.concat(_contractName, "Proxy"), proxy);
address impl = EIP1967Helper.getImplementation(proxy);
require(impl != address(0), "Upgrade: Implementation address is zero");
save(_contractName, impl);
save(string.concat(_contractName, "Impl"), impl);
}
}
Loading

0 comments on commit a969e4b

Please sign in to comment.