Skip to content

Commit ff78dea

Browse files
mergify[bot]srdtrkcolin-axner
authored
imp!: removed 'ConsensusHost' interface (backport #6937) (#7057)
* imp!: removed 'ConsensusHost' interface (#6937) * imp(02-client,03-connection)!: remove `ValidateSelfClient` (#6853) * imp: removed ValidateSelfClient * docs: updated a godoc * imp: deleted consensus host from core * imp(08-wasm): removed consensus host * imp: fix linter * imp: fixed linter * imp: fixed simapp * imp: updated docs * imp: removed more code * revert * imp: removed unneeded proto fields * imp: lint * lint * imp: auto generated code * imp: removed conflicts * imp: removed more code * fix: tests * feat: all tests passing * fix: added the reserved proto fields back with deprecation notice * style: linted * imp: regenerated proto * imp: review item * revert: conn name change * docs: added changelog * add godoc string of QueryConnectionHandshakeProof * add migration docs for ibc-go * Update CHANGELOG.md * update changelog * imp(proto): added deprecation notice to field * imp: ran 'make proto-all' * imp: removed unused keeper * Update CHANGELOG.md Co-authored-by: colin axnér <[email protected]> * Update docs/docs/05-migrations/13-v8-to-v9.md Co-authored-by: colin axnér <[email protected]> * Update docs/docs/05-migrations/13-v8-to-v9.md Co-authored-by: colin axnér <[email protected]> --------- Co-authored-by: Carlos Rodriguez <[email protected]> Co-authored-by: colin axnér <[email protected]> (cherry picked from commit 2028e9a) # Conflicts: # CHANGELOG.md # docs/docs/01-ibc/02-integration.md # docs/docs/05-migrations/13-v8-to-v9.md # modules/core/02-client/keeper/keeper.go # modules/core/keeper/keeper.go # modules/light-clients/08-wasm/CHANGELOG.md * fix merge conflicts, changelog, delete docs, keeper fns --------- Co-authored-by: srdtrk <[email protected]> Co-authored-by: Colin Axnér <[email protected]>
1 parent 98d1edc commit ff78dea

File tree

30 files changed

+219
-1643
lines changed

30 files changed

+219
-1643
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
6767
* (core/types) [\#6794](https://github.com/cosmos/ibc-go/pull/6794) The composite interface `QueryServer` has been removed from package `core/types`. Please use the granular `QueryServer` interfaces provided by each core submodule.
6868
* (light-clients/06-solomachine) [\#6888](https://github.com/cosmos/ibc-go/pull/6888) Remove `TypeClientMisbehaviour` constant and the `Type` method on `Misbehaviour`.
6969
* (light-clients/06-solomachine, light-clients/07-tendermint) [\#6891](https://github.com/cosmos/ibc-go/pull/6891) The `VerifyMembership` and `VerifyNonMembership` functions of solomachine's `ClientState` have been made private. The `VerifyMembership`, `VerifyNonMembership`, `GetTimestampAtHeight`, `Status` and `Initialize` functions of tendermint's `ClientState` have been made private.
70+
* (core/04-channel) [\#6902](https://github.com/cosmos/ibc-go/pull/6902) Add channel version to core application callbacks.
71+
* (core/03-connection, core/02-client) [\#6937](https://github.com/cosmos/ibc-go/pull/6937) Remove 'ConsensusHost' interface, also removing self client and consensus state validation in the connection handshake.
7072
* (core/24-host) [\#6882](https://github.com/cosmos/ibc-go/issues/6882) All functions ending in `Path` have been removed from 24-host in favour of their sybling functions ending in `Key`.
7173

7274
### State Machine Breaking

modules/apps/callbacks/testing/simapp/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ func NewSimApp(
405405
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
406406

407407
app.IBCKeeper = ibckeeper.NewKeeper(
408-
appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), ibctm.NewConsensusHost(app.StakingKeeper), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
408+
appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
409409
)
410410

411411
// NOTE: The mock ContractKeeper is only created for testing.

modules/core/02-client/keeper/keeper.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ type Keeper struct {
2727
storeKey storetypes.StoreKey
2828
cdc codec.BinaryCodec
2929
router *types.Router
30-
consensusHost types.ConsensusHost
3130
legacySubspace types.ParamSubspace
3231
upgradeKeeper types.UpgradeKeeper
3332
}
3433

3534
// NewKeeper creates a new NewKeeper instance
36-
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, consensusHost types.ConsensusHost, uk types.UpgradeKeeper) *Keeper {
35+
func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace types.ParamSubspace, uk types.UpgradeKeeper) *Keeper {
3736
router := types.NewRouter()
3837
localhostModule := localhost.NewLightClientModule(cdc, key)
3938
router.AddRoute(exported.Localhost, localhostModule)
@@ -42,7 +41,6 @@ func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, legacySubspace ty
4241
storeKey: key,
4342
cdc: cdc,
4443
router: router,
45-
consensusHost: consensusHost,
4644
legacySubspace: legacySubspace,
4745
upgradeKeeper: uk,
4846
}
@@ -90,15 +88,6 @@ func (k *Keeper) Route(ctx sdk.Context, clientID string) (exported.LightClientMo
9088
return clientModule, nil
9189
}
9290

93-
// SetConsensusHost sets a custom ConsensusHost for self client state and consensus state validation.
94-
func (k *Keeper) SetConsensusHost(consensusHost types.ConsensusHost) {
95-
if consensusHost == nil {
96-
panic(fmt.Errorf("cannot set a nil self consensus host"))
97-
}
98-
99-
k.consensusHost = consensusHost
100-
}
101-
10291
// GenerateClientIdentifier returns the next client identifier.
10392
func (k *Keeper) GenerateClientIdentifier(ctx sdk.Context, clientType string) string {
10493
nextClientSeq := k.GetNextClientSequence(ctx)
@@ -315,21 +304,6 @@ func (k *Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string)
315304
return k.GetClientConsensusState(ctx, clientID, clientModule.LatestHeight(ctx, clientID))
316305
}
317306

318-
// GetSelfConsensusState introspects the (self) past historical info at a given height
319-
// and returns the expected consensus state at that height.
320-
// For now, can only retrieve self consensus states for the current revision
321-
func (k *Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) (exported.ConsensusState, error) {
322-
return k.consensusHost.GetSelfConsensusState(ctx, height)
323-
}
324-
325-
// ValidateSelfClient validates the client parameters for a client of the running chain.
326-
// This function is only used to validate the client state the counterparty stores for this chain.
327-
// NOTE: If the client type is not of type Tendermint then delegate to a custom client validator function.
328-
// This allows support for non-Tendermint clients, for example 08-wasm clients.
329-
func (k *Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientState) error {
330-
return k.consensusHost.ValidateSelfClient(ctx, clientState)
331-
}
332-
333307
// VerifyMembership retrieves the light client module for the clientID and verifies the proof of the existence of a key-value pair at a specified height.
334308
func (k *Keeper) VerifyMembership(ctx sdk.Context, clientID string, height exported.Height, delayTimePeriod uint64, delayBlockPeriod uint64, proof []byte, path exported.Path, value []byte) error {
335309
clientModule, err := k.Route(ctx, clientID)

modules/core/02-client/types/client.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
errorsmod "cosmossdk.io/errors"
1212

1313
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
14-
sdk "github.com/cosmos/cosmos-sdk/types"
1514

1615
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
1716
"github.com/cosmos/ibc-go/v9/modules/core/exported"
@@ -22,12 +21,6 @@ var (
2221
_ codectypes.UnpackInterfacesMessage = (*ConsensusStateWithHeight)(nil)
2322
)
2423

25-
// ConsensusHost defines an interface used to validate an IBC ClientState and ConsensusState against the host chain's underlying consensus parameters.
26-
type ConsensusHost interface {
27-
GetSelfConsensusState(ctx sdk.Context, height exported.Height) (exported.ConsensusState, error)
28-
ValidateSelfClient(ctx sdk.Context, clientState exported.ClientState) error
29-
}
30-
3124
// NewIdentifiedClientState creates a new IdentifiedClientState instance
3225
func NewIdentifiedClientState(clientID string, clientState exported.ClientState) IdentifiedClientState {
3326
msg, ok := clientState.(proto.Message)

modules/core/02-client/types/expected_keepers.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@ package types
22

33
import (
44
"context"
5-
"time"
65

76
upgradetypes "cosmossdk.io/x/upgrade/types"
87

98
sdk "github.com/cosmos/cosmos-sdk/types"
109
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
11-
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
1210
)
1311

14-
// StakingKeeper expected staking keeper
15-
type StakingKeeper interface {
16-
GetHistoricalInfo(ctx context.Context, height int64) (stakingtypes.HistoricalInfo, error)
17-
UnbondingTime(ctx context.Context) (time.Duration, error)
18-
}
19-
2012
// UpgradeKeeper expected upgrade keeper
2113
type UpgradeKeeper interface {
2214
GetUpgradePlan(ctx context.Context) (plan upgradetypes.Plan, err error)

modules/core/03-connection/keeper/events_test.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ func (suite *KeeperTestSuite) TestMsgConnectionOpenTryEvents() {
4848

4949
suite.Require().NoError(path.EndpointB.UpdateClient())
5050

51-
counterpartyClient, clientProof, consensusProof, consensusHeight, initProof, proofHeight := path.EndpointB.QueryConnectionHandshakeProof()
51+
initProof, proofHeight := path.EndpointB.QueryConnectionHandshakeProof()
5252

5353
msg := types.NewMsgConnectionOpenTry(
5454
path.EndpointB.ClientID, path.EndpointB.Counterparty.ConnectionID, path.EndpointB.Counterparty.ClientID,
55-
counterpartyClient, path.EndpointB.Counterparty.Chain.GetPrefix(), []*types.Version{ibctesting.ConnectionVersion}, path.EndpointB.ConnectionConfig.DelayPeriod,
56-
initProof, clientProof, consensusProof,
57-
proofHeight, consensusHeight,
55+
path.EndpointB.Counterparty.Chain.GetPrefix(), []*types.Version{ibctesting.ConnectionVersion},
56+
path.EndpointB.ConnectionConfig.DelayPeriod, initProof, proofHeight,
5857
path.EndpointB.Chain.SenderAccount.GetAddress().String(),
5958
)
6059

@@ -88,13 +87,11 @@ func (suite *KeeperTestSuite) TestMsgConnectionOpenAckEvents() {
8887

8988
suite.Require().NoError(path.EndpointA.UpdateClient())
9089

91-
counterpartyClient, clientProof, consensusProof, consensusHeight, tryProof, proofHeight := path.EndpointA.QueryConnectionHandshakeProof()
90+
tryProof, proofHeight := path.EndpointA.QueryConnectionHandshakeProof()
9291

9392
msg := types.NewMsgConnectionOpenAck(
94-
path.EndpointA.ConnectionID, path.EndpointA.Counterparty.ConnectionID, counterpartyClient,
95-
tryProof, clientProof, consensusProof,
96-
proofHeight, consensusHeight,
97-
ibctesting.ConnectionVersion,
93+
path.EndpointA.ConnectionID, path.EndpointA.Counterparty.ConnectionID,
94+
tryProof, proofHeight, ibctesting.ConnectionVersion,
9895
path.EndpointA.Chain.SenderAccount.GetAddress().String(),
9996
)
10097

modules/core/03-connection/keeper/handshake.go

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"
1010
"github.com/cosmos/ibc-go/v9/modules/core/03-connection/types"
1111
commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types"
12-
ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors"
1312
"github.com/cosmos/ibc-go/v9/modules/core/exported"
1413
)
1514

@@ -67,37 +66,13 @@ func (k *Keeper) ConnOpenTry(
6766
counterparty types.Counterparty, // counterpartyConnectionIdentifier, counterpartyPrefix and counterpartyClientIdentifier
6867
delayPeriod uint64,
6968
clientID string, // clientID of chainA
70-
clientState exported.ClientState, // clientState that chainA has for chainB
7169
counterpartyVersions []*types.Version, // supported versions of chain A
7270
initProof []byte, // proof that chainA stored connectionEnd in state (on ConnOpenInit)
73-
clientProof []byte, // proof that chainA stored a light client of chainB
74-
consensusProof []byte, // proof that chainA stored chainB's consensus state at consensus height
7571
proofHeight exported.Height, // height at which relayer constructs proof of A storing connectionEnd in state
76-
consensusHeight exported.Height, // latest height of chain B which chain A has stored in its chain B client
7772
) (string, error) {
7873
// generate a new connection
7974
connectionID := k.GenerateConnectionIdentifier(ctx)
8075

81-
// check that the consensus height the counterparty chain is using to store a representation
82-
// of this chain's consensus state is at a height in the past
83-
selfHeight := clienttypes.GetSelfHeight(ctx)
84-
if consensusHeight.GTE(selfHeight) {
85-
return "", errorsmod.Wrapf(
86-
ibcerrors.ErrInvalidHeight,
87-
"consensus height is greater than or equal to the current block height (%s >= %s)", consensusHeight, selfHeight,
88-
)
89-
}
90-
91-
// validate client parameters of a chainB client stored on chainA
92-
if err := k.clientKeeper.ValidateSelfClient(ctx, clientState); err != nil {
93-
return "", err
94-
}
95-
96-
expectedConsensusState, err := k.clientKeeper.GetSelfConsensusState(ctx, consensusHeight)
97-
if err != nil {
98-
return "", errorsmod.Wrapf(err, "self consensus state not found for height %s", consensusHeight.String())
99-
}
100-
10176
// expectedConnection defines Chain A's ConnectionEnd
10277
// NOTE: chain A's counterparty is chain B (i.e where this code is executed)
10378
// NOTE: chainA and chainB must have the same delay period
@@ -124,18 +99,6 @@ func (k *Keeper) ConnOpenTry(
12499
return "", err
125100
}
126101

127-
// Check that ChainA stored the clientState provided in the msg
128-
if err := k.VerifyClientState(ctx, connection, proofHeight, clientProof, clientState); err != nil {
129-
return "", err
130-
}
131-
132-
// Check that ChainA stored the correct ConsensusState of chainB at the given consensusHeight
133-
if err := k.VerifyClientConsensusState(
134-
ctx, connection, proofHeight, consensusHeight, consensusProof, expectedConsensusState,
135-
); err != nil {
136-
return "", err
137-
}
138-
139102
// store connection in chainB state
140103
if err := k.addConnectionToClient(ctx, clientID, connectionID); err != nil {
141104
return "", errorsmod.Wrapf(err, "failed to add connection with ID %s to client with ID %s", connectionID, clientID)
@@ -158,25 +121,11 @@ func (k *Keeper) ConnOpenTry(
158121
func (k *Keeper) ConnOpenAck(
159122
ctx sdk.Context,
160123
connectionID string,
161-
clientState exported.ClientState, // client state for chainA on chainB
162124
version *types.Version, // version that ChainB chose in ConnOpenTry
163125
counterpartyConnectionID string,
164126
tryProof []byte, // proof that connectionEnd was added to ChainB state in ConnOpenTry
165-
clientProof []byte, // proof of client state on chainB for chainA
166-
consensusProof []byte, // proof that chainB has stored ConsensusState of chainA on its client
167127
proofHeight exported.Height, // height that relayer constructed proofTry
168-
consensusHeight exported.Height, // latest height of chainA that chainB has stored on its chainA client
169128
) error {
170-
// check that the consensus height the counterparty chain is using to store a representation
171-
// of this chain's consensus state is at a height in the past
172-
selfHeight := clienttypes.GetSelfHeight(ctx)
173-
if consensusHeight.GTE(selfHeight) {
174-
return errorsmod.Wrapf(
175-
ibcerrors.ErrInvalidHeight,
176-
"consensus height is greater than or equal to the current block height (%s >= %s)", consensusHeight, selfHeight,
177-
)
178-
}
179-
180129
// Retrieve connection
181130
connection, found := k.GetConnection(ctx, connectionID)
182131
if !found {
@@ -199,17 +148,6 @@ func (k *Keeper) ConnOpenAck(
199148
)
200149
}
201150

202-
// validate client parameters of a chainA client stored on chainB
203-
if err := k.clientKeeper.ValidateSelfClient(ctx, clientState); err != nil {
204-
return err
205-
}
206-
207-
// Retrieve chainA's consensus state at consensusheight
208-
expectedConsensusState, err := k.clientKeeper.GetSelfConsensusState(ctx, consensusHeight)
209-
if err != nil {
210-
return errorsmod.Wrapf(err, "self consensus state not found for height %s", consensusHeight.String())
211-
}
212-
213151
prefix := k.GetCommitmentPrefix()
214152
expectedCounterparty := types.NewCounterparty(connection.ClientId, connectionID, commitmenttypes.NewMerklePrefix(prefix.Bytes()))
215153
expectedConnection := types.NewConnectionEnd(types.TRYOPEN, connection.Counterparty.ClientId, expectedCounterparty, []*types.Version{version}, connection.DelayPeriod)
@@ -222,18 +160,6 @@ func (k *Keeper) ConnOpenAck(
222160
return err
223161
}
224162

225-
// Check that ChainB stored the clientState provided in the msg
226-
if err := k.VerifyClientState(ctx, connection, proofHeight, clientProof, clientState); err != nil {
227-
return err
228-
}
229-
230-
// Ensure that ChainB has stored the correct ConsensusState for chainA at the consensusHeight
231-
if err := k.VerifyClientConsensusState(
232-
ctx, connection, proofHeight, consensusHeight, consensusProof, expectedConsensusState,
233-
); err != nil {
234-
return err
235-
}
236-
237163
k.Logger(ctx).Info("connection state updated", "connection-id", connectionID, "previous-state", types.INIT, "new-state", types.OPEN)
238164

239165
defer telemetry.IncrCounter(1, "ibc", "connection", "open-ack")

0 commit comments

Comments
 (0)