Commit ec1dafcb authored by Maurelian's avatar Maurelian

feat(ctb): Maintain backwards compatibility with lowercase getters

parent e4fbe54e
...@@ -443,10 +443,12 @@ contract Deploy is Deployer { ...@@ -443,10 +443,12 @@ contract Deploy is Deployer {
/// @notice Deploy the OptimismMintableERC20Factory /// @notice Deploy the OptimismMintableERC20Factory
function deployOptimismMintableERC20Factory() public broadcast returns (address addr_) { function deployOptimismMintableERC20Factory() public broadcast returns (address addr_) {
OptimismMintableERC20Factory factory = new OptimismMintableERC20Factory{ salt: implSalt() }(); address l1standardBridgeProxy = mustGetAddress("L1StandardBridgeProxy");
OptimismMintableERC20Factory factory =
new OptimismMintableERC20Factory{ salt: implSalt() }({_bridge: l1standardBridgeProxy});
require(factory.BRIDGE() == address(0)); require(factory.BRIDGE() == l1standardBridgeProxy);
require(factory.bridge() == address(0)); require(factory.bridge() == l1standardBridgeProxy);
save("OptimismMintableERC20Factory", address(factory)); save("OptimismMintableERC20Factory", address(factory));
console.log("OptimismMintableERC20Factory deployed at %s", address(factory)); console.log("OptimismMintableERC20Factory deployed at %s", address(factory));
...@@ -706,14 +708,16 @@ contract Deploy is Deployer { ...@@ -706,14 +708,16 @@ contract Deploy is Deployer {
/// @notice Ininitialize the OptimismMintableERC20Factory /// @notice Ininitialize the OptimismMintableERC20Factory
function initializeOptimismMintableERC20Factory() public broadcast { function initializeOptimismMintableERC20Factory() public broadcast {
address proxyAdmin = mustGetAddress("ProxyAdmin");
address optimismMintableERC20FactoryProxy = mustGetAddress("OptimismMintableERC20FactoryProxy"); address optimismMintableERC20FactoryProxy = mustGetAddress("OptimismMintableERC20FactoryProxy");
address optimismMintableERC20Factory = mustGetAddress("OptimismMintableERC20Factory"); address optimismMintableERC20Factory = mustGetAddress("OptimismMintableERC20Factory");
address l1StandardBridgeProxy = mustGetAddress("L1StandardBridgeProxy"); address l1StandardBridgeProxy = mustGetAddress("L1StandardBridgeProxy");
_upgradeAndCallViaSafe({ _callViaSafe({
_proxy: payable(optimismMintableERC20FactoryProxy), _target: proxyAdmin,
_implementation: optimismMintableERC20Factory, _data: abi.encodeCall(
_innerCallData: abi.encodeCall(OptimismMintableERC20Factory.initialize, (l1StandardBridgeProxy)) ProxyAdmin.upgrade, (payable(optimismMintableERC20FactoryProxy), optimismMintableERC20Factory)
)
}); });
OptimismMintableERC20Factory factory = OptimismMintableERC20Factory(optimismMintableERC20FactoryProxy); OptimismMintableERC20Factory factory = OptimismMintableERC20Factory(optimismMintableERC20FactoryProxy);
......
...@@ -13,7 +13,9 @@ import { Constants } from "src/libraries/Constants.sol"; ...@@ -13,7 +13,9 @@ import { Constants } from "src/libraries/Constants.sol";
/// for sending and receiving data on the L1 side. Users are encouraged to use this /// for sending and receiving data on the L1 side. Users are encouraged to use this
/// interface instead of interacting with lower-level contracts directly. /// interface instead of interacting with lower-level contracts directly.
contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver { contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver {
/// @notice Address of the OptimismPortal. /// @notice Address of the OptimismPortal. This will be removed in the
/// future, use `portal` instead.
/// @custom:legacy
OptimismPortal public immutable PORTAL; OptimismPortal public immutable PORTAL;
/// @notice Semantic version. /// @notice Semantic version.
...@@ -32,6 +34,11 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver { ...@@ -32,6 +34,11 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver {
__CrossDomainMessenger_init(); __CrossDomainMessenger_init();
} }
/// @notice Getter for the OptimismPortal address.
function portal() external view returns (address) {
return address(PORTAL);
}
/// @inheritdoc CrossDomainMessenger /// @inheritdoc CrossDomainMessenger
function _sendMessage(address _to, uint64 _gasLimit, uint256 _value, bytes memory _data) internal override { function _sendMessage(address _to, uint64 _gasLimit, uint256 _value, bytes memory _data) internal override {
PORTAL.depositTransaction{ value: _value }(_to, _value, _gasLimit, false, _data); PORTAL.depositTransaction{ value: _value }(_to, _value, _gasLimit, false, _data);
......
...@@ -20,10 +20,14 @@ contract L2OutputOracle is Initializable, ISemver { ...@@ -20,10 +20,14 @@ contract L2OutputOracle is Initializable, ISemver {
/// @notice The time between L2 blocks in seconds. Once set, this value MUST NOT be modified. /// @notice The time between L2 blocks in seconds. Once set, this value MUST NOT be modified.
uint256 public immutable L2_BLOCK_TIME; uint256 public immutable L2_BLOCK_TIME;
/// @notice The address of the challenger. Can be updated via upgrade. /// @notice The address of the challenger. Can be updated via upgrade. This will be removed in the
/// future, use `proposer` instead.
/// @custom:legacy
address public immutable CHALLENGER; address public immutable CHALLENGER;
/// @notice The address of the proposer. Can be updated via upgrade. /// @notice The address of the proposer. Can be updated via upgrade. This will be removed in the
/// future, use `proposer` instead.
/// @custom:legacy
address public immutable PROPOSER; address public immutable PROPOSER;
/// @notice The minimum time (in seconds) that must elapse before a withdrawal can be finalized. /// @notice The minimum time (in seconds) that must elapse before a withdrawal can be finalized.
...@@ -97,6 +101,31 @@ contract L2OutputOracle is Initializable, ISemver { ...@@ -97,6 +101,31 @@ contract L2OutputOracle is Initializable, ISemver {
startingBlockNumber = _startingBlockNumber; startingBlockNumber = _startingBlockNumber;
} }
/// @notice Getter for the challenger address.
function challenger() external view returns (address) {
return CHALLENGER;
}
/// @notice Getter for the PROPOSER address.
function proposer() external view returns (address) {
return PROPOSER;
}
/// @notice Getter for the SUBMISSION_INTERVAL.
function submissionInterval() external view returns (uint256) {
return SUBMISSION_INTERVAL;
}
/// @notice Getter for the L2_BLOCK_TIME.
function l2BlockTime() external view returns (uint256) {
return L2_BLOCK_TIME;
}
/// @notice Getter for the FINALIZATION_PERIOD_SECONDS.
function finalizationPeriodSeconds() external view returns (uint256) {
return FINALIZATION_PERIOD_SECONDS;
}
/// @notice Deletes all output proposals after and including the proposal that corresponds to /// @notice Deletes all output proposals after and including the proposal that corresponds to
/// the given output index. Only the challenger address can delete outputs. /// the given output index. Only the challenger address can delete outputs.
/// @param _l2OutputIndex Index of the first L2 output to be deleted. /// @param _l2OutputIndex Index of the first L2 output to be deleted.
......
...@@ -36,13 +36,19 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver { ...@@ -36,13 +36,19 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
/// @notice The L2 gas limit set when eth is deposited using the receive() function. /// @notice The L2 gas limit set when eth is deposited using the receive() function.
uint64 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000; uint64 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000;
/// @notice Address of the L2OutputOracle contract. /// @notice Address of the L2OutputOracle contract. This will be removed in the
/// future, use `l2Oracle` instead.
/// @custom:legacy
L2OutputOracle public immutable L2_ORACLE; L2OutputOracle public immutable L2_ORACLE;
/// @notice Address of the SystemConfig contract. /// @notice Address of the SystemConfig contract. This will be removed in the
/// future, use `systemConfig` instead.
/// @custom:legacy
SystemConfig public immutable SYSTEM_CONFIG; SystemConfig public immutable SYSTEM_CONFIG;
/// @notice Address that has the ability to pause and unpause withdrawals. /// @notice Address that has the ability to pause and unpause withdrawals. This will be removed in the
/// future, use `guardian` instead.
/// @custom:legacy
address public immutable GUARDIAN; address public immutable GUARDIAN;
/// @notice Address of the L2 account which initiated a withdrawal in this transaction. /// @notice Address of the L2 account which initiated a withdrawal in this transaction.
...@@ -118,6 +124,24 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver { ...@@ -118,6 +124,24 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
__ResourceMetering_init(); __ResourceMetering_init();
} }
/// @notice Getter function for the address of the L2OutputOracle on this chain.
/// @notice Address of the L2OutputOracle on this chain.
function l2Oracle() public view returns (L2OutputOracle) {
return L2_ORACLE;
}
/// @notice Getter function for the address of the SystemConfig on this chain.
/// @notice Address of the SystemConfig on this chain.
function systemConfig() public view returns (SystemConfig) {
return SYSTEM_CONFIG;
}
/// @notice Getter function for the address of the L2OutputOracle on this chain.
/// @notice Address of the L2OutputOracle on this chain.
function guardian() public view returns (address) {
return GUARDIAN;
}
/// @notice Pauses withdrawals. /// @notice Pauses withdrawals.
function pause() external { function pause() external {
require(msg.sender == GUARDIAN, "OptimismPortal: only guardian can pause"); require(msg.sender == GUARDIAN, "OptimismPortal: only guardian can pause");
......
...@@ -8,10 +8,14 @@ import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable ...@@ -8,10 +8,14 @@ import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable
/// @title ERC721Bridge /// @title ERC721Bridge
/// @notice ERC721Bridge is a base contract for the L1 and L2 ERC721 bridges. /// @notice ERC721Bridge is a base contract for the L1 and L2 ERC721 bridges.
abstract contract ERC721Bridge { abstract contract ERC721Bridge {
/// @notice Messenger contract on this domain. /// @notice Messenger contract on this domain. This will be removed in the
/// future, use `messenger` instead.
/// @custom:legacy
CrossDomainMessenger public immutable MESSENGER; CrossDomainMessenger public immutable MESSENGER;
/// @notice Address of the bridge on the other network. /// @notice Address of the bridge on the other network. This will be removed in the
/// future, use `otherBridge` instead.
/// @custom:legacy
address public immutable OTHER_BRIDGE; address public immutable OTHER_BRIDGE;
/// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades. /// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.
...@@ -68,14 +72,12 @@ abstract contract ERC721Bridge { ...@@ -68,14 +72,12 @@ abstract contract ERC721Bridge {
OTHER_BRIDGE = _otherBridge; OTHER_BRIDGE = _otherBridge;
} }
/// @custom:legacy
/// @notice Legacy getter for messenger contract. /// @notice Legacy getter for messenger contract.
/// @return Messenger contract on this domain. /// @return Messenger contract on this domain.
function messenger() external view returns (CrossDomainMessenger) { function messenger() external view returns (CrossDomainMessenger) {
return MESSENGER; return MESSENGER;
} }
/// @custom:legacy
/// @notice Legacy getter for other bridge address. /// @notice Legacy getter for other bridge address.
/// @return Address of the bridge on the other network. /// @return Address of the bridge on the other network.
function otherBridge() external view returns (address) { function otherBridge() external view returns (address) {
......
...@@ -40,6 +40,12 @@ contract OptimismMintableERC20Factory is ISemver { ...@@ -40,6 +40,12 @@ contract OptimismMintableERC20Factory is ISemver {
BRIDGE = _bridge; BRIDGE = _bridge;
} }
/// @notice Getter function for the address of the StandardBridge on this chain.
/// @notice Address of the StandardBridge on this chain.
function bridge() public view returns (address) {
return BRIDGE;
}
/// @custom:legacy /// @custom:legacy
/// @notice Creates an instance of the OptimismMintableERC20 contract. Legacy version of the /// @notice Creates an instance of the OptimismMintableERC20 contract. Legacy version of the
/// newer createOptimismMintableERC20 function, which has a more intuitive name. /// newer createOptimismMintableERC20 function, which has a more intuitive name.
...@@ -93,7 +99,7 @@ contract OptimismMintableERC20Factory is ISemver { ...@@ -93,7 +99,7 @@ contract OptimismMintableERC20Factory is ISemver {
bytes32 salt = keccak256(abi.encode(_remoteToken, _name, _symbol, _decimals)); bytes32 salt = keccak256(abi.encode(_remoteToken, _name, _symbol, _decimals));
address localToken = address localToken =
address(new OptimismMintableERC20{salt: salt}(bridge, _remoteToken, _name, _symbol, _decimals)); address(new OptimismMintableERC20{salt: salt}(BRIDGE, _remoteToken, _name, _symbol, _decimals));
// Emit the old event too for legacy support. // Emit the old event too for legacy support.
emit StandardL2TokenCreated(_remoteToken, localToken); emit StandardL2TokenCreated(_remoteToken, localToken);
......
...@@ -120,13 +120,18 @@ abstract contract StandardBridge { ...@@ -120,13 +120,18 @@ abstract contract StandardBridge {
/// Must be implemented by contracts that inherit. /// Must be implemented by contracts that inherit.
receive() external payable virtual; receive() external payable virtual;
/// @custom:legacy /// @notice Getter for messenger contract.
/// @notice Legacy getter for messenger contract.
/// @return Messenger contract on this domain. /// @return Messenger contract on this domain.
function messenger() external view returns (CrossDomainMessenger) { function messenger() external view returns (CrossDomainMessenger) {
return MESSENGER; return MESSENGER;
} }
/// @notice Getter for the other bridge.
/// @return The bridge contract on the other network.
function otherBridge() external view returns (StandardBridge) {
return OTHER_BRIDGE;
}
/// @notice Sends ETH to the sender's address on the other chain. /// @notice Sends ETH to the sender's address on the other chain.
/// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with. /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
/// @param _extraData Extra data to be sent with the transaction. Note that the recipient will /// @param _extraData Extra data to be sent with the transaction. Note that the recipient will
......
...@@ -140,7 +140,6 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -140,7 +140,6 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
/// chain is done so by an honest party. /// chain is done so by an honest party.
function test_initialize_firstOutput_reverts() public { function test_initialize_firstOutput_reverts() public {
uint256 submissionInterval = l2OutputOracle.SUBMISSION_INTERVAL(); uint256 submissionInterval = l2OutputOracle.SUBMISSION_INTERVAL();
uint256 submissionInterval = l2OutputOracle.submissionInterval();
vm.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11)); vm.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11));
factory.create(GAME_TYPE, ROOT_CLAIM, abi.encode(submissionInterval, block.number - 1)); factory.create(GAME_TYPE, ROOT_CLAIM, abi.encode(submissionInterval, block.number - 1));
} }
......
...@@ -45,21 +45,12 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init { ...@@ -45,21 +45,12 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init {
/// @dev Tests that initailization sets the correct values. /// @dev Tests that initailization sets the correct values.
function test_initialize_values_succeeds() external { function test_initialize_values_succeeds() external {
assertEq(systemConfig.l1CrossDomainMessenger(), address(l1CrossDomainMessenger));
assertEq(systemConfig.l1ERC721Bridge(), address(l1ERC721Bridge));
assertEq(systemConfig.l1StandardBridge(), address(l1StandardBridge));
assertEq(systemConfig.l2OutputOracle(), address(l2OutputOracle));
assertEq(systemConfig.optimismPortal(), address(optimismPortal));
assertEq(systemConfig.optimismMintableERC20Factory(), optimismMintableERC20Factory);
assertEq(systemConfig.batchInbox(), batchInbox);
assertEq(systemConfig.owner(), owner); assertEq(systemConfig.owner(), owner);
assertEq(systemConfig.overhead(), overhead); assertEq(systemConfig.overhead(), overhead);
assertEq(systemConfig.scalar(), scalar); assertEq(systemConfig.scalar(), scalar);
assertEq(systemConfig.batcherHash(), batcherHash); assertEq(systemConfig.batcherHash(), batcherHash);
assertEq(systemConfig.gasLimit(), gasLimit); assertEq(systemConfig.gasLimit(), gasLimit);
assertEq(systemConfig.unsafeBlockSigner(), unsafeBlockSigner); assertEq(systemConfig.unsafeBlockSigner(), unsafeBlockSigner);
// Depends on start block being set to 0 in `initialize`
assertEq(systemConfig.startBlock(), block.number);
// Depends on `initialize` being called with defaults // Depends on `initialize` being called with defaults
ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG(); ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG();
ResourceMetering.ResourceConfig memory actual = systemConfig.resourceConfig(); ResourceMetering.ResourceConfig memory actual = systemConfig.resourceConfig();
......
...@@ -118,8 +118,10 @@ contract Setup is Deploy { ...@@ -118,8 +118,10 @@ contract Setup is Deploy {
vm.etch(address(l2StandardBridge), address(new L2StandardBridge(payable(l1StandardBridge))).code); vm.etch(address(l2StandardBridge), address(new L2StandardBridge(payable(l1StandardBridge))).code);
vm.etch(address(l2OptimismMintableERC20Factory), address(new OptimismMintableERC20Factory()).code); vm.etch(
l2OptimismMintableERC20Factory.initialize(address(l2StandardBridge)); address(l2OptimismMintableERC20Factory),
address(new OptimismMintableERC20Factory(address(l2StandardBridge))).code
);
vm.etch(address(legacyERC20ETH), address(new LegacyERC20ETH()).code); vm.etch(address(legacyERC20ETH), address(new LegacyERC20ETH()).code);
......
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