Skip to content

Commit

Permalink
Merge branch 'feat/wasm-clients' into cian/issue#5090-run-wasm-e2e-te…
Browse files Browse the repository at this point in the history
…sts-only-when-relevant-changes-are-made
  • Loading branch information
chatton authored Nov 16, 2023
2 parents 5740dea + c983119 commit eadd1d6
Show file tree
Hide file tree
Showing 58 changed files with 720 additions and 720 deletions.
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ require (
github.com/hashicorp/go-getter v1.7.1 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.1 // indirect
github.com/hashicorp/go-metrics v0.5.2 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-metrics v0.5.2 h1:ErEYO2f//CjKsUDw4SmLzelsK6L3ZmOAR/4P9iS7ruY=
github.com/hashicorp/go-metrics v0.5.2/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y=
Expand Down
Binary file modified e2e/tests/data/ics10_grandpa_cw.wasm
100644 → 100755
Binary file not shown.
56 changes: 28 additions & 28 deletions e2e/tests/wasm/grandpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ func (s *GrandpaTestSuite) TestMsgTransfer_Succeeds_GrandpaContract() {
file, err := os.Open("../data/ics10_grandpa_cw.wasm")
s.Require().NoError(err)

codeHash := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, file)
checksum := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, file)

s.Require().NotEmpty(codeHash, "codehash was empty but should not have been")
s.Require().NotEmpty(checksum, "checksum was empty but should not have been")

eRep := s.GetRelayerExecReporter()

// Set client contract hash in cosmos chain config
err = r.SetClientContractHash(ctx, eRep, cosmosChain.Config(), codeHash)
err = r.SetClientContractHash(ctx, eRep, cosmosChain.Config(), checksum)
s.Require().NoError(err)

// Ensure parachain has started (starts 1 session/epoch after relay chain)
Expand Down Expand Up @@ -237,14 +237,14 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_Success_GrandpaContract() {
file, err := os.Open("../data/ics10_grandpa_cw.wasm")
s.Require().NoError(err)

codeHash := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, file)
checksum := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, file)

s.Require().NotEmpty(codeHash, "codehash was empty but should not have been")
s.Require().NotEmpty(checksum, "checksum was empty but should not have been")

eRep := s.GetRelayerExecReporter()

// Set client contract hash in cosmos chain config
err = r.SetClientContractHash(ctx, eRep, cosmosChain.Config(), codeHash)
err = r.SetClientContractHash(ctx, eRep, cosmosChain.Config(), checksum)
s.Require().NoError(err)

// Ensure parachain has started (starts 1 session/epoch after relay chain)
Expand All @@ -270,17 +270,17 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_Success_GrandpaContract() {
s.Require().NoError(err)

// First Store the code
newCodeHash := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, migrateFile)
s.Require().NotEmpty(newCodeHash, "codehash was empty but should not have been")
newChecksum := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, migrateFile)
s.Require().NotEmpty(newChecksum, "checksum was empty but should not have been")

newCodeHashBz, err := hex.DecodeString(newCodeHash)
newChecksumBz, err := hex.DecodeString(newChecksum)
s.Require().NoError(err)

// Attempt to migrate the contract
message := wasmtypes.NewMsgMigrateContract(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
defaultWasmClientID,
newCodeHashBz,
newChecksumBz,
[]byte("{}"),
)

Expand All @@ -292,7 +292,7 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_Success_GrandpaContract() {
wasmClientState, ok := clientState.(*wasmtypes.ClientState)
s.Require().True(ok)

s.Require().Equal(newCodeHashBz, wasmClientState.CodeHash)
s.Require().Equal(newChecksumBz, wasmClientState.Checksum)
}

// TestMsgMigrateContract_ContractError_GrandpaContract features
Expand Down Expand Up @@ -324,14 +324,14 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_ContractError_GrandpaContract(
file, err := os.Open("../data/ics10_grandpa_cw.wasm")
s.Require().NoError(err)

codeHash := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, file)
checksum := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, file)

