cosmos / ibc

Interchain Standards (ICS) for the Cosmos network & interchain ecosystem.
Other
929 stars 383 forks source link

Use Protobuf encoding instead of JSON for the ICS20-v2 `FungibleTokenPacketData` #1097

Closed womensrights closed 3 months ago

womensrights commented 5 months ago

The encoding type used for the FungibleTokenPacketData and FungibleTokenPacketAcknowledgement in the current ICS-20 spec is JSON. There have been some suggestions to use protobuf based encoding instead which I am personally on board with. Some of the reasons for the change are detailed below and is intended to open up the discussion for the choice of encoding for ICS-20 v2:

Advantages of using protobuf over json

Disadvantages of using protobuf over json

womensrights commented 5 months ago

Some additional useful context is also detailed in this write up.

The main argument is that json is too expensive in EVM environments and for ZK based applications

zmanian commented 3 months ago

One question in my mind is how IBC can more intentionally address the demand for alternative serialization in ICS-20.

There is a considerable amount of demand for Ethereum 's ABI encoding and Borsh for Near/solana.

One way might be to define ICS-20 v2 as a family of similar protocols each with its own serialization.

nicolaslara commented 3 months ago

One question in my mind is how IBC can more intentionally address the demand for alternative serialization in ICS-20.

This sounds like a good idea, but probably something that should live one level up. Maybe the Packet itself could have an optional field specifying the serialization format of the data.

bluele commented 3 months ago

Maybe the Packet itself could have an optional field specifying the serialization format of the data.

I think it makes sense to use ChannelEnd's version to determine which packet encoding method during Channel handshake. This prevents the receiving of packets with encoding that is not supported by the chain.

Looks like this idea is also described in https://github.com/cosmos/ibc/tree/main/spec/core/ics-004-channel-and-packet-semantics#definitions.

The version string stores an opaque channel version, which is agreed upon during the handshake. This can determine module-level configuration such as which packet encoding is used for the channel.

crodriguezvega commented 3 months ago

Thank y'all for the feedback. We will go ahead with this proposal for now and use protobuf encoding in ICS20 v2. However, we envision a not so distant future where we should be able to have an ICS04 packet that contains enough information to explain the type and the encoding of the application packet data.

crodriguezvega commented 3 months ago

Closed by #1118