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 to emit a ChannelUpgradeOpen event if transit to OPEN state in channelUpgradeConfirm #290

Merged
merged 1 commit into from
Jul 24, 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
36 changes: 18 additions & 18 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: 36639835)
TestICS02:testCreateClient() (gas: 36638179)
TestICS02:testHeightToUint128((uint64,uint64)) (runs: 256, μ: 887, ~: 887)
TestICS02:testInvalidCreateClient() (gas: 36536946)
TestICS02:testInvalidUpdateClient() (gas: 36535962)
TestICS02:testRegisterClient() (gas: 36191628)
TestICS02:testRegisterClientDuplicatedClientType() (gas: 36176937)
TestICS02:testRegisterClientInvalidClientType() (gas: 36206443)
TestICS02:testUpdateClient() (gas: 36704162)
TestICS02:testInvalidCreateClient() (gas: 36535290)
TestICS02:testInvalidUpdateClient() (gas: 36534306)
TestICS02:testRegisterClient() (gas: 36189972)
TestICS02:testRegisterClientDuplicatedClientType() (gas: 36175281)
TestICS02:testRegisterClientInvalidClientType() (gas: 36204787)
TestICS02:testUpdateClient() (gas: 36702506)
TestICS03Handshake:testConnOpenAck() (gas: 1858230)
TestICS03Handshake:testConnOpenConfirm() (gas: 2054143)
TestICS03Handshake:testConnOpenInit() (gas: 1429838)
Expand Down Expand Up @@ -48,24 +48,24 @@ TestICS04Packet:testRecvPacketTimeoutHeight() (gas: 3259769)
TestICS04Packet:testRecvPacketTimeoutTimestamp() (gas: 3284145)
TestICS04Packet:testSendPacket() (gas: 6411842)
TestICS04Packet:testTimeoutOnClose() (gas: 3553375)
TestICS04Upgrade:testUpgradeAuthorityCancel() (gas: 46723464)
TestICS04Upgrade:testUpgradeAuthorityCancel() (gas: 46734825)
TestICS04Upgrade:testUpgradeCannotCancelWithOldErrorReceipt() (gas: 3458838)
TestICS04Upgrade:testUpgradeCannotRecvNextUpgradePacket() (gas: 5259191)
TestICS04Upgrade:testUpgradeCounterpartyAdvanceNextSequenceBeforeOpen() (gas: 5230069)
TestICS04Upgrade:testUpgradeCannotRecvNextUpgradePacket() (gas: 5258785)
TestICS04Upgrade:testUpgradeCounterpartyAdvanceNextSequenceBeforeOpen() (gas: 5229663)
TestICS04Upgrade:testUpgradeCrossingHelloIncompatibleProposals() (gas: 5068281)
TestICS04Upgrade:testUpgradeFull() (gas: 56559261)
TestICS04Upgrade:testUpgradeFull() (gas: 56577477)
TestICS04Upgrade:testUpgradeInit() (gas: 3074224)
TestICS04Upgrade:testUpgradeNoChanges() (gas: 2473090)
TestICS04Upgrade:testUpgradeNotUpgradableModule() (gas: 3648638)
TestICS04Upgrade:testUpgradeNotUpgradableModule() (gas: 3648626)
TestICS04Upgrade:testUpgradeOutOfSync() (gas: 3905908)
TestICS04Upgrade:testUpgradeRelaySuccessAtCounterpartyFlushComplete() (gas: 5230956)
TestICS04Upgrade:testUpgradeRelaySuccessAtFlushing() (gas: 5604165)
TestICS04Upgrade:testUpgradeSendPacketFailAtFlushingOrFlushComplete() (gas: 4069212)
TestICS04Upgrade:testUpgradeRelaySuccessAtCounterpartyFlushComplete() (gas: 5230550)
TestICS04Upgrade:testUpgradeRelaySuccessAtFlushing() (gas: 5603759)
TestICS04Upgrade:testUpgradeSendPacketFailAtFlushingOrFlushComplete() (gas: 4072103)
TestICS04Upgrade:testUpgradeTimeoutAbortAck() (gas: 17708385)
TestICS04Upgrade:testUpgradeTimeoutAbortConfirm() (gas: 21315818)
TestICS04Upgrade:testUpgradeTimeoutUpgrade() (gas: 70973805)
TestICS04Upgrade:testUpgradeToOrdered() (gas: 56461648)
TestICS04Upgrade:testUpgradeToUnordered() (gas: 45074517)
TestICS04Upgrade:testUpgradeTimeoutUpgrade() (gas: 70972587)
TestICS04Upgrade:testUpgradeToOrdered() (gas: 56491951)
TestICS04Upgrade:testUpgradeToUnordered() (gas: 45100181)
TestICS04UpgradeApp:testUpgradeAuthorizationChanneNotFound() (gas: 61690)
TestICS04UpgradeApp:testUpgradeAuthorizationRePropose() (gas: 2565379)
TestICS04UpgradeApp:testUpgradeAuthorizationRemove() (gas: 2475938)
Expand Down
4 changes: 3 additions & 1 deletion contracts/core/04-channel/IBCChannelUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ abstract contract IBCChannelUpgradeBase is
* over to the agreed upon upgrade fields.
* it will reset the channel state to OPEN.
* it will delete auxiliary upgrade state.
* it will emit a `ChannelUpgradeOpen` event.
* caller must do all relevant checks before calling this function.
*/
function openUpgradeHandshake(string calldata portId, string calldata channelId) internal {
Expand Down Expand Up @@ -173,6 +174,8 @@ abstract contract IBCChannelUpgradeBase is

updateChannelCommitment(portId, channelId, channel);
deleteUpgradeCommitment(portId, channelId);

emit ChannelUpgradeOpen(portId, channelId, channel.upgrade_sequence);
}