s.Require().NotEmpty(codeHash, "codehash was empty but should not have been")
s.Require().NotEmpty(checksum, "checksum was empty but should not have been")

eRep := s.GetRelayerExecReporter()

// Set client contract hash in cosmos chain config
err = r.SetClientContractHash(ctx, eRep, cosmosChain.Config(), codeHash)
err = r.SetClientContractHash(ctx, eRep, cosmosChain.Config(), checksum)
s.Require().NoError(err)

// Ensure parachain has started (starts 1 session/epoch after relay chain)
Expand All @@ -357,17 +357,17 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_ContractError_GrandpaContract(
s.Require().NoError(err)

// First Store the code
newCodeHash := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, migrateFile)
s.Require().NotEmpty(newCodeHash, "codehash was empty but should not have been")
newChecksum := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, migrateFile)
s.Require().NotEmpty(newChecksum, "checksum was empty but should not have been")

newCodeHashBz, err := hex.DecodeString(newCodeHash)
newChecksumBz, err := hex.DecodeString(newChecksum)
s.Require().NoError(err)

// Attempt to migrate the contract
message := wasmtypes.NewMsgMigrateContract(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
defaultWasmClientID,
newCodeHashBz,
newChecksumBz,
[]byte("{}"),
)

Expand All @@ -376,21 +376,21 @@ func (s *GrandpaTestSuite) TestMsgMigrateContract_ContractError_GrandpaContract(
s.Require().ErrorContains(err, "migration not supported")
}

