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

ChanUpgradeTimeout msg_server function #3855

Merged
merged 44 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
50b1163
writeupgradetimeout method, pull in util methods
charleenfei Jun 8, 2023
ba1fde4
update method to use abort method instead of restoreChannel
charleenfei Jun 9, 2023
8cd8c0b
Merge branch '04-channel-upgrades' into charly/#37500-write-upgrade-t…
charleenfei Jun 9, 2023
392a5b5
add expected keepers
charleenfei Jun 12, 2023
0a363de
Merge branch '04-channel-upgrades' into charly/#3747-upgrade-timeout-…
charleenfei Jun 12, 2023
a227949
finish upgrade timeout handler
charleenfei Jun 12, 2023
8b18b02
Merge branch '04-channel-upgrades' into charly/#3747-upgrade-timeout-…
charleenfei Jun 12, 2023
7b8b67b
add tests
charleenfei Jun 13, 2023
760940b
lint
charleenfei Jun 13, 2023
106ac13
Merge branch '04-channel-upgrades' into charly/#3747-upgrade-timeout-…
charleenfei Jun 13, 2023
7f12c0b
update test
charleenfei Jun 13, 2023
29f84ce
rm events file from pr
charleenfei Jun 13, 2023
16f196a
Merge branch '04-channel-upgrades' into charly/#3747-upgrade-timeout-…
charleenfei Jun 13, 2023
17748af
rm unnecessary param in test
charleenfei Jun 13, 2023
7341c5a
Merge branch 'charly/#3747-upgrade-timeout-hand' of github.com:cosmos…
charleenfei Jun 13, 2023
e9a2c20
Merge branch '04-channel-upgrades' into charly/#3747-upgrade-timeout-…
charleenfei Jun 13, 2023
900dcb6
Merge branch '04-channel-upgrades' into charly/#3747-upgrade-timeout-…
charleenfei Jun 13, 2023
8cf4a62
Merge branch '04-channel-upgrades' into charly/#3747-upgrade-timeout-…
charleenfei Jun 13, 2023
661f006
Merge branch '04-channel-upgrades' into charly/#3747-upgrade-timeout-…
charleenfei Jun 14, 2023
014990e
update ibcmodule/ibc middleware interfaces, ChanUpgradeTimeout respon…
charleenfei Jun 14, 2023
5153722
wip msg_server
charleenfei Jun 14, 2023
4326f79
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 15, 2023
42c124d
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 15, 2023
480d28e
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 15, 2023
e83a917
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 15, 2023
9ee7758
merge
charleenfei Jun 17, 2023
55bc80f
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 17, 2023
3fc5a86
merge
charleenfei Jun 17, 2023
21ea910
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 17, 2023
3abf883
add write function
charleenfei Jun 19, 2023
2a1b870
rm unnecessary app callbacks
charleenfei Jun 19, 2023
f703ae1
update msg_server call
charleenfei Jun 19, 2023
ee6b71b
update msg_server test
charleenfei Jun 20, 2023
ef48a1b
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 20, 2023
c15d556
merge
charleenfei Jun 20, 2023
8fc43af
use restore
charleenfei Jun 20, 2023
b2f777b
update upgrade seq comparison
charleenfei Jun 20, 2023
e7afe58
update Write
charleenfei Jun 20, 2023
c4f3c81
Merge branch 'charly/upgrade-sequence' into charly/#3749-msg-server-t…
charleenfei Jun 20, 2023
47897ec
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 20, 2023
1759848
pr comments
charleenfei Jun 20, 2023
118c94d
pr comments
charleenfei Jun 20, 2023
a392979
Merge branch '04-channel-upgrades' into charly/#3749-msg-server-timeout
charleenfei Jun 21, 2023
3ac26a9
fix post-merge
charleenfei Jun 21, 2023
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
13 changes: 0 additions & 13 deletions modules/apps/27-interchain-accounts/controller/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,6 @@ func (im IBCMiddleware) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID str
// OnChanUpgradeRestore implements the IBCModule interface
func (im IBCMiddleware) OnChanUpgradeRestore(ctx sdk.Context, portID, channelID string) {}

