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

chore: rename proofXyz -> xyzProof #5599

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func (cs ClientState) VerifyUpgradeAndUpdateState(
store sdk.KVStore,
newClient ClientState,
newConsState ConsensusState,
proofUpgradeClient,
proofUpgradeConsState []byte,
upgradeClientProof,
upgradeConsensusStateProof []byte,
) error
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() {
suite.Require().NoError(err)

channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)
proofInit, proofHeight := path.EndpointB.Chain.QueryProof(channelKey)
initProof, proofHeight := path.EndpointB.Chain.QueryProof(channelKey)

// use chainA (controller) for ChanOpenTry
msg := channeltypes.NewMsgChannelOpenTry(path.EndpointA.ChannelConfig.PortID, TestVersion, channeltypes.ORDERED, []string{path.EndpointA.ConnectionID}, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, TestVersion, proofInit, proofHeight, icatypes.ModuleName)
msg := channeltypes.NewMsgChannelOpenTry(path.EndpointA.ChannelConfig.PortID, TestVersion, channeltypes.ORDERED, []string{path.EndpointA.ConnectionID}, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, TestVersion, initProof, proofHeight, icatypes.ModuleName)
handler := suite.chainA.GetSimApp().MsgServiceRouter().Handler(msg)
_, err = handler(suite.chainA.GetContext(), msg)

Expand Down Expand Up @@ -427,10 +427,10 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() {

// query proof from ChainB
channelKey := host.ChannelKey(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID)
proofAck, proofHeight := path.EndpointB.Chain.QueryProof(channelKey)
ackProof, proofHeight := path.EndpointB.Chain.QueryProof(channelKey)

// use chainA (controller) for ChanOpenConfirm
msg := channeltypes.NewMsgChannelOpenConfirm(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, proofAck, proofHeight, icatypes.ModuleName)
msg := channeltypes.NewMsgChannelOpenConfirm(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, ackProof, proofHeight, icatypes.ModuleName)
handler := suite.chainA.GetSimApp().MsgServiceRouter().Handler(msg)
_, err = handler(suite.chainA.GetContext(), msg)

Expand Down
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/host/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenAck() {

// query proof from ChainA
channelKey := host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
proofTry, proofHeight := path.EndpointA.Chain.QueryProof(channelKey)
tryProof, proofHeight := path.EndpointA.Chain.QueryProof(channelKey)

// use chainB (host) for ChanOpenAck
msg := channeltypes.NewMsgChannelOpenAck(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelID, TestVersion, proofTry, proofHeight, icatypes.ModuleName)
msg := channeltypes.NewMsgChannelOpenAck(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelID, TestVersion, tryProof, proofHeight, icatypes.ModuleName)
handler := suite.chainB.GetSimApp().MsgServiceRouter().Handler(msg)
_, err = handler(suite.chainB.GetContext(), msg)

Expand Down
6 changes: 3 additions & 3 deletions modules/core/02-client/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ func newUpgradeClientCmd() *cobra.Command {
}
}

proofUpgradeClient := []byte(args[3])
proofUpgradeConsensus := []byte(args[4])
upgradeClientProof := []byte(args[3])
upgradeConsensusProof := []byte(args[4])

msg, err := types.NewMsgUpgradeClient(clientID, clientState, consensusState, proofUpgradeClient, proofUpgradeConsensus, clientCtx.GetFromAddress().String())
msg, err := types.NewMsgUpgradeClient(clientID, clientState, consensusState, upgradeClientProof, upgradeConsensusProof, clientCtx.GetFromAddress().String())
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg exporte
// UpgradeClient upgrades the client to a new client state if this new client was committed to
// by the old client at the specified upgrade height
func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient exported.ClientState, upgradedConsState exported.ConsensusState,
proofUpgradeClient, proofUpgradeConsState []byte,
upgradeClientProof, upgradeConsensusStateProof []byte,
) error {
clientState, found := k.GetClientState(ctx, clientID)
if !found {
Expand All @@ -138,7 +138,7 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e
}

if err := clientState.VerifyUpgradeAndUpdateState(ctx, k.cdc, clientStore,
upgradedClient, upgradedConsState, proofUpgradeClient, proofUpgradeConsState,
upgradedClient, upgradedConsState, upgradeClientProof, upgradeConsensusStateProof,
); err != nil {
return errorsmod.Wrapf(err, "cannot upgrade client with ID %s", clientID)
}
Expand Down
34 changes: 17 additions & 17 deletions modules/core/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {

func (suite *KeeperTestSuite) TestUpgradeClient() {
var (
path *ibctesting.Path
upgradedClient exported.ClientState
upgradedConsState exported.ConsensusState
lastHeight exported.Height
proofUpgradedClient, proofUpgradedConsState []byte
upgradedClientBz, upgradedConsStateBz []byte
path *ibctesting.Path
upgradedClient exported.ClientState
upgradedConsState exported.ConsensusState
lastHeight exported.Height
upgradedClientProof, upgradedConsensusStateProof []byte
upgradedClientBz, upgradedConsStateBz []byte
)

testCases := []struct {
Expand Down Expand Up @@ -340,8 +340,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID)
suite.Require().True(found)

proofUpgradedClient, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
proofUpgradedConsState, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedClientProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedConsensusStateProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
},
expPass: true,
},
Expand All @@ -366,8 +366,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID)
suite.Require().True(found)

proofUpgradedClient, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
proofUpgradedConsState, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedClientProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedConsensusStateProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())

path.EndpointA.ClientID = "wrongclientid"
},
Expand Down Expand Up @@ -396,8 +396,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID)
suite.Require().True(found)

proofUpgradedClient, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
proofUpgradedConsState, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedClientProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedConsensusStateProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())

// set frozen client in store
tmClient, ok := cs.(*ibctm.ClientState)
Expand Down Expand Up @@ -431,8 +431,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID)
suite.Require().True(found)

proofUpgradedClient, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
proofUpgradedConsState, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedClientProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedConsensusStateProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
},
expPass: false,
},
Expand Down Expand Up @@ -460,8 +460,8 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {
cs, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID)
suite.Require().True(found)

proofUpgradedClient, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
proofUpgradedConsState, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedClientProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
upgradedConsensusStateProof, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight())
},
expPass: false,
},
Expand Down Expand Up @@ -491,7 +491,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() {

tc.setup()

err = suite.chainA.App.GetIBCKeeper().ClientKeeper.UpgradeClient(suite.chainA.GetContext(), path.EndpointA.ClientID, upgradedClient, upgradedConsState, proofUpgradedClient, proofUpgradedConsState)
err = suite.chainA.App.GetIBCKeeper().ClientKeeper.UpgradeClient(suite.chainA.GetContext(), path.EndpointA.ClientID, upgradedClient, upgradedConsState, upgradedClientProof, upgradedConsensusStateProof)

if tc.expPass {
suite.Require().NoError(err, "verify upgrade failed on valid case: %s", tc.name)
Expand Down
6 changes: 3 additions & 3 deletions modules/core/02-client/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (msg MsgUpdateClient) UnpackInterfaces(unpacker codectypes.AnyUnpacker) err

// NewMsgUpgradeClient creates a new MsgUpgradeClient instance
func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, consState exported.ConsensusState,
proofUpgradeClient, proofUpgradeConsState []byte, signer string,
upgradeClientProof, upgradeConsensusStateProof []byte, signer string,
) (*MsgUpgradeClient, error) {
anyClient, err := PackClientState(clientState)
if err != nil {
Expand All @@ -148,8 +148,8 @@ func NewMsgUpgradeClient(clientID string, clientState exported.ClientState, cons
ClientId: clientID,
ClientState: anyClient,
ConsensusState: anyConsState,
ProofUpgradeClient: proofUpgradeClient,
ProofUpgradeConsensusState: proofUpgradeConsState,
ProofUpgradeClient: upgradeClientProof,
ProofUpgradeConsensusState: upgradeConsensusStateProof,
Signer: signer,
}, nil
}
Expand Down
28 changes: 14 additions & 14 deletions modules/core/03-connection/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func (k Keeper) ConnOpenTry(
clientID string, // clientID of chainA
clientState exported.ClientState, // clientState that chainA has for chainB
counterpartyVersions []*types.Version, // supported versions of chain A
proofInit []byte, // proof that chainA stored connectionEnd in state (on ConnOpenInit)
proofClient []byte, // proof that chainA stored a light client of chainB
proofConsensus []byte, // proof that chainA stored chainB's consensus state at consensus height
initProof []byte, // proof that chainA stored connectionEnd in state (on ConnOpenInit)
clientProof []byte, // proof that chainA stored a light client of chainB
consensusProof []byte, // proof that chainA stored chainB's consensus state at consensus height
proofHeight exported.Height, // height at which relayer constructs proof of A storing connectionEnd in state
consensusHeight exported.Height, // latest height of chain B which chain A has stored in its chain B client
) (string, error) {
Expand Down Expand Up @@ -123,20 +123,20 @@ func (k Keeper) ConnOpenTry(

// Check that ChainA committed expectedConnectionEnd to its state
if err := k.VerifyConnectionState(
ctx, connection, proofHeight, proofInit, counterparty.ConnectionId,
ctx, connection, proofHeight, initProof, counterparty.ConnectionId,
expectedConnection,
); err != nil {
return "", err
}

// Check that ChainA stored the clientState provided in the msg
if err := k.VerifyClientState(ctx, connection, proofHeight, proofClient, clientState); err != nil {
if err := k.VerifyClientState(ctx, connection, proofHeight, clientProof, clientState); err != nil {
return "", err
}

// Check that ChainA stored the correct ConsensusState of chainB at the given consensusHeight
if err := k.VerifyClientConsensusState(
ctx, connection, proofHeight, consensusHeight, proofConsensus, expectedConsensusState,
ctx, connection, proofHeight, consensusHeight, consensusProof, expectedConsensusState,
); err != nil {
return "", err
}
Expand Down Expand Up @@ -166,9 +166,9 @@ func (k Keeper) ConnOpenAck(
clientState exported.ClientState, // client state for chainA on chainB
version *types.Version, // version that ChainB chose in ConnOpenTry
counterpartyConnectionID string,
proofTry []byte, // proof that connectionEnd was added to ChainB state in ConnOpenTry
proofClient []byte, // proof of client state on chainB for chainA
proofConsensus []byte, // proof that chainB has stored ConsensusState of chainA on its client
tryProof []byte, // proof that connectionEnd was added to ChainB state in ConnOpenTry
clientProof []byte, // proof of client state on chainB for chainA
consensusProof []byte, // proof that chainB has stored ConsensusState of chainA on its client
proofHeight exported.Height, // height that relayer constructed proofTry
consensusHeight exported.Height, // latest height of chainA that chainB has stored on its chainA client
) error {
Expand Down Expand Up @@ -221,20 +221,20 @@ func (k Keeper) ConnOpenAck(

// Ensure that ChainB stored expected connectionEnd in its state during ConnOpenTry
if err := k.VerifyConnectionState(
ctx, connection, proofHeight, proofTry, counterpartyConnectionID,
ctx, connection, proofHeight, tryProof, counterpartyConnectionID,
expectedConnection,
); err != nil {
return err
}

// Check that ChainB stored the clientState provided in the msg
if err := k.VerifyClientState(ctx, connection, proofHeight, proofClient, clientState); err != nil {
if err := k.VerifyClientState(ctx, connection, proofHeight, clientProof, clientState); err != nil {
return err
}

// Ensure that ChainB has stored the correct ConsensusState for chainA at the consensusHeight
if err := k.VerifyClientConsensusState(
ctx, connection, proofHeight, consensusHeight, proofConsensus, expectedConsensusState,
ctx, connection, proofHeight, consensusHeight, consensusProof, expectedConsensusState,
); err != nil {
return err
}
Expand All @@ -261,7 +261,7 @@ func (k Keeper) ConnOpenAck(
func (k Keeper) ConnOpenConfirm(
ctx sdk.Context,
connectionID string,
proofAck []byte, // proof that connection opened on ChainA during ConnOpenAck
ackProof []byte, // proof that connection opened on ChainA during ConnOpenAck
proofHeight exported.Height, // height that relayer constructed proofAck
) error {
// Retrieve connection
Expand All @@ -284,7 +284,7 @@ func (k Keeper) ConnOpenConfirm(

// Check that connection on ChainA is open
if err := k.VerifyConnectionState(
ctx, connection, proofHeight, proofAck, connection.Counterparty.ConnectionId,
ctx, connection, proofHeight, ackProof, connection.Counterparty.ConnectionId,
expectedConnection,
); err != nil {
return err
Expand Down
20 changes: 10 additions & 10 deletions modules/core/03-connection/keeper/handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,22 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
suite.Require().NoError(err)

connectionKey := host.ConnectionKey(path.EndpointA.ConnectionID)
proofInit, proofHeight := suite.chainA.QueryProof(connectionKey)
initProof, proofHeight := suite.chainA.QueryProof(connectionKey)

if consensusHeight.IsZero() {
// retrieve consensus state height to provide proof for
consensusHeight = counterpartyClient.GetLatestHeight()
}
consensusKey := host.FullConsensusStateKey(path.EndpointA.ClientID, consensusHeight)
proofConsensus, _ := suite.chainA.QueryProof(consensusKey)
consensusProof, _ := suite.chainA.QueryProof(consensusKey)

// retrieve proof of counterparty clientstate on chainA
clientKey := host.FullClientStateKey(path.EndpointA.ClientID)
proofClient, _ := suite.chainA.QueryProof(clientKey)
clientProof, _ := suite.chainA.QueryProof(clientKey)

connectionID, err := suite.chainB.App.GetIBCKeeper().ConnectionKeeper.ConnOpenTry(
suite.chainB.GetContext(), counterparty, delayPeriod, path.EndpointB.ClientID, counterpartyClient,
versions, proofInit, proofClient, proofConsensus,
versions, initProof, clientProof, consensusProof,
proofHeight, consensusHeight,
)

Expand Down Expand Up @@ -491,23 +491,23 @@ func (suite *KeeperTestSuite) TestConnOpenAck() {
suite.Require().NoError(err)

connectionKey := host.ConnectionKey(path.EndpointB.ConnectionID)
proofTry, proofHeight := suite.chainB.QueryProof(connectionKey)
tryProof, proofHeight := suite.chainB.QueryProof(connectionKey)

if consensusHeight.IsZero() {
// retrieve consensus state height to provide proof for
clientState := suite.chainB.GetClientState(path.EndpointB.ClientID)
consensusHeight = clientState.GetLatestHeight()
}
consensusKey := host.FullConsensusStateKey(path.EndpointB.ClientID, consensusHeight)
proofConsensus, _ := suite.chainB.QueryProof(consensusKey)
consensusProof, _ := suite.chainB.QueryProof(consensusKey)

// retrieve proof of counterparty clientstate on chainA
clientKey := host.FullClientStateKey(path.EndpointB.ClientID)
proofClient, _ := suite.chainB.QueryProof(clientKey)
clientProof, _ := suite.chainB.QueryProof(clientKey)

err = suite.chainA.App.GetIBCKeeper().ConnectionKeeper.ConnOpenAck(
suite.chainA.GetContext(), path.EndpointA.ConnectionID, counterpartyClient, version, path.EndpointB.ConnectionID,
proofTry, proofClient, proofConsensus, proofHeight, consensusHeight,
tryProof, clientProof, consensusProof, proofHeight, consensusHeight,
)

if tc.expPass {
Expand Down Expand Up @@ -570,10 +570,10 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() {
suite.Require().NoError(err)

connectionKey := host.ConnectionKey(path.EndpointA.ConnectionID)
proofAck, proofHeight := suite.chainA.QueryProof(connectionKey)
ackProof, proofHeight := suite.chainA.QueryProof(connectionKey)

err = suite.chainB.App.GetIBCKeeper().ConnectionKeeper.ConnOpenConfirm(
suite.chainB.GetContext(), path.EndpointB.ConnectionID, proofAck, proofHeight,
suite.chainB.GetContext(), path.EndpointB.ConnectionID, ackProof, proofHeight,
)

if tc.expPass {
Expand Down
Loading
Loading