diff --git a/modules/core/02-client/types/params.go b/modules/core/02-client/types/params.go index 81127e5b300..b0c43b156ef 100644 --- a/modules/core/02-client/types/params.go +++ b/modules/core/02-client/types/params.go @@ -11,7 +11,7 @@ import ( var ( // DefaultAllowedClients are the default clients for the AllowedClients parameter. - DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, exported.Wasm, exported.Localhost} + DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, exported.Localhost} // KeyAllowedClients is store's key for AllowedClients Params KeyAllowedClients = []byte("AllowedClients") diff --git a/modules/core/exported/client.go b/modules/core/exported/client.go index 2008fa50b6e..731d7e5edf7 100644 --- a/modules/core/exported/client.go +++ b/modules/core/exported/client.go @@ -19,9 +19,6 @@ const ( // Tendermint is used to indicate that the client uses the Tendermint Consensus Algorithm. Tendermint string = "07-tendermint" - // Wasm is used to indicate that the light client is a on-chain wasm program - Wasm string = "08-wasm" - // Localhost is the client type for the localhost client. Localhost string = "09-localhost" diff --git a/modules/light-clients/08-wasm/keeper/keeper_test.go b/modules/light-clients/08-wasm/keeper/keeper_test.go index 2ddd994de69..8f5d5306765 100644 --- a/modules/light-clients/08-wasm/keeper/keeper_test.go +++ b/modules/light-clients/08-wasm/keeper/keeper_test.go @@ -78,6 +78,8 @@ func (suite *KeeperTestSuite) SetupWasmWithMockVM() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 1) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + + wasmtesting.AllowWasmClients(suite.chainA) } func (suite *KeeperTestSuite) setupWasmWithMockVM() (ibctesting.TestingApp, map[string]json.RawMessage) { diff --git a/modules/light-clients/08-wasm/testing/wasm_endpoint.go b/modules/light-clients/08-wasm/testing/wasm_endpoint.go index d947939771b..a20a27070fe 100644 --- a/modules/light-clients/08-wasm/testing/wasm_endpoint.go +++ b/modules/light-clients/08-wasm/testing/wasm_endpoint.go @@ -50,3 +50,12 @@ func (endpoint *WasmEndpoint) CreateClient() error { return nil } + +// AllowWasmClients adds 08-wasm to the list of allowed clients +func AllowWasmClients(chain *ibctesting.TestChain) { + ctx := chain.GetContext() + clientKeeper := chain.App.GetIBCKeeper().ClientKeeper + params := clientKeeper.GetParams(ctx) + params.AllowedClients = append(params.AllowedClients, types.Wasm) + clientKeeper.SetParams(ctx, params) +} diff --git a/modules/light-clients/08-wasm/types/client_message.go b/modules/light-clients/08-wasm/types/client_message.go index cf7a0b8a12e..06d0f354756 100644 --- a/modules/light-clients/08-wasm/types/client_message.go +++ b/modules/light-clients/08-wasm/types/client_message.go @@ -10,7 +10,7 @@ var _ exported.ClientMessage = &ClientMessage{} // ClientType is a Wasm light client. func (ClientMessage) ClientType() string { - return exported.Wasm + return Wasm } // ValidateBasic defines a basic validation for the wasm client message. diff --git a/modules/light-clients/08-wasm/types/client_message_test.go b/modules/light-clients/08-wasm/types/client_message_test.go index e0d7dd92556..c405e3fe0f8 100644 --- a/modules/light-clients/08-wasm/types/client_message_test.go +++ b/modules/light-clients/08-wasm/types/client_message_test.go @@ -2,7 +2,6 @@ package types_test import ( "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" - "github.com/cosmos/ibc-go/v7/modules/core/exported" ) func (suite *TypesTestSuite) TestClientMessageValidateBasic() { @@ -38,7 +37,7 @@ func (suite *TypesTestSuite) TestClientMessageValidateBasic() { suite.Run(tc.name, func() { clientMessage := tc.clientMessage - suite.Require().Equal(exported.Wasm, clientMessage.ClientType()) + suite.Require().Equal(types.Wasm, clientMessage.ClientType()) err := clientMessage.ValidateBasic() if tc.expPass { diff --git a/modules/light-clients/08-wasm/types/client_state.go b/modules/light-clients/08-wasm/types/client_state.go index 1f52afcf701..b988dda5853 100644 --- a/modules/light-clients/08-wasm/types/client_state.go +++ b/modules/light-clients/08-wasm/types/client_state.go @@ -27,7 +27,7 @@ func NewClientState(data []byte, checksum []byte, height clienttypes.Height) *Cl // ClientType is Wasm light client. func (ClientState) ClientType() string { - return exported.Wasm + return Wasm } // GetLatestHeight returns latest block height. diff --git a/modules/light-clients/08-wasm/types/consensus_state.go b/modules/light-clients/08-wasm/types/consensus_state.go index 08d34c850de..30a81e89efe 100644 --- a/modules/light-clients/08-wasm/types/consensus_state.go +++ b/modules/light-clients/08-wasm/types/consensus_state.go @@ -17,7 +17,7 @@ func NewConsensusState(data []byte) *ConsensusState { // ClientType returns Wasm type. func (ConsensusState) ClientType() string { - return exported.Wasm + return Wasm } // GetTimestamp returns block time in nanoseconds of the header that created consensus state. diff --git a/modules/light-clients/08-wasm/types/consensus_state_test.go b/modules/light-clients/08-wasm/types/consensus_state_test.go index 088ce765329..76a75be6525 100644 --- a/modules/light-clients/08-wasm/types/consensus_state_test.go +++ b/modules/light-clients/08-wasm/types/consensus_state_test.go @@ -2,7 +2,6 @@ package types_test import ( "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" - "github.com/cosmos/ibc-go/v7/modules/core/exported" ) func (suite *TypesTestSuite) TestConsensusStateValidateBasic() { @@ -31,7 +30,7 @@ func (suite *TypesTestSuite) TestConsensusStateValidateBasic() { for _, tc := range testCases { suite.Run(tc.name, func() { // check just to increase coverage - suite.Require().Equal(exported.Wasm, tc.consensusState.ClientType()) + suite.Require().Equal(types.Wasm, tc.consensusState.ClientType()) err := tc.consensusState.ValidateBasic() if tc.expectPass { diff --git a/modules/light-clients/08-wasm/types/keys.go b/modules/light-clients/08-wasm/types/keys.go index 44e1bfd5420..7d64d50f2bb 100644 --- a/modules/light-clients/08-wasm/types/keys.go +++ b/modules/light-clients/08-wasm/types/keys.go @@ -7,6 +7,9 @@ const ( // StoreKey is the store key string for 08-wasm StoreKey = ModuleName + // Wasm is the client type for IBC light clients created using 08-wasm + Wasm = ModuleName + // KeyChecksums is the key under which all checksums are stored KeyChecksums = "checksums" ) diff --git a/modules/light-clients/08-wasm/types/types_test.go b/modules/light-clients/08-wasm/types/types_test.go index 182a72fa308..051b5815a95 100644 --- a/modules/light-clients/08-wasm/types/types_test.go +++ b/modules/light-clients/08-wasm/types/types_test.go @@ -79,6 +79,8 @@ func (suite *TypesTestSuite) SetupWasmWithMockVM() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 1) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.checksum = storeWasmCode(suite, wasmtesting.Code) + + wasmtesting.AllowWasmClients(suite.chainA) } func (suite *TypesTestSuite) setupWasmWithMockVM() (ibctesting.TestingApp, map[string]json.RawMessage) { diff --git a/modules/light-clients/08-wasm/types/validation.go b/modules/light-clients/08-wasm/types/validation.go index 3b42341f14c..f76afd6897f 100644 --- a/modules/light-clients/08-wasm/types/validation.go +++ b/modules/light-clients/08-wasm/types/validation.go @@ -7,7 +7,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - "github.com/cosmos/ibc-go/v7/modules/core/exported" ) const maxWasmSize = 3 * 1024 * 1024 @@ -50,8 +49,8 @@ func ValidateClientID(clientID string) error { return errorsmod.Wrapf(host.ErrInvalidID, "invalid client identifier %s", clientID) } - if !strings.HasPrefix(clientID, exported.Wasm) { - return errorsmod.Wrapf(host.ErrInvalidID, "client identifier %s does not contain %s prefix", clientID, exported.Wasm) + if !strings.HasPrefix(clientID, Wasm) { + return errorsmod.Wrapf(host.ErrInvalidID, "client identifier %s does not contain %s prefix", clientID, Wasm) } return nil diff --git a/modules/light-clients/08-wasm/types/validation_test.go b/modules/light-clients/08-wasm/types/validation_test.go index f16fdd32231..1c568d29340 100644 --- a/modules/light-clients/08-wasm/types/validation_test.go +++ b/modules/light-clients/08-wasm/types/validation_test.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v7/testing" wasmtesting "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing" @@ -144,7 +143,7 @@ func TestValidateClientID(t *testing.T) { func() { clientID = ibctesting.FirstClientID }, - errorsmod.Wrapf(host.ErrInvalidID, "client identifier %s does not contain %s prefix", ibctesting.FirstClientID, exported.Wasm), + errorsmod.Wrapf(host.ErrInvalidID, "client identifier %s does not contain %s prefix", ibctesting.FirstClientID, types.Wasm), }, }