// OnChanUpgradeTimeout implements the IBCModule interface
func (im IBCMiddleware) OnChanUpgradeTimeout(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are actually calling OnChanUpgradeRestore in the UpgradeTimeout application callbacks

ctx sdk.Context,
portID, channelID string,
counterpartyChannel channeltypes.Channel,
prevErrorReceipt channeltypes.ErrorReceipt,
proofCounterpartyChannel,
proofErrorReceipt []byte,
proofHeight ibcexported.Height,
) error {
return im.app.OnChanUpgradeTimeout(ctx, portID, channelID, counterpartyChannel, prevErrorReceipt, proofCounterpartyChannel, proofErrorReceipt, proofHeight)
}

// SendPacket implements the ICS4 Wrapper interface
func (im IBCMiddleware) SendPacket(
ctx sdk.Context,
Expand Down
13 changes: 0 additions & 13 deletions modules/apps/27-interchain-accounts/host/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,3 @@ func (im IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string)

// OnChanUpgradeRestore implements the IBCModule interface
func (im IBCModule) OnChanUpgradeRestore(ctx sdk.Context, portID, channelID string) {}

// OnChanUpgradeTimeout implements the IBCModule interface
func (im IBCModule) OnChanUpgradeTimeout(
ctx sdk.Context,
portID, channelID string,
counterpartyChannel channeltypes.Channel,
prevErrorReceipt channeltypes.ErrorReceipt,
proofCounterpartyChannel,
proofErrorReceipt []byte,
proofHeight ibcexported.Height,
) error {
return nil
}
13 changes: 0 additions & 13 deletions modules/apps/29-fee/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,19 +345,6 @@ func (im IBCMiddleware) OnChanUpgradeRestore(ctx sdk.Context, portID, channelID
im.app.OnChanUpgradeRestore(ctx, portID, channelID)
}

// OnChanUpgradeTimeout implements the IBCModule interface
func (im IBCMiddleware) OnChanUpgradeTimeout(
ctx sdk.Context,
portID, channelID string,
counterpartyChannel channeltypes.Channel,
prevErrorReceipt channeltypes.ErrorReceipt,
proofCounterpartyChannel,
proofErrorReceipt []byte,
proofHeight exported.Height,
) error {
return im.app.OnChanUpgradeTimeout(ctx, portID, channelID, counterpartyChannel, prevErrorReceipt, proofCounterpartyChannel, proofErrorReceipt, proofHeight)
}

// SendPacket implements the ICS4 Wrapper interface
func (im IBCMiddleware) SendPacket(
ctx sdk.Context,
Expand Down
17 changes: 3 additions & 14 deletions modules/apps/transfer/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,9 @@ func (im IBCModule) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counter
}

// OnChanUpgradeOpen implements the IBCModule interface
func (im IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string) {}
func (im IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string) {
}
charleenfei marked this conversation as resolved.
Show resolved Hide resolved

// OnChanUpgradeRestore implements the IBCModule interface
func (im IBCModule) OnChanUpgradeRestore(ctx sdk.Context, portID, channelID string) {}

// OnChanUpgradeTimeout implements the IBCModule interface
func (im IBCModule) OnChanUpgradeTimeout(
ctx sdk.Context,
portID, channelID string,
counterpartyChannel channeltypes.Channel,
prevErrorReceipt channeltypes.ErrorReceipt,
proofCounterpartyChannel,
proofErrorReceipt []byte,
proofHeight ibcexported.Height,
) error {
return nil
func (im IBCModule) OnChanUpgradeRestore(ctx sdk.Context, portID, channelID string) {
}
5 changes: 0 additions & 5 deletions modules/core/04-channel/keeper/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,3 @@ func (k Keeper) ValidateUpgradeFields(ctx sdk.Context, proposedUpgrade types.Upg
func (k Keeper) WriteUpgradeOpenChannel(ctx sdk.Context, portID, channelID string) {
k.writeUpgradeOpenChannel(ctx, portID, channelID)
}

// WriteUpgradeTimeoutChannel is a wrapper around writeUpgradeTimeoutChannel to allow the function to be directly called in tests.
func (k Keeper) WriteUpgradeTimeoutChannel(ctx sdk.Context, portID, channelID string) error {
return k.writeUpgradeTimeoutChannel(ctx, portID, channelID)
}
8 changes: 3 additions & 5 deletions modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@ func (k Keeper) ChanUpgradeTimeout(
return nil
}

// writeUpgradeTimeoutChannel restores the channel state of an initialising chain in the event that the counterparty chain has passed the timeout set in ChanUpgradeInit to the state before the upgrade was proposed.
// WriteUpgradeTimeoutChannel restores the channel state of an initialising chain in the event that the counterparty chain has passed the timeout set in ChanUpgradeInit to the state before the upgrade was proposed.
// Auxiliary upgrade state is also deleted.
// An event is emitted for the handshake step.
func (k Keeper) writeUpgradeTimeoutChannel(
func (k Keeper) WriteUpgradeTimeoutChannel(
charleenfei marked this conversation as resolved.
Show resolved Hide resolved
ctx sdk.Context,
portID, channelID string,
) error {
Expand All @@ -485,9 +485,7 @@ func (k Keeper) writeUpgradeTimeoutChannel(
panic(fmt.Sprintf("could not find existing upgrade when cancelling channel upgrade, channelID: %s, portID: %s", channelID, portID))
}

if err := k.AbortUpgrade(ctx, portID, channelID, types.NewUpgradeError(channel.UpgradeSequence, types.ErrUpgradeTimeout)); err != nil {
return errorsmod.Wrapf(types.ErrUpgradeRestoreFailed, "err: %v", err)
}
k.restoreChannel(ctx, portID, channelID, channel)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use restore here because we don't need to set an error receipt, just restoring channel state.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me, see cosmos/ibc#986 for additional thoughts on the matter


k.Logger(ctx).Info("channel state restored", "port-id", portID, "channel-id", channelID)
emitChannelUpgradeTimeoutEvent(ctx, portID, channelID, channel, upgrade)
Expand Down
2 changes: 1 addition & 1 deletion modules/core/04-channel/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ var _ sdk.Msg = &MsgChannelUpgradeTimeout{}
func NewMsgChannelUpgradeTimeout(
portID, channelID string,
counterpartyChannel Channel,
errorReceipt ErrorReceipt,
errorReceipt *ErrorReceipt,
proofChannel, proofErrorReceipt []byte,
proofHeight clienttypes.Height,
signer string,
Expand Down
14 changes: 12 additions & 2 deletions modules/core/04-channel/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,16 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeTimeoutValidateBasic() {
func() {},
true,
},
{
"success with non-nil error receipt",
func() {
msg.PreviousErrorReceipt = &types.ErrorReceipt{
Sequence: 1,
Message: "error message",
}
},
true,
},
{
"invalid port identifier",
func() {
Expand Down Expand Up @@ -835,7 +845,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeTimeoutValidateBasic() {
suite.Run(tc.name, func() {
msg = types.NewMsgChannelUpgradeTimeout(
ibctesting.MockPort, ibctesting.FirstChannelID,
types.Channel{State: types.OPEN}, types.ErrorReceipt{},
types.Channel{State: types.OPEN}, nil,
suite.proof, suite.proof,
height, addr,
)
Expand All @@ -858,7 +868,7 @@ func (suite *TypesTestSuite) TestMsgChannelUpgradeTimeoutGetSigners() {

msg := types.NewMsgChannelUpgradeTimeout(
ibctesting.MockPort, ibctesting.FirstChannelID,
types.Channel{}, types.ErrorReceipt{},
types.Channel{}, nil,
suite.proof, suite.proof,
height, addr,
)
Expand Down
Loading