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: disable callOnRevert in GatewayEVM call #407

Merged
merged 5 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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 @@ -329,6 +329,7 @@ contract GatewayEVM is
external
whenNotPaused
{
if (revertOptions.callOnRevert) revert CallOnRevertNotSupported();
if (receiver == address(0)) revert ZeroAddress();
if (payload.length + revertOptions.revertMessage.length > MAX_PAYLOAD_SIZE) revert PayloadSizeExceeded();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ Interface for contracts that with non supported methods.
error ZETANotSupported();
```

### CallOnRevertNotSupported

```solidity
error CallOnRevertNotSupported();
```

2 changes: 1 addition & 1 deletion v2/pkg/erc20custody.t.sol/erc20custodytest.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/errors.sol/inotsupportedmethods.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions v2/pkg/gatewayevm.sol/gatewayevm.go

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions v2/pkg/gatewayevm.t.sol/gatewayevminboundtest.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/gatewayevm.t.sol/gatewayevmtest.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions v2/pkg/gatewayevmupgradetest.sol/gatewayevmupgradetest.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions v2/pkg/gatewayzevm.sol/gatewayzevm.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/gatewayzevm.t.sol/gatewayzevminboundtest.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/gatewayzevm.t.sol/gatewayzevmoutboundtest.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion v2/pkg/zrc20.t.sol/zrc20test.go

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions v2/test/GatewayEVM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,13 @@ 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 +420,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 +460,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 +684,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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import type {
} from "../../Errors.sol/INotSupportedMethods";

const _abi = [
{
type: "error",
name: "CallOnRevertNotSupported",
inputs: [],
},
{
type: "error",
name: "ZETANotSupported",
Expand Down
7 changes: 6 additions & 1 deletion v2/types/factories/GatewayEVMUpgradeTest__factory.ts

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion v2/types/factories/GatewayEVM__factory.ts

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion v2/types/factories/GatewayZEVM__factory.ts

Large diffs are not rendered by default.

Loading