Skip to content

Commit

Permalink
chore: rename isCalldataSameAsTx
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeoneth committed Oct 8, 2024
1 parent 8ed4d51 commit ba6214d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/bridge/AbsInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
pragma solidity ^0.8.4;

import {
CalldataNotSameAsTx,
DataTooLarge,
GasLimitTooLarge,
InsufficientValue,
InsufficientSubmissionCost,
L1Forked,
NotAllowedOrigin,
NotTopLevel,
NotRollupOrOwner,
RetryableData
} from "../libraries/Error.sol";
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
NoSuchKeyset,
NotForked,
NotBatchPosterManager,
NotTopLevel,
CalldataNotSameAsTx,
RollupNotChanged,
DataBlobsNotSupported,
InitParamZero,
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/libraries/CallerChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Error.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/GasRefundEnabled.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ba6214d

Please sign in to comment.