Skip to content

Commit

Permalink
Merge pull request #292 from hyperledger-labs/fix-ibc-1127
Browse files Browse the repository at this point in the history
Fix cosmos/ibc#1127

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored Jul 30, 2024
2 parents 3189415 + e6a9796 commit 9b5036a
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 48 deletions.
51 changes: 26 additions & 25 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ IBCMockAppTest:testHandshakeBetweenDifferentPorts() (gas: 3339603)
IBCMockAppTest:testPacketRelay() (gas: 13935831)
IBCMockAppTest:testPacketTimeout() (gas: 4284259)
ICS24HostTest:testValidatePortIdentifier() (gas: 37060)
TestICS02:testCreateClient() (gas: 36638191)
TestICS02:testCreateClient() (gas: 36875161)
TestICS02:testHeightToUint128((uint64,uint64)) (runs: 256, μ: 887, ~: 887)
TestICS02:testInvalidCreateClient() (gas: 36535302)
TestICS02:testInvalidUpdateClient() (gas: 36534318)
TestICS02:testRegisterClient() (gas: 36189984)
TestICS02:testRegisterClientDuplicatedClientType() (gas: 36175293)
TestICS02:testRegisterClientInvalidClientType() (gas: 36204799)
TestICS02:testUpdateClient() (gas: 36702518)
TestICS02:testInvalidCreateClient() (gas: 36772272)
TestICS02:testInvalidUpdateClient() (gas: 36771288)
TestICS02:testRegisterClient() (gas: 36426954)
TestICS02:testRegisterClientDuplicatedClientType() (gas: 36412263)
TestICS02:testRegisterClientInvalidClientType() (gas: 36441769)
TestICS02:testUpdateClient() (gas: 36939488)
TestICS03Handshake:testConnOpenAck() (gas: 1858230)
TestICS03Handshake:testConnOpenConfirm() (gas: 2054143)
TestICS03Handshake:testConnOpenInit() (gas: 1429838)
Expand Down Expand Up @@ -48,24 +48,25 @@ TestICS04Packet:testRecvPacketTimeoutHeight() (gas: 3259769)
TestICS04Packet:testRecvPacketTimeoutTimestamp() (gas: 3284145)
TestICS04Packet:testSendPacket() (gas: 6411842)
TestICS04Packet:testTimeoutOnClose() (gas: 3553375)
TestICS04Upgrade:testUpgradeAuthorityCancel() (gas: 46734825)
TestICS04Upgrade:testUpgradeCannotCancelWithOldErrorReceipt() (gas: 3458838)
TestICS04Upgrade:testUpgradeCannotRecvNextUpgradePacket() (gas: 5258785)
TestICS04Upgrade:testUpgradeCounterpartyAdvanceNextSequenceBeforeOpen() (gas: 5229663)
TestICS04Upgrade:testUpgradeCrossingHelloIncompatibleProposals() (gas: 5068281)
TestICS04Upgrade:testUpgradeFull() (gas: 56577477)
TestICS04Upgrade:testUpgradeInit() (gas: 3074224)
TestICS04Upgrade:testUpgradeNoChanges() (gas: 2473090)
TestICS04Upgrade:testUpgradeNotUpgradableModule() (gas: 3648626)
TestICS04Upgrade:testUpgradeOutOfSync() (gas: 3905908)
TestICS04Upgrade:testUpgradeRelaySuccessAtCounterpartyFlushComplete() (gas: 5230550)
TestICS04Upgrade:testUpgradeRelaySuccessAtFlushing() (gas: 5603759)
TestICS04Upgrade:testUpgradeSendPacketFailAtFlushingOrFlushComplete() (gas: 4072103)
TestICS04Upgrade:testUpgradeTimeoutAbortAck() (gas: 17708385)
TestICS04Upgrade:testUpgradeTimeoutAbortConfirm() (gas: 21315818)
TestICS04Upgrade:testUpgradeTimeoutUpgrade() (gas: 70972587)
TestICS04Upgrade:testUpgradeToOrdered() (gas: 56491951)
TestICS04Upgrade:testUpgradeToUnordered() (gas: 45100181)
TestICS04Upgrade:testCrossingHelloInconsistentVersions() (gas: 10152794)
TestICS04Upgrade:testUpgradeAuthorityCancel() (gas: 47011316)
TestICS04Upgrade:testUpgradeCannotCancelWithOldErrorReceipt() (gas: 3460218)
TestICS04Upgrade:testUpgradeCannotRecvNextUpgradePacket() (gas: 5325143)
TestICS04Upgrade:testUpgradeCounterpartyAdvanceNextSequenceBeforeOpen() (gas: 5295126)
TestICS04Upgrade:testUpgradeCrossingHelloIncompatibleProposals() (gas: 5070497)
TestICS04Upgrade:testUpgradeFull() (gas: 57118740)
TestICS04Upgrade:testUpgradeInit() (gas: 3075843)
TestICS04Upgrade:testUpgradeNoChanges() (gas: 2473554)
TestICS04Upgrade:testUpgradeNotUpgradableModule() (gas: 3649002)
TestICS04Upgrade:testUpgradeOutOfSync() (gas: 3909083)
TestICS04Upgrade:testUpgradeRelaySuccessAtCounterpartyFlushComplete() (gas: 5296851)
TestICS04Upgrade:testUpgradeRelaySuccessAtFlushing() (gas: 5670614)
TestICS04Upgrade:testUpgradeSendPacketFailAtFlushingOrFlushComplete() (gas: 4089431)
TestICS04Upgrade:testUpgradeTimeoutAbortAck() (gas: 17829083)
TestICS04Upgrade:testUpgradeTimeoutAbortConfirm() (gas: 21547969)
TestICS04Upgrade:testUpgradeTimeoutUpgrade() (gas: 71726806)
TestICS04Upgrade:testUpgradeToOrdered() (gas: 56982472)
TestICS04Upgrade:testUpgradeToUnordered() (gas: 45498427)
TestICS04UpgradeApp:testUpgradeAuthorizationChanneNotFound() (gas: 61690)
TestICS04UpgradeApp:testUpgradeAuthorizationRePropose() (gas: 2565379)
TestICS04UpgradeApp:testUpgradeAuthorizationRemove() (gas: 2475938)
Expand Down
9 changes: 9 additions & 0 deletions contracts/core/04-channel/IBCChannelUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,15 @@ contract IBCChannelUpgradeConfirmOpenTimeoutCancel is
msg_.proofs
);

Upgrade.Data storage existingUpgrade = upgrades[msg_.portId][msg_.channelId];
if (existingUpgrade.fields.ordering == Channel.Order.ORDER_NONE_UNSPECIFIED) {
revert IBCChannelUpgradeNoExistingUpgrade();
}
if (!isCompatibleUpgradeFields(existingUpgrade.fields, msg_.counterpartyUpgrade.fields)) {
restoreChannel(msg_.portId, msg_.channelId, UpgradeHandshakeError.IncompatibleProposal);
return false;
}

// counterparty-specified timeout must not have exceeded
// if it has, then restore the channel and abort upgrade handshake
Timeout.Data calldata timeout = msg_.counterpartyUpgrade.timeout;
Expand Down
Loading

0 comments on commit 9b5036a

Please sign in to comment.