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