Skip to content

Conversation

@alpe
Copy link
Contributor

@alpe alpe commented Jun 14, 2021

Updates doc to describe the edge case for response overwrite in submessages

Follow up from: CosmWasm/wasmd#534 (comment)

overwrite any previous `data` value).

An edge is *empty* data returned with `data: Some(empty)`. We handle this equal
to `data: None` to avoid unmarshalling issues.
Copy link
Member

@webmaster128 webmaster128 Jun 14, 2021

Choose a reason for hiding this comment

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

With this solution, there is no way for a contract to clear previous data. E.g.

// Execute
data: Some(b"first thought")

// Reply
data: Some(b"") // Okay, better shut my mouth

Do we really want to do that? Or better increase testing for the null/empty differentiation?

Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot conceive of such a case, but I do admit there are cases we thought would never come up, which later do.

That said, the whole Some(b"") vs None his us in many places, and I am still not convinced that in any of them we really needed to differentiate them.

Where we pass these values in JSON, we need to explicitly use custom types in Go, as the default parser for []byte doesn't distinguish between these two "zero values".

Copy link
Member

Choose a reason for hiding this comment

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

Where we pass these values in JSON, we need to explicitly use custom types in Go, as the default parser for []byte doesn't distinguish between these two "zero values".

I think we tested that and it worked well. It just collapses with strings as the string type in Go is not nullable but []byte is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm... you are right... This does produce different values for null/missing and ""
https://play.golang.org/p/KqI86DXQ7jq

I guess it makes sense to test this and enforce different behaviors.

I was concerned about distinguishing them and advised Alex to be careful about handling these two cases differently

@webmaster128 webmaster128 added this to the 0.15.0 milestone Jun 15, 2021
@alpe alpe deleted the empty_submsg_result_doc branch June 25, 2021 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants