diff --git a/src/bridge/AbsInbox.sol b/src/bridge/AbsInbox.sol index e612b9b2b..3f69643c6 100644 --- a/src/bridge/AbsInbox.sol +++ b/src/bridge/AbsInbox.sol @@ -5,13 +5,13 @@ pragma solidity ^0.8.4; import { + CalldataNotSameAsTx, DataTooLarge, GasLimitTooLarge, InsufficientValue, InsufficientSubmissionCost, L1Forked, NotAllowedOrigin, - NotTopLevel, NotRollupOrOwner, RetryableData } from "../libraries/Error.sol"; @@ -140,7 +140,7 @@ abstract contract AbsInbox is DelegateCallAware, PausableUpgradeable, IInboxBase bytes calldata messageData ) external whenNotPaused onlyAllowed returns (uint256) { if (_chainIdChanged()) revert L1Forked(); - if (!CallerChecker.isCallerTopLevel()) revert NotTopLevel(); + if (!CallerChecker.isCalldataSameAsTx()) revert CalldataNotSameAsTx(); if (messageData.length > maxDataSize) revert DataTooLarge(messageData.length, maxDataSize); uint256 msgNum = _deliverToBridge(L2_MSG, msg.sender, keccak256(messageData), 0); emit InboxMessageDeliveredFromOrigin(msgNum); diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index d02929e7d..d2445cd61 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -19,7 +19,7 @@ import { NoSuchKeyset, NotForked, NotBatchPosterManager, - NotTopLevel, + CalldataNotSameAsTx, RollupNotChanged, DataBlobsNotSupported, InitParamZero, @@ -335,7 +335,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox uint256 prevMessageCount, uint256 newMessageCount ) external refundsGas(gasRefunder, IReader4844(address(0))) { - if (!CallerChecker.isCallerTopLevel()) revert NotTopLevel(); + if (!CallerChecker.isCalldataSameAsTx()) revert CalldataNotSameAsTx(); if (!isBatchPoster[msg.sender]) revert NotBatchPoster(); if (isDelayProofRequired(afterDelayedMessagesRead)) revert DelayProofRequired(); @@ -388,7 +388,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox uint256 newMessageCount, DelayProof calldata delayProof ) external refundsGas(gasRefunder, IReader4844(address(0))) { - if (!CallerChecker.isCallerTopLevel()) revert NotTopLevel(); + if (!CallerChecker.isCalldataSameAsTx()) revert CalldataNotSameAsTx(); if (!isBatchPoster[msg.sender]) revert NotBatchPoster(); if (!isDelayBufferable) revert NotDelayBufferable(); @@ -438,7 +438,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox // submit a batch spending report to refund the entity that produced the blob batch data // same as using calldata, we only submit spending report if the caller is the origin of the tx // such that one cannot "double-claim" batch posting refund in the same tx - if (CallerChecker.isCallerTopLevel() && !isUsingFeeToken) { + if (CallerChecker.isCalldataSameAsTx() && !isUsingFeeToken) { submitBatchSpendingReport(dataHash, seqMessageIndex, block.basefee, blobGas); } } diff --git a/src/libraries/CallerChecker.sol b/src/libraries/CallerChecker.sol index f4ef6efed..3965fbaea 100644 --- a/src/libraries/CallerChecker.sol +++ b/src/libraries/CallerChecker.sol @@ -4,12 +4,12 @@ pragma solidity ^0.8.0; -library CallerChecker { +library CalldataChecker { /** - * @notice A EIP-7702 safe check for top level caller, used to ensure the calldata is available in the tx - * @return bool true if the caller is a top level caller, false otherwise + * @notice A EIP-7702 safe check to ensure the calldata is available in the top level tx + * @return bool true if calldata is guaranteed to be available in the top level tx */ - function isCallerTopLevel() internal view returns (bool) { + function isCalldataSameAsTx() internal view returns (bool) { // solhint-disable-next-line avoid-tx-origin return msg.sender == tx.origin && msg.sender.code.length == 0; } diff --git a/src/libraries/Error.sol b/src/libraries/Error.sol index c600ff3a8..8bb190da8 100644 --- a/src/libraries/Error.sol +++ b/src/libraries/Error.sol @@ -13,8 +13,8 @@ error HadZeroInit(); /// @dev Thrown when post upgrade init validation fails error BadPostUpgradeInit(); -/// @dev Thrown when the caller is not a top level caller -error NotTopLevel(); +/// @dev Thrown when the calldata is not same as the top level tx +error CalldataNotSameAsTx(); /// @dev Thrown when non owner tries to access an only-owner function /// @param sender The msg.sender who is not the owner diff --git a/src/libraries/GasRefundEnabled.sol b/src/libraries/GasRefundEnabled.sol index f96574aac..c75879b12 100644 --- a/src/libraries/GasRefundEnabled.sol +++ b/src/libraries/GasRefundEnabled.sol @@ -25,7 +25,7 @@ abstract contract GasRefundEnabled { startGasLeft += calldataWords * 6 + (calldataWords ** 2) / 512; // if triggered in a contract call, the spender may be overrefunded by appending dummy data to the call // so we check if it is a top level call, which would mean the sender paid calldata as part of tx.input - if (!CallerChecker.isCallerTopLevel()) { + if (!CallerChecker.isCalldataSameAsTx()) { // We can't be sure if this calldata came from the top level tx, // so to be safe we tell the gas refunder there was no calldata. calldataSize = 0;