Commit b0a4c114 authored by smartcontracts's avatar smartcontracts Committed by GitHub

maint(ct): add leftover interfaces (#12167)

Adds a few remaining interfaces required before we can migrate
OPCM to use interfaces over source contracts.
parent 169f808f
...@@ -885,7 +885,7 @@ contract DeployImplementations is Script { ...@@ -885,7 +885,7 @@ contract DeployImplementations is Script {
if (existingImplementation != address(0)) { if (existingImplementation != address(0)) {
singleton = MIPS(payable(existingImplementation)); singleton = MIPS(payable(existingImplementation));
} else if (isDevelopRelease(release)) { } else if (isDevelopRelease(release)) {
IPreimageOracle preimageOracle = IPreimageOracle(_dio.preimageOracleSingleton()); IPreimageOracle preimageOracle = IPreimageOracle(address(_dio.preimageOracleSingleton()));
vm.broadcast(msg.sender); vm.broadcast(msg.sender);
singleton = new MIPS(preimageOracle); singleton = new MIPS(preimageOracle);
} else { } else {
......
...@@ -10,9 +10,6 @@ import { DeployConfig } from "scripts/deploy/DeployConfig.s.sol"; ...@@ -10,9 +10,6 @@ import { DeployConfig } from "scripts/deploy/DeployConfig.s.sol";
import { Deployer } from "scripts/deploy/Deployer.sol"; import { Deployer } from "scripts/deploy/Deployer.sol";
import { ISystemConfigV0 } from "scripts/interfaces/ISystemConfigV0.sol"; import { ISystemConfigV0 } from "scripts/interfaces/ISystemConfigV0.sol";
// Contracts
import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
// Libraries // Libraries
import { Constants } from "src/libraries/Constants.sol"; import { Constants } from "src/libraries/Constants.sol";
import { Predeploys } from "src/libraries/Predeploys.sol"; import { Predeploys } from "src/libraries/Predeploys.sol";
......
...@@ -26,25 +26,19 @@ import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol"; ...@@ -26,25 +26,19 @@ import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol";
import { DeployUtils } from "scripts/libraries/DeployUtils.sol"; import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
// Contracts // Contracts
import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
import { AddressManager } from "src/legacy/AddressManager.sol"; import { AddressManager } from "src/legacy/AddressManager.sol";
import { Proxy } from "src/universal/Proxy.sol";
import { StandardBridge } from "src/universal/StandardBridge.sol";
import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol";
import { ResolvedDelegateProxy } from "src/legacy/ResolvedDelegateProxy.sol";
import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
import { MIPS } from "src/cannon/MIPS.sol";
import { MIPS2 } from "src/cannon/MIPS2.sol";
import { StorageSetter } from "src/universal/StorageSetter.sol"; import { StorageSetter } from "src/universal/StorageSetter.sol";
// Libraries // Libraries
import { Constants } from "src/libraries/Constants.sol"; import { Constants } from "src/libraries/Constants.sol";
import { Predeploys } from "src/libraries/Predeploys.sol"; import { Predeploys } from "src/libraries/Predeploys.sol";
import { Types } from "scripts/libraries/Types.sol"; import { Types } from "scripts/libraries/Types.sol";
import "src/dispute/lib/Types.sol";
import { LibClaim, Duration } from "src/dispute/lib/LibUDT.sol"; import { LibClaim, Duration } from "src/dispute/lib/LibUDT.sol";
import "src/dispute/lib/Types.sol";
// Interfaces // Interfaces
import { IProxy } from "src/universal/interfaces/IProxy.sol";
import { IProxyAdmin } from "src/universal/interfaces/IProxyAdmin.sol";
import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol";
import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol";
import { IOptimismPortalInterop } from "src/L1/interfaces/IOptimismPortalInterop.sol"; import { IOptimismPortalInterop } from "src/L1/interfaces/IOptimismPortalInterop.sol";
...@@ -65,8 +59,13 @@ import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol" ...@@ -65,8 +59,13 @@ import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol"
import { IPermissionedDisputeGame } from "src/dispute/interfaces/IPermissionedDisputeGame.sol"; import { IPermissionedDisputeGame } from "src/dispute/interfaces/IPermissionedDisputeGame.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IMIPS } from "src/cannon/interfaces/IMIPS.sol";
import { IMIPS2 } from "src/cannon/interfaces/IMIPS2.sol";
import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol"; import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol";
import { IOptimismMintableERC20Factory } from "src/universal/interfaces/IOptimismMintableERC20Factory.sol"; import { IOptimismMintableERC20Factory } from "src/universal/interfaces/IOptimismMintableERC20Factory.sol";
import { IAddressManager } from "src/legacy/interfaces/IAddressManager.sol";
import { IL1ChugSplashProxy } from "src/legacy/interfaces/IL1ChugSplashProxy.sol";
import { IResolvedDelegateProxy } from "src/legacy/interfaces/IResolvedDelegateProxy.sol";
/// @title Deploy /// @title Deploy
/// @notice Script used to deploy a bedrock system. The entire system is deployed within the `run` function. /// @notice Script used to deploy a bedrock system. The entire system is deployed within the `run` function.
...@@ -245,7 +244,7 @@ contract Deploy is Deployer { ...@@ -245,7 +244,7 @@ contract Deploy is Deployer {
address proxyAdmin = mustGetAddress("ProxyAdmin"); address proxyAdmin = mustGetAddress("ProxyAdmin");
bytes memory data = bytes memory data =
abi.encodeCall(ProxyAdmin.upgradeAndCall, (payable(_proxy), _implementation, _innerCallData)); abi.encodeCall(IProxyAdmin.upgradeAndCall, (payable(_proxy), _implementation, _innerCallData));
Safe safe = Safe(mustGetAddress("SystemOwnerSafe")); Safe safe = Safe(mustGetAddress("SystemOwnerSafe"));
_callViaSafe({ _safe: safe, _target: proxyAdmin, _data: data }); _callViaSafe({ _safe: safe, _target: proxyAdmin, _data: data });
...@@ -253,7 +252,7 @@ contract Deploy is Deployer { ...@@ -253,7 +252,7 @@ contract Deploy is Deployer {
/// @notice Transfer ownership of the ProxyAdmin contract to the final system owner /// @notice Transfer ownership of the ProxyAdmin contract to the final system owner
function transferProxyAdminOwnership() public broadcast { function transferProxyAdminOwnership() public broadcast {
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin")); IProxyAdmin proxyAdmin = IProxyAdmin(mustGetAddress("ProxyAdmin"));
address owner = proxyAdmin.owner(); address owner = proxyAdmin.owner();
address safe = mustGetAddress("SystemOwnerSafe"); address safe = mustGetAddress("SystemOwnerSafe");
if (owner != safe) { if (owner != safe) {
...@@ -267,7 +266,7 @@ contract Deploy is Deployer { ...@@ -267,7 +266,7 @@ contract Deploy is Deployer {
/// have been performed on the proxy. /// have been performed on the proxy.
/// @param _name The name of the proxy to transfer ownership of. /// @param _name The name of the proxy to transfer ownership of.
function transferProxyToProxyAdmin(string memory _name) public broadcast { function transferProxyToProxyAdmin(string memory _name) public broadcast {
Proxy proxy = Proxy(mustGetAddress(_name)); IProxy proxy = IProxy(mustGetAddress(_name));
address proxyAdmin = mustGetAddress("ProxyAdmin"); address proxyAdmin = mustGetAddress("ProxyAdmin");
proxy.changeAdmin(proxyAdmin); proxy.changeAdmin(proxyAdmin);
console.log("Proxy %s ownership transferred to ProxyAdmin at: %s", _name, proxyAdmin); console.log("Proxy %s ownership transferred to ProxyAdmin at: %s", _name, proxyAdmin);
...@@ -301,11 +300,11 @@ contract Deploy is Deployer { ...@@ -301,11 +300,11 @@ contract Deploy is Deployer {
console.log("Deploying a fresh OP Stack with existing SuperchainConfig and ProtocolVersions"); console.log("Deploying a fresh OP Stack with existing SuperchainConfig and ProtocolVersions");
Proxy scProxy = Proxy(_superchainConfigProxy); IProxy scProxy = IProxy(_superchainConfigProxy);
save("SuperchainConfig", scProxy.implementation()); save("SuperchainConfig", scProxy.implementation());
save("SuperchainConfigProxy", _superchainConfigProxy); save("SuperchainConfigProxy", _superchainConfigProxy);
Proxy pvProxy = Proxy(_protocolVersionsProxy); IProxy pvProxy = IProxy(_protocolVersionsProxy);
save("ProtocolVersions", pvProxy.implementation()); save("ProtocolVersions", pvProxy.implementation());
save("ProtocolVersionsProxy", _protocolVersionsProxy); save("ProtocolVersionsProxy", _protocolVersionsProxy);
...@@ -569,19 +568,22 @@ contract Deploy is Deployer { ...@@ -569,19 +568,22 @@ contract Deploy is Deployer {
/// @notice Deploy the ProxyAdmin /// @notice Deploy the ProxyAdmin
function deployProxyAdmin() public broadcast returns (address addr_) { function deployProxyAdmin() public broadcast returns (address addr_) {
console.log("Deploying ProxyAdmin"); IProxyAdmin admin = IProxyAdmin(
ProxyAdmin admin = new ProxyAdmin({ _owner: msg.sender }); DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "ProxyAdmin",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IProxyAdmin.__constructor__, (msg.sender)))
})
);
require(admin.owner() == msg.sender); require(admin.owner() == msg.sender);
AddressManager addressManager = AddressManager(mustGetAddress("AddressManager")); IAddressManager addressManager = IAddressManager(mustGetAddress("AddressManager"));
if (admin.addressManager() != addressManager) { if (admin.addressManager() != addressManager) {
admin.setAddressManager(addressManager); admin.setAddressManager(addressManager);
} }
require(admin.addressManager() == addressManager); require(admin.addressManager() == addressManager);
save("ProxyAdmin", address(admin));
console.log("ProxyAdmin deployed at %s", address(admin));
addr_ = address(admin); addr_ = address(admin);
} }
...@@ -601,26 +603,36 @@ contract Deploy is Deployer { ...@@ -601,26 +603,36 @@ contract Deploy is Deployer {
/// @notice Deploy the L1StandardBridgeProxy using a ChugSplashProxy /// @notice Deploy the L1StandardBridgeProxy using a ChugSplashProxy
function deployL1StandardBridgeProxy() public broadcast returns (address addr_) { function deployL1StandardBridgeProxy() public broadcast returns (address addr_) {
console.log("Deploying proxy for L1StandardBridge");
address proxyAdmin = mustGetAddress("ProxyAdmin"); address proxyAdmin = mustGetAddress("ProxyAdmin");
L1ChugSplashProxy proxy = new L1ChugSplashProxy(proxyAdmin); IL1ChugSplashProxy proxy = IL1ChugSplashProxy(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "L1ChugSplashProxy",
_nick: "L1StandardBridgeProxy",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IL1ChugSplashProxy.__constructor__, (proxyAdmin)))
})
);
require(EIP1967Helper.getAdmin(address(proxy)) == proxyAdmin); require(EIP1967Helper.getAdmin(address(proxy)) == proxyAdmin);
save("L1StandardBridgeProxy", address(proxy));
console.log("L1StandardBridgeProxy deployed at %s", address(proxy));
addr_ = address(proxy); addr_ = address(proxy);
} }
/// @notice Deploy the L1CrossDomainMessengerProxy using a ResolvedDelegateProxy /// @notice Deploy the L1CrossDomainMessengerProxy using a ResolvedDelegateProxy
function deployL1CrossDomainMessengerProxy() public broadcast returns (address addr_) { function deployL1CrossDomainMessengerProxy() public broadcast returns (address addr_) {
console.log("Deploying proxy for L1CrossDomainMessenger"); IResolvedDelegateProxy proxy = IResolvedDelegateProxy(
AddressManager addressManager = AddressManager(mustGetAddress("AddressManager")); DeployUtils.create2AndSave({
ResolvedDelegateProxy proxy = new ResolvedDelegateProxy(addressManager, "OVM_L1CrossDomainMessenger"); _save: this,
_salt: _implSalt(),
save("L1CrossDomainMessengerProxy", address(proxy)); _name: "ResolvedDelegateProxy",
console.log("L1CrossDomainMessengerProxy deployed at %s", address(proxy)); _nick: "L1CrossDomainMessengerProxy",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IResolvedDelegateProxy.__constructor__,
(IAddressManager(mustGetAddress("AddressManager")), "OVM_L1CrossDomainMessenger")
)
)
})
);
addr_ = address(proxy); addr_ = address(proxy);
} }
...@@ -643,27 +655,32 @@ contract Deploy is Deployer { ...@@ -643,27 +655,32 @@ contract Deploy is Deployer {
broadcast broadcast
returns (address addr_) returns (address addr_)
{ {
console.log(string.concat("Deploying ERC1967 proxy for ", _name)); IProxy proxy = IProxy(
Proxy proxy = new Proxy({ _admin: _proxyOwner }); DeployUtils.create2AndSave({
_save: this,
_salt: keccak256(abi.encode(_implSalt(), _name)),
_name: "Proxy",
_nick: _name,
_args: DeployUtils.encodeConstructor(abi.encodeCall(IProxy.__constructor__, (_proxyOwner)))
})
);
require(EIP1967Helper.getAdmin(address(proxy)) == _proxyOwner); require(EIP1967Helper.getAdmin(address(proxy)) == _proxyOwner);
save(_name, address(proxy));
console.log(" at %s", address(proxy));
addr_ = address(proxy); addr_ = address(proxy);
} }
/// @notice Deploy the DataAvailabilityChallengeProxy /// @notice Deploy the DataAvailabilityChallengeProxy
function deployDataAvailabilityChallengeProxy() public broadcast returns (address addr_) { function deployDataAvailabilityChallengeProxy() public broadcast returns (address addr_) {
console.log("Deploying proxy for DataAvailabilityChallenge");
address proxyAdmin = mustGetAddress("ProxyAdmin"); address proxyAdmin = mustGetAddress("ProxyAdmin");
Proxy proxy = new Proxy({ _admin: proxyAdmin }); IProxy proxy = IProxy(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "Proxy",
_nick: "DataAvailabilityChallengeProxy",
_args: DeployUtils.encodeConstructor(abi.encodeCall(IProxy.__constructor__, (proxyAdmin)))
})
);
require(EIP1967Helper.getAdmin(address(proxy)) == proxyAdmin); require(EIP1967Helper.getAdmin(address(proxy)) == proxyAdmin);
save("DataAvailabilityChallengeProxy", address(proxy));
console.log("DataAvailabilityChallengeProxy deployed at %s", address(proxy));
addr_ = address(proxy); addr_ = address(proxy);
} }
...@@ -888,43 +905,35 @@ contract Deploy is Deployer { ...@@ -888,43 +905,35 @@ contract Deploy is Deployer {
/// @notice Deploy the PreimageOracle /// @notice Deploy the PreimageOracle
function deployPreimageOracle() public broadcast returns (address addr_) { function deployPreimageOracle() public broadcast returns (address addr_) {
console.log("Deploying PreimageOracle implementation"); IPreimageOracle preimageOracle = IPreimageOracle(
PreimageOracle preimageOracle = new PreimageOracle{ salt: _implSalt() }({ DeployUtils.create2AndSave({
_minProposalSize: cfg.preimageOracleMinProposalSize(), _save: this,
_challengePeriod: cfg.preimageOracleChallengePeriod() _salt: _implSalt(),
}); _name: "PreimageOracle",
save("PreimageOracle", address(preimageOracle)); _args: DeployUtils.encodeConstructor(
console.log("PreimageOracle deployed at %s", address(preimageOracle)); abi.encodeCall(
IPreimageOracle.__constructor__,
(cfg.preimageOracleMinProposalSize(), cfg.preimageOracleChallengePeriod())
)
)
})
);
addr_ = address(preimageOracle); addr_ = address(preimageOracle);
} }
/// @notice Deploy Mips VM. Deploys either MIPS or MIPS2 depending on the environment /// @notice Deploy Mips VM. Deploys either MIPS or MIPS2 depending on the environment
function deployMips() public broadcast returns (address addr_) { function deployMips() public broadcast returns (address addr_) {
if (Config.useMultithreadedCannon()) { addr_ = DeployUtils.create2AndSave({
addr_ = _deployMips2(); _save: this,
} else { _salt: _implSalt(),
addr_ = _deployMips(); _name: Config.useMultithreadedCannon() ? "MIPS2" : "MIPS",
} _args: DeployUtils.encodeConstructor(
abi.encodeCall(IMIPS2.__constructor__, (IPreimageOracle(mustGetAddress("PreimageOracle"))))
)
});
save("Mips", address(addr_)); save("Mips", address(addr_));
} }
/// @notice Deploy MIPS
function _deployMips() internal returns (address addr_) {
console.log("Deploying Mips implementation");
MIPS mips = new MIPS{ salt: _implSalt() }(IPreimageOracle(mustGetAddress("PreimageOracle")));
console.log("MIPS deployed at %s", address(mips));
addr_ = address(mips);
}
/// @notice Deploy MIPS2
function _deployMips2() internal returns (address addr_) {
console.log("Deploying Mips2 implementation");
MIPS2 mips2 = new MIPS2{ salt: _implSalt() }(IPreimageOracle(mustGetAddress("PreimageOracle")));
console.log("MIPS2 deployed at %s", address(mips2));
addr_ = address(mips2);
}
/// @notice Deploy the AnchorStateRegistry /// @notice Deploy the AnchorStateRegistry
function deployAnchorStateRegistry() public broadcast returns (address addr_) { function deployAnchorStateRegistry() public broadcast returns (address addr_) {
IAnchorStateRegistry anchorStateRegistry = IAnchorStateRegistry( IAnchorStateRegistry anchorStateRegistry = IAnchorStateRegistry(
...@@ -1017,7 +1026,7 @@ contract Deploy is Deployer { ...@@ -1017,7 +1026,7 @@ contract Deploy is Deployer {
/// @notice Transfer ownership of the address manager to the ProxyAdmin /// @notice Transfer ownership of the address manager to the ProxyAdmin
function transferAddressManagerOwnership() public broadcast { function transferAddressManagerOwnership() public broadcast {
console.log("Transferring AddressManager ownership to ProxyAdmin"); console.log("Transferring AddressManager ownership to ProxyAdmin");
AddressManager addressManager = AddressManager(mustGetAddress("AddressManager")); IAddressManager addressManager = IAddressManager(mustGetAddress("AddressManager"));
address owner = addressManager.owner(); address owner = addressManager.owner();
address proxyAdmin = mustGetAddress("ProxyAdmin"); address proxyAdmin = mustGetAddress("ProxyAdmin");
if (owner != proxyAdmin) { if (owner != proxyAdmin) {
...@@ -1225,7 +1234,7 @@ contract Deploy is Deployer { ...@@ -1225,7 +1234,7 @@ contract Deploy is Deployer {
/// @notice Initialize the L1StandardBridge /// @notice Initialize the L1StandardBridge
function initializeL1StandardBridge() public broadcast { function initializeL1StandardBridge() public broadcast {
console.log("Upgrading and initializing L1StandardBridge proxy"); console.log("Upgrading and initializing L1StandardBridge proxy");
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin")); IProxyAdmin proxyAdmin = IProxyAdmin(mustGetAddress("ProxyAdmin"));
address l1StandardBridgeProxy = mustGetAddress("L1StandardBridgeProxy"); address l1StandardBridgeProxy = mustGetAddress("L1StandardBridgeProxy");
address l1StandardBridge = mustGetAddress("L1StandardBridge"); address l1StandardBridge = mustGetAddress("L1StandardBridge");
address l1CrossDomainMessengerProxy = mustGetAddress("L1CrossDomainMessengerProxy"); address l1CrossDomainMessengerProxy = mustGetAddress("L1CrossDomainMessengerProxy");
...@@ -1234,14 +1243,14 @@ contract Deploy is Deployer { ...@@ -1234,14 +1243,14 @@ contract Deploy is Deployer {
uint256 proxyType = uint256(proxyAdmin.proxyType(l1StandardBridgeProxy)); uint256 proxyType = uint256(proxyAdmin.proxyType(l1StandardBridgeProxy));
Safe safe = Safe(mustGetAddress("SystemOwnerSafe")); Safe safe = Safe(mustGetAddress("SystemOwnerSafe"));
if (proxyType != uint256(ProxyAdmin.ProxyType.CHUGSPLASH)) { if (proxyType != uint256(IProxyAdmin.ProxyType.CHUGSPLASH)) {
_callViaSafe({ _callViaSafe({
_safe: safe, _safe: safe,
_target: address(proxyAdmin), _target: address(proxyAdmin),
_data: abi.encodeCall(ProxyAdmin.setProxyType, (l1StandardBridgeProxy, ProxyAdmin.ProxyType.CHUGSPLASH)) _data: abi.encodeCall(IProxyAdmin.setProxyType, (l1StandardBridgeProxy, IProxyAdmin.ProxyType.CHUGSPLASH))
}); });
} }
require(uint256(proxyAdmin.proxyType(l1StandardBridgeProxy)) == uint256(ProxyAdmin.ProxyType.CHUGSPLASH)); require(uint256(proxyAdmin.proxyType(l1StandardBridgeProxy)) == uint256(IProxyAdmin.ProxyType.CHUGSPLASH));
_upgradeAndCallViaSafe({ _upgradeAndCallViaSafe({
_proxy: payable(l1StandardBridgeProxy), _proxy: payable(l1StandardBridgeProxy),
...@@ -1309,7 +1318,7 @@ contract Deploy is Deployer { ...@@ -1309,7 +1318,7 @@ contract Deploy is Deployer {
/// @notice initializeL1CrossDomainMessenger /// @notice initializeL1CrossDomainMessenger
function initializeL1CrossDomainMessenger() public broadcast { function initializeL1CrossDomainMessenger() public broadcast {
console.log("Upgrading and initializing L1CrossDomainMessenger proxy"); console.log("Upgrading and initializing L1CrossDomainMessenger proxy");
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin")); IProxyAdmin proxyAdmin = IProxyAdmin(mustGetAddress("ProxyAdmin"));
address l1CrossDomainMessengerProxy = mustGetAddress("L1CrossDomainMessengerProxy"); address l1CrossDomainMessengerProxy = mustGetAddress("L1CrossDomainMessengerProxy");
address l1CrossDomainMessenger = mustGetAddress("L1CrossDomainMessenger"); address l1CrossDomainMessenger = mustGetAddress("L1CrossDomainMessenger");
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
...@@ -1318,14 +1327,16 @@ contract Deploy is Deployer { ...@@ -1318,14 +1327,16 @@ contract Deploy is Deployer {
uint256 proxyType = uint256(proxyAdmin.proxyType(l1CrossDomainMessengerProxy)); uint256 proxyType = uint256(proxyAdmin.proxyType(l1CrossDomainMessengerProxy));
Safe safe = Safe(mustGetAddress("SystemOwnerSafe")); Safe safe = Safe(mustGetAddress("SystemOwnerSafe"));
if (proxyType != uint256(ProxyAdmin.ProxyType.RESOLVED)) { if (proxyType != uint256(IProxyAdmin.ProxyType.RESOLVED)) {
_callViaSafe({ _callViaSafe({
_safe: safe, _safe: safe,
_target: address(proxyAdmin), _target: address(proxyAdmin),
_data: abi.encodeCall(ProxyAdmin.setProxyType, (l1CrossDomainMessengerProxy, ProxyAdmin.ProxyType.RESOLVED)) _data: abi.encodeCall(
IProxyAdmin.setProxyType, (l1CrossDomainMessengerProxy, IProxyAdmin.ProxyType.RESOLVED)
)
}); });
} }
require(uint256(proxyAdmin.proxyType(l1CrossDomainMessengerProxy)) == uint256(ProxyAdmin.ProxyType.RESOLVED)); require(uint256(proxyAdmin.proxyType(l1CrossDomainMessengerProxy)) == uint256(IProxyAdmin.ProxyType.RESOLVED));
string memory contractName = "OVM_L1CrossDomainMessenger"; string memory contractName = "OVM_L1CrossDomainMessenger";
string memory implName = proxyAdmin.implementationName(l1CrossDomainMessenger); string memory implName = proxyAdmin.implementationName(l1CrossDomainMessenger);
...@@ -1333,7 +1344,7 @@ contract Deploy is Deployer { ...@@ -1333,7 +1344,7 @@ contract Deploy is Deployer {
_callViaSafe({ _callViaSafe({
_safe: safe, _safe: safe,
_target: address(proxyAdmin), _target: address(proxyAdmin),
_data: abi.encodeCall(ProxyAdmin.setImplementationName, (l1CrossDomainMessengerProxy, contractName)) _data: abi.encodeCall(IProxyAdmin.setImplementationName, (l1CrossDomainMessengerProxy, contractName))
}); });
} }
require( require(
...@@ -1648,7 +1659,7 @@ contract Deploy is Deployer { ...@@ -1648,7 +1659,7 @@ contract Deploy is Deployer {
weth: weth, weth: weth,
gameType: GameTypes.ALPHABET, gameType: GameTypes.ALPHABET,
absolutePrestate: outputAbsolutePrestate, absolutePrestate: outputAbsolutePrestate,
faultVm: IBigStepper(new AlphabetVM(outputAbsolutePrestate, PreimageOracle(mustGetAddress("PreimageOracle")))), faultVm: IBigStepper(new AlphabetVM(outputAbsolutePrestate, IPreimageOracle(mustGetAddress("PreimageOracle")))),
// The max depth for the alphabet trace is always 3. Add 1 because split depth is fully inclusive. // The max depth for the alphabet trace is always 3. Add 1 because split depth is fully inclusive.
maxGameDepth: cfg.faultGameSplitDepth() + 3 + 1, maxGameDepth: cfg.faultGameSplitDepth() + 3 + 1,
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration())) maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration()))
...@@ -1663,7 +1674,17 @@ contract Deploy is Deployer { ...@@ -1663,7 +1674,17 @@ contract Deploy is Deployer {
IDelayedWETH weth = IDelayedWETH(mustGetAddress("DelayedWETHProxy")); IDelayedWETH weth = IDelayedWETH(mustGetAddress("DelayedWETHProxy"));
Claim outputAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())); Claim outputAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
PreimageOracle fastOracle = new PreimageOracle(cfg.preimageOracleMinProposalSize(), 0); IPreimageOracle fastOracle = IPreimageOracle(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "PreimageOracle",
_nick: "FastPreimageOracle",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(IPreimageOracle.__constructor__, (cfg.preimageOracleMinProposalSize(), 0))
)
})
);
_setFaultGameImplementation({ _setFaultGameImplementation({
_factory: factory, _factory: factory,
_allowUpgrade: _allowUpgrade, _allowUpgrade: _allowUpgrade,
......
...@@ -5,13 +5,11 @@ pragma solidity 0.8.15; ...@@ -5,13 +5,11 @@ pragma solidity 0.8.15;
import { StdAssertions } from "forge-std/StdAssertions.sol"; import { StdAssertions } from "forge-std/StdAssertions.sol";
import "scripts/deploy/Deploy.s.sol"; import "scripts/deploy/Deploy.s.sol";
// Contracts
import { Proxy } from "src/universal/Proxy.sol";
// Libraries // Libraries
import "src/dispute/lib/Types.sol"; import "src/dispute/lib/Types.sol";
// Interfaces // Interfaces
import { IProxy } from "src/universal/interfaces/IProxy.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
...@@ -78,7 +76,7 @@ contract FPACOPS is Deploy, StdAssertions { ...@@ -78,7 +76,7 @@ contract FPACOPS is Deploy, StdAssertions {
console.log("Initializing DisputeGameFactoryProxy with DisputeGameFactory."); console.log("Initializing DisputeGameFactoryProxy with DisputeGameFactory.");
address dgfProxy = mustGetAddress("DisputeGameFactoryProxy"); address dgfProxy = mustGetAddress("DisputeGameFactoryProxy");
Proxy(payable(dgfProxy)).upgradeToAndCall( IProxy(payable(dgfProxy)).upgradeToAndCall(
mustGetAddress("DisputeGameFactory"), abi.encodeCall(IDisputeGameFactory.initialize, msg.sender) mustGetAddress("DisputeGameFactory"), abi.encodeCall(IDisputeGameFactory.initialize, msg.sender)
); );
...@@ -93,7 +91,7 @@ contract FPACOPS is Deploy, StdAssertions { ...@@ -93,7 +91,7 @@ contract FPACOPS is Deploy, StdAssertions {
address wethProxy = mustGetAddress("DelayedWETHProxy"); address wethProxy = mustGetAddress("DelayedWETHProxy");
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
Proxy(payable(wethProxy)).upgradeToAndCall( IProxy(payable(wethProxy)).upgradeToAndCall(
mustGetAddress("DelayedWETH"), mustGetAddress("DelayedWETH"),
abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
); );
...@@ -121,7 +119,7 @@ contract FPACOPS is Deploy, StdAssertions { ...@@ -121,7 +119,7 @@ contract FPACOPS is Deploy, StdAssertions {
}); });
address asrProxy = mustGetAddress("AnchorStateRegistryProxy"); address asrProxy = mustGetAddress("AnchorStateRegistryProxy");
Proxy(payable(asrProxy)).upgradeToAndCall( IProxy(payable(asrProxy)).upgradeToAndCall(
mustGetAddress("AnchorStateRegistry"), mustGetAddress("AnchorStateRegistry"),
abi.encodeCall(IAnchorStateRegistry.initialize, (roots, superchainConfig)) abi.encodeCall(IAnchorStateRegistry.initialize, (roots, superchainConfig))
); );
...@@ -136,7 +134,7 @@ contract FPACOPS is Deploy, StdAssertions { ...@@ -136,7 +134,7 @@ contract FPACOPS is Deploy, StdAssertions {
dgf.transferOwnership(_systemOwnerSafe); dgf.transferOwnership(_systemOwnerSafe);
// Transfer the admin rights of the DisputeGameFactoryProxy to the ProxyAdmin. // Transfer the admin rights of the DisputeGameFactoryProxy to the ProxyAdmin.
Proxy prox = Proxy(payable(address(dgf))); IProxy prox = IProxy(payable(address(dgf)));
prox.changeAdmin(_proxyAdmin); prox.changeAdmin(_proxyAdmin);
} }
...@@ -149,7 +147,7 @@ contract FPACOPS is Deploy, StdAssertions { ...@@ -149,7 +147,7 @@ contract FPACOPS is Deploy, StdAssertions {
weth.transferOwnership(_systemOwnerSafe); weth.transferOwnership(_systemOwnerSafe);
// Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin. // Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin.
Proxy prox = Proxy(payable(address(weth))); IProxy prox = IProxy(payable(address(weth)));
prox.changeAdmin(_proxyAdmin); prox.changeAdmin(_proxyAdmin);
} }
...@@ -158,7 +156,7 @@ contract FPACOPS is Deploy, StdAssertions { ...@@ -158,7 +156,7 @@ contract FPACOPS is Deploy, StdAssertions {
IAnchorStateRegistry asr = IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")); IAnchorStateRegistry asr = IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy"));
// Transfer the admin rights of the AnchorStateRegistryProxy to the ProxyAdmin. // Transfer the admin rights of the AnchorStateRegistryProxy to the ProxyAdmin.
Proxy prox = Proxy(payable(address(asr))); IProxy prox = IProxy(payable(address(asr)));
prox.changeAdmin(_proxyAdmin); prox.changeAdmin(_proxyAdmin);
} }
...@@ -182,11 +180,11 @@ contract FPACOPS is Deploy, StdAssertions { ...@@ -182,11 +180,11 @@ contract FPACOPS is Deploy, StdAssertions {
// Check the config elements in the deployed contracts. // Check the config elements in the deployed contracts.
ChainAssertions.checkOptimismPortal2(contracts, cfg, false); ChainAssertions.checkOptimismPortal2(contracts, cfg, false);
PreimageOracle oracle = PreimageOracle(mustGetAddress("PreimageOracle")); IPreimageOracle oracle = IPreimageOracle(mustGetAddress("PreimageOracle"));
assertEq(oracle.minProposalSize(), cfg.preimageOracleMinProposalSize()); assertEq(oracle.minProposalSize(), cfg.preimageOracleMinProposalSize());
assertEq(oracle.challengePeriod(), cfg.preimageOracleChallengePeriod()); assertEq(oracle.challengePeriod(), cfg.preimageOracleChallengePeriod());
MIPS mips = MIPS(mustGetAddress("Mips")); IMIPS mips = IMIPS(mustGetAddress("Mips"));
assertEq(address(mips.oracle()), address(oracle)); assertEq(address(mips.oracle()), address(oracle));
// Check the AnchorStateRegistry configuration. // Check the AnchorStateRegistry configuration.
......
...@@ -5,13 +5,11 @@ pragma solidity 0.8.15; ...@@ -5,13 +5,11 @@ pragma solidity 0.8.15;
import { StdAssertions } from "forge-std/StdAssertions.sol"; import { StdAssertions } from "forge-std/StdAssertions.sol";
import "scripts/deploy/Deploy.s.sol"; import "scripts/deploy/Deploy.s.sol";
// Contracts
import { Proxy } from "src/universal/Proxy.sol";
// Libraries // Libraries
import "src/dispute/lib/Types.sol"; import "src/dispute/lib/Types.sol";
// Interfaces // Interfaces
import { IProxy } from "src/universal/interfaces/IProxy.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
...@@ -152,7 +150,7 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -152,7 +150,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
address wethProxy = mustGetAddress("DelayedWETHProxy"); address wethProxy = mustGetAddress("DelayedWETHProxy");
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
Proxy(payable(wethProxy)).upgradeToAndCall( IProxy(payable(wethProxy)).upgradeToAndCall(
mustGetAddress("DelayedWETH"), mustGetAddress("DelayedWETH"),
abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
); );
...@@ -164,7 +162,7 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -164,7 +162,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
address wethProxy = mustGetAddress("PermissionedDelayedWETHProxy"); address wethProxy = mustGetAddress("PermissionedDelayedWETHProxy");
address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); address superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
Proxy(payable(wethProxy)).upgradeToAndCall( IProxy(payable(wethProxy)).upgradeToAndCall(
mustGetAddress("DelayedWETH"), mustGetAddress("DelayedWETH"),
abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy))) abi.encodeCall(IDelayedWETH.initialize, (msg.sender, ISuperchainConfig(superchainConfigProxy)))
); );
...@@ -181,7 +179,7 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -181,7 +179,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
weth.transferOwnership(_systemOwnerSafe); weth.transferOwnership(_systemOwnerSafe);
// Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin. // Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin.
Proxy prox = Proxy(payable(address(weth))); IProxy prox = IProxy(payable(address(weth)));
prox.changeAdmin(_proxyAdmin); prox.changeAdmin(_proxyAdmin);
} }
...@@ -196,7 +194,7 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -196,7 +194,7 @@ contract FPACOPS2 is Deploy, StdAssertions {
weth.transferOwnership(_systemOwnerSafe); weth.transferOwnership(_systemOwnerSafe);
// Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin. // Transfer the admin rights of the DelayedWETHProxy to the ProxyAdmin.
Proxy prox = Proxy(payable(address(weth))); IProxy prox = IProxy(payable(address(weth)));
prox.changeAdmin(_proxyAdmin); prox.changeAdmin(_proxyAdmin);
} }
...@@ -225,12 +223,12 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -225,12 +223,12 @@ contract FPACOPS2 is Deploy, StdAssertions {
ChainAssertions.checkPermissionedDelayedWETH(contracts, cfg, true, _systemOwnerSafe); ChainAssertions.checkPermissionedDelayedWETH(contracts, cfg, true, _systemOwnerSafe);
// Verify PreimageOracle configuration. // Verify PreimageOracle configuration.
PreimageOracle oracle = PreimageOracle(mustGetAddress("PreimageOracle")); IPreimageOracle oracle = IPreimageOracle(mustGetAddress("PreimageOracle"));
assertEq(oracle.minProposalSize(), cfg.preimageOracleMinProposalSize()); assertEq(oracle.minProposalSize(), cfg.preimageOracleMinProposalSize());
assertEq(oracle.challengePeriod(), cfg.preimageOracleChallengePeriod()); assertEq(oracle.challengePeriod(), cfg.preimageOracleChallengePeriod());
// Verify MIPS configuration. // Verify MIPS configuration.
MIPS mips = MIPS(mustGetAddress("Mips")); IMIPS mips = IMIPS(mustGetAddress("Mips"));
assertEq(address(mips.oracle()), address(oracle)); assertEq(address(mips.oracle()), address(oracle));
// Grab ASR // Grab ASR
......
...@@ -10,8 +10,8 @@ import { Artifacts } from "scripts/Artifacts.s.sol"; ...@@ -10,8 +10,8 @@ import { Artifacts } from "scripts/Artifacts.s.sol";
import { LibString } from "@solady/utils/LibString.sol"; import { LibString } from "@solady/utils/LibString.sol";
import { Bytes } from "src/libraries/Bytes.sol"; import { Bytes } from "src/libraries/Bytes.sol";
// Contracts // Interfaces
import { Proxy } from "src/universal/Proxy.sol"; import { IProxy } from "src/universal/interfaces/IProxy.sol";
library DeployUtils { library DeployUtils {
Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
...@@ -221,7 +221,7 @@ library DeployUtils { ...@@ -221,7 +221,7 @@ library DeployUtils {
// We prank as the zero address due to the Proxy's `proxyCallIfNotAdmin` modifier. // We prank as the zero address due to the Proxy's `proxyCallIfNotAdmin` modifier.
// Pranking inside this function also means it can no longer be considered `view`. // Pranking inside this function also means it can no longer be considered `view`.
vm.prank(address(0)); vm.prank(address(0));
address implementation = Proxy(payable(_proxy)).implementation(); address implementation = IProxy(payable(_proxy)).implementation();
assertValidContractAddress(implementation); assertValidContractAddress(implementation);
} }
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
// TODO: Migrate this script to use DeployUtils
import { console2 as console } from "forge-std/console2.sol"; import { console2 as console } from "forge-std/console2.sol";
import { Script } from "forge-std/Script.sol"; import { Script } from "forge-std/Script.sol";
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
"sourceCodeHash": "0xde4df0f9633dc0cdb1c9f634003ea5b0f7c5c1aebc407bc1b2f44c0ecf938649" "sourceCodeHash": "0xde4df0f9633dc0cdb1c9f634003ea5b0f7c5c1aebc407bc1b2f44c0ecf938649"
}, },
"src/L1/OPContractsManager.sol": { "src/L1/OPContractsManager.sol": {
"initCodeHash": "0x620481066bd0979c409ed9c089d32a1b7a05c610509222901ee3e73b0dc5565d", "initCodeHash": "0x944deadee322fdbae8a8fffd16deceb3766509cfb54da06adb8aa84473f79f53",
"sourceCodeHash": "0x1bd201aef876cd32a34f8b100362df87ffaa0c1ddfbf5a19a5c43ced4c26d791" "sourceCodeHash": "0x1a48119cbc0b778a4dd3454179060b71361ba44b61af1ac6398cc9274bb5e89f"
}, },
"src/L1/OptimismPortal.sol": { "src/L1/OptimismPortal.sol": {
"initCodeHash": "0xbe2c0c81b3459014f287d8c89cdc0d27dde5d1f44e5d024fa1e4773ddc47c190", "initCodeHash": "0xbe2c0c81b3459014f287d8c89cdc0d27dde5d1f44e5d024fa1e4773ddc47c190",
...@@ -148,8 +148,8 @@ ...@@ -148,8 +148,8 @@
"sourceCodeHash": "0x50ed780b621521047ed36ffb260032f2e5ec287f3e1ab3d742c7de45febb280d" "sourceCodeHash": "0x50ed780b621521047ed36ffb260032f2e5ec287f3e1ab3d742c7de45febb280d"
}, },
"src/cannon/PreimageOracle.sol": { "src/cannon/PreimageOracle.sol": {
"initCodeHash": "0x801e52f9c8439fcf7089575fa93272dfb874641dbfc7d82f36d979c987271c0b", "initCodeHash": "0x3690e6dafe588c29de74790123bf6de5b0f741869bf5dbd8a122fdef96cab733",
"sourceCodeHash": "0xdb9421a552e6d7581b3db9e4c2a02d8210ad6ca66ba0f8703d77f7cd4b8e132b" "sourceCodeHash": "0x19b48b7d5fcb296cacf0cb15326b2e12a9556d6d811a16cbe2344792afa30427"
}, },
"src/dispute/AnchorStateRegistry.sol": { "src/dispute/AnchorStateRegistry.sol": {
"initCodeHash": "0x13d00eef8c3f769863fc766180acc8586f5da309ca0a098e67d4d90bd3243341", "initCodeHash": "0x13d00eef8c3f769863fc766180acc8586f5da309ca0a098e67d4d90bd3243341",
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"name": "addressManager", "name": "addressManager",
"outputs": [ "outputs": [
{ {
"internalType": "contract AddressManager", "internalType": "contract IAddressManager",
"name": "", "name": "",
"type": "address" "type": "address"
} }
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
{ {
"inputs": [ "inputs": [
{ {
"internalType": "contract AddressManager", "internalType": "contract IAddressManager",
"name": "_address", "name": "_address",
"type": "address" "type": "address"
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
"label": "addressManager", "label": "addressManager",
"offset": 0, "offset": 0,
"slot": "3", "slot": "3",
"type": "contract AddressManager" "type": "contract IAddressManager"
}, },
{ {
"bytes": "1", "bytes": "1",
......
...@@ -13,6 +13,7 @@ import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; ...@@ -13,6 +13,7 @@ import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { ISystemConfigV160 } from "src/L1/interfaces/ISystemConfigV160.sol"; import { ISystemConfigV160 } from "src/L1/interfaces/ISystemConfigV160.sol";
import { IAddressManager } from "src/legacy/interfaces/IAddressManager.sol";
import { Proxy } from "src/universal/Proxy.sol"; import { Proxy } from "src/universal/Proxy.sol";
import { ProxyAdmin } from "src/universal/ProxyAdmin.sol"; import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
...@@ -127,8 +128,8 @@ contract OPContractsManager is ISemver, Initializable { ...@@ -127,8 +128,8 @@ contract OPContractsManager is ISemver, Initializable {
// -------- Constants and Variables -------- // -------- Constants and Variables --------
/// @custom:semver 1.0.0-beta.13 /// @custom:semver 1.0.0-beta.14
string public constant version = "1.0.0-beta.13"; string public constant version = "1.0.0-beta.14";
/// @notice Represents the interface version so consumers know how to decode the DeployOutput struct /// @notice Represents the interface version so consumers know how to decode the DeployOutput struct
/// that's emitted in the `Deployed` event. Whenever that struct changes, a new version should be used. /// that's emitted in the `Deployed` event. Whenever that struct changes, a new version should be used.
...@@ -240,7 +241,7 @@ contract OPContractsManager is ISemver, Initializable { ...@@ -240,7 +241,7 @@ contract OPContractsManager is ISemver, Initializable {
output.addressManager = AddressManager(Blueprint.deployFrom(blueprint.addressManager, salt)); output.addressManager = AddressManager(Blueprint.deployFrom(blueprint.addressManager, salt));
output.opChainProxyAdmin = output.opChainProxyAdmin =
ProxyAdmin(Blueprint.deployFrom(blueprint.proxyAdmin, salt, abi.encode(address(this)))); ProxyAdmin(Blueprint.deployFrom(blueprint.proxyAdmin, salt, abi.encode(address(this))));
output.opChainProxyAdmin.setAddressManager(output.addressManager); output.opChainProxyAdmin.setAddressManager(IAddressManager(address(output.addressManager)));
// -------- Deploy Proxy Contracts -------- // -------- Deploy Proxy Contracts --------
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
import { IPreimageOracle } from "./interfaces/IPreimageOracle.sol"; // Libraries
import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { PreimageKeyLib } from "./PreimageKeyLib.sol";
import { LibKeccak } from "@lib-keccak/LibKeccak.sol"; import { LibKeccak } from "@lib-keccak/LibKeccak.sol";
import { PreimageKeyLib } from "src/cannon/PreimageKeyLib.sol";
import "src/cannon/libraries/CannonErrors.sol"; import "src/cannon/libraries/CannonErrors.sol";
import "src/cannon/libraries/CannonTypes.sol"; import "src/cannon/libraries/CannonTypes.sol";
// Interfaces
import { ISemver } from "src/universal/interfaces/ISemver.sol";
/// @title PreimageOracle /// @title PreimageOracle
/// @notice A contract for storing permissioned pre-images. /// @notice A contract for storing permissioned pre-images.
/// @custom:attribution Solady <https://github.com/Vectorized/solady/blob/main/src/utils/MerkleProofLib.sol#L13-L43> /// @custom:attribution Solady <https://github.com/Vectorized/solady/blob/main/src/utils/MerkleProofLib.sol#L13-L43>
/// @custom:attribution Beacon Deposit Contract <0x00000000219ab540356cbb839cbe05303d7705fa> /// @custom:attribution Beacon Deposit Contract <0x00000000219ab540356cbb839cbe05303d7705fa>
contract PreimageOracle is IPreimageOracle, ISemver { contract PreimageOracle is ISemver {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Constants & Immutables // // Constants & Immutables //
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -31,8 +33,8 @@ contract PreimageOracle is IPreimageOracle, ISemver { ...@@ -31,8 +33,8 @@ contract PreimageOracle is IPreimageOracle, ISemver {
uint256 public constant PRECOMPILE_CALL_RESERVED_GAS = 100_000; uint256 public constant PRECOMPILE_CALL_RESERVED_GAS = 100_000;
/// @notice The semantic version of the Preimage Oracle contract. /// @notice The semantic version of the Preimage Oracle contract.
/// @custom:semver 1.1.3-beta.2 /// @custom:semver 1.1.3-beta.3
string public constant version = "1.1.3-beta.2"; string public constant version = "1.1.3-beta.3";
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Authorized Preimage Parts // // Authorized Preimage Parts //
...@@ -107,7 +109,11 @@ contract PreimageOracle is IPreimageOracle, ISemver { ...@@ -107,7 +109,11 @@ contract PreimageOracle is IPreimageOracle, ISemver {
// Standard Preimage Route (External) // // Standard Preimage Route (External) //
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
/// @inheritdoc IPreimageOracle /// @notice Reads a preimage from the oracle.
/// @param _key The key of the preimage to read.
/// @param _offset The offset of the preimage to read.
/// @return dat_ The preimage data.
/// @return datLen_ The length of the preimage data.
function readPreimage(bytes32 _key, uint256 _offset) external view returns (bytes32 dat_, uint256 datLen_) { function readPreimage(bytes32 _key, uint256 _offset) external view returns (bytes32 dat_, uint256 datLen_) {
require(preimagePartOk[_key][_offset], "pre-image must exist"); require(preimagePartOk[_key][_offset], "pre-image must exist");
...@@ -123,7 +129,27 @@ contract PreimageOracle is IPreimageOracle, ISemver { ...@@ -123,7 +129,27 @@ contract PreimageOracle is IPreimageOracle, ISemver {
dat_ = preimageParts[_key][_offset]; dat_ = preimageParts[_key][_offset];
} }
/// @inheritdoc IPreimageOracle /// @notice Loads of local data part into the preimage oracle.
/// @param _ident The identifier of the local data.
/// @param _localContext The local key context for the preimage oracle. Optionally, can be set as a constant
/// if the caller only requires one set of local keys.
/// @param _word The local data word.
/// @param _size The number of bytes in `_word` to load.
/// @param _partOffset The offset of the local data part to write to the oracle.
/// @dev The local data parts are loaded into the preimage oracle under the context
/// of the caller - no other account can write to the caller's context
/// specific data.
///
/// There are 5 local data identifiers:
/// ┌────────────┬────────────────────────┐
/// │ Identifier │ Data │
/// ├────────────┼────────────────────────┤
/// │ 1 │ L1 Head Hash (bytes32) │
/// │ 2 │ Output Root (bytes32) │
/// │ 3 │ Root Claim (bytes32) │
/// │ 4 │ L2 Block Number (u64) │
/// │ 5 │ Chain ID (u64) │
/// └────────────┴────────────────────────┘
function loadLocalData( function loadLocalData(
uint256 _ident, uint256 _ident,
bytes32 _localContext, bytes32 _localContext,
...@@ -163,7 +189,10 @@ contract PreimageOracle is IPreimageOracle, ISemver { ...@@ -163,7 +189,10 @@ contract PreimageOracle is IPreimageOracle, ISemver {
preimageLengths[key_] = _size; preimageLengths[key_] = _size;
} }
/// @inheritdoc IPreimageOracle /// @notice Prepares a preimage to be read by keccak256 key, starting at the given offset and up to 32 bytes
/// (clipped at preimage length, if out of data).
/// @param _partOffset The offset of the preimage to read.
/// @param _preimage The preimage data.
function loadKeccak256PreimagePart(uint256 _partOffset, bytes calldata _preimage) external { function loadKeccak256PreimagePart(uint256 _partOffset, bytes calldata _preimage) external {
uint256 size; uint256 size;
bytes32 key; bytes32 key;
...@@ -198,7 +227,10 @@ contract PreimageOracle is IPreimageOracle, ISemver { ...@@ -198,7 +227,10 @@ contract PreimageOracle is IPreimageOracle, ISemver {
preimageLengths[key] = size; preimageLengths[key] = size;
} }
/// @inheritdoc IPreimageOracle /// @notice Prepares a preimage to be read by sha256 key, starting at the given offset and up to 32 bytes
/// (clipped at preimage length, if out of data).
/// @param _partOffset The offset of the preimage to read.
/// @param _preimage The preimage data.
function loadSha256PreimagePart(uint256 _partOffset, bytes calldata _preimage) external { function loadSha256PreimagePart(uint256 _partOffset, bytes calldata _preimage) external {
uint256 size; uint256 size;
bytes32 key; bytes32 key;
...@@ -247,7 +279,13 @@ contract PreimageOracle is IPreimageOracle, ISemver { ...@@ -247,7 +279,13 @@ contract PreimageOracle is IPreimageOracle, ISemver {
preimageLengths[key] = size; preimageLengths[key] = size;
} }
/// @inheritdoc IPreimageOracle /// @notice Verifies that `p(_z) = _y` given `_commitment` that corresponds to the polynomial `p(x)` and a KZG
// proof. The value `y` is the pre-image, and the preimage key is `5 ++ keccak256(_commitment ++ z)[1:]`.
/// @param _z Big endian point value. Part of the preimage key.
/// @param _y Big endian point value. The preimage for the key.
/// @param _commitment The commitment to the polynomial. 48 bytes, part of the preimage key.
/// @param _proof The KZG proof, part of the preimage key.
/// @param _partOffset The offset of the preimage to store.
function loadBlobPreimagePart( function loadBlobPreimagePart(
uint256 _z, uint256 _z,
uint256 _y, uint256 _y,
...@@ -338,7 +376,13 @@ contract PreimageOracle is IPreimageOracle, ISemver { ...@@ -338,7 +376,13 @@ contract PreimageOracle is IPreimageOracle, ISemver {
preimageLengths[key] = 32; preimageLengths[key] = 32;
} }
/// @inheritdoc IPreimageOracle /// @notice Prepares a precompile result to be read by a precompile key for the specified offset.
/// The precompile result data is a concatenation of the precompile call status byte and its return data.
/// The preimage key is `6 ++ keccak256(precompile ++ input)[1:]`.
/// @param _partOffset The offset of the precompile result being loaded.
/// @param _precompile The precompile address
/// @param _requiredGas The gas required to fully execute an L1 precompile.
/// @param _input The input to the precompile call.
function loadPrecompilePreimagePart( function loadPrecompilePreimagePart(
uint256 _partOffset, uint256 _partOffset,
address _precompile, address _precompile,
......
...@@ -88,4 +88,9 @@ interface IPreimageOracle { ...@@ -88,4 +88,9 @@ interface IPreimageOracle {
bytes calldata _input bytes calldata _input
) )
external; external;
/// @notice Returns the minimum size (in bytes) of a large preimage proposal.
function minProposalSize() external view returns (uint256);
function __constructor__(uint256 _minProposalSize, uint256 _challengePeriod) external;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
import { IAddressManager } from "src/legacy/interfaces/IAddressManager.sol";
/// @title IResolvedDelegateProxy /// @title IResolvedDelegateProxy
/// @notice Interface for the ResolvedDelegateProxy contract. /// @notice Interface for the ResolvedDelegateProxy contract.
interface IResolvedDelegateProxy { interface IResolvedDelegateProxy {
fallback() external payable; fallback() external payable;
receive() external payable;
function __constructor__(IAddressManager _addressManager, string memory _implementationName) external;
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Contracts
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { Proxy } from "src/universal/Proxy.sol";
import { AddressManager } from "src/legacy/AddressManager.sol"; // Libraries
import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol";
import { Constants } from "src/libraries/Constants.sol"; import { Constants } from "src/libraries/Constants.sol";
import { IStaticERC1967Proxy } from "src/universal/interfaces/IStaticERC1967Proxy.sol";
// Interfaces
import { IAddressManager } from "src/legacy/interfaces/IAddressManager.sol";
import { IL1ChugSplashProxy } from "src/legacy/interfaces/IL1ChugSplashProxy.sol";
import { IStaticL1ChugSplashProxy } from "src/legacy/interfaces/IL1ChugSplashProxy.sol"; import { IStaticL1ChugSplashProxy } from "src/legacy/interfaces/IL1ChugSplashProxy.sol";
import { IStaticERC1967Proxy } from "src/universal/interfaces/IStaticERC1967Proxy.sol";
import { IProxy } from "src/universal/interfaces/IProxy.sol";
/// @title ProxyAdmin /// @title ProxyAdmin
/// @notice This is an auxiliary contract meant to be assigned as the admin of an ERC1967 Proxy, /// @notice This is an auxiliary contract meant to be assigned as the admin of an ERC1967 Proxy,
...@@ -34,7 +39,7 @@ contract ProxyAdmin is Ownable { ...@@ -34,7 +39,7 @@ contract ProxyAdmin is Ownable {
/// @notice The address of the address manager, this is required to manage the /// @notice The address of the address manager, this is required to manage the
/// ResolvedDelegateProxy type. /// ResolvedDelegateProxy type.
AddressManager public addressManager; IAddressManager public addressManager;
/// @notice A legacy upgrading indicator used by the old Chugsplash Proxy. /// @notice A legacy upgrading indicator used by the old Chugsplash Proxy.
bool internal upgrading; bool internal upgrading;
...@@ -63,7 +68,7 @@ contract ProxyAdmin is Ownable { ...@@ -63,7 +68,7 @@ contract ProxyAdmin is Ownable {
/// @notice Set the address of the AddressManager. This is required to manage legacy /// @notice Set the address of the AddressManager. This is required to manage legacy
/// ResolvedDelegateProxy type proxy contracts. /// ResolvedDelegateProxy type proxy contracts.
/// @param _address Address of the AddressManager. /// @param _address Address of the AddressManager.
function setAddressManager(AddressManager _address) external onlyOwner { function setAddressManager(IAddressManager _address) external onlyOwner {
addressManager = _address; addressManager = _address;
} }
...@@ -131,9 +136,9 @@ contract ProxyAdmin is Ownable { ...@@ -131,9 +136,9 @@ contract ProxyAdmin is Ownable {
function changeProxyAdmin(address payable _proxy, address _newAdmin) external onlyOwner { function changeProxyAdmin(address payable _proxy, address _newAdmin) external onlyOwner {
ProxyType ptype = proxyType[_proxy]; ProxyType ptype = proxyType[_proxy];
if (ptype == ProxyType.ERC1967) { if (ptype == ProxyType.ERC1967) {
Proxy(_proxy).changeAdmin(_newAdmin); IProxy(_proxy).changeAdmin(_newAdmin);
} else if (ptype == ProxyType.CHUGSPLASH) { } else if (ptype == ProxyType.CHUGSPLASH) {
L1ChugSplashProxy(_proxy).setOwner(_newAdmin); IL1ChugSplashProxy(_proxy).setOwner(_newAdmin);
} else if (ptype == ProxyType.RESOLVED) { } else if (ptype == ProxyType.RESOLVED) {
addressManager.transferOwnership(_newAdmin); addressManager.transferOwnership(_newAdmin);
} else { } else {
...@@ -147,9 +152,9 @@ contract ProxyAdmin is Ownable { ...@@ -147,9 +152,9 @@ contract ProxyAdmin is Ownable {
function upgrade(address payable _proxy, address _implementation) public onlyOwner { function upgrade(address payable _proxy, address _implementation) public onlyOwner {
ProxyType ptype = proxyType[_proxy]; ProxyType ptype = proxyType[_proxy];
if (ptype == ProxyType.ERC1967) { if (ptype == ProxyType.ERC1967) {
Proxy(_proxy).upgradeTo(_implementation); IProxy(_proxy).upgradeTo(_implementation);
} else if (ptype == ProxyType.CHUGSPLASH) { } else if (ptype == ProxyType.CHUGSPLASH) {
L1ChugSplashProxy(_proxy).setStorage( IL1ChugSplashProxy(_proxy).setStorage(
Constants.PROXY_IMPLEMENTATION_ADDRESS, bytes32(uint256(uint160(_implementation))) Constants.PROXY_IMPLEMENTATION_ADDRESS, bytes32(uint256(uint160(_implementation)))
); );
} else if (ptype == ProxyType.RESOLVED) { } else if (ptype == ProxyType.RESOLVED) {
...@@ -178,7 +183,7 @@ contract ProxyAdmin is Ownable { ...@@ -178,7 +183,7 @@ contract ProxyAdmin is Ownable {
{ {
ProxyType ptype = proxyType[_proxy]; ProxyType ptype = proxyType[_proxy];
if (ptype == ProxyType.ERC1967) { if (ptype == ProxyType.ERC1967) {
Proxy(_proxy).upgradeToAndCall{ value: msg.value }(_implementation, _data); IProxy(_proxy).upgradeToAndCall{ value: msg.value }(_implementation, _data);
} else { } else {
// reverts if proxy type is unknown // reverts if proxy type is unknown
upgrade(_proxy, _implementation); upgrade(_proxy, _implementation);
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IOptimismMintableERC721Factory {
event OptimismMintableERC721Created(address indexed localToken, address indexed remoteToken, address deployer);
function BRIDGE() external view returns (address);
function REMOTE_CHAIN_ID() external view returns (uint256);
function createOptimismMintableERC721(
address _remoteToken,
string memory _name,
string memory _symbol
)
external
returns (address);
function isOptimismMintableERC721(address) external view returns (bool);
function version() external view returns (string memory);
function __constructor__(address _bridge, uint256 _remoteChainId) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IProxy {
event AdminChanged(address previousAdmin, address newAdmin);
event Upgraded(address indexed implementation);
fallback() external payable;
receive() external payable;
function admin() external returns (address);
function changeAdmin(address _admin) external;
function implementation() external returns (address);
function upgradeTo(address _implementation) external;
function upgradeToAndCall(address _implementation, bytes memory _data) external payable returns (bytes memory);
function __constructor__(address _admin) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IAddressManager } from "src/legacy/interfaces/IAddressManager.sol";
interface IProxyAdmin {
enum ProxyType {
ERC1967,
CHUGSPLASH,
RESOLVED
}
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function addressManager() external view returns (IAddressManager);
function changeProxyAdmin(address payable _proxy, address _newAdmin) external;
function getProxyAdmin(address payable _proxy) external view returns (address);
function getProxyImplementation(address _proxy) external view returns (address);
function implementationName(address) external view returns (string memory);
function isUpgrading() external view returns (bool);
function owner() external view returns (address);
function proxyType(address) external view returns (ProxyType);
function renounceOwnership() external;
function setAddress(string memory _name, address _address) external;
function setAddressManager(IAddressManager _address) external;
function setImplementationName(address _address, string memory _name) external;
function setProxyType(address _address, ProxyType _type) external;
function setUpgrading(bool _upgrading) external;
function transferOwnership(address newOwner) external; // nosemgrep
function upgrade(address payable _proxy, address _implementation) external;
function upgradeAndCall(address payable _proxy, address _implementation, bytes memory _data) external payable;
function __constructor__(address _owner) external;
}
...@@ -8,7 +8,6 @@ import { ...@@ -8,7 +8,6 @@ import {
CommitmentType CommitmentType
} from "src/L1/interfaces/IDataAvailabilityChallenge.sol"; } from "src/L1/interfaces/IDataAvailabilityChallenge.sol";
import { computeCommitmentKeccak256 } from "src/L1/DataAvailabilityChallenge.sol"; import { computeCommitmentKeccak256 } from "src/L1/DataAvailabilityChallenge.sol";
import { Proxy } from "src/universal/Proxy.sol";
import { CommonTest } from "test/setup/CommonTest.sol"; import { CommonTest } from "test/setup/CommonTest.sol";
import { Preinstalls } from "src/libraries/Preinstalls.sol"; import { Preinstalls } from "src/libraries/Preinstalls.sol";
......
...@@ -10,7 +10,6 @@ import { NextImpl } from "test/mocks/NextImpl.sol"; ...@@ -10,7 +10,6 @@ import { NextImpl } from "test/mocks/NextImpl.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Contracts // Contracts
import { Proxy } from "src/universal/Proxy.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
// Libraries // Libraries
...@@ -27,6 +26,7 @@ import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; ...@@ -27,6 +26,7 @@ import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol";
import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol";
import { IL1Block } from "src/L2/interfaces/IL1Block.sol"; import { IL1Block } from "src/L2/interfaces/IL1Block.sol";
import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol";
import { IProxy } from "src/universal/interfaces/IProxy.sol";
contract OptimismPortal_Test is CommonTest { contract OptimismPortal_Test is CommonTest {
address depositor; address depositor;
...@@ -1173,10 +1173,10 @@ contract OptimismPortalUpgradeable_Test is CommonTest { ...@@ -1173,10 +1173,10 @@ contract OptimismPortalUpgradeable_Test is CommonTest {
vm.startPrank(EIP1967Helper.getAdmin(address(optimismPortal))); vm.startPrank(EIP1967Helper.getAdmin(address(optimismPortal)));
// The value passed to the initialize must be larger than the last value // The value passed to the initialize must be larger than the last value
// that initialize was called with. // that initialize was called with.
Proxy(payable(address(optimismPortal))).upgradeToAndCall( IProxy(payable(address(optimismPortal))).upgradeToAndCall(
address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, 2) address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, 2)
); );
assertEq(Proxy(payable(address(optimismPortal))).implementation(), address(nextImpl)); assertEq(IProxy(payable(address(optimismPortal))).implementation(), address(nextImpl));
// Verify that the NextImpl contract initialized its values according as expected // Verify that the NextImpl contract initialized its values according as expected
bytes32 slot21After = vm.load(address(optimismPortal), bytes32(uint256(21))); bytes32 slot21After = vm.load(address(optimismPortal), bytes32(uint256(21)));
......
...@@ -10,7 +10,6 @@ import { NextImpl } from "test/mocks/NextImpl.sol"; ...@@ -10,7 +10,6 @@ import { NextImpl } from "test/mocks/NextImpl.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Contracts // Contracts
import { Proxy } from "src/universal/Proxy.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
// Libraries // Libraries
...@@ -29,6 +28,7 @@ import { IL1Block } from "src/L2/interfaces/IL1Block.sol"; ...@@ -29,6 +28,7 @@ import { IL1Block } from "src/L2/interfaces/IL1Block.sol";
import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol"; import { IOptimismPortal2 } from "src/L1/interfaces/IOptimismPortal2.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol"; import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { IProxy } from "src/universal/interfaces/IProxy.sol";
contract OptimismPortal2_Test is CommonTest { contract OptimismPortal2_Test is CommonTest {
address depositor; address depositor;
...@@ -1422,10 +1422,10 @@ contract OptimismPortal2_Upgradeable_Test is CommonTest { ...@@ -1422,10 +1422,10 @@ contract OptimismPortal2_Upgradeable_Test is CommonTest {
vm.startPrank(EIP1967Helper.getAdmin(address(optimismPortal2))); vm.startPrank(EIP1967Helper.getAdmin(address(optimismPortal2)));
// The value passed to the initialize must be larger than the last value // The value passed to the initialize must be larger than the last value
// that initialize was called with. // that initialize was called with.
Proxy(payable(address(optimismPortal2))).upgradeToAndCall( IProxy(payable(address(optimismPortal2))).upgradeToAndCall(
address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, 2) address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, 2)
); );
assertEq(Proxy(payable(address(optimismPortal2))).implementation(), address(nextImpl)); assertEq(IProxy(payable(address(optimismPortal2))).implementation(), address(nextImpl));
// Verify that the NextImpl contract initialized its values according as expected // Verify that the NextImpl contract initialized its values according as expected
bytes32 slot21After = vm.load(address(optimismPortal2), bytes32(uint256(21))); bytes32 slot21After = vm.load(address(optimismPortal2), bytes32(uint256(21)));
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing utilities // Testing
import { CommonTest } from "test/setup/CommonTest.sol"; import { CommonTest } from "test/setup/CommonTest.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Libraries // Libraries
import { Constants } from "src/libraries/Constants.sol"; import { Constants } from "src/libraries/Constants.sol";
// Target contract dependencies // Interfaces
import { Proxy } from "src/universal/Proxy.sol"; import { IProxy } from "src/universal/interfaces/IProxy.sol";
// Target contract
import { IProtocolVersions, ProtocolVersion } from "src/L1/interfaces/IProtocolVersions.sol"; import { IProtocolVersions, ProtocolVersion } from "src/L1/interfaces/IProtocolVersions.sol";
contract ProtocolVersions_Init is CommonTest { contract ProtocolVersions_Init is CommonTest {
...@@ -57,7 +55,7 @@ contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init { ...@@ -57,7 +55,7 @@ contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init {
emit ConfigUpdate(0, IProtocolVersions.UpdateType.RECOMMENDED_PROTOCOL_VERSION, abi.encode(recommended)); emit ConfigUpdate(0, IProtocolVersions.UpdateType.RECOMMENDED_PROTOCOL_VERSION, abi.encode(recommended));
vm.prank(EIP1967Helper.getAdmin(address(protocolVersions))); vm.prank(EIP1967Helper.getAdmin(address(protocolVersions)));
Proxy(payable(address(protocolVersions))).upgradeToAndCall( IProxy(payable(address(protocolVersions))).upgradeToAndCall(
address(protocolVersionsImpl), address(protocolVersionsImpl),
abi.encodeCall( abi.encodeCall(
IProtocolVersions.initialize, IProtocolVersions.initialize,
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing utilities // Testing
import { Test } from "forge-std/Test.sol"; import { Test } from "forge-std/Test.sol";
// Contracts
import { ResourceMetering } from "src/L1/ResourceMetering.sol";
// Libraries // Libraries
import { Constants } from "src/libraries/Constants.sol"; import { Constants } from "src/libraries/Constants.sol";
// Target contract dependencies // Interfaces
import { Proxy } from "src/universal/Proxy.sol";
// Target contract
import { ResourceMetering } from "src/L1/ResourceMetering.sol";
import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol"; import { IResourceMetering } from "src/L1/interfaces/IResourceMetering.sol";
contract MeterUser is ResourceMetering { contract MeterUser is ResourceMetering {
......
...@@ -7,7 +7,6 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; ...@@ -7,7 +7,6 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Contracts // Contracts
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { Proxy } from "src/universal/Proxy.sol";
// Libraries // Libraries
import { Constants } from "src/libraries/Constants.sol"; import { Constants } from "src/libraries/Constants.sol";
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing
import { CommonTest } from "test/setup/CommonTest.sol"; import { CommonTest } from "test/setup/CommonTest.sol";
// Contracts
import { MIPS } from "src/cannon/MIPS.sol"; import { MIPS } from "src/cannon/MIPS.sol";
import { PreimageOracle } from "src/cannon/PreimageOracle.sol"; import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
// Libraries
import { MIPSInstructions } from "src/cannon/libraries/MIPSInstructions.sol"; import { MIPSInstructions } from "src/cannon/libraries/MIPSInstructions.sol";
import { MIPSSyscalls as sys } from "src/cannon/libraries/MIPSSyscalls.sol"; import { MIPSSyscalls as sys } from "src/cannon/libraries/MIPSSyscalls.sol";
import { InvalidExitedValue, InvalidMemoryProof } from "src/cannon/libraries/CannonErrors.sol"; import { InvalidExitedValue, InvalidMemoryProof } from "src/cannon/libraries/CannonErrors.sol";
import "src/dispute/lib/Types.sol"; import "src/dispute/lib/Types.sol";
// Interfaces
import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol";
contract MIPS_Test is CommonTest { contract MIPS_Test is CommonTest {
MIPS internal mips; MIPS internal mips;
PreimageOracle internal oracle; PreimageOracle internal oracle;
...@@ -16,7 +24,7 @@ contract MIPS_Test is CommonTest { ...@@ -16,7 +24,7 @@ contract MIPS_Test is CommonTest {
function setUp() public virtual override { function setUp() public virtual override {
super.setUp(); super.setUp();
oracle = new PreimageOracle(0, 0); oracle = new PreimageOracle(0, 0);
mips = new MIPS(oracle); mips = new MIPS(IPreimageOracle(address(oracle)));
vm.store(address(mips), 0x0, bytes32(abi.encode(address(oracle)))); vm.store(address(mips), 0x0, bytes32(abi.encode(address(oracle))));
vm.label(address(oracle), "PreimageOracle"); vm.label(address(oracle), "PreimageOracle");
vm.label(address(mips), "MIPS"); vm.label(address(mips), "MIPS");
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing
import { CommonTest } from "test/setup/CommonTest.sol"; import { CommonTest } from "test/setup/CommonTest.sol";
// Contracts
import { MIPS2 } from "src/cannon/MIPS2.sol"; import { MIPS2 } from "src/cannon/MIPS2.sol";
import { PreimageOracle } from "src/cannon/PreimageOracle.sol"; import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
// Libraries
import { MIPSSyscalls as sys } from "src/cannon/libraries/MIPSSyscalls.sol"; import { MIPSSyscalls as sys } from "src/cannon/libraries/MIPSSyscalls.sol";
import { MIPSInstructions as ins } from "src/cannon/libraries/MIPSInstructions.sol"; import { MIPSInstructions as ins } from "src/cannon/libraries/MIPSInstructions.sol";
import "src/dispute/lib/Types.sol";
import { InvalidExitedValue, InvalidMemoryProof, InvalidSecondMemoryProof } from "src/cannon/libraries/CannonErrors.sol"; import { InvalidExitedValue, InvalidMemoryProof, InvalidSecondMemoryProof } from "src/cannon/libraries/CannonErrors.sol";
import "src/dispute/lib/Types.sol";
// Interfaces
import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol";
contract ThreadStack { contract ThreadStack {
bytes32 internal constant EMPTY_THREAD_ROOT = hex"ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5"; bytes32 internal constant EMPTY_THREAD_ROOT = hex"ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5";
...@@ -127,7 +135,7 @@ contract MIPS2_Test is CommonTest { ...@@ -127,7 +135,7 @@ contract MIPS2_Test is CommonTest {
function setUp() public virtual override { function setUp() public virtual override {
super.setUp(); super.setUp();
oracle = new PreimageOracle(0, 0); oracle = new PreimageOracle(0, 0);
mips = new MIPS2(oracle); mips = new MIPS2(IPreimageOracle(address(oracle)));
threading = new Threading(); threading = new Threading();
vm.store(address(mips), 0x0, bytes32(abi.encode(address(oracle)))); vm.store(address(mips), 0x0, bytes32(abi.encode(address(oracle))));
vm.label(address(oracle), "PreimageOracle"); vm.label(address(oracle), "PreimageOracle");
......
...@@ -54,7 +54,7 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init { ...@@ -54,7 +54,7 @@ contract FaultDisputeGame_Init is DisputeGameFactory_Init {
// Set preimage oracle challenge period to something arbitrary (4 seconds) just so we can // Set preimage oracle challenge period to something arbitrary (4 seconds) just so we can
// actually test the clock extensions later on. This is not a realistic value. // actually test the clock extensions later on. This is not a realistic value.
PreimageOracle oracle = new PreimageOracle(0, 4); PreimageOracle oracle = new PreimageOracle(0, 4);
AlphabetVM _vm = new AlphabetVM(absolutePrestate, oracle); AlphabetVM _vm = new AlphabetVM(absolutePrestate, IPreimageOracle(address(oracle)));
// Deploy an implementation of the fault game // Deploy an implementation of the fault game
gameImpl = IFaultDisputeGame( gameImpl = IFaultDisputeGame(
...@@ -123,7 +123,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -123,7 +123,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
/// @dev Tests that the constructor of the `FaultDisputeGame` reverts when the `MAX_GAME_DEPTH` parameter is /// @dev Tests that the constructor of the `FaultDisputeGame` reverts when the `MAX_GAME_DEPTH` parameter is
/// greater than `LibPosition.MAX_POSITION_BITLEN - 1`. /// greater than `LibPosition.MAX_POSITION_BITLEN - 1`.
function testFuzz_constructor_maxDepthTooLarge_reverts(uint256 _maxGameDepth) public { function testFuzz_constructor_maxDepthTooLarge_reverts(uint256 _maxGameDepth) public {
AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, new PreimageOracle(0, 0)); AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, IPreimageOracle(address(new PreimageOracle(0, 0))));
_maxGameDepth = bound(_maxGameDepth, LibPosition.MAX_POSITION_BITLEN, type(uint256).max - 1); _maxGameDepth = bound(_maxGameDepth, LibPosition.MAX_POSITION_BITLEN, type(uint256).max - 1);
vm.expectRevert(MaxDepthTooLarge.selector); vm.expectRevert(MaxDepthTooLarge.selector);
...@@ -148,7 +148,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -148,7 +148,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
_challengePeriod = bound(_challengePeriod, uint256(type(uint64).max) + 1, type(uint256).max); _challengePeriod = bound(_challengePeriod, uint256(type(uint64).max) + 1, type(uint256).max);
PreimageOracle oracle = new PreimageOracle(0, 0); PreimageOracle oracle = new PreimageOracle(0, 0);
AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, oracle); AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, IPreimageOracle(address(oracle)));
// PreimageOracle constructor will revert if the challenge period is too large, so we need // PreimageOracle constructor will revert if the challenge period is too large, so we need
// to mock the call to pretend this is a bugged implementation where the challenge period // to mock the call to pretend this is a bugged implementation where the challenge period
...@@ -175,7 +175,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -175,7 +175,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
/// @dev Tests that the constructor of the `FaultDisputeGame` reverts when the `_splitDepth` /// @dev Tests that the constructor of the `FaultDisputeGame` reverts when the `_splitDepth`
/// parameter is greater than or equal to the `MAX_GAME_DEPTH` /// parameter is greater than or equal to the `MAX_GAME_DEPTH`
function testFuzz_constructor_invalidSplitDepth_reverts(uint256 _splitDepth) public { function testFuzz_constructor_invalidSplitDepth_reverts(uint256 _splitDepth) public {
AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, new PreimageOracle(0, 0)); AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, IPreimageOracle(address(new PreimageOracle(0, 0))));
uint256 maxGameDepth = 2 ** 3; uint256 maxGameDepth = 2 ** 3;
_splitDepth = bound(_splitDepth, maxGameDepth - 1, type(uint256).max); _splitDepth = bound(_splitDepth, maxGameDepth - 1, type(uint256).max);
...@@ -197,7 +197,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -197,7 +197,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
/// @dev Tests that the constructor of the `FaultDisputeGame` reverts when the `_splitDepth` /// @dev Tests that the constructor of the `FaultDisputeGame` reverts when the `_splitDepth`
/// parameter is less than the minimum split depth (currently 2). /// parameter is less than the minimum split depth (currently 2).
function testFuzz_constructor_lowSplitDepth_reverts(uint256 _splitDepth) public { function testFuzz_constructor_lowSplitDepth_reverts(uint256 _splitDepth) public {
AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, new PreimageOracle(0, 0)); AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, IPreimageOracle(address(new PreimageOracle(0, 0))));
uint256 minSplitDepth = 2; uint256 minSplitDepth = 2;
_splitDepth = bound(_splitDepth, 0, minSplitDepth - 1); _splitDepth = bound(_splitDepth, 0, minSplitDepth - 1);
...@@ -224,7 +224,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -224,7 +224,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
) )
public public
{ {
AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, new PreimageOracle(0, 0)); AlphabetVM alphabetVM = new AlphabetVM(absolutePrestate, IPreimageOracle(address(new PreimageOracle(0, 0))));
// Force the clock extension * 2 to be greater than the max clock duration, but keep things within // Force the clock extension * 2 to be greater than the max clock duration, but keep things within
// bounds of the uint64 type. // bounds of the uint64 type.
......
...@@ -47,7 +47,7 @@ contract PermissionedDisputeGame_Init is DisputeGameFactory_Init { ...@@ -47,7 +47,7 @@ contract PermissionedDisputeGame_Init is DisputeGameFactory_Init {
// Set the extra data for the game creation // Set the extra data for the game creation
extraData = abi.encode(l2BlockNumber); extraData = abi.encode(l2BlockNumber);
AlphabetVM _vm = new AlphabetVM(absolutePrestate, new PreimageOracle(0, 0)); AlphabetVM _vm = new AlphabetVM(absolutePrestate, IPreimageOracle(address(new PreimageOracle(0, 0))));
// Use a 7 day delayed WETH to simulate withdrawals. // Use a 7 day delayed WETH to simulate withdrawals.
IDelayedWETH _weth = IDelayedWETH(payable(new DelayedWETH(7 days))); IDelayedWETH _weth = IDelayedWETH(payable(new DelayedWETH(7 days)));
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.15; pragma solidity ^0.8.15;
import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol"; // Libraries
import { PreimageOracle, PreimageKeyLib } from "src/cannon/PreimageOracle.sol"; import { PreimageKeyLib } from "src/cannon/PreimageKeyLib.sol";
import "src/dispute/lib/Types.sol"; import "src/dispute/lib/Types.sol";
// Interfaces
import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol";
/// @title AlphabetVM /// @title AlphabetVM
/// @dev A mock VM for the purpose of testing the dispute game infrastructure. Note that this only works /// @dev A mock VM for the purpose of testing the dispute game infrastructure. Note that this only works
/// for games with an execution trace subgame max depth of 3 (8 instructions per subgame). /// for games with an execution trace subgame max depth of 3 (8 instructions per subgame).
...@@ -12,7 +15,7 @@ contract AlphabetVM is IBigStepper { ...@@ -12,7 +15,7 @@ contract AlphabetVM is IBigStepper {
Claim internal immutable ABSOLUTE_PRESTATE; Claim internal immutable ABSOLUTE_PRESTATE;
IPreimageOracle public oracle; IPreimageOracle public oracle;
constructor(Claim _absolutePrestate, PreimageOracle _oracle) { constructor(Claim _absolutePrestate, IPreimageOracle _oracle) {
ABSOLUTE_PRESTATE = _absolutePrestate; ABSOLUTE_PRESTATE = _absolutePrestate;
oracle = _oracle; oracle = _oracle;
} }
......
...@@ -9,9 +9,9 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol"; ...@@ -9,9 +9,9 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
// Contracts // Contracts
import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol"; import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol";
import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC20Factory.sol"; import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC20Factory.sol";
import { Proxy } from "src/universal/Proxy.sol";
// Interfaces // Interfaces
import { IProxy } from "src/universal/interfaces/IProxy.sol";
import { IOptimismMintableERC20Factory } from "src/universal/interfaces/IOptimismMintableERC20Factory.sol"; import { IOptimismMintableERC20Factory } from "src/universal/interfaces/IOptimismMintableERC20Factory.sol";
contract OptimismMintableTokenFactory_Test is Bridge_Initializer { contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
...@@ -33,7 +33,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer { ...@@ -33,7 +33,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
/// @notice Tests that the upgrade is successful. /// @notice Tests that the upgrade is successful.
function test_upgrading_succeeds() external { function test_upgrading_succeeds() external {
Proxy proxy = Proxy(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy")); IProxy proxy = IProxy(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"));
// Check an unused slot before upgrading. // Check an unused slot before upgrading.
bytes32 slot21Before = vm.load(address(l1OptimismMintableERC20Factory), bytes32(uint256(21))); bytes32 slot21Before = vm.load(address(l1OptimismMintableERC20Factory), bytes32(uint256(21)));
assertEq(bytes32(0), slot21Before); assertEq(bytes32(0), slot21Before);
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
// Testing
import { Test } from "forge-std/Test.sol"; import { Test } from "forge-std/Test.sol";
import { SimpleStorage } from "test/universal/Proxy.t.sol";
// Contracts
import { Proxy } from "src/universal/Proxy.sol"; import { Proxy } from "src/universal/Proxy.sol";
import { ProxyAdmin } from "src/universal/ProxyAdmin.sol"; import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
import { SimpleStorage } from "test/universal/Proxy.t.sol"; import { AddressManager } from "src/legacy/AddressManager.sol";
import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol"; import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol";
import { ResolvedDelegateProxy } from "src/legacy/ResolvedDelegateProxy.sol"; import { ResolvedDelegateProxy } from "src/legacy/ResolvedDelegateProxy.sol";
import { AddressManager } from "src/legacy/AddressManager.sol";
// Interfaces
import { IAddressManager } from "src/legacy/interfaces/IAddressManager.sol";
contract ProxyAdmin_Test is Test { contract ProxyAdmin_Test is Test {
address alice = address(64); address alice = address(64);
...@@ -45,7 +51,7 @@ contract ProxyAdmin_Test is Test { ...@@ -45,7 +51,7 @@ contract ProxyAdmin_Test is Test {
// Set the address of the address manager in the admin so that it // Set the address of the address manager in the admin so that it
// can resolve the implementation address of legacy // can resolve the implementation address of legacy
// ResolvedDelegateProxy based proxies. // ResolvedDelegateProxy based proxies.
admin.setAddressManager(addressManager); admin.setAddressManager(IAddressManager(address(addressManager)));
// Set the reverse lookup of the ResolvedDelegateProxy // Set the reverse lookup of the ResolvedDelegateProxy
// proxy // proxy
admin.setImplementationName(address(resolved), "a"); admin.setImplementationName(address(resolved), "a");
...@@ -67,7 +73,7 @@ contract ProxyAdmin_Test is Test { ...@@ -67,7 +73,7 @@ contract ProxyAdmin_Test is Test {
function test_setAddressManager_notOwner_reverts() external { function test_setAddressManager_notOwner_reverts() external {
vm.expectRevert("Ownable: caller is not the owner"); vm.expectRevert("Ownable: caller is not the owner");
admin.setAddressManager(AddressManager((address(0)))); admin.setAddressManager(IAddressManager((address(0))));
} }
function test_setImplementationName_notOwner_reverts() external { function test_setImplementationName_notOwner_reverts() external {
......
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