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
Show 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 {
...
@@ -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));
...
...
packages/contracts-bedrock/src/L1/OptimismPortal.sol
View file @
00d57445
...
@@ -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 th
e
/// @notice Getter function for the address of the
guardian. This will be removed in the future, us
e
///
future, use
`SuperchainConfig.guardian()` instead.
/// `SuperchainConfig.guardian()` instead.
/// @notice Address of the
L2OutputOracle on this chai
n.
/// @notice Address of the
guardia
n.
/// @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.
...
...
packages/contracts-bedrock/test/Initializable.t.sol
View file @
00d57445
...
@@ -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
...
...
packages/contracts-bedrock/test/OptimismPortal.t.sol
View file @
00d57445
...
@@ -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.
...
...
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