function isCompatibleUpgradeFields(
Expand Down Expand Up @@ -699,7 +702,6 @@ contract IBCChannelUpgradeConfirmTimeoutCancel is IBCChannelUpgradeBase, IIBCCha

// move channel to OPEN and adopt upgrade parameters
openUpgradeHandshake(msg_.portId, msg_.channelId);
emit ChannelUpgradeOpen(msg_.portId, msg_.channelId, channel.upgrade_sequence);

// open callback must not return error since counterparty successfully upgraded
// make application state changes based on new channel parameters
Expand Down
88 changes: 44 additions & 44 deletions contracts/core/04-channel/IIBCChannelUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@ import {Height} from "../../proto/Client.sol";
import {Channel, Upgrade, UpgradeFields, ErrorReceipt, Timeout} from "../../proto/Channel.sol";

interface IIBCChannelUpgradeBase {
// --------------------- Events --------------------- //

/// @notice emitted when channelUpgradeInit is successfully executed
event ChannelUpgradeInit(
string portId, string channelId, uint64 upgradeSequence, UpgradeFields.Data proposedUpgradeFields
);

/// @notice emitted when channelUpgradeTry is successfully executed
event ChannelUpgradeTry(
string portId,
string channelId,
uint64 upgradeSequence,
UpgradeFields.Data upgradeFields,
Timeout.Data timeout,
uint64 nextSequenceSend
);

/// @notice emitted when channelUpgradeAck is successfully executed
/// @param channelState post channel state (FLUSHING or FLUSHCOMPLETE)
event ChannelUpgradeAck(
string portId,
string channelId,
uint64 upgradeSequence,
Channel.State channelState,
UpgradeFields.Data upgradeFields,
Timeout.Data timeout,
uint64 nextSequenceSend
);

/// @notice emitted when channelUpgradeConfirm is successfully executed
/// @param channelState post channel state (FLUSHING or FLUSHCOMPLETE or OPEN)
event ChannelUpgradeConfirm(string portId, string channelId, uint64 upgradeSequence, Channel.State channelState);

/// @notice emitted when channelUpgradeOpen is successfully executed
event ChannelUpgradeOpen(string portId, string channelId, uint64 upgradeSequence);

/// @notice error when the upgrade attempt fails
/// @param portId port identifier
/// @param channelId channel identifier
/// @param upgradeSequence upgrade sequence
event WriteErrorReceipt(string portId, string channelId, uint64 upgradeSequence, string message);

// --------------------- Structs --------------------- //

enum UpgradeHandshakeError {
None,
Overwritten,
Expand Down Expand Up @@ -75,44 +119,9 @@ interface IIBCChannelUpgradeBase {
bytes proofUpgrade;
Height.Data proofHeight;
}

/// @notice error when the upgrade attempt fails
/// @param portId port identifier
/// @param channelId channel identifier
/// @param upgradeSequence upgrade sequence
event WriteErrorReceipt(string portId, string channelId, uint64 upgradeSequence, string message);
}

interface IIBCChannelUpgradeInitTryAck is IIBCChannelUpgradeBase {
// --------------------- Events --------------------- //

/// @notice emitted when channelUpgradeInit is successfully executed
event ChannelUpgradeInit(
string portId, string channelId, uint64 upgradeSequence, UpgradeFields.Data proposedUpgradeFields
);

/// @notice emitted when channelUpgradeTry is successfully executed
event ChannelUpgradeTry(
string portId,
string channelId,
uint64 upgradeSequence,
UpgradeFields.Data upgradeFields,
Timeout.Data timeout,
uint64 nextSequenceSend
);

/// @notice emitted when channelUpgradeAck is successfully executed
/// @param channelState post channel state (FLUSHING or FLUSHCOMPLETE)
event ChannelUpgradeAck(
string portId,
string channelId,
uint64 upgradeSequence,
Channel.State channelState,
UpgradeFields.Data upgradeFields,
Timeout.Data timeout,
uint64 nextSequenceSend
);

// --------------------- External Functions --------------------- //

/**
Expand Down Expand Up @@ -147,15 +156,6 @@ interface IIBCChannelUpgradeInitTryAck is IIBCChannelUpgradeBase {
}

interface IIBCChannelUpgradeConfirmOpenTimeoutCancel is IIBCChannelUpgradeBase {
// --------------------- Events --------------------- //

/// @notice emitted when channelUpgradeConfirm is successfully executed
/// @param channelState post channel state (FLUSHING or FLUSHCOMPLETE or OPEN)
event ChannelUpgradeConfirm(string portId, string channelId, uint64 upgradeSequence, Channel.State channelState);

/// @notice emitted when channelUpgradeOpen is successfully executed
event ChannelUpgradeOpen(string portId, string channelId, uint64 upgradeSequence);

// --------------------- External Functions --------------------- //

/**
Expand Down
2 changes: 1 addition & 1 deletion pkg/contract/ibchandler/ibchandler.go

Large diffs are not rendered by default.