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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface IOptimismPortal2 is IProxyAdminOwnedBase {
error OptimismPortal_NotAllowedOnCGTMode();
error OptimismPortal_GasEstimation();
error OptimismPortal_GasLimitTooLow();
error OptimismPortal_GasLimitTooHigh();
error OptimismPortal_ImproperDisputeGame();
error OptimismPortal_InvalidDisputeGame();
error OptimismPortal_InvalidMerkleProof();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,11 @@
"name": "OptimismPortal_GasEstimation",
"type": "error"
},
{
"inputs": [],
"name": "OptimismPortal_GasLimitTooHigh",
"type": "error"
},
{
"inputs": [],
"name": "OptimismPortal_GasLimitTooLow",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"sourceCodeHash": "0x90afce90a5d84c9ec696554ab40ae9d9f04e27ce3f3d758f4ac6001aef89b45e"
},
"src/L1/OptimismPortal2.sol:OptimismPortal2": {
"initCodeHash": "0x1101a3124e60908ec3e7690b33389d835d0405416d107114edd1684528f39bee",
"sourceCodeHash": "0xe9baa6201cba314f5db2f30a6d8c6c23fcdc2e2407246c9e0624d7e781f511e3"
"initCodeHash": "0xe0c29f245df9064c7108664ca0f94152f6c3733b1e17ffc866d3f04259c51586",
"sourceCodeHash": "0x1b83fa8d12b761cb87f11afbe483f935bfa2bf9c39063eee40d29a43c50f6df7"
},
"src/L1/ProtocolVersions.sol:ProtocolVersions": {
"initCodeHash": "0xcb59ad9a5ec2a0831b7f4daa74bdacba82ffa03035dafb499a732c641e017f4e",
Expand Down
13 changes: 11 additions & 2 deletions packages/contracts-bedrock/src/L1/OptimismPortal2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ReinitializableBase
/// @notice Thrown when the gas limit for a deposit is too low.
error OptimismPortal_GasLimitTooLow();

/// @notice Thrown when the gas limit for a deposit is too high.
error OptimismPortal_GasLimitTooHigh();

/// @notice Thrown when the target of a withdrawal is not a proper dispute game.
error OptimismPortal_ImproperDisputeGame();

Expand Down Expand Up @@ -234,9 +237,9 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ReinitializableBase
error OptimismPortal_InvalidLockboxState();

/// @notice Semantic version.
/// @custom:semver 5.6.0
/// @custom:semver 5.7.0
function version() public pure virtual returns (string memory) {
return "5.6.0";
return "5.7.0";
}

/// @param _proofMaturityDelaySeconds The proof maturity delay in seconds.
Expand Down Expand Up @@ -696,6 +699,12 @@ contract OptimismPortal2 is Initializable, ResourceMetering, ReinitializableBase
revert OptimismPortal_GasLimitTooLow();
}

// Prevent depositing transactions that have a gas limit that exceeds the post-Osaka
// maximum for non-system transactins.
if (_gasLimit > Constants.L2_MAX_TX_GAS_LIMIT) {
revert OptimismPortal_GasLimitTooHigh();
}

// Prevent the creation of deposit transactions that have too much calldata. This gives an
// upper limit on the size of unsafe blocks over the p2p network. 120kb is chosen to ensure
// that the transaction can fit into the p2p network policy of 128kb even though deposit
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts-bedrock/src/libraries/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ library Constants {
/// @notice Current bundle artifact path for Network Upgrade Transaction bundles.
string internal constant CURRENT_BUNDLE_PATH = "snapshots/upgrades/current-upgrade-bundle.json";

/// @notice The post-Osaka maximum gas limit allowed for a non-system transaction on L2.
uint64 internal constant L2_MAX_TX_GAS_LIMIT = 2 ** 24;

/// @notice Returns the default values for the ResourceConfig. These are the recommended values
/// for a production network.
function DEFAULT_RESOURCE_CONFIG() internal pure returns (IResourceMetering.ResourceConfig memory) {
Expand Down
12 changes: 12 additions & 0 deletions packages/contracts-bedrock/test/L1/OptimismPortal2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,18 @@ contract OptimismPortal2_DepositTransaction_Test is OptimismPortal2_TestInit {
optimismPortal2.depositTransaction({ _to: address(1), _value: 0, _gasLimit: 0, _isCreation: false, _data: hex"" });
}

/// @notice Tests that `depositTransaction` reverts when the gas limit is too large.
function test_depositTransaction_largeGasLimit_reverts() external {
vm.expectRevert(IOptimismPortal.OptimismPortal_GasLimitTooHigh.selector);
optimismPortal2.depositTransaction({
_to: address(1),
_value: 0,
_gasLimit: Constants.L2_MAX_TX_GAS_LIMIT + 1,
_isCreation: false,
_data: hex""
});
}

/// @notice Tests that `depositTransaction` reverts when the value is greater than 0 and the
/// custom gas token is active.
function test_depositTransaction_withCustomGasTokenAndValue_reverts(bytes memory _data, uint256 _value) external {
Expand Down
Loading