-
Notifications
You must be signed in to change notification settings - Fork 26
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
Reduce contract size to ensure the contract is deployable #44
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
Comment on lines
296
to
322
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The contract uses SPDX license identifier Consider specifying a more specific license if the code is intended for open-source distribution, to clearly communicate usage rights and restrictions.
The contract specifies Solidity version Consider using a fixed version or a narrower version range for Solidity to ensure consistent contract behavior. - pragma solidity ^0.8.9;
+ pragma solidity 0.8.9; |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
onCloseIbcChannel
function has been commented out to reduce the contract size, which is a critical step towards ensuring the contract's deployability. However, this change impacts the contract's ability to handle channel closure events. It's important to consider the implications of this removal on the overall system functionality and whether alternative optimizations could achieve size reduction without sacrificing important features.Consider optimizing contract size through other methods such as code refactoring, using libraries, or splitting the contract into smaller contracts to preserve important functionalities like channel closure handling.