Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N-04 use better hardcoded values #14

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions contracts/messageService/l1/L1MessageService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ abstract contract L1MessageService is
// @dev adding these should not affect storage as they are constants and are stored in bytecode.
uint256 private constant REFUND_OVERHEAD_IN_GAS = 42000;

address private constant DEFAULT_SENDER_ADDRESS = address(123456789);

/**
* @notice Initialises underlying message service dependencies.
* @dev _messageSender is initialised to a non-zero value for gas efficiency on claiming.
Expand Down Expand Up @@ -66,7 +68,7 @@ abstract contract L1MessageService is
_grantRole(PAUSE_MANAGER_ROLE, _pauseManagerAddress);

nextMessageNumber = 1;
_messageSender = address(123456789);
_messageSender = DEFAULT_SENDER_ADDRESS;
}

/**
Expand Down Expand Up @@ -107,7 +109,7 @@ abstract contract L1MessageService is
* @notice Claims and delivers a cross-chain message.
* @dev _feeRecipient can be set to address(0) to receive as msg.sender.
* @dev _messageSender is set temporarily when claiming and reset post. Used in sender().
* @dev _messageSender is reset to address(123456789) to be more gas efficient.
* @dev _messageSender is reset to DEFAULT_SENDER_ADDRESS to be more gas efficient.
* @param _from The address of the original sender.
* @param _to The address the message is intended for.
* @param _fee The fee being paid for the message delivery.
Expand Down Expand Up @@ -149,7 +151,7 @@ abstract contract L1MessageService is
}
}

_messageSender = address(123456789);
_messageSender = DEFAULT_SENDER_ADDRESS;

emit MessageClaimed(messageHash);
}
Expand Down
6 changes: 4 additions & 2 deletions contracts/messageService/l2/L2MessageService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ contract L2MessageService is
// @dev adding these should not affect storage as they are constants and are store in bytecode
uint256 private constant REFUND_OVERHEAD_IN_GAS = 47500;

address private constant DEFAULT_SENDER_ADDRESS = address(123456789);

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
Expand Down Expand Up @@ -78,7 +80,7 @@ contract L2MessageService is
_grantRole(RATE_LIMIT_SETTER_ROLE, _securityCouncil);
_grantRole(PAUSE_MANAGER_ROLE, _securityCouncil);

_messageSender = address(123456789);
_messageSender = DEFAULT_SENDER_ADDRESS;
}

/**
Expand Down Expand Up @@ -173,7 +175,7 @@ contract L2MessageService is
}
}

_messageSender = address(123456789);
_messageSender = DEFAULT_SENDER_ADDRESS;
emit MessageClaimed(messageHash);
}

Expand Down
3 changes: 1 addition & 2 deletions contracts/tokenBridge/TokenBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ contract TokenBridge is
using SafeERC20Upgradeable for IERC20Upgradeable;

// solhint-disable-next-line var-name-mixedcase
bytes4 internal constant _PERMIT_SELECTOR =
bytes4(keccak256(bytes("permit(address,address,uint256,uint256,uint8,bytes32,bytes32)")));
bytes4 internal constant _PERMIT_SELECTOR = IERC20PermitUpgradeable.permit.selector;

/// @notice used for the token metadata
bytes private constant METADATA_NAME = abi.encodeCall(IERC20MetadataUpgradeable.name, ());
Expand Down