Skip to content

Commit 83f1cd1

Browse files
authored
feat: add AppModuleBasic for tendermint client (#2825)
feat: add `AppModuleBasic` for the 07-tendermint client and remove tendermint type registration from core IBC. Chains must register the `AppModuleBasic` of light clients.
1 parent 9720607 commit 83f1cd1

File tree

5 files changed

+81
-4
lines changed

5 files changed

+81
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
115115

116116
### Features
117117

118+
* (light-clients/07-tendermint) [\#2825](https://github.com/cosmos/ibc-go/pull/2825) Add `AppModuleBasic` for the 07-tendermint client and remove tendermint type registration from core IBC. Chains must register the `AppModuleBasic` of light clients.
118119
* (light-clients/07-tendermint) [\#2800](https://github.com/cosmos/ibc-go/pull/2800) Add optional in-place store migration function to prune all expired tendermint consensus states.
119120
* (core/24-host) [\#2820](https://github.com/cosmos/ibc-go/pull/2820) Add `MustParseClientStatePath` which parses the clientID from a client state key path.
120121
* (apps/27-interchain-accounts) [\#2147](https://github.com/cosmos/ibc-go/pull/2147) Adding a `SubmitTx` gRPC endpoint for the ICS27 Controller module which allows owners of interchain accounts to submit transactions. This replaces the previously existing need for authentication modules to implement this standard functionality.

docs/migrations/v6-to-v7.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,32 @@ app.UpgradeKeeper.SetUpgradeHandler(
3939

4040
Checkout the logs to see how many consensus states are pruned.
4141

42+
### Light client registration
43+
44+
Chains must explicitly register the types of any light client modules it wishes to integrate.
45+
46+
#### Tendermint registration
47+
48+
To register the tendermint client, modify the `app.go` file to include the tendermint `AppModuleBasic`:
49+
50+
```diff
51+
import (
52+
...
53+
+ ibctm "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint"
54+
...
55+
)
56+
...
57+
58+
ModuleBasics = module.NewBasicManager(
59+
...
60+
ibc.AppModuleBasic{},
61+
+ ibctm.AppModuleBasic{},
62+
...
63+
)
64+
```
65+
66+
It may be useful to reference the [PR](https://github.com/cosmos/ibc-go/pull/2825) which added the `AppModuleBasic` for the tendermint client.
67+
4268
## IBC Apps
4369

4470
- No relevant changes were made in this release.

modules/core/types/codec.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
99
commitmenttypes "github.com/cosmos/ibc-go/v6/modules/core/23-commitment/types"
1010
solomachine "github.com/cosmos/ibc-go/v6/modules/light-clients/06-solomachine"
11-
ibctm "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint"
1211
)
1312

1413
// RegisterInterfaces registers x/ibc interfaces into protobuf Any.
@@ -17,6 +16,5 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
1716
connectiontypes.RegisterInterfaces(registry)
1817
channeltypes.RegisterInterfaces(registry)
1918
solomachine.RegisterInterfaces(registry)
20-
ibctm.RegisterInterfaces(registry)
2119
commitmenttypes.RegisterInterfaces(registry)
2220
}
Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,56 @@
11
package tendermint
22

3-
// Name returns the IBC client name
4-
func Name() string {
3+
import (
4+
"encoding/json"
5+
6+
"github.com/cosmos/cosmos-sdk/client"
7+
"github.com/cosmos/cosmos-sdk/codec"
8+
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
9+
"github.com/cosmos/cosmos-sdk/types/module"
10+
"github.com/grpc-ecosystem/grpc-gateway/runtime"
11+
"github.com/spf13/cobra"
12+
)
13+
14+
var _ module.AppModuleBasic = AppModuleBasic{}
15+
16+
// AppModuleBasic defines the basic application module used by the tendermint light client.
17+
// Only the RegisterInterfaces function needs to be implemented. All other function perform
18+
// a no-op.
19+
type AppModuleBasic struct{}
20+
21+
// Name returns the tendermint module name.
22+
func (AppModuleBasic) Name() string {
523
return SubModuleName
624
}
25+
26+
// RegisterLegacyAminoCodec performs a no-op. The Tendermint client does not support amino.
27+
func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {}
28+
29+
// RegisterInterfaces registers module concrete types into protobuf Any. This allows core IBC
30+
// to unmarshal tendermint light client types.
31+
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
32+
RegisterInterfaces(registry)
33+
}
34+
35+
// DefaultGenesis performs a no-op. Genesis is not supported for the tendermint light client.
36+
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
37+
return nil
38+
}
39+
40+
// ValidateGenesis performs a no-op. Genesis is not supported for the tendermint light cilent.
41+
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
42+
return nil
43+
}
44+
45+
// RegisterGRPCGatewayRoutes performs a no-op.
46+
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {}
47+
48+
// GetTxCmd performs a no-op. Please see the 02-client cli commands.
49+
func (AppModuleBasic) GetTxCmd() *cobra.Command {
50+
return nil
51+
}
52+
53+
// GetQueryCmd performs a no-op. Please see the 02-client cli commands.
54+
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
55+
return nil
56+
}

testing/simapp/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import (
109109
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
110110
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
111111
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
112+
ibctm "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint"
112113
ibcmock "github.com/cosmos/ibc-go/v6/testing/mock"
113114
simappparams "github.com/cosmos/ibc-go/v6/testing/simapp/params"
114115
simappupgrades "github.com/cosmos/ibc-go/v6/testing/simapp/upgrades"
@@ -153,6 +154,7 @@ var (
153154
crisis.AppModuleBasic{},
154155
slashing.AppModuleBasic{},
155156
ibc.AppModuleBasic{},
157+
ibctm.AppModuleBasic{},
156158
feegrantmodule.AppModuleBasic{},
157159
upgrade.AppModuleBasic{},
158160
evidence.AppModuleBasic{},

0 commit comments

Comments
 (0)