-
Notifications
You must be signed in to change notification settings - Fork 592
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
refactor: remove FlushStatus
from ack handler and msg
#4364
Merged
damiannolan
merged 8 commits into
04-channel-upgrades
from
damian/remove-flush-status-from-ack-handler
Aug 17, 2023
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
50bb359
chore: remove restore logic in try handler, fast forward upgrade sequ…
chatton bf8f276
chore: fix linter
chatton 729d0d6
refactor: remove channel flush status from ack msg and handler
damiannolan a480386
fix: address test acknowledgement failing testcase, replace flush sta…
damiannolan fa111f1
fix: linter crying
damiannolan c82beaa
adding back failure testcase for AcknowledgePacket
damiannolan 1c335d1
updating testcase name to be more reflective of channel state
damiannolan fd14263
Merge branch '04-channel-upgrades' into damian/remove-flush-status-fr…
damiannolan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,8 +114,13 @@ func (k Keeper) ChanUpgradeTry( | |
if found { | ||
proposedUpgradeFields = upgrade.Fields | ||
} else { | ||
// TODO: add fast forward feature | ||
// https://github.com/cosmos/ibc-go/issues/3794 | ||
// if the counterparty sequence is greater than the current sequence, we fast-forward to the counterparty sequence. | ||
if counterpartyUpgradeSequence > channel.UpgradeSequence { | ||
// using -1 as WriteUpgradeInitChannel increments the sequence | ||
channel.UpgradeSequence = counterpartyUpgradeSequence - 1 | ||
k.SetChannel(ctx, portID, channelID, channel) | ||
} | ||
|
||
// NOTE: OnChanUpgradeInit will not be executed by the application | ||
upgrade, err = k.ChanUpgradeInit(ctx, portID, channelID, proposedUpgradeFields) | ||
if err != nil { | ||
|
@@ -153,9 +158,10 @@ func (k Keeper) ChanUpgradeTry( | |
); err != nil { | ||
return types.Upgrade{}, errorsmod.Wrap(err, "failed to verify counterparty channel state") | ||
} | ||
|
||
if err := k.syncUpgradeSequence(ctx, portID, channelID, channel, counterpartyUpgradeSequence); err != nil { | ||
return types.Upgrade{}, err | ||
if counterpartyUpgradeSequence < channel.UpgradeSequence { | ||
return upgrade, types.NewUpgradeError(channel.UpgradeSequence-1, errorsmod.Wrapf( | ||
types.ErrInvalidUpgradeSequence, "counterparty upgrade sequence < current upgrade sequence (%d < %d)", counterpartyUpgradeSequence, channel.UpgradeSequence, | ||
)) | ||
} | ||
|
||
// verifies the proof that a particular proposed upgrade has been stored in the upgrade path of the counterparty | ||
|
@@ -189,11 +195,6 @@ func (k Keeper) WriteUpgradeTryChannel(ctx sdk.Context, portID, channelID string | |
|
||
previousState := channel.State | ||
channel.State = types.TRYUPGRADE | ||
channel.FlushStatus = types.FLUSHING | ||
|
||
if !k.HasInflightPackets(ctx, portID, channelID) { | ||
channel.FlushStatus = types.FLUSHCOMPLETE | ||
} | ||
|
||
upgrade.Fields.Version = upgradeVersion | ||
|
||
|
@@ -215,7 +216,6 @@ func (k Keeper) ChanUpgradeAck( | |
ctx sdk.Context, | ||
portID, | ||
channelID string, | ||
counterpartyFlushStatus types.FlushStatus, | ||
counterpartyUpgrade types.Upgrade, | ||
proofChannel, | ||
proofUpgrade []byte, | ||
|
@@ -230,10 +230,6 @@ func (k Keeper) ChanUpgradeAck( | |
return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.OPEN, types.STATE_FLUSHING, channel.State) | ||
} | ||
|
||
if !collections.Contains(counterpartyFlushStatus, []types.FlushStatus{types.FLUSHING, types.FLUSHCOMPLETE}) { | ||
return errorsmod.Wrapf(types.ErrInvalidFlushStatus, "expected one of [%s, %s], got %s", types.FLUSHING, types.FLUSHCOMPLETE, counterpartyFlushStatus) | ||
} | ||
|
||
connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) | ||
if !found { | ||
return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0]) | ||
|
@@ -251,7 +247,7 @@ func (k Keeper) ChanUpgradeAck( | |
Counterparty: types.NewCounterparty(portID, channelID), | ||
Version: channel.Version, | ||
UpgradeSequence: channel.UpgradeSequence, | ||
FlushStatus: counterpartyFlushStatus, // provided by the relayer | ||
FlushStatus: types.NOTINFLUSH, // TODO: remove flush status from channel end | ||
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. temporarily hard code the flush status to the default value so proofs can succeed |
||
} | ||
|
||
// verify the counterparty channel state containing the upgrade sequence | ||
|
@@ -892,7 +888,7 @@ func (k Keeper) abortUpgrade(ctx sdk.Context, portID, channelID string, err erro | |
upgradeError = types.NewUpgradeError(channel.UpgradeSequence, err) | ||
} | ||
|
||
if err := k.writeErrorReceipt(ctx, portID, channelID, upgrade, upgradeError); err != nil { | ||
if err := k.WriteErrorReceipt(ctx, portID, channelID, upgrade.Fields, upgradeError); err != nil { | ||
return err | ||
} | ||
|
||
|
@@ -911,14 +907,14 @@ func (k Keeper) restoreChannel(ctx sdk.Context, portID, channelID string, upgrad | |
k.deleteUpgradeInfo(ctx, portID, channelID) | ||
} | ||
|
||
// writeErrorReceipt will write an error receipt from the provided UpgradeError. | ||
func (k Keeper) writeErrorReceipt(ctx sdk.Context, portID, channelID string, upgrade types.Upgrade, upgradeError *types.UpgradeError) error { | ||
// WriteErrorReceipt will write an error receipt from the provided UpgradeError. | ||
func (k Keeper) WriteErrorReceipt(ctx sdk.Context, portID, channelID string, upgradeFields types.UpgradeFields, upgradeError *types.UpgradeError) error { | ||
channel, found := k.GetChannel(ctx, portID, channelID) | ||
if !found { | ||
return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID) | ||
} | ||
|
||
k.SetUpgradeErrorReceipt(ctx, portID, channelID, upgradeError.GetErrorReceipt()) | ||
emitErrorReceiptEvent(ctx, portID, channelID, channel, upgrade, upgradeError) | ||
emitErrorReceiptEvent(ctx, portID, channelID, channel, upgradeFields, upgradeError) | ||
return nil | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
At the moment this is functioning with "tryupgrade" rather than the flushing state, but I made the change to the test string because this will still pass successfully when #4243 is completed