From 4df01e35e0575dd684a867d7b04f5b4788761b1e Mon Sep 17 00:00:00 2001 From: skosito Date: Mon, 21 Oct 2024 10:56:59 +0200 Subject: [PATCH] fix nonReentrant modifier usage --- v2/contracts/evm/GatewayEVM.sol | 7 ++----- v2/contracts/zevm/GatewayZEVM.sol | 11 +++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/v2/contracts/evm/GatewayEVM.sol b/v2/contracts/evm/GatewayEVM.sol index 68e4d709..71dfe87a 100644 --- a/v2/contracts/evm/GatewayEVM.sol +++ b/v2/contracts/evm/GatewayEVM.sol @@ -137,6 +137,7 @@ contract GatewayEVM is payable onlyRole(TSS_ROLE) whenNotPaused + nonReentrant returns (bytes memory) { if (destination == address(0)) revert ZeroAddress(); @@ -173,6 +174,7 @@ contract GatewayEVM is public onlyRole(ASSET_HANDLER_ROLE) whenNotPaused + nonReentrant { if (amount == 0) revert InsufficientERC20Amount(); if (to == address(0)) revert ZeroAddress(); @@ -238,7 +240,6 @@ contract GatewayEVM is external payable whenNotPaused - nonReentrant { if (msg.value == 0) revert InsufficientETHAmount(); if (receiver == address(0)) revert ZeroAddress(); @@ -264,7 +265,6 @@ contract GatewayEVM is ) external whenNotPaused - nonReentrant { if (amount == 0) revert InsufficientERC20Amount(); if (receiver == address(0)) revert ZeroAddress(); @@ -287,7 +287,6 @@ contract GatewayEVM is external payable whenNotPaused - nonReentrant { if (msg.value == 0) revert InsufficientETHAmount(); if (receiver == address(0)) revert ZeroAddress(); @@ -315,7 +314,6 @@ contract GatewayEVM is ) external whenNotPaused - nonReentrant { if (amount == 0) revert InsufficientERC20Amount(); if (receiver == address(0)) revert ZeroAddress(); @@ -337,7 +335,6 @@ contract GatewayEVM is ) external whenNotPaused - nonReentrant { if (receiver == address(0)) revert ZeroAddress(); if (payload.length + revertOptions.revertMessage.length > MAX_PAYLOAD_SIZE) revert PayloadSizeExceeded(); diff --git a/v2/contracts/zevm/GatewayZEVM.sol b/v2/contracts/zevm/GatewayZEVM.sol index 7c91072d..7b512007 100644 --- a/v2/contracts/zevm/GatewayZEVM.sol +++ b/v2/contracts/zevm/GatewayZEVM.sol @@ -140,7 +140,6 @@ contract GatewayZEVM is RevertOptions calldata revertOptions ) external - nonReentrant whenNotPaused { if (receiver.length == 0) revert ZeroAddress(); @@ -178,7 +177,6 @@ contract GatewayZEVM is RevertOptions calldata revertOptions ) external - nonReentrant whenNotPaused { if (receiver.length == 0) revert ZeroAddress(); @@ -212,7 +210,6 @@ contract GatewayZEVM is RevertOptions calldata /*revertOptions*/ ) external - nonReentrant whenNotPaused { // TODO: remove error and comment out code once ZETA supported back @@ -255,7 +252,6 @@ contract GatewayZEVM is RevertOptions calldata /*revertOptions*/ ) external - nonReentrant whenNotPaused { // TODO: remove error and comment out code once ZETA supported back @@ -288,7 +284,6 @@ contract GatewayZEVM is RevertOptions calldata revertOptions ) external - nonReentrant whenNotPaused { if (callOptions.gasLimit == 0) revert InsufficientGasLimit(); @@ -345,6 +340,7 @@ contract GatewayZEVM is external onlyProtocol whenNotPaused + nonReentrant { if (zrc20 == address(0) || target == address(0)) revert ZeroAddress(); @@ -367,6 +363,7 @@ contract GatewayZEVM is external onlyProtocol whenNotPaused + nonReentrant { if (zrc20 == address(0) || target == address(0)) revert ZeroAddress(); if (amount == 0) revert InsufficientZRC20Amount(); @@ -390,6 +387,7 @@ contract GatewayZEVM is external onlyProtocol whenNotPaused + nonReentrant { if (target == address(0)) revert ZeroAddress(); if (amount == 0) revert InsufficientZetaAmount(); @@ -402,7 +400,7 @@ contract GatewayZEVM is /// @notice Revert a user-specified contract on ZEVM. /// @param target The target contract to call. /// @param revertContext Revert context to pass to onRevert. - function executeRevert(address target, RevertContext calldata revertContext) external onlyProtocol whenNotPaused { + function executeRevert(address target, RevertContext calldata revertContext) external onlyProtocol whenNotPaused nonReentrant { if (target == address(0)) revert ZeroAddress(); Revertable(target).onRevert(revertContext); @@ -422,6 +420,7 @@ contract GatewayZEVM is external onlyProtocol whenNotPaused + nonReentrant { if (zrc20 == address(0) || target == address(0)) revert ZeroAddress(); if (amount == 0) revert InsufficientZRC20Amount();