Skip to content

Commit

Permalink
fix: remove 08-wasm from 02-client exported (#5306)
Browse files Browse the repository at this point in the history
* fix: remove 08-wasm from 02-client exported

* fix grandpa test

* add function to add 08-wasm to allowed clients

* e2e: add gov proposal to add 08-wasm client to list of allowed clients

* use cosmos chain when querying gov module address

* make functions for querying allowed clients and to add 08-wasm

* Update modules/light-clients/08-wasm/types/validation.go

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>

* Update modules/light-clients/08-wasm/types/keys.go

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

* Update keys.go

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
(cherry picked from commit e3ab9be)

# Conflicts:
#	e2e/tests/wasm/grandpa_test.go
#	modules/core/02-client/types/params.go
#	modules/light-clients/08-wasm/types/client_message_test.go
#	modules/light-clients/08-wasm/types/consensus_state_test.go
#	modules/light-clients/08-wasm/types/keys.go
#	modules/light-clients/08-wasm/types/validation.go
#	modules/light-clients/08-wasm/types/validation_test.go
  • Loading branch information
crodriguezvega authored and mergify[bot] committed Dec 5, 2023
1 parent d8b03ea commit 1877c82
Show file tree
Hide file tree
Showing 14 changed files with 879 additions and 11 deletions.
832 changes: 832 additions & 0 deletions e2e/tests/wasm/grandpa_test.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions modules/core/02-client/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/cosmos/ibc-go/v7/modules/core/exported"
)

<<<<<<< HEAD

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

syntax error: non-declaration statement outside function body

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

syntax error: non-declaration statement outside function body

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body

Check failure on line 12 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body
var (
// DefaultAllowedClients are the default clients for the AllowedClients parameter.
DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, exported.Wasm, exported.Localhost}
Expand All @@ -21,6 +22,10 @@ var (
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
=======

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

syntax error: non-declaration statement outside function body

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

syntax error: non-declaration statement outside function body

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body

Check failure on line 25 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body
// DefaultAllowedClients are the default clients for the AllowedClients parameter.
var DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint, exported.Localhost}
>>>>>>> e3ab9bec (fix: remove 08-wasm from 02-client exported (#5306))

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

syntax error: non-declaration statement outside function body

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

invalid digit '8' in octal literal

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (arm64)

invalid character U+0023 '#'

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

syntax error: non-declaration statement outside function body

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

invalid digit '8' in octal literal

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / build (amd64)

invalid character U+0023 '#'

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid digit '8' in octal literal

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid character U+0023 '#'

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: non-declaration statement outside function body

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid digit '8' in octal literal

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (02)

invalid character U+0023 '#'

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: non-declaration statement outside function body

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid digit '8' in octal literal

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (03)

invalid character U+0023 '#'

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: non-declaration statement outside function body

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid digit '8' in octal literal

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (00)

invalid character U+0023 '#'

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: non-declaration statement outside function body

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid digit '8' in octal literal

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / tests (01)

invalid character U+0023 '#'

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / lint

invalid digit '8' in octal literal

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / lint

invalid character U+0023 '#') (typecheck)

Check failure on line 28 in modules/core/02-client/types/params.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body

// NewParams creates a new parameter configuration for the ibc client module
func NewParams(allowedClients ...string) Params {
Expand Down
3 changes: 0 additions & 3 deletions modules/core/exported/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions modules/light-clients/08-wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions modules/light-clients/08-wasm/testing/wasm_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/types/client_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion modules/light-clients/08-wasm/types/client_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package types_test

import (
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
<<<<<<< HEAD
"github.com/cosmos/ibc-go/v7/modules/core/exported"
=======
>>>>>>> e3ab9bec (fix: remove 08-wasm from 02-client exported (#5306))
)

func (suite *TypesTestSuite) TestClientMessageValidateBasic() {
Expand Down Expand Up @@ -38,7 +41,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 {
Expand Down
2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/types/consensus_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion modules/light-clients/08-wasm/types/consensus_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package types_test

import (
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
<<<<<<< HEAD
"github.com/cosmos/ibc-go/v7/modules/core/exported"
=======
>>>>>>> e3ab9bec (fix: remove 08-wasm from 02-client exported (#5306))
)

func (suite *TypesTestSuite) TestConsensusStateValidateBasic() {
Expand Down Expand Up @@ -31,7 +34,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 {
Expand Down
5 changes: 5 additions & 0 deletions modules/light-clients/08-wasm/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const (
// StoreKey is the store key string for 08-wasm
StoreKey = ModuleName

<<<<<<< HEAD
// KeyChecksums is the key under which all checksums are stored
KeyChecksums = "checksums"
=======
// Wasm is the client type for IBC light clients created using 08-wasm
Wasm = ModuleName
>>>>>>> e3ab9bec (fix: remove 08-wasm from 02-client exported (#5306))
)
2 changes: 2 additions & 0 deletions modules/light-clients/08-wasm/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions modules/light-clients/08-wasm/types/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import (

errorsmod "cosmossdk.io/errors"

<<<<<<< HEAD
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"
=======
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
>>>>>>> e3ab9bec (fix: remove 08-wasm from 02-client exported (#5306))
)

const maxWasmSize = 3 * 1024 * 1024
Expand Down Expand Up @@ -50,8 +55,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
Expand Down
7 changes: 6 additions & 1 deletion modules/light-clients/08-wasm/types/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import (
errorsmod "cosmossdk.io/errors"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
<<<<<<< HEAD
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"
=======
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
>>>>>>> e3ab9bec (fix: remove 08-wasm from 02-client exported (#5306))
)

func TestValidateWasmCode(t *testing.T) {
Expand Down Expand Up @@ -144,7 +149,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),
},
}

Expand Down

0 comments on commit 1877c82

Please sign in to comment.