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

fix: rm dependency on 08-wasm in ibc-go #4801

Merged
merged 12 commits into from
Oct 4, 2023
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ To report a security vulnerability, see our [Coordinated Vulnerability Disclosur

The following audits have been performed on the `ibc-go` source code:

- [ICS27 Interchain Accounts](https://github.com/cosmos/ibc-go/tree/main/docs/apps/interchain-accounts/audits) by Trail of Bits
- [ICS27 Interchain Accounts](https://github.com/cosmos/ibc-go/blob/main/docs/audits/Trail%20of%20Bits%20audit%20-%20Final%20Report.pdf) by Trail of Bits

## Quick Navigation

Expand Down
6 changes: 1 addition & 5 deletions go.mod
charleenfei marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/cosmos/cosmos-sdk v0.47.5
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-go/modules/capability v1.0.0-rc1
github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0
github.com/cosmos/ics23/go v0.10.0
github.com/golang/protobuf v1.5.3
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand Down Expand Up @@ -41,7 +40,6 @@ require (
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/CosmWasm/wasmvm v1.2.4 // indirect
github.com/aws/aws-sdk-go v1.44.203 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
Expand Down Expand Up @@ -176,6 +174,4 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

replace github.com/cosmos/ibc-go/modules/light-clients/08-wasm => ./modules/light-clients/08-wasm
replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/CosmWasm/wasmvm v1.2.4 h1:6OfeZuEcEH/9iqwrg2pkeVtDCkMoj9U6PpKtcrCyVrQ=
github.com/CosmWasm/wasmvm v1.2.4/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
Expand Down
23 changes: 2 additions & 21 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/cometbft/cometbft/libs/log"
"github.com/cometbft/cometbft/light"

wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
"github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
Expand Down Expand Up @@ -258,7 +257,7 @@ func (k Keeper) GetLatestClientConsensusState(ctx sdk.Context, clientID string)
// GetSelfConsensusState introspects the (self) past historical info at a given height
// and returns the expected consensus state at that height.
// For now, can only retrieve self consensus states for the current revision
func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height, clientType string) (exported.ConsensusState, error) {
func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height) (exported.ConsensusState, error) {
selfHeight, ok := height.(types.Height)
if !ok {
return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "expected %T, got %T", types.Height{}, height)
Expand All @@ -273,22 +272,11 @@ func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height, c
return nil, errorsmod.Wrapf(ibcerrors.ErrNotFound, "no historical info found at height %d", selfHeight.RevisionHeight)
}

tmConsensusState := &ibctm.ConsensusState{
consensusState := &ibctm.ConsensusState{
Timestamp: histInfo.Header.Time,
Root: commitmenttypes.NewMerkleRoot(histInfo.Header.GetAppHash()),
NextValidatorsHash: histInfo.Header.NextValidatorsHash,
}
var consensusState exported.ConsensusState
consensusState = tmConsensusState
if clientType == exported.Wasm {
wasmData, err := k.cdc.MarshalInterface(tmConsensusState)
if err != nil {
return nil, errorsmod.Wrapf(ibcerrors.ErrInvalidType, "cannot marshal tendermint consensus state")
}
consensusState = &wasmtypes.ConsensusState{
Data: wasmData,
}
}

return consensusState, nil
}
Expand All @@ -297,13 +285,6 @@ func (k Keeper) GetSelfConsensusState(ctx sdk.Context, height exported.Height, c
// This function is only used to validate the client state the counterparty stores for this chain
// Client must be in same revision as the executing chain
func (k Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientState) error {
if clientState.ClientType() == exported.Wasm {
wasmClientState := clientState.(*wasmtypes.ClientState)
err := k.cdc.UnmarshalInterface(wasmClientState.Data, &clientState)
if err != nil {
return errorsmod.Wrapf(types.ErrInvalidClient, "cannot unmarshal wasm client state data")
}
}
tmClient, ok := clientState.(*ibctm.ClientState)
if !ok {
return errorsmod.Wrapf(types.ErrInvalidClient, "client must be a Tendermint client, expected: %T, got: %T",
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() { //nolint:govet // this is

for i, tc := range cases {
tc := tc
cs, err := suite.keeper.GetSelfConsensusState(suite.ctx, tc.height, exported.Tendermint)
cs, err := suite.keeper.GetSelfConsensusState(suite.ctx, tc.height)
if tc.expPass {
suite.Require().NoError(err, "Case %d should have passed: %s", i, tc.name)
suite.Require().NotNil(cs, "Case %d should have passed: %s", i, tc.name)
Expand Down
4 changes: 2 additions & 2 deletions modules/core/03-connection/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (k Keeper) ConnOpenTry(
return "", err
}

expectedConsensusState, err := k.clientKeeper.GetSelfConsensusState(ctx, consensusHeight, clientState.ClientType())
expectedConsensusState, err := k.clientKeeper.GetSelfConsensusState(ctx, consensusHeight)
if err != nil {
return "", errorsmod.Wrapf(err, "self consensus state not found for height %s", consensusHeight.String())
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func (k Keeper) ConnOpenAck(
}

// Retrieve chainA's consensus state at consensusheight
expectedConsensusState, err := k.clientKeeper.GetSelfConsensusState(ctx, consensusHeight, clientState.ClientType())
expectedConsensusState, err := k.clientKeeper.GetSelfConsensusState(ctx, consensusHeight)
if err != nil {
return errorsmod.Wrapf(err, "self consensus state not found for height %s", consensusHeight.String())
}
Expand Down
3 changes: 1 addition & 2 deletions modules/core/03-connection/keeper/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() {
tc.malleate()

connection := path.EndpointA.GetConnection()
clientState := suite.chainB.GetClientState(path.EndpointB.ClientID)
proof, consensusHeight := suite.chainB.QueryConsensusStateProof(path.EndpointB.ClientID)
proofHeight := clienttypes.NewHeight(1, uint64(suite.chainB.GetContext().BlockHeight()-1))
consensusState, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetSelfConsensusState(suite.chainA.GetContext(), consensusHeight, clientState.ClientType())
consensusState, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetSelfConsensusState(suite.chainA.GetContext(), consensusHeight)
suite.Require().NoError(err)

err = suite.chainA.App.GetIBCKeeper().ConnectionKeeper.VerifyClientConsensusState(
Expand Down
2 changes: 1 addition & 1 deletion modules/core/03-connection/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ClientKeeper interface {
GetClientStatus(ctx sdk.Context, clientState exported.ClientState, clientID string) exported.Status
GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool)
GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool)
GetSelfConsensusState(ctx sdk.Context, height exported.Height, clientType string) (exported.ConsensusState, error)
GetSelfConsensusState(ctx sdk.Context, height exported.Height) (exported.ConsensusState, error)
ValidateSelfClient(ctx sdk.Context, clientState exported.ClientState) error
IterateClientStates(ctx sdk.Context, prefix []byte, cb func(string, exported.ClientState) bool)
ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore
Expand Down
Loading
Loading