-
Notifications
You must be signed in to change notification settings - Fork 59
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
Changes from all commits
acd0c41
17d9590
905691f
4df01e3
39e72fe
36c6a2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -110,9 +110,9 @@ contract GatewayEVM is | |||||
) | ||||||
public | ||||||
payable | ||||||
nonReentrant | ||||||
onlyRole(TSS_ROLE) | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
{ | ||||||
if (destination == address(0)) revert ZeroAddress(); | ||||||
(bool success,) = destination.call{ value: msg.value }(""); | ||||||
|
@@ -135,9 +135,9 @@ contract GatewayEVM is | |||||
) | ||||||
external | ||||||
payable | ||||||
nonReentrant | ||||||
onlyRole(TSS_ROLE) | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
returns (bytes memory) | ||||||
{ | ||||||
if (destination == address(0)) revert ZeroAddress(); | ||||||
|
@@ -172,9 +172,9 @@ contract GatewayEVM is | |||||
bytes calldata data | ||||||
) | ||||||
public | ||||||
nonReentrant | ||||||
onlyRole(ASSET_HANDLER_ROLE) | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
{ | ||||||
if (amount == 0) revert InsufficientERC20Amount(); | ||||||
if (to == address(0)) revert ZeroAddress(); | ||||||
|
@@ -217,9 +217,9 @@ contract GatewayEVM is | |||||
RevertContext calldata revertContext | ||||||
) | ||||||
external | ||||||
nonReentrant | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unnecessary nonReentrant modifier The function revertWithERC20(
address token,
address to,
uint256 amount,
bytes calldata data,
RevertContext calldata revertContext
)
external
- nonReentrant
onlyRole(ASSET_HANDLER_ROLE)
whenNotPaused 📝 Committable suggestion
Suggested change
|
||||||
onlyRole(ASSET_HANDLER_ROLE) | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
{ | ||||||
if (amount == 0) revert InsufficientERC20Amount(); | ||||||
if (to == address(0)) revert ZeroAddress(); | ||||||
|
@@ -233,15 +233,7 @@ contract GatewayEVM is | |||||
/// @notice Deposits ETH to the TSS address. | ||||||
/// @param receiver Address of the receiver. | ||||||
/// @param revertOptions Revert options. | ||||||
function deposit( | ||||||
address receiver, | ||||||
RevertOptions calldata revertOptions | ||||||
) | ||||||
external | ||||||
payable | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
{ | ||||||
function deposit(address receiver, RevertOptions calldata revertOptions) external payable whenNotPaused { | ||||||
if (msg.value == 0) revert InsufficientETHAmount(); | ||||||
if (receiver == address(0)) revert ZeroAddress(); | ||||||
if (revertOptions.revertMessage.length > MAX_PAYLOAD_SIZE) revert PayloadSizeExceeded(); | ||||||
|
@@ -266,7 +258,6 @@ contract GatewayEVM is | |||||
) | ||||||
external | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
{ | ||||||
if (amount == 0) revert InsufficientERC20Amount(); | ||||||
if (receiver == address(0)) revert ZeroAddress(); | ||||||
|
@@ -289,7 +280,6 @@ contract GatewayEVM is | |||||
external | ||||||
payable | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
{ | ||||||
if (msg.value == 0) revert InsufficientETHAmount(); | ||||||
if (receiver == address(0)) revert ZeroAddress(); | ||||||
|
@@ -317,7 +307,6 @@ contract GatewayEVM is | |||||
) | ||||||
external | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
{ | ||||||
if (amount == 0) revert InsufficientERC20Amount(); | ||||||
if (receiver == address(0)) revert ZeroAddress(); | ||||||
|
@@ -339,7 +328,6 @@ contract GatewayEVM is | |||||
) | ||||||
external | ||||||
whenNotPaused | ||||||
nonReentrant | ||||||
{ | ||||||
if (receiver == address(0)) revert ZeroAddress(); | ||||||
if (payload.length + revertOptions.revertMessage.length > MAX_PAYLOAD_SIZE) revert PayloadSizeExceeded(); | ||||||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary nonReentrant modifier
The
executeRevert
function only interacts with contracts implementing theRevertable
interface and doesn't make arbitrary external calls. ThenonReentrant
modifier is not necessary here as the function enforces a specific interface.function executeRevert( address destination, bytes calldata data, RevertContext calldata revertContext ) public payable - nonReentrant onlyRole(TSS_ROLE) whenNotPaused
📝 Committable suggestion