cosmos / ibc-proto-rs

Rust Protobuf definitions and gRPC clients for interacting with Cosmos SDK, IBC and Interchain Security
Apache License 2.0
42 stars 25 forks source link

Use the v0.34 definition of `tendermint.abci.Event` which does not enforce valid UTF-8 data #180

Closed romac closed 5 months ago

romac commented 6 months ago

Closes: #181

Use the v0.34 definition of abci.Event which does not enforce valid UTF-8 data for its key and value attributes, specifying them as bytes instead of string. This is required, because ibc-go emits event attributes which are not valid UTF-8, so we need to use this definition to be able to parse them. In Protobuf, bytes and string are wire-compatible, so doing this strictly increases the amount fo data we can parse.

See this Hermes PR for background information: https://github.com/informalsystems/hermes/pull/3768

romac commented 6 months ago

Here is the diff between tendermint_proto::v0_38::abci::EventAttribute and tendermint_proto::v0_34::abci::EventAttribute:

--- /tmp/038.rs 2024-01-22 10:37:42
+++ /tmp/034.rs 2024-01-22 10:38:27
@@ -2,10 +2,10 @@
 #[allow(clippy::derive_partial_eq_without_eq)]
 #[derive(Clone, PartialEq, ::prost::Message)]
 pub struct EventAttribute {
-    #[prost(string, tag = "1")]
-    pub key: ::prost::alloc::string::String,
-    #[prost(string, tag = "2")]
-    pub value: ::prost::alloc::string::String,
+    #[prost(bytes = "bytes", tag = "1")]
+    pub key: ::prost::bytes::Bytes,
+    #[prost(bytes = "bytes", tag = "2")]
+    pub value: ::prost::bytes::Bytes,
     /// nondeterministic
     #[prost(bool, tag = "3")]
     pub index: bool,
romac commented 5 months ago

This PR has been confirmed to fix the issue seen in Hermes.