From 48de3a7a6a560da8ec417466e44beb4f4f1f53fb Mon Sep 17 00:00:00 2001 From: skosito Date: Mon, 21 Oct 2024 15:21:20 +0200 Subject: [PATCH] disable callOnRevert in GatewayEVM call --- v2/contracts/Errors.sol | 1 + v2/contracts/evm/GatewayEVM.sol | 1 + v2/test/GatewayEVM.t.sol | 14 ++++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/v2/contracts/Errors.sol b/v2/contracts/Errors.sol index 27b150f7..1a957de5 100644 --- a/v2/contracts/Errors.sol +++ b/v2/contracts/Errors.sol @@ -5,4 +5,5 @@ pragma solidity 0.8.26; /// @notice Interface for contracts that with non supported methods. interface INotSupportedMethods { error ZETANotSupported(); + error CallOnRevertNotSupported(); } diff --git a/v2/contracts/evm/GatewayEVM.sol b/v2/contracts/evm/GatewayEVM.sol index 416695f1..980a0343 100644 --- a/v2/contracts/evm/GatewayEVM.sol +++ b/v2/contracts/evm/GatewayEVM.sol @@ -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(); diff --git a/v2/test/GatewayEVM.t.sol b/v2/test/GatewayEVM.t.sol index 33d24d24..75cbc6bd 100644 --- a/v2/test/GatewayEVM.t.sol +++ b/v2/test/GatewayEVM.t.sol @@ -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; @@ -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); @@ -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 @@ -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);