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

Update to cosmwasm 0.8 #68

Merged
merged 16 commits into from Apr 28, 2020
Merged

Update to cosmwasm 0.8 #68

merged 16 commits into from Apr 28, 2020

Conversation

ethanfrey
Copy link
Member

@ethanfrey ethanfrey commented Apr 27, 2020

This updates go-cosmwasm to the current master of cosmwasm and updates to contract_0.8.wasm. This now works to 90%. There is some error with the humanize_address callback that I need to track down and repair.

There are also a number of TODOs to get full working version, some of which may be in future PRs. This is tracked in https://github.com/CosmWasm/go-cosmwasm/blob/update-cosmwasm-0.8/TODO

Planned for this PR:

  • Update all types in go (left: ApiError)
  • All tests pass with current mocks
  • Update to cbindgen 0.14
  • Implement remove for DB
  • Add StakingMsg to types

Planned for future PRs (linked to this PR):

  • Ensure empty arrays are encoded as [] not null (transform on Rust side if needed) - need to find sample failure case
  • Add Querier callback to go code
  • Enable iterator feature flag and implement iterator callback

@ethanfrey
Copy link
Member Author

If someone could take a look at help figure out why humanize_address is failing, that would be super useful. I tried adding print statements, but nothing came out.

@webmaster128
Copy link
Member

webmaster128 commented Apr 27, 2020

If someone could take a look at help figure out why humanize_address is failing, that would be super useful. I tried adding print statements, but nothing came out.

Looking at the error message, there must be an ApiError::ContractError

Expected nil, but got: &types.ApiError{Base64Err:(*types.SourceErr)(nil), ContractErr:(*types.MsgErr)(0xc000230d70)...

Maybe this new error case? CosmWasm/cosmwasm@b82025a

Update: CosmWasm/cosmwasm@bbe1cbe

Copy link
Contributor

@reuvenpo reuvenpo left a comment

Choose a reason for hiding this comment

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

I had to go somewhere in the middle of my review, so it took longer to wrap up than expected. There are missing documentation comments here and there, and plenty of TODO comments but i'm sure you won't leave those unchecked.
I couldn't find the source of the error you mention by statically analyzing the code, so i'll try running/debugging it now

api/memory.go Show resolved Hide resolved
src/error.rs Show resolved Hide resolved
src/api.rs Outdated Show resolved Hide resolved
types/types.go Outdated
Comment on lines 72 to 85
type ApiError struct {
Base64Err *SourceErr `json:"base64_err,omitempty"`
ContractErr *MsgErr `json:"contract_err,omitempty"`
DynContractErr *MsgErr `json:"dyn_contract_err,omitempty"`
NotFound *NotFoundErr `json:"not_found,omitempty"`
NullPointer *struct{} `json:"null_pointer,omitempty"`
ParseErr *JSONErr `json:"parse_err,omitempty"`
SerializeErr *JSONErr `json:"serialize_err,omitempty"`
Unauthorized *struct{} `json:"unauthorized,omitempty"`
UnderflowErr *UnderflowErr `json:"underflow_err,omitempty"`
Utf8Err *SourceErr `json:"utf8_err,omitempty"`
Utf8StringErr *SourceErr `json:"utf8_string_err,omitempty"`
ValidationErr *ValidationErr `json:"validation_err,omitempty"`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not that well versed in Go, but is it maybe better to define this as something akin to a pointer to a trait object in rust? that way the layout of this type won't be so big.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I can try to use a (private) interface and then separate types/structs for each of these cases, and use a type-switch. This guarantees 0 or 1 elements (not 0 to N) and will be a smaller struct, but actually a fair bit more code for the structs.

Copy link
Member Author

Choose a reason for hiding this comment

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

That probably is more idiomatic Go as well

Copy link
Member Author

Choose a reason for hiding this comment

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

I started doing this for errors and it is a lot of code. And they are being overhauled right now..

I will update messages to work like this, and then update errors once CosmWasm/cosmwasm#271 is merged and we update go-cosmwasm to that commit

Copy link
Member Author

Choose a reason for hiding this comment

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

Oof... I did this for CosmosMsg, then I realized something...
interface{} types can be json serialized, but not deserialized (missing info on how), so I will need more custom code there.

I was trying the approach used by protobuf, but they use codegen and determine the bytes and cast it to a type manually (in generated code).

I will stick with the current (ugly) solution. But at least I know why I did this

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable. The overhead here isn't too terrible, and it's definitely fixable in the future since there's zero effect on exposed interfaces afaik.
How/Where do these types propagate to the cosmos sdk and eventually users of the CLI or client libraries?

@ethanfrey ethanfrey added this to In progress in Blockchain Development via automation Apr 27, 2020
@ethanfrey ethanfrey changed the title Update cosmwasm 0.8 Update to cosmwasm 0.8 Apr 27, 2020
src/db.rs Outdated Show resolved Hide resolved
@ethanfrey ethanfrey marked this pull request as ready for review April 27, 2020 19:08
@ethanfrey
Copy link
Member Author

I made PRs for follow-ups. I would like to merge this in to have a solid base, and we can keep making PRs (in parallel) to add features to get 0.8 feature complete.

If I forget some other feature, please add it to the list

TODO Outdated Show resolved Hide resolved
@ethanfrey ethanfrey merged commit fb2501a into master Apr 28, 2020
Blockchain Development automation moved this from In progress to Done Apr 28, 2020
@ethanfrey ethanfrey deleted the update-cosmwasm-0.8 branch April 28, 2020 10:12
faddat pushed a commit to faddat/go-cosmwasm that referenced this pull request Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants