You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whether or not this is a bug needs discussion. A recently made commit (#5778) has the unintended consequence of allowing unknown fields in transfer packet data.
Description
In #5778, we have removed ModuleCdc in favor of encoding/json. (This PR hasn't made its way to any releases yet). The module codec used protojson to decode the packet data which has the default behavior of returning an error if it sees an unknown field. However, encoding/json ignores the unknown fields and proceeds with deserialization.
srdtrk
changed the title
Packet data unmarshaling doesn't error even if there is an unknown field
Packet data unmarshaling doesn't error when there is an unknown field
Apr 23, 2024
Oh my, nice find! Tagging bug, as allowing unmarshaling of unknown fields sounds problematic. We often make use of new fields to introduce new features. If I send a packet to chain X using a new field it doesn't understand (memo for example), I'd expect it to fail, not succeed ignoring my addition input
I suppose there's no easy way to error on unknown fields with std json lib?
We can override the unmarshaling behaviour of encoding/json for FungibleTokenPacketData by implementing json.Unmarshaler on it. We would write our custom UnmarshalJSON function. Wouldn't be too difficult
We have decided to implement the json.Unmarshaler with our custom function. If anything goes awry we can fallback to protojson for the time being (so as not to block v9 release)
Summary of Bug
Whether or not this is a bug needs discussion. A recently made commit (#5778) has the unintended consequence of allowing unknown fields in transfer packet data.
Description
In #5778, we have removed
ModuleCdc
in favor ofencoding/json
. (This PR hasn't made its way to any releases yet). The module codec used protojson to decode the packet data which has the default behavior of returning an error if it sees an unknown field. However,encoding/json
ignores the unknown fields and proceeds with deserialization.Expected Behavior
Consider the following transfer packet data:
This cannot be deserialized in release versions of ibc-go. But can be deserialized in main.
Version
Only main. This hasn't made its way back to any releases yet.
Steps to Reproduce
See the tests I wrote here
For Admin Use
The text was updated successfully, but these errors were encountered: