Skip to content

Commit

Permalink
feat: removed verifychannelupgradeErrorAbsence from the 03-connection (
Browse files Browse the repository at this point in the history
…#5532)

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
  • Loading branch information
3 people committed Jan 8, 2024
1 parent bf12ce3 commit e1df7a6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 116 deletions.
37 changes: 0 additions & 37 deletions modules/core/03-connection/keeper/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,43 +408,6 @@ func (k Keeper) VerifyChannelUpgradeError(
return nil
}

// VerifyChannelUpgradeErrorAbsence verifies a proof of the absence of a
// channel upgrade error.
func (k Keeper) VerifyChannelUpgradeErrorAbsence(
ctx sdk.Context,
connection exported.ConnectionI,
proofHeight exported.Height,
proofErrorReceiptAbsence []byte,
portID,
channelID string,
) error {
clientID := connection.GetClientID()
clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID)
if err != nil {
return err
}

if status := k.clientKeeper.GetClientStatus(ctx, clientState, clientID); status != exported.Active {
return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status)
}

merklePath := commitmenttypes.NewMerklePath(host.ChannelUpgradeErrorPath(portID, channelID))
merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath)
if err != nil {
return err
}

if err := clientState.VerifyNonMembership(
ctx, clientStore, k.cdc, proofHeight,
0, 0,
proofErrorReceiptAbsence, merklePath,
); err != nil {
return errorsmod.Wrapf(err, "failed upgrade error receipt absence verification for client (%s)", clientID)
}

return nil
}

// VerifyChannelUpgrade verifies the proof that a particular proposed upgrade has been stored in the upgrade path.
func (k Keeper) VerifyChannelUpgrade(
ctx sdk.Context,
Expand Down
71 changes: 0 additions & 71 deletions modules/core/03-connection/keeper/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,77 +764,6 @@ func (suite *KeeperTestSuite) TestVerifyUpgradeErrorReceipt() {
}
}

func (suite *KeeperTestSuite) TestVerifyUpgradeErrorReceiptAbsence() {
var path *ibctesting.Path

cases := []struct {
name string
malleate func()
expPass bool
}{
{
name: "success",
malleate: func() {},
expPass: true,
},
{
name: "fails when client state is frozen",
malleate: func() {
clientState := path.EndpointB.GetClientState().(*ibctm.ClientState)
clientState.FrozenHeight = clienttypes.NewHeight(0, 1)
path.EndpointB.SetClientState(clientState)
},
expPass: false,
},
{
name: "fails with bad client id",
malleate: func() {
connection := path.EndpointB.GetConnection()
connection.ClientId = ibctesting.InvalidID
path.EndpointB.SetConnection(connection)
},
expPass: false,
},
{
name: "verification fails when the key exists",
malleate: func() {
upgradeErr := channeltypes.NewUpgradeError(1, channeltypes.ErrInvalidChannel)
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeErr)
suite.chainA.Coordinator.CommitBlock(suite.chainA)
suite.Require().NoError(path.EndpointB.UpdateClient())
},
expPass: false,
},
}

for _, tc := range cases {
tc := tc

suite.Run(tc.name, func() {
suite.SetupTest() // reset

path = ibctesting.NewPath(suite.chainA, suite.chainB)
suite.coordinator.Setup(path)

suite.chainA.Coordinator.CommitBlock(suite.chainA)
suite.Require().NoError(path.EndpointB.UpdateClient())

tc.malleate()

upgradeErrorReceiptKey := host.ChannelUpgradeErrorKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
proof, proofHeight := suite.chainA.QueryProof(upgradeErrorReceiptKey)

err := suite.chainB.GetSimApp().IBCKeeper.ConnectionKeeper.VerifyChannelUpgradeErrorAbsence(suite.chainB.GetContext(), path.EndpointB.GetConnection(), proofHeight, proof, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)

if tc.expPass {
suite.Require().NoError(err)
} else {
suite.Require().Error(err)
}
})
}
}

func (suite *KeeperTestSuite) TestVerifyUpgrade() {
var (
path *ibctesting.Path
Expand Down
8 changes: 0 additions & 8 deletions modules/core/04-channel/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ type ConnectionKeeper interface {
channelID string,
errorReceipt ErrorReceipt,
) error
VerifyChannelUpgradeErrorAbsence(
ctx sdk.Context,
connection exported.ConnectionI,
proofHeight exported.Height,
proofErrorReceiptAbsence []byte,
portID,
channelID string,
) error
}

// PortKeeper expected account IBC port keeper
Expand Down

0 comments on commit e1df7a6

Please sign in to comment.