Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
00d57445
Unverified
Commit
00d57445
authored
Nov 27, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: Move SuperchainConfig address to storage
parent
7acc2d23
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
26 deletions
+24
-26
Deploy.s.sol
packages/contracts-bedrock/scripts/Deploy.s.sol
+2
-1
OptimismPortal.sol
packages/contracts-bedrock/src/L1/OptimismPortal.sol
+16
-22
Initializable.t.sol
packages/contracts-bedrock/test/Initializable.t.sol
+1
-1
OptimismPortal.t.sol
packages/contracts-bedrock/test/OptimismPortal.t.sol
+5
-2
No files found.
packages/contracts-bedrock/scripts/Deploy.s.sol
View file @
00d57445
...
...
@@ -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));
...
...
packages/contracts-bedrock/src/L1/OptimismPortal.sol
View file @
00d57445
...
...
@@ -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 th
e
///
future, use
`SuperchainConfig.guardian()` instead.
/// @notice Address of the
L2OutputOracle on this chai
n.
/// @notice Getter function for the address of the
guardian. This will be removed in the future, us
e
/// `SuperchainConfig.guardian()` instead.
/// @notice Address of the
guardia
n.
/// @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.
...
...
packages/contracts-bedrock/test/Initializable.t.sol
View file @
00d57445
...
...
@@ -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
...
...
packages/contracts-bedrock/test/OptimismPortal.t.sol
View file @
00d57445
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment