diff --git a/contracts/docs/apis/L1ERC1155Gateway.md b/contracts/docs/apis/L1ERC1155Gateway.md index 7c3d451ce8..d83998c7fd 100644 --- a/contracts/docs/apis/L1ERC1155Gateway.md +++ b/contracts/docs/apis/L1ERC1155Gateway.md @@ -260,23 +260,6 @@ function owner() external view returns (address) *Returns the address of the current owner.* -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of token rate limiter contract. - - - - #### Returns | Name | Type | Description | @@ -371,22 +354,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ### updateTokenMapping ```solidity @@ -563,23 +530,6 @@ Emitted when some ERC1155 token is refunded. | tokenId | uint256 | undefined | | amount | uint256 | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - ### UpdateTokenMapping ```solidity diff --git a/contracts/docs/apis/L1ERC721Gateway.md b/contracts/docs/apis/L1ERC721Gateway.md index 8efe16d723..bd68c05844 100644 --- a/contracts/docs/apis/L1ERC721Gateway.md +++ b/contracts/docs/apis/L1ERC721Gateway.md @@ -227,23 +227,6 @@ function owner() external view returns (address) *Returns the address of the current owner.* -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of token rate limiter contract. - - - - #### Returns | Name | Type | Description | @@ -316,22 +299,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ### updateTokenMapping ```solidity @@ -502,23 +469,6 @@ Emitted when some ERC721 token is refunded. | recipient `indexed` | address | undefined | | tokenId | uint256 | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - ### UpdateTokenMapping ```solidity diff --git a/contracts/docs/apis/L1ScrollMessenger.md b/contracts/docs/apis/L1ScrollMessenger.md index f8d05b2b0a..120f5a6603 100644 --- a/contracts/docs/apis/L1ScrollMessenger.md +++ b/contracts/docs/apis/L1ScrollMessenger.md @@ -239,23 +239,6 @@ Mapping from queue index to previous replay queue index. |---|---|---| | _0 | uint256 | undefined | -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of ETH rate limiter contract. - - - - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - ### relayMessageWithProof ```solidity @@ -453,22 +436,6 @@ Update max replay times. |---|---|---| | _newMaxReplayTimes | uint256 | The new max replay times. | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ### xDomainMessageSender ```solidity @@ -642,22 +609,5 @@ Emitted when the maximum number of times each message can be replayed is updated | oldMaxReplayTimes | uint256 | undefined | | newMaxReplayTimes | uint256 | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - diff --git a/contracts/docs/apis/L1StandardERC20Gateway.md b/contracts/docs/apis/L1StandardERC20Gateway.md index ff44a11e72..26d3403c40 100644 --- a/contracts/docs/apis/L1StandardERC20Gateway.md +++ b/contracts/docs/apis/L1StandardERC20Gateway.md @@ -225,23 +225,6 @@ function owner() external view returns (address) *Returns the address of the current owner.* -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of token rate limiter contract. - - - - #### Returns | Name | Type | Description | @@ -292,22 +275,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ## Events @@ -405,22 +372,5 @@ Emitted when some ERC20 token is refunded. | recipient `indexed` | address | undefined | | amount | uint256 | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - diff --git a/contracts/docs/apis/L1WETHGateway.md b/contracts/docs/apis/L1WETHGateway.md index 769e3b42e8..e181deb15c 100644 --- a/contracts/docs/apis/L1WETHGateway.md +++ b/contracts/docs/apis/L1WETHGateway.md @@ -223,23 +223,6 @@ function owner() external view returns (address) *Returns the address of the current owner.* -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of token rate limiter contract. - - - - #### Returns | Name | Type | Description | @@ -290,22 +273,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ## Events @@ -403,22 +370,5 @@ Emitted when some ERC20 token is refunded. | recipient `indexed` | address | undefined | | amount | uint256 | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - diff --git a/contracts/docs/apis/L2ERC1155Gateway.md b/contracts/docs/apis/L2ERC1155Gateway.md index b730898b22..dfe439a7d9 100644 --- a/contracts/docs/apis/L2ERC1155Gateway.md +++ b/contracts/docs/apis/L2ERC1155Gateway.md @@ -205,23 +205,6 @@ function owner() external view returns (address) *Returns the address of the current owner.* -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of token rate limiter contract. - - - - #### Returns | Name | Type | Description | @@ -316,22 +299,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ### updateTokenMapping ```solidity @@ -488,23 +455,6 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn | previousOwner `indexed` | address | undefined | | newOwner `indexed` | address | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - ### UpdateTokenMapping ```solidity diff --git a/contracts/docs/apis/L2ERC721Gateway.md b/contracts/docs/apis/L2ERC721Gateway.md index 64cded67da..d93099f66f 100644 --- a/contracts/docs/apis/L2ERC721Gateway.md +++ b/contracts/docs/apis/L2ERC721Gateway.md @@ -174,23 +174,6 @@ function owner() external view returns (address) *Returns the address of the current owner.* -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of token rate limiter contract. - - - - #### Returns | Name | Type | Description | @@ -263,22 +246,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ### updateTokenMapping ```solidity @@ -430,23 +397,6 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn | previousOwner `indexed` | address | undefined | | newOwner `indexed` | address | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - ### UpdateTokenMapping ```solidity diff --git a/contracts/docs/apis/L2ScrollMessenger.md b/contracts/docs/apis/L2ScrollMessenger.md index abe335f5e1..02b69767f2 100644 --- a/contracts/docs/apis/L2ScrollMessenger.md +++ b/contracts/docs/apis/L2ScrollMessenger.md @@ -155,23 +155,6 @@ function paused() external view returns (bool) |---|---|---| | _0 | bool | undefined | -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of ETH rate limiter contract. - - - - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - ### relayMessage ```solidity @@ -290,22 +273,6 @@ Update fee vault contract. |---|---|---| | _newFeeVault | address | The address of new fee vault contract. | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ### xDomainMessageSender ```solidity @@ -479,22 +446,5 @@ Emitted when the maximum number of times each message can fail in L2 is updated. | oldMaxFailedExecutionTimes | uint256 | undefined | | newMaxFailedExecutionTimes | uint256 | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - diff --git a/contracts/docs/apis/L2StandardERC20Gateway.md b/contracts/docs/apis/L2StandardERC20Gateway.md index 3427bb908e..cd521814f2 100644 --- a/contracts/docs/apis/L2StandardERC20Gateway.md +++ b/contracts/docs/apis/L2StandardERC20Gateway.md @@ -139,23 +139,6 @@ function owner() external view returns (address) *Returns the address of the current owner.* -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of token rate limiter contract. - - - - #### Returns | Name | Type | Description | @@ -223,22 +206,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ### withdrawERC20 ```solidity @@ -354,23 +321,6 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn | previousOwner `indexed` | address | undefined | | newOwner `indexed` | address | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - ### WithdrawERC20 ```solidity diff --git a/contracts/docs/apis/L2WETHGateway.md b/contracts/docs/apis/L2WETHGateway.md index 8dd64b3f80..ae04ad07ec 100644 --- a/contracts/docs/apis/L2WETHGateway.md +++ b/contracts/docs/apis/L2WETHGateway.md @@ -172,23 +172,6 @@ function owner() external view returns (address) *Returns the address of the current owner.* -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - -### rateLimiter - -```solidity -function rateLimiter() external view returns (address) -``` - -The address of token rate limiter contract. - - - - #### Returns | Name | Type | Description | @@ -239,22 +222,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateRateLimiter - -```solidity -function updateRateLimiter(address _newRateLimiter) external nonpayable -``` - -Update rate limiter contract. - -*This function can only called by contract owner.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newRateLimiter | address | The address of new rate limiter contract. | - ### withdrawERC20 ```solidity @@ -370,23 +337,6 @@ event OwnershipTransferred(address indexed previousOwner, address indexed newOwn | previousOwner `indexed` | address | undefined | | newOwner `indexed` | address | undefined | -### UpdateRateLimiter - -```solidity -event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter) -``` - -Emitted when owner updates rate limiter contract. - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _oldRateLimiter `indexed` | address | undefined | -| _newRateLimiter `indexed` | address | undefined | - ### WithdrawERC20 ```solidity diff --git a/contracts/scripts/foundry/InitializeL2RateLimiter.s.sol b/contracts/scripts/foundry/InitializeL2RateLimiter.s.sol deleted file mode 100644 index c6e5921393..0000000000 --- a/contracts/scripts/foundry/InitializeL2RateLimiter.s.sol +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.10; - -import {Script} from "forge-std/Script.sol"; - -import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; -import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; -import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; - -import {ScrollMessengerBase} from "../../src/libraries/ScrollMessengerBase.sol"; -import {ScrollGatewayBase} from "../../src/libraries/gateway/ScrollGatewayBase.sol"; -import {ETHRateLimiter} from "../../src/rate-limiter/ETHRateLimiter.sol"; -import {TokenRateLimiter} from "../../src/rate-limiter/TokenRateLimiter.sol"; - -// solhint-disable max-states-count -// solhint-disable state-visibility -// solhint-disable var-name-mixedcase - -contract InitializeL2RateLimiter is Script { - uint256 L2_DEPLOYER_PRIVATE_KEY = vm.envUint("L2_DEPLOYER_PRIVATE_KEY"); - - address L2_SCROLL_MESSENGER_PROXY_ADDR = vm.envAddress("L2_SCROLL_MESSENGER_PROXY_ADDR"); - address L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR = vm.envAddress("L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR"); - address L2_ETH_GATEWAY_PROXY_ADDR = vm.envAddress("L2_ETH_GATEWAY_PROXY_ADDR"); - address L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR = vm.envAddress("L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR"); - address L2_DAI_GATEWAY_PROXY_ADDR = vm.envAddress("L2_DAI_GATEWAY_PROXY_ADDR"); - // address L2_USDC_GATEWAY_PROXY_ADDR = vm.envAddress("L2_USDC_GATEWAY_PROXY_ADDR"); - - address L2_ETH_RATE_LIMITER_ADDR = vm.envAddress("L2_ETH_RATE_LIMITER_ADDR"); - address L2_TOKEN_RATE_LIMITER_ADDR = vm.envAddress("L2_TOKEN_RATE_LIMITER_ADDR"); - - function run() external { - vm.startBroadcast(L2_DEPLOYER_PRIVATE_KEY); - - ScrollMessengerBase(payable(L2_SCROLL_MESSENGER_PROXY_ADDR)).updateRateLimiter(L2_ETH_RATE_LIMITER_ADDR); - - bytes32 TOKEN_SPENDER_ROLE = TokenRateLimiter(L2_TOKEN_RATE_LIMITER_ADDR).TOKEN_SPENDER_ROLE(); - TokenRateLimiter(L2_TOKEN_RATE_LIMITER_ADDR).grantRole(TOKEN_SPENDER_ROLE, L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR); - TokenRateLimiter(L2_TOKEN_RATE_LIMITER_ADDR).grantRole( - TOKEN_SPENDER_ROLE, - L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR - ); - TokenRateLimiter(L2_TOKEN_RATE_LIMITER_ADDR).grantRole(TOKEN_SPENDER_ROLE, L2_DAI_GATEWAY_PROXY_ADDR); - - ScrollGatewayBase(payable(L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR)).updateRateLimiter(L2_TOKEN_RATE_LIMITER_ADDR); - ScrollGatewayBase(payable(L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR)).updateRateLimiter(L2_TOKEN_RATE_LIMITER_ADDR); - ScrollGatewayBase(payable(L2_DAI_GATEWAY_PROXY_ADDR)).updateRateLimiter(L2_TOKEN_RATE_LIMITER_ADDR); - - // @note comments out for now - // limiter.grantRole(TOKEN_SPENDER_ROLE, L2_USDC_GATEWAY_PROXY_ADDR); - // ScrollGatewayBase(payable(L2_USDC_GATEWAY_PROXY_ADDR)).updateRateLimiter(address(limiter)); - - vm.stopBroadcast(); - } -} diff --git a/contracts/src/L1/L1ScrollMessenger.sol b/contracts/src/L1/L1ScrollMessenger.sol index 92a58561a1..3f3907c17d 100644 --- a/contracts/src/L1/L1ScrollMessenger.sol +++ b/contracts/src/L1/L1ScrollMessenger.sol @@ -316,8 +316,6 @@ contract L1ScrollMessenger is ScrollMessengerBase, IL1ScrollMessenger { uint256 _gasLimit, address _refundAddress ) internal nonReentrant { - _addUsedAmount(_value); - address _messageQueue = messageQueue; // gas saving address _counterpart = counterpart; // gas saving diff --git a/contracts/src/L1/gateways/L1ERC20Gateway.sol b/contracts/src/L1/gateways/L1ERC20Gateway.sol index 4f1f9727ca..d50a0fc863 100644 --- a/contracts/src/L1/gateways/L1ERC20Gateway.sol +++ b/contracts/src/L1/gateways/L1ERC20Gateway.sol @@ -161,9 +161,6 @@ abstract contract L1ERC20Gateway is IL1ERC20Gateway, IMessageDropCallback, Scrol // ignore weird fee on transfer token require(_amount > 0, "deposit zero amount"); - // rate limit - _addUsedAmount(_token, _amount); - return (_from, _amount, _data); } diff --git a/contracts/src/L2/L2ScrollMessenger.sol b/contracts/src/L2/L2ScrollMessenger.sol index 5e3e66c611..fbf2788b68 100644 --- a/contracts/src/L2/L2ScrollMessenger.sol +++ b/contracts/src/L2/L2ScrollMessenger.sol @@ -117,7 +117,6 @@ contract L2ScrollMessenger is ScrollMessengerBase, IL2ScrollMessenger { uint256 _gasLimit ) internal nonReentrant { require(msg.value == _value, "msg.value mismatch"); - _addUsedAmount(_value); uint256 _nonce = L2MessageQueue(messageQueue).nextMessageIndex(); bytes32 _xDomainCalldataHash = keccak256(_encodeXDomainCalldata(_msgSender(), _to, _value, _nonce, _message)); diff --git a/contracts/src/L2/gateways/L2CustomERC20Gateway.sol b/contracts/src/L2/gateways/L2CustomERC20Gateway.sol index d6e65824e8..6c9d9e6958 100644 --- a/contracts/src/L2/gateways/L2CustomERC20Gateway.sol +++ b/contracts/src/L2/gateways/L2CustomERC20Gateway.sol @@ -126,9 +126,6 @@ contract L2CustomERC20Gateway is L2ERC20Gateway { (_from, _data) = abi.decode(_data, (address, bytes)); } - // rate limit - _addUsedAmount(_token, _amount); - // 2. Burn token. IScrollERC20Upgradeable(_token).burn(_from, _amount); diff --git a/contracts/src/L2/gateways/L2StandardERC20Gateway.sol b/contracts/src/L2/gateways/L2StandardERC20Gateway.sol index bb108df1c8..2808d34eb4 100644 --- a/contracts/src/L2/gateways/L2StandardERC20Gateway.sol +++ b/contracts/src/L2/gateways/L2StandardERC20Gateway.sol @@ -140,9 +140,6 @@ contract L2StandardERC20Gateway is L2ERC20Gateway { address _l1Token = tokenMapping[_token]; require(_l1Token != address(0), "no corresponding l1 token"); - // rate limit - _addUsedAmount(_token, _amount); - // 2. Burn token. IScrollERC20Upgradeable(_token).burn(_from, _amount); diff --git a/contracts/src/L2/gateways/L2WETHGateway.sol b/contracts/src/L2/gateways/L2WETHGateway.sol index 6a499a7309..4562faa70d 100644 --- a/contracts/src/L2/gateways/L2WETHGateway.sol +++ b/contracts/src/L2/gateways/L2WETHGateway.sol @@ -116,9 +116,6 @@ contract L2WETHGateway is L2ERC20Gateway { (_from, _data) = abi.decode(_data, (address, bytes)); } - // rate limit - _addUsedAmount(_token, _amount); - // 2. Transfer token into this contract. IERC20Upgradeable(_token).safeTransferFrom(_from, address(this), _amount); IWETH(_token).withdraw(_amount); diff --git a/contracts/src/L2/gateways/usdc/L2USDCGateway.sol b/contracts/src/L2/gateways/usdc/L2USDCGateway.sol index 6cea821cec..1e499226a3 100644 --- a/contracts/src/L2/gateways/usdc/L2USDCGateway.sol +++ b/contracts/src/L2/gateways/usdc/L2USDCGateway.sol @@ -162,9 +162,6 @@ contract L2USDCGateway is L2ERC20Gateway, IUSDCDestinationBridge { } require(_data.length == 0, "call is not allowed"); - // rate limit - _addUsedAmount(_token, _amount); - // 2. Transfer token into this contract. IERC20Upgradeable(_token).safeTransferFrom(_from, address(this), _amount); IFiatToken(_token).burn(_amount); diff --git a/contracts/src/libraries/ScrollMessengerBase.sol b/contracts/src/libraries/ScrollMessengerBase.sol index b6c1fe6ce2..5bf5ee58f2 100644 --- a/contracts/src/libraries/ScrollMessengerBase.sol +++ b/contracts/src/libraries/ScrollMessengerBase.sol @@ -7,7 +7,6 @@ import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import {ScrollConstants} from "./constants/ScrollConstants.sol"; -import {IETHRateLimiter} from "../rate-limiter/IETHRateLimiter.sol"; import {IScrollMessenger} from "./IScrollMessenger.sol"; // solhint-disable var-name-mixedcase @@ -27,11 +26,6 @@ abstract contract ScrollMessengerBase is /// @param _newFeeVault The address of new fee vault contract. event UpdateFeeVault(address _oldFeeVault, address _newFeeVault); - /// @notice Emitted when owner updates rate limiter contract. - /// @param _oldRateLimiter The address of old rate limiter contract. - /// @param _newRateLimiter The address of new rate limiter contract. - event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter); - /************* * Variables * *************/ @@ -45,8 +39,8 @@ abstract contract ScrollMessengerBase is /// @notice The address of fee vault, collecting cross domain messaging fee. address public feeVault; - /// @notice The address of ETH rate limiter contract. - address public rateLimiter; + /// @dev The storage slot used as ETH rate limiter contract, which is deprecated now. + address private __rateLimiter; /// @dev The storage slots for future usage. uint256[46] private __gap; @@ -98,16 +92,6 @@ abstract contract ScrollMessengerBase is emit UpdateFeeVault(_oldFeeVault, _newFeeVault); } - /// @notice Update rate limiter contract. - /// @dev This function can only called by contract owner. - /// @param _newRateLimiter The address of new rate limiter contract. - function updateRateLimiter(address _newRateLimiter) external onlyOwner { - address _oldRateLimiter = rateLimiter; - - rateLimiter = _newRateLimiter; - emit UpdateRateLimiter(_oldRateLimiter, _newRateLimiter); - } - /// @notice Pause the contract /// @dev This function can only called by contract owner. /// @param _status The pause status to update. @@ -148,26 +132,11 @@ abstract contract ScrollMessengerBase is ); } - /// @dev Internal function to increase ETH usage for the given `_sender`. - /// @param _amount The amount of ETH used. - function _addUsedAmount(uint256 _amount) internal { - if (_amount == 0) return; - - address _rateLimiter = rateLimiter; - if (_rateLimiter != address(0)) { - IETHRateLimiter(_rateLimiter).addUsedAmount(_amount); - } - } - /// @dev Internal function to check whether the `_target` address is allowed to avoid attack. /// @param _target The address of target address to check. function _validateTargetAddress(address _target) internal view { // @note check more `_target` address to avoid attack in the future when we add more external contracts. - address _rateLimiter = rateLimiter; - if (_rateLimiter != address(0)) { - require(_target != _rateLimiter, "Forbid to call rate limiter"); - } require(_target != address(this), "Forbid to call self"); } } diff --git a/contracts/src/libraries/gateway/ScrollGatewayBase.sol b/contracts/src/libraries/gateway/ScrollGatewayBase.sol index 3190ea5c4b..8b02c35d61 100644 --- a/contracts/src/libraries/gateway/ScrollGatewayBase.sol +++ b/contracts/src/libraries/gateway/ScrollGatewayBase.sol @@ -14,15 +14,6 @@ import {ITokenRateLimiter} from "../../rate-limiter/ITokenRateLimiter.sol"; /// @title ScrollGatewayBase /// @notice The `ScrollGatewayBase` is a base contract for gateway contracts used in both in L1 and L2. abstract contract ScrollGatewayBase is ReentrancyGuardUpgradeable, OwnableUpgradeable, IScrollGateway { - /********** - * Events * - **********/ - - /// @notice Emitted when owner updates rate limiter contract. - /// @param _oldRateLimiter The address of old rate limiter contract. - /// @param _newRateLimiter The address of new rate limiter contract. - event UpdateRateLimiter(address indexed _oldRateLimiter, address indexed _newRateLimiter); - /************* * Variables * *************/ @@ -36,8 +27,8 @@ abstract contract ScrollGatewayBase is ReentrancyGuardUpgradeable, OwnableUpgrad /// @inheritdoc IScrollGateway address public override messenger; - /// @notice The address of token rate limiter contract. - address public rateLimiter; + /// @dev The storage slot used as token rate limiter contract, which is deprecated now. + address private __rateLimiter; /// @dev The storage slots for future usage. uint256[46] private __gap; @@ -87,20 +78,6 @@ abstract contract ScrollGatewayBase is ReentrancyGuardUpgradeable, OwnableUpgrad } } - /************************ - * Restricted Functions * - ************************/ - - /// @notice Update rate limiter contract. - /// @dev This function can only called by contract owner. - /// @param _newRateLimiter The address of new rate limiter contract. - function updateRateLimiter(address _newRateLimiter) external onlyOwner { - address _oldRateLimiter = rateLimiter; - - rateLimiter = _newRateLimiter; - emit UpdateRateLimiter(_oldRateLimiter, _newRateLimiter); - } - /********************** * Internal Functions * **********************/ @@ -113,16 +90,4 @@ abstract contract ScrollGatewayBase is ReentrancyGuardUpgradeable, OwnableUpgrad IScrollGatewayCallback(_to).onScrollGatewayCallback(_data); } } - - /// @dev Internal function to increase token usage for the given `_sender`. - /// @param _token The address of token. - /// @param _amount The amount of token used. - function _addUsedAmount(address _token, uint256 _amount) internal { - if (_amount == 0) return; - - address _rateLimiter = rateLimiter; - if (_rateLimiter != address(0)) { - ITokenRateLimiter(_rateLimiter).addUsedAmount(_token, _amount); - } - } } diff --git a/contracts/src/test/L1ScrollMessengerTest.t.sol b/contracts/src/test/L1ScrollMessengerTest.t.sol index 4664640650..5e1ce19b05 100644 --- a/contracts/src/test/L1ScrollMessengerTest.t.sol +++ b/contracts/src/test/L1ScrollMessengerTest.t.sol @@ -42,26 +42,6 @@ contract L1ScrollMessengerTest is L1GatewayTestBase { l1Messenger.relayMessageWithProof(address(this), address(messageQueue), 0, 0, new bytes(0), proof); } - function testForbidCallRateLimiterFromL2() external { - l1Messenger.updateRateLimiter(address(1)); - bytes32 _xDomainCalldataHash = keccak256( - abi.encodeWithSignature( - "relayMessage(address,address,uint256,uint256,bytes)", - address(this), - address(1), - 0, - 0, - new bytes(0) - ) - ); - prepareL2MessageRoot(_xDomainCalldataHash); - IL1ScrollMessenger.L2MessageProof memory proof; - proof.batchIndex = rollup.lastFinalizedBatchIndex(); - - hevm.expectRevert("Forbid to call rate limiter"); - l1Messenger.relayMessageWithProof(address(this), address(1), 0, 0, new bytes(0), proof); - } - function testForbidCallSelfFromL2() external { bytes32 _xDomainCalldataHash = keccak256( abi.encodeWithSignature( diff --git a/contracts/src/test/L2ScrollMessenger.t.sol b/contracts/src/test/L2ScrollMessenger.t.sol index 86d47325d0..9726e73bf1 100644 --- a/contracts/src/test/L2ScrollMessenger.t.sol +++ b/contracts/src/test/L2ScrollMessenger.t.sol @@ -51,15 +51,10 @@ contract L2ScrollMessengerTest is DSTestPlus { } function testForbidCallFromL1() external { - l2Messenger.updateRateLimiter(address(1)); - hevm.startPrank(AddressAliasHelper.applyL1ToL2Alias(address(l1Messenger))); hevm.expectRevert("Forbid to call message queue"); l2Messenger.relayMessage(address(this), address(l2MessageQueue), 0, 0, new bytes(0)); - hevm.expectRevert("Forbid to call rate limiter"); - l2Messenger.relayMessage(address(this), address(1), 0, 0, new bytes(0)); - hevm.expectRevert("Forbid to call self"); l2Messenger.relayMessage(address(this), address(l2Messenger), 0, 0, new bytes(0)); hevm.stopPrank();