diff --git a/contracts/Arbitrator.sol b/contracts/Arbitrator.sol index 0bc7248..ce10c00 100644 --- a/contracts/Arbitrator.sol +++ b/contracts/Arbitrator.sol @@ -83,7 +83,7 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra function setSecondaryChainGateway( IL1Gateway _gateway, bool _active, - bytes memory _adapterParams + bytes calldata _adapterParams ) external payable onlyOwner { require(_gateway != primaryChainGateway, "Invalid gateway"); secondaryChainGateways[_gateway] = _active; @@ -104,7 +104,7 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra IL1Gateway _gateway, address _validator, bool _active, - bytes memory _adapterParams + bytes calldata _adapterParams ) external payable onlyOwner { require(_gateway == primaryChainGateway || secondaryChainGateways[_gateway], "Invalid gateway"); bytes memory callData = abi.encodeCall(IAdmin.setValidator, (_validator, _active)); @@ -117,7 +117,7 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra function changeFeeParams( IL1Gateway _gateway, FeeParams calldata _newFeeParams, - bytes memory _adapterParams + bytes calldata _adapterParams ) external payable onlyOwner { require(_gateway == primaryChainGateway || secondaryChainGateways[_gateway], "Invalid gateway"); bytes memory callData = abi.encodeCall(IAdmin.changeFeeParams, (_newFeeParams)); @@ -126,7 +126,7 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra emit NewFeeParams(_gateway, _newFeeParams); } - function receiveMessage(uint256 _value, bytes memory _callData) external payable { + function receiveMessage(uint256 _value, bytes calldata _callData) external payable { require(msg.value == _value, "Invalid msg value"); // store message hash for forwarding bytes32 finalizeMessageHash = keccak256(abi.encode(_value, _callData)); @@ -143,8 +143,8 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra function forwardMessage( IL1Gateway _gateway, uint256 _value, - bytes memory _callData, - bytes memory _adapterParams + bytes calldata _callData, + bytes calldata _adapterParams ) external payable nonReentrant onlyRelayer { bytes32 finalizeMessageHash = keccak256(abi.encode(_value, _callData)); if (_gateway == primaryChainGateway) { diff --git a/contracts/dev-contracts/DummyArbitrator.sol b/contracts/dev-contracts/DummyArbitrator.sol index 9a2289e..7c84a6f 100644 --- a/contracts/dev-contracts/DummyArbitrator.sol +++ b/contracts/dev-contracts/DummyArbitrator.sol @@ -19,7 +19,7 @@ contract DummyArbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Re function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} - function receiveMessage(uint256 _value, bytes memory _callData) external payable { + function receiveMessage(uint256 _value, bytes calldata _callData) external payable { require(msg.value == _value, "Invalid msg value"); emit ReceiveMessage(_value, _callData); } @@ -27,8 +27,8 @@ contract DummyArbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Re function forwardMessage( IL1Gateway _gateway, uint256 _value, - bytes memory _callData, - bytes memory _adapterParams + bytes calldata _callData, + bytes calldata _adapterParams ) external payable { // Forward fee to send message _gateway.sendMessage{value: msg.value + _value}(_value, _callData, _adapterParams); diff --git a/contracts/gateway/arbitrum/ArbitrumL1Gateway.sol b/contracts/gateway/arbitrum/ArbitrumL1Gateway.sol index 2f2c14d..1b1eef3 100644 --- a/contracts/gateway/arbitrum/ArbitrumL1Gateway.sol +++ b/contracts/gateway/arbitrum/ArbitrumL1Gateway.sol @@ -33,8 +33,8 @@ contract ArbitrumL1Gateway is IMessageClaimer, L1BaseGateway, BaseGateway { function sendMessage( uint256 _value, - bytes memory _callData, - bytes memory _adapterParams + bytes calldata _callData, + bytes calldata _adapterParams ) external payable onlyArbitrator { (uint256 maxSubmissionCost, uint256 gasLimit, uint256 maxFeePerGas) = abi.decode( _adapterParams, @@ -55,7 +55,7 @@ contract ArbitrumL1Gateway is IMessageClaimer, L1BaseGateway, BaseGateway { ); } - function claimMessageCallback(uint256 _value, bytes memory _callData) external payable onlyRemoteGateway { + function claimMessageCallback(uint256 _value, bytes calldata _callData) external payable onlyRemoteGateway { require(msg.value == _value, "Invalid value"); // Forward message to arbitrator ARBITRATOR.receiveMessage{value: _value}(_value, _callData); diff --git a/contracts/gateway/arbitrum/ArbitrumL2Gateway.sol b/contracts/gateway/arbitrum/ArbitrumL2Gateway.sol index 7782141..70e022f 100644 --- a/contracts/gateway/arbitrum/ArbitrumL2Gateway.sol +++ b/contracts/gateway/arbitrum/ArbitrumL2Gateway.sol @@ -25,7 +25,7 @@ contract ArbitrumL2Gateway is IMessageClaimer, L2BaseGateway, BaseGateway { __BaseGateway_init(); } - function sendMessage(uint256 _value, bytes memory _callData) external payable override onlyZkLink { + function sendMessage(uint256 _value, bytes calldata _callData) external payable override onlyZkLink { // no fee require(msg.value == _value, "Invalid value"); @@ -36,7 +36,7 @@ contract ArbitrumL2Gateway is IMessageClaimer, L2BaseGateway, BaseGateway { emit L2GatewayMessageSent(_value, _callData); } - function claimMessageCallback(uint256 _value, bytes memory _callData) external payable onlyRemoteGateway { + function claimMessageCallback(uint256 _value, bytes calldata _callData) external payable onlyRemoteGateway { require(msg.value == _value, "Invalid value"); // solhint-disable-next-line avoid-low-level-calls diff --git a/contracts/gateway/ethereum/EthereumGateway.sol b/contracts/gateway/ethereum/EthereumGateway.sol index 7216435..8f4dd82 100644 --- a/contracts/gateway/ethereum/EthereumGateway.sol +++ b/contracts/gateway/ethereum/EthereumGateway.sol @@ -31,7 +31,7 @@ contract EthereumGateway is return address(this); } - function sendMessage(uint256 _value, bytes memory _callData, bytes memory) external payable onlyArbitrator { + function sendMessage(uint256 _value, bytes calldata _callData, bytes calldata) external payable onlyArbitrator { require(msg.value == _value, "Invalid value"); // solhint-disable-next-line avoid-low-level-calls @@ -39,7 +39,7 @@ contract EthereumGateway is require(success, "Call zkLink failed"); } - function sendMessage(uint256 _value, bytes memory _callData) external payable override onlyZkLink { + function sendMessage(uint256 _value, bytes calldata _callData) external payable override onlyZkLink { require(msg.value == _value, "Invalid value"); // Forward message to arbitrator ARBITRATOR.receiveMessage{value: _value}(_value, _callData); diff --git a/contracts/gateway/linea/LineaL1Gateway.sol b/contracts/gateway/linea/LineaL1Gateway.sol index 2508e08..c479767 100644 --- a/contracts/gateway/linea/LineaL1Gateway.sol +++ b/contracts/gateway/linea/LineaL1Gateway.sol @@ -19,7 +19,7 @@ contract LineaL1Gateway is L1BaseGateway, LineaGateway { __LineaGateway_init(); } - function sendMessage(uint256 _value, bytes memory _callData, bytes memory) external payable onlyArbitrator { + function sendMessage(uint256 _value, bytes calldata _callData, bytes calldata) external payable onlyArbitrator { // transfer no fee to destination chain require(msg.value == _value, "Invalid value"); bytes memory message = abi.encodeCall(IMessageClaimer.claimMessageCallback, (_value, _callData)); diff --git a/contracts/gateway/linea/LineaL2Gateway.sol b/contracts/gateway/linea/LineaL2Gateway.sol index 31c7ca5..c0fed4e 100644 --- a/contracts/gateway/linea/LineaL2Gateway.sol +++ b/contracts/gateway/linea/LineaL2Gateway.sol @@ -18,7 +18,7 @@ contract LineaL2Gateway is L2BaseGateway, LineaGateway { __LineaGateway_init(); } - function sendMessage(uint256 _value, bytes memory _callData) external payable override onlyZkLink { + function sendMessage(uint256 _value, bytes calldata _callData) external payable override onlyZkLink { // msg value should include fee uint256 coinbaseFee = IL2MessageService(address(MESSAGE_SERVICE)).minimumFeeInWei(); require(msg.value == _value + coinbaseFee, "Invalid value"); diff --git a/contracts/gateway/optimism/OptimismL1Gateway.sol b/contracts/gateway/optimism/OptimismL1Gateway.sol index 4896bbd..aefbf6a 100644 --- a/contracts/gateway/optimism/OptimismL1Gateway.sol +++ b/contracts/gateway/optimism/OptimismL1Gateway.sol @@ -21,8 +21,8 @@ contract OptimismL1Gateway is L1BaseGateway, OptimismGateway { function sendMessage( uint256 _value, - bytes memory _callData, - bytes memory _adapterParams + bytes calldata _callData, + bytes calldata _adapterParams ) external payable onlyArbitrator { require(msg.value == _value, "Invalid value"); uint32 _minGasLimit = abi.decode(_adapterParams, (uint32)); diff --git a/contracts/gateway/optimism/OptimismL2Gateway.sol b/contracts/gateway/optimism/OptimismL2Gateway.sol index 1bd65c8..6362b4f 100644 --- a/contracts/gateway/optimism/OptimismL2Gateway.sol +++ b/contracts/gateway/optimism/OptimismL2Gateway.sol @@ -17,7 +17,7 @@ contract OptimismL2Gateway is L2BaseGateway, OptimismGateway { __OptimismGateway_init(); } - function sendMessage(uint256 _value, bytes memory _callData) external payable override onlyZkLink { + function sendMessage(uint256 _value, bytes calldata _callData) external payable override onlyZkLink { require(msg.value == _value, "Invalid fee"); bytes memory message = abi.encodeCall(IMessageClaimer.claimMessageCallback, (_value, _callData)); diff --git a/contracts/gateway/scroll/ScrollL1Gateway.sol b/contracts/gateway/scroll/ScrollL1Gateway.sol index 6f5ca39..6b4de6f 100644 --- a/contracts/gateway/scroll/ScrollL1Gateway.sol +++ b/contracts/gateway/scroll/ScrollL1Gateway.sol @@ -21,8 +21,8 @@ contract ScrollL1Gateway is ScrollGateway, L1BaseGateway { function sendMessage( uint256 _value, - bytes memory _callData, - bytes memory _adapterParams + bytes calldata _callData, + bytes calldata _adapterParams ) external payable override onlyArbitrator { uint256 _finalizeMessageGasLimit = abi.decode(_adapterParams, (uint256)); @@ -39,7 +39,7 @@ contract ScrollL1Gateway is ScrollGateway, L1BaseGateway { function claimMessageCallback( uint256 _value, - bytes memory _callData + bytes calldata _callData ) external payable override onlyMessageService onlyRemoteGateway { // no fee require(msg.value == _value, "Invalid value"); diff --git a/contracts/gateway/scroll/ScrollL2Gateway.sol b/contracts/gateway/scroll/ScrollL2Gateway.sol index 7256d35..627e0e6 100644 --- a/contracts/gateway/scroll/ScrollL2Gateway.sol +++ b/contracts/gateway/scroll/ScrollL2Gateway.sol @@ -18,7 +18,7 @@ contract ScrollL2Gateway is L2BaseGateway, ScrollGateway { __ScrollGateway_init(); } - function sendMessage(uint256 _value, bytes memory _callData) external payable override onlyZkLink { + function sendMessage(uint256 _value, bytes calldata _callData) external payable override onlyZkLink { // no fee require(msg.value == _value, "Invalid value"); @@ -35,7 +35,7 @@ contract ScrollL2Gateway is L2BaseGateway, ScrollGateway { function claimMessageCallback( uint256 _value, - bytes memory _callData + bytes calldata _callData ) external payable override onlyMessageService onlyRemoteGateway { require(msg.value == _value, "Invalid value"); diff --git a/contracts/gateway/zkpolygon/ZkPolygonL1Gateway.sol b/contracts/gateway/zkpolygon/ZkPolygonL1Gateway.sol index e7bfec1..f220275 100644 --- a/contracts/gateway/zkpolygon/ZkPolygonL1Gateway.sol +++ b/contracts/gateway/zkpolygon/ZkPolygonL1Gateway.sol @@ -33,7 +33,7 @@ contract ZkPolygonL1Gateway is IBridgeMessageReceiver, L1BaseGateway, BaseGatewa __BaseGateway_init(); } - function sendMessage(uint256 _value, bytes memory _callData, bytes memory) external payable onlyArbitrator { + function sendMessage(uint256 _value, bytes calldata _callData, bytes calldata) external payable onlyArbitrator { require(msg.value == _value, "Invalid value"); bytes memory executeData = abi.encode(_value, _callData); @@ -48,7 +48,7 @@ contract ZkPolygonL1Gateway is IBridgeMessageReceiver, L1BaseGateway, BaseGatewa function onMessageReceived( address originAddress, uint32, - bytes memory data + bytes calldata data ) external payable override onlyMessageService { require(originAddress == remoteGateway, "Invalid origin address"); diff --git a/contracts/gateway/zkpolygon/ZkPolygonL2Gateway.sol b/contracts/gateway/zkpolygon/ZkPolygonL2Gateway.sol index ed1922e..9c142bc 100644 --- a/contracts/gateway/zkpolygon/ZkPolygonL2Gateway.sol +++ b/contracts/gateway/zkpolygon/ZkPolygonL2Gateway.sol @@ -29,7 +29,7 @@ contract ZkPolygonL2Gateway is IBridgeMessageReceiver, L2BaseGateway, BaseGatewa __BaseGateway_init(); } - function sendMessage(uint256 _value, bytes memory _callData) external payable onlyZkLink { + function sendMessage(uint256 _value, bytes calldata _callData) external payable onlyZkLink { // no fee require(msg.value == _value, "Invalid value"); @@ -46,7 +46,7 @@ contract ZkPolygonL2Gateway is IBridgeMessageReceiver, L2BaseGateway, BaseGatewa function onMessageReceived( address originAddress, uint32, - bytes memory data + bytes calldata data ) external payable override onlyMessageService { require(originAddress == remoteGateway, "Invalid origin address"); (uint256 _value, bytes memory _callData) = abi.decode(data, (uint256, bytes)); diff --git a/contracts/gateway/zksync/ZkSyncL1Gateway.sol b/contracts/gateway/zksync/ZkSyncL1Gateway.sol index e07a1fd..9ddc1a1 100644 --- a/contracts/gateway/zksync/ZkSyncL1Gateway.sol +++ b/contracts/gateway/zksync/ZkSyncL1Gateway.sol @@ -34,8 +34,8 @@ contract ZkSyncL1Gateway is IZkSyncL1Gateway, L1BaseGateway, BaseGateway { function sendMessage( uint256 _value, - bytes memory _callData, - bytes memory _adapterParams + bytes calldata _callData, + bytes calldata _adapterParams ) external payable onlyArbitrator { (uint256 _l2GasLimit, uint256 _l2GasPerPubdataByteLimit) = abi.decode(_adapterParams, (uint256, uint256)); bytes memory executeData = abi.encodeCall(IMessageClaimer.claimMessageCallback, (_value, _callData)); diff --git a/contracts/gateway/zksync/ZkSyncL2Gateway.sol b/contracts/gateway/zksync/ZkSyncL2Gateway.sol index 0fffcc5..d42f471 100644 --- a/contracts/gateway/zksync/ZkSyncL2Gateway.sol +++ b/contracts/gateway/zksync/ZkSyncL2Gateway.sol @@ -31,7 +31,7 @@ contract ZkSyncL2Gateway is IMessageClaimer, L2BaseGateway, BaseGateway { __BaseGateway_init(); } - function sendMessage(uint256 _value, bytes memory _callData) external payable override onlyZkLink { + function sendMessage(uint256 _value, bytes calldata _callData) external payable override onlyZkLink { // no fee require(msg.value == _value, "Invalid value"); @@ -40,7 +40,7 @@ contract ZkSyncL2Gateway is IMessageClaimer, L2BaseGateway, BaseGateway { emit L2GatewayMessageSent(_value, _callData); } - function claimMessageCallback(uint256 _value, bytes memory _callData) external payable onlyRemoteGateway { + function claimMessageCallback(uint256 _value, bytes calldata _callData) external payable onlyRemoteGateway { require(msg.value == _value, "Invalid value"); // solhint-disable-next-line avoid-low-level-calls diff --git a/contracts/interfaces/IArbitrator.sol b/contracts/interfaces/IArbitrator.sol index 78d9469..83a1149 100644 --- a/contracts/interfaces/IArbitrator.sol +++ b/contracts/interfaces/IArbitrator.sol @@ -7,7 +7,7 @@ interface IArbitrator { /// @notice Receive message from one L1 gateway to another L1 gateway /// @param _value The msg value /// @param _callData The call data - function receiveMessage(uint256 _value, bytes memory _callData) external payable; + function receiveMessage(uint256 _value, bytes calldata _callData) external payable; /// @notice Forward message from one L1 gateway to another L1 gateway /// @param _gateway The message source gateway @@ -17,7 +17,7 @@ interface IArbitrator { function forwardMessage( IL1Gateway _gateway, uint256 _value, - bytes memory _callData, - bytes memory _adapterParams + bytes calldata _callData, + bytes calldata _adapterParams ) external payable; } diff --git a/contracts/interfaces/IL1Gateway.sol b/contracts/interfaces/IL1Gateway.sol index 1571d9a..d835a56 100644 --- a/contracts/interfaces/IL1Gateway.sol +++ b/contracts/interfaces/IL1Gateway.sol @@ -8,5 +8,5 @@ interface IL1Gateway is IGateway { /// @param _value The msg value /// @param _callData The call data /// @param _adapterParams Some params need to call canonical message service - function sendMessage(uint256 _value, bytes memory _callData, bytes memory _adapterParams) external payable; + function sendMessage(uint256 _value, bytes calldata _callData, bytes calldata _adapterParams) external payable; } diff --git a/contracts/interfaces/IL2Gateway.sol b/contracts/interfaces/IL2Gateway.sol index 12e225b..f932a6d 100644 --- a/contracts/interfaces/IL2Gateway.sol +++ b/contracts/interfaces/IL2Gateway.sol @@ -7,5 +7,5 @@ interface IL2Gateway is IGateway { /// @notice Send message to remote gateway /// @param _value The msg value /// @param _callData The call data - function sendMessage(uint256 _value, bytes memory _callData) external payable; + function sendMessage(uint256 _value, bytes calldata _callData) external payable; } diff --git a/contracts/interfaces/IMessageClaimer.sol b/contracts/interfaces/IMessageClaimer.sol index 86969b6..f6c0930 100644 --- a/contracts/interfaces/IMessageClaimer.sol +++ b/contracts/interfaces/IMessageClaimer.sol @@ -5,5 +5,5 @@ interface IMessageClaimer { /// @notice Receive callback called by message service /// @param _value The message value /// @param _callData The message data - function claimMessageCallback(uint256 _value, bytes memory _callData) external payable; + function claimMessageCallback(uint256 _value, bytes calldata _callData) external payable; }