Skip to content

Commit

Permalink
Merge branch 'charly/#3448-modify-upgrade-try' of github.com:cosmos/i…
Browse files Browse the repository at this point in the history
…bc-go into charly/#3448-modify-upgrade-try
  • Loading branch information
charleenfei committed May 24, 2023
2 parents 3d99205 + 804f6d0 commit 40ec564
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 101 deletions.
4 changes: 0 additions & 4 deletions modules/core/04-channel/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,6 @@ func (k Keeper) ValidateUpgradeFields(ctx sdk.Context, proposedUpgrade types.Upg
return errorsmod.Wrap(types.ErrChannelExists, "existing channel end is identical to proposed upgrade channel end")
}

if !proposedUpgrade.Ordering.SubsetOf(currentFields.Ordering) {
return errorsmod.Wrap(types.ErrInvalidChannelOrdering, "channel ordering must be a subset of the new ordering")
}

connectionID := proposedUpgrade.ConnectionHops[0]
connection, err := k.GetConnection(ctx, connectionID)
if err != nil {
Expand Down
7 changes: 0 additions & 7 deletions modules/core/04-channel/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,6 @@ func (suite *KeeperTestSuite) TestValidateProposedUpgradeFields() {
},
expPass: true,
},
{
name: "fails with stricter ordering",
malleate: func() {
proposedUpgrade.Ordering = types.ORDERED
},
expPass: false,
},
{
name: "fails with unmodified fields",
malleate: func() {},
Expand Down
7 changes: 0 additions & 7 deletions modules/core/04-channel/keeper/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() {
},
false,
},
{
"stricter proposed channel upgrade ordering",
func() {
upgrade.Fields.Ordering = types.ORDERED
},
false,
},
}

for _, tc := range testCases {
Expand Down
16 changes: 0 additions & 16 deletions modules/core/04-channel/types/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

errorsmod "cosmossdk.io/errors"

"github.com/cosmos/ibc-go/v7/internal/collections"
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
)
Expand Down Expand Up @@ -138,21 +137,6 @@ func (ic IdentifiedChannel) ValidateBasic() error {
return channel.ValidateBasic()
}

// orderSubsets defines a map of supported ordering subsets
var orderSubsets = map[Order][]Order{
ORDERED: {UNORDERED, ORDERED},
UNORDERED: {UNORDERED},
}

// SubsetOf returns true if Order is a valid subset of the provided parent Order.
func (o Order) SubsetOf(parentOrder Order) bool {
if supported, ok := orderSubsets[parentOrder]; ok {
return collections.Contains(o, supported)
}

return false
}

// NewErrorReceipt returns an error receipt with the code from the provided error type stripped
// out to ensure changes of the error message don't cause state machine breaking changes.
func NewErrorReceipt(upgradeSequence uint64, err error) ErrorReceipt {
Expand Down
67 changes: 0 additions & 67 deletions modules/core/04-channel/types/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,70 +57,3 @@ func TestCounterpartyValidateBasic(t *testing.T) {
}
}
}

func TestSubsetOf(t *testing.T) {
testCases := []struct {
name string
order types.Order
parentOrder types.Order
expPass bool
}{
{
"ordered -> ordered",
types.ORDERED,
types.ORDERED,
true,
},
{
"ordered -> unordered",
types.UNORDERED,
types.ORDERED,
true,
},
{
"unordered -> unordered",
types.UNORDERED,
types.UNORDERED,
true,
},
{
"unordered -> ordered",
types.ORDERED,
types.UNORDERED,
false,
},
{
"none -> ordered",
types.ORDERED,
types.NONE,
false,
},
{
"none -> unordered",
types.UNORDERED,
types.NONE,
false,
},
{
"ordered -> none",
types.NONE,
types.ORDERED,
false,
},
{
"unordered -> none",
types.NONE,
types.UNORDERED,
false,
},
}

for _, tc := range testCases {
ok := tc.order.SubsetOf(tc.parentOrder)
if tc.expPass {
require.True(t, ok, tc.name)
} else {
require.False(t, ok, tc.name)
}
}
}

0 comments on commit 40ec564

Please sign in to comment.