From 0a8dbb8da163bab1fd9a92ba006c6ae373148fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Pernas=20Maradei?= Date: Mon, 19 Feb 2024 15:05:46 -0300 Subject: [PATCH] comment out close channel support --- contracts/core/Dispatcher.sol | 41 ++++++++++++------------ test/Dispatcher.t.sol | 59 ++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/contracts/core/Dispatcher.sol b/contracts/core/Dispatcher.sol index 3b06706e..b7b26064 100644 --- a/contracts/core/Dispatcher.sol +++ b/contracts/core/Dispatcher.sol @@ -296,26 +296,27 @@ contract Dispatcher is IbcDispatcher, IbcEventsEmitter, Ownable, Ibc { * The dApp's onCloseIbcChannel callback is invoked. * dApp should throw an error if the channel should not be closed. */ - function onCloseIbcChannel(address portAddress, bytes32 channelId, Ics23Proof calldata proof) external { - // verify VIBC/IBC hub chain has processed ChanCloseConfirm event - consensusStateManager.verifyMembership( - proof, - bytes('channel/path/to/be/added/here'), - bytes('expected channel bytes constructed from params. Channel.State = {Closed(_Pending?)}') - ); - - // ensure port owns channel - Channel memory channel = portChannelMap[portAddress][channelId]; - if (channel.counterpartyChannelId == bytes32(0)) { - revert channelNotOwnedByPortAddress(); - } - - // confirm with dApp by calling its callback - IbcChannelReceiver reciever = IbcChannelReceiver(portAddress); - reciever.onCloseIbcChannel(channelId, channel.counterpartyPortId, channel.counterpartyChannelId); - delete portChannelMap[portAddress][channelId]; - emit CloseIbcChannel(portAddress, channelId); - } + // FIXME this is commented out to make the contract size smaller. We need to optimise for size + // function onCloseIbcChannel(address portAddress, bytes32 channelId, Ics23Proof calldata proof) external { + // // verify VIBC/IBC hub chain has processed ChanCloseConfirm event + // consensusStateManager.verifyMembership( + // proof, + // bytes('channel/path/to/be/added/here'), + // bytes('expected channel bytes constructed from params. Channel.State = {Closed(_Pending?)}') + // ); + // + // // ensure port owns channel + // Channel memory channel = portChannelMap[portAddress][channelId]; + // if (channel.counterpartyChannelId == bytes32(0)) { + // revert channelNotOwnedByPortAddress(); + // } + // + // // confirm with dApp by calling its callback + // IbcChannelReceiver reciever = IbcChannelReceiver(portAddress); + // reciever.onCloseIbcChannel(channelId, channel.counterpartyPortId, channel.counterpartyChannelId); + // delete portChannelMap[portAddress][channelId]; + // emit CloseIbcChannel(portAddress, channelId); + // } // // IBC Packet methods diff --git a/test/Dispatcher.t.sol b/test/Dispatcher.t.sol index 370a83d2..a8f4b6eb 100644 --- a/test/Dispatcher.t.sol +++ b/test/Dispatcher.t.sol @@ -219,35 +219,36 @@ contract ChannelOpenTestBase is Base { } } -contract DispatcherCloseChannelTest is ChannelOpenTestBase { - function test_closeChannelInit_success() public { - vm.expectEmit(true, true, true, true); - emit CloseIbcChannel(address(mars), channelId); - mars.triggerChannelClose(channelId); - } - - function test_closeChannelInit_mustOwner() public { - Mars earth = new Mars(dispatcher); - vm.expectRevert(abi.encodeWithSignature('channelNotOwnedBySender()')); - earth.triggerChannelClose(channelId); - } - - function test_closeChannelConfirm_success() public { - vm.expectEmit(true, true, true, true); - emit CloseIbcChannel(address(mars), channelId); - dispatcher.onCloseIbcChannel(address(mars), channelId, validProof); - } - - function test_closeChannelConfirm_mustOwner() public { - vm.expectRevert(abi.encodeWithSignature('channelNotOwnedByPortAddress()')); - dispatcher.onCloseIbcChannel(address(mars), 'channel-999', validProof); - } - - function test_closeChannelConfirm_invalidProof() public { - vm.expectRevert('Invalid dummy membership proof'); - dispatcher.onCloseIbcChannel(address(mars), channelId, invalidProof); - } -} +// FIXME this is commented out to make the contract size smaller. We need to optimise for size +// contract DispatcherCloseChannelTest is ChannelOpenTestBase { +// function test_closeChannelInit_success() public { +// vm.expectEmit(true, true, true, true); +// emit CloseIbcChannel(address(mars), channelId); +// mars.triggerChannelClose(channelId); +// } +// +// function test_closeChannelInit_mustOwner() public { +// Mars earth = new Mars(dispatcher); +// vm.expectRevert(abi.encodeWithSignature('channelNotOwnedBySender()')); +// earth.triggerChannelClose(channelId); +// } +// +// function test_closeChannelConfirm_success() public { +// vm.expectEmit(true, true, true, true); +// emit CloseIbcChannel(address(mars), channelId); +// dispatcher.onCloseIbcChannel(address(mars), channelId, validProof); +// } +// +// function test_closeChannelConfirm_mustOwner() public { +// vm.expectRevert(abi.encodeWithSignature('channelNotOwnedByPortAddress()')); +// dispatcher.onCloseIbcChannel(address(mars), 'channel-999', validProof); +// } +// +// function test_closeChannelConfirm_invalidProof() public { +// vm.expectRevert('Invalid dummy membership proof'); +// dispatcher.onCloseIbcChannel(address(mars), channelId, invalidProof); +// } +// } contract DispatcherSendPacketTest is ChannelOpenTestBase { // default params