Skip to content

Commit

Permalink
fix nonReentrant modifier usage
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Oct 21, 2024
1 parent 905691f commit 4df01e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
7 changes: 2 additions & 5 deletions v2/contracts/evm/GatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ contract GatewayEVM is
payable
onlyRole(TSS_ROLE)
whenNotPaused
nonReentrant
returns (bytes memory)
{
if (destination == address(0)) revert ZeroAddress();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -238,7 +240,6 @@ contract GatewayEVM is
external
payable
whenNotPaused
nonReentrant
{
if (msg.value == 0) revert InsufficientETHAmount();
if (receiver == address(0)) revert ZeroAddress();
Expand All @@ -264,7 +265,6 @@ contract GatewayEVM is
)
external
whenNotPaused
nonReentrant
{
if (amount == 0) revert InsufficientERC20Amount();
if (receiver == address(0)) revert ZeroAddress();
Expand All @@ -287,7 +287,6 @@ contract GatewayEVM is
external
payable
whenNotPaused
nonReentrant
{
if (msg.value == 0) revert InsufficientETHAmount();
if (receiver == address(0)) revert ZeroAddress();
Expand Down Expand Up @@ -315,7 +314,6 @@ contract GatewayEVM is
)
external
whenNotPaused
nonReentrant
{
if (amount == 0) revert InsufficientERC20Amount();
if (receiver == address(0)) revert ZeroAddress();
Expand All @@ -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();
Expand Down
11 changes: 5 additions & 6 deletions v2/contracts/zevm/GatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ contract GatewayZEVM is
RevertOptions calldata revertOptions
)
external
nonReentrant
whenNotPaused
{
if (receiver.length == 0) revert ZeroAddress();
Expand Down Expand Up @@ -178,7 +177,6 @@ contract GatewayZEVM is
RevertOptions calldata revertOptions
)
external
nonReentrant
whenNotPaused
{
if (receiver.length == 0) revert ZeroAddress();
Expand Down Expand Up @@ -212,7 +210,6 @@ contract GatewayZEVM is
RevertOptions calldata /*revertOptions*/
)
external
nonReentrant
whenNotPaused
{
// TODO: remove error and comment out code once ZETA supported back
Expand Down Expand Up @@ -255,7 +252,6 @@ contract GatewayZEVM is
RevertOptions calldata /*revertOptions*/
)
external
nonReentrant
whenNotPaused
{
// TODO: remove error and comment out code once ZETA supported back
Expand Down Expand Up @@ -288,7 +284,6 @@ contract GatewayZEVM is
RevertOptions calldata revertOptions
)
external
nonReentrant
whenNotPaused
{
if (callOptions.gasLimit == 0) revert InsufficientGasLimit();
Expand Down Expand Up @@ -345,6 +340,7 @@ contract GatewayZEVM is
external
onlyProtocol
whenNotPaused
nonReentrant
{
if (zrc20 == address(0) || target == address(0)) revert ZeroAddress();

Expand All @@ -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();
Expand All @@ -390,6 +387,7 @@ contract GatewayZEVM is
external
onlyProtocol
whenNotPaused
nonReentrant
{
if (target == address(0)) revert ZeroAddress();
if (amount == 0) revert InsufficientZetaAmount();
Expand All @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 4df01e3

Please sign in to comment.