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

Channel Upgrade Open #4379

Merged
merged 31 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
50bb359
chore: remove restore logic in try handler, fast forward upgrade sequ…
chatton Aug 16, 2023
bf8f276
chore: fix linter
chatton Aug 16, 2023
279771b
disable acknowledmgent test where try upgrade is called
damiannolan Aug 16, 2023
ae4ec82
fixing failing msg server test for chanUpgradeTry
damiannolan Aug 16, 2023
1945763
wip: update write upgrade try func to no longer write channel as TRYU…
damiannolan Aug 16, 2023
c50261a
refactor: remove channel flush status from ack msg and handler
damiannolan Aug 16, 2023
729d0d6
refactor: remove channel flush status from ack msg and handler
damiannolan Aug 16, 2023
a480386
fix: address test acknowledgement failing testcase, replace flush sta…
damiannolan Aug 16, 2023
fa111f1
fix: linter crying
damiannolan Aug 16, 2023
c82beaa
adding back failure testcase for AcknowledgePacket
damiannolan Aug 16, 2023
1c335d1
updating testcase name to be more reflective of channel state
damiannolan Aug 16, 2023
fd14263
Merge branch '04-channel-upgrades' into damian/remove-flush-status-fr…
damiannolan Aug 17, 2023
d7c9bcb
refactor: update chanUpgradeAck as per spec changes
chatton Aug 17, 2023
f51446b
merge 04-channel-upgrades
chatton Aug 17, 2023
51f0fac
rm commented out lines of code in write try func
damiannolan Aug 17, 2023
f0e47b4
Merge branch '04-channel-upgrades' into damian/4243-modify-ack-expect…
damiannolan Aug 17, 2023
0538caf
address todo for handling packet acks in correct channel state
damiannolan Aug 17, 2023
cf1098a
Merge branch 'damian/4243-modify-ack-expected-channel' into cian/dami…
chatton Aug 17, 2023
8219e54
chore: fixing ack tests
chatton Aug 17, 2023
234d1a2
chore: remove unneeded comment
chatton Aug 17, 2023
f112afd
Merge branch '04-channel-upgrades' into cian/damian/channel-upgrade-ack
chatton Aug 17, 2023
354c160
chore: removed previous state log entry
chatton Aug 17, 2023
248fbdb
Update modules/core/04-channel/keeper/upgrade.go
chatton Aug 17, 2023
9b055a3
block comment code to be moved and link issue, uncomment previously d…
damiannolan Aug 17, 2023
10591fe
addding ChanUpgradeConfirm implementation with test suite
damiannolan Aug 17, 2023
471a046
adding the msg server impl for chanUpgradeConfirm, adding tests :)
damiannolan Aug 17, 2023
41c14af
refactor: updated ChanUpgradeOpen keeper function to match spec
chatton Aug 17, 2023
cdb19d4
chore: fixing tests for ChannelUpgradeOpen
chatton Aug 17, 2023
e1fb04b
chore: merge 04-channel-upgrades
chatton Aug 17, 2023
82b284b
chore: added test case for invalid counterparty channel state
chatton Aug 17, 2023
c1fb999
Merge branch '04-channel-upgrades' into cian/damian/channel-upgrade-open
chatton Aug 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
36 changes: 5 additions & 31 deletions modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,21 +441,13 @@ func (k Keeper) ChanUpgradeOpen(
proofCounterpartyChannel []byte,
proofHeight clienttypes.Height,
) error {
if k.HasInflightPackets(ctx, portID, channelID) {
return errorsmod.Wrapf(types.ErrPendingInflightPackets, "port ID (%s) channel ID (%s)", portID, channelID)
}

channel, found := k.GetChannel(ctx, portID, channelID)
if !found {
return errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (%s) channel ID (%s)", portID, channelID)
}

if !collections.Contains(channel.State, []types.State{types.TRYUPGRADE, types.ACKUPGRADE}) {
return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected one of [%s, %s], got %s", types.TRYUPGRADE, types.ACKUPGRADE, channel.State)
}

if channel.FlushStatus != types.FLUSHCOMPLETE {
return errorsmod.Wrapf(types.ErrInvalidFlushStatus, "expected %s, got %s", types.FLUSHCOMPLETE, channel.FlushStatus)
if channel.State != types.STATE_FLUSHCOMPLETE {
return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected %s, got %s", types.STATE_FLUSHCOMPLETE, channel.State)
}

connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0])
Expand Down Expand Up @@ -491,38 +483,20 @@ func (k Keeper) ChanUpgradeOpen(
Counterparty: types.NewCounterparty(portID, channelID),
Version: upgrade.Fields.Version,
UpgradeSequence: channel.UpgradeSequence,
FlushStatus: types.NOTINFLUSH,
}

case types.TRYUPGRADE:
// If the counterparty is in TRYUPGRADE, then we must have gone through the ACKUPGRADE step.
if channel.State != types.ACKUPGRADE {
return errorsmod.Wrapf(types.ErrInvalidChannelState, "expected %s, got %s", types.ACKUPGRADE, channel.State)
}

counterpartyChannel = types.Channel{
State: types.TRYUPGRADE,
Ordering: channel.Ordering,
ConnectionHops: []string{connection.GetCounterparty().GetConnectionID()},
Counterparty: types.NewCounterparty(portID, channelID),
Version: channel.Version,
UpgradeSequence: channel.UpgradeSequence,
FlushStatus: types.FLUSHCOMPLETE,
}

case types.ACKUPGRADE:
case types.STATE_FLUSHCOMPLETE:
counterpartyChannel = types.Channel{
State: types.ACKUPGRADE,
State: types.STATE_FLUSHCOMPLETE,
Ordering: channel.Ordering,
ConnectionHops: []string{connection.GetCounterparty().GetConnectionID()},
Counterparty: types.NewCounterparty(portID, channelID),
Version: channel.Version,
UpgradeSequence: channel.UpgradeSequence,
FlushStatus: types.FLUSHCOMPLETE,
}

default:
panic(fmt.Sprintf("counterparty channel state should be in one of [%s, %s, %s], got %s", types.TRYUPGRADE, types.ACKUPGRADE, types.OPEN, counterpartyChannelState))
return errorsmod.Wrapf(types.ErrInvalidCounterparty, "counterparty channel state must be one of [%s, %s], got %s", types.OPEN, types.STATE_FLUSHCOMPLETE, counterpartyChannelState)
}

if err := k.connectionKeeper.VerifyChannelState(
Expand Down
Loading