From 76608a38dc153f29858fcb5b66a9ae023c6764f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Fri, 30 Aug 2024 10:09:47 +0200 Subject: [PATCH 1/3] fix(proto): align crypto.Proof serialization with go tendermint --- proto/src/prost/v0_34/tendermint.crypto.rs | 2 -- proto/src/prost/v0_37/tendermint.crypto.rs | 2 -- proto/src/tendermint/v0_34.rs | 2 +- tendermint/src/lib.rs | 8 +------- tools/proto-compiler/src/constants.rs | 2 -- 5 files changed, 2 insertions(+), 14 deletions(-) diff --git a/proto/src/prost/v0_34/tendermint.crypto.rs b/proto/src/prost/v0_34/tendermint.crypto.rs index cfd024d19..0c1ec0b60 100644 --- a/proto/src/prost/v0_34/tendermint.crypto.rs +++ b/proto/src/prost/v0_34/tendermint.crypto.rs @@ -3,10 +3,8 @@ #[derive(Clone, PartialEq, ::prost::Message)] pub struct Proof { #[prost(int64, tag = "1")] - #[serde(with = "crate::serializers::from_str")] pub total: i64, #[prost(int64, tag = "2")] - #[serde(with = "crate::serializers::from_str")] pub index: i64, #[prost(bytes = "vec", tag = "3")] #[serde(with = "crate::serializers::bytes::base64string")] diff --git a/proto/src/prost/v0_37/tendermint.crypto.rs b/proto/src/prost/v0_37/tendermint.crypto.rs index cfd024d19..0c1ec0b60 100644 --- a/proto/src/prost/v0_37/tendermint.crypto.rs +++ b/proto/src/prost/v0_37/tendermint.crypto.rs @@ -3,10 +3,8 @@ #[derive(Clone, PartialEq, ::prost::Message)] pub struct Proof { #[prost(int64, tag = "1")] - #[serde(with = "crate::serializers::from_str")] pub total: i64, #[prost(int64, tag = "2")] - #[serde(with = "crate::serializers::from_str")] pub index: i64, #[prost(bytes = "vec", tag = "3")] #[serde(with = "crate::serializers::bytes::base64string")] diff --git a/proto/src/tendermint/v0_34.rs b/proto/src/tendermint/v0_34.rs index feb43ede9..3f1e3f16f 100644 --- a/proto/src/tendermint/v0_34.rs +++ b/proto/src/tendermint/v0_34.rs @@ -62,5 +62,5 @@ pub mod version { pub mod meta { pub const REPOSITORY: &str = "https://github.com/celestiaorg/celestia-core"; - pub const COMMITISH: &str = "v0.34.x-celestia"; + pub const COMMITISH: &str = "a1b07a1e6c77595466da9c61b37c83b4769b47e7"; } diff --git a/tendermint/src/lib.rs b/tendermint/src/lib.rs index edc358010..552543b7f 100644 --- a/tendermint/src/lib.rs +++ b/tendermint/src/lib.rs @@ -6,13 +6,7 @@ #![no_std] #![cfg_attr(docsrs, feature(doc_cfg))] -#![deny( - warnings, - trivial_casts, - trivial_numeric_casts, - unused_import_braces, - unused_qualifications -)] +#![deny(warnings, trivial_casts, trivial_numeric_casts, unused_import_braces)] #![forbid(unsafe_code)] #![doc( html_logo_url = "https://raw.githubusercontent.com/informalsystems/tendermint-rs/master/img/logo-tendermint-rs_3961x4001.png" diff --git a/tools/proto-compiler/src/constants.rs b/tools/proto-compiler/src/constants.rs index 805c9509a..2ef57630a 100644 --- a/tools/proto-compiler/src/constants.rs +++ b/tools/proto-compiler/src/constants.rs @@ -219,8 +219,6 @@ pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ ), (".tendermint.types.TxProof.data", BASE64STRING), (".tendermint.types.TxProof.root_hash", HEXSTRING), - (".tendermint.crypto.Proof.index", QUOTED), - (".tendermint.crypto.Proof.total", QUOTED), (".tendermint.crypto.Proof.aunts", VEC_BASE64STRING), (".tendermint.crypto.Proof.leaf_hash", BASE64STRING), ]; From d1bfd20010af4e166fc3804809222924c554351a Mon Sep 17 00:00:00 2001 From: zvolin Date: Fri, 30 Aug 2024 10:55:07 +0200 Subject: [PATCH 2/3] fix clippy issues --- tendermint/src/merkle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tendermint/src/merkle.rs b/tendermint/src/merkle.rs index 63c6361fb..a3a77def8 100644 --- a/tendermint/src/merkle.rs +++ b/tendermint/src/merkle.rs @@ -152,7 +152,7 @@ mod tests { let empty_tree_root_hex = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; let empty_tree_root = &hex::decode(empty_tree_root_hex).unwrap(); - let empty_tree: Vec> = vec![vec![]; 0]; + let empty_tree: Vec> = vec![]; let root = simple_hash_from_byte_vectors::(&empty_tree); assert_eq!(empty_tree_root, &root); From c62d61749af98f0adaf9a271b174fda48e5c2461 Mon Sep 17 00:00:00 2001 From: zvolin Date: Tue, 3 Sep 2024 15:45:53 +0200 Subject: [PATCH 3/3] align also Row, Share and NMT proofs --- proto/src/prost/v0_34/tendermint.abci.rs | 1 + .../src/prost/v0_34/tendermint.blockchain.rs | 1 + proto/src/prost/v0_34/tendermint.consensus.rs | 1 + proto/src/prost/v0_34/tendermint.crypto.rs | 1 + proto/src/prost/v0_34/tendermint.libs.bits.rs | 1 + proto/src/prost/v0_34/tendermint.mempool.rs | 1 + proto/src/prost/v0_34/tendermint.p2p.rs | 1 + proto/src/prost/v0_34/tendermint.privval.rs | 1 + proto/src/prost/v0_34/tendermint.rpc.grpc.rs | 1 + proto/src/prost/v0_34/tendermint.state.rs | 1 + proto/src/prost/v0_34/tendermint.statesync.rs | 1 + proto/src/prost/v0_34/tendermint.store.rs | 1 + proto/src/prost/v0_34/tendermint.types.rs | 12 +++++++ proto/src/prost/v0_34/tendermint.version.rs | 1 + proto/src/prost/v0_37/tendermint.abci.rs | 1 + proto/src/prost/v0_37/tendermint.blocksync.rs | 1 + proto/src/prost/v0_37/tendermint.consensus.rs | 1 + proto/src/prost/v0_37/tendermint.crypto.rs | 1 + proto/src/prost/v0_37/tendermint.libs.bits.rs | 1 + proto/src/prost/v0_37/tendermint.mempool.rs | 1 + proto/src/prost/v0_37/tendermint.p2p.rs | 1 + proto/src/prost/v0_37/tendermint.privval.rs | 1 + proto/src/prost/v0_37/tendermint.rpc.grpc.rs | 1 + proto/src/prost/v0_37/tendermint.state.rs | 1 + proto/src/prost/v0_37/tendermint.statesync.rs | 1 + proto/src/prost/v0_37/tendermint.store.rs | 1 + proto/src/prost/v0_37/tendermint.types.rs | 1 + proto/src/prost/v0_37/tendermint.version.rs | 1 + proto/src/serializers/bytes.rs | 36 +++++++++++++++++++ tools/proto-compiler/src/constants.rs | 12 +++++++ 30 files changed, 87 insertions(+) diff --git a/proto/src/prost/v0_34/tendermint.abci.rs b/proto/src/prost/v0_34/tendermint.abci.rs index 9352cd7ac..0d778014a 100644 --- a/proto/src/prost/v0_34/tendermint.abci.rs +++ b/proto/src/prost/v0_34/tendermint.abci.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Request { diff --git a/proto/src/prost/v0_34/tendermint.blockchain.rs b/proto/src/prost/v0_34/tendermint.blockchain.rs index 4480ece49..045177639 100644 --- a/proto/src/prost/v0_34/tendermint.blockchain.rs +++ b/proto/src/prost/v0_34/tendermint.blockchain.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// BlockRequest requests a block for a specific height #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_34/tendermint.consensus.rs b/proto/src/prost/v0_34/tendermint.consensus.rs index 95237cc78..a12be1181 100644 --- a/proto/src/prost/v0_34/tendermint.consensus.rs +++ b/proto/src/prost/v0_34/tendermint.consensus.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// NewRoundStep is sent for every step taken in the ConsensusState. /// For every height/round/step transition #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/proto/src/prost/v0_34/tendermint.crypto.rs b/proto/src/prost/v0_34/tendermint.crypto.rs index 0c1ec0b60..f9a679d96 100644 --- a/proto/src/prost/v0_34/tendermint.crypto.rs +++ b/proto/src/prost/v0_34/tendermint.crypto.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_34/tendermint.libs.bits.rs b/proto/src/prost/v0_34/tendermint.libs.bits.rs index 460876d21..7ddf7f64a 100644 --- a/proto/src/prost/v0_34/tendermint.libs.bits.rs +++ b/proto/src/prost/v0_34/tendermint.libs.bits.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_34/tendermint.mempool.rs b/proto/src/prost/v0_34/tendermint.mempool.rs index 05c02dca2..e5051ee7b 100644 --- a/proto/src/prost/v0_34/tendermint.mempool.rs +++ b/proto/src/prost/v0_34/tendermint.mempool.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Txs { diff --git a/proto/src/prost/v0_34/tendermint.p2p.rs b/proto/src/prost/v0_34/tendermint.p2p.rs index bfaa808cb..b219bb837 100644 --- a/proto/src/prost/v0_34/tendermint.p2p.rs +++ b/proto/src/prost/v0_34/tendermint.p2p.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PacketPing {} diff --git a/proto/src/prost/v0_34/tendermint.privval.rs b/proto/src/prost/v0_34/tendermint.privval.rs index 8485c3816..bc390fd53 100644 --- a/proto/src/prost/v0_34/tendermint.privval.rs +++ b/proto/src/prost/v0_34/tendermint.privval.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RemoteSignerError { diff --git a/proto/src/prost/v0_34/tendermint.rpc.grpc.rs b/proto/src/prost/v0_34/tendermint.rpc.grpc.rs index 5630cb50c..5e37e3fc2 100644 --- a/proto/src/prost/v0_34/tendermint.rpc.grpc.rs +++ b/proto/src/prost/v0_34/tendermint.rpc.grpc.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RequestPing {} diff --git a/proto/src/prost/v0_34/tendermint.state.rs b/proto/src/prost/v0_34/tendermint.state.rs index dd006a2c6..699bffe9d 100644 --- a/proto/src/prost/v0_34/tendermint.state.rs +++ b/proto/src/prost/v0_34/tendermint.state.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// ABCIResponses retains the responses /// of the various ABCI calls during block processing. /// It is persisted to disk for each height before calling Commit. diff --git a/proto/src/prost/v0_34/tendermint.statesync.rs b/proto/src/prost/v0_34/tendermint.statesync.rs index a2ad034e3..b397c6162 100644 --- a/proto/src/prost/v0_34/tendermint.statesync.rs +++ b/proto/src/prost/v0_34/tendermint.statesync.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Message { diff --git a/proto/src/prost/v0_34/tendermint.store.rs b/proto/src/prost/v0_34/tendermint.store.rs index 98d20b0fc..eca59ddf7 100644 --- a/proto/src/prost/v0_34/tendermint.store.rs +++ b/proto/src/prost/v0_34/tendermint.store.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BlockStoreState { diff --git a/proto/src/prost/v0_34/tendermint.types.rs b/proto/src/prost/v0_34/tendermint.types.rs index 83267716c..ec39c0537 100644 --- a/proto/src/prost/v0_34/tendermint.types.rs +++ b/proto/src/prost/v0_34/tendermint.types.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -333,14 +334,17 @@ pub struct BlobTx { } /// ShareProof is an NMT proof that a set of shares exist in a set of rows and a /// Merkle proof that those rows exist in a Merkle tree with a given data root. +#[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ShareProof { #[prost(bytes = "vec", repeated, tag = "1")] + #[serde(with = "crate::serializers::bytes::vec_base64string")] pub data: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, #[prost(message, repeated, tag = "2")] pub share_proofs: ::prost::alloc::vec::Vec, #[prost(bytes = "vec", tag = "3")] + #[serde(with = "crate::serializers::bytes::base64string")] pub namespace_id: ::prost::alloc::vec::Vec, #[prost(message, optional, tag = "4")] pub row_proof: ::core::option::Option, @@ -349,14 +353,18 @@ pub struct ShareProof { } /// RowProof is a Merkle proof that a set of rows exist in a Merkle tree with a /// given data root. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[serde(default)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RowProof { #[prost(bytes = "vec", repeated, tag = "1")] + #[serde(with = "crate::serializers::bytes::vec_hexstring")] pub row_roots: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, #[prost(message, repeated, tag = "2")] pub proofs: ::prost::alloc::vec::Vec, #[prost(bytes = "vec", tag = "3")] + #[serde(with = "crate::serializers::bytes::base64string")] pub root: ::prost::alloc::vec::Vec, #[prost(uint32, tag = "4")] pub start_row: u32, @@ -367,6 +375,8 @@ pub struct RowProof { /// In case this proof proves the absence of a namespace.ID /// in a tree it also contains the leaf hashes of the range /// where that namespace would be. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[serde(default)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct NmtProof { @@ -381,6 +391,7 @@ pub struct NmtProof { /// and min namespaces along with the actual hash, resulting in each being 48 /// bytes each #[prost(bytes = "vec", repeated, tag = "3")] + #[serde(with = "crate::serializers::bytes::vec_base64string")] pub nodes: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, /// leafHash are nil if the namespace is present in the NMT. In case the /// namespace to be proved is in the min/max range of the tree but absent, this @@ -388,6 +399,7 @@ pub struct NmtProof { /// hashes should consist of the namespace along with the actual hash, /// resulting 40 bytes total. #[prost(bytes = "vec", tag = "4")] + #[serde(with = "crate::serializers::bytes::base64string")] pub leaf_hash: ::prost::alloc::vec::Vec, } /// BlockIdFlag indicates which BlcokID the signature is for diff --git a/proto/src/prost/v0_34/tendermint.version.rs b/proto/src/prost/v0_34/tendermint.version.rs index 8a77a26fc..fc7a8f448 100644 --- a/proto/src/prost/v0_34/tendermint.version.rs +++ b/proto/src/prost/v0_34/tendermint.version.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// App includes the protocol and software version for the application. /// This information is included in ResponseInfo. The App.Protocol can be /// updated in ResponseEndBlock. diff --git a/proto/src/prost/v0_37/tendermint.abci.rs b/proto/src/prost/v0_37/tendermint.abci.rs index f92640a9b..934feb379 100644 --- a/proto/src/prost/v0_37/tendermint.abci.rs +++ b/proto/src/prost/v0_37/tendermint.abci.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Request { diff --git a/proto/src/prost/v0_37/tendermint.blocksync.rs b/proto/src/prost/v0_37/tendermint.blocksync.rs index 4480ece49..045177639 100644 --- a/proto/src/prost/v0_37/tendermint.blocksync.rs +++ b/proto/src/prost/v0_37/tendermint.blocksync.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// BlockRequest requests a block for a specific height #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_37/tendermint.consensus.rs b/proto/src/prost/v0_37/tendermint.consensus.rs index 95237cc78..a12be1181 100644 --- a/proto/src/prost/v0_37/tendermint.consensus.rs +++ b/proto/src/prost/v0_37/tendermint.consensus.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// NewRoundStep is sent for every step taken in the ConsensusState. /// For every height/round/step transition #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/proto/src/prost/v0_37/tendermint.crypto.rs b/proto/src/prost/v0_37/tendermint.crypto.rs index 0c1ec0b60..f9a679d96 100644 --- a/proto/src/prost/v0_37/tendermint.crypto.rs +++ b/proto/src/prost/v0_37/tendermint.crypto.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_37/tendermint.libs.bits.rs b/proto/src/prost/v0_37/tendermint.libs.bits.rs index 460876d21..7ddf7f64a 100644 --- a/proto/src/prost/v0_37/tendermint.libs.bits.rs +++ b/proto/src/prost/v0_37/tendermint.libs.bits.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_37/tendermint.mempool.rs b/proto/src/prost/v0_37/tendermint.mempool.rs index 9fec1376b..056cddaf5 100644 --- a/proto/src/prost/v0_37/tendermint.mempool.rs +++ b/proto/src/prost/v0_37/tendermint.mempool.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Txs { diff --git a/proto/src/prost/v0_37/tendermint.p2p.rs b/proto/src/prost/v0_37/tendermint.p2p.rs index bfaa808cb..b219bb837 100644 --- a/proto/src/prost/v0_37/tendermint.p2p.rs +++ b/proto/src/prost/v0_37/tendermint.p2p.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PacketPing {} diff --git a/proto/src/prost/v0_37/tendermint.privval.rs b/proto/src/prost/v0_37/tendermint.privval.rs index 8485c3816..bc390fd53 100644 --- a/proto/src/prost/v0_37/tendermint.privval.rs +++ b/proto/src/prost/v0_37/tendermint.privval.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RemoteSignerError { diff --git a/proto/src/prost/v0_37/tendermint.rpc.grpc.rs b/proto/src/prost/v0_37/tendermint.rpc.grpc.rs index 5630cb50c..5e37e3fc2 100644 --- a/proto/src/prost/v0_37/tendermint.rpc.grpc.rs +++ b/proto/src/prost/v0_37/tendermint.rpc.grpc.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RequestPing {} diff --git a/proto/src/prost/v0_37/tendermint.state.rs b/proto/src/prost/v0_37/tendermint.state.rs index dd006a2c6..699bffe9d 100644 --- a/proto/src/prost/v0_37/tendermint.state.rs +++ b/proto/src/prost/v0_37/tendermint.state.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// ABCIResponses retains the responses /// of the various ABCI calls during block processing. /// It is persisted to disk for each height before calling Commit. diff --git a/proto/src/prost/v0_37/tendermint.statesync.rs b/proto/src/prost/v0_37/tendermint.statesync.rs index a2ad034e3..b397c6162 100644 --- a/proto/src/prost/v0_37/tendermint.statesync.rs +++ b/proto/src/prost/v0_37/tendermint.statesync.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Message { diff --git a/proto/src/prost/v0_37/tendermint.store.rs b/proto/src/prost/v0_37/tendermint.store.rs index 98d20b0fc..eca59ddf7 100644 --- a/proto/src/prost/v0_37/tendermint.store.rs +++ b/proto/src/prost/v0_37/tendermint.store.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BlockStoreState { diff --git a/proto/src/prost/v0_37/tendermint.types.rs b/proto/src/prost/v0_37/tendermint.types.rs index e83c89e62..faa700ab7 100644 --- a/proto/src/prost/v0_37/tendermint.types.rs +++ b/proto/src/prost/v0_37/tendermint.types.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_37/tendermint.version.rs b/proto/src/prost/v0_37/tendermint.version.rs index 8a77a26fc..fc7a8f448 100644 --- a/proto/src/prost/v0_37/tendermint.version.rs +++ b/proto/src/prost/v0_37/tendermint.version.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. /// App includes the protocol and software version for the application. /// This information is included in ResponseInfo. The App.Protocol can be /// updated in ResponseEndBlock. diff --git a/proto/src/serializers/bytes.rs b/proto/src/serializers/bytes.rs index fdf9af9f3..5cef5373a 100644 --- a/proto/src/serializers/bytes.rs +++ b/proto/src/serializers/bytes.rs @@ -31,6 +31,42 @@ pub mod hexstring { } } +/// Serialize into and deserialize from a sequence of _hexstring_. +pub mod vec_hexstring { + use serde::{Deserialize, Deserializer, Serializer}; + use subtle_encoding::hex; + + use crate::prelude::*; + use crate::serializers::cow_str::CowStr; + + /// Deserialize array into `Vec>` + pub fn deserialize<'de, D>(deserializer: D) -> Result>, D::Error> + where + D: Deserializer<'de>, + { + Option::>::deserialize(deserializer)? + .unwrap_or_default() + .into_iter() + .map(|s| hex::decode_upper(s).map_err(serde::de::Error::custom)) + .collect() + } + + /// Serialize from `Vec` into `Vec` + pub fn serialize(value: &[T], serializer: S) -> Result + where + S: Serializer, + T: AsRef<[u8]>, + { + let hexstrings = value + .iter() + .map(|v| { + String::from_utf8(hex::encode_upper(v.as_ref())).map_err(serde::ser::Error::custom) + }) + .collect::, S::Error>>()?; + serializer.serialize_some(&hexstrings) + } +} + /// Serialize into base64string, deserialize from base64string pub mod base64string { use serde::{Deserialize, Deserializer, Serializer}; diff --git a/tools/proto-compiler/src/constants.rs b/tools/proto-compiler/src/constants.rs index 2ef57630a..fd00feeba 100644 --- a/tools/proto-compiler/src/constants.rs +++ b/tools/proto-compiler/src/constants.rs @@ -39,6 +39,7 @@ const QUOTED: &str = r#"#[serde(with = "crate::serializers::from_str")]"#; const QUOTED_WITH_DEFAULT: &str = r#"#[serde(with = "crate::serializers::from_str", default)]"#; const DEFAULT: &str = r#"#[serde(default)]"#; const HEXSTRING: &str = r#"#[serde(with = "crate::serializers::bytes::hexstring")]"#; +const VEC_HEXSTRING: &str = r#"#[serde(with = "crate::serializers::bytes::vec_hexstring")]"#; const BASE64STRING: &str = r#"#[serde(with = "crate::serializers::bytes::base64string")]"#; const VEC_BASE64STRING: &str = r#"#[serde(with = "crate::serializers::bytes::vec_base64string")]"#; const OPTIONAL: &str = r#"#[serde(with = "crate::serializers::optional")]"#; @@ -107,6 +108,11 @@ pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ (".tendermint.types.BlockMeta", SERIALIZED), (".tendermint.types.TxProof", SERIALIZED), (".tendermint.crypto.Proof", SERIALIZED), + (".tendermint.types.RowProof", SERIALIZED), + (".tendermint.types.RowProof", DEFAULT), + (".tendermint.types.ShareProof", SERIALIZED), + (".tendermint.types.NMTProof", SERIALIZED), + (".tendermint.types.NMTProof", DEFAULT), ]; /// Custom field attributes applied on top of protobuf fields in (a) struct(s) @@ -221,4 +227,10 @@ pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ (".tendermint.types.TxProof.root_hash", HEXSTRING), (".tendermint.crypto.Proof.aunts", VEC_BASE64STRING), (".tendermint.crypto.Proof.leaf_hash", BASE64STRING), + (".tendermint.types.RowProof.row_roots", VEC_HEXSTRING), + (".tendermint.types.RowProof.root", BASE64STRING), + (".tendermint.types.ShareProof.data", VEC_BASE64STRING), + (".tendermint.types.ShareProof.namespace_id", BASE64STRING), + (".tendermint.types.NMTProof.nodes", VEC_BASE64STRING), + (".tendermint.types.NMTProof.leaf_hash", BASE64STRING), ];