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

renaming to align with x/wasm naming #4091

Merged
merged 6 commits into from
Jul 20, 2023

Conversation

crodriguezvega
Copy link
Contributor

@crodriguezvega crodriguezvega commented Jul 14, 2023

Description

Opening this one to hear opinions if we should do all this renaming to align with x/wasm naming. This causes a change in the store key and will require some changes in the contracts (test failures are expected).

closes: #XXXX

Commit Message / Changelog Entry

type: commit message

see the guidelines for commit messages. (view raw markdown for examples)


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

// metadata value
bytes contract_code = 1;
// contract byte code
bytes code_bytes = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here.

@@ -9,12 +9,12 @@ option go_package = "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/type
// GenesisState defines 08-wasm's keeper genesis state
message GenesisState {
// uploaded light client wasm contracts
repeated GenesisContract contracts = 1 [(gogoproto.nullable) = false];
repeated Contract contracts = 1 [(gogoproto.nullable) = false];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here.

}

// MsgStoreCodeResponse defines the response type for the StoreCode rpc
message MsgStoreCodeResponse {
bytes code_id = 1;
// Checksum is the sha256 hash of the stored code
bytes checksum = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto on protodoc lowercase nit

@@ -18,10 +19,12 @@ message MsgStoreCode {
option (cosmos.msg.v1.signer) = "signer";

string signer = 1;
bytes code = 2;
// WASMByteCode can be raw or gzip compressed
bytes wasm_byte_code = 2 [(gogoproto.customname) = "WASMByteCode"];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I know these replicate the wasmd protos but for our protodocs we usually use all lowercase

}

// QueryCodeResponse is the response type for the Query/Code RPC method.
message QueryCodeResponse {
bytes code = 1;
bytes data = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here.

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryCodeRequest is the request type for the Query/Code RPC method.
message QueryCodeRequest {
string code_id = 1;
string code_hash = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code ID has a different meaning in x/wasm so I thought of renaming to code_hash to avoid confusion between x/wasm and 08-wasm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is the meaning different? i thought they both referred to stored contract code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, "meaning" is probably not the right word... What I wanted to say is that the term code ID in x/wasm is an integer that indeed is used to refer to the contract (this integer is generated when a contract is stored) and the code hash is the hash of the byte code. So I thought that to avoid confusion between the code ID in x/wasm and the code ID we were using here it was better to rename it to code hash, so that we use the same terms for the same things in both modules.

@@ -12,11 +12,11 @@ const (
// StoreKey is the store key string for 08-wasm
StoreKey = ModuleName

KeyCodeIDPrefix = "codeId"
KeyCodeHashPrefix = "codeHash"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this changes the store key prefix...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change with #4085 anyways tho right? we won't be storing the wasm code anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I guess we will have a codeHashes key where we store the list of all code hashes.

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice clean up! Big++ on maintaining the same terminology/concepts naming conventions as x/wasm!

I just left some nits, but LGTM!

docs/architecture/adr-027-ibc-wasm.md Outdated Show resolved Hide resolved
Comment on lines 46 to 51
lenCodeHash := len(cs.CodeHash)
if lenCodeHash == 0 {
return errorsmod.Wrap(ErrInvalidCodeHash, "code hash cannot be empty")
}
if lenCodeID > 32 { // sha256 output is 256 bits long
return errorsmod.Wrapf(ErrInvalidCodeID, "expected 32, got %d", lenCodeID)
if lenCodeHash > 32 { // sha256 output is 256 bits long
return errorsmod.Wrapf(ErrInvalidCodeHash, "expected 32, got %d", lenCodeHash)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the output expected to be exactly 256 bits long? why doesn't this check for strict equality?

Is my thinking correct here that this could be replaced with a if len(cs.CodeHash) != 32 { return err } ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to revisit these errors, ErrInvalid and ErrInvalidData seem almost overly generic to maintain here?

@@ -12,11 +12,11 @@ const (
// StoreKey is the store key string for 08-wasm
StoreKey = ModuleName

KeyCodeIDPrefix = "codeId"
KeyCodeHashPrefix = "codeHash"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will change with #4085 anyways tho right? we won't be storing the wasm code anymore

@@ -18,10 +19,12 @@ message MsgStoreCode {
option (cosmos.msg.v1.signer) = "signer";

string signer = 1;
bytes code = 2;
// WASMByteCode can be raw or gzip compressed
bytes wasm_byte_code = 2 [(gogoproto.customname) = "WASMByteCode"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I know these replicate the wasmd protos but for our protodocs we usually use all lowercase

}

// MsgStoreCodeResponse defines the response type for the StoreCode rpc
message MsgStoreCodeResponse {
bytes code_id = 1;
// Checksum is the sha256 hash of the stored code
bytes checksum = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto on protodoc lowercase nit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in here are flagged for removal in #4048 👍

Co-authored-by: Damian Nolan <damiannolan@gmail.com>
@@ -47,7 +47,7 @@ func (cs ClientState) Validate() error {
if lenCodeHash == 0 {
return errorsmod.Wrap(ErrInvalidCodeHash, "code hash cannot be empty")
}
if lenCodeHash > 32 { // sha256 output is 256 bits long
if lenCodeHash != 32 { // sha256 output is 256 bits long
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only nit pertains to err message used here, doesn't really give indication that 32 refers to # of bytes.

// WASMByteCode can be raw or gzip compressed
bytes wasm_byte_code = 2 [(gogoproto.customname) = "WASMByteCode"];
// wasm byte code of light client contract. It can be raw or gzip compressed
bytes wasm_byte_code = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't you want to keep the gogoproto custom name?

https://github.com/CosmWasm/wasmd/blob/main/proto/cosmwasm/wasm/v1/tx.proto#L83

Copy link
Contributor Author

@crodriguezvega crodriguezvega Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought you preferred to have the field name as WasmByteCode. I will merge the PR now, but let me know if you'd like me to change this, and I will do in a follow up.

@crodriguezvega crodriguezvega merged commit 59ccad5 into feat/wasm-clients Jul 20, 2023
49 of 50 checks passed
@crodriguezvega crodriguezvega deleted the carlos/align-with-wasm-naming branch July 20, 2023 18:58
@faddat faddat mentioned this pull request Sep 10, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants