diff --git a/proto/src/prost/v0_34/tendermint.abci.rs b/proto/src/prost/v0_34/tendermint.abci.rs index fbc793b73..d482ccfa0 100644 --- a/proto/src/prost/v0_34/tendermint.abci.rs +++ b/proto/src/prost/v0_34/tendermint.abci.rs @@ -3,7 +3,7 @@ pub struct Request { #[prost( oneof = "request::Value", - tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15" + tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17" )] pub value: ::core::option::Option, } @@ -42,6 +42,10 @@ pub mod request { LoadSnapshotChunk(super::RequestLoadSnapshotChunk), #[prost(message, tag = "15")] ApplySnapshotChunk(super::RequestApplySnapshotChunk), + #[prost(message, tag = "16")] + PrepareProposal(super::RequestPrepareProposal), + #[prost(message, tag = "17")] + ProcessProposal(super::RequestProcessProposal), } } #[allow(clippy::derive_partial_eq_without_eq)] @@ -174,10 +178,30 @@ pub struct RequestApplySnapshotChunk { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestPrepareProposal { + /// block_data is an array of transactions that will be included in a block, + /// sent to the app for possible modifications. + /// applications can not exceed the size of the data passed to it. + #[prost(message, optional, tag = "1")] + pub block_data: ::core::option::Option, + /// If an application decides to populate block_data with extra information, they can not exceed this value. + #[prost(int64, tag = "2")] + pub block_data_size: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestProcessProposal { + #[prost(message, optional, tag = "1")] + pub header: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub block_data: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct Response { #[prost( oneof = "response::Value", - tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16" + tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18" )] pub value: ::core::option::Option, } @@ -218,6 +242,10 @@ pub mod response { LoadSnapshotChunk(super::ResponseLoadSnapshotChunk), #[prost(message, tag = "16")] ApplySnapshotChunk(super::ResponseApplySnapshotChunk), + #[prost(message, tag = "17")] + PrepareProposal(super::ResponsePrepareProposal), + #[prost(message, tag = "18")] + ProcessProposal(super::ResponseProcessProposal), } } /// nondeterministic @@ -397,7 +425,17 @@ pub struct ResponseOfferSnapshot { } /// Nested message and enum types in `ResponseOfferSnapshot`. pub mod response_offer_snapshot { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] #[repr(i32)] pub enum Result { /// Unknown result, abort all snapshot restoration @@ -462,7 +500,17 @@ pub struct ResponseApplySnapshotChunk { } /// Nested message and enum types in `ResponseApplySnapshotChunk`. pub mod response_apply_snapshot_chunk { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] #[repr(i32)] pub enum Result { /// Unknown result, abort all snapshot restoration @@ -507,6 +555,65 @@ pub mod response_apply_snapshot_chunk { } } } +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponsePrepareProposal { + #[prost(message, optional, tag = "1")] + pub block_data: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseProcessProposal { + #[prost(enumeration = "response_process_proposal::Result", tag = "1")] + pub result: i32, + #[prost(bytes = "bytes", repeated, tag = "2")] + pub evidence: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>, +} +/// Nested message and enum types in `ResponseProcessProposal`. +pub mod response_process_proposal { + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Result { + /// Unknown result, invalidate + Unknown = 0, + /// proposal verified, vote on the proposal + Accept = 1, + /// proposal invalidated + Reject = 2, + } + impl Result { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Result::Unknown => "UNKNOWN", + Result::Accept => "ACCEPT", + Result::Reject => "REJECT", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNKNOWN" => Some(Self::Unknown), + "ACCEPT" => Some(Self::Accept), + "REJECT" => Some(Self::Reject), + _ => None, + } + } + } +} /// ConsensusParams contains all consensus-relevant parameters /// that can be adjusted by the abci app #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/proto/src/prost/v0_34/tendermint.mempool.rs b/proto/src/prost/v0_34/tendermint.mempool.rs index 9fec1376b..05c02dca2 100644 --- a/proto/src/prost/v0_34/tendermint.mempool.rs +++ b/proto/src/prost/v0_34/tendermint.mempool.rs @@ -6,8 +6,20 @@ pub struct Txs { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct SeenTx { + #[prost(bytes = "vec", tag = "1")] + pub tx_key: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WantTx { + #[prost(bytes = "vec", tag = "1")] + pub tx_key: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct Message { - #[prost(oneof = "message::Sum", tags = "1")] + #[prost(oneof = "message::Sum", tags = "1, 2, 3")] pub sum: ::core::option::Option, } /// Nested message and enum types in `Message`. @@ -17,5 +29,9 @@ pub mod message { pub enum Sum { #[prost(message, tag = "1")] Txs(super::Txs), + #[prost(message, tag = "2")] + SeenTx(super::SeenTx), + #[prost(message, tag = "3")] + WantTx(super::WantTx), } } diff --git a/proto/src/prost/v0_34/tendermint.p2p.rs b/proto/src/prost/v0_34/tendermint.p2p.rs index c95d86641..bfaa808cb 100644 --- a/proto/src/prost/v0_34/tendermint.p2p.rs +++ b/proto/src/prost/v0_34/tendermint.p2p.rs @@ -1,5 +1,48 @@ #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketPing {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketPong {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketMsg { + #[prost(int32, tag = "1")] + pub channel_id: i32, + #[prost(bool, tag = "2")] + pub eof: bool, + #[prost(bytes = "vec", tag = "3")] + pub data: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Packet { + #[prost(oneof = "packet::Sum", tags = "1, 2, 3")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Packet`. +pub mod packet { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + PacketPing(super::PacketPing), + #[prost(message, tag = "2")] + PacketPong(super::PacketPong), + #[prost(message, tag = "3")] + PacketMsg(super::PacketMsg), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AuthSigMessage { + #[prost(message, optional, tag = "1")] + pub pub_key: ::core::option::Option, + #[prost(bytes = "vec", tag = "2")] + pub sig: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct NetAddress { #[prost(string, tag = "1")] pub id: ::prost::alloc::string::String, @@ -48,49 +91,6 @@ pub struct DefaultNodeInfoOther { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct PacketPing {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PacketPong {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PacketMsg { - #[prost(int32, tag = "1")] - pub channel_id: i32, - #[prost(bool, tag = "2")] - pub eof: bool, - #[prost(bytes = "vec", tag = "3")] - pub data: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Packet { - #[prost(oneof = "packet::Sum", tags = "1, 2, 3")] - pub sum: ::core::option::Option, -} -/// Nested message and enum types in `Packet`. -pub mod packet { - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Sum { - #[prost(message, tag = "1")] - PacketPing(super::PacketPing), - #[prost(message, tag = "2")] - PacketPong(super::PacketPong), - #[prost(message, tag = "3")] - PacketMsg(super::PacketMsg), - } -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct AuthSigMessage { - #[prost(message, optional, tag = "1")] - pub pub_key: ::core::option::Option, - #[prost(bytes = "vec", tag = "2")] - pub sig: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] pub struct PexRequest {} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_34/tendermint.types.rs b/proto/src/prost/v0_34/tendermint.types.rs index c1001662a..6450b7083 100644 --- a/proto/src/prost/v0_34/tendermint.types.rs +++ b/proto/src/prost/v0_34/tendermint.types.rs @@ -130,17 +130,46 @@ pub struct Header { #[serde(with = "crate::serializers::bytes::hexstring")] pub proposer_address: ::prost::alloc::vec::Vec, } -/// Data contains the set of transactions included in the block +/// Data contains all the information needed for a consensus full node to +/// reconstruct an extended data square. #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Data { - /// Txs that will be applied by state @ block.Height+1. - /// NOTE: not all txs here are valid. We're just agreeing on the order first. - /// This means that block.AppHash does not include these txs. + /// Txs that will be applied to state in block.Height + 1 because deferred execution. + /// This means that the block.AppHash of this block does not include these txs. + /// NOTE: not all txs here are valid. We're just agreeing on the order first. #[prost(bytes = "vec", repeated, tag = "1")] #[serde(with = "crate::serializers::txs")] pub txs: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + /// SquareSize is the number of rows or columns in the original data square. + #[prost(uint64, tag = "5")] + pub square_size: u64, + /// Hash is the root of a binary Merkle tree where the leaves of the tree are + /// the row and column roots of an extended data square. Hash is often referred + /// to as the "data root". + #[prost(bytes = "vec", tag = "6")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub hash: ::prost::alloc::vec::Vec, +} +/// Blob (named after binary large object) is a chunk of data submitted by a user +/// to be published to the Celestia blockchain. The data of a Blob is published +/// to a namespace and is encoded into shares based on the format specified by +/// share_version. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Blob { + #[prost(bytes = "vec", tag = "1")] + #[serde(with = "crate::serializers::bytes::base64string")] + pub namespace_id: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "2")] + #[serde(with = "crate::serializers::bytes::base64string")] + pub data: ::prost::alloc::vec::Vec, + #[prost(uint32, tag = "3")] + pub share_version: u32, + #[prost(uint32, tag = "4")] + pub namespace_version: u32, } /// Vote represents a prevote, precommit, or commit vote from validators for /// consensus. @@ -254,7 +283,17 @@ pub struct BlockMeta { #[serde(with = "crate::serializers::from_str")] pub num_txs: i64, } -/// TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. +/// TxProof represents a Merkle proof of the presence of a transaction in the +/// Merkle tree. +/// +/// Note: TxProof is not used in celestia-core because of modifications to the +/// data root. In a normal Cosmos chain, the data root is the root of a Merkle +/// tree of transactions in the block. However, in Celestia the data root is the +/// root of the row and column roots in the extended data square. See +/// +/// for more details. Therefore, TxProof isn't sufficient to prove the existence +/// of a transaction in a Celestia block and ShareProof was defined instead. See +/// ShareProof for more details. #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -268,20 +307,93 @@ pub struct TxProof { #[prost(message, optional, tag = "3")] pub proof: ::core::option::Option, } +/// IndexWrapper adds index metadata to a transaction. This is used to track +/// transactions that pay for blobs, and where the blobs start in the square. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IndexWrapper { + #[prost(bytes = "vec", tag = "1")] + pub tx: ::prost::alloc::vec::Vec, + #[prost(uint32, repeated, tag = "2")] + pub share_indexes: ::prost::alloc::vec::Vec, + #[prost(string, tag = "3")] + pub type_id: ::prost::alloc::string::String, +} +/// BlobTx wraps an encoded sdk.Tx with a second field to contain blobs of data. +/// The raw bytes of the blobs are not signed over, instead we verify each blob +/// using the relevant MsgPayForBlobs that is signed over in the encoded sdk.Tx. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BlobTx { + #[prost(bytes = "vec", tag = "1")] + pub tx: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "2")] + pub blobs: ::prost::alloc::vec::Vec, + #[prost(string, tag = "3")] + pub type_id: ::prost::alloc::string::String, +} +/// 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. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ShareProof { + #[prost(bytes = "vec", repeated, tag = "1")] + 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")] + pub namespace_id: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "4")] + pub row_proof: ::core::option::Option, + #[prost(uint32, tag = "5")] + pub namespace_version: u32, +} +/// RowProof is a Merkle proof that a set of rows exist in a Merkle tree with a +/// given data root. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RowProof { + #[prost(bytes = "vec", repeated, tag = "1")] + 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")] + pub root: ::prost::alloc::vec::Vec, + #[prost(uint32, tag = "4")] + pub start_row: u32, + #[prost(uint32, tag = "5")] + pub end_row: u32, +} +/// NMTProof is a proof of a namespace.ID in an NMT. +/// 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. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NmtProof { + /// Start index of this proof. + #[prost(int32, tag = "1")] + pub start: i32, + /// End index of this proof. + #[prost(int32, tag = "2")] + pub end: i32, + /// Nodes that together with the corresponding leaf values can be used to + /// recompute the root and verify this proof. Nodes should consist of the max + /// and min namespaces along with the actual hash, resulting in each being 48 + /// bytes each + #[prost(bytes = "vec", repeated, tag = "3")] + 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 + /// will contain the leaf hash necessary to verify the proof of absence. Leaf + /// hashes should consist of the namespace along with the actual hash, + /// resulting 40 bytes total. + #[prost(bytes = "vec", tag = "4")] + pub leaf_hash: ::prost::alloc::vec::Vec, +} /// BlockIdFlag indicates which BlcokID the signature is for -#[derive( - ::num_derive::FromPrimitive, - ::num_derive::ToPrimitive, - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration, -)] +#[derive(::num_derive::FromPrimitive, ::num_derive::ToPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum BlockIdFlag { Unknown = 0, @@ -348,16 +460,6 @@ impl SignedMsgType { } } } -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct EventDataRoundState { - #[prost(int64, tag = "1")] - pub height: i64, - #[prost(int32, tag = "2")] - pub round: i32, - #[prost(string, tag = "3")] - pub step: ::prost::alloc::string::String, -} /// ConsensusParams contains consensus critical parameters that determine the /// validity of blocks. #[allow(clippy::derive_partial_eq_without_eq)] @@ -513,6 +615,29 @@ pub struct EvidenceList { #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct Block { + #[prost(message, optional, tag = "1")] + pub header: ::core::option::Option
, + #[prost(message, optional, tag = "2")] + pub data: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub evidence: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub last_commit: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EventDataRoundState { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(string, tag = "3")] + pub step: ::prost::alloc::string::String, +} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct CanonicalBlockId { #[prost(bytes = "vec", tag = "1")] pub hash: ::prost::alloc::vec::Vec, @@ -569,16 +694,3 @@ pub struct CanonicalVote { #[prost(string, tag = "6")] pub chain_id: ::prost::alloc::string::String, } -#[derive(::serde::Deserialize, ::serde::Serialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Block { - #[prost(message, optional, tag = "1")] - pub header: ::core::option::Option
, - #[prost(message, optional, tag = "2")] - pub data: ::core::option::Option, - #[prost(message, optional, tag = "3")] - pub evidence: ::core::option::Option, - #[prost(message, optional, tag = "4")] - pub last_commit: ::core::option::Option, -} diff --git a/proto/src/prost/v0_37/tendermint.p2p.rs b/proto/src/prost/v0_37/tendermint.p2p.rs index c95d86641..bfaa808cb 100644 --- a/proto/src/prost/v0_37/tendermint.p2p.rs +++ b/proto/src/prost/v0_37/tendermint.p2p.rs @@ -1,5 +1,48 @@ #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketPing {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketPong {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PacketMsg { + #[prost(int32, tag = "1")] + pub channel_id: i32, + #[prost(bool, tag = "2")] + pub eof: bool, + #[prost(bytes = "vec", tag = "3")] + pub data: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Packet { + #[prost(oneof = "packet::Sum", tags = "1, 2, 3")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Packet`. +pub mod packet { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + PacketPing(super::PacketPing), + #[prost(message, tag = "2")] + PacketPong(super::PacketPong), + #[prost(message, tag = "3")] + PacketMsg(super::PacketMsg), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AuthSigMessage { + #[prost(message, optional, tag = "1")] + pub pub_key: ::core::option::Option, + #[prost(bytes = "vec", tag = "2")] + pub sig: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct NetAddress { #[prost(string, tag = "1")] pub id: ::prost::alloc::string::String, @@ -48,49 +91,6 @@ pub struct DefaultNodeInfoOther { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct PacketPing {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PacketPong {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PacketMsg { - #[prost(int32, tag = "1")] - pub channel_id: i32, - #[prost(bool, tag = "2")] - pub eof: bool, - #[prost(bytes = "vec", tag = "3")] - pub data: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Packet { - #[prost(oneof = "packet::Sum", tags = "1, 2, 3")] - pub sum: ::core::option::Option, -} -/// Nested message and enum types in `Packet`. -pub mod packet { - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Sum { - #[prost(message, tag = "1")] - PacketPing(super::PacketPing), - #[prost(message, tag = "2")] - PacketPong(super::PacketPong), - #[prost(message, tag = "3")] - PacketMsg(super::PacketMsg), - } -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct AuthSigMessage { - #[prost(message, optional, tag = "1")] - pub pub_key: ::core::option::Option, - #[prost(bytes = "vec", tag = "2")] - pub sig: ::prost::alloc::vec::Vec, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] pub struct PexRequest {} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/v0_37/tendermint.types.rs b/proto/src/prost/v0_37/tendermint.types.rs index ff28c0eb2..fde9f6c1d 100644 --- a/proto/src/prost/v0_37/tendermint.types.rs +++ b/proto/src/prost/v0_37/tendermint.types.rs @@ -269,19 +269,8 @@ pub struct TxProof { pub proof: ::core::option::Option, } /// BlockIdFlag indicates which BlcokID the signature is for -#[derive( - ::num_derive::FromPrimitive, - ::num_derive::ToPrimitive, - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration, -)] +#[derive(::num_derive::FromPrimitive, ::num_derive::ToPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum BlockIdFlag { Unknown = 0, @@ -348,6 +337,85 @@ impl SignedMsgType { } } } +/// ConsensusParams contains consensus critical parameters that determine the +/// validity of blocks. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConsensusParams { + #[prost(message, optional, tag = "1")] + pub block: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub evidence: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub validator: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub version: ::core::option::Option, +} +/// BlockParams contains limits on the block size. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BlockParams { + /// Max block size, in bytes. + /// Note: must be greater than 0 + #[prost(int64, tag = "1")] + pub max_bytes: i64, + /// Max gas per block. + /// Note: must be greater or equal to -1 + #[prost(int64, tag = "2")] + pub max_gas: i64, +} +/// EvidenceParams determine how we handle evidence of malfeasance. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EvidenceParams { + /// Max age of evidence, in blocks. + /// + /// The basic formula for calculating this is: MaxAgeDuration / {average block + /// time}. + #[prost(int64, tag = "1")] + #[serde(with = "crate::serializers::from_str", default)] + pub max_age_num_blocks: i64, + /// Max age of evidence, in time. + /// + /// It should correspond with an app's "unbonding period" or other similar + /// mechanism for handling [Nothing-At-Stake + /// attacks](). + #[prost(message, optional, tag = "2")] + pub max_age_duration: ::core::option::Option, + /// This sets the maximum size of total evidence in bytes that can be committed in a single block. + /// and should fall comfortably under the max block bytes. + /// Default is 1048576 or 1MB + #[prost(int64, tag = "3")] + #[serde(with = "crate::serializers::from_str", default)] + pub max_bytes: i64, +} +/// ValidatorParams restrict the public key types validators can use. +/// NOTE: uses ABCI pubkey naming, not Amino names. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValidatorParams { + #[prost(string, repeated, tag = "1")] + pub pub_key_types: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +/// VersionParams contains the ABCI application version. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VersionParams { + #[prost(uint64, tag = "1")] + pub app: u64, +} +/// HashedParams is a subset of ConsensusParams. +/// +/// It is hashed into the Header.ConsensusHash. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HashedParams { + #[prost(int64, tag = "1")] + pub block_max_bytes: i64, + #[prost(int64, tag = "2")] + pub block_max_gas: i64, +} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Evidence { @@ -438,85 +506,6 @@ pub struct EventDataRoundState { #[prost(string, tag = "3")] pub step: ::prost::alloc::string::String, } -/// ConsensusParams contains consensus critical parameters that determine the -/// validity of blocks. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ConsensusParams { - #[prost(message, optional, tag = "1")] - pub block: ::core::option::Option, - #[prost(message, optional, tag = "2")] - pub evidence: ::core::option::Option, - #[prost(message, optional, tag = "3")] - pub validator: ::core::option::Option, - #[prost(message, optional, tag = "4")] - pub version: ::core::option::Option, -} -/// BlockParams contains limits on the block size. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct BlockParams { - /// Max block size, in bytes. - /// Note: must be greater than 0 - #[prost(int64, tag = "1")] - pub max_bytes: i64, - /// Max gas per block. - /// Note: must be greater or equal to -1 - #[prost(int64, tag = "2")] - pub max_gas: i64, -} -/// EvidenceParams determine how we handle evidence of malfeasance. -#[derive(::serde::Deserialize, ::serde::Serialize)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct EvidenceParams { - /// Max age of evidence, in blocks. - /// - /// The basic formula for calculating this is: MaxAgeDuration / {average block - /// time}. - #[prost(int64, tag = "1")] - #[serde(with = "crate::serializers::from_str", default)] - pub max_age_num_blocks: i64, - /// Max age of evidence, in time. - /// - /// It should correspond with an app's "unbonding period" or other similar - /// mechanism for handling [Nothing-At-Stake - /// attacks](). - #[prost(message, optional, tag = "2")] - pub max_age_duration: ::core::option::Option, - /// This sets the maximum size of total evidence in bytes that can be committed in a single block. - /// and should fall comfortably under the max block bytes. - /// Default is 1048576 or 1MB - #[prost(int64, tag = "3")] - #[serde(with = "crate::serializers::from_str", default)] - pub max_bytes: i64, -} -/// ValidatorParams restrict the public key types validators can use. -/// NOTE: uses ABCI pubkey naming, not Amino names. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ValidatorParams { - #[prost(string, repeated, tag = "1")] - pub pub_key_types: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -/// VersionParams contains the ABCI application version. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct VersionParams { - #[prost(uint64, tag = "1")] - pub app: u64, -} -/// HashedParams is a subset of ConsensusParams. -/// -/// It is hashed into the Header.ConsensusHash. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct HashedParams { - #[prost(int64, tag = "1")] - pub block_max_bytes: i64, - #[prost(int64, tag = "2")] - pub block_max_gas: i64, -} #[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/tendermint/v0_34.rs b/proto/src/tendermint/v0_34.rs index 561b12534..feb43ede9 100644 --- a/proto/src/tendermint/v0_34.rs +++ b/proto/src/tendermint/v0_34.rs @@ -61,6 +61,6 @@ pub mod version { } pub mod meta { - pub const REPOSITORY: &str = "https://github.com/cometbft/cometbft"; - pub const COMMITISH: &str = "v0.34.27"; + pub const REPOSITORY: &str = "https://github.com/celestiaorg/celestia-core"; + pub const COMMITISH: &str = "v0.34.x-celestia"; } diff --git a/tendermint/src/abci/request/prepare_proposal.rs b/tendermint/src/abci/request/prepare_proposal.rs index a95dc691e..8928e2d32 100644 --- a/tendermint/src/abci/request/prepare_proposal.rs +++ b/tendermint/src/abci/request/prepare_proposal.rs @@ -1,78 +1,45 @@ +use crate::block::Data; use crate::prelude::*; -use crate::{ - abci::types::{CommitInfo, Misbehavior}, - account, block, Error, Hash, Time, -}; - -use bytes::Bytes; #[doc = include_str!("../doc/request-prepareproposal.md")] #[derive(Clone, Debug, PartialEq, Eq)] pub struct PrepareProposal { - /// the modified transactions cannot exceed this size. - pub max_tx_bytes: i64, - /// txs is an array of transactions that will be included in a block, - /// sent to the app for possible modifications. - pub txs: Vec, - pub local_last_commit: Option, - pub misbehavior: Vec, - pub height: block::Height, - pub time: Time, - pub next_validators_hash: Hash, - /// address of the public key of the validator proposing the block. - pub proposer_address: account::Id, + pub block_data: Data, + pub block_data_size: i64, } // ============================================================================= // Protobuf conversions // ============================================================================= -// The PrepareProposal request has been added in 0.37. - -use tendermint_proto::v0_37::abci as pb; -use tendermint_proto::Protobuf; - -impl From for pb::RequestPrepareProposal { - fn from(value: PrepareProposal) -> Self { - Self { - max_tx_bytes: value.max_tx_bytes, - txs: value.txs, - local_last_commit: value.local_last_commit.map(Into::into), - misbehavior: value.misbehavior.into_iter().map(Into::into).collect(), - height: value.height.into(), - time: Some(value.time.into()), - next_validators_hash: value.next_validators_hash.into(), - proposer_address: value.proposer_address.into(), +mod v0_34 { + use super::PrepareProposal; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_34::abci as pb; + use tendermint_proto::Protobuf; + + impl From for pb::RequestPrepareProposal { + fn from(value: PrepareProposal) -> Self { + Self { + block_data: Some(value.block_data.into()), + block_data_size: value.block_data_size, + } } } -} -impl TryFrom for PrepareProposal { - type Error = Error; - - fn try_from(message: pb::RequestPrepareProposal) -> Result { - let req = Self { - max_tx_bytes: message.max_tx_bytes, - txs: message.txs, - local_last_commit: message - .local_last_commit - .map(TryInto::try_into) - .transpose()?, - misbehavior: message - .misbehavior - .into_iter() - .map(TryInto::try_into) - .collect::, _>>()?, - height: message.height.try_into()?, - time: message - .time - .ok_or_else(Error::missing_timestamp)? - .try_into()?, - next_validators_hash: message.next_validators_hash.try_into()?, - proposer_address: message.proposer_address.try_into()?, - }; - Ok(req) + impl TryFrom for PrepareProposal { + type Error = Error; + + fn try_from(message: pb::RequestPrepareProposal) -> Result { + Ok(PrepareProposal { + block_data: message + .block_data + .ok_or_else(Error::missing_data)? + .try_into()?, + block_data_size: message.block_data_size, + }) + } } -} -impl Protobuf for PrepareProposal {} + impl Protobuf for PrepareProposal {} +} diff --git a/tendermint/src/abci/request/process_proposal.rs b/tendermint/src/abci/request/process_proposal.rs index bb3020048..088fe09eb 100644 --- a/tendermint/src/abci/request/process_proposal.rs +++ b/tendermint/src/abci/request/process_proposal.rs @@ -1,77 +1,48 @@ +use crate::block::{Data, Header}; use crate::prelude::*; -use crate::{ - abci::types::{CommitInfo, Misbehavior}, - account, block, Error, Hash, Time, -}; - -use bytes::Bytes; #[doc = include_str!("../doc/request-processproposal.md")] #[derive(Clone, Debug, PartialEq, Eq)] pub struct ProcessProposal { - /// txs is an array of transactions that will be included in a block, - /// sent to the app for possible modifications. - pub txs: Vec, - pub proposed_last_commit: Option, - pub misbehavior: Vec, - pub hash: Hash, - pub height: block::Height, - pub time: Time, - pub next_validators_hash: Hash, - /// address of the public key of the validator proposing the block. - pub proposer_address: account::Id, + pub header: Header, + pub block_data: Data, } // ============================================================================= // Protobuf conversions // ============================================================================= -// The ProcessProposal request has been added in 0.37. - -use tendermint_proto::v0_37::abci as pb; -use tendermint_proto::Protobuf; - -impl From for pb::RequestProcessProposal { - fn from(value: ProcessProposal) -> Self { - Self { - txs: value.txs, - proposed_last_commit: value.proposed_last_commit.map(Into::into), - misbehavior: value.misbehavior.into_iter().map(Into::into).collect(), - hash: value.hash.into(), - height: value.height.into(), - time: Some(value.time.into()), - next_validators_hash: value.next_validators_hash.into(), - proposer_address: value.proposer_address.into(), +mod v0_34 { + use super::ProcessProposal; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_34::abci as pb; + use tendermint_proto::Protobuf; + + impl From for pb::RequestProcessProposal { + fn from(value: ProcessProposal) -> Self { + Self { + header: Some(value.header.into()), + block_data: Some(value.block_data.into()), + } } } -} -impl TryFrom for ProcessProposal { - type Error = Error; - - fn try_from(message: pb::RequestProcessProposal) -> Result { - let req = Self { - txs: message.txs, - proposed_last_commit: message - .proposed_last_commit - .map(TryInto::try_into) - .transpose()?, - misbehavior: message - .misbehavior - .into_iter() - .map(TryInto::try_into) - .collect::, _>>()?, - hash: message.hash.try_into()?, - height: message.height.try_into()?, - time: message - .time - .ok_or_else(Error::missing_timestamp)? - .try_into()?, - next_validators_hash: message.next_validators_hash.try_into()?, - proposer_address: message.proposer_address.try_into()?, - }; - Ok(req) + impl TryFrom for ProcessProposal { + type Error = Error; + + fn try_from(message: pb::RequestProcessProposal) -> Result { + Ok(ProcessProposal { + header: message + .header + .ok_or_else(Error::missing_header)? + .try_into()?, + block_data: message + .block_data + .ok_or_else(Error::missing_data)? + .try_into()?, + }) + } } -} -impl Protobuf for ProcessProposal {} + impl Protobuf for ProcessProposal {} +} diff --git a/tendermint/src/abci/response/prepare_proposal.rs b/tendermint/src/abci/response/prepare_proposal.rs index d8facfed5..fc7b7b10f 100644 --- a/tendermint/src/abci/response/prepare_proposal.rs +++ b/tendermint/src/abci/response/prepare_proposal.rs @@ -1,34 +1,42 @@ -use bytes::Bytes; - +use crate::block::Data; use crate::prelude::*; #[doc = include_str!("../doc/response-prepareproposal.md")] #[derive(Clone, Debug, PartialEq, Eq)] pub struct PrepareProposal { - pub txs: Vec, + pub block_data: Data, } // ============================================================================= // Protobuf conversions // ============================================================================= -// PrepareProposal has been introduced in 0.37. - -use tendermint_proto::v0_37::abci as pb; -use tendermint_proto::Protobuf; - -impl From for pb::ResponsePrepareProposal { - fn from(value: PrepareProposal) -> Self { - Self { txs: value.txs } +mod v0_34 { + use super::PrepareProposal; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_34::abci as pb; + use tendermint_proto::Protobuf; + + impl From for pb::ResponsePrepareProposal { + fn from(value: PrepareProposal) -> Self { + Self { + block_data: Some(value.block_data.into()), + } + } } -} -impl TryFrom for PrepareProposal { - type Error = crate::Error; - - fn try_from(message: pb::ResponsePrepareProposal) -> Result { - Ok(Self { txs: message.txs }) + impl TryFrom for PrepareProposal { + type Error = Error; + + fn try_from(message: pb::ResponsePrepareProposal) -> Result { + Ok(Self { + block_data: message + .block_data + .ok_or_else(Error::missing_data)? + .try_into()?, + }) + } } -} -impl Protobuf for PrepareProposal {} + impl Protobuf for PrepareProposal {} +} diff --git a/tendermint/src/abci/response/process_proposal.rs b/tendermint/src/abci/response/process_proposal.rs index 9e3d6d50c..5c8b44729 100644 --- a/tendermint/src/abci/response/process_proposal.rs +++ b/tendermint/src/abci/response/process_proposal.rs @@ -1,10 +1,18 @@ use crate::prelude::*; +use bytes::Bytes; + #[doc = include_str!("../doc/response-processproposal.md")] +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ProcessProposal { + pub result: ProcessProposalResult, + pub evidence: Vec, +} + #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(i32)] #[derive(Default)] -pub enum ProcessProposal { +pub enum ProcessProposalResult { #[default] Unknown = 0, Accept = 1, @@ -15,72 +23,42 @@ pub enum ProcessProposal { // Protobuf conversions // ============================================================================= -// ProcessProposal has been introduced in 0.37. - -use tendermint_proto::v0_37::abci as pb; -use tendermint_proto::Protobuf; +mod v0_34 { + use super::{ProcessProposal, ProcessProposalResult}; + use crate::Error; + use tendermint_proto::v0_34::abci as pb; + use tendermint_proto::Protobuf; -impl From for pb::ResponseProcessProposal { - fn from(value: ProcessProposal) -> Self { - Self { - status: value as i32, + impl From for pb::ResponseProcessProposal { + fn from(value: ProcessProposal) -> pb::ResponseProcessProposal { + pb::ResponseProcessProposal { + result: value.result as i32, + evidence: value.evidence, + } } } -} -impl TryFrom for ProcessProposal { - type Error = crate::Error; + impl TryFrom for ProcessProposal { + type Error = Error; - fn try_from(message: pb::ResponseProcessProposal) -> Result { - let value = match message.status { - 0 => ProcessProposal::Unknown, - 1 => ProcessProposal::Accept, - 2 => ProcessProposal::Reject, - _ => return Err(crate::Error::unsupported_process_proposal_status()), - }; - Ok(value) - } -} + fn try_from(message: pb::ResponseProcessProposal) -> Result { + use pb::response_process_proposal::Result; -impl Protobuf for ProcessProposal {} + let result = Result::from_i32(message.result) + .ok_or_else(Error::unsupported_process_proposal_result)?; -#[cfg(test)] -mod tests { - use super::*; - use crate::error::ErrorDetail; + let result = match result { + Result::Unknown => ProcessProposalResult::Unknown, + Result::Accept => ProcessProposalResult::Accept, + Result::Reject => ProcessProposalResult::Reject, + }; - use std::collections::HashMap; - - #[test] - fn all_status_values_are_covered() { - use pb::response_process_proposal::ProposalStatus::*; - - const FIRST_INVALID_STATUS: i32 = 3; - - let mut covered = HashMap::new(); - for v in [Unknown, Accept, Reject] { - // Match the generated enum values exhaustively - match v { - Unknown | Accept | Reject => { - covered.insert(v as i32, false); - }, - } + Ok(ProcessProposal { + result, + evidence: message.evidence, + }) } - for status in 0..FIRST_INVALID_STATUS { - let message = pb::ResponseProcessProposal { status }; - let response: ProcessProposal = message.try_into().unwrap(); - assert_eq!(response as i32, status); - covered.insert(status, true); - } - assert!(covered.values().all(|&x| x)); - - let message = pb::ResponseProcessProposal { - status: FIRST_INVALID_STATUS, - }; - let err = ProcessProposal::try_from(message).err().unwrap(); - assert!(matches!( - err.0, - ErrorDetail::UnsupportedProcessProposalStatus(_), - )); } + + impl Protobuf for ProcessProposal {} } diff --git a/tendermint/src/block.rs b/tendermint/src/block.rs index 2898d7a79..bf352adbe 100644 --- a/tendermint/src/block.rs +++ b/tendermint/src/block.rs @@ -2,6 +2,7 @@ mod commit; pub mod commit_sig; +mod data; pub mod header; mod height; mod id; @@ -12,11 +13,12 @@ pub mod signed_header; mod size; use serde::{Deserialize, Serialize}; -use tendermint_proto::v0_37::types::Block as RawBlock; +use tendermint_proto::v0_34::types::Block as RawBlock; pub use self::{ commit::*, commit_sig::*, + data::Data, header::Header, height::*, id::{Id, ParseId}, @@ -39,7 +41,7 @@ pub struct Block { pub header: Header, /// Transaction data - pub data: Vec>, + pub data: Data, /// Evidence of malfeasance pub evidence: evidence::List, @@ -48,10 +50,11 @@ pub struct Block { pub last_commit: Option, } -tendermint_pb_modules! { - use super::{Block, Header, Commit}; - use crate::{Error, prelude::*}; - use pb::types::Block as RawBlock; +mod v0_34 { + use super::{Block, Commit, Header}; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_34::types::Block as RawBlock; + use tendermint_proto::Protobuf; impl Protobuf for Block {} @@ -80,8 +83,12 @@ tendermint_pb_modules! { Ok(Block { header, - data: value.data.ok_or_else(Error::missing_data)?.txs, - evidence: value.evidence.map(TryInto::try_into).transpose()?.unwrap_or_default(), + data: value.data.ok_or_else(Error::missing_data)?.try_into()?, + evidence: value + .evidence + .map(TryInto::try_into) + .transpose()? + .unwrap_or_default(), last_commit, }) } @@ -89,10 +96,9 @@ tendermint_pb_modules! { impl From for RawBlock { fn from(value: Block) -> Self { - use pb::types::Data as RawData; RawBlock { header: Some(value.header.into()), - data: Some(RawData { txs: value.data }), + data: Some(value.data.into()), evidence: Some(value.evidence.into()), last_commit: value.last_commit.map(Into::into), } @@ -104,7 +110,7 @@ impl Block { /// constructor pub fn new( header: Header, - data: Vec>, + data: Data, evidence: evidence::List, last_commit: Option, ) -> Result { @@ -132,7 +138,7 @@ impl Block { } /// Get data - pub fn data(&self) -> &Vec> { + pub fn data(&self) -> &Data { &self.data } diff --git a/tendermint/src/block/data.rs b/tendermint/src/block/data.rs new file mode 100644 index 000000000..59430a3fb --- /dev/null +++ b/tendermint/src/block/data.rs @@ -0,0 +1,44 @@ +use serde::{Deserialize, Serialize}; +use tendermint_proto::v0_34::types::Data as RawData; + +use crate::prelude::*; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +#[non_exhaustive] +#[serde(try_from = "RawData", into = "RawData")] +pub struct Data { + pub txs: Vec>, + pub square_size: u64, + pub hash: Vec, +} + +mod v0_34 { + use super::Data; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_34::types::Data as RawData; + use tendermint_proto::Protobuf; + + impl Protobuf for Data {} + + impl TryFrom for Data { + type Error = Error; + + fn try_from(value: RawData) -> Result { + Ok(Data { + txs: value.txs, + square_size: value.square_size, + hash: value.hash, + }) + } + } + + impl From for RawData { + fn from(value: Data) -> RawData { + RawData { + txs: value.txs, + square_size: value.square_size, + hash: value.hash, + } + } + } +} diff --git a/tendermint/src/error.rs b/tendermint/src/error.rs index 56abab5d9..3999b9f16 100644 --- a/tendermint/src/error.rs +++ b/tendermint/src/error.rs @@ -188,8 +188,8 @@ define_error! { UnsupportedOfferSnapshotChunkResult |_| { format_args!("unsupported OfferSnapshotChunkResult type" ) }, - UnsupportedProcessProposalStatus - |_| { format_args!("unsupported ProcessProposal status value" ) }, + UnsupportedProcessProposalResult + |_| { format_args!("unsupported ProcessProposal result value" ) }, NegativeMaxAgeNum [ DisplayOnly ] diff --git a/tendermint/src/v0_34/abci/request.rs b/tendermint/src/v0_34/abci/request.rs index 6199750b8..ea6699546 100644 --- a/tendermint/src/v0_34/abci/request.rs +++ b/tendermint/src/v0_34/abci/request.rs @@ -7,7 +7,8 @@ use crate::Error; pub use crate::abci::request::{ ApplySnapshotChunk, BeginBlock, CheckTx, CheckTxKind, DeliverTx, Echo, EndBlock, Info, - InitChain, LoadSnapshotChunk, OfferSnapshot, Query, SetOption, + InitChain, LoadSnapshotChunk, OfferSnapshot, PrepareProposal, ProcessProposal, Query, + SetOption, }; /// All possible ABCI requests. @@ -44,6 +45,8 @@ pub enum Request { LoadSnapshotChunk(LoadSnapshotChunk), #[doc = include_str!("../../abci/doc/request-applysnapshotchunk.md")] ApplySnapshotChunk(ApplySnapshotChunk), + PrepareProposal(PrepareProposal), + ProcessProposal(ProcessProposal), } impl Request { @@ -53,6 +56,8 @@ impl Request { match self { Flush => MethodKind::Flush, InitChain(_) => MethodKind::Consensus, + PrepareProposal(_) => MethodKind::Consensus, + ProcessProposal(_) => MethodKind::Consensus, BeginBlock(_) => MethodKind::Consensus, DeliverTx(_) => MethodKind::Consensus, EndBlock(_) => MethodKind::Consensus, @@ -191,6 +196,8 @@ impl From for pb::Request { Request::OfferSnapshot(x) => Some(Value::OfferSnapshot(x.into())), Request::LoadSnapshotChunk(x) => Some(Value::LoadSnapshotChunk(x.into())), Request::ApplySnapshotChunk(x) => Some(Value::ApplySnapshotChunk(x.into())), + Request::PrepareProposal(x) => Some(Value::PrepareProposal(x.into())), + Request::ProcessProposal(x) => Some(Value::ProcessProposal(x.into())), }; pb::Request { value } } @@ -217,6 +224,8 @@ impl TryFrom for Request { Some(Value::OfferSnapshot(x)) => Ok(Request::OfferSnapshot(x.try_into()?)), Some(Value::LoadSnapshotChunk(x)) => Ok(Request::LoadSnapshotChunk(x.try_into()?)), Some(Value::ApplySnapshotChunk(x)) => Ok(Request::ApplySnapshotChunk(x.try_into()?)), + Some(Value::PrepareProposal(x)) => Ok(Request::PrepareProposal(x.try_into()?)), + Some(Value::ProcessProposal(x)) => Ok(Request::ProcessProposal(x.try_into()?)), None => Err(crate::Error::missing_data()), } } diff --git a/tendermint/src/v0_34/abci/response.rs b/tendermint/src/v0_34/abci/response.rs index 3ab12b894..8b6719e84 100644 --- a/tendermint/src/v0_34/abci/response.rs +++ b/tendermint/src/v0_34/abci/response.rs @@ -1,6 +1,7 @@ pub use crate::abci::response::{ ApplySnapshotChunk, BeginBlock, CheckTx, Commit, DeliverTx, Echo, EndBlock, Exception, Info, - InitChain, ListSnapshots, LoadSnapshotChunk, OfferSnapshot, Query, SetOption, + InitChain, ListSnapshots, LoadSnapshotChunk, OfferSnapshot, PrepareProposal, ProcessProposal, + Query, SetOption, }; use crate::abci::response::{ConsensusResponse, InfoResponse, MempoolResponse, SnapshotResponse}; use crate::Error; @@ -40,6 +41,8 @@ pub enum Response { LoadSnapshotChunk(LoadSnapshotChunk), #[doc = include_str!("../../abci/doc/response-applysnapshotchunk.md")] ApplySnapshotChunk(ApplySnapshotChunk), + PrepareProposal(PrepareProposal), + ProcessProposal(ProcessProposal), } impl From for Response { @@ -167,6 +170,8 @@ impl From for pb::Response { Response::OfferSnapshot(x) => Some(Value::OfferSnapshot(x.into())), Response::LoadSnapshotChunk(x) => Some(Value::LoadSnapshotChunk(x.into())), Response::ApplySnapshotChunk(x) => Some(Value::ApplySnapshotChunk(x.into())), + Response::PrepareProposal(x) => Some(Value::PrepareProposal(x.into())), + Response::ProcessProposal(x) => Some(Value::ProcessProposal(x.into())), }; pb::Response { value } } @@ -194,6 +199,8 @@ impl TryFrom for Response { Some(Value::OfferSnapshot(x)) => Ok(Response::OfferSnapshot(x.try_into()?)), Some(Value::LoadSnapshotChunk(x)) => Ok(Response::LoadSnapshotChunk(x.try_into()?)), Some(Value::ApplySnapshotChunk(x)) => Ok(Response::ApplySnapshotChunk(x.try_into()?)), + Some(Value::PrepareProposal(x)) => Ok(Response::PrepareProposal(x.try_into()?)), + Some(Value::ProcessProposal(x)) => Ok(Response::ProcessProposal(x.try_into()?)), None => Err(crate::Error::missing_data()), } } diff --git a/tendermint/src/v0_37/abci/request.rs b/tendermint/src/v0_37/abci/request.rs index fce4d19c8..619fa7d44 100644 --- a/tendermint/src/v0_37/abci/request.rs +++ b/tendermint/src/v0_37/abci/request.rs @@ -190,8 +190,8 @@ impl From for pb::Request { Request::OfferSnapshot(x) => Some(Value::OfferSnapshot(x.into())), Request::LoadSnapshotChunk(x) => Some(Value::LoadSnapshotChunk(x.into())), Request::ApplySnapshotChunk(x) => Some(Value::ApplySnapshotChunk(x.into())), - Request::PrepareProposal(x) => Some(Value::PrepareProposal(x.into())), - Request::ProcessProposal(x) => Some(Value::ProcessProposal(x.into())), + Request::PrepareProposal(_) => panic!("unsupported"), + Request::ProcessProposal(_) => panic!("unsupported"), }; pb::Request { value } } @@ -217,8 +217,8 @@ impl TryFrom for Request { Some(Value::OfferSnapshot(x)) => Ok(Request::OfferSnapshot(x.try_into()?)), Some(Value::LoadSnapshotChunk(x)) => Ok(Request::LoadSnapshotChunk(x.try_into()?)), Some(Value::ApplySnapshotChunk(x)) => Ok(Request::ApplySnapshotChunk(x.try_into()?)), - Some(Value::PrepareProposal(x)) => Ok(Request::PrepareProposal(x.try_into()?)), - Some(Value::ProcessProposal(x)) => Ok(Request::ProcessProposal(x.try_into()?)), + Some(Value::PrepareProposal(_)) => panic!("unsupported"), + Some(Value::ProcessProposal(_)) => panic!("unsupported"), None => Err(crate::Error::missing_data()), } } diff --git a/tendermint/src/v0_37/abci/response.rs b/tendermint/src/v0_37/abci/response.rs index 831f2783c..2c6c25803 100644 --- a/tendermint/src/v0_37/abci/response.rs +++ b/tendermint/src/v0_37/abci/response.rs @@ -166,8 +166,8 @@ impl From for pb::Response { Response::OfferSnapshot(x) => Some(Value::OfferSnapshot(x.into())), Response::LoadSnapshotChunk(x) => Some(Value::LoadSnapshotChunk(x.into())), Response::ApplySnapshotChunk(x) => Some(Value::ApplySnapshotChunk(x.into())), - Response::PrepareProposal(x) => Some(Value::PrepareProposal(x.into())), - Response::ProcessProposal(x) => Some(Value::ProcessProposal(x.into())), + Response::PrepareProposal(_) => unimplemented!("unsupported"), + Response::ProcessProposal(_) => unimplemented!("unsupported"), }; pb::Response { value } } @@ -194,8 +194,8 @@ impl TryFrom for Response { Some(Value::OfferSnapshot(x)) => Ok(Response::OfferSnapshot(x.try_into()?)), Some(Value::LoadSnapshotChunk(x)) => Ok(Response::LoadSnapshotChunk(x.try_into()?)), Some(Value::ApplySnapshotChunk(x)) => Ok(Response::ApplySnapshotChunk(x.try_into()?)), - Some(Value::PrepareProposal(x)) => Ok(Response::PrepareProposal(x.try_into()?)), - Some(Value::ProcessProposal(x)) => Ok(Response::ProcessProposal(x.try_into()?)), + Some(Value::PrepareProposal(_)) => unimplemented!("unsupported"), + Some(Value::ProcessProposal(_)) => unimplemented!("unsupported"), None => Err(crate::Error::missing_data()), } } diff --git a/tools/proto-compiler/README.md b/tools/proto-compiler/README.md index 39b738a93..a70e4794d 100644 --- a/tools/proto-compiler/README.md +++ b/tools/proto-compiler/README.md @@ -1,5 +1,6 @@ ## How to compile fresh proto structs +* install `buf` * `cargo run` in the compiler folder. The resultant structs will be created in the `proto/src/prost` folder. diff --git a/tools/proto-compiler/src/constants.rs b/tools/proto-compiler/src/constants.rs index 7485089a9..2c9fb3d85 100644 --- a/tools/proto-compiler/src/constants.rs +++ b/tools/proto-compiler/src/constants.rs @@ -17,9 +17,9 @@ pub struct TendermintVersion { /// All Tendermint versions to generate code for pub const TENDERMINT_VERSIONS: &[TendermintVersion] = &[ TendermintVersion { - repo: "https://github.com/cometbft/cometbft", + repo: "https://github.com/celestiaorg/celestia-core", ident: "v0_34", - commitish: "v0.34.27", + commitish: "v0.34.x-celestia", }, TendermintVersion { repo: "https://github.com/cometbft/cometbft", @@ -70,8 +70,9 @@ const RENAME_PARTS: &str = r#"#[serde(rename = "parts", alias = "part_set_header /// https://docs.rs/prost-build/0.6.1/prost_build/struct.Config.html#method.btree_map pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ (".tendermint.libs.bits.BitArray", SERIALIZED), - (".tendermint.types.BlockIDFlag", PRIMITIVE_ENUM), + (".tendermint.types.Blob", SERIALIZED), (".tendermint.types.Block", SERIALIZED), + (".tendermint.types.BlockIDFlag", PRIMITIVE_ENUM), (".tendermint.types.Data", SERIALIZED), (".tendermint.types.EvidenceParams", SERIALIZED), (".tendermint.types.Evidence.sum", SERIALIZED), @@ -111,6 +112,8 @@ pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ /// The first item is a path as defined in the prost_build::Config::btree_map here: /// https://docs.rs/prost-build/0.6.1/prost_build/struct.Config.html#method.btree_map pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ + (".tendermint.types.Blob.data", BASE64STRING), + (".tendermint.types.Blob.namespace_id", BASE64STRING), ( ".tendermint.types.EvidenceParams.max_bytes", QUOTED_WITH_DEFAULT, @@ -155,6 +158,7 @@ pub static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[ (".tendermint.types.Header.evidence_hash", HEXSTRING), (".tendermint.types.Header.proposer_address", HEXSTRING), (".tendermint.types.Data.txs", NULLABLEVECARRAY), + (".tendermint.types.Data.hash", HEXSTRING), (".tendermint.types.EvidenceList.evidence", NULLABLE), (".tendermint.types.Commit.height", QUOTED), (".tendermint.types.Commit.signatures", NULLABLE), diff --git a/tools/proto-compiler/src/main.rs b/tools/proto-compiler/src/main.rs index 4991273a5..e2000ef67 100644 --- a/tools/proto-compiler/src/main.rs +++ b/tools/proto-compiler/src/main.rs @@ -35,6 +35,15 @@ fn main() { "[info] => Fetching {} at {} into {tendermint_dir:?}", version.repo, version.commitish, ); + + let repo_name = version + .repo + .rsplit_once('/') + .map(|s| s.1) + .unwrap_or(&version.repo); + + let tendermint_dir = tendermint_dir.join(repo_name); + get_commitish(&tendermint_dir, &version.repo, &version.commitish); // This panics if it fails. let proto_path = tendermint_dir.join("proto");