Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,9 @@ func TestEndToEndBootstrapApplyWithUpgrade(t *testing.T) {
// of the contracts-bedrock folder so upgrading directly would revert.
t.Run("upgrade superchain config", func(t *testing.T) {
upgradeConfig := embedded.UpgradeSuperchainConfigInput{
Prank: superchainProxyAdminOwner,
Opcm: impls.Opcm,
SuperchainConfig: superchain.SuperchainConfigAddr,
SuperchainProxyAdmin: superchainProxyAdmin,
Prank: superchainProxyAdminOwner,
Opcm: impls.Opcm,
SuperchainConfig: superchain.SuperchainConfigAddr,
}

err = embedded.UpgradeSuperchainConfig(host, upgradeConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
)

type UpgradeSuperchainConfigInput struct {
Prank common.Address `json:"prank"`
Opcm common.Address `json:"opcm"`
SuperchainConfig common.Address `json:"superchainConfig"`
SuperchainProxyAdmin common.Address `json:"superchainProxyAdmin"`
Prank common.Address `json:"prank"`
Opcm common.Address `json:"opcm"`
SuperchainConfig common.Address `json:"superchainConfig"`
}

type UpgradeSuperchainConfigScript script.DeployScriptWithoutOutput[UpgradeSuperchainConfigInput]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ interface IOPContractsManagerUpgrader {

function upgrade(IOPContractsManager.OpChainConfig[] memory _opChainConfigs) external;

function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig, IProxyAdmin _superchainProxyAdmin) external;
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig) external;

function contractsContainer() external view returns (IOPContractsManagerContractsContainer);
}
Expand Down Expand Up @@ -343,8 +343,7 @@ interface IOPContractsManager {

/// @notice Upgrades the SuperchainConfig contract.
/// @param _superchainConfig The SuperchainConfig contract to upgrade.
/// @param _superchainProxyAdmin The ProxyAdmin contract to use for the upgrade.
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig, IProxyAdmin _superchainProxyAdmin) external;
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig) external;

/// @notice addGameType deploys a new dispute game and links it to the DisputeGameFactory. The inputted _gameConfigs
/// must be added in ascending GameType order.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ pragma solidity ^0.8.0;
import { Script } from "forge-std/Script.sol";
import { IOPContractsManager } from "interfaces/L1/IOPContractsManager.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { IProxyAdmin } from "interfaces/universal/IProxyAdmin.sol";

contract UpgradeSuperchainConfig is Script {
struct Input {
address prank;
IOPContractsManager opcm;
ISuperchainConfig superchainConfig;
IProxyAdmin superchainProxyAdmin;
}

/// @notice Delegate calls upgradeSuperchainConfig on the OPCM from the input.prank address.
Expand All @@ -33,12 +31,11 @@ contract UpgradeSuperchainConfig is Script {
vm.label(prank, "DummyCaller");

ISuperchainConfig superchainConfig = _input.superchainConfig;
IProxyAdmin superchainProxyAdmin = _input.superchainProxyAdmin;

// Call into the DummyCaller to perform the delegatecall
vm.broadcast(msg.sender);

(bool success,) = DummyCaller(prank).upgradeSuperchainConfig(superchainConfig, superchainProxyAdmin);
(bool success,) = DummyCaller(prank).upgradeSuperchainConfig(superchainConfig);
require(success, "UpgradeSuperchainConfig: upgradeSuperchainConfig failed");
}

Expand All @@ -47,9 +44,6 @@ contract UpgradeSuperchainConfig is Script {
require(_input.prank != address(0), "UpgradeSuperchainConfig: prank not set");
require(address(_input.opcm) != address(0), "UpgradeSuperchainConfig: opcm not set");
require(address(_input.superchainConfig) != address(0), "UpgradeSuperchainConfig: superchainConfig not set");
require(
address(_input.superchainProxyAdmin) != address(0), "UpgradeSuperchainConfig: superchainProxyAdmin not set"
);
}
}