// extractCodeHashFromGzippedContent takes a gzipped wasm contract and returns the codehash.
func (s *GrandpaTestSuite) extractCodeHashFromGzippedContent(zippedContent []byte) string {
// extractChecksumFromGzippedContent takes a gzipped wasm contract and returns the checksum.
func (s *GrandpaTestSuite) extractChecksumFromGzippedContent(zippedContent []byte) string {
content, err := wasmtypes.Uncompress(zippedContent, wasmtypes.MaxWasmByteSize())
s.Require().NoError(err)

codeHashByte32 := sha256.Sum256(content)
return hex.EncodeToString(codeHashByte32[:])
checksum32 := sha256.Sum256(content)
return hex.EncodeToString(checksum32[:])
}

// PushNewWasmClientProposal submits a new wasm client governance proposal to the chain.
func (s *GrandpaTestSuite) PushNewWasmClientProposal(ctx context.Context, chain *cosmos.CosmosChain, wallet ibc.Wallet, proposalContentReader io.Reader) string {
zippedContent, err := io.ReadAll(proposalContentReader)
s.Require().NoError(err)

computedCodeHash := s.extractCodeHashFromGzippedContent(zippedContent)
computedChecksum := s.extractChecksumFromGzippedContent(zippedContent)

s.Require().NoError(err)
message := wasmtypes.MsgStoreCode{
Expand All @@ -400,14 +400,14 @@ func (s *GrandpaTestSuite) PushNewWasmClientProposal(ctx context.Context, chain

s.ExecuteAndPassGovV1Proposal(ctx, &message, chain, wallet)

codeHashBz, err := s.QueryWasmCode(ctx, chain, computedCodeHash)
checksumBz, err := s.QueryWasmCode(ctx, chain, computedChecksum)
s.Require().NoError(err)

codeHashByte32 := sha256.Sum256(codeHashBz)
actualCodeHash := hex.EncodeToString(codeHashByte32[:])
s.Require().Equal(computedCodeHash, actualCodeHash, "code hash returned from query did not match the computed code hash")
checksum32 := sha256.Sum256(checksumBz)
actualChecksum := hex.EncodeToString(checksum32[:])
s.Require().Equal(computedChecksum, actualChecksum, "checksum returned from query did not match the computed checksum")

return actualCodeHash
return actualChecksum
}

func (s *GrandpaTestSuite) fundUsers(ctx context.Context, fundAmount int64, polkadotChain ibc.Chain, cosmosChain ibc.Chain) (ibc.Wallet, ibc.Wallet) {
Expand Down
4 changes: 2 additions & 2 deletions e2e/testsuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ func (s *E2ETestSuite) QueryDenomMetadata(ctx context.Context, chain ibc.Chain,
}

// QueryWasmCode queries the code for a wasm contract.
func (s *E2ETestSuite) QueryWasmCode(ctx context.Context, chain ibc.Chain, codehash string) ([]byte, error) {
func (s *E2ETestSuite) QueryWasmCode(ctx context.Context, chain ibc.Chain, checksum string) ([]byte, error) {
queryClient := s.GetChainGRCPClients(chain).WasmQueryClient
queryRequest := &wasmtypes.QueryCodeRequest{
CodeHash: codehash,
Checksum: checksum,
}
res, err := queryClient.Code(ctx, queryRequest)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/cosmos/ics23/go v0.10.0
github.com/golang/protobuf v1.5.3
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-metrics v0.5.1
github.com/hashicorp/go-metrics v0.5.2
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-metrics v0.5.2 h1:ErEYO2f//CjKsUDw4SmLzelsK6L3ZmOAR/4P9iS7ruY=
github.com/hashicorp/go-metrics v0.5.2/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y=
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/callbacks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ require (
github.com/hashicorp/go-getter v1.7.1 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.1 // indirect
github.com/hashicorp/go-metrics v0.5.2 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/callbacks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-metrics v0.5.2 h1:ErEYO2f//CjKsUDw4SmLzelsK6L3ZmOAR/4P9iS7ruY=
github.com/hashicorp/go-metrics v0.5.2/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y=
Expand Down
2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func GetQueryCmd() *cobra.Command {

queryCmd.AddCommand(
getCmdCode(),
getCmdCodeHashes(),
getCmdChecksums(),
)

return queryCmd
Expand Down
28 changes: 14 additions & 14 deletions modules/light-clients/08-wasm/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import (
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
)

// getCmdCode defines the command to query wasm code for given code hash.
// getCmdCode defines the command to query wasm code for given checksum.
func getCmdCode() *cobra.Command {
cmd := &cobra.Command{
Use: "code [code-hash]",
Use: "code [checksum]",
Short: "Query wasm code",
Long: "Query wasm code for a light client wasm contract with a given code hash",
Example: fmt.Sprintf("%s query %s wasm code [code-hash]", version.AppName, ibcexported.ModuleName),
Long: "Query wasm code for a light client wasm contract with a given checksum",
Example: fmt.Sprintf("%s query %s wasm code [checksum]", version.AppName, ibcexported.ModuleName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
Expand All @@ -29,9 +29,9 @@ func getCmdCode() *cobra.Command {
}
queryClient := types.NewQueryClient(clientCtx)

codeHash := args[0]
checksum := args[0]
req := types.QueryCodeRequest{
CodeHash: codeHash,
Checksum: checksum,
}

res, err := queryClient.Code(context.Background(), &req)
Expand All @@ -48,23 +48,23 @@ func getCmdCode() *cobra.Command {
return cmd
}

// getCmdCodeHashes defines the command to query all wasm code hashes.
func getCmdCodeHashes() *cobra.Command {
// getCmdChecksums defines the command to query all wasm checksums.
func getCmdChecksums() *cobra.Command {
cmd := &cobra.Command{
Use: "code-hashes",
Short: "Query all code hashes",
Long: "Query all code hashes for all deployed light client wasm contracts",
Example: fmt.Sprintf("%s query %s wasm code-hashes", version.AppName, ibcexported.ModuleName),
Use: "checksums",
Short: "Query all checksums",
Long: "Query all checksums for all deployed light client wasm contracts",
Example: fmt.Sprintf("%s query %s wasm checksums", version.AppName, ibcexported.ModuleName),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
req := types.QueryCodeHashesRequest{}
req := types.QueryChecksumsRequest{}

res, err := queryClient.CodeHashes(context.Background(), &req)
res, err := queryClient.Checksums(context.Background(), &req)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ require (
github.com/hashicorp/go-getter v1.7.1 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.1 // indirect
github.com/hashicorp/go-metrics v0.5.2 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions modules/light-clients/08-wasm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-metrics v0.5.2 h1:ErEYO2f//CjKsUDw4SmLzelsK6L3ZmOAR/4P9iS7ruY=
github.com/hashicorp/go-metrics v0.5.2/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type WasmEngine interface {
) ([]byte, uint64, error)

// Migrate migrates an existing contract to a new code binary.
// This takes storage of the data from the original contract and the code hash of the new contract that should
// This takes storage of the data from the original contract and the checksum of the new contract that should
// replace it. This allows it to run a migration step if needed, or return an error if unable to migrate
// the given data.
//
Expand Down
10 changes: 5 additions & 5 deletions modules/light-clients/08-wasm/internal/ibcwasm/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ var (
vm WasmEngine

// state management
Schema collections.Schema
CodeHashes collections.KeySet[[]byte]
Schema collections.Schema
Checksums collections.KeySet[[]byte]

// CodeHashesKey is the key under which all code hashes are stored
CodeHashesKey = collections.NewPrefix(0)
// ChecksumsKey is the key under which all checksums are stored
ChecksumsKey = collections.NewPrefix(0)
)

// SetVM sets the wasm VM for the 08-wasm module.
Expand All @@ -36,7 +36,7 @@ func GetVM() WasmEngine {
func SetupWasmStoreService(storeService storetypes.KVStoreService) {
sb := collections.NewSchemaBuilder(storeService)

CodeHashes = collections.NewKeySet(sb, CodeHashesKey, "code_hashes", collections.BytesKey)
Checksums = collections.NewKeySet(sb, ChecksumsKey, "checksums", collections.BytesKey)

schema, err := sb.Build()
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions modules/light-clients/08-wasm/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
)

// emitStoreWasmCodeEvent emits a store wasm code event
func emitStoreWasmCodeEvent(ctx sdk.Context, codeHash []byte) {
func emitStoreWasmCodeEvent(ctx sdk.Context, checksum []byte) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeStoreWasmCode,
sdk.NewAttribute(types.AttributeKeyWasmCodeHash, hex.EncodeToString(codeHash)),
sdk.NewAttribute(types.AttributeKeyWasmChecksum, hex.EncodeToString(checksum)),
),
sdk.NewEvent(
sdk.EventTypeMessage,
Expand All @@ -23,13 +23,13 @@ func emitStoreWasmCodeEvent(ctx sdk.Context, codeHash []byte) {
}

// emitMigrateContractEvent emits a migrate contract event
func emitMigrateContractEvent(ctx sdk.Context, clientID string, codeHash, newCodeHash []byte) {
func emitMigrateContractEvent(ctx sdk.Context, clientID string, checksum, newChecksum []byte) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeMigrateContract,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyWasmCodeHash, hex.EncodeToString(codeHash)),
sdk.NewAttribute(types.AttributeKeyNewCodeHash, hex.EncodeToString(newCodeHash)),
sdk.NewAttribute(types.AttributeKeyWasmChecksum, hex.EncodeToString(checksum)),
sdk.NewAttribute(types.AttributeKeyNewChecksum, hex.EncodeToString(newChecksum)),
),
sdk.NewEvent(
sdk.EventTypeMessage,
Expand Down
4 changes: 2 additions & 2 deletions modules/light-clients/08-wasm/keeper/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ package keeper
This file is to allow for unexported functions to be accessible to the testing package.
*/

func GenerateWasmCodeHash(code []byte) []byte {
return generateWasmCodeHash(code)
func GenerateWasmChecksum(code []byte) []byte {
return generateWasmChecksum(code)
}
Loading

0 comments on commit eadd1d6

Please sign in to comment.