Commit 00d57445 authored by Maurelian's avatar Maurelian

contracts-bedrock: Move SuperchainConfig address to storage

parent 7acc2d23
......@@ -935,11 +935,12 @@ contract Deploy is Deployer {
console.log("Upgrading and initializing OptimismPortal proxy");
address optimismPortalProxy = mustGetAddress("OptimismPortalProxy");
address optimismPortal = mustGetAddress("OptimismPortal");
SuperchainConfig superchainConfigProxy = SuperchainConfig(mustGetAddress("SuperchainConfigProxy"));
_upgradeAndCallViaSafe({
_proxy: payable(optimismPortalProxy),
_implementation: optimismPortal,
_innerCallData: abi.encodeCall(OptimismPortal.initialize, ())
_innerCallData: abi.encodeCall(OptimismPortal.initialize, (superchainConfigProxy))
});
OptimismPortal portal = OptimismPortal(payable(optimismPortalProxy));
......
......@@ -47,14 +47,6 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
/// @custom:legacy
SystemConfig public immutable SYSTEM_CONFIG;
/// @notice Address that has the ability to pause and unpause withdrawals. This will be removed in the
/// future, use `guardian` instead.
/// @custom:legacy
address public immutable GUARDIAN;
/// @notice The address of the Superchain Config contract.
SuperchainConfig internal immutable SUPERCHAIN_CONFIG;
/// @notice Address of the L2 account which initiated a withdrawal in this transaction.
/// If the of this variable is the default L2 sender address, then we are NOT inside of
/// a call to finalizeWithdrawalTransaction.
......@@ -119,14 +111,14 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
constructor(L2OutputOracle _l2Oracle, SystemConfig _systemConfig, SuperchainConfig _superchainConfig) {
L2_ORACLE = _l2Oracle;
SYSTEM_CONFIG = _systemConfig;
SUPERCHAIN_CONFIG = _superchainConfig;
GUARDIAN = _superchainConfig.guardian();
initialize();
initialize(_superchainConfig);
}
/// @notice Initializer.
function initialize() public initializer {
/// @param _superchainConfig Address of the SuperchainConfig contract.
function initialize(SuperchainConfig _superchainConfig) public initializer {
l2Sender = Constants.DEFAULT_L2_SENDER;
superchainConfig = _superchainConfig;
__ResourceMetering_init();
}
......@@ -142,23 +134,25 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
return SYSTEM_CONFIG;
}
/// @notice Getter function for the address of the L2OutputOracle on this chain. This will be removed in the
/// future, use `SuperchainConfig.guardian()` instead.
/// @notice Address of the L2OutputOracle on this chain.
/// @notice Getter function for the address of the guardian. This will be removed in the future, use
/// `SuperchainConfig.guardian()` instead.
/// @notice Address of the guardian.
/// @custom:legacy
function guardian() public view returns (address) {
return SUPERCHAIN_CONFIG.guardian();
function GUARDIAN() external view returns (address) {
return guardian();
}
/// @notice Getter function for the address of the SuperchainConfig on this chain.
/// @return SuperchainConfig Address of the SuperchainConfig on this chain.
function superchainConfig() public view returns (SuperchainConfig) {
return SUPERCHAIN_CONFIG;
/// @notice Getter function for the address of the guardian. This will be removed in the future, use
/// `SuperchainConfig.guardian()` instead.
/// @notice Address of the guardian.
/// @custom:legacy
function guardian() public view returns (address) {
return superchainConfig.guardian();
}
/// @notice Getter for the current paused status.
function paused() public view returns (bool paused_) {
paused_ = SUPERCHAIN_CONFIG.paused();
paused_ = superchainConfig.paused();
}
/// @notice Computes the minimum gas limit for a deposit.
......
......@@ -64,7 +64,7 @@ contract Initializer_Test is Bridge_Initializer {
InitializeableContract({
target: address(optimismPortal),
initCalldata: abi.encodeCall(optimismPortal.initialize, ()),
initializedSlotVal: deploy.loadInitializedSlot("OptimismPortal", true)
initializedSlotVal: loadInitializedSlot("OptimismPortal", true)
})
);
// SystemConfig
......
......@@ -18,6 +18,7 @@ import { ResourceMetering } from "src/L1/ResourceMetering.sol";
import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
import { SystemConfig } from "src/L1/SystemConfig.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
import { OptimismPortal } from "src/L1/OptimismPortal.sol";
contract OptimismPortal_Test is CommonTest {
......@@ -895,15 +896,17 @@ contract OptimismPortalUpgradeable_Test is CommonTest {
/// @dev Tests that the proxy cannot be initialized twice.
function test_initialize_cannotInitProxy_reverts() external {
SuperchainConfig superchainConfig = SuperchainConfig(mustGetAddress("SuperchainConfig"));
vm.expectRevert("Initializable: contract is already initialized");
optimismPortal.initialize();
optimismPortal.initialize(superchainConfig);
}
/// @dev Tests that the implementation cannot be initialized twice.
function test_initialize_cannotInitImpl_reverts() external {
address opImpl = deploy.mustGetAddress("OptimismPortal");
SuperchainConfig superchainConfig = SuperchainConfig(mustGetAddress("SuperchainConfig"));
vm.expectRevert("Initializable: contract is already initialized");
OptimismPortal(payable(opImpl)).initialize();
OptimismPortal(payable(opImpl)).initialize(superchainConfig);
}
/// @dev Tests that the proxy can be upgraded.
......
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