Expand All @@ -58,15 +52,8 @@ contract UpgradeSuperchainConfig is Script {
contract DummyCaller {
address internal _opcmAddr;

function upgradeSuperchainConfig(
ISuperchainConfig _superchainConfig,
IProxyAdmin _superchainProxyAdmin
)
external
returns (bool, bytes memory)
{
bytes memory data =
abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (_superchainConfig, _superchainProxyAdmin));
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig) external returns (bool, bytes memory) {
bytes memory data = abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (_superchainConfig));
(bool success, bytes memory result) = _opcmAddr.delegatecall(data);
return (success, result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,6 @@
"internalType": "contract ISuperchainConfig",
"name": "_superchainConfig",
"type": "address"
},
{
"internalType": "contract IProxyAdmin",
"name": "_superchainProxyAdmin",
"type": "address"
}
],
"name": "upgradeSuperchainConfig",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@
"internalType": "contract ISuperchainConfig",
"name": "_superchainConfig",
"type": "address"
},
{
"internalType": "contract IProxyAdmin",
"name": "_superchainProxyAdmin",
"type": "address"
}
],
"name": "upgradeSuperchainConfig",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"sourceCodeHash": "0xfca613b5d055ffc4c3cbccb0773ddb9030abedc1aa6508c9e2e7727cc0cd617b"
},
"src/L1/OPContractsManager.sol:OPContractsManager": {
"initCodeHash": "0xc6a5146f158bc14297447cda1668f83e8dbfdd74f1b8bc2291d9626933bd23ad",
"sourceCodeHash": "0xd883ebfcc637ba9c6de12a872015098614cd288aaee84cda9d4c746aa1dcba18"
"initCodeHash": "0x0ef3fcb6fee1f73c95a48269bba8c83ee463a6f116f36f8d88edb247f72e8a05",
"sourceCodeHash": "0x16a845ddb5ee469e81f3d817ee9f6d6ff5697ace0bc399bd1e0f26e05546f781"
},
"src/L1/OPContractsManagerStandardValidator.sol:OPContractsManagerStandardValidator": {
"initCodeHash": "0x2eaa345ba05582c67b40a1eb7ec9d54823aa08468e697e2d6c04bb74cc574abc",
Expand Down
16 changes: 7 additions & 9 deletions packages/contracts-bedrock/src/L1/OPContractsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,9 @@ contract OPContractsManagerUpgrader is OPContractsManagerBase {

/// @notice Upgrades the SuperchainConfig contract.
/// @param _superchainConfig The SuperchainConfig contract to upgrade.
/// @param _superchainProxyAdmin The ProxyAdmin contract to use for the upgrade.
/// @dev This function is intended to be DELEGATECALLed by the superchainConfig's ProxyAdminOwner.
/// @dev This function will revert if the SuperchainConfig is already at or above the target version.
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig, IProxyAdmin _superchainProxyAdmin) external {
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig) external {
// Only upgrade the superchainConfig if the current version is less than the target version.
if (
SemverComp.gte(
Expand All @@ -1018,6 +1017,8 @@ contract OPContractsManagerUpgrader is OPContractsManagerBase {

// Grab the implementations.
OPContractsManager.Implementations memory impls = getImplementations();
// Grab the superchainConfig's proxyAdmin.
IProxyAdmin _superchainProxyAdmin = IProxyAdmin(_superchainConfig.proxyAdmin());

// Attempt to upgrade. If the ProxyAdmin is not the SuperchainConfig's admin, this will revert.
upgradeTo(_superchainProxyAdmin, address(_superchainConfig), impls.superchainConfigImpl);
Expand Down Expand Up @@ -2088,9 +2089,9 @@ contract OPContractsManager is ISemver {

// -------- Constants and Variables --------

/// @custom:semver 4.3.0
/// @custom:semver 4.4.0
function version() public pure virtual returns (string memory) {
return "4.3.0";
return "4.4.0";
}

OPContractsManagerGameTypeAdder public immutable opcmGameTypeAdder;
Expand Down Expand Up @@ -2232,15 +2233,12 @@ contract OPContractsManager is ISemver {

/// @notice Upgrades the SuperchainConfig contract.
/// @param _superchainConfig The SuperchainConfig contract to upgrade.
/// @param _superchainProxyAdmin The ProxyAdmin contract to use for the upgrade.
/// @dev This function is intended to be DELEGATECALLed by the superchainConfig's ProxyAdminOwner.
/// @dev This function will revert if the SuperchainConfig is already at or above the target version.
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig, IProxyAdmin _superchainProxyAdmin) external {
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig) external {
if (address(this) == address(thisOPCM)) revert OnlyDelegatecall();

bytes memory data = abi.encodeCall(
OPContractsManagerUpgrader.upgradeSuperchainConfig, (_superchainConfig, _superchainProxyAdmin)
);
bytes memory data = abi.encodeCall(OPContractsManagerUpgrader.upgradeSuperchainConfig, (_superchainConfig));
_performDelegateCall(address(opcmUpgrader), data);
}

Expand Down
14 changes: 5 additions & 9 deletions packages/contracts-bedrock/test/L1/OPContractsManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ contract OPContractsManager_Upgrade_Harness is CommonTest {
// Execute the SuperchainConfig upgrade.
// nosemgrep: sol-safety-trycatch-eip150
try DelegateCaller(superchainPAO).dcForward(
address(_opcm),
abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig, superchainProxyAdmin))
address(_opcm), abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig))
) {
// Great, the upgrade succeeded.
} catch (bytes memory reason) {
Expand Down Expand Up @@ -1535,8 +1534,7 @@ contract OPContractsManager_UpgradeSuperchainConfig_Test is OPContractsManager_U
vm.expectEmit(address(superchainConfig));
emit Upgraded(impls.superchainConfigImpl);
DelegateCaller(superchainPAO).dcForward(
address(opcm),
abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig, superchainProxyAdmin))
address(opcm), abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig))
);
}

