-
Notifications
You must be signed in to change notification settings - Fork 673
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
renaming to align with x/wasm naming #4091
Conversation
// metadata value | ||
bytes contract_code = 1; | ||
// contract byte code | ||
bytes code_bytes = 1; |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See here.
There was a problem hiding this comment.
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"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See here.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
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) |
There was a problem hiding this comment.
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 }
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch!
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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"]; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
testing/coordinator.go
Outdated
There was a problem hiding this comment.
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 <[email protected]>
@@ -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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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
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.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.