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

fix: use nonReentrant only on functions interacting with arbitrary contracts #395

Merged
merged 6 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions v2/contracts/evm/GatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ contract GatewayEVM is
external
payable
whenNotPaused
nonReentrant
{
if (msg.value == 0) revert InsufficientETHAmount();
if (receiver == address(0)) revert ZeroAddress();
Expand All @@ -266,7 +265,6 @@ contract GatewayEVM is
)
external
whenNotPaused
nonReentrant
{
if (amount == 0) revert InsufficientERC20Amount();
if (receiver == address(0)) revert ZeroAddress();
Expand All @@ -289,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 @@ -317,7 +314,6 @@ contract GatewayEVM is
)
external
whenNotPaused
nonReentrant
{
if (amount == 0) revert InsufficientERC20Amount();
if (receiver == address(0)) revert ZeroAddress();
Expand All @@ -339,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
Loading