Commit eb4033c3 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: update optimism portal

parent ac5923af
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
...@@ -53,15 +53,15 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -53,15 +53,15 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
/// @notice Address of the L2OutputOracle contract. /// @notice Address of the L2OutputOracle contract.
/// @custom:network-specific /// @custom:network-specific
L2OutputOracle public L2_ORACLE; L2OutputOracle internal _L2_ORACLE;
/// @notice Address of the SystemConfig contract. /// @notice Address of the SystemConfig contract.
/// @custom:network-specific /// @custom:network-specific
SystemConfig public SYSTEM_CONFIG; SystemConfig internal _SYSTEM_CONFIG;
/// @notice Address that has the ability to pause and unpause withdrawals. /// @notice Address that has the ability to pause and unpause withdrawals.
/// @custom:network-specific /// @custom:network-specific
address public GUARDIAN; address internal _GUARDIAN;
/// @notice Emitted when a transaction is deposited from L1 to L2. /// @notice Emitted when a transaction is deposited from L1 to L2.
/// The parameters of this event are read by the rollup node and used to derive deposit /// The parameters of this event are read by the rollup node and used to derive deposit
...@@ -129,23 +129,55 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -129,23 +129,55 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
bool _paused bool _paused
) public reinitializer(2) { ) public reinitializer(2) {
l2Sender = Constants.DEFAULT_L2_SENDER; l2Sender = Constants.DEFAULT_L2_SENDER;
L2_ORACLE = _l2Oracle; _L2_ORACLE = _l2Oracle;
SYSTEM_CONFIG = _systemConfig; _SYSTEM_CONFIG = _systemConfig;
GUARDIAN = _guardian; _GUARDIAN = _guardian;
paused = _paused; paused = _paused;
__ResourceMetering_init(); __ResourceMetering_init();
} }
/// @notice Getter for the L2OutputOracle
/// @custom:legacy
function L2_ORACLE() external view returns (L2OutputOracle) {
return _L2_ORACLE;
}
/// @notice Getter for the L2OutputOracle
function l2Oracle() external view returns (L2OutputOracle) {
return _L2_ORACLE;
}
/// @notice Getter for the SystemConfig
/// @custom:legacy
function SYSTEM_CONFIG() external view returns (SystemConfig) {
return _SYSTEM_CONFIG;
}
/// @notice Getter for the SystemConfig
function systemConfig() external view returns (SystemConfig) {
return _SYSTEM_CONFIG;
}
/// @notice Getter for the Guardian
/// @custom:legacy
function GUARDIAN() external view returns (address) {
return _GUARDIAN;
}
/// @notice Getter for the Guardian
function guardian() external 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");
paused = true; paused = true;
emit Paused(msg.sender); emit Paused(msg.sender);
} }
/// @notice Unpauses withdrawals. /// @notice Unpauses withdrawals.
function unpause() external { function unpause() external {
require(msg.sender == GUARDIAN, "OptimismPortal: only guardian can unpause"); require(msg.sender == _GUARDIAN, "OptimismPortal: only guardian can unpause");
paused = false; paused = false;
emit Unpaused(msg.sender); emit Unpaused(msg.sender);
} }
...@@ -187,7 +219,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -187,7 +219,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
override override
returns (ResourceMetering.ResourceConfig memory) returns (ResourceMetering.ResourceConfig memory)
{ {
return SYSTEM_CONFIG.resourceConfig(); return _SYSTEM_CONFIG.resourceConfig();
} }
/// @notice Proves a withdrawal transaction. /// @notice Proves a withdrawal transaction.
...@@ -211,7 +243,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -211,7 +243,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
// Get the output root and load onto the stack to prevent multiple mloads. This will // Get the output root and load onto the stack to prevent multiple mloads. This will
// revert if there is no output root for the given block number. // revert if there is no output root for the given block number.
bytes32 outputRoot = L2_ORACLE.getL2Output(_l2OutputIndex).outputRoot; bytes32 outputRoot = _L2_ORACLE.getL2Output(_l2OutputIndex).outputRoot;
// Verify that the output root can be generated with the elements in the proof. // Verify that the output root can be generated with the elements in the proof.
require( require(
...@@ -231,7 +263,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -231,7 +263,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
// output index has been updated. // output index has been updated.
require( require(
provenWithdrawal.timestamp == 0 || provenWithdrawal.timestamp == 0 ||
L2_ORACLE.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != _L2_ORACLE.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot !=
provenWithdrawal.outputRoot, provenWithdrawal.outputRoot,
"OptimismPortal: withdrawal hash has already been proven" "OptimismPortal: withdrawal hash has already been proven"
); );
...@@ -303,7 +335,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -303,7 +335,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
// starting timestamp inside the L2OutputOracle. Not strictly necessary but extra layer of // starting timestamp inside the L2OutputOracle. Not strictly necessary but extra layer of
// safety against weird bugs in the proving step. // safety against weird bugs in the proving step.
require( require(
provenWithdrawal.timestamp >= L2_ORACLE.startingTimestamp(), provenWithdrawal.timestamp >= _L2_ORACLE.startingTimestamp(),
"OptimismPortal: withdrawal timestamp less than L2 Oracle starting timestamp" "OptimismPortal: withdrawal timestamp less than L2 Oracle starting timestamp"
); );
...@@ -318,7 +350,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -318,7 +350,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
// Grab the OutputProposal from the L2OutputOracle, will revert if the output that // Grab the OutputProposal from the L2OutputOracle, will revert if the output that
// corresponds to the given index has not been proposed yet. // corresponds to the given index has not been proposed yet.
Types.OutputProposal memory proposal = L2_ORACLE.getL2Output( Types.OutputProposal memory proposal = _L2_ORACLE.getL2Output(
provenWithdrawal.l2OutputIndex provenWithdrawal.l2OutputIndex
); );
...@@ -438,7 +470,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -438,7 +470,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
/// @param _l2OutputIndex Index of the L2 output to check. /// @param _l2OutputIndex Index of the L2 output to check.
/// @return Whether or not the output is finalized. /// @return Whether or not the output is finalized.
function isOutputFinalized(uint256 _l2OutputIndex) external view returns (bool) { function isOutputFinalized(uint256 _l2OutputIndex) external view returns (bool) {
return _isFinalizationPeriodElapsed(L2_ORACLE.getL2Output(_l2OutputIndex).timestamp); return _isFinalizationPeriodElapsed(_L2_ORACLE.getL2Output(_l2OutputIndex).timestamp);
} }
/// @notice Determines whether the finalization period has elapsed with respect to /// @notice Determines whether the finalization period has elapsed with respect to
...@@ -446,6 +478,6 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -446,6 +478,6 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
/// @param _timestamp Timestamp to check. /// @param _timestamp Timestamp to check.
/// @return Whether or not the finalization period has elapsed. /// @return Whether or not the finalization period has elapsed.
function _isFinalizationPeriodElapsed(uint256 _timestamp) internal view returns (bool) { function _isFinalizationPeriodElapsed(uint256 _timestamp) internal view returns (bool) {
return block.timestamp > _timestamp + L2_ORACLE.FINALIZATION_PERIOD_SECONDS(); return block.timestamp > _timestamp + _L2_ORACLE.FINALIZATION_PERIOD_SECONDS();
} }
} }
...@@ -26,6 +26,9 @@ contract OptimismPortal_Test is Portal_Initializer { ...@@ -26,6 +26,9 @@ contract OptimismPortal_Test is Portal_Initializer {
/// @dev Tests that the constructor sets the correct values. /// @dev Tests that the constructor sets the correct values.
function test_constructor_succeeds() external { function test_constructor_succeeds() external {
assertEq(address(op.L2_ORACLE()), address(oracle)); assertEq(address(op.L2_ORACLE()), address(oracle));
assertEq(address(op.l2Oracle()), address(oracle));
assertEq(op.GUARDIAN(), guardian);
assertEq(op.guardian(), guardian);
assertEq(op.l2Sender(), 0x000000000000000000000000000000000000dEaD); assertEq(op.l2Sender(), 0x000000000000000000000000000000000000dEaD);
assertEq(op.paused(), false); assertEq(op.paused(), false);
} }
......
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