Expand All @@ -1545,7 +1543,7 @@ contract OPContractsManager_UpgradeSuperchainConfig_Test is OPContractsManager_U
ISuperchainConfig superchainConfig = ISuperchainConfig(artifacts.mustGetAddress("SuperchainConfigProxy"));

vm.expectRevert(IOPContractsManager.OnlyDelegatecall.selector);
opcm.upgradeSuperchainConfig(superchainConfig, superchainProxyAdmin);
opcm.upgradeSuperchainConfig(superchainConfig);
}

/// @notice Tests that the upgradeSuperchainConfig function reverts when the delegate caller is not the
Expand All @@ -1561,8 +1559,7 @@ contract OPContractsManager_UpgradeSuperchainConfig_Test is OPContractsManager_U

vm.expectRevert("Ownable: caller is not the owner");
DelegateCaller(delegateCaller).dcForward(
address(opcm),
abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig, superchainProxyAdmin))
address(opcm), abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig))
);
}

Expand All @@ -1580,8 +1577,7 @@ contract OPContractsManager_UpgradeSuperchainConfig_Test is OPContractsManager_U
// Try to upgrade the SuperchainConfig contract again, should fail.
vm.expectRevert(IOPContractsManagerUpgrader.OPContractsManagerUpgrader_SuperchainConfigAlreadyUpToDate.selector);
DelegateCaller(upgrader).dcForward(
address(opcm),
abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig, superchainProxyAdmin))
address(opcm), abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";

import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { IProxyAdmin } from "interfaces/universal/IProxyAdmin.sol";

import { UpgradeSuperchainConfig } from "scripts/deploy/UpgradeSuperchainConfig.s.sol";
import { IOPContractsManager } from "interfaces/L1/IOPContractsManager.sol";

/// @title MockOPCM
/// @notice This contract is used to mock the OPCM contract and emit an event which we check for in the test.
contract MockOPCM {
event UpgradeCalled(address indexed superchainConfig, address indexed superchainProxyAdmin);
event UpgradeCalled(address indexed superchainConfig);

function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig, IProxyAdmin _superchainProxyAdmin) public {
emit UpgradeCalled(address(_superchainConfig), address(_superchainProxyAdmin));
function upgradeSuperchainConfig(ISuperchainConfig _superchainConfig) public {
emit UpgradeCalled(address(_superchainConfig));
}
}

Expand All @@ -27,9 +26,8 @@ contract UpgradeSuperchainConfig_Run_Test is Test {
UpgradeSuperchainConfig upgradeSuperchainConfig;
address prank;
ISuperchainConfig superchainConfig;
IProxyAdmin superchainProxyAdmin;

event UpgradeCalled(address indexed superchainConfig, address indexed superchainProxyAdmin);
event UpgradeCalled(address indexed superchainConfig);

/// @notice Sets up the test suite.
function setUp() public virtual {
Expand All @@ -38,11 +36,9 @@ contract UpgradeSuperchainConfig_Run_Test is Test {
input.opcm = IOPContractsManager(address(mockOPCM));

superchainConfig = ISuperchainConfig(makeAddr("superchainConfig"));
superchainProxyAdmin = IProxyAdmin(makeAddr("superchainProxyAdmin"));
prank = makeAddr("prank");

input.superchainConfig = superchainConfig;
input.superchainProxyAdmin = superchainProxyAdmin;
input.prank = prank;

upgradeSuperchainConfig = new UpgradeSuperchainConfig();
Expand All @@ -52,7 +48,7 @@ contract UpgradeSuperchainConfig_Run_Test is Test {
function test_upgrade_succeeds() public {
// UpgradeCalled should be emitted by the prank since it's a delegate call.
vm.expectEmit(address(prank));
emit UpgradeCalled(address(superchainConfig), address(superchainProxyAdmin));
emit UpgradeCalled(address(superchainConfig));
upgradeSuperchainConfig.run(input);
}

Expand All @@ -72,10 +68,5 @@ contract UpgradeSuperchainConfig_Run_Test is Test {
vm.expectRevert("UpgradeSuperchainConfig: superchainConfig not set");
upgradeSuperchainConfig.run(input);
input.superchainConfig = ISuperchainConfig(address(superchainConfig));

input.superchainProxyAdmin = IProxyAdmin(address(0));
vm.expectRevert("UpgradeSuperchainConfig: superchainProxyAdmin not set");
upgradeSuperchainConfig.run(input);
input.superchainProxyAdmin = IProxyAdmin(address(superchainProxyAdmin));
}
}
3 changes: 1 addition & 2 deletions packages/contracts-bedrock/test/setup/ForkLive.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ contract ForkLive is Deployer, StdAssertions {
// Always try to upgrade the SuperchainConfig. Not always necessary but easier to do it
// every time rather than adding or removing this code for each upgrade.
try DelegateCaller(superchainPAO).dcForward(
address(_opcm),
abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig, superchainProxyAdmin))
address(_opcm), abi.encodeCall(IOPContractsManager.upgradeSuperchainConfig, (superchainConfig))
) {
// Great, the upgrade succeeded.
} catch (bytes memory reason) {
Expand Down