From 022ff23242bdda9da14dc9d2b5d700f0862eb890 Mon Sep 17 00:00:00 2001 From: RnkSngh Date: Mon, 6 May 2024 17:13:44 -0400 Subject: [PATCH] add inline comment for why state modifications in channelClosing happen even on dapp revert --- contracts/core/Dispatcher.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/core/Dispatcher.sol b/contracts/core/Dispatcher.sol index 45bba497..525cb8e9 100644 --- a/contracts/core/Dispatcher.sol +++ b/contracts/core/Dispatcher.sol @@ -383,8 +383,9 @@ contract Dispatcher is OwnableUpgradeable, UUPSUpgradeable, ReentrancyGuard, IDi ) ); + // Note: We delete the portChannelMap here even on Dapp revert to avoid having a case where a dapp deployed with + // a faulty callback cannot close a channel (as is done on channelCloseConfirm) delete _portChannelMap[msg.sender][channelId]; - if (success) { emit ChannelCloseInit(msg.sender, channelId); } else { @@ -440,6 +441,8 @@ contract Dispatcher is OwnableUpgradeable, UUPSUpgradeable, ReentrancyGuard, IDi ) ); + // Note: We delete the portChannelMap here even on Dapp revert to avoid having a case where a dapp deployed with + // a faulty callback cannot close a channel (as is done on channelCloseInit) delete _portChannelMap[portAddress][channelId]; if (success) { emit ChannelCloseConfirm(portAddress, channelId);