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

feat: add AppModuleBasic for solo machine client #2826

Merged
merged 8 commits into from
Nov 29, 2022
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* (light-clients/06-solomachine) [\#2826](https://github.com/cosmos/ibc-go/pull/2826) Add `AppModuleBasic` for the 06-solomachine client and remove solo machine type registration from core IBC. Chains must register the `AppModuleBasic` of light clients.
* (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.
* (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.
* (core/24-host) [\#2820](https://github.com/cosmos/ibc-go/pull/2820) Add `MustParseClientStatePath` which parses the clientID from a client state key path.
Expand Down
28 changes: 25 additions & 3 deletions docs/migrations/v6-to-v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ To register the tendermint client, modify the `app.go` file to include the tende

```diff
import (
...
// ...
+ ibctm "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint"
...
)
...

// ...

ModuleBasics = module.NewBasicManager(
...
Expand All @@ -65,6 +65,28 @@ ModuleBasics = module.NewBasicManager(

It may be useful to reference the [PR](https://github.com/cosmos/ibc-go/pull/2825) which added the `AppModuleBasic` for the tendermint client.

#### Solo machine registration

To register the solo machine client, modify the `app.go` file to include the solo machine `AppModuleBasic`:

```diff
import (
// ...
+ solomachine "github.com/cosmos/ibc-go/v6/modules/light-clients/06-solomachine"
)

// ...

ModuleBasics = module.NewBasicManager(
...
ibc.AppModuleBasic{},
+ solomachine.AppModuleBasic{},
...
)
```

It may be useful to reference the [PR](https://github.com/cosmos/ibc-go/pull/2826) which added the `AppModuleBasic` for the solo machine client.

## IBC Apps

- No relevant changes were made in this release.
Expand Down
2 changes: 0 additions & 2 deletions modules/core/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import (
connectiontypes "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v6/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/v6/modules/core/23-commitment/types"
solomachine "github.com/cosmos/ibc-go/v6/modules/light-clients/06-solomachine"
)

// RegisterInterfaces registers x/ibc interfaces into protobuf Any.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
clienttypes.RegisterInterfaces(registry)
connectiontypes.RegisterInterfaces(registry)
channeltypes.RegisterInterfaces(registry)
solomachine.RegisterInterfaces(registry)
commitmenttypes.RegisterInterfaces(registry)
}
54 changes: 52 additions & 2 deletions modules/light-clients/06-solomachine/module.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
package solomachine

// Name returns the solo machine client name.
func Name() string {
import (
"encoding/json"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
)

var _ module.AppModuleBasic = AppModuleBasic{}

// AppModuleBasic defines the basic application module used by the solo machine light client.
// Only the RegisterInterfaces function needs to be implemented. All other function perform
// a no-op.
type AppModuleBasic struct{}

// Name returns the solo machine module name.
func (AppModuleBasic) Name() string {
return SubModuleName
}

// RegisterLegacyAminoCodec performs a no-op. The solo machine client does not support amino.
func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {}

// RegisterInterfaces registers module concrete types into protobuf Any. This allows core IBC
// to unmarshal solo machine types.
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
RegisterInterfaces(registry)
}

// DefaultGenesis performs a no-op. Genesis is not supported for solo machine.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return nil
}

// ValidateGenesis performs a no-op. Genesis is not supported for solo machine.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
return nil
}

// RegisterGRPCGatewayRoutes performs a no-op.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {}

// GetTxCmd performs a no-op. Please see the 02-client cli commands.
func (AppModuleBasic) GetTxCmd() *cobra.Command {
return nil
}

// GetQueryCmd performs a no-op. Please see the 02-client cli commands.
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
return nil
}
2 changes: 2 additions & 0 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import (
porttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
solomachine "github.com/cosmos/ibc-go/v6/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint"
ibcmock "github.com/cosmos/ibc-go/v6/testing/mock"
simappparams "github.com/cosmos/ibc-go/v6/testing/simapp/params"
Expand Down Expand Up @@ -155,6 +156,7 @@ var (
slashing.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctm.AppModuleBasic{},
solomachine.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
Expand Down