Skip to content

Commit

Permalink
disable callOnRevert in GatewayEVM call
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Oct 21, 2024
1 parent d40d2e2 commit 48de3a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions v2/contracts/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pragma solidity 0.8.26;
/// @notice Interface for contracts that with non supported methods.
interface INotSupportedMethods {
error ZETANotSupported();
error CallOnRevertNotSupported();
}
1 change: 1 addition & 0 deletions v2/contracts/evm/GatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ contract GatewayEVM is
whenNotPaused
nonReentrant
{
if (revertOptions.callOnRevert) revert CallOnRevertNotSupported();
if (receiver == address(0)) revert ZeroAddress();
if (payload.length + revertOptions.revertMessage.length > MAX_PAYLOAD_SIZE) revert PayloadSizeExceeded();

Expand Down
14 changes: 10 additions & 4 deletions v2/test/GatewayEVM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ contract GatewayEVMTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiver
}
}

contract GatewayEVMInboundTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiverEVMEvents {
contract GatewayEVMInboundTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiverEVMEvents, INotSupportedMethods {
using SafeERC20 for IERC20;

address proxy;
Expand All @@ -414,8 +414,6 @@ contract GatewayEVMInboundTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IR

uint256 ownerAmount = 1_000_000;

error ZETANotSupported();

function setUp() public {
owner = address(this);
destination = address(0x1234);
Expand Down Expand Up @@ -456,7 +454,7 @@ contract GatewayEVMInboundTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IR

revertOptions = RevertOptions({
revertAddress: address(0x321),
callOnRevert: true,
callOnRevert: false,
abortAddress: address(0x321),
revertMessage: "",
onRevertGasLimit: 0
Expand Down Expand Up @@ -680,6 +678,14 @@ contract GatewayEVMInboundTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IR
gateway.call(destination, payload, revertOptions);
}

function testCallWithPayloadFailsIfCallOnRevertIsTrue() public {
bytes memory payload = abi.encodeWithSignature("hello(address)", destination);
revertOptions.callOnRevert = true;

vm.expectRevert(CallOnRevertNotSupported.selector);
gateway.call(destination, payload, revertOptions);
}

function testCallWithPayloadFailsIfDestinationIsZeroAddress() public {
bytes memory payload = abi.encodeWithSignature("hello(address)", destination);

Expand Down

0 comments on commit 48de3a7

Please sign in to comment.