diff --git a/.changelog/unreleased/breaking-changes/1312-cometbft-0.38.md b/.changelog/unreleased/breaking-changes/1312-cometbft-0.38.md new file mode 100644 index 000000000..7ced74a28 --- /dev/null +++ b/.changelog/unreleased/breaking-changes/1312-cometbft-0.38.md @@ -0,0 +1,18 @@ +- `[tendermint]` Adaptations for CometFBT 0.38 + ([\#1312](https://github.com/informalsystems/tendermint-rs/pull/1312)): + * Define `consensus::params::AbciParams` struct, add the `abci` field of this + type to `consensus::Params` to represent the protobuf additions. + * Change the `abci::Request` and `abci::Response` reexports to use the + enums defined in `v0_38`. +- `[tendermint]` Define version-specific categorized request/response enums: + `ConsensusRequest`, `MempoolRequest`, `InfoRequest`, `ShapshotRequest`, + `ConsensusResponse`, `MempoolResponse`, `InfoResponse`, `ShapshotResponse`, + in each of the `v0_*::abci` modules, so that the variants are trimmed to the + requests/responses used by the respective protocol version. + Reexport the types from `v0_38::abci` as aliases for these names in the + `abci` module, continuing the naming as used in older API. + ([\#1312](https://github.com/informalsystems/tendermint-rs/pull/1312)). +- `[tendermint]` Rename `Signature::to_bytes` to `Signature::into_bytes` + ([\#1312](https://github.com/informalsystems/tendermint-rs/pull/1312)). +- `[tendermint-abci]` Update the `Application` interface to CometBFT 0.38 + ([\#1312](https://github.com/informalsystems/tendermint-rs/pull/1312)) diff --git a/.changelog/unreleased/improvements/1312-cometbft-0.38.md b/.changelog/unreleased/improvements/1312-cometbft-0.38.md new file mode 100644 index 000000000..3f14a9750 --- /dev/null +++ b/.changelog/unreleased/improvements/1312-cometbft-0.38.md @@ -0,0 +1,12 @@ +- `[tendermint-proto]` Generate prost bindings for CometBFT 0.38 + under the `tendermint::v0_38` module + ([\#1312](https://github.com/informalsystems/tendermint-rs/pull/1312)) +- `[tendermint]` Support for CometBFT 0.38: + ([\#1312](https://github.com/informalsystems/tendermint-rs/pull/1312)): + * Add conversions to and from `tendermint::v0_38` protobuf + types generated in [`tendermint-proto`]. + * Add request and response enums under `v0_38::abci` to enumerate all requests + and responses appropriate for CometBFT version 0.38. + * Add request and response types under `abci` to represent the requests + and responses new to ABCI++ 2.0 in CometBFT version 0.38. The names are + `ExtendVote`, `FinalizeBlock`, `VerifyVoteExtension`. \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7342584ae..7f4048469 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,18 +69,20 @@ jobs: override: true - name: Install protoc run: | - curl -Lo /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-linux-x86_64.zip + curl -Lo /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v22.3/protoc-22.3-linux-x86_64.zip unzip /tmp/protoc.zip -d ${HOME}/.local echo "PROTOC=${HOME}/.local/bin/protoc" >> $GITHUB_ENV export PATH="${PATH}:${HOME}/.local/bin" - name: Install buf run: | - curl -sSL https://github.com/bufbuild/buf/releases/download/v1.15.1/buf-Linux-x86_64 \ + curl -sSL https://github.com/bufbuild/buf/releases/download/v1.18.0/buf-Linux-x86_64 \ -o /usr/local/bin/buf chmod +x /usr/local/bin/buf - name: Regenerate proto definitions working-directory: ./tools/proto-compiler/ run: cargo run + - name: Show the differences with checked-in files + run: git diff -- proto/src/prost - name: Ensure that generated proto definitions compile uses: actions-rs/cargo@v1 with: diff --git a/abci/Cargo.toml b/abci/Cargo.toml index e4cdb69cf..8d7c7449f 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -18,7 +18,7 @@ description = """ [[bin]] name = "kvstore-rs" path = "src/application/kvstore/main.rs" -required-features = [ "binary", "kvstore-app" ] +required-features = [ "binary", "client", "kvstore-app" ] [features] default = ["flex-error/std", "flex-error/eyre_tracer"] diff --git a/abci/src/application.rs b/abci/src/application.rs index 6fd532b7c..263ea7ecb 100644 --- a/abci/src/application.rs +++ b/abci/src/application.rs @@ -5,15 +5,16 @@ pub mod echo; #[cfg(feature = "kvstore-app")] pub mod kvstore; -use tendermint_proto::v0_37::abci::{ - request::Value, response, response_process_proposal, Request, RequestApplySnapshotChunk, - RequestBeginBlock, RequestCheckTx, RequestDeliverTx, RequestEcho, RequestEndBlock, RequestInfo, - RequestInitChain, RequestLoadSnapshotChunk, RequestOfferSnapshot, RequestPrepareProposal, - RequestProcessProposal, RequestQuery, Response, ResponseApplySnapshotChunk, ResponseBeginBlock, - ResponseCheckTx, ResponseCommit, ResponseDeliverTx, ResponseEcho, ResponseEndBlock, - ResponseFlush, ResponseInfo, ResponseInitChain, ResponseListSnapshots, - ResponseLoadSnapshotChunk, ResponseOfferSnapshot, ResponsePrepareProposal, - ResponseProcessProposal, ResponseQuery, +use tendermint_proto::v0_38::abci::{ + request::Value, response, response_process_proposal, response_verify_vote_extension, Request, + RequestApplySnapshotChunk, RequestCheckTx, RequestEcho, RequestExtendVote, + RequestFinalizeBlock, RequestInfo, RequestInitChain, RequestLoadSnapshotChunk, + RequestOfferSnapshot, RequestPrepareProposal, RequestProcessProposal, RequestQuery, + RequestVerifyVoteExtension, Response, ResponseApplySnapshotChunk, ResponseCheckTx, + ResponseCommit, ResponseEcho, ResponseExtendVote, ResponseFinalizeBlock, ResponseFlush, + ResponseInfo, ResponseInitChain, ResponseListSnapshots, ResponseLoadSnapshotChunk, + ResponseOfferSnapshot, ResponsePrepareProposal, ResponseProcessProposal, ResponseQuery, + ResponseVerifyVoteExtension, }; /// An ABCI application. @@ -52,21 +53,6 @@ pub trait Application: Send + Clone + 'static { Default::default() } - /// Signals the beginning of a new block, prior to any `DeliverTx` calls. - fn begin_block(&self, _request: RequestBeginBlock) -> ResponseBeginBlock { - Default::default() - } - - /// Apply a transaction to the application's state. - fn deliver_tx(&self, _request: RequestDeliverTx) -> ResponseDeliverTx { - Default::default() - } - - /// Signals the end of a block. - fn end_block(&self, _request: RequestEndBlock) -> ResponseEndBlock { - Default::default() - } - /// Signals that messages queued on the client should be flushed to the server. fn flush(&self) -> ResponseFlush { ResponseFlush {} @@ -147,6 +133,23 @@ pub trait Application: Send + Clone + 'static { status: response_process_proposal::ProposalStatus::Accept as i32, } } + + fn extend_vote(&self, _request: RequestExtendVote) -> ResponseExtendVote { + Default::default() + } + + fn verify_vote_extension( + &self, + _request: RequestVerifyVoteExtension, + ) -> ResponseVerifyVoteExtension { + ResponseVerifyVoteExtension { + status: response_verify_vote_extension::VerifyStatus::Accept as i32, + } + } + + fn finalize_block(&self, _request: RequestFinalizeBlock) -> ResponseFinalizeBlock { + Default::default() + } } /// Provides a mechanism for the [`Server`] to execute incoming requests while @@ -168,10 +171,7 @@ impl RequestDispatcher for A { Value::Info(req) => response::Value::Info(self.info(req)), Value::InitChain(req) => response::Value::InitChain(self.init_chain(req)), Value::Query(req) => response::Value::Query(self.query(req)), - Value::BeginBlock(req) => response::Value::BeginBlock(self.begin_block(req)), Value::CheckTx(req) => response::Value::CheckTx(self.check_tx(req)), - Value::DeliverTx(req) => response::Value::DeliverTx(self.deliver_tx(req)), - Value::EndBlock(req) => response::Value::EndBlock(self.end_block(req)), Value::Commit(_) => response::Value::Commit(self.commit()), Value::ListSnapshots(_) => response::Value::ListSnapshots(self.list_snapshots()), Value::OfferSnapshot(req) => { @@ -189,6 +189,13 @@ impl RequestDispatcher for A { Value::ProcessProposal(req) => { response::Value::ProcessProposal(self.process_proposal(req)) }, + Value::ExtendVote(req) => response::Value::ExtendVote(self.extend_vote(req)), + Value::VerifyVoteExtension(req) => { + response::Value::VerifyVoteExtension(self.verify_vote_extension(req)) + }, + Value::FinalizeBlock(req) => { + response::Value::FinalizeBlock(self.finalize_block(req)) + }, }), } } diff --git a/abci/src/application/kvstore.rs b/abci/src/application/kvstore.rs index bad695141..0410dfa50 100644 --- a/abci/src/application/kvstore.rs +++ b/abci/src/application/kvstore.rs @@ -6,9 +6,9 @@ use std::{ }; use bytes::BytesMut; -use tendermint_proto::v0_37::abci::{ - Event, EventAttribute, RequestCheckTx, RequestDeliverTx, RequestInfo, RequestQuery, - ResponseCheckTx, ResponseCommit, ResponseDeliverTx, ResponseInfo, ResponseQuery, +use tendermint_proto::v0_38::abci::{ + Event, EventAttribute, RequestCheckTx, RequestFinalizeBlock, RequestInfo, RequestQuery, + ResponseCheckTx, ResponseCommit, ResponseFinalizeBlock, ResponseInfo, ResponseQuery, }; use tracing::{debug, info}; @@ -20,9 +20,10 @@ use crate::{codec::MAX_VARINT_LENGTH, Application, Error}; /// store - the [`KeyValueStoreDriver`]. /// /// ## Example -/// ```rust +/// +/// ``` /// use tendermint_abci::{KeyValueStoreApp, ServerBuilder, ClientBuilder}; -/// use tendermint_proto::abci::{RequestEcho, RequestDeliverTx, RequestQuery}; +/// use tendermint_proto::abci::{RequestEcho, RequestFinalizeBlock, RequestQuery}; /// /// // Create our key/value store application /// let (app, driver) = KeyValueStoreApp::new(); @@ -46,8 +47,9 @@ use crate::{codec::MAX_VARINT_LENGTH, Application, Error}; /// /// // Deliver a transaction and then commit the transaction /// client -/// .deliver_tx(RequestDeliverTx { -/// tx: "test-key=test-value".into(), +/// .finalize_block(RequestFinalizeBlock { +/// txs: vec!["test-key=test-value".into()], +/// ..Default::default() /// }) /// .unwrap(); /// client.commit().unwrap(); @@ -175,27 +177,31 @@ impl Application for KeyValueStoreApp { gas_used: 0, events: vec![], codespace: "".to_string(), - ..Default::default() } } - fn deliver_tx(&self, request: RequestDeliverTx) -> ResponseDeliverTx { - let tx = std::str::from_utf8(&request.tx).unwrap(); - let tx_parts = tx.split('=').collect::>(); - let (key, value) = if tx_parts.len() == 2 { - (tx_parts[0], tx_parts[1]) - } else { - (tx, tx) - }; - let _ = self.set(key, value).unwrap(); - ResponseDeliverTx { - code: 0, - data: Default::default(), - log: "".to_string(), - info: "".to_string(), - gas_wanted: 0, - gas_used: 0, - events: vec![Event { + fn commit(&self) -> ResponseCommit { + let (result_tx, result_rx) = channel(); + channel_send(&self.cmd_tx, Command::Commit { result_tx }).unwrap(); + let height = channel_recv(&result_rx).unwrap(); + info!("Committed height {}", height); + ResponseCommit { + retain_height: height - 1, + } + } + + fn finalize_block(&self, request: RequestFinalizeBlock) -> ResponseFinalizeBlock { + let mut events = Vec::new(); + for tx in request.txs { + let tx = std::str::from_utf8(&tx).unwrap(); + let tx_parts = tx.split('=').collect::>(); + let (key, value) = if tx_parts.len() == 2 { + (tx_parts[0], tx_parts[1]) + } else { + (tx, tx) + }; + let _ = self.set(key, value).unwrap(); + events.push(Event { r#type: "app".to_string(), attributes: vec![ EventAttribute { @@ -214,19 +220,11 @@ impl Application for KeyValueStoreApp { index: false, }, ], - }], - codespace: "".to_string(), + }); } - } - - fn commit(&self) -> ResponseCommit { - let (result_tx, result_rx) = channel(); - channel_send(&self.cmd_tx, Command::Commit { result_tx }).unwrap(); - let (height, app_hash) = channel_recv(&result_rx).unwrap(); - info!("Committed height {}", height); - ResponseCommit { - data: app_hash.into(), - retain_height: height - 1, + ResponseFinalizeBlock { + events, + ..Default::default() } } } @@ -278,14 +276,14 @@ impl KeyValueStoreDriver { } } - fn commit(&mut self, result_tx: Sender<(i64, Vec)>) -> Result<(), Error> { + fn commit(&mut self, result_tx: Sender) -> Result<(), Error> { // As in the Go-based key/value store, simply encode the number of // items as the "app hash" let mut app_hash = BytesMut::with_capacity(MAX_VARINT_LENGTH); prost::encoding::encode_varint(self.store.len() as u64, &mut app_hash); self.app_hash = app_hash.to_vec(); self.height += 1; - channel_send(&result_tx, (self.height, self.app_hash.clone())) + channel_send(&result_tx, self.height) } } @@ -305,8 +303,8 @@ enum Command { result_tx: Sender>, }, /// Commit the current state of the application, which involves recomputing - /// the application's hash. - Commit { result_tx: Sender<(i64, Vec)> }, + /// the application's hash, and return the new height. + Commit { result_tx: Sender }, } fn channel_send(tx: &Sender, value: T) -> Result<(), Error> { diff --git a/abci/src/client.rs b/abci/src/client.rs index 6fdb1de75..45e1350b6 100644 --- a/abci/src/client.rs +++ b/abci/src/client.rs @@ -2,14 +2,14 @@ use std::net::{TcpStream, ToSocketAddrs}; -use tendermint_proto::v0_37::abci::{ - request, response, Request, RequestApplySnapshotChunk, RequestBeginBlock, RequestCheckTx, - RequestCommit, RequestDeliverTx, RequestEcho, RequestEndBlock, RequestFlush, RequestInfo, +use tendermint_proto::v0_38::abci::{ + request, response, Request, RequestApplySnapshotChunk, RequestCheckTx, RequestCommit, + RequestEcho, RequestExtendVote, RequestFinalizeBlock, RequestFlush, RequestInfo, RequestInitChain, RequestListSnapshots, RequestLoadSnapshotChunk, RequestOfferSnapshot, - RequestQuery, ResponseApplySnapshotChunk, ResponseBeginBlock, ResponseCheckTx, ResponseCommit, - ResponseDeliverTx, ResponseEcho, ResponseEndBlock, ResponseFlush, ResponseInfo, - ResponseInitChain, ResponseListSnapshots, ResponseLoadSnapshotChunk, ResponseOfferSnapshot, - ResponseQuery, + RequestQuery, RequestVerifyVoteExtension, ResponseApplySnapshotChunk, ResponseCheckTx, + ResponseCommit, ResponseEcho, ResponseExtendVote, ResponseFinalizeBlock, ResponseFlush, + ResponseInfo, ResponseInitChain, ResponseListSnapshots, ResponseLoadSnapshotChunk, + ResponseOfferSnapshot, ResponseQuery, ResponseVerifyVoteExtension, }; use crate::{codec::ClientCodec, Error}; @@ -89,21 +89,6 @@ impl Client { perform!(self, CheckTx, req) } - /// Signal the beginning of a new block, prior to any `DeliverTx` calls. - pub fn begin_block(&mut self, req: RequestBeginBlock) -> Result { - perform!(self, BeginBlock, req) - } - - /// Apply a transaction to the application's state. - pub fn deliver_tx(&mut self, req: RequestDeliverTx) -> Result { - perform!(self, DeliverTx, req) - } - - /// Signal the end of a block. - pub fn end_block(&mut self, req: RequestEndBlock) -> Result { - perform!(self, EndBlock, req) - } - pub fn flush(&mut self) -> Result { perform!(self, Flush, RequestFlush {}) } @@ -142,6 +127,24 @@ impl Client { perform!(self, ApplySnapshotChunk, req) } + pub fn extend_vote(&mut self, req: RequestExtendVote) -> Result { + perform!(self, ExtendVote, req) + } + + pub fn verify_vote_extension( + &mut self, + req: RequestVerifyVoteExtension, + ) -> Result { + perform!(self, VerifyVoteExtension, req) + } + + pub fn finalize_block( + &mut self, + req: RequestFinalizeBlock, + ) -> Result { + perform!(self, FinalizeBlock, req) + } + fn perform(&mut self, req: request::Value) -> Result { self.codec.send(Request { value: Some(req) })?; let res = self diff --git a/abci/src/codec.rs b/abci/src/codec.rs index 6542a066d..258c083a0 100644 --- a/abci/src/codec.rs +++ b/abci/src/codec.rs @@ -11,7 +11,7 @@ use std::{ use bytes::{Buf, BufMut, BytesMut}; use prost::Message; -use tendermint_proto::v0_37::abci::{Request, Response}; +use tendermint_proto::v0_38::abci::{Request, Response}; use crate::error::Error; diff --git a/abci/src/error.rs b/abci/src/error.rs index 72b875d0e..572b30893 100644 --- a/abci/src/error.rs +++ b/abci/src/error.rs @@ -1,7 +1,7 @@ //! tendermint-abci errors use flex_error::{define_error, DisplayError}; -use tendermint_proto::v0_37::abci::response::Value; +use tendermint_proto::v0_38::abci::response::Value; define_error! { Error { diff --git a/abci/tests/echo_app.rs b/abci/tests/echo_app.rs index c2f07895b..cbe198eec 100644 --- a/abci/tests/echo_app.rs +++ b/abci/tests/echo_app.rs @@ -3,7 +3,7 @@ #[cfg(all(feature = "client", feature = "echo-app"))] mod echo_app_integration { use tendermint_abci::{ClientBuilder, EchoApp, ServerBuilder}; - use tendermint_proto::v0_37::abci::RequestEcho; + use tendermint_proto::v0_38::abci::RequestEcho; #[test] fn echo() { diff --git a/abci/tests/kvstore_app.rs b/abci/tests/kvstore_app.rs index 998f167be..42cf513ad 100644 --- a/abci/tests/kvstore_app.rs +++ b/abci/tests/kvstore_app.rs @@ -5,7 +5,7 @@ mod kvstore_app_integration { use std::thread; use tendermint_abci::{ClientBuilder, KeyValueStoreApp, ServerBuilder}; - use tendermint_proto::v0_37::abci::{RequestDeliverTx, RequestEcho, RequestQuery}; + use tendermint_proto::v0_38::abci::{RequestEcho, RequestFinalizeBlock, RequestQuery}; #[test] fn happy_path() { @@ -24,8 +24,9 @@ mod kvstore_app_integration { assert_eq!(res.message, "Hello ABCI!"); client - .deliver_tx(RequestDeliverTx { - tx: "test-key=test-value".into(), + .finalize_block(RequestFinalizeBlock { + txs: vec!["test-key=test-value".into()], + ..Default::default() }) .unwrap(); client.commit().unwrap(); diff --git a/light-client-verifier/src/operations/voting_power.rs b/light-client-verifier/src/operations/voting_power.rs index 720ecd92b..73d395161 100644 --- a/light-client-verifier/src/operations/voting_power.rs +++ b/light-client-verifier/src/operations/voting_power.rs @@ -232,6 +232,8 @@ fn non_absent_vote( validator_address, validator_index, signature: signature.clone(), + extension: Default::default(), + extension_signature: None, }) } diff --git a/p2p/src/secret_connection.rs b/p2p/src/secret_connection.rs index 68a6681be..163c509d0 100644 --- a/p2p/src/secret_connection.rs +++ b/p2p/src/secret_connection.rs @@ -19,7 +19,7 @@ use chacha20poly1305::{ use merlin::Transcript; use rand_core::OsRng; use subtle::ConstantTimeEq; -use tendermint_proto::v0_37 as proto; +use tendermint_proto::v0_38 as proto; use tendermint_std_ext::TryClone; use x25519_dalek::{EphemeralSecret, PublicKey as EphemeralPublic}; diff --git a/p2p/src/secret_connection/amino_types.rs b/p2p/src/secret_connection/amino_types.rs index 938418f90..79912e0e9 100644 --- a/p2p/src/secret_connection/amino_types.rs +++ b/p2p/src/secret_connection/amino_types.rs @@ -2,7 +2,7 @@ use core::convert::TryFrom; use prost_derive::Message; -use tendermint_proto::v0_37 as proto; +use tendermint_proto::v0_38 as proto; use crate::error::Error; diff --git a/p2p/src/secret_connection/protocol.rs b/p2p/src/secret_connection/protocol.rs index d15d90f29..16511a587 100644 --- a/p2p/src/secret_connection/protocol.rs +++ b/p2p/src/secret_connection/protocol.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; use prost::Message as _; -use tendermint_proto::v0_37 as proto; +use tendermint_proto::v0_38 as proto; use x25519_dalek::PublicKey as EphemeralPublic; #[cfg(feature = "amino")] diff --git a/proto/src/prost/v0_34/tendermint.abci.rs b/proto/src/prost/v0_34/tendermint.abci.rs index fbc793b73..ae59b8286 100644 --- a/proto/src/prost/v0_34/tendermint.abci.rs +++ b/proto/src/prost/v0_34/tendermint.abci.rs @@ -397,7 +397,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 +472,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 diff --git a/proto/src/prost/v0_34/tendermint.crypto.rs b/proto/src/prost/v0_34/tendermint.crypto.rs index cfd024d19..a6273013b 100644 --- a/proto/src/prost/v0_34/tendermint.crypto.rs +++ b/proto/src/prost/v0_34/tendermint.crypto.rs @@ -56,6 +56,7 @@ pub struct ProofOps { pub ops: ::prost::alloc::vec::Vec, } /// PublicKey defines the keys available for use with Validators +#[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PublicKey { 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..c6e153fb3 100644 --- a/proto/src/prost/v0_34/tendermint.types.rs +++ b/proto/src/prost/v0_34/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,16 +337,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)] @@ -445,6 +424,16 @@ pub struct HashedParams { } #[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, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct Evidence { #[prost(oneof = "evidence::Sum", tags = "1, 2")] pub sum: ::core::option::Option, @@ -513,6 +502,19 @@ 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, +} +#[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 +571,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.crypto.rs b/proto/src/prost/v0_37/tendermint.crypto.rs index cfd024d19..a6273013b 100644 --- a/proto/src/prost/v0_37/tendermint.crypto.rs +++ b/proto/src/prost/v0_37/tendermint.crypto.rs @@ -56,6 +56,7 @@ pub struct ProofOps { pub ops: ::prost::alloc::vec::Vec, } /// PublicKey defines the keys available for use with Validators +#[derive(::serde::Deserialize, ::serde::Serialize)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PublicKey { 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..9ec028f2b 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,95 @@ 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 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, +} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Evidence { @@ -428,95 +506,6 @@ pub struct Block { #[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, -} -/// 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/prost/v0_38/tendermint.abci.rs b/proto/src/prost/v0_38/tendermint.abci.rs new file mode 100644 index 000000000..e13732082 --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.abci.rs @@ -0,0 +1,891 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Request { + #[prost( + oneof = "request::Value", + tags = "1, 2, 3, 5, 6, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20" + )] + pub value: ::core::option::Option, +} +/// Nested message and enum types in `Request`. +pub mod request { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Value { + #[prost(message, tag = "1")] + Echo(super::RequestEcho), + #[prost(message, tag = "2")] + Flush(super::RequestFlush), + #[prost(message, tag = "3")] + Info(super::RequestInfo), + #[prost(message, tag = "5")] + InitChain(super::RequestInitChain), + #[prost(message, tag = "6")] + Query(super::RequestQuery), + #[prost(message, tag = "8")] + CheckTx(super::RequestCheckTx), + #[prost(message, tag = "11")] + Commit(super::RequestCommit), + #[prost(message, tag = "12")] + ListSnapshots(super::RequestListSnapshots), + #[prost(message, tag = "13")] + OfferSnapshot(super::RequestOfferSnapshot), + #[prost(message, tag = "14")] + LoadSnapshotChunk(super::RequestLoadSnapshotChunk), + #[prost(message, tag = "15")] + ApplySnapshotChunk(super::RequestApplySnapshotChunk), + #[prost(message, tag = "16")] + PrepareProposal(super::RequestPrepareProposal), + #[prost(message, tag = "17")] + ProcessProposal(super::RequestProcessProposal), + #[prost(message, tag = "18")] + ExtendVote(super::RequestExtendVote), + #[prost(message, tag = "19")] + VerifyVoteExtension(super::RequestVerifyVoteExtension), + #[prost(message, tag = "20")] + FinalizeBlock(super::RequestFinalizeBlock), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestEcho { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestFlush {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestInfo { + #[prost(string, tag = "1")] + pub version: ::prost::alloc::string::String, + #[prost(uint64, tag = "2")] + pub block_version: u64, + #[prost(uint64, tag = "3")] + pub p2p_version: u64, + #[prost(string, tag = "4")] + pub abci_version: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestInitChain { + #[prost(message, optional, tag = "1")] + pub time: ::core::option::Option, + #[prost(string, tag = "2")] + pub chain_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "3")] + pub consensus_params: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + pub validators: ::prost::alloc::vec::Vec, + #[prost(bytes = "bytes", tag = "5")] + pub app_state_bytes: ::prost::bytes::Bytes, + #[prost(int64, tag = "6")] + pub initial_height: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestQuery { + #[prost(bytes = "bytes", tag = "1")] + pub data: ::prost::bytes::Bytes, + #[prost(string, tag = "2")] + pub path: ::prost::alloc::string::String, + #[prost(int64, tag = "3")] + pub height: i64, + #[prost(bool, tag = "4")] + pub prove: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestCheckTx { + #[prost(bytes = "bytes", tag = "1")] + pub tx: ::prost::bytes::Bytes, + #[prost(enumeration = "CheckTxType", tag = "2")] + pub r#type: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestCommit {} +/// lists available snapshots +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestListSnapshots {} +/// offers a snapshot to the application +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestOfferSnapshot { + /// snapshot offered by peers + #[prost(message, optional, tag = "1")] + pub snapshot: ::core::option::Option, + /// light client-verified app hash for snapshot height + #[prost(bytes = "bytes", tag = "2")] + pub app_hash: ::prost::bytes::Bytes, +} +/// loads a snapshot chunk +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestLoadSnapshotChunk { + #[prost(uint64, tag = "1")] + pub height: u64, + #[prost(uint32, tag = "2")] + pub format: u32, + #[prost(uint32, tag = "3")] + pub chunk: u32, +} +/// Applies a snapshot chunk +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestApplySnapshotChunk { + #[prost(uint32, tag = "1")] + pub index: u32, + #[prost(bytes = "bytes", tag = "2")] + pub chunk: ::prost::bytes::Bytes, + #[prost(string, tag = "3")] + pub sender: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestPrepareProposal { + /// the modified transactions cannot exceed this size. + #[prost(int64, tag = "1")] + 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. + #[prost(bytes = "bytes", repeated, tag = "2")] + pub txs: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>, + #[prost(message, optional, tag = "3")] + pub local_last_commit: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + pub misbehavior: ::prost::alloc::vec::Vec, + #[prost(int64, tag = "5")] + pub height: i64, + #[prost(message, optional, tag = "6")] + pub time: ::core::option::Option, + #[prost(bytes = "bytes", tag = "7")] + pub next_validators_hash: ::prost::bytes::Bytes, + /// address of the public key of the validator proposing the block. + #[prost(bytes = "bytes", tag = "8")] + pub proposer_address: ::prost::bytes::Bytes, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestProcessProposal { + #[prost(bytes = "bytes", repeated, tag = "1")] + pub txs: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>, + #[prost(message, optional, tag = "2")] + pub proposed_last_commit: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub misbehavior: ::prost::alloc::vec::Vec, + /// hash is the merkle root hash of the fields of the proposed block. + #[prost(bytes = "bytes", tag = "4")] + pub hash: ::prost::bytes::Bytes, + #[prost(int64, tag = "5")] + pub height: i64, + #[prost(message, optional, tag = "6")] + pub time: ::core::option::Option, + #[prost(bytes = "bytes", tag = "7")] + pub next_validators_hash: ::prost::bytes::Bytes, + /// address of the public key of the original proposer of the block. + #[prost(bytes = "bytes", tag = "8")] + pub proposer_address: ::prost::bytes::Bytes, +} +/// Extends a vote with application-injected data +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestExtendVote { + /// the hash of the block that this vote may be referring to + #[prost(bytes = "bytes", tag = "1")] + pub hash: ::prost::bytes::Bytes, + /// the height of the extended vote + #[prost(int64, tag = "2")] + pub height: i64, +} +/// Verify the vote extension +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestVerifyVoteExtension { + /// the hash of the block that this received vote corresponds to + #[prost(bytes = "bytes", tag = "1")] + pub hash: ::prost::bytes::Bytes, + /// the validator that signed the vote extension + #[prost(bytes = "bytes", tag = "2")] + pub validator_address: ::prost::bytes::Bytes, + #[prost(int64, tag = "3")] + pub height: i64, + #[prost(bytes = "bytes", tag = "4")] + pub vote_extension: ::prost::bytes::Bytes, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestFinalizeBlock { + #[prost(bytes = "bytes", repeated, tag = "1")] + pub txs: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>, + #[prost(message, optional, tag = "2")] + pub decided_last_commit: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub misbehavior: ::prost::alloc::vec::Vec, + /// hash is the merkle root hash of the fields of the decided block. + #[prost(bytes = "bytes", tag = "4")] + pub hash: ::prost::bytes::Bytes, + #[prost(int64, tag = "5")] + pub height: i64, + #[prost(message, optional, tag = "6")] + pub time: ::core::option::Option, + #[prost(bytes = "bytes", tag = "7")] + pub next_validators_hash: ::prost::bytes::Bytes, + /// proposer_address is the address of the public key of the original proposer of the block. + #[prost(bytes = "bytes", tag = "8")] + pub proposer_address: ::prost::bytes::Bytes, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Response { + #[prost( + oneof = "response::Value", + tags = "1, 2, 3, 4, 6, 7, 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21" + )] + pub value: ::core::option::Option, +} +/// Nested message and enum types in `Response`. +pub mod response { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Value { + #[prost(message, tag = "1")] + Exception(super::ResponseException), + #[prost(message, tag = "2")] + Echo(super::ResponseEcho), + #[prost(message, tag = "3")] + Flush(super::ResponseFlush), + #[prost(message, tag = "4")] + Info(super::ResponseInfo), + #[prost(message, tag = "6")] + InitChain(super::ResponseInitChain), + #[prost(message, tag = "7")] + Query(super::ResponseQuery), + #[prost(message, tag = "9")] + CheckTx(super::ResponseCheckTx), + #[prost(message, tag = "12")] + Commit(super::ResponseCommit), + #[prost(message, tag = "13")] + ListSnapshots(super::ResponseListSnapshots), + #[prost(message, tag = "14")] + OfferSnapshot(super::ResponseOfferSnapshot), + #[prost(message, tag = "15")] + LoadSnapshotChunk(super::ResponseLoadSnapshotChunk), + #[prost(message, tag = "16")] + ApplySnapshotChunk(super::ResponseApplySnapshotChunk), + #[prost(message, tag = "17")] + PrepareProposal(super::ResponsePrepareProposal), + #[prost(message, tag = "18")] + ProcessProposal(super::ResponseProcessProposal), + #[prost(message, tag = "19")] + ExtendVote(super::ResponseExtendVote), + #[prost(message, tag = "20")] + VerifyVoteExtension(super::ResponseVerifyVoteExtension), + #[prost(message, tag = "21")] + FinalizeBlock(super::ResponseFinalizeBlock), + } +} +/// nondeterministic +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseException { + #[prost(string, tag = "1")] + pub error: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseEcho { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseFlush {} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseInfo { + #[prost(string, tag = "1")] + #[serde(default)] + pub data: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + #[serde(default)] + pub version: ::prost::alloc::string::String, + #[prost(uint64, tag = "3")] + #[serde(with = "crate::serializers::from_str", default)] + pub app_version: u64, + #[prost(int64, tag = "4")] + #[serde(with = "crate::serializers::from_str", default)] + pub last_block_height: i64, + #[prost(bytes = "bytes", tag = "5")] + #[serde(default)] + #[serde(skip_serializing_if = "bytes::Bytes::is_empty")] + pub last_block_app_hash: ::prost::bytes::Bytes, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseInitChain { + #[prost(message, optional, tag = "1")] + pub consensus_params: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub validators: ::prost::alloc::vec::Vec, + #[prost(bytes = "bytes", tag = "3")] + pub app_hash: ::prost::bytes::Bytes, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseQuery { + #[prost(uint32, tag = "1")] + pub code: u32, + /// bytes data = 2; // use "value" instead. + /// + /// nondeterministic + #[prost(string, tag = "3")] + pub log: ::prost::alloc::string::String, + /// nondeterministic + #[prost(string, tag = "4")] + pub info: ::prost::alloc::string::String, + #[prost(int64, tag = "5")] + pub index: i64, + #[prost(bytes = "bytes", tag = "6")] + pub key: ::prost::bytes::Bytes, + #[prost(bytes = "bytes", tag = "7")] + pub value: ::prost::bytes::Bytes, + #[prost(message, optional, tag = "8")] + pub proof_ops: ::core::option::Option, + #[prost(int64, tag = "9")] + pub height: i64, + #[prost(string, tag = "10")] + pub codespace: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseCheckTx { + #[prost(uint32, tag = "1")] + pub code: u32, + #[prost(bytes = "bytes", tag = "2")] + pub data: ::prost::bytes::Bytes, + /// nondeterministic + #[prost(string, tag = "3")] + pub log: ::prost::alloc::string::String, + /// nondeterministic + #[prost(string, tag = "4")] + pub info: ::prost::alloc::string::String, + #[prost(int64, tag = "5")] + pub gas_wanted: i64, + #[prost(int64, tag = "6")] + pub gas_used: i64, + #[prost(message, repeated, tag = "7")] + pub events: ::prost::alloc::vec::Vec, + #[prost(string, tag = "8")] + pub codespace: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseCommit { + #[prost(int64, tag = "3")] + pub retain_height: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseListSnapshots { + #[prost(message, repeated, tag = "1")] + pub snapshots: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseOfferSnapshot { + #[prost(enumeration = "response_offer_snapshot::Result", tag = "1")] + pub result: i32, +} +/// Nested message and enum types in `ResponseOfferSnapshot`. +pub mod response_offer_snapshot { + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Result { + /// Unknown result, abort all snapshot restoration + Unknown = 0, + /// Snapshot accepted, apply chunks + Accept = 1, + /// Abort all snapshot restoration + Abort = 2, + /// Reject this specific snapshot, try others + Reject = 3, + /// Reject all snapshots of this format, try others + RejectFormat = 4, + /// Reject all snapshots from the sender(s), try others + RejectSender = 5, + } + 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::Abort => "ABORT", + Result::Reject => "REJECT", + Result::RejectFormat => "REJECT_FORMAT", + Result::RejectSender => "REJECT_SENDER", + } + } + /// 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), + "ABORT" => Some(Self::Abort), + "REJECT" => Some(Self::Reject), + "REJECT_FORMAT" => Some(Self::RejectFormat), + "REJECT_SENDER" => Some(Self::RejectSender), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseLoadSnapshotChunk { + #[prost(bytes = "bytes", tag = "1")] + pub chunk: ::prost::bytes::Bytes, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseApplySnapshotChunk { + #[prost(enumeration = "response_apply_snapshot_chunk::Result", tag = "1")] + pub result: i32, + /// Chunks to refetch and reapply + #[prost(uint32, repeated, tag = "2")] + pub refetch_chunks: ::prost::alloc::vec::Vec, + /// Chunk senders to reject and ban + #[prost(string, repeated, tag = "3")] + pub reject_senders: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +/// Nested message and enum types in `ResponseApplySnapshotChunk`. +pub mod response_apply_snapshot_chunk { + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Result { + /// Unknown result, abort all snapshot restoration + Unknown = 0, + /// Chunk successfully accepted + Accept = 1, + /// Abort all snapshot restoration + Abort = 2, + /// Retry chunk (combine with refetch and reject) + Retry = 3, + /// Retry snapshot (combine with refetch and reject) + RetrySnapshot = 4, + /// Reject this snapshot, try others + RejectSnapshot = 5, + } + 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::Abort => "ABORT", + Result::Retry => "RETRY", + Result::RetrySnapshot => "RETRY_SNAPSHOT", + Result::RejectSnapshot => "REJECT_SNAPSHOT", + } + } + /// 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), + "ABORT" => Some(Self::Abort), + "RETRY" => Some(Self::Retry), + "RETRY_SNAPSHOT" => Some(Self::RetrySnapshot), + "REJECT_SNAPSHOT" => Some(Self::RejectSnapshot), + _ => None, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponsePrepareProposal { + #[prost(bytes = "bytes", repeated, tag = "1")] + pub txs: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseProcessProposal { + #[prost(enumeration = "response_process_proposal::ProposalStatus", tag = "1")] + pub status: i32, +} +/// 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 ProposalStatus { + Unknown = 0, + Accept = 1, + Reject = 2, + } + impl ProposalStatus { + /// 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 { + ProposalStatus::Unknown => "UNKNOWN", + ProposalStatus::Accept => "ACCEPT", + ProposalStatus::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, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseExtendVote { + #[prost(bytes = "bytes", tag = "1")] + pub vote_extension: ::prost::bytes::Bytes, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseVerifyVoteExtension { + #[prost(enumeration = "response_verify_vote_extension::VerifyStatus", tag = "1")] + pub status: i32, +} +/// Nested message and enum types in `ResponseVerifyVoteExtension`. +pub mod response_verify_vote_extension { + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum VerifyStatus { + Unknown = 0, + Accept = 1, + /// Rejecting the vote extension will reject the entire precommit by the sender. + /// Incorrectly implementing this thus has liveness implications as it may affect + /// CometBFT's ability to receive 2/3+ valid votes to finalize the block. + /// Honest nodes should never be rejected. + Reject = 2, + } + impl VerifyStatus { + /// 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 { + VerifyStatus::Unknown => "UNKNOWN", + VerifyStatus::Accept => "ACCEPT", + VerifyStatus::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, + } + } + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseFinalizeBlock { + /// set of block events emmitted as part of executing the block + #[prost(message, repeated, tag = "1")] + pub events: ::prost::alloc::vec::Vec, + /// the result of executing each transaction including the events + /// the particular transction emitted. This should match the order + /// of the transactions delivered in the block itself + #[prost(message, repeated, tag = "2")] + pub tx_results: ::prost::alloc::vec::Vec, + /// a list of updates to the validator set. These will reflect the validator set at current height + 2. + #[prost(message, repeated, tag = "3")] + pub validator_updates: ::prost::alloc::vec::Vec, + /// updates to the consensus params, if any. + #[prost(message, optional, tag = "4")] + pub consensus_param_updates: ::core::option::Option, + /// app_hash is the hash of the applications' state which is used to confirm that execution of the transactions was deterministic. It is up to the application to decide which algorithm to use. + #[prost(bytes = "bytes", tag = "5")] + pub app_hash: ::prost::bytes::Bytes, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CommitInfo { + #[prost(int32, tag = "1")] + pub round: i32, + #[prost(message, repeated, tag = "2")] + pub votes: ::prost::alloc::vec::Vec, +} +/// ExtendedCommitInfo is similar to CommitInfo except that it is only used in +/// the PrepareProposal request such that CometBFT can provide vote extensions +/// to the application. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExtendedCommitInfo { + /// The round at which the block proposer decided in the previous height. + #[prost(int32, tag = "1")] + pub round: i32, + /// List of validators' addresses in the last validator set with their voting + /// information, including vote extensions. + #[prost(message, repeated, tag = "2")] + pub votes: ::prost::alloc::vec::Vec, +} +/// Event allows application developers to attach additional information to +/// ResponseFinalizeBlock and ResponseCheckTx. +/// Later, transactions may be queried using these events. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Event { + #[prost(string, tag = "1")] + pub r#type: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub attributes: ::prost::alloc::vec::Vec, +} +/// EventAttribute is a single key-value pair, associated with an event. +#[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, + /// nondeterministic + #[prost(bool, tag = "3")] + pub index: bool, +} +/// ExecTxResult contains results of executing one individual transaction. +/// +/// * Its structure is equivalent to #ResponseDeliverTx which will be deprecated/deleted +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExecTxResult { + #[prost(uint32, tag = "1")] + pub code: u32, + #[prost(bytes = "bytes", tag = "2")] + pub data: ::prost::bytes::Bytes, + /// nondeterministic + #[prost(string, tag = "3")] + pub log: ::prost::alloc::string::String, + /// nondeterministic + #[prost(string, tag = "4")] + pub info: ::prost::alloc::string::String, + #[prost(int64, tag = "5")] + pub gas_wanted: i64, + #[prost(int64, tag = "6")] + pub gas_used: i64, + /// nondeterministic + #[prost(message, repeated, tag = "7")] + pub events: ::prost::alloc::vec::Vec, + #[prost(string, tag = "8")] + pub codespace: ::prost::alloc::string::String, +} +/// TxResult contains results of executing the transaction. +/// +/// One usage is indexing transaction results. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TxResult { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(uint32, tag = "2")] + pub index: u32, + #[prost(bytes = "bytes", tag = "3")] + pub tx: ::prost::bytes::Bytes, + #[prost(message, optional, tag = "4")] + pub result: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Validator { + /// The first 20 bytes of SHA256(public key) + #[prost(bytes = "bytes", tag = "1")] + pub address: ::prost::bytes::Bytes, + /// PubKey pub_key = 2 \[(gogoproto.nullable)=false\]; + /// + /// The voting power + #[prost(int64, tag = "3")] + pub power: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValidatorUpdate { + #[prost(message, optional, tag = "1")] + pub pub_key: ::core::option::Option, + #[prost(int64, tag = "2")] + pub power: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VoteInfo { + #[prost(message, optional, tag = "1")] + pub validator: ::core::option::Option, + #[prost(enumeration = "super::types::BlockIdFlag", tag = "3")] + pub block_id_flag: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExtendedVoteInfo { + /// The validator that sent the vote. + #[prost(message, optional, tag = "1")] + pub validator: ::core::option::Option, + /// Non-deterministic extension provided by the sending validator's application. + #[prost(bytes = "bytes", tag = "3")] + pub vote_extension: ::prost::bytes::Bytes, + /// Vote extension signature created by CometBFT + #[prost(bytes = "bytes", tag = "4")] + pub extension_signature: ::prost::bytes::Bytes, + /// block_id_flag indicates whether the validator voted for a block, nil, or did not vote at all + #[prost(enumeration = "super::types::BlockIdFlag", tag = "5")] + pub block_id_flag: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Misbehavior { + #[prost(enumeration = "MisbehaviorType", tag = "1")] + pub r#type: i32, + /// The offending validator + #[prost(message, optional, tag = "2")] + pub validator: ::core::option::Option, + /// The height when the offense occurred + #[prost(int64, tag = "3")] + pub height: i64, + /// The corresponding time where the offense occurred + #[prost(message, optional, tag = "4")] + pub time: ::core::option::Option, + /// Total voting power of the validator set in case the ABCI application does + /// not store historical validators. + /// + #[prost(int64, tag = "5")] + pub total_voting_power: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Snapshot { + /// The height at which the snapshot was taken + #[prost(uint64, tag = "1")] + pub height: u64, + /// The application-specific snapshot format + #[prost(uint32, tag = "2")] + pub format: u32, + /// Number of chunks in the snapshot + #[prost(uint32, tag = "3")] + pub chunks: u32, + /// Arbitrary snapshot hash, equal only if identical + #[prost(bytes = "bytes", tag = "4")] + pub hash: ::prost::bytes::Bytes, + /// Arbitrary application metadata + #[prost(bytes = "bytes", tag = "5")] + pub metadata: ::prost::bytes::Bytes, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum CheckTxType { + New = 0, + Recheck = 1, +} +impl CheckTxType { + /// 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 { + CheckTxType::New => "NEW", + CheckTxType::Recheck => "RECHECK", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "NEW" => Some(Self::New), + "RECHECK" => Some(Self::Recheck), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum MisbehaviorType { + Unknown = 0, + DuplicateVote = 1, + LightClientAttack = 2, +} +impl MisbehaviorType { + /// 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 { + MisbehaviorType::Unknown => "UNKNOWN", + MisbehaviorType::DuplicateVote => "DUPLICATE_VOTE", + MisbehaviorType::LightClientAttack => "LIGHT_CLIENT_ATTACK", + } + } + /// 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), + "DUPLICATE_VOTE" => Some(Self::DuplicateVote), + "LIGHT_CLIENT_ATTACK" => Some(Self::LightClientAttack), + _ => None, + } + } +} diff --git a/proto/src/prost/v0_38/tendermint.blocksync.rs b/proto/src/prost/v0_38/tendermint.blocksync.rs new file mode 100644 index 000000000..ae51fa7d7 --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.blocksync.rs @@ -0,0 +1,59 @@ +/// BlockRequest requests a block for a specific height +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BlockRequest { + #[prost(int64, tag = "1")] + pub height: i64, +} +/// NoBlockResponse informs the node that the peer does not have block at the requested height +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NoBlockResponse { + #[prost(int64, tag = "1")] + pub height: i64, +} +/// BlockResponse returns block to the requested +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BlockResponse { + #[prost(message, optional, tag = "1")] + pub block: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub ext_commit: ::core::option::Option, +} +/// StatusRequest requests the status of a peer. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StatusRequest {} +/// StatusResponse is a peer response to inform their status. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StatusResponse { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int64, tag = "2")] + pub base: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Message { + #[prost(oneof = "message::Sum", tags = "1, 2, 3, 4, 5")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Message`. +pub mod message { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + BlockRequest(super::BlockRequest), + #[prost(message, tag = "2")] + NoBlockResponse(super::NoBlockResponse), + #[prost(message, tag = "3")] + BlockResponse(super::BlockResponse), + #[prost(message, tag = "4")] + StatusRequest(super::StatusRequest), + #[prost(message, tag = "5")] + StatusResponse(super::StatusResponse), + } +} diff --git a/proto/src/prost/v0_38/tendermint.consensus.rs b/proto/src/prost/v0_38/tendermint.consensus.rs new file mode 100644 index 000000000..95237cc78 --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.consensus.rs @@ -0,0 +1,201 @@ +/// NewRoundStep is sent for every step taken in the ConsensusState. +/// For every height/round/step transition +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NewRoundStep { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(uint32, tag = "3")] + pub step: u32, + #[prost(int64, tag = "4")] + pub seconds_since_start_time: i64, + #[prost(int32, tag = "5")] + pub last_commit_round: i32, +} +/// NewValidBlock is sent when a validator observes a valid block B in some round r, +/// i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. +/// In case the block is also committed, then IsCommit flag is set to true. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct NewValidBlock { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(message, optional, tag = "3")] + pub block_part_set_header: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub block_parts: ::core::option::Option, + #[prost(bool, tag = "5")] + pub is_commit: bool, +} +/// Proposal is sent when a new block is proposed. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Proposal { + #[prost(message, optional, tag = "1")] + pub proposal: ::core::option::Option, +} +/// ProposalPOL is sent when a previous proposal is re-proposed. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProposalPol { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub proposal_pol_round: i32, + #[prost(message, optional, tag = "3")] + pub proposal_pol: ::core::option::Option, +} +/// BlockPart is sent when gossipping a piece of the proposed block. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BlockPart { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(message, optional, tag = "3")] + pub part: ::core::option::Option, +} +/// Vote is sent when voting for a proposal (or lack thereof). +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Vote { + #[prost(message, optional, tag = "1")] + pub vote: ::core::option::Option, +} +/// HasVote is sent to indicate that a particular vote has been received. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct HasVote { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(enumeration = "super::types::SignedMsgType", tag = "3")] + pub r#type: i32, + #[prost(int32, tag = "4")] + pub index: i32, +} +/// VoteSetMaj23 is sent to indicate that a given BlockID has seen +2/3 votes. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VoteSetMaj23 { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(enumeration = "super::types::SignedMsgType", tag = "3")] + pub r#type: i32, + #[prost(message, optional, tag = "4")] + pub block_id: ::core::option::Option, +} +/// VoteSetBits is sent to communicate the bit-array of votes seen for the BlockID. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VoteSetBits { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(enumeration = "super::types::SignedMsgType", tag = "3")] + pub r#type: i32, + #[prost(message, optional, tag = "4")] + pub block_id: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub votes: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Message { + #[prost(oneof = "message::Sum", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Message`. +pub mod message { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + NewRoundStep(super::NewRoundStep), + #[prost(message, tag = "2")] + NewValidBlock(super::NewValidBlock), + #[prost(message, tag = "3")] + Proposal(super::Proposal), + #[prost(message, tag = "4")] + ProposalPol(super::ProposalPol), + #[prost(message, tag = "5")] + BlockPart(super::BlockPart), + #[prost(message, tag = "6")] + Vote(super::Vote), + #[prost(message, tag = "7")] + HasVote(super::HasVote), + #[prost(message, tag = "8")] + VoteSetMaj23(super::VoteSetMaj23), + #[prost(message, tag = "9")] + VoteSetBits(super::VoteSetBits), + } +} +/// MsgInfo are msgs from the reactor which may update the state +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MsgInfo { + #[prost(message, optional, tag = "1")] + pub msg: ::core::option::Option, + #[prost(string, tag = "2")] + pub peer_id: ::prost::alloc::string::String, +} +/// TimeoutInfo internally generated messages which may update the state +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TimeoutInfo { + #[prost(message, optional, tag = "1")] + pub duration: ::core::option::Option, + #[prost(int64, tag = "2")] + pub height: i64, + #[prost(int32, tag = "3")] + pub round: i32, + #[prost(uint32, tag = "4")] + pub step: u32, +} +/// EndHeight marks the end of the given height inside WAL. +/// @internal used by scripts/wal2json util. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EndHeight { + #[prost(int64, tag = "1")] + pub height: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WalMessage { + #[prost(oneof = "wal_message::Sum", tags = "1, 2, 3, 4")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `WALMessage`. +pub mod wal_message { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + EventDataRoundState(super::super::types::EventDataRoundState), + #[prost(message, tag = "2")] + MsgInfo(super::MsgInfo), + #[prost(message, tag = "3")] + TimeoutInfo(super::TimeoutInfo), + #[prost(message, tag = "4")] + EndHeight(super::EndHeight), + } +} +/// TimedWALMessage wraps WALMessage and adds Time for debugging purposes. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TimedWalMessage { + #[prost(message, optional, tag = "1")] + pub time: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub msg: ::core::option::Option, +} diff --git a/proto/src/prost/v0_38/tendermint.crypto.rs b/proto/src/prost/v0_38/tendermint.crypto.rs new file mode 100644 index 000000000..a6273013b --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.crypto.rs @@ -0,0 +1,86 @@ +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[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")] + pub leaf_hash: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", repeated, tag = "4")] + #[serde(with = "crate::serializers::bytes::vec_base64string")] + pub aunts: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValueOp { + /// Encoded in ProofOp.Key. + #[prost(bytes = "vec", tag = "1")] + pub key: ::prost::alloc::vec::Vec, + /// To encode in ProofOp.Data + #[prost(message, optional, tag = "2")] + pub proof: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DominoOp { + #[prost(string, tag = "1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub input: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub output: ::prost::alloc::string::String, +} +/// ProofOp defines an operation used for calculating Merkle root +/// The data could be arbitrary format, providing nessecary data +/// for example neighbouring node hash +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProofOp { + #[prost(string, tag = "1")] + pub r#type: ::prost::alloc::string::String, + #[prost(bytes = "vec", tag = "2")] + pub key: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "3")] + pub data: ::prost::alloc::vec::Vec, +} +/// ProofOps is Merkle proof defined by the list of ProofOps +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProofOps { + #[prost(message, repeated, tag = "1")] + pub ops: ::prost::alloc::vec::Vec, +} +/// PublicKey defines the keys available for use with Validators +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PublicKey { + #[prost(oneof = "public_key::Sum", tags = "1, 2")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `PublicKey`. +pub mod public_key { + #[derive(::serde::Deserialize, ::serde::Serialize)] + #[serde(tag = "type", content = "value")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(bytes, tag = "1")] + #[serde( + rename = "tendermint/PubKeyEd25519", + with = "crate::serializers::bytes::base64string" + )] + Ed25519(::prost::alloc::vec::Vec), + #[prost(bytes, tag = "2")] + #[serde( + rename = "tendermint/PubKeySecp256k1", + with = "crate::serializers::bytes::base64string" + )] + Secp256k1(::prost::alloc::vec::Vec), + } +} diff --git a/proto/src/prost/v0_38/tendermint.libs.bits.rs b/proto/src/prost/v0_38/tendermint.libs.bits.rs new file mode 100644 index 000000000..460876d21 --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.libs.bits.rs @@ -0,0 +1,9 @@ +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BitArray { + #[prost(int64, tag = "1")] + pub bits: i64, + #[prost(uint64, repeated, tag = "2")] + pub elems: ::prost::alloc::vec::Vec, +} diff --git a/proto/src/prost/v0_38/tendermint.mempool.rs b/proto/src/prost/v0_38/tendermint.mempool.rs new file mode 100644 index 000000000..9fec1376b --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.mempool.rs @@ -0,0 +1,21 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Txs { + #[prost(bytes = "vec", repeated, tag = "1")] + pub txs: ::prost::alloc::vec::Vec<::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")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Message`. +pub mod message { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + Txs(super::Txs), + } +} diff --git a/proto/src/prost/v0_38/tendermint.p2p.rs b/proto/src/prost/v0_38/tendermint.p2p.rs new file mode 100644 index 000000000..bfaa808cb --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.p2p.rs @@ -0,0 +1,117 @@ +#[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, + #[prost(string, tag = "2")] + pub ip: ::prost::alloc::string::String, + #[prost(uint32, tag = "3")] + pub port: u32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ProtocolVersion { + #[prost(uint64, tag = "1")] + pub p2p: u64, + #[prost(uint64, tag = "2")] + pub block: u64, + #[prost(uint64, tag = "3")] + pub app: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DefaultNodeInfo { + #[prost(message, optional, tag = "1")] + pub protocol_version: ::core::option::Option, + #[prost(string, tag = "2")] + pub default_node_id: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub listen_addr: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub network: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub version: ::prost::alloc::string::String, + #[prost(bytes = "vec", tag = "6")] + pub channels: ::prost::alloc::vec::Vec, + #[prost(string, tag = "7")] + pub moniker: ::prost::alloc::string::String, + #[prost(message, optional, tag = "8")] + pub other: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DefaultNodeInfoOther { + #[prost(string, tag = "1")] + pub tx_index: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub rpc_address: ::prost::alloc::string::String, +} +#[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)] +pub struct PexAddrs { + #[prost(message, repeated, tag = "1")] + pub addrs: ::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, 2")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Message`. +pub mod message { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + PexRequest(super::PexRequest), + #[prost(message, tag = "2")] + PexAddrs(super::PexAddrs), + } +} diff --git a/proto/src/prost/v0_38/tendermint.privval.rs b/proto/src/prost/v0_38/tendermint.privval.rs new file mode 100644 index 000000000..8485c3816 --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.privval.rs @@ -0,0 +1,135 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RemoteSignerError { + #[prost(int32, tag = "1")] + pub code: i32, + #[prost(string, tag = "2")] + pub description: ::prost::alloc::string::String, +} +/// PubKeyRequest requests the consensus public key from the remote signer. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PubKeyRequest { + #[prost(string, tag = "1")] + pub chain_id: ::prost::alloc::string::String, +} +/// PubKeyResponse is a response message containing the public key. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PubKeyResponse { + #[prost(message, optional, tag = "1")] + pub pub_key: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub error: ::core::option::Option, +} +/// SignVoteRequest is a request to sign a vote +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SignVoteRequest { + #[prost(message, optional, tag = "1")] + pub vote: ::core::option::Option, + #[prost(string, tag = "2")] + pub chain_id: ::prost::alloc::string::String, +} +/// SignedVoteResponse is a response containing a signed vote or an error +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SignedVoteResponse { + #[prost(message, optional, tag = "1")] + pub vote: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub error: ::core::option::Option, +} +/// SignProposalRequest is a request to sign a proposal +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SignProposalRequest { + #[prost(message, optional, tag = "1")] + pub proposal: ::core::option::Option, + #[prost(string, tag = "2")] + pub chain_id: ::prost::alloc::string::String, +} +/// SignedProposalResponse is response containing a signed proposal or an error +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SignedProposalResponse { + #[prost(message, optional, tag = "1")] + pub proposal: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub error: ::core::option::Option, +} +/// PingRequest is a request to confirm that the connection is alive. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PingRequest {} +/// PingResponse is a response to confirm that the connection is alive. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PingResponse {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Message { + #[prost(oneof = "message::Sum", tags = "1, 2, 3, 4, 5, 6, 7, 8")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Message`. +pub mod message { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + PubKeyRequest(super::PubKeyRequest), + #[prost(message, tag = "2")] + PubKeyResponse(super::PubKeyResponse), + #[prost(message, tag = "3")] + SignVoteRequest(super::SignVoteRequest), + #[prost(message, tag = "4")] + SignedVoteResponse(super::SignedVoteResponse), + #[prost(message, tag = "5")] + SignProposalRequest(super::SignProposalRequest), + #[prost(message, tag = "6")] + SignedProposalResponse(super::SignedProposalResponse), + #[prost(message, tag = "7")] + PingRequest(super::PingRequest), + #[prost(message, tag = "8")] + PingResponse(super::PingResponse), + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum Errors { + Unknown = 0, + UnexpectedResponse = 1, + NoConnection = 2, + ConnectionTimeout = 3, + ReadTimeout = 4, + WriteTimeout = 5, +} +impl Errors { + /// 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 { + Errors::Unknown => "ERRORS_UNKNOWN", + Errors::UnexpectedResponse => "ERRORS_UNEXPECTED_RESPONSE", + Errors::NoConnection => "ERRORS_NO_CONNECTION", + Errors::ConnectionTimeout => "ERRORS_CONNECTION_TIMEOUT", + Errors::ReadTimeout => "ERRORS_READ_TIMEOUT", + Errors::WriteTimeout => "ERRORS_WRITE_TIMEOUT", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "ERRORS_UNKNOWN" => Some(Self::Unknown), + "ERRORS_UNEXPECTED_RESPONSE" => Some(Self::UnexpectedResponse), + "ERRORS_NO_CONNECTION" => Some(Self::NoConnection), + "ERRORS_CONNECTION_TIMEOUT" => Some(Self::ConnectionTimeout), + "ERRORS_READ_TIMEOUT" => Some(Self::ReadTimeout), + "ERRORS_WRITE_TIMEOUT" => Some(Self::WriteTimeout), + _ => None, + } + } +} diff --git a/proto/src/prost/v0_38/tendermint.rpc.grpc.rs b/proto/src/prost/v0_38/tendermint.rpc.grpc.rs new file mode 100644 index 000000000..aa2131a15 --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.rpc.grpc.rs @@ -0,0 +1,20 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestPing {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RequestBroadcastTx { + #[prost(bytes = "vec", tag = "1")] + pub tx: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponsePing {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseBroadcastTx { + #[prost(message, optional, tag = "1")] + pub check_tx: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub tx_result: ::core::option::Option, +} diff --git a/proto/src/prost/v0_38/tendermint.state.rs b/proto/src/prost/v0_38/tendermint.state.rs new file mode 100644 index 000000000..014ddd6dc --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.state.rs @@ -0,0 +1,114 @@ +/// LegacyABCIResponses retains the responses +/// of the legacy ABCI calls during block processing. +/// Note ReponseDeliverTx is renamed to ExecTxResult but they are semantically the same +/// Kept for backwards compatibility for versions prior to v0.38 +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LegacyAbciResponses { + #[prost(message, repeated, tag = "1")] + pub deliver_txs: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub end_block: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub begin_block: ::core::option::Option, +} +/// ResponseBeginBlock is kept for backwards compatibility for versions prior to v0.38 +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseBeginBlock { + #[prost(message, repeated, tag = "1")] + pub events: ::prost::alloc::vec::Vec, +} +/// ResponseEndBlock is kept for backwards compatibility for versions prior to v0.38 +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ResponseEndBlock { + #[prost(message, repeated, tag = "1")] + pub validator_updates: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub consensus_param_updates: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub events: ::prost::alloc::vec::Vec, +} +/// ValidatorsInfo represents the latest validator set, or the last height it changed +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValidatorsInfo { + #[prost(message, optional, tag = "1")] + pub validator_set: ::core::option::Option, + #[prost(int64, tag = "2")] + pub last_height_changed: i64, +} +/// ConsensusParamsInfo represents the latest consensus params, or the last height it changed +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConsensusParamsInfo { + #[prost(message, optional, tag = "1")] + pub consensus_params: ::core::option::Option, + #[prost(int64, tag = "2")] + pub last_height_changed: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AbciResponsesInfo { + #[prost(message, optional, tag = "1")] + pub legacy_abci_responses: ::core::option::Option, + #[prost(int64, tag = "2")] + pub height: i64, + #[prost(message, optional, tag = "3")] + pub response_finalize_block: ::core::option::Option< + super::abci::ResponseFinalizeBlock, + >, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Version { + #[prost(message, optional, tag = "1")] + pub consensus: ::core::option::Option, + #[prost(string, tag = "2")] + pub software: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct State { + #[prost(message, optional, tag = "1")] + pub version: ::core::option::Option, + /// immutable + #[prost(string, tag = "2")] + pub chain_id: ::prost::alloc::string::String, + #[prost(int64, tag = "14")] + pub initial_height: i64, + /// LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) + #[prost(int64, tag = "3")] + pub last_block_height: i64, + #[prost(message, optional, tag = "4")] + pub last_block_id: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub last_block_time: ::core::option::Option, + /// LastValidators is used to validate block.LastCommit. + /// Validators are persisted to the database separately every time they change, + /// so we can query for historical validator sets. + /// Note that if s.LastBlockHeight causes a valset change, + /// we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 + 1 + /// Extra +1 due to nextValSet delay. + #[prost(message, optional, tag = "6")] + pub next_validators: ::core::option::Option, + #[prost(message, optional, tag = "7")] + pub validators: ::core::option::Option, + #[prost(message, optional, tag = "8")] + pub last_validators: ::core::option::Option, + #[prost(int64, tag = "9")] + pub last_height_validators_changed: i64, + /// Consensus parameters used for validating blocks. + /// Changes returned by EndBlock and updated after Commit. + #[prost(message, optional, tag = "10")] + pub consensus_params: ::core::option::Option, + #[prost(int64, tag = "11")] + pub last_height_consensus_params_changed: i64, + /// Merkle root of the results from executing prev block + #[prost(bytes = "vec", tag = "12")] + pub last_results_hash: ::prost::alloc::vec::Vec, + /// the latest AppHash we've received from calling abci.Commit() + #[prost(bytes = "vec", tag = "13")] + pub app_hash: ::prost::alloc::vec::Vec, +} diff --git a/proto/src/prost/v0_38/tendermint.statesync.rs b/proto/src/prost/v0_38/tendermint.statesync.rs new file mode 100644 index 000000000..a2ad034e3 --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.statesync.rs @@ -0,0 +1,62 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Message { + #[prost(oneof = "message::Sum", tags = "1, 2, 3, 4")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Message`. +pub mod message { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + SnapshotsRequest(super::SnapshotsRequest), + #[prost(message, tag = "2")] + SnapshotsResponse(super::SnapshotsResponse), + #[prost(message, tag = "3")] + ChunkRequest(super::ChunkRequest), + #[prost(message, tag = "4")] + ChunkResponse(super::ChunkResponse), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SnapshotsRequest {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SnapshotsResponse { + #[prost(uint64, tag = "1")] + pub height: u64, + #[prost(uint32, tag = "2")] + pub format: u32, + #[prost(uint32, tag = "3")] + pub chunks: u32, + #[prost(bytes = "vec", tag = "4")] + pub hash: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "5")] + pub metadata: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ChunkRequest { + #[prost(uint64, tag = "1")] + pub height: u64, + #[prost(uint32, tag = "2")] + pub format: u32, + #[prost(uint32, tag = "3")] + pub index: u32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ChunkResponse { + #[prost(uint64, tag = "1")] + pub height: u64, + #[prost(uint32, tag = "2")] + pub format: u32, + #[prost(uint32, tag = "3")] + pub index: u32, + #[prost(bytes = "vec", tag = "4")] + pub chunk: ::prost::alloc::vec::Vec, + #[prost(bool, tag = "5")] + pub missing: bool, +} diff --git a/proto/src/prost/v0_38/tendermint.store.rs b/proto/src/prost/v0_38/tendermint.store.rs new file mode 100644 index 000000000..98d20b0fc --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.store.rs @@ -0,0 +1,8 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BlockStoreState { + #[prost(int64, tag = "1")] + pub base: i64, + #[prost(int64, tag = "2")] + pub height: i64, +} diff --git a/proto/src/prost/v0_38/tendermint.types.rs b/proto/src/prost/v0_38/tendermint.types.rs new file mode 100644 index 000000000..2d9bca00f --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.types.rs @@ -0,0 +1,647 @@ +/// 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, + #[prost(message, optional, tag = "5")] + pub abci: ::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, +} +/// ABCIParams configure functionality specific to the Application Blockchain Interface. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AbciParams { + /// vote_extensions_enable_height configures the first height during which + /// vote extensions will be enabled. During this specified height, and for all + /// subsequent heights, precommit messages that do not contain valid extension data + /// will be considered invalid. Prior to this height, vote extensions will not + /// be used or accepted by validators on the network. + /// + /// Once enabled, vote extensions will be created by the application in ExtendVote, + /// passed to the application for validation in VerifyVoteExtension and given + /// to the application to use when proposing a block during PrepareProposal. + #[prost(int64, tag = "1")] + pub vote_extensions_enable_height: i64, +} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ValidatorSet { + #[prost(message, repeated, tag = "1")] + pub validators: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub proposer: ::core::option::Option, + #[prost(int64, tag = "3")] + #[serde(skip)] + pub total_voting_power: i64, +} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Validator { + #[prost(bytes = "vec", tag = "1")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub address: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub pub_key: ::core::option::Option, + #[prost(int64, tag = "3")] + #[serde(alias = "power", with = "crate::serializers::from_str")] + pub voting_power: i64, + #[prost(int64, tag = "4")] + #[serde(with = "crate::serializers::from_str", default)] + pub proposer_priority: i64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SimpleValidator { + #[prost(message, optional, tag = "1")] + pub pub_key: ::core::option::Option, + #[prost(int64, tag = "2")] + pub voting_power: i64, +} +/// BlockIdFlag indicates which BlockID the signature is for +#[derive(::num_derive::FromPrimitive, ::num_derive::ToPrimitive)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum BlockIdFlag { + /// indicates an error condition + Unknown = 0, + /// the vote was not received + Absent = 1, + /// voted for the block that received the majority + Commit = 2, + /// voted for nil + Nil = 3, +} +impl BlockIdFlag { + /// 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 { + BlockIdFlag::Unknown => "BLOCK_ID_FLAG_UNKNOWN", + BlockIdFlag::Absent => "BLOCK_ID_FLAG_ABSENT", + BlockIdFlag::Commit => "BLOCK_ID_FLAG_COMMIT", + BlockIdFlag::Nil => "BLOCK_ID_FLAG_NIL", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "BLOCK_ID_FLAG_UNKNOWN" => Some(Self::Unknown), + "BLOCK_ID_FLAG_ABSENT" => Some(Self::Absent), + "BLOCK_ID_FLAG_COMMIT" => Some(Self::Commit), + "BLOCK_ID_FLAG_NIL" => Some(Self::Nil), + _ => None, + } + } +} +/// PartsetHeader +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PartSetHeader { + #[prost(uint32, tag = "1")] + #[serde(with = "crate::serializers::part_set_header_total")] + pub total: u32, + #[prost(bytes = "vec", tag = "2")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub hash: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Part { + #[prost(uint32, tag = "1")] + pub index: u32, + #[prost(bytes = "vec", tag = "2")] + pub bytes: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "3")] + pub proof: ::core::option::Option, +} +/// BlockID +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BlockId { + #[prost(bytes = "vec", tag = "1")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub hash: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + #[serde(rename = "parts", alias = "part_set_header")] + pub part_set_header: ::core::option::Option, +} +/// Header defines the structure of a block header. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Header { + /// basic block info + #[prost(message, optional, tag = "1")] + pub version: ::core::option::Option, + #[prost(string, tag = "2")] + pub chain_id: ::prost::alloc::string::String, + #[prost(int64, tag = "3")] + #[serde(with = "crate::serializers::from_str")] + pub height: i64, + #[prost(message, optional, tag = "4")] + #[serde(with = "crate::serializers::optional")] + pub time: ::core::option::Option, + /// prev block info + #[prost(message, optional, tag = "5")] + pub last_block_id: ::core::option::Option, + /// hashes of block data + /// + /// commit from validators from the last block + #[prost(bytes = "vec", tag = "6")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub last_commit_hash: ::prost::alloc::vec::Vec, + /// transactions + #[prost(bytes = "vec", tag = "7")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub data_hash: ::prost::alloc::vec::Vec, + /// hashes from the app output from the prev block + /// + /// validators for the current block + #[prost(bytes = "vec", tag = "8")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub validators_hash: ::prost::alloc::vec::Vec, + /// validators for the next block + #[prost(bytes = "vec", tag = "9")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub next_validators_hash: ::prost::alloc::vec::Vec, + /// consensus params for current block + #[prost(bytes = "vec", tag = "10")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub consensus_hash: ::prost::alloc::vec::Vec, + /// state after txs from the previous block + #[prost(bytes = "vec", tag = "11")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub app_hash: ::prost::alloc::vec::Vec, + /// root hash of all results from the txs from the previous block + #[prost(bytes = "vec", tag = "12")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub last_results_hash: ::prost::alloc::vec::Vec, + /// consensus info + /// + /// evidence included in the block + #[prost(bytes = "vec", tag = "13")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub evidence_hash: ::prost::alloc::vec::Vec, + /// original proposer of the block + #[prost(bytes = "vec", tag = "14")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub proposer_address: ::prost::alloc::vec::Vec, +} +/// Data contains the set of transactions included in the block +#[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. + #[prost(bytes = "vec", repeated, tag = "1")] + #[serde(with = "crate::serializers::txs")] + pub txs: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, +} +/// Vote represents a prevote or precommit vote from validators for +/// consensus. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Vote { + #[prost(enumeration = "SignedMsgType", tag = "1")] + pub r#type: i32, + #[prost(int64, tag = "2")] + #[serde(with = "crate::serializers::from_str")] + pub height: i64, + #[prost(int32, tag = "3")] + pub round: i32, + /// zero if vote is nil. + #[prost(message, optional, tag = "4")] + pub block_id: ::core::option::Option, + #[prost(message, optional, tag = "5")] + #[serde(with = "crate::serializers::optional")] + pub timestamp: ::core::option::Option, + #[prost(bytes = "vec", tag = "6")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub validator_address: ::prost::alloc::vec::Vec, + #[prost(int32, tag = "7")] + pub validator_index: i32, + /// Vote signature by the validator if they participated in consensus for the + /// associated block. + #[prost(bytes = "vec", tag = "8")] + #[serde(with = "crate::serializers::bytes::base64string")] + pub signature: ::prost::alloc::vec::Vec, + /// Vote extension provided by the application. Only valid for precommit + /// messages. + #[prost(bytes = "vec", tag = "9")] + pub extension: ::prost::alloc::vec::Vec, + /// Vote extension signature by the validator if they participated in + /// consensus for the associated block. + /// Only valid for precommit messages. + #[prost(bytes = "vec", tag = "10")] + pub extension_signature: ::prost::alloc::vec::Vec, +} +/// Commit contains the evidence that a block was committed by a set of validators. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Commit { + #[prost(int64, tag = "1")] + #[serde(with = "crate::serializers::from_str")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(message, optional, tag = "3")] + pub block_id: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + #[serde(with = "crate::serializers::nullable")] + pub signatures: ::prost::alloc::vec::Vec, +} +/// CommitSig is a part of the Vote included in a Commit. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CommitSig { + #[prost(enumeration = "BlockIdFlag", tag = "1")] + pub block_id_flag: i32, + #[prost(bytes = "vec", tag = "2")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub validator_address: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "3")] + #[serde(with = "crate::serializers::optional")] + pub timestamp: ::core::option::Option, + #[prost(bytes = "vec", tag = "4")] + #[serde(with = "crate::serializers::bytes::base64string")] + pub signature: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExtendedCommit { + #[prost(int64, tag = "1")] + pub height: i64, + #[prost(int32, tag = "2")] + pub round: i32, + #[prost(message, optional, tag = "3")] + pub block_id: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + pub extended_signatures: ::prost::alloc::vec::Vec, +} +/// ExtendedCommitSig retains all the same fields as CommitSig but adds vote +/// extension-related fields. We use two signatures to ensure backwards compatibility. +/// That is the digest of the original signature is still the same in prior versions +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExtendedCommitSig { + #[prost(enumeration = "BlockIdFlag", tag = "1")] + pub block_id_flag: i32, + #[prost(bytes = "vec", tag = "2")] + pub validator_address: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "3")] + pub timestamp: ::core::option::Option, + #[prost(bytes = "vec", tag = "4")] + pub signature: ::prost::alloc::vec::Vec, + /// Vote extension data + #[prost(bytes = "vec", tag = "5")] + pub extension: ::prost::alloc::vec::Vec, + /// Vote extension signature + #[prost(bytes = "vec", tag = "6")] + pub extension_signature: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Proposal { + #[prost(enumeration = "SignedMsgType", tag = "1")] + pub r#type: i32, + #[prost(int64, tag = "2")] + pub height: i64, + #[prost(int32, tag = "3")] + pub round: i32, + #[prost(int32, tag = "4")] + pub pol_round: i32, + #[prost(message, optional, tag = "5")] + pub block_id: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub timestamp: ::core::option::Option, + #[prost(bytes = "vec", tag = "7")] + pub signature: ::prost::alloc::vec::Vec, +} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SignedHeader { + #[prost(message, optional, tag = "1")] + pub header: ::core::option::Option
, + #[prost(message, optional, tag = "2")] + pub commit: ::core::option::Option, +} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LightBlock { + #[prost(message, optional, tag = "1")] + pub signed_header: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub validator_set: ::core::option::Option, +} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BlockMeta { + #[prost(message, optional, tag = "1")] + pub block_id: ::core::option::Option, + #[prost(int64, tag = "2")] + #[serde(with = "crate::serializers::from_str")] + pub block_size: i64, + #[prost(message, optional, tag = "3")] + pub header: ::core::option::Option
, + #[prost(int64, tag = "4")] + #[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. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TxProof { + #[prost(bytes = "vec", tag = "1")] + #[serde(with = "crate::serializers::bytes::hexstring")] + pub root_hash: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "2")] + #[serde(with = "crate::serializers::bytes::base64string")] + pub data: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "3")] + pub proof: ::core::option::Option, +} +/// SignedMsgType is a type of signed message in the consensus. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum SignedMsgType { + Unknown = 0, + /// Votes + Prevote = 1, + Precommit = 2, + /// Proposals + Proposal = 32, +} +impl SignedMsgType { + /// 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 { + SignedMsgType::Unknown => "SIGNED_MSG_TYPE_UNKNOWN", + SignedMsgType::Prevote => "SIGNED_MSG_TYPE_PREVOTE", + SignedMsgType::Precommit => "SIGNED_MSG_TYPE_PRECOMMIT", + SignedMsgType::Proposal => "SIGNED_MSG_TYPE_PROPOSAL", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "SIGNED_MSG_TYPE_UNKNOWN" => Some(Self::Unknown), + "SIGNED_MSG_TYPE_PREVOTE" => Some(Self::Prevote), + "SIGNED_MSG_TYPE_PRECOMMIT" => Some(Self::Precommit), + "SIGNED_MSG_TYPE_PROPOSAL" => Some(Self::Proposal), + _ => None, + } + } +} +#[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, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Evidence { + #[prost(oneof = "evidence::Sum", tags = "1, 2")] + pub sum: ::core::option::Option, +} +/// Nested message and enum types in `Evidence`. +pub mod evidence { + #[derive(::serde::Deserialize, ::serde::Serialize)] + #[serde(tag = "type", content = "value")] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Sum { + #[prost(message, tag = "1")] + #[serde(rename = "tendermint/DuplicateVoteEvidence")] + DuplicateVoteEvidence(super::DuplicateVoteEvidence), + #[prost(message, tag = "2")] + #[serde(rename = "tendermint/LightClientAttackEvidence")] + LightClientAttackEvidence(super::LightClientAttackEvidence), + } +} +/// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DuplicateVoteEvidence { + #[prost(message, optional, tag = "1")] + pub vote_a: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub vote_b: ::core::option::Option, + #[prost(int64, tag = "3")] + #[serde(rename = "TotalVotingPower", with = "crate::serializers::from_str")] + pub total_voting_power: i64, + #[prost(int64, tag = "4")] + #[serde(rename = "ValidatorPower", with = "crate::serializers::from_str")] + pub validator_power: i64, + #[prost(message, optional, tag = "5")] + #[serde(rename = "Timestamp")] + pub timestamp: ::core::option::Option, +} +/// LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[serde(rename_all = "PascalCase")] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LightClientAttackEvidence { + #[prost(message, optional, tag = "1")] + pub conflicting_block: ::core::option::Option, + #[prost(int64, tag = "2")] + #[serde(with = "crate::serializers::from_str")] + pub common_height: i64, + #[prost(message, repeated, tag = "3")] + pub byzantine_validators: ::prost::alloc::vec::Vec, + #[prost(int64, tag = "4")] + #[serde(with = "crate::serializers::from_str")] + pub total_voting_power: i64, + #[prost(message, optional, tag = "5")] + pub timestamp: ::core::option::Option, +} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EvidenceList { + #[prost(message, repeated, tag = "1")] + #[serde(with = "crate::serializers::nullable")] + pub evidence: ::prost::alloc::vec::Vec, +} +#[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, +} +#[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, + #[prost(message, optional, tag = "2")] + pub part_set_header: ::core::option::Option, +} +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CanonicalPartSetHeader { + #[prost(uint32, tag = "1")] + pub total: u32, + #[prost(bytes = "vec", tag = "2")] + pub hash: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CanonicalProposal { + /// type alias for byte + #[prost(enumeration = "SignedMsgType", tag = "1")] + pub r#type: i32, + /// canonicalization requires fixed size encoding here + #[prost(sfixed64, tag = "2")] + pub height: i64, + /// canonicalization requires fixed size encoding here + #[prost(sfixed64, tag = "3")] + pub round: i64, + #[prost(int64, tag = "4")] + pub pol_round: i64, + #[prost(message, optional, tag = "5")] + pub block_id: ::core::option::Option, + #[prost(message, optional, tag = "6")] + pub timestamp: ::core::option::Option, + #[prost(string, tag = "7")] + 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 CanonicalVote { + /// type alias for byte + #[prost(enumeration = "SignedMsgType", tag = "1")] + pub r#type: i32, + /// canonicalization requires fixed size encoding here + #[prost(sfixed64, tag = "2")] + pub height: i64, + /// canonicalization requires fixed size encoding here + #[prost(sfixed64, tag = "3")] + pub round: i64, + #[prost(message, optional, tag = "4")] + pub block_id: ::core::option::Option, + #[prost(message, optional, tag = "5")] + pub timestamp: ::core::option::Option, + #[prost(string, tag = "6")] + pub chain_id: ::prost::alloc::string::String, +} +/// CanonicalVoteExtension provides us a way to serialize a vote extension from +/// a particular validator such that we can sign over those serialized bytes. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CanonicalVoteExtension { + #[prost(bytes = "vec", tag = "1")] + pub extension: ::prost::alloc::vec::Vec, + #[prost(sfixed64, tag = "2")] + pub height: i64, + #[prost(sfixed64, tag = "3")] + pub round: i64, + #[prost(string, tag = "4")] + pub chain_id: ::prost::alloc::string::String, +} diff --git a/proto/src/prost/v0_38/tendermint.version.rs b/proto/src/prost/v0_38/tendermint.version.rs new file mode 100644 index 000000000..8a77a26fc --- /dev/null +++ b/proto/src/prost/v0_38/tendermint.version.rs @@ -0,0 +1,25 @@ +/// App includes the protocol and software version for the application. +/// This information is included in ResponseInfo. The App.Protocol can be +/// updated in ResponseEndBlock. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct App { + #[prost(uint64, tag = "1")] + pub protocol: u64, + #[prost(string, tag = "2")] + pub software: ::prost::alloc::string::String, +} +/// Consensus captures the consensus rules for processing a block in the blockchain, +/// including all blockchain data structures and the rules of the application's +/// state transition machine. +#[derive(::serde::Deserialize, ::serde::Serialize)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Consensus { + #[prost(uint64, tag = "1")] + #[serde(with = "crate::serializers::from_str")] + pub block: u64, + #[prost(uint64, tag = "2")] + #[serde(with = "crate::serializers::from_str", default)] + pub app: u64, +} diff --git a/proto/src/serializers.rs b/proto/src/serializers.rs index 5780154c0..1f9ffd94a 100644 --- a/proto/src/serializers.rs +++ b/proto/src/serializers.rs @@ -61,7 +61,6 @@ pub mod nullable; pub mod optional; pub mod optional_from_str; pub mod part_set_header_total; -pub mod public_key; pub mod time_duration; pub mod timestamp; pub mod txs; diff --git a/proto/src/serializers/evidence.rs b/proto/src/serializers/evidence.rs index 7136455c5..632a47132 100644 --- a/proto/src/serializers/evidence.rs +++ b/proto/src/serializers/evidence.rs @@ -45,3 +45,27 @@ mod v0_37 { } } } + +mod v0_38 { + use crate::v0_38::types::{evidence, Evidence}; + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + + impl<'de> Deserialize<'de> for Evidence { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let sum = Option::::deserialize(deserializer)?; + Ok(Self { sum }) + } + } + + impl Serialize for Evidence { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + self.sum.serialize(serializer) + } + } +} diff --git a/proto/src/serializers/public_key.rs b/proto/src/serializers/public_key.rs deleted file mode 100644 index 49a6fda02..000000000 --- a/proto/src/serializers/public_key.rs +++ /dev/null @@ -1,47 +0,0 @@ -mod v0_34 { - use crate::v0_34::crypto::{public_key, PublicKey}; - use serde::{Deserialize, Deserializer, Serialize, Serializer}; - - impl<'de> Deserialize<'de> for PublicKey { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let sum = Option::::deserialize(deserializer)?; - Ok(Self { sum }) - } - } - - impl Serialize for PublicKey { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - self.sum.serialize(serializer) - } - } -} - -mod v0_37 { - use crate::v0_37::crypto::{public_key, PublicKey}; - use serde::{Deserialize, Deserializer, Serialize, Serializer}; - - impl<'de> Deserialize<'de> for PublicKey { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let sum = Option::::deserialize(deserializer)?; - Ok(Self { sum }) - } - } - - impl Serialize for PublicKey { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - self.sum.serialize(serializer) - } - } -} diff --git a/proto/src/tendermint.rs b/proto/src/tendermint.rs index 4a8211a91..9a9aa4a52 100644 --- a/proto/src/tendermint.rs +++ b/proto/src/tendermint.rs @@ -1,3 +1,4 @@ pub mod v0_34; pub mod v0_37; -pub use v0_37::*; +pub mod v0_38; +pub use v0_38::*; diff --git a/proto/src/tendermint/v0_34.rs b/proto/src/tendermint/v0_34.rs index 561b12534..0bd49d93b 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/cometbft/cometbft"; - pub const COMMITISH: &str = "v0.34.27"; + pub const COMMITISH: &str = "v0.34.28"; } diff --git a/proto/src/tendermint/v0_37.rs b/proto/src/tendermint/v0_37.rs index 6f987b3e6..580b38d92 100644 --- a/proto/src/tendermint/v0_37.rs +++ b/proto/src/tendermint/v0_37.rs @@ -62,5 +62,5 @@ pub mod version { pub mod meta { pub const REPOSITORY: &str = "https://github.com/cometbft/cometbft"; - pub const COMMITISH: &str = "v0.37.0"; + pub const COMMITISH: &str = "v0.37.1"; } diff --git a/proto/src/tendermint/v0_38.rs b/proto/src/tendermint/v0_38.rs new file mode 100644 index 000000000..f3eb9433e --- /dev/null +++ b/proto/src/tendermint/v0_38.rs @@ -0,0 +1,66 @@ +//! Tendermint-proto auto-generated sub-modules for Tendermint + +pub mod abci { + include!("../prost/v0_38/tendermint.abci.rs"); +} + +pub mod blocksync { + include!("../prost/v0_38/tendermint.blocksync.rs"); +} + +pub mod consensus { + include!("../prost/v0_38/tendermint.consensus.rs"); +} + +pub mod crypto { + include!("../prost/v0_38/tendermint.crypto.rs"); +} + +pub mod libs { + pub mod bits { + include!("../prost/v0_38/tendermint.libs.bits.rs"); + } +} + +pub mod mempool { + include!("../prost/v0_38/tendermint.mempool.rs"); +} + +pub mod p2p { + include!("../prost/v0_38/tendermint.p2p.rs"); +} + +pub mod privval { + include!("../prost/v0_38/tendermint.privval.rs"); +} + +pub mod rpc { + pub mod grpc { + include!("../prost/v0_38/tendermint.rpc.grpc.rs"); + } +} + +pub mod state { + include!("../prost/v0_38/tendermint.state.rs"); +} + +pub mod statesync { + include!("../prost/v0_38/tendermint.statesync.rs"); +} + +pub mod store { + include!("../prost/v0_38/tendermint.store.rs"); +} + +pub mod types { + include!("../prost/v0_38/tendermint.types.rs"); +} + +pub mod version { + include!("../prost/v0_38/tendermint.version.rs"); +} + +pub mod meta { + pub const REPOSITORY: &str = "https://github.com/cometbft/cometbft"; + pub const COMMITISH: &str = "v0.38.0-alpha.1"; +} diff --git a/proto/tests/unit.rs b/proto/tests/unit.rs index d0bc59d4d..c7eb639a2 100644 --- a/proto/tests/unit.rs +++ b/proto/tests/unit.rs @@ -1,6 +1,6 @@ use core::convert::TryFrom; -use tendermint_proto::v0_37::types::{BlockId as RawBlockId, PartSetHeader as RawPartSetHeader}; +use tendermint_proto::v0_38::types::{BlockId as RawBlockId, PartSetHeader as RawPartSetHeader}; use tendermint_proto::Protobuf; impl Protobuf for BlockId {} diff --git a/tendermint/src/abci.rs b/tendermint/src/abci.rs index fd347398d..2fae2e88d 100644 --- a/tendermint/src/abci.rs +++ b/tendermint/src/abci.rs @@ -44,15 +44,16 @@ pub mod request; pub mod response; pub mod types; -pub use crate::v0_37::abci::request::Request; -pub use crate::v0_37::abci::response::Response; +pub use crate::v0_38::abci::request::Request; +pub use crate::v0_38::abci::request::{ + ConsensusRequest, InfoRequest, MempoolRequest, SnapshotRequest, +}; +pub use crate::v0_38::abci::response::Response; +pub use crate::v0_38::abci::response::{ + ConsensusResponse, InfoResponse, MempoolResponse, SnapshotResponse, +}; pub use event::{Event, EventAttribute, EventAttributeIndexExt, TypedEvent}; #[doc(inline)] -pub use self::{ - code::Code, - kind::MethodKind, - request::{ConsensusRequest, InfoRequest, MempoolRequest, SnapshotRequest}, - response::{ConsensusResponse, InfoResponse, MempoolResponse, SnapshotResponse}, -}; +pub use self::{code::Code, kind::MethodKind}; diff --git a/tendermint/src/abci/doc/request-extendvote.md b/tendermint/src/abci/doc/request-extendvote.md new file mode 100644 index 000000000..2a390a1e2 --- /dev/null +++ b/tendermint/src/abci/doc/request-extendvote.md @@ -0,0 +1 @@ +[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#extendvote) diff --git a/tendermint/src/abci/doc/request-finalizeblock.md b/tendermint/src/abci/doc/request-finalizeblock.md new file mode 100644 index 000000000..c6b89c887 --- /dev/null +++ b/tendermint/src/abci/doc/request-finalizeblock.md @@ -0,0 +1 @@ +[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#finalizeblock) diff --git a/tendermint/src/abci/doc/request-verifyvoteextension.md b/tendermint/src/abci/doc/request-verifyvoteextension.md new file mode 100644 index 000000000..66affbb35 --- /dev/null +++ b/tendermint/src/abci/doc/request-verifyvoteextension.md @@ -0,0 +1 @@ +[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#verifyvoteextension) diff --git a/tendermint/src/abci/doc/response-extendvote.md b/tendermint/src/abci/doc/response-extendvote.md new file mode 100644 index 000000000..2a390a1e2 --- /dev/null +++ b/tendermint/src/abci/doc/response-extendvote.md @@ -0,0 +1 @@ +[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#extendvote) diff --git a/tendermint/src/abci/doc/response-finalizeblock.md b/tendermint/src/abci/doc/response-finalizeblock.md new file mode 100644 index 000000000..c6b89c887 --- /dev/null +++ b/tendermint/src/abci/doc/response-finalizeblock.md @@ -0,0 +1 @@ +[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#finalizeblock) diff --git a/tendermint/src/abci/doc/response-verifyvoteextension.md b/tendermint/src/abci/doc/response-verifyvoteextension.md new file mode 100644 index 000000000..66affbb35 --- /dev/null +++ b/tendermint/src/abci/doc/response-verifyvoteextension.md @@ -0,0 +1 @@ +[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#verifyvoteextension) diff --git a/tendermint/src/abci/event.rs b/tendermint/src/abci/event.rs index 38b9352c7..4dc13e443 100644 --- a/tendermint/src/abci/event.rs +++ b/tendermint/src/abci/event.rs @@ -281,7 +281,65 @@ mod v0_37 { type Error = crate::Error; fn try_from(event: pb::EventAttribute) -> Result { - // We insist that keys and values are strings, like tm 0.35 did. + Ok(Self { + key: event.key, + value: event.value, + index: event.index, + }) + } + } + + impl Protobuf for EventAttribute {} + + impl From for pb::Event { + fn from(event: Event) -> Self { + Self { + r#type: event.kind, + attributes: event.attributes.into_iter().map(Into::into).collect(), + } + } + } + + impl TryFrom for Event { + type Error = crate::Error; + + fn try_from(event: pb::Event) -> Result { + Ok(Self { + kind: event.r#type, + attributes: event + .attributes + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } + } + + impl Protobuf for Event {} +} + +mod v0_38 { + use super::{Event, EventAttribute}; + use crate::prelude::*; + use core::convert::{TryFrom, TryInto}; + + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; + + impl From for pb::EventAttribute { + fn from(event: EventAttribute) -> Self { + Self { + key: event.key, + value: event.value, + index: event.index, + } + } + } + + impl TryFrom for EventAttribute { + type Error = crate::Error; + + fn try_from(event: pb::EventAttribute) -> Result { Ok(Self { key: event.key, value: event.value, diff --git a/tendermint/src/abci/request.rs b/tendermint/src/abci/request.rs index 40f9bbdcf..aca85aca2 100644 --- a/tendermint/src/abci/request.rs +++ b/tendermint/src/abci/request.rs @@ -26,6 +26,8 @@ pub(super) mod check_tx; pub(super) mod deliver_tx; pub(super) mod echo; pub(super) mod end_block; +pub(super) mod extend_vote; +pub(super) mod finalize_block; pub(super) mod info; pub(super) mod init_chain; pub(super) mod load_snapshot_chunk; @@ -34,6 +36,7 @@ pub(super) mod prepare_proposal; pub(super) mod process_proposal; pub(super) mod query; pub(super) mod set_option; +pub(super) mod verify_vote_extension; pub use apply_snapshot_chunk::ApplySnapshotChunk; pub use begin_block::BeginBlock; @@ -41,6 +44,8 @@ pub use check_tx::{CheckTx, CheckTxKind}; pub use deliver_tx::DeliverTx; pub use echo::Echo; pub use end_block::EndBlock; +pub use extend_vote::ExtendVote; +pub use finalize_block::FinalizeBlock; pub use info::Info; pub use init_chain::InitChain; pub use load_snapshot_chunk::LoadSnapshotChunk; @@ -49,56 +54,4 @@ pub use prepare_proposal::PrepareProposal; pub use process_proposal::ProcessProposal; pub use query::Query; pub use set_option::SetOption; - -/// The consensus category of ABCI requests. -#[allow(clippy::large_enum_variant)] -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum ConsensusRequest { - #[doc = include_str!("doc/request-initchain.md")] - InitChain(InitChain), - #[doc = include_str!("doc/request-prepareproposal.md")] - PrepareProposal(PrepareProposal), - #[doc = include_str!("doc/request-processproposal.md")] - ProcessProposal(ProcessProposal), - #[doc = include_str!("doc/request-beginblock.md")] - BeginBlock(BeginBlock), - #[doc = include_str!("doc/request-delivertx.md")] - DeliverTx(DeliverTx), - #[doc = include_str!("doc/request-endblock.md")] - EndBlock(EndBlock), - #[doc = include_str!("doc/request-commit.md")] - Commit, -} - -/// The mempool category of ABCI requests. -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum MempoolRequest { - #[doc = include_str!("doc/request-checktx.md")] - CheckTx(CheckTx), -} - -/// The info category of ABCI requests. -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum InfoRequest { - #[doc = include_str!("doc/request-info.md")] - Info(Info), - #[doc = include_str!("doc/request-query.md")] - Query(Query), - #[doc = include_str!("doc/request-echo.md")] - Echo(Echo), - #[doc = include_str!("doc/request-setoption.md")] - SetOption(SetOption), -} - -/// The snapshot category of ABCI requests. -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum SnapshotRequest { - #[doc = include_str!("doc/request-listsnapshots.md")] - ListSnapshots, - #[doc = include_str!("doc/request-offersnapshot.md")] - OfferSnapshot(OfferSnapshot), - #[doc = include_str!("doc/request-loadsnapshotchunk.md")] - LoadSnapshotChunk(LoadSnapshotChunk), - #[doc = include_str!("doc/request-applysnapshotchunk.md")] - ApplySnapshotChunk(ApplySnapshotChunk), -} +pub use verify_vote_extension::VerifyVoteExtension; diff --git a/tendermint/src/abci/request/begin_block.rs b/tendermint/src/abci/request/begin_block.rs index 9174d77b3..8b1526456 100644 --- a/tendermint/src/abci/request/begin_block.rs +++ b/tendermint/src/abci/request/begin_block.rs @@ -30,9 +30,58 @@ pub struct BeginBlock { // Protobuf conversions // ============================================================================= -tendermint_pb_modules! { +mod v0_34 { use super::BeginBlock; use crate::Error; + use tendermint_proto::v0_34 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::RequestBeginBlock { + fn from(begin_block: BeginBlock) -> Self { + Self { + hash: begin_block.hash.into(), + header: Some(begin_block.header.into()), + last_commit_info: Some(begin_block.last_commit_info.into()), + byzantine_validators: begin_block + .byzantine_validators + .into_iter() + .map(Into::into) + .collect(), + } + } + } + + impl TryFrom for BeginBlock { + type Error = Error; + + fn try_from(begin_block: pb::abci::RequestBeginBlock) -> Result { + Ok(Self { + hash: begin_block.hash.try_into()?, + header: begin_block + .header + .ok_or_else(Error::missing_header)? + .try_into()?, + last_commit_info: begin_block + .last_commit_info + .ok_or_else(Error::missing_last_commit_info)? + .try_into()?, + byzantine_validators: begin_block + .byzantine_validators + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } + } + + impl Protobuf for BeginBlock {} +} + +mod v0_37 { + use super::BeginBlock; + use crate::Error; + use tendermint_proto::v0_37 as pb; + use tendermint_proto::Protobuf; impl From for pb::abci::RequestBeginBlock { fn from(begin_block: BeginBlock) -> Self { diff --git a/tendermint/src/abci/request/deliver_tx.rs b/tendermint/src/abci/request/deliver_tx.rs index 83fc11a14..3e85ef061 100644 --- a/tendermint/src/abci/request/deliver_tx.rs +++ b/tendermint/src/abci/request/deliver_tx.rs @@ -13,8 +13,32 @@ pub struct DeliverTx { // Protobuf conversions // ============================================================================= -tendermint_pb_modules! { +mod v0_34 { use super::DeliverTx; + use tendermint_proto::v0_34 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::RequestDeliverTx { + fn from(deliver_tx: DeliverTx) -> Self { + Self { tx: deliver_tx.tx } + } + } + + impl TryFrom for DeliverTx { + type Error = crate::Error; + + fn try_from(deliver_tx: pb::abci::RequestDeliverTx) -> Result { + Ok(Self { tx: deliver_tx.tx }) + } + } + + impl Protobuf for DeliverTx {} +} + +mod v0_37 { + use super::DeliverTx; + use tendermint_proto::v0_37 as pb; + use tendermint_proto::Protobuf; impl From for pb::abci::RequestDeliverTx { fn from(deliver_tx: DeliverTx) -> Self { diff --git a/tendermint/src/abci/request/end_block.rs b/tendermint/src/abci/request/end_block.rs index c3b05b8b8..879e1849e 100644 --- a/tendermint/src/abci/request/end_block.rs +++ b/tendermint/src/abci/request/end_block.rs @@ -11,8 +11,36 @@ pub struct EndBlock { // Protobuf conversions // ============================================================================= -tendermint_pb_modules! { +mod v0_34 { use super::EndBlock; + use tendermint_proto::v0_34 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::RequestEndBlock { + fn from(end_block: EndBlock) -> Self { + Self { + height: end_block.height, + } + } + } + + impl TryFrom for EndBlock { + type Error = crate::Error; + + fn try_from(end_block: pb::abci::RequestEndBlock) -> Result { + Ok(Self { + height: end_block.height, + }) + } + } + + impl Protobuf for EndBlock {} +} + +mod v0_37 { + use super::EndBlock; + use tendermint_proto::v0_37 as pb; + use tendermint_proto::Protobuf; impl From for pb::abci::RequestEndBlock { fn from(end_block: EndBlock) -> Self { diff --git a/tendermint/src/abci/request/extend_vote.rs b/tendermint/src/abci/request/extend_vote.rs new file mode 100644 index 000000000..5f7fef403 --- /dev/null +++ b/tendermint/src/abci/request/extend_vote.rs @@ -0,0 +1,40 @@ +use crate::{block, Hash}; + +#[doc = include_str!("../doc/request-extendvote.md")] +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct ExtendVote { + pub hash: Hash, + pub height: block::Height, +} + +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +mod v0_38 { + use super::ExtendVote; + use tendermint_proto::v0_38 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::RequestExtendVote { + fn from(extend_vote: ExtendVote) -> Self { + Self { + hash: extend_vote.hash.into(), + height: extend_vote.height.into(), + } + } + } + + impl TryFrom for ExtendVote { + type Error = crate::Error; + + fn try_from(message: pb::abci::RequestExtendVote) -> Result { + Ok(Self { + hash: message.hash.try_into()?, + height: message.height.try_into()?, + }) + } + } + + impl Protobuf for ExtendVote {} +} diff --git a/tendermint/src/abci/request/finalize_block.rs b/tendermint/src/abci/request/finalize_block.rs new file mode 100644 index 000000000..9bc829a90 --- /dev/null +++ b/tendermint/src/abci/request/finalize_block.rs @@ -0,0 +1,85 @@ +use crate::prelude::*; +use crate::{ + abci::types::{CommitInfo, Misbehavior}, + account, block, Hash, Time, +}; +use bytes::Bytes; + +#[doc = include_str!("../doc/request-finalizeblock.md")] +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct FinalizeBlock { + /// List of transactions committed as part of the block. + pub txs: Vec, + /// Information about the last commit, obtained from the block that was just decided. + /// + /// This includes the round, the list of validators, and which validators + /// signed the last block. + pub decided_last_commit: CommitInfo, + /// Evidence of validator misbehavior. + pub misbehavior: Vec, + /// Merkle root hash of the fields of the decided block. + pub hash: Hash, + /// The height of the finalized block. + pub height: block::Height, + /// Timestamp of the finalized block. + pub time: Time, + /// Merkle root of the next validator set. + pub next_validators_hash: Hash, + /// The address of the public key of the original proposer of the block. + pub proposer_address: account::Id, +} + +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +mod v0_38 { + use super::FinalizeBlock; + use crate::Error; + use tendermint_proto::v0_38 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::RequestFinalizeBlock { + fn from(value: FinalizeBlock) -> Self { + Self { + txs: value.txs, + decided_last_commit: Some(value.decided_last_commit.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(), + } + } + } + + impl TryFrom for FinalizeBlock { + type Error = Error; + + fn try_from(message: pb::abci::RequestFinalizeBlock) -> Result { + Ok(Self { + txs: message.txs, + decided_last_commit: message + .decided_last_commit + .ok_or_else(Error::missing_last_commit_info)? + .try_into()?, + 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()?, + }) + } + } + + impl Protobuf for FinalizeBlock {} +} diff --git a/tendermint/src/abci/request/info.rs b/tendermint/src/abci/request/info.rs index f9be161b6..abd68dc64 100644 --- a/tendermint/src/abci/request/info.rs +++ b/tendermint/src/abci/request/info.rs @@ -79,3 +79,35 @@ mod v0_37 { impl Protobuf for Info {} } + +mod v0_38 { + use super::Info; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; + + impl From for pb::RequestInfo { + fn from(info: Info) -> Self { + Self { + version: info.version, + block_version: info.block_version, + p2p_version: info.p2p_version, + abci_version: info.abci_version, + } + } + } + + impl TryFrom for Info { + type Error = crate::Error; + + fn try_from(info: pb::RequestInfo) -> Result { + Ok(Self { + version: info.version, + block_version: info.block_version, + p2p_version: info.p2p_version, + abci_version: info.abci_version, + }) + } + } + + impl Protobuf for Info {} +} diff --git a/tendermint/src/abci/request/prepare_proposal.rs b/tendermint/src/abci/request/prepare_proposal.rs index a95dc691e..577b1bb07 100644 --- a/tendermint/src/abci/request/prepare_proposal.rs +++ b/tendermint/src/abci/request/prepare_proposal.rs @@ -1,7 +1,7 @@ use crate::prelude::*; use crate::{ - abci::types::{CommitInfo, Misbehavior}, - account, block, Error, Hash, Time, + abci::types::{ExtendedCommitInfo, Misbehavior}, + account, block, Hash, Time, }; use bytes::Bytes; @@ -14,7 +14,7 @@ pub struct PrepareProposal { /// 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 local_last_commit: Option, pub misbehavior: Vec, pub height: block::Height, pub time: Time, @@ -27,52 +27,106 @@ pub struct PrepareProposal { // Protobuf conversions // ============================================================================= -// The PrepareProposal request has been added in 0.37. +mod v0_37 { + use super::PrepareProposal; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_37::abci as pb; + use tendermint_proto::Protobuf; -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(), + } + } + } + + impl TryFrom for PrepareProposal { + type Error = Error; -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(), + 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 Protobuf for PrepareProposal {} } -impl TryFrom for PrepareProposal { - type Error = Error; +mod v0_38 { + use super::PrepareProposal; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; - 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 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(), + } + } } -} -impl Protobuf for PrepareProposal {} + 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 Protobuf for PrepareProposal {} +} diff --git a/tendermint/src/abci/request/process_proposal.rs b/tendermint/src/abci/request/process_proposal.rs index bb3020048..2eafa2930 100644 --- a/tendermint/src/abci/request/process_proposal.rs +++ b/tendermint/src/abci/request/process_proposal.rs @@ -1,7 +1,7 @@ use crate::prelude::*; use crate::{ abci::types::{CommitInfo, Misbehavior}, - account, block, Error, Hash, Time, + account, block, Hash, Time, }; use bytes::Bytes; @@ -26,52 +26,106 @@ pub struct ProcessProposal { // Protobuf conversions // ============================================================================= -// The ProcessProposal request has been added in 0.37. +mod v0_37 { + use super::ProcessProposal; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_37::abci as pb; + use tendermint_proto::Protobuf; -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(), + } + } + } + + impl TryFrom for ProcessProposal { + type Error = Error; -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(), + 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 Protobuf for ProcessProposal {} } -impl TryFrom for ProcessProposal { - type Error = Error; +mod v0_38 { + use super::ProcessProposal; + use crate::{prelude::*, Error}; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; - 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 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(), + } + } } -} -impl Protobuf for ProcessProposal {} + 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 Protobuf for ProcessProposal {} +} diff --git a/tendermint/src/abci/request/verify_vote_extension.rs b/tendermint/src/abci/request/verify_vote_extension.rs new file mode 100644 index 000000000..031cb3b86 --- /dev/null +++ b/tendermint/src/abci/request/verify_vote_extension.rs @@ -0,0 +1,47 @@ +use crate::{account, block, Hash}; +use bytes::Bytes; + +#[doc = include_str!("../doc/request-verifyvoteextension.md")] +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct VerifyVoteExtension { + pub hash: Hash, + pub validator_address: account::Id, + pub height: block::Height, + pub vote_extension: Bytes, +} + +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +mod v0_38 { + use super::VerifyVoteExtension; + use tendermint_proto::v0_38 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::RequestVerifyVoteExtension { + fn from(value: VerifyVoteExtension) -> Self { + Self { + hash: value.hash.into(), + validator_address: value.validator_address.into(), + height: value.height.into(), + vote_extension: value.vote_extension, + } + } + } + + impl TryFrom for VerifyVoteExtension { + type Error = crate::Error; + + fn try_from(message: pb::abci::RequestVerifyVoteExtension) -> Result { + Ok(Self { + hash: message.hash.try_into()?, + validator_address: message.validator_address.try_into()?, + height: message.height.try_into()?, + vote_extension: message.vote_extension, + }) + } + } + + impl Protobuf for VerifyVoteExtension {} +} diff --git a/tendermint/src/abci/response.rs b/tendermint/src/abci/response.rs index 725de9f7d..cbebc8f99 100644 --- a/tendermint/src/abci/response.rs +++ b/tendermint/src/abci/response.rs @@ -18,7 +18,6 @@ // bring into scope for doc links #[allow(unused)] use super::types::Snapshot; -use crate::prelude::*; mod apply_snapshot_chunk; mod begin_block; @@ -28,6 +27,8 @@ mod deliver_tx; mod echo; mod end_block; mod exception; +mod extend_vote; +mod finalize_block; mod info; mod init_chain; mod list_snapshots; @@ -37,6 +38,7 @@ mod prepare_proposal; mod process_proposal; mod query; mod set_option; +mod verify_vote_extension; pub use apply_snapshot_chunk::{ApplySnapshotChunk, ApplySnapshotChunkResult}; pub use begin_block::BeginBlock; @@ -46,6 +48,8 @@ pub use deliver_tx::DeliverTx; pub use echo::Echo; pub use end_block::EndBlock; pub use exception::Exception; +pub use extend_vote::ExtendVote; +pub use finalize_block::FinalizeBlock; pub use info::Info; pub use init_chain::InitChain; pub use list_snapshots::ListSnapshots; @@ -55,55 +59,4 @@ pub use prepare_proposal::PrepareProposal; pub use process_proposal::ProcessProposal; pub use query::Query; pub use set_option::SetOption; - -/// The consensus category of ABCI responses. -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum ConsensusResponse { - #[doc = include_str!("doc/response-initchain.md")] - InitChain(InitChain), - #[doc = include_str!("doc/response-prepareproposal.md")] - PrepareProposal(PrepareProposal), - #[doc = include_str!("doc/response-processproposal.md")] - ProcessProposal(ProcessProposal), - #[doc = include_str!("doc/response-beginblock.md")] - BeginBlock(BeginBlock), - #[doc = include_str!("doc/response-delivertx.md")] - DeliverTx(DeliverTx), - #[doc = include_str!("doc/response-endblock.md")] - EndBlock(EndBlock), - #[doc = include_str!("doc/response-commit.md")] - Commit(Commit), -} - -/// The mempool category of ABCI responses. -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum MempoolResponse { - #[doc = include_str!("doc/response-checktx.md")] - CheckTx(CheckTx), -} - -/// The info category of ABCI responses. -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum InfoResponse { - #[doc = include_str!("doc/response-echo.md")] - Echo(Echo), - #[doc = include_str!("doc/response-info.md")] - Info(Info), - #[doc = include_str!("doc/response-query.md")] - Query(Query), - #[doc = include_str!("doc/response-setoption.md")] - SetOption(SetOption), -} - -/// The snapshot category of ABCI responses. -#[derive(Clone, PartialEq, Eq, Debug)] -pub enum SnapshotResponse { - #[doc = include_str!("doc/response-listsnapshots.md")] - ListSnapshots(ListSnapshots), - #[doc = include_str!("doc/response-offersnapshot.md")] - OfferSnapshot(OfferSnapshot), - #[doc = include_str!("doc/response-loadsnapshotchunk.md")] - LoadSnapshotChunk(LoadSnapshotChunk), - #[doc = include_str!("doc/response-applysnapshotchunk.md")] - ApplySnapshotChunk(ApplySnapshotChunk), -} +pub use verify_vote_extension::VerifyVoteExtension; diff --git a/tendermint/src/abci/response/begin_block.rs b/tendermint/src/abci/response/begin_block.rs index 8319a116a..bd35e98cb 100644 --- a/tendermint/src/abci/response/begin_block.rs +++ b/tendermint/src/abci/response/begin_block.rs @@ -12,8 +12,40 @@ pub struct BeginBlock { // Protobuf conversions // ============================================================================= -tendermint_pb_modules! { +mod v0_34 { use super::BeginBlock; + use tendermint_proto::v0_34 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::ResponseBeginBlock { + fn from(begin_block: BeginBlock) -> Self { + Self { + events: begin_block.events.into_iter().map(Into::into).collect(), + } + } + } + + impl TryFrom for BeginBlock { + type Error = crate::Error; + + fn try_from(begin_block: pb::abci::ResponseBeginBlock) -> Result { + Ok(Self { + events: begin_block + .events + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } + } + + impl Protobuf for BeginBlock {} +} + +mod v0_37 { + use super::BeginBlock; + use tendermint_proto::v0_37 as pb; + use tendermint_proto::Protobuf; impl From for pb::abci::ResponseBeginBlock { fn from(begin_block: BeginBlock) -> Self { diff --git a/tendermint/src/abci/response/check_tx.rs b/tendermint/src/abci/response/check_tx.rs index 4b7dceccb..f5c117fb7 100644 --- a/tendermint/src/abci/response/check_tx.rs +++ b/tendermint/src/abci/response/check_tx.rs @@ -31,12 +31,11 @@ pub struct CheckTx { pub events: Vec, /// The namespace for the `code`. pub codespace: String, - /// The transaction's sender (e.g. the signer). + /// The transactions's sender. Not used since CometBFT 0.38. pub sender: String, - /// The transaction's priority (for mempool ordering). + /// Priority for the mempool. Not used since CometBFT 0.38. pub priority: i64, - /// mempool_error is set by Tendermint. - /// ABCI applications should not set mempool_error. + /// Error reported for the mempool. Not used since CometBFT 0.38. pub mempool_error: String, } @@ -44,8 +43,10 @@ pub struct CheckTx { // Protobuf conversions // ============================================================================= -tendermint_pb_modules! { +mod v0_34 { use super::CheckTx; + use tendermint_proto::v0_34 as pb; + use tendermint_proto::Protobuf; impl From for pb::abci::ResponseCheckTx { fn from(check_tx: CheckTx) -> Self { @@ -91,3 +92,100 @@ tendermint_pb_modules! { impl Protobuf for CheckTx {} } + +mod v0_37 { + use super::CheckTx; + use tendermint_proto::v0_37 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::ResponseCheckTx { + fn from(check_tx: CheckTx) -> Self { + Self { + code: check_tx.code.into(), + data: check_tx.data, + log: check_tx.log, + info: check_tx.info, + gas_wanted: check_tx.gas_wanted, + gas_used: check_tx.gas_used, + events: check_tx.events.into_iter().map(Into::into).collect(), + codespace: check_tx.codespace, + sender: check_tx.sender, + priority: check_tx.priority, + mempool_error: check_tx.mempool_error, + } + } + } + + impl TryFrom for CheckTx { + type Error = crate::Error; + + fn try_from(check_tx: pb::abci::ResponseCheckTx) -> Result { + Ok(Self { + code: check_tx.code.into(), + data: check_tx.data, + log: check_tx.log, + info: check_tx.info, + gas_wanted: check_tx.gas_wanted, + gas_used: check_tx.gas_used, + events: check_tx + .events + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + codespace: check_tx.codespace, + sender: check_tx.sender, + priority: check_tx.priority, + mempool_error: check_tx.mempool_error, + }) + } + } + + impl Protobuf for CheckTx {} +} + +mod v0_38 { + use super::CheckTx; + use tendermint_proto::v0_38 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::ResponseCheckTx { + fn from(check_tx: CheckTx) -> Self { + Self { + code: check_tx.code.into(), + data: check_tx.data, + log: check_tx.log, + info: check_tx.info, + gas_wanted: check_tx.gas_wanted, + gas_used: check_tx.gas_used, + events: check_tx.events.into_iter().map(Into::into).collect(), + codespace: check_tx.codespace, + } + } + } + + impl TryFrom for CheckTx { + type Error = crate::Error; + + fn try_from(check_tx: pb::abci::ResponseCheckTx) -> Result { + Ok(Self { + code: check_tx.code.into(), + data: check_tx.data, + log: check_tx.log, + info: check_tx.info, + gas_wanted: check_tx.gas_wanted, + gas_used: check_tx.gas_used, + events: check_tx + .events + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + codespace: check_tx.codespace, + sender: Default::default(), + priority: Default::default(), + mempool_error: Default::default(), + }) + } + } + + impl Protobuf for CheckTx {} +} diff --git a/tendermint/src/abci/response/commit.rs b/tendermint/src/abci/response/commit.rs index 30ab4be87..f564e40c3 100644 --- a/tendermint/src/abci/response/commit.rs +++ b/tendermint/src/abci/response/commit.rs @@ -1,14 +1,12 @@ -use bytes::Bytes; - use crate::{block, prelude::*}; +use bytes::Bytes; #[doc = include_str!("../doc/response-commit.md")] #[derive(Clone, PartialEq, Eq, Debug, Default)] pub struct Commit { - /// The Merkle root hash of the application state + /// The Merkle root hash of the application state. /// - /// XXX(hdevalence) - is this different from an app hash? - /// XXX(hdevalence) - rename to app_hash ? + /// This field is ignored since CometBFT 0.38. pub data: Bytes, /// Blocks below this height may be removed. pub retain_height: block::Height, @@ -18,8 +16,10 @@ pub struct Commit { // Protobuf conversions // ============================================================================= -tendermint_pb_modules! { +mod v0_34 { use super::Commit; + use tendermint_proto::v0_34 as pb; + use tendermint_proto::Protobuf; impl From for pb::abci::ResponseCommit { fn from(commit: Commit) -> Self { @@ -43,3 +43,58 @@ tendermint_pb_modules! { impl Protobuf for Commit {} } + +mod v0_37 { + use super::Commit; + use tendermint_proto::v0_37 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::ResponseCommit { + fn from(commit: Commit) -> Self { + Self { + data: commit.data, + retain_height: commit.retain_height.into(), + } + } + } + + impl TryFrom for Commit { + type Error = crate::Error; + + fn try_from(commit: pb::abci::ResponseCommit) -> Result { + Ok(Self { + data: commit.data, + retain_height: commit.retain_height.try_into()?, + }) + } + } + + impl Protobuf for Commit {} +} + +mod v0_38 { + use super::Commit; + use tendermint_proto::v0_38 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::ResponseCommit { + fn from(commit: Commit) -> Self { + Self { + retain_height: commit.retain_height.into(), + } + } + } + + impl TryFrom for Commit { + type Error = crate::Error; + + fn try_from(commit: pb::abci::ResponseCommit) -> Result { + Ok(Self { + retain_height: commit.retain_height.try_into()?, + data: Default::default(), + }) + } + } + + impl Protobuf for Commit {} +} diff --git a/tendermint/src/abci/response/deliver_tx.rs b/tendermint/src/abci/response/deliver_tx.rs index f98f77624..dcefcc9a2 100644 --- a/tendermint/src/abci/response/deliver_tx.rs +++ b/tendermint/src/abci/response/deliver_tx.rs @@ -37,8 +37,54 @@ pub struct DeliverTx { // Protobuf conversions // ============================================================================= -tendermint_pb_modules! { +mod v0_34 { use super::DeliverTx; + use tendermint_proto::v0_34 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::ResponseDeliverTx { + fn from(deliver_tx: DeliverTx) -> Self { + Self { + code: deliver_tx.code.into(), + data: deliver_tx.data, + log: deliver_tx.log, + info: deliver_tx.info, + gas_wanted: deliver_tx.gas_wanted, + gas_used: deliver_tx.gas_used, + events: deliver_tx.events.into_iter().map(Into::into).collect(), + codespace: deliver_tx.codespace, + } + } + } + + impl TryFrom for DeliverTx { + type Error = crate::Error; + + fn try_from(deliver_tx: pb::abci::ResponseDeliverTx) -> Result { + Ok(Self { + code: deliver_tx.code.into(), + data: deliver_tx.data, + log: deliver_tx.log, + info: deliver_tx.info, + gas_wanted: deliver_tx.gas_wanted, + gas_used: deliver_tx.gas_used, + events: deliver_tx + .events + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + codespace: deliver_tx.codespace, + }) + } + } + + impl Protobuf for DeliverTx {} +} + +mod v0_37 { + use super::DeliverTx; + use tendermint_proto::v0_37 as pb; + use tendermint_proto::Protobuf; impl From for pb::abci::ResponseDeliverTx { fn from(deliver_tx: DeliverTx) -> Self { diff --git a/tendermint/src/abci/response/end_block.rs b/tendermint/src/abci/response/end_block.rs index ce2b9950f..044242df1 100644 --- a/tendermint/src/abci/response/end_block.rs +++ b/tendermint/src/abci/response/end_block.rs @@ -18,8 +18,55 @@ pub struct EndBlock { // Protobuf conversions // ============================================================================= -tendermint_pb_modules! { +mod v0_34 { use super::EndBlock; + use tendermint_proto::v0_34 as pb; + use tendermint_proto::Protobuf; + + impl From for pb::abci::ResponseEndBlock { + fn from(end_block: EndBlock) -> Self { + Self { + validator_updates: end_block + .validator_updates + .into_iter() + .map(Into::into) + .collect(), + consensus_param_updates: end_block.consensus_param_updates.map(Into::into), + events: end_block.events.into_iter().map(Into::into).collect(), + } + } + } + + impl TryFrom for EndBlock { + type Error = crate::Error; + + fn try_from(end_block: pb::abci::ResponseEndBlock) -> Result { + Ok(Self { + validator_updates: end_block + .validator_updates + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + consensus_param_updates: end_block + .consensus_param_updates + .map(TryInto::try_into) + .transpose()?, + events: end_block + .events + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } + } + + impl Protobuf for EndBlock {} +} + +mod v0_37 { + use super::EndBlock; + use tendermint_proto::v0_37 as pb; + use tendermint_proto::Protobuf; impl From for pb::abci::ResponseEndBlock { fn from(end_block: EndBlock) -> Self { diff --git a/tendermint/src/abci/response/extend_vote.rs b/tendermint/src/abci/response/extend_vote.rs new file mode 100644 index 000000000..fe2d89139 --- /dev/null +++ b/tendermint/src/abci/response/extend_vote.rs @@ -0,0 +1,37 @@ +use bytes::Bytes; + +#[doc = include_str!("../doc/response-extendvote.md")] +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ExtendVote { + pub vote_extension: Bytes, +} + +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +mod v0_38 { + use super::ExtendVote; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; + + impl From for pb::ResponseExtendVote { + fn from(value: ExtendVote) -> Self { + Self { + vote_extension: value.vote_extension, + } + } + } + + impl TryFrom for ExtendVote { + type Error = crate::Error; + + fn try_from(message: pb::ResponseExtendVote) -> Result { + Ok(Self { + vote_extension: message.vote_extension, + }) + } + } + + impl Protobuf for ExtendVote {} +} diff --git a/tendermint/src/abci/response/finalize_block.rs b/tendermint/src/abci/response/finalize_block.rs new file mode 100644 index 000000000..5984a8705 --- /dev/null +++ b/tendermint/src/abci/response/finalize_block.rs @@ -0,0 +1,76 @@ +use crate::abci::{types::ExecTxResult, Event}; +use crate::prelude::*; +use crate::{consensus, validator, AppHash}; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct FinalizeBlock { + /// Set of block events emitted as part of executing the block + pub events: Vec, + /// The result of executing each transaction including the events + /// the particular transction emitted. This should match the order + /// of the transactions delivered in the block itself + pub tx_results: Vec, + /// A list of updates to the validator set. + /// These will reflect the validator set at current height + 2. + pub validator_updates: Vec, + /// Updates to the consensus params, if any. + pub consensus_param_updates: Option, + pub app_hash: AppHash, +} + +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +mod v0_38 { + use super::FinalizeBlock; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; + + impl From for pb::ResponseFinalizeBlock { + fn from(value: FinalizeBlock) -> Self { + Self { + events: value.events.into_iter().map(Into::into).collect(), + tx_results: value.tx_results.into_iter().map(Into::into).collect(), + validator_updates: value + .validator_updates + .into_iter() + .map(Into::into) + .collect(), + consensus_param_updates: value.consensus_param_updates.map(Into::into), + app_hash: value.app_hash.into(), + } + } + } + + impl TryFrom for FinalizeBlock { + type Error = crate::Error; + + fn try_from(message: pb::ResponseFinalizeBlock) -> Result { + Ok(Self { + events: message + .events + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + tx_results: message + .tx_results + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + validator_updates: message + .validator_updates + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + consensus_param_updates: message + .consensus_param_updates + .map(TryInto::try_into) + .transpose()?, + app_hash: message.app_hash.try_into()?, + }) + } + } + + impl Protobuf for FinalizeBlock {} +} diff --git a/tendermint/src/abci/response/prepare_proposal.rs b/tendermint/src/abci/response/prepare_proposal.rs index d8facfed5..89d277ba8 100644 --- a/tendermint/src/abci/response/prepare_proposal.rs +++ b/tendermint/src/abci/response/prepare_proposal.rs @@ -12,23 +12,46 @@ pub struct PrepareProposal { // Protobuf conversions // ============================================================================= -// PrepareProposal has been introduced in 0.37. +mod v0_37 { + use super::PrepareProposal; + 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 } + } + } -use tendermint_proto::v0_37::abci as pb; -use tendermint_proto::Protobuf; + impl TryFrom for PrepareProposal { + type Error = crate::Error; -impl From for pb::ResponsePrepareProposal { - fn from(value: PrepareProposal) -> Self { - Self { txs: value.txs } + fn try_from(message: pb::ResponsePrepareProposal) -> Result { + Ok(Self { txs: message.txs }) + } } + + impl Protobuf for PrepareProposal {} } -impl TryFrom for PrepareProposal { - type Error = crate::Error; +mod v0_38 { + use super::PrepareProposal; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; - fn try_from(message: pb::ResponsePrepareProposal) -> Result { - Ok(Self { txs: message.txs }) + impl From for pb::ResponsePrepareProposal { + fn from(value: PrepareProposal) -> Self { + Self { txs: value.txs } + } } -} -impl Protobuf for PrepareProposal {} + impl TryFrom for PrepareProposal { + type Error = crate::Error; + + fn try_from(message: pb::ResponsePrepareProposal) -> Result { + Ok(Self { txs: message.txs }) + } + } + + impl Protobuf for PrepareProposal {} +} diff --git a/tendermint/src/abci/response/process_proposal.rs b/tendermint/src/abci/response/process_proposal.rs index 9e3d6d50c..e89d74aad 100644 --- a/tendermint/src/abci/response/process_proposal.rs +++ b/tendermint/src/abci/response/process_proposal.rs @@ -15,72 +15,72 @@ pub enum ProcessProposal { // Protobuf conversions // ============================================================================= -// ProcessProposal has been introduced in 0.37. +mod v0_37 { + use super::ProcessProposal; + use crate::Error; + use tendermint_proto::v0_37::abci as pb; + use tendermint_proto::Protobuf; -use tendermint_proto::v0_37::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) -> Self { + Self { + status: value as i32, + } } } -} -impl TryFrom for ProcessProposal { - type Error = crate::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) - } -} + impl TryFrom for ProcessProposal { + type Error = Error; -impl Protobuf for ProcessProposal {} + fn try_from(message: pb::ResponseProcessProposal) -> Result { + use pb::response_process_proposal::ProposalStatus; -#[cfg(test)] -mod tests { - use super::*; - use crate::error::ErrorDetail; + let status = ProposalStatus::from_i32(message.status) + .ok_or_else(Error::unsupported_process_proposal_status)?; - use std::collections::HashMap; + let value = match status { + ProposalStatus::Unknown => ProcessProposal::Unknown, + ProposalStatus::Accept => ProcessProposal::Accept, + ProposalStatus::Reject => ProcessProposal::Reject, + }; + Ok(value) + } + } - #[test] - fn all_status_values_are_covered() { - use pb::response_process_proposal::ProposalStatus::*; + impl Protobuf for ProcessProposal {} +} - const FIRST_INVALID_STATUS: i32 = 3; +mod v0_38 { + use super::ProcessProposal; + use crate::Error; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; - 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); - }, + impl From for pb::ResponseProcessProposal { + fn from(value: ProcessProposal) -> Self { + Self { + status: value as i32, } } - 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); + } + + impl TryFrom for ProcessProposal { + type Error = Error; + + fn try_from(message: pb::ResponseProcessProposal) -> Result { + use pb::response_process_proposal::ProposalStatus; + + let status = ProposalStatus::from_i32(message.status) + .ok_or_else(Error::unsupported_process_proposal_status)?; + + let value = match status { + ProposalStatus::Unknown => ProcessProposal::Unknown, + ProposalStatus::Accept => ProcessProposal::Accept, + ProposalStatus::Reject => ProcessProposal::Reject, + }; + Ok(value) } - 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/abci/response/verify_vote_extension.rs b/tendermint/src/abci/response/verify_vote_extension.rs new file mode 100644 index 000000000..685d9d317 --- /dev/null +++ b/tendermint/src/abci/response/verify_vote_extension.rs @@ -0,0 +1,47 @@ +#[doc = include_str!("../doc/response-verifyvoteextension.md")] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[repr(i32)] +pub enum VerifyVoteExtension { + Unknown = 0, + Accept = 1, + Reject = 2, +} + +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +mod v0_38 { + use super::VerifyVoteExtension; + use crate::Error; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::Protobuf; + + impl From for pb::ResponseVerifyVoteExtension { + fn from(value: VerifyVoteExtension) -> Self { + Self { + status: value as i32, + } + } + } + + impl TryFrom for VerifyVoteExtension { + type Error = Error; + + fn try_from(message: pb::ResponseVerifyVoteExtension) -> Result { + use pb::response_verify_vote_extension::VerifyStatus; + + let status = VerifyStatus::from_i32(message.status) + .ok_or_else(Error::unsupported_verify_vote_extension_status)?; + + let value = match status { + VerifyStatus::Unknown => VerifyVoteExtension::Unknown, + VerifyStatus::Accept => VerifyVoteExtension::Accept, + VerifyStatus::Reject => VerifyVoteExtension::Reject, + }; + Ok(value) + } + } + + impl Protobuf for VerifyVoteExtension {} +} diff --git a/tendermint/src/abci/types.rs b/tendermint/src/abci/types.rs index f3abf5dca..709a4daaf 100644 --- a/tendermint/src/abci/types.rs +++ b/tendermint/src/abci/types.rs @@ -7,7 +7,12 @@ use bytes::Bytes; -use crate::{block, prelude::*, vote, Time}; +use super::{Code, Event}; +use crate::{ + block::{self, BlockIdFlag}, + prelude::*, + vote, Signature, Time, +}; /// A validator address with voting power. /// @@ -22,13 +27,68 @@ pub struct Validator { /// Information about a whether a validator signed the last block. /// -/// [ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#voteinfo) +/// [ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci%2B%2B_methods.md#voteinfo) #[derive(Clone, PartialEq, Eq, Debug)] pub struct VoteInfo { /// Identifies the validator. pub validator: Validator, /// Whether or not the validator signed the last block. - pub signed_last_block: bool, + pub sig_info: BlockSignatureInfo, +} + +/// Information about a whether a validator signed the last block, +/// together with vote extensions. +/// +/// [ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci%2B%2B_methods.md#extendedvoteinfo) +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct ExtendedVoteInfo { + /// Identifies the validator. + pub validator: Validator, + /// Whether or not the validator signed the last block. + pub sig_info: BlockSignatureInfo, + /// Non-deterministic extension provided by the sending validator's application. + /// + /// This field is only used since CometBFT 0.38. It will be ignored when + /// encoding into earlier protocol versions. + pub vote_extension: Bytes, + /// Signature for the vote extension. + /// + /// This field has been added in CometBFT 0.38 and will be ignored when + /// encoding into earlier protocol versions. + pub extension_signature: Option, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +/// Information on how the validator voted for a block. +pub enum BlockSignatureInfo { + /// Full information available, as determined by the [`BlockIdFlag`] value. + /// + /// In CometBFT versions before 0.38, both [`Commit`] and [`Nil`] values + /// are encoded as the true value of the `signed_last_block` field, + /// losing information on whether the vote was for the block or nil. + /// + /// [`Commit`]: BlockIdFlag::Commit + /// [`Nil`]: BlockIdFlag::Nil + Flag(BlockIdFlag), + /// In the message encoded in a CometBFT version before 0.38, + /// the `signed_last_block` field has the value of true. + /// + /// This variant should not be used in CometBFT 0.38 or later + /// and will result in the "undefined" encoding in protobuf. + LegacySigned, +} + +impl BlockSignatureInfo { + /// Whether the validator has signed the block accordingly to this information. + pub fn is_signed(&self) -> bool { + use BlockIdFlag::*; + + match self { + BlockSignatureInfo::Flag(Commit) | BlockSignatureInfo::Flag(Nil) => true, + BlockSignatureInfo::Flag(Absent) => false, + BlockSignatureInfo::LegacySigned => true, + } + } } /// The possible kinds of [`Misbehavior`]. @@ -75,7 +135,7 @@ pub struct Misbehavior { /// Information on a block commit. /// -/// [ABCI documentation](https://github.com/tendermint/tendermint/blob/main/spec/abci/abci++_methods.md#extendedcommitinfo) +/// [ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci%2B%2B_methods.md#commitinfo) #[derive(Clone, PartialEq, Eq, Debug)] pub struct CommitInfo { /// The commit round. @@ -88,6 +148,21 @@ pub struct CommitInfo { pub votes: Vec, } +/// Information on a block commit with provided vote extensions. +/// +/// [ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci%2B%2B_methods.md#extendedcommitinfo) +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct ExtendedCommitInfo { + /// The commit round. + /// + /// Reflects the total number of rounds it took to come to consensus for the + /// current block. + pub round: block::Round, + /// The list of validator addresses in the last validator set, with their + /// voting power and whether or not they signed a vote. + pub votes: Vec, +} + /// Used for state sync snapshots. /// /// When sent across the network, a `Snapshot` can be at most 4 MB. @@ -114,13 +189,49 @@ pub struct Snapshot { pub metadata: Bytes, } +/// Results of executing one individual transaction. +/// +/// This structure is equivalent to [`response::DeliverTx`] which will be +/// deprecated and removed. +/// +/// [`response::DeliverTx`]: super::response::DeliverTx +#[derive(Clone, PartialEq, Eq, Debug, Default)] +pub struct ExecTxResult { + /// The response code. + /// + /// This code should be `Ok` only if the transaction is fully valid. However, + /// invalid transactions included in a block will still be executed against + /// the application state. + pub code: Code, + /// Result bytes, if any. + pub data: Bytes, + /// The output of the application's logger. + /// + /// **May be non-deterministic**. + pub log: String, + /// Additional information. + /// + /// **May be non-deterministic**. + pub info: String, + /// Amount of gas requested for the transaction. + pub gas_wanted: i64, + /// Amount of gas consumed by the transaction. + pub gas_used: i64, + /// Events that occurred while executing the transaction. + pub events: Vec, + /// The namespace for the `code`. + pub codespace: String, +} + // ============================================================================= // Protobuf conversions // ============================================================================= mod v0_34 { - use super::{CommitInfo, Misbehavior, MisbehaviorKind, Snapshot, Validator, VoteInfo}; - use crate::{prelude::*, Error}; + use super::{ + BlockSignatureInfo, CommitInfo, Misbehavior, MisbehaviorKind, Snapshot, Validator, VoteInfo, + }; + use crate::{block::BlockIdFlag, prelude::*, Error}; use tendermint_proto::v0_34::abci as pb; use tendermint_proto::Protobuf; @@ -160,7 +271,7 @@ mod v0_34 { fn from(vi: VoteInfo) -> Self { Self { validator: Some(vi.validator.into()), - signed_last_block: vi.signed_last_block, + signed_last_block: vi.sig_info.is_signed(), } } } @@ -169,12 +280,17 @@ mod v0_34 { type Error = Error; fn try_from(vi: pb::VoteInfo) -> Result { + let sig_info = if vi.signed_last_block { + BlockSignatureInfo::LegacySigned + } else { + BlockSignatureInfo::Flag(BlockIdFlag::Absent) + }; Ok(Self { validator: vi .validator .ok_or_else(Error::missing_validator)? .try_into()?, - signed_last_block: vi.signed_last_block, + sig_info, }) } } @@ -278,8 +394,11 @@ mod v0_34 { } mod v0_37 { - use super::{CommitInfo, Misbehavior, MisbehaviorKind, Snapshot, Validator, VoteInfo}; - use crate::{prelude::*, Error}; + use super::{ + BlockSignatureInfo, CommitInfo, ExtendedCommitInfo, ExtendedVoteInfo, Misbehavior, + MisbehaviorKind, Snapshot, Validator, VoteInfo, + }; + use crate::{block::BlockIdFlag, prelude::*, Error}; use tendermint_proto::v0_37::abci as pb; use tendermint_proto::Protobuf; @@ -319,7 +438,7 @@ mod v0_37 { fn from(vi: VoteInfo) -> Self { Self { validator: Some(vi.validator.into()), - signed_last_block: vi.signed_last_block, + signed_last_block: vi.sig_info.is_signed(), } } } @@ -328,46 +447,58 @@ mod v0_37 { type Error = Error; fn try_from(vi: pb::VoteInfo) -> Result { + let sig_info = if vi.signed_last_block { + BlockSignatureInfo::LegacySigned + } else { + BlockSignatureInfo::Flag(BlockIdFlag::Absent) + }; Ok(Self { validator: vi .validator .ok_or_else(Error::missing_validator)? .try_into()?, - signed_last_block: vi.signed_last_block, + sig_info, }) } } impl Protobuf for VoteInfo {} - // ExtendedVoteInfo is defined in 0.37, but the vote_extension field is always nil, - // so we can omit it from VoteInfo for the time being. + // ExtendedVoteInfo is defined in 0.37, but the vote_extension field + // should be always nil and is ignored. - impl From for pb::ExtendedVoteInfo { - fn from(vi: VoteInfo) -> Self { + impl From for pb::ExtendedVoteInfo { + fn from(vi: ExtendedVoteInfo) -> Self { Self { validator: Some(vi.validator.into()), - signed_last_block: vi.signed_last_block, + signed_last_block: vi.sig_info.is_signed(), vote_extension: Default::default(), } } } - impl TryFrom for VoteInfo { + impl TryFrom for ExtendedVoteInfo { type Error = Error; fn try_from(vi: pb::ExtendedVoteInfo) -> Result { + let sig_info = if vi.signed_last_block { + BlockSignatureInfo::LegacySigned + } else { + BlockSignatureInfo::Flag(BlockIdFlag::Absent) + }; Ok(Self { validator: vi .validator .ok_or_else(Error::missing_validator)? .try_into()?, - signed_last_block: vi.signed_last_block, + sig_info, + vote_extension: Default::default(), + extension_signature: None, }) } } - impl Protobuf for VoteInfo {} + impl Protobuf for ExtendedVoteInfo {} impl From for pb::Misbehavior { fn from(evidence: Misbehavior) -> Self { @@ -410,9 +541,6 @@ mod v0_37 { impl Protobuf for Misbehavior {} - // The CommitInfo domain type represents both CommitInfo and ExtendedCommitInfo - // as defined in protobuf for 0.37. - impl From for pb::CommitInfo { fn from(lci: CommitInfo) -> Self { Self { @@ -439,7 +567,217 @@ mod v0_37 { impl Protobuf for CommitInfo {} - impl From for pb::ExtendedCommitInfo { + impl From for pb::ExtendedCommitInfo { + fn from(lci: ExtendedCommitInfo) -> Self { + Self { + round: lci.round.into(), + votes: lci.votes.into_iter().map(Into::into).collect(), + } + } + } + + impl TryFrom for ExtendedCommitInfo { + type Error = Error; + + fn try_from(lci: pb::ExtendedCommitInfo) -> Result { + Ok(Self { + round: lci.round.try_into()?, + votes: lci + .votes + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } + } + + impl Protobuf for ExtendedCommitInfo {} + + impl From for pb::Snapshot { + fn from(snapshot: Snapshot) -> Self { + Self { + height: snapshot.height.into(), + format: snapshot.format, + chunks: snapshot.chunks, + hash: snapshot.hash, + metadata: snapshot.metadata, + } + } + } + + impl TryFrom for Snapshot { + type Error = Error; + + fn try_from(snapshot: pb::Snapshot) -> Result { + Ok(Self { + height: snapshot.height.try_into()?, + format: snapshot.format, + chunks: snapshot.chunks, + hash: snapshot.hash, + metadata: snapshot.metadata, + }) + } + } + + impl Protobuf for Snapshot {} +} + +mod v0_38 { + use super::{ + BlockSignatureInfo, CommitInfo, ExecTxResult, ExtendedCommitInfo, ExtendedVoteInfo, + Misbehavior, MisbehaviorKind, Snapshot, Validator, VoteInfo, + }; + use crate::{prelude::*, Error, Signature}; + use tendermint_proto::v0_38::abci as pb; + use tendermint_proto::v0_38::types::BlockIdFlag as RawBlockIdFlag; + use tendermint_proto::Protobuf; + + use bytes::Bytes; + + impl From for pb::Validator { + fn from(v: Validator) -> Self { + Self { + address: Bytes::copy_from_slice(&v.address[..]), + power: v.power.into(), + } + } + } + + impl TryFrom for Validator { + type Error = Error; + + fn try_from(vu: pb::Validator) -> Result { + let address = if vu.address.len() == 20 { + let mut bytes = [0u8; 20]; + bytes.copy_from_slice(&vu.address); + bytes + } else { + return Err(Error::invalid_account_id_length()); + }; + + Ok(Self { + address, + power: vu.power.try_into()?, + }) + } + } + + impl Protobuf for Validator {} + + impl From for RawBlockIdFlag { + fn from(value: BlockSignatureInfo) -> Self { + // The API user should not use the LegacySigned flag in + // values for 0.38-based chains. As this conversion is infallible, + // silently convert it to the undefined value. + match value { + BlockSignatureInfo::Flag(flag) => flag.into(), + BlockSignatureInfo::LegacySigned => RawBlockIdFlag::Unknown, + } + } + } + + impl From for pb::VoteInfo { + fn from(vi: VoteInfo) -> Self { + let block_id_flag: RawBlockIdFlag = vi.sig_info.into(); + Self { + validator: Some(vi.validator.into()), + block_id_flag: block_id_flag as i32, + } + } + } + + impl TryFrom for VoteInfo { + type Error = Error; + + fn try_from(vi: pb::VoteInfo) -> Result { + let block_id_flag = + RawBlockIdFlag::from_i32(vi.block_id_flag).ok_or_else(Error::block_id_flag)?; + Ok(Self { + validator: vi + .validator + .ok_or_else(Error::missing_validator)? + .try_into()?, + sig_info: BlockSignatureInfo::Flag(block_id_flag.try_into()?), + }) + } + } + + impl Protobuf for VoteInfo {} + + impl From for pb::ExtendedVoteInfo { + fn from(vi: ExtendedVoteInfo) -> Self { + let block_id_flag: RawBlockIdFlag = vi.sig_info.into(); + Self { + validator: Some(vi.validator.into()), + vote_extension: vi.vote_extension, + extension_signature: vi.extension_signature.map(Into::into).unwrap_or_default(), + block_id_flag: block_id_flag as i32, + } + } + } + + impl TryFrom for ExtendedVoteInfo { + type Error = Error; + + fn try_from(vi: pb::ExtendedVoteInfo) -> Result { + let block_id_flag = + RawBlockIdFlag::from_i32(vi.block_id_flag).ok_or_else(Error::block_id_flag)?; + Ok(Self { + validator: vi + .validator + .ok_or_else(Error::missing_validator)? + .try_into()?, + sig_info: BlockSignatureInfo::Flag(block_id_flag.try_into()?), + vote_extension: vi.vote_extension, + extension_signature: Signature::new(vi.extension_signature)?, + }) + } + } + + impl Protobuf for ExtendedVoteInfo {} + + impl From for pb::Misbehavior { + fn from(evidence: Misbehavior) -> Self { + Self { + r#type: evidence.kind as i32, + validator: Some(evidence.validator.into()), + height: evidence.height.into(), + time: Some(evidence.time.into()), + total_voting_power: evidence.total_voting_power.into(), + } + } + } + + impl TryFrom for Misbehavior { + type Error = Error; + + fn try_from(evidence: pb::Misbehavior) -> Result { + let kind = match evidence.r#type { + 0 => MisbehaviorKind::Unknown, + 1 => MisbehaviorKind::DuplicateVote, + 2 => MisbehaviorKind::LightClientAttack, + _ => return Err(Error::invalid_evidence()), + }; + + Ok(Self { + kind, + validator: evidence + .validator + .ok_or_else(Error::missing_validator)? + .try_into()?, + height: evidence.height.try_into()?, + time: evidence + .time + .ok_or_else(Error::missing_timestamp)? + .try_into()?, + total_voting_power: evidence.total_voting_power.try_into()?, + }) + } + } + + impl Protobuf for Misbehavior {} + + impl From for pb::CommitInfo { fn from(lci: CommitInfo) -> Self { Self { round: lci.round.into(), @@ -448,7 +786,33 @@ mod v0_37 { } } - impl TryFrom for CommitInfo { + impl TryFrom for CommitInfo { + type Error = Error; + + fn try_from(lci: pb::CommitInfo) -> Result { + Ok(Self { + round: lci.round.try_into()?, + votes: lci + .votes + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + }) + } + } + + impl Protobuf for CommitInfo {} + + impl From for pb::ExtendedCommitInfo { + fn from(lci: ExtendedCommitInfo) -> Self { + Self { + round: lci.round.into(), + votes: lci.votes.into_iter().map(Into::into).collect(), + } + } + } + + impl TryFrom for ExtendedCommitInfo { type Error = Error; fn try_from(lci: pb::ExtendedCommitInfo) -> Result { @@ -463,7 +827,7 @@ mod v0_37 { } } - impl Protobuf for CommitInfo {} + impl Protobuf for ExtendedCommitInfo {} impl From for pb::Snapshot { fn from(snapshot: Snapshot) -> Self { @@ -492,4 +856,42 @@ mod v0_37 { } impl Protobuf for Snapshot {} + + impl From for pb::ExecTxResult { + fn from(deliver_tx: ExecTxResult) -> Self { + Self { + code: deliver_tx.code.into(), + data: deliver_tx.data, + log: deliver_tx.log, + info: deliver_tx.info, + gas_wanted: deliver_tx.gas_wanted, + gas_used: deliver_tx.gas_used, + events: deliver_tx.events.into_iter().map(Into::into).collect(), + codespace: deliver_tx.codespace, + } + } + } + + impl TryFrom for ExecTxResult { + type Error = Error; + + fn try_from(deliver_tx: pb::ExecTxResult) -> Result { + Ok(Self { + code: deliver_tx.code.into(), + data: deliver_tx.data, + log: deliver_tx.log, + info: deliver_tx.info, + gas_wanted: deliver_tx.gas_wanted, + gas_used: deliver_tx.gas_used, + events: deliver_tx + .events + .into_iter() + .map(TryInto::try_into) + .collect::>()?, + codespace: deliver_tx.codespace, + }) + } + } + + impl Protobuf for ExecTxResult {} } diff --git a/tendermint/src/block.rs b/tendermint/src/block.rs index 2898d7a79..6ad8d6e07 100644 --- a/tendermint/src/block.rs +++ b/tendermint/src/block.rs @@ -1,5 +1,6 @@ //! Blocks within the chains of a Tendermint network +mod block_id_flag; mod commit; pub mod commit_sig; pub mod header; @@ -15,6 +16,7 @@ use serde::{Deserialize, Serialize}; use tendermint_proto::v0_37::types::Block as RawBlock; pub use self::{ + block_id_flag::BlockIdFlag, commit::*, commit_sig::*, header::Header, diff --git a/tendermint/src/block/block_id_flag.rs b/tendermint/src/block/block_id_flag.rs new file mode 100644 index 000000000..b97b6a78a --- /dev/null +++ b/tendermint/src/block/block_id_flag.rs @@ -0,0 +1,38 @@ +/// Indicates whether the validator voted for a block, nil, or did not vote at all +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum BlockIdFlag { + /// The vote was not received. + Absent, + /// Voted for a block. + Commit, + /// Voted for nil. + Nil, +} + +tendermint_pb_modules! { + use super::BlockIdFlag; + use crate::{error::Error, prelude::*}; + use pb::types::BlockIdFlag as RawBlockIdFlag; + + impl TryFrom for BlockIdFlag { + type Error = Error; + + fn try_from(value: RawBlockIdFlag) -> Result { + match value { + RawBlockIdFlag::Absent => Ok(BlockIdFlag::Absent), + RawBlockIdFlag::Commit => Ok(BlockIdFlag::Commit), + RawBlockIdFlag::Nil => Ok(BlockIdFlag::Nil), + _ => Err(Error::block_id_flag()), } + } + } + + impl From for RawBlockIdFlag { + fn from(value: BlockIdFlag) -> RawBlockIdFlag { + match value { + BlockIdFlag::Absent => RawBlockIdFlag::Absent, + BlockIdFlag::Commit => RawBlockIdFlag::Commit, + BlockIdFlag::Nil => RawBlockIdFlag::Nil, + } + } + } +} diff --git a/tendermint/src/block/commit_sig.rs b/tendermint/src/block/commit_sig.rs index 39c71cc1c..4e85cd77b 100644 --- a/tendermint/src/block/commit_sig.rs +++ b/tendermint/src/block/commit_sig.rs @@ -151,7 +151,7 @@ tendermint_pb_modules! { block_id_flag: BlockIdFlag::Nil.to_i32().unwrap(), validator_address: validator_address.into(), timestamp: Some(timestamp.into()), - signature: signature.map(|s| s.to_bytes()).unwrap_or_default(), + signature: signature.map(|s| s.into_bytes()).unwrap_or_default(), }, CommitSig::BlockIdFlagCommit { validator_address, @@ -161,7 +161,7 @@ tendermint_pb_modules! { block_id_flag: BlockIdFlag::Commit.to_i32().unwrap(), validator_address: validator_address.into(), timestamp: Some(timestamp.into()), - signature: signature.map(|s| s.to_bytes()).unwrap_or_default(), + signature: signature.map(|s| s.into_bytes()).unwrap_or_default(), }, } } diff --git a/tendermint/src/block/size.rs b/tendermint/src/block/size.rs index 52204eec5..4df3f4bae 100644 --- a/tendermint/src/block/size.rs +++ b/tendermint/src/block/size.rs @@ -124,3 +124,37 @@ mod v0_37 { } } } + +mod v0_38 { + use super::Size; + use crate::error::Error; + use tendermint_proto::v0_38::types::BlockParams as RawSize; + use tendermint_proto::Protobuf; + + impl Protobuf for Size {} + + impl TryFrom for Size { + type Error = Error; + + fn try_from(value: RawSize) -> Result { + Ok(Self { + max_bytes: value + .max_bytes + .try_into() + .map_err(Error::integer_overflow)?, + max_gas: value.max_gas, + time_iota_ms: Size::default_time_iota_ms(), + }) + } + } + + impl From for RawSize { + fn from(value: Size) -> Self { + // Todo: make the struct more robust so this can become infallible. + RawSize { + max_bytes: value.max_bytes as i64, + max_gas: value.max_gas, + } + } + } +} diff --git a/tendermint/src/consensus/params.rs b/tendermint/src/consensus/params.rs index ac6295c60..ea1a1e19d 100644 --- a/tendermint/src/consensus/params.rs +++ b/tendermint/src/consensus/params.rs @@ -18,6 +18,12 @@ pub struct Params { /// The ABCI application version. #[serde(skip)] // FIXME: kvstore /genesis returns '{}' instead of '{app_version: "0"}' pub version: Option, + /// Parameters specific to the Application Blockchain Interface. + /// + /// This field has been added in CometBFT 0.38 and will be ignored when + /// encoding into earlier protocol versions. + #[serde(default)] + pub abci: AbciParams, } /// ValidatorParams restrict the public key types validators can use. @@ -39,6 +45,18 @@ pub struct VersionParams { pub app: u64, } +/// Parameters specific to the Application Blockchain Interface. +#[derive(Clone, Serialize, Deserialize, Debug, Eq, PartialEq, Default)] +pub struct AbciParams { + /// Configures the first height during which + /// vote extensions will be enabled. During this specified height, and for all + /// subsequent heights, precommit messages that do not contain valid extension data + /// will be considered invalid. Prior to this height, vote extensions will not + /// be used or accepted by validators on the network. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub vote_extensions_enable_height: Option, +} + // ============================================================================= // Protobuf conversions // ============================================================================= @@ -56,7 +74,7 @@ fn key_type(s: &str) -> public_key::Algorithm { mod v0_34 { use tendermint_proto::v0_34::{ - abci::ConsensusParams as RawAbciParams, + abci::ConsensusParams as RawAbciConsensusParams, types::{ ConsensusParams as RawParams, ValidatorParams as RawValidatorParams, VersionParams as RawVersionParams, @@ -87,6 +105,7 @@ mod v0_34 { .ok_or_else(Error::invalid_validator_params)? .try_into()?, version: value.version.map(TryFrom::try_from).transpose()?, + abci: Default::default(), }) } } @@ -102,12 +121,12 @@ mod v0_34 { } } - impl Protobuf for Params {} + impl Protobuf for Params {} - impl TryFrom for Params { + impl TryFrom for Params { type Error = Error; - fn try_from(value: RawAbciParams) -> Result { + fn try_from(value: RawAbciConsensusParams) -> Result { Ok(Self { block: value .block @@ -122,13 +141,14 @@ mod v0_34 { .ok_or_else(Error::invalid_validator_params)? .try_into()?, version: value.version.map(TryFrom::try_from).transpose()?, + abci: Default::default(), }) } } - impl From for RawAbciParams { + impl From for RawAbciConsensusParams { fn from(value: Params) -> Self { - RawAbciParams { + RawAbciConsensusParams { block: Some(value.block.into()), evidence: Some(value.evidence.into()), validator: Some(value.validator.into()), @@ -215,6 +235,7 @@ mod v0_37 { .ok_or_else(Error::invalid_validator_params)? .try_into()?, version: value.version.map(TryFrom::try_from).transpose()?, + abci: Default::default(), }) } } @@ -273,3 +294,124 @@ mod v0_37 { } } } + +mod v0_38 { + use tendermint_proto::v0_38::types::{ + AbciParams as RawAbciParams, ConsensusParams as RawParams, + ValidatorParams as RawValidatorParams, VersionParams as RawVersionParams, + }; + use tendermint_proto::Protobuf; + + use super::{key_type, AbciParams, Params, ValidatorParams, VersionParams}; + use crate::{error::Error, prelude::*, public_key}; + + impl Protobuf for Params {} + + impl TryFrom for Params { + type Error = Error; + + fn try_from(value: RawParams) -> Result { + Ok(Self { + block: value + .block + .ok_or_else(|| Error::invalid_block("missing block".to_string()))? + .try_into()?, + evidence: value + .evidence + .ok_or_else(Error::invalid_evidence)? + .try_into()?, + validator: value + .validator + .ok_or_else(Error::invalid_validator_params)? + .try_into()?, + version: value.version.map(TryFrom::try_from).transpose()?, + abci: value + .abci + .map(TryFrom::try_from) + .transpose()? + .unwrap_or_default(), + }) + } + } + + impl From for RawParams { + fn from(value: Params) -> Self { + RawParams { + block: Some(value.block.into()), + evidence: Some(value.evidence.into()), + validator: Some(value.validator.into()), + version: value.version.map(From::from), + abci: Some(value.abci.into()), + } + } + } + + impl Protobuf for ValidatorParams {} + + impl TryFrom for ValidatorParams { + type Error = Error; + + fn try_from(value: RawValidatorParams) -> Result { + Ok(Self { + pub_key_types: value.pub_key_types.iter().map(|f| key_type(f)).collect(), + }) + } + } + + impl From for RawValidatorParams { + fn from(value: ValidatorParams) -> Self { + RawValidatorParams { + pub_key_types: value + .pub_key_types + .into_iter() + .map(|k| match k { + public_key::Algorithm::Ed25519 => "ed25519".to_string(), + public_key::Algorithm::Secp256k1 => "secp256k1".to_string(), + }) + .collect(), + } + } + } + + impl Protobuf for VersionParams {} + + impl TryFrom for VersionParams { + type Error = Error; + + fn try_from(value: RawVersionParams) -> Result { + Ok(Self { app: value.app }) + } + } + + impl From for RawVersionParams { + fn from(value: VersionParams) -> Self { + RawVersionParams { app: value.app } + } + } + + impl Protobuf for AbciParams {} + + impl TryFrom for AbciParams { + type Error = Error; + + fn try_from(message: RawAbciParams) -> Result { + let vote_extensions_enable_height = match message.vote_extensions_enable_height { + 0 => None, + h => Some(h.try_into()?), + }; + Ok(Self { + vote_extensions_enable_height, + }) + } + } + + impl From for RawAbciParams { + fn from(value: AbciParams) -> Self { + Self { + vote_extensions_enable_height: value + .vote_extensions_enable_height + .map_or(0, Into::into), + } + } + } +} diff --git a/tendermint/src/error.rs b/tendermint/src/error.rs index 56abab5d9..6ee216c9a 100644 --- a/tendermint/src/error.rs +++ b/tendermint/src/error.rs @@ -191,6 +191,9 @@ define_error! { UnsupportedProcessProposalStatus |_| { format_args!("unsupported ProcessProposal status value" ) }, + UnsupportedVerifyVoteExtensionStatus + |_| { format_args!("unsupported VerifyVoteExtension status value" ) }, + NegativeMaxAgeNum [ DisplayOnly ] |_| { format_args!("negative max_age_num_blocks") }, diff --git a/tendermint/src/lib.rs b/tendermint/src/lib.rs index edc358010..96315820f 100644 --- a/tendermint/src/lib.rs +++ b/tendermint/src/lib.rs @@ -58,6 +58,7 @@ pub mod vote; pub mod v0_34; pub mod v0_37; +pub mod v0_38; #[cfg(test)] mod test; diff --git a/tendermint/src/proposal.rs b/tendermint/src/proposal.rs index 10c832b5a..275facacf 100644 --- a/tendermint/src/proposal.rs +++ b/tendermint/src/proposal.rs @@ -77,7 +77,7 @@ tendermint_pb_modules! { pol_round: value.pol_round.map_or(-1, Into::into), block_id: value.block_id.map(Into::into), timestamp: value.timestamp.map(Into::into), - signature: value.signature.map(|s| s.to_bytes()).unwrap_or_default(), + signature: value.signature.map(|s| s.into_bytes()).unwrap_or_default(), } } } diff --git a/tendermint/src/proto_macros.rs b/tendermint/src/proto_macros.rs index 49948a02b..2fdc8beee 100644 --- a/tendermint/src/proto_macros.rs +++ b/tendermint/src/proto_macros.rs @@ -16,6 +16,13 @@ macro_rules! tendermint_pb_modules { #[allow(unused_imports)] use tendermint_proto::Protobuf; + $($contents)* + } + mod v0_38 { + use tendermint_proto::v0_38 as pb; + #[allow(unused_imports)] + use tendermint_proto::Protobuf; + $($contents)* } }; diff --git a/tendermint/src/signature.rs b/tendermint/src/signature.rs index e95b0a892..6c70afad3 100644 --- a/tendermint/src/signature.rs +++ b/tendermint/src/signature.rs @@ -4,6 +4,8 @@ pub use ed25519::Signature as Ed25519Signature; #[cfg(feature = "secp256k1")] pub use k256::ecdsa::Signature as Secp256k1Signature; +use bytes::Bytes; + use tendermint_proto::Protobuf; use crate::{error::Error, prelude::*}; @@ -39,6 +41,20 @@ impl From for Vec { } } +impl TryFrom for Signature { + type Error = Error; + + fn try_from(bytes: Bytes) -> Result { + Self::new_non_empty(bytes) + } +} + +impl From for Bytes { + fn from(value: Signature) -> Self { + value.0.into() + } +} + impl Signature { /// Create a new signature from the given byte array, if non-empty. /// @@ -69,7 +85,7 @@ impl Signature { } /// Return the underlying byte array - pub fn to_bytes(self) -> Vec { + pub fn into_bytes(self) -> Vec { self.0 } } diff --git a/tendermint/src/v0_34/abci.rs b/tendermint/src/v0_34/abci.rs index 601e534df..02bb3b6fb 100644 --- a/tendermint/src/v0_34/abci.rs +++ b/tendermint/src/v0_34/abci.rs @@ -1,5 +1,5 @@ pub mod request; pub mod response; -pub use request::Request; -pub use response::Response; +pub use request::{ConsensusRequest, InfoRequest, MempoolRequest, Request, SnapshotRequest}; +pub use response::{ConsensusResponse, InfoResponse, MempoolResponse, Response, SnapshotResponse}; diff --git a/tendermint/src/v0_34/abci/request.rs b/tendermint/src/v0_34/abci/request.rs index 6199750b8..090361789 100644 --- a/tendermint/src/v0_34/abci/request.rs +++ b/tendermint/src/v0_34/abci/request.rs @@ -1,7 +1,6 @@ use tendermint_proto::v0_34::abci as pb; use tendermint_proto::Protobuf; -use crate::abci::request::{ConsensusRequest, InfoRequest, MempoolRequest, SnapshotRequest}; use crate::abci::MethodKind; use crate::Error; @@ -10,7 +9,7 @@ pub use crate::abci::request::{ InitChain, LoadSnapshotChunk, OfferSnapshot, Query, SetOption, }; -/// All possible ABCI requests. +/// All possible ABCI requests in CometBFT 0.34. #[allow(clippy::large_enum_variant)] #[derive(Clone, PartialEq, Eq, Debug)] pub enum Request { @@ -46,6 +45,55 @@ pub enum Request { ApplySnapshotChunk(ApplySnapshotChunk), } +/// The consensus category of ABCI requests. +#[allow(clippy::large_enum_variant)] +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum ConsensusRequest { + #[doc = include_str!("../../abci/doc/request-initchain.md")] + InitChain(InitChain), + #[doc = include_str!("../../abci/doc/request-beginblock.md")] + BeginBlock(BeginBlock), + #[doc = include_str!("../../abci/doc/request-delivertx.md")] + DeliverTx(DeliverTx), + #[doc = include_str!("../../abci/doc/request-endblock.md")] + EndBlock(EndBlock), + #[doc = include_str!("../../abci/doc/request-commit.md")] + Commit, +} + +/// The mempool category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum MempoolRequest { + #[doc = include_str!("../../abci/doc/request-checktx.md")] + CheckTx(CheckTx), +} + +/// The info category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum InfoRequest { + #[doc = include_str!("../../abci/doc/request-info.md")] + Info(Info), + #[doc = include_str!("../../abci/doc/request-query.md")] + Query(Query), + #[doc = include_str!("../../abci/doc/request-echo.md")] + Echo(Echo), + #[doc = include_str!("../../abci/doc/request-setoption.md")] + SetOption(SetOption), +} + +/// The snapshot category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum SnapshotRequest { + #[doc = include_str!("../../abci/doc/request-listsnapshots.md")] + ListSnapshots, + #[doc = include_str!("../../abci/doc/request-offersnapshot.md")] + OfferSnapshot(OfferSnapshot), + #[doc = include_str!("../../abci/doc/request-loadsnapshotchunk.md")] + LoadSnapshotChunk(LoadSnapshotChunk), + #[doc = include_str!("../../abci/doc/request-applysnapshotchunk.md")] + ApplySnapshotChunk(ApplySnapshotChunk), +} + impl Request { /// Get the method kind for this request. pub fn kind(&self) -> MethodKind { @@ -74,12 +122,6 @@ impl From for Request { fn from(req: ConsensusRequest) -> Self { match req { ConsensusRequest::InitChain(x) => Self::InitChain(x), - ConsensusRequest::PrepareProposal(_) => { - panic!("Cannot convert PrepareProposal into a v0.34 Request") - }, - ConsensusRequest::ProcessProposal(_) => { - panic!("Cannot convert ProcessProposal into a v0.34 Request") - }, ConsensusRequest::BeginBlock(x) => Self::BeginBlock(x), ConsensusRequest::DeliverTx(x) => Self::DeliverTx(x), ConsensusRequest::EndBlock(x) => Self::EndBlock(x), diff --git a/tendermint/src/v0_34/abci/response.rs b/tendermint/src/v0_34/abci/response.rs index 3ab12b894..aef9fb5e1 100644 --- a/tendermint/src/v0_34/abci/response.rs +++ b/tendermint/src/v0_34/abci/response.rs @@ -2,7 +2,6 @@ pub use crate::abci::response::{ ApplySnapshotChunk, BeginBlock, CheckTx, Commit, DeliverTx, Echo, EndBlock, Exception, Info, InitChain, ListSnapshots, LoadSnapshotChunk, OfferSnapshot, Query, SetOption, }; -use crate::abci::response::{ConsensusResponse, InfoResponse, MempoolResponse, SnapshotResponse}; use crate::Error; /// All possible ABCI responses for this protocol version. @@ -42,16 +41,58 @@ pub enum Response { ApplySnapshotChunk(ApplySnapshotChunk), } +/// The consensus category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum ConsensusResponse { + #[doc = include_str!("../../abci/doc/response-initchain.md")] + InitChain(InitChain), + #[doc = include_str!("../../abci/doc/response-beginblock.md")] + BeginBlock(BeginBlock), + #[doc = include_str!("../../abci/doc/response-delivertx.md")] + DeliverTx(DeliverTx), + #[doc = include_str!("../../abci/doc/response-endblock.md")] + EndBlock(EndBlock), + #[doc = include_str!("../../abci/doc/response-commit.md")] + Commit(Commit), +} + +/// The mempool category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum MempoolResponse { + #[doc = include_str!("../../abci/doc/response-checktx.md")] + CheckTx(CheckTx), +} + +/// The info category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum InfoResponse { + #[doc = include_str!("../../abci/doc/response-echo.md")] + Echo(Echo), + #[doc = include_str!("../../abci/doc/response-info.md")] + Info(Info), + #[doc = include_str!("../../abci/doc/response-query.md")] + Query(Query), + #[doc = include_str!("../../abci/doc/response-setoption.md")] + SetOption(SetOption), +} + +/// The snapshot category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum SnapshotResponse { + #[doc = include_str!("../../abci/doc/response-listsnapshots.md")] + ListSnapshots(ListSnapshots), + #[doc = include_str!("../../abci/doc/response-offersnapshot.md")] + OfferSnapshot(OfferSnapshot), + #[doc = include_str!("../../abci/doc/response-loadsnapshotchunk.md")] + LoadSnapshotChunk(LoadSnapshotChunk), + #[doc = include_str!("../../abci/doc/response-applysnapshotchunk.md")] + ApplySnapshotChunk(ApplySnapshotChunk), +} + impl From for Response { fn from(req: ConsensusResponse) -> Self { match req { ConsensusResponse::InitChain(x) => Self::InitChain(x), - ConsensusResponse::PrepareProposal(_) => { - panic!("Cannot convert PrepareProposal into a v0.34 Response") - }, - ConsensusResponse::ProcessProposal(_) => { - panic!("Cannot convert ProcessProposal into a v0.34 Response") - }, ConsensusResponse::BeginBlock(x) => Self::BeginBlock(x), ConsensusResponse::DeliverTx(x) => Self::DeliverTx(x), ConsensusResponse::EndBlock(x) => Self::EndBlock(x), diff --git a/tendermint/src/v0_37/abci.rs b/tendermint/src/v0_37/abci.rs index 601e534df..02bb3b6fb 100644 --- a/tendermint/src/v0_37/abci.rs +++ b/tendermint/src/v0_37/abci.rs @@ -1,5 +1,5 @@ pub mod request; pub mod response; -pub use request::Request; -pub use response::Response; +pub use request::{ConsensusRequest, InfoRequest, MempoolRequest, Request, SnapshotRequest}; +pub use response::{ConsensusResponse, InfoResponse, MempoolResponse, Response, SnapshotResponse}; diff --git a/tendermint/src/v0_37/abci/request.rs b/tendermint/src/v0_37/abci/request.rs index fce4d19c8..036889cf6 100644 --- a/tendermint/src/v0_37/abci/request.rs +++ b/tendermint/src/v0_37/abci/request.rs @@ -1,7 +1,6 @@ use tendermint_proto::v0_37::abci as pb; use tendermint_proto::Protobuf; -use crate::abci::request::{ConsensusRequest, InfoRequest, MempoolRequest, SnapshotRequest}; use crate::abci::MethodKind; use crate::Error; @@ -10,7 +9,7 @@ pub use crate::abci::request::{ InitChain, LoadSnapshotChunk, OfferSnapshot, PrepareProposal, ProcessProposal, Query, }; -/// All possible ABCI requests. +/// All possible ABCI requests in CometBFT 0.37. #[allow(clippy::large_enum_variant)] #[derive(Clone, PartialEq, Eq, Debug)] pub enum Request { @@ -48,6 +47,57 @@ pub enum Request { ProcessProposal(ProcessProposal), } +/// The consensus category of ABCI requests. +#[allow(clippy::large_enum_variant)] +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum ConsensusRequest { + #[doc = include_str!("../../abci/doc/request-initchain.md")] + InitChain(InitChain), + #[doc = include_str!("../../abci/doc/request-prepareproposal.md")] + PrepareProposal(PrepareProposal), + #[doc = include_str!("../../abci/doc/request-processproposal.md")] + ProcessProposal(ProcessProposal), + #[doc = include_str!("../../abci/doc/request-beginblock.md")] + BeginBlock(BeginBlock), + #[doc = include_str!("../../abci/doc/request-delivertx.md")] + DeliverTx(DeliverTx), + #[doc = include_str!("../../abci/doc/request-endblock.md")] + EndBlock(EndBlock), + #[doc = include_str!("../../abci/doc/request-commit.md")] + Commit, +} + +/// The mempool category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum MempoolRequest { + #[doc = include_str!("../../abci/doc/request-checktx.md")] + CheckTx(CheckTx), +} + +/// The info category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum InfoRequest { + #[doc = include_str!("../../abci/doc/request-info.md")] + Info(Info), + #[doc = include_str!("../../abci/doc/request-query.md")] + Query(Query), + #[doc = include_str!("../../abci/doc/request-echo.md")] + Echo(Echo), +} + +/// The snapshot category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum SnapshotRequest { + #[doc = include_str!("../../abci/doc/request-listsnapshots.md")] + ListSnapshots, + #[doc = include_str!("../../abci/doc/request-offersnapshot.md")] + OfferSnapshot(OfferSnapshot), + #[doc = include_str!("../../abci/doc/request-loadsnapshotchunk.md")] + LoadSnapshotChunk(LoadSnapshotChunk), + #[doc = include_str!("../../abci/doc/request-applysnapshotchunk.md")] + ApplySnapshotChunk(ApplySnapshotChunk), +} + impl Request { /// Get the method kind for this request. pub fn kind(&self) -> MethodKind { @@ -127,7 +177,6 @@ impl From for Request { InfoRequest::Info(x) => Self::Info(x), InfoRequest::Query(x) => Self::Query(x), InfoRequest::Echo(x) => Self::Echo(x), - InfoRequest::SetOption(_) => panic!("cannot be used with v0.37"), } } } diff --git a/tendermint/src/v0_37/abci/response.rs b/tendermint/src/v0_37/abci/response.rs index 831f2783c..b233222d5 100644 --- a/tendermint/src/v0_37/abci/response.rs +++ b/tendermint/src/v0_37/abci/response.rs @@ -3,7 +3,6 @@ pub use crate::abci::response::{ InitChain, ListSnapshots, LoadSnapshotChunk, OfferSnapshot, PrepareProposal, ProcessProposal, Query, }; -use crate::abci::response::{ConsensusResponse, InfoResponse, MempoolResponse, SnapshotResponse}; use crate::Error; /// All possible ABCI responses for this protocol version. @@ -45,6 +44,56 @@ pub enum Response { ProcessProposal(ProcessProposal), } +/// The consensus category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum ConsensusResponse { + #[doc = include_str!("../../abci/doc/response-initchain.md")] + InitChain(InitChain), + #[doc = include_str!("../../abci/doc/response-prepareproposal.md")] + PrepareProposal(PrepareProposal), + #[doc = include_str!("../../abci/doc/response-processproposal.md")] + ProcessProposal(ProcessProposal), + #[doc = include_str!("../../abci/doc/response-beginblock.md")] + BeginBlock(BeginBlock), + #[doc = include_str!("../../abci/doc/response-delivertx.md")] + DeliverTx(DeliverTx), + #[doc = include_str!("../../abci/doc/response-endblock.md")] + EndBlock(EndBlock), + #[doc = include_str!("../../abci/doc/response-commit.md")] + Commit(Commit), +} + +/// The mempool category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum MempoolResponse { + #[doc = include_str!("../../abci/doc/response-checktx.md")] + CheckTx(CheckTx), +} + +/// The info category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum InfoResponse { + #[doc = include_str!("../../abci/doc/response-echo.md")] + Echo(Echo), + #[doc = include_str!("../../abci/doc/response-info.md")] + Info(Info), + #[doc = include_str!("../../abci/doc/response-query.md")] + Query(Query), +} + +/// The snapshot category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum SnapshotResponse { + #[doc = include_str!("../../abci/doc/response-listsnapshots.md")] + ListSnapshots(ListSnapshots), + #[doc = include_str!("../../abci/doc/response-offersnapshot.md")] + OfferSnapshot(OfferSnapshot), + #[doc = include_str!("../../abci/doc/response-loadsnapshotchunk.md")] + LoadSnapshotChunk(LoadSnapshotChunk), + #[doc = include_str!("../../abci/doc/response-applysnapshotchunk.md")] + ApplySnapshotChunk(ApplySnapshotChunk), +} + impl From for Response { fn from(req: ConsensusResponse) -> Self { match req { @@ -99,7 +148,6 @@ impl From for Response { InfoResponse::Echo(x) => Self::Echo(x), InfoResponse::Info(x) => Self::Info(x), InfoResponse::Query(x) => Self::Query(x), - InfoResponse::SetOption(_) => panic!("cannot be used with v0.37"), } } } diff --git a/tendermint/src/v0_38.rs b/tendermint/src/v0_38.rs new file mode 100644 index 000000000..c52eb0a4c --- /dev/null +++ b/tendermint/src/v0_38.rs @@ -0,0 +1 @@ +pub mod abci; diff --git a/tendermint/src/v0_38/abci.rs b/tendermint/src/v0_38/abci.rs new file mode 100644 index 000000000..02bb3b6fb --- /dev/null +++ b/tendermint/src/v0_38/abci.rs @@ -0,0 +1,5 @@ +pub mod request; +pub mod response; + +pub use request::{ConsensusRequest, InfoRequest, MempoolRequest, Request, SnapshotRequest}; +pub use response::{ConsensusResponse, InfoResponse, MempoolResponse, Response, SnapshotResponse}; diff --git a/tendermint/src/v0_38/abci/request.rs b/tendermint/src/v0_38/abci/request.rs new file mode 100644 index 000000000..6cdc9c451 --- /dev/null +++ b/tendermint/src/v0_38/abci/request.rs @@ -0,0 +1,278 @@ +use tendermint_proto::v0_38::abci as pb; +use tendermint_proto::Protobuf; + +use crate::abci::MethodKind; +use crate::Error; + +pub use crate::abci::request::{ + ApplySnapshotChunk, CheckTx, CheckTxKind, Echo, ExtendVote, FinalizeBlock, Info, InitChain, + LoadSnapshotChunk, OfferSnapshot, PrepareProposal, ProcessProposal, Query, VerifyVoteExtension, +}; + +/// All possible ABCI requests in CometBFT 0.38. +#[allow(clippy::large_enum_variant)] +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum Request { + #[doc = include_str!("../../abci/doc/request-echo.md")] + Echo(Echo), + #[doc = include_str!("../../abci/doc/request-flush.md")] + Flush, + #[doc = include_str!("../../abci/doc/request-info.md")] + Info(Info), + #[doc = include_str!("../../abci/doc/request-initchain.md")] + InitChain(InitChain), + #[doc = include_str!("../../abci/doc/request-query.md")] + Query(Query), + #[doc = include_str!("../../abci/doc/request-checktx.md")] + CheckTx(CheckTx), + #[doc = include_str!("../../abci/doc/request-commit.md")] + Commit, + #[doc = include_str!("../../abci/doc/request-listsnapshots.md")] + ListSnapshots, + #[doc = include_str!("../../abci/doc/request-offersnapshot.md")] + OfferSnapshot(OfferSnapshot), + #[doc = include_str!("../../abci/doc/request-loadsnapshotchunk.md")] + LoadSnapshotChunk(LoadSnapshotChunk), + #[doc = include_str!("../../abci/doc/request-applysnapshotchunk.md")] + ApplySnapshotChunk(ApplySnapshotChunk), + #[doc = include_str!("../../abci/doc/request-prepareproposal.md")] + PrepareProposal(PrepareProposal), + #[doc = include_str!("../../abci/doc/request-processproposal.md")] + ProcessProposal(ProcessProposal), + #[doc = include_str!("../../abci/doc/request-extendvote.md")] + ExtendVote(ExtendVote), + #[doc = include_str!("../../abci/doc/request-verifyvoteextension.md")] + VerifyVoteExtension(VerifyVoteExtension), + #[doc = include_str!("../../abci/doc/request-finalizeblock.md")] + FinalizeBlock(FinalizeBlock), +} + +/// The consensus category of ABCI requests. +#[allow(clippy::large_enum_variant)] +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum ConsensusRequest { + #[doc = include_str!("../../abci/doc/request-initchain.md")] + InitChain(InitChain), + #[doc = include_str!("../../abci/doc/request-prepareproposal.md")] + PrepareProposal(PrepareProposal), + #[doc = include_str!("../../abci/doc/request-processproposal.md")] + ProcessProposal(ProcessProposal), + #[doc = include_str!("../../abci/doc/request-commit.md")] + Commit, + #[doc = include_str!("../../abci/doc/request-extendvote.md")] + ExtendVote(ExtendVote), + #[doc = include_str!("../../abci/doc/request-verifyvoteextension.md")] + VerifyVoteExtension(VerifyVoteExtension), + #[doc = include_str!("../../abci/doc/request-finalizeblock.md")] + FinalizeBlock(FinalizeBlock), +} + +/// The mempool category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum MempoolRequest { + #[doc = include_str!("../../abci/doc/request-checktx.md")] + CheckTx(CheckTx), +} + +/// The info category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum InfoRequest { + #[doc = include_str!("../../abci/doc/request-info.md")] + Info(Info), + #[doc = include_str!("../../abci/doc/request-query.md")] + Query(Query), + #[doc = include_str!("../../abci/doc/request-echo.md")] + Echo(Echo), +} + +/// The snapshot category of ABCI requests. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum SnapshotRequest { + #[doc = include_str!("../../abci/doc/request-listsnapshots.md")] + ListSnapshots, + #[doc = include_str!("../../abci/doc/request-offersnapshot.md")] + OfferSnapshot(OfferSnapshot), + #[doc = include_str!("../../abci/doc/request-loadsnapshotchunk.md")] + LoadSnapshotChunk(LoadSnapshotChunk), + #[doc = include_str!("../../abci/doc/request-applysnapshotchunk.md")] + ApplySnapshotChunk(ApplySnapshotChunk), +} + +impl Request { + /// Get the method kind for this request. + pub fn kind(&self) -> MethodKind { + use Request::*; + match self { + Flush => MethodKind::Flush, + InitChain(_) => MethodKind::Consensus, + Commit => MethodKind::Consensus, + PrepareProposal(_) => MethodKind::Consensus, + ProcessProposal(_) => MethodKind::Consensus, + ExtendVote(_) => MethodKind::Consensus, + VerifyVoteExtension(_) => MethodKind::Consensus, + FinalizeBlock(_) => MethodKind::Consensus, + CheckTx(_) => MethodKind::Mempool, + ListSnapshots => MethodKind::Snapshot, + OfferSnapshot(_) => MethodKind::Snapshot, + LoadSnapshotChunk(_) => MethodKind::Snapshot, + ApplySnapshotChunk(_) => MethodKind::Snapshot, + Info(_) => MethodKind::Info, + Query(_) => MethodKind::Info, + Echo(_) => MethodKind::Info, + } + } +} + +impl From for Request { + fn from(req: ConsensusRequest) -> Self { + match req { + ConsensusRequest::InitChain(x) => Self::InitChain(x), + ConsensusRequest::PrepareProposal(x) => Self::PrepareProposal(x), + ConsensusRequest::ProcessProposal(x) => Self::ProcessProposal(x), + ConsensusRequest::Commit => Self::Commit, + ConsensusRequest::ExtendVote(x) => Self::ExtendVote(x), + ConsensusRequest::VerifyVoteExtension(x) => Self::VerifyVoteExtension(x), + ConsensusRequest::FinalizeBlock(x) => Self::FinalizeBlock(x), + } + } +} + +impl TryFrom for ConsensusRequest { + type Error = Error; + fn try_from(req: Request) -> Result { + match req { + Request::InitChain(x) => Ok(Self::InitChain(x)), + Request::PrepareProposal(x) => Ok(Self::PrepareProposal(x)), + Request::ProcessProposal(x) => Ok(Self::ProcessProposal(x)), + Request::Commit => Ok(Self::Commit), + Request::ExtendVote(x) => Ok(Self::ExtendVote(x)), + Request::VerifyVoteExtension(x) => Ok(Self::VerifyVoteExtension(x)), + Request::FinalizeBlock(x) => Ok(Self::FinalizeBlock(x)), + _ => Err(Error::invalid_abci_request_type()), + } + } +} + +impl From for Request { + fn from(req: MempoolRequest) -> Self { + match req { + MempoolRequest::CheckTx(x) => Self::CheckTx(x), + } + } +} + +impl TryFrom for MempoolRequest { + type Error = Error; + fn try_from(req: Request) -> Result { + match req { + Request::CheckTx(x) => Ok(Self::CheckTx(x)), + _ => Err(Error::invalid_abci_request_type()), + } + } +} + +impl From for Request { + fn from(req: InfoRequest) -> Self { + match req { + InfoRequest::Info(x) => Self::Info(x), + InfoRequest::Query(x) => Self::Query(x), + InfoRequest::Echo(x) => Self::Echo(x), + } + } +} + +impl TryFrom for InfoRequest { + type Error = Error; + fn try_from(req: Request) -> Result { + match req { + Request::Info(x) => Ok(Self::Info(x)), + Request::Query(x) => Ok(Self::Query(x)), + Request::Echo(x) => Ok(Self::Echo(x)), + _ => Err(Error::invalid_abci_request_type()), + } + } +} + +impl From for Request { + fn from(req: SnapshotRequest) -> Self { + match req { + SnapshotRequest::ListSnapshots => Self::ListSnapshots, + SnapshotRequest::OfferSnapshot(x) => Self::OfferSnapshot(x), + SnapshotRequest::LoadSnapshotChunk(x) => Self::LoadSnapshotChunk(x), + SnapshotRequest::ApplySnapshotChunk(x) => Self::ApplySnapshotChunk(x), + } + } +} + +impl TryFrom for SnapshotRequest { + type Error = Error; + fn try_from(req: Request) -> Result { + match req { + Request::ListSnapshots => Ok(Self::ListSnapshots), + Request::OfferSnapshot(x) => Ok(Self::OfferSnapshot(x)), + Request::LoadSnapshotChunk(x) => Ok(Self::LoadSnapshotChunk(x)), + Request::ApplySnapshotChunk(x) => Ok(Self::ApplySnapshotChunk(x)), + _ => Err(Error::invalid_abci_request_type()), + } + } +} + +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +impl From for pb::Request { + fn from(request: Request) -> pb::Request { + use pb::request::Value; + let value = match request { + Request::Echo(x) => Some(Value::Echo(x.into())), + Request::Flush => Some(Value::Flush(Default::default())), + Request::Info(x) => Some(Value::Info(x.into())), + Request::InitChain(x) => Some(Value::InitChain(x.into())), + Request::Query(x) => Some(Value::Query(x.into())), + Request::CheckTx(x) => Some(Value::CheckTx(x.into())), + Request::Commit => Some(Value::Commit(Default::default())), + Request::ListSnapshots => Some(Value::ListSnapshots(Default::default())), + 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::ExtendVote(x) => Some(Value::ExtendVote(x.into())), + Request::VerifyVoteExtension(x) => Some(Value::VerifyVoteExtension(x.into())), + Request::FinalizeBlock(x) => Some(Value::FinalizeBlock(x.into())), + }; + pb::Request { value } + } +} + +impl TryFrom for Request { + type Error = Error; + + fn try_from(request: pb::Request) -> Result { + use pb::request::Value; + + let value = request.value.ok_or_else(Error::missing_data)?; + let request = match value { + Value::Echo(x) => Request::Echo(x.try_into()?), + Value::Flush(pb::RequestFlush {}) => Request::Flush, + Value::Info(x) => Request::Info(x.try_into()?), + Value::InitChain(x) => Request::InitChain(x.try_into()?), + Value::Query(x) => Request::Query(x.try_into()?), + Value::CheckTx(x) => Request::CheckTx(x.try_into()?), + Value::Commit(pb::RequestCommit {}) => Request::Commit, + Value::ListSnapshots(pb::RequestListSnapshots {}) => Request::ListSnapshots, + Value::OfferSnapshot(x) => Request::OfferSnapshot(x.try_into()?), + Value::LoadSnapshotChunk(x) => Request::LoadSnapshotChunk(x.try_into()?), + Value::ApplySnapshotChunk(x) => Request::ApplySnapshotChunk(x.try_into()?), + Value::PrepareProposal(x) => Request::PrepareProposal(x.try_into()?), + Value::ProcessProposal(x) => Request::ProcessProposal(x.try_into()?), + Value::ExtendVote(x) => Request::ExtendVote(x.try_into()?), + Value::VerifyVoteExtension(x) => Request::VerifyVoteExtension(x.try_into()?), + Value::FinalizeBlock(x) => Request::FinalizeBlock(x.try_into()?), + }; + Ok(request) + } +} + +impl Protobuf for Request {} diff --git a/tendermint/src/v0_38/abci/response.rs b/tendermint/src/v0_38/abci/response.rs new file mode 100644 index 000000000..2b8015d6d --- /dev/null +++ b/tendermint/src/v0_38/abci/response.rs @@ -0,0 +1,255 @@ +pub use crate::abci::response::{ + ApplySnapshotChunk, BeginBlock, CheckTx, Commit, DeliverTx, Echo, EndBlock, Exception, + ExtendVote, FinalizeBlock, Info, InitChain, ListSnapshots, LoadSnapshotChunk, OfferSnapshot, + PrepareProposal, ProcessProposal, Query, VerifyVoteExtension, +}; +use crate::Error; + +/// All possible ABCI responses for this protocol version. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum Response { + #[doc = include_str!("../../abci/doc/response-exception.md")] + Exception(Exception), + #[doc = include_str!("../../abci/doc/response-echo.md")] + Echo(Echo), + #[doc = include_str!("../../abci/doc/response-flush.md")] + Flush, + #[doc = include_str!("../../abci/doc/response-info.md")] + Info(Info), + #[doc = include_str!("../../abci/doc/response-initchain.md")] + InitChain(InitChain), + #[doc = include_str!("../../abci/doc/response-query.md")] + Query(Query), + #[doc = include_str!("../../abci/doc/response-checktx.md")] + CheckTx(CheckTx), + #[doc = include_str!("../../abci/doc/response-commit.md")] + Commit(Commit), + #[doc = include_str!("../../abci/doc/response-listsnapshots.md")] + ListSnapshots(ListSnapshots), + #[doc = include_str!("../../abci/doc/response-offersnapshot.md")] + OfferSnapshot(OfferSnapshot), + #[doc = include_str!("../../abci/doc/response-loadsnapshotchunk.md")] + LoadSnapshotChunk(LoadSnapshotChunk), + #[doc = include_str!("../../abci/doc/response-applysnapshotchunk.md")] + ApplySnapshotChunk(ApplySnapshotChunk), + #[doc = include_str!("../../abci/doc/response-prepareproposal.md")] + PrepareProposal(PrepareProposal), + #[doc = include_str!("../../abci/doc/response-processproposal.md")] + ProcessProposal(ProcessProposal), + #[doc = include_str!("../../abci/doc/response-extendvote.md")] + ExtendVote(ExtendVote), + #[doc = include_str!("../../abci/doc/response-verifyvoteextension.md")] + VerifyVoteExtension(VerifyVoteExtension), + #[doc = include_str!("../../abci/doc/response-finalizeblock.md")] + FinalizeBlock(FinalizeBlock), +} + +/// The consensus category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum ConsensusResponse { + #[doc = include_str!("../../abci/doc/response-initchain.md")] + InitChain(InitChain), + #[doc = include_str!("../../abci/doc/response-prepareproposal.md")] + PrepareProposal(PrepareProposal), + #[doc = include_str!("../../abci/doc/response-processproposal.md")] + ProcessProposal(ProcessProposal), + #[doc = include_str!("../../abci/doc/response-commit.md")] + Commit(Commit), + #[doc = include_str!("../../abci/doc/response-extendvote.md")] + ExtendVote(ExtendVote), + #[doc = include_str!("../../abci/doc/response-verifyvoteextension.md")] + VerifyVoteExtension(VerifyVoteExtension), + #[doc = include_str!("../../abci/doc/response-finalizeblock.md")] + FinalizeBlock(FinalizeBlock), +} + +/// The mempool category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum MempoolResponse { + #[doc = include_str!("../../abci/doc/response-checktx.md")] + CheckTx(CheckTx), +} + +/// The info category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum InfoResponse { + #[doc = include_str!("../../abci/doc/response-echo.md")] + Echo(Echo), + #[doc = include_str!("../../abci/doc/response-info.md")] + Info(Info), + #[doc = include_str!("../../abci/doc/response-query.md")] + Query(Query), +} + +/// The snapshot category of ABCI responses. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum SnapshotResponse { + #[doc = include_str!("../../abci/doc/response-listsnapshots.md")] + ListSnapshots(ListSnapshots), + #[doc = include_str!("../../abci/doc/response-offersnapshot.md")] + OfferSnapshot(OfferSnapshot), + #[doc = include_str!("../../abci/doc/response-loadsnapshotchunk.md")] + LoadSnapshotChunk(LoadSnapshotChunk), + #[doc = include_str!("../../abci/doc/response-applysnapshotchunk.md")] + ApplySnapshotChunk(ApplySnapshotChunk), +} + +impl From for Response { + fn from(req: ConsensusResponse) -> Self { + match req { + ConsensusResponse::InitChain(x) => Self::InitChain(x), + ConsensusResponse::PrepareProposal(x) => Self::PrepareProposal(x), + ConsensusResponse::ProcessProposal(x) => Self::ProcessProposal(x), + ConsensusResponse::Commit(x) => Self::Commit(x), + ConsensusResponse::ExtendVote(x) => Self::ExtendVote(x), + ConsensusResponse::VerifyVoteExtension(x) => Self::VerifyVoteExtension(x), + ConsensusResponse::FinalizeBlock(x) => Self::FinalizeBlock(x), + } + } +} + +impl TryFrom for ConsensusResponse { + type Error = Error; + fn try_from(req: Response) -> Result { + match req { + Response::InitChain(x) => Ok(Self::InitChain(x)), + Response::PrepareProposal(x) => Ok(Self::PrepareProposal(x)), + Response::ProcessProposal(x) => Ok(Self::ProcessProposal(x)), + Response::Commit(x) => Ok(Self::Commit(x)), + Response::ExtendVote(x) => Ok(Self::ExtendVote(x)), + Response::VerifyVoteExtension(x) => Ok(Self::VerifyVoteExtension(x)), + Response::FinalizeBlock(x) => Ok(Self::FinalizeBlock(x)), + _ => Err(Error::invalid_abci_response_type()), + } + } +} + +impl From for Response { + fn from(req: MempoolResponse) -> Self { + match req { + MempoolResponse::CheckTx(x) => Self::CheckTx(x), + } + } +} + +impl TryFrom for MempoolResponse { + type Error = Error; + fn try_from(req: Response) -> Result { + match req { + Response::CheckTx(x) => Ok(Self::CheckTx(x)), + _ => Err(Error::invalid_abci_response_type()), + } + } +} + +impl From for Response { + fn from(req: InfoResponse) -> Self { + match req { + InfoResponse::Echo(x) => Self::Echo(x), + InfoResponse::Info(x) => Self::Info(x), + InfoResponse::Query(x) => Self::Query(x), + } + } +} + +impl TryFrom for InfoResponse { + type Error = Error; + fn try_from(req: Response) -> Result { + match req { + Response::Echo(x) => Ok(Self::Echo(x)), + Response::Info(x) => Ok(Self::Info(x)), + Response::Query(x) => Ok(Self::Query(x)), + _ => Err(Error::invalid_abci_response_type()), + } + } +} + +impl From for Response { + fn from(req: SnapshotResponse) -> Self { + match req { + SnapshotResponse::ListSnapshots(x) => Self::ListSnapshots(x), + SnapshotResponse::OfferSnapshot(x) => Self::OfferSnapshot(x), + SnapshotResponse::LoadSnapshotChunk(x) => Self::LoadSnapshotChunk(x), + SnapshotResponse::ApplySnapshotChunk(x) => Self::ApplySnapshotChunk(x), + } + } +} + +impl TryFrom for SnapshotResponse { + type Error = Error; + fn try_from(req: Response) -> Result { + match req { + Response::ListSnapshots(x) => Ok(Self::ListSnapshots(x)), + Response::OfferSnapshot(x) => Ok(Self::OfferSnapshot(x)), + Response::LoadSnapshotChunk(x) => Ok(Self::LoadSnapshotChunk(x)), + Response::ApplySnapshotChunk(x) => Ok(Self::ApplySnapshotChunk(x)), + _ => Err(Error::invalid_abci_response_type()), + } + } +} + +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +use tendermint_proto::v0_38::abci as pb; +use tendermint_proto::Protobuf; + +impl From for pb::Response { + fn from(response: Response) -> pb::Response { + use pb::response::Value; + let value = match response { + Response::Exception(x) => Some(Value::Exception(x.into())), + Response::Echo(x) => Some(Value::Echo(x.into())), + Response::Flush => Some(Value::Flush(Default::default())), + Response::Info(x) => Some(Value::Info(x.into())), + Response::InitChain(x) => Some(Value::InitChain(x.into())), + Response::Query(x) => Some(Value::Query(x.into())), + Response::CheckTx(x) => Some(Value::CheckTx(x.into())), + Response::Commit(x) => Some(Value::Commit(x.into())), + Response::ListSnapshots(x) => Some(Value::ListSnapshots(x.into())), + 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::ExtendVote(x) => Some(Value::ExtendVote(x.into())), + Response::VerifyVoteExtension(x) => Some(Value::VerifyVoteExtension(x.into())), + Response::FinalizeBlock(x) => Some(Value::FinalizeBlock(x.into())), + }; + pb::Response { value } + } +} + +impl TryFrom for Response { + type Error = Error; + + fn try_from(response: pb::Response) -> Result { + use pb::response::Value; + + let value = response.value.ok_or_else(Error::missing_data)?; + + let response = match value { + Value::Exception(x) => Response::Exception(x.try_into()?), + Value::Echo(x) => Response::Echo(x.try_into()?), + Value::Flush(_) => Response::Flush, + Value::Info(x) => Response::Info(x.try_into()?), + Value::InitChain(x) => Response::InitChain(x.try_into()?), + Value::Query(x) => Response::Query(x.try_into()?), + Value::CheckTx(x) => Response::CheckTx(x.try_into()?), + Value::Commit(x) => Response::Commit(x.try_into()?), + Value::ListSnapshots(x) => Response::ListSnapshots(x.try_into()?), + Value::OfferSnapshot(x) => Response::OfferSnapshot(x.try_into()?), + Value::LoadSnapshotChunk(x) => Response::LoadSnapshotChunk(x.try_into()?), + Value::ApplySnapshotChunk(x) => Response::ApplySnapshotChunk(x.try_into()?), + Value::PrepareProposal(x) => Response::PrepareProposal(x.try_into()?), + Value::ProcessProposal(x) => Response::ProcessProposal(x.try_into()?), + Value::ExtendVote(x) => Response::ExtendVote(x.try_into()?), + Value::VerifyVoteExtension(x) => Response::VerifyVoteExtension(x.try_into()?), + Value::FinalizeBlock(x) => Response::FinalizeBlock(x.try_into()?), + }; + Ok(response) + } +} + +impl Protobuf for Response {} diff --git a/tendermint/src/vote.rs b/tendermint/src/vote.rs index 8c2e4c416..241d2bf35 100644 --- a/tendermint/src/vote.rs +++ b/tendermint/src/vote.rs @@ -9,7 +9,7 @@ use core::{fmt, str::FromStr}; use bytes::BufMut; use serde::{Deserialize, Serialize}; -use tendermint_proto::v0_37::types::{CanonicalVote as RawCanonicalVote, Vote as RawVote}; +use tendermint_proto::v0_38::types::{CanonicalVote as RawCanonicalVote, Vote as RawVote}; use tendermint_proto::{Error as ProtobufError, Protobuf}; pub use self::{ @@ -17,7 +17,7 @@ pub use self::{ }; use crate::{ account, block, chain::Id as ChainId, consensus::State, error::Error, hash, prelude::*, - signature::Ed25519Signature, Signature, Time, + Signature, Time, }; /// Votes are signed messages from validators for a particular block which @@ -50,12 +50,31 @@ pub struct Vote { /// Signature pub signature: Option, + + /// Vote extension provided by the application. + /// Only valid for precommit messages. + /// + /// This field has been added in CometBFT 0.38 and will be ignored when + /// encoding into earlier protocol versions. + pub extension: Vec, + + /// Vote extension signature by the validator + /// Only valid for precommit messages. + /// + /// This field has been added in CometBFT 0.38 and will be ignored when + /// encoding into earlier protocol versions. + pub extension_signature: Option, } -tendermint_pb_modules! { +// ============================================================================= +// Protobuf conversions +// ============================================================================= + +mod v0_34 { use super::Vote; - use crate::{prelude::*, block, Error, Signature}; - use pb::types::Vote as RawVote; + use crate::{block, prelude::*, Error, Signature}; + use tendermint_proto::v0_34::types::Vote as RawVote; + use tendermint_proto::Protobuf; impl Protobuf for Vote {} @@ -80,6 +99,8 @@ tendermint_pb_modules! { validator_address: value.validator_address.try_into()?, validator_index: value.validator_index.try_into()?, signature: Signature::new(value.signature)?, + extension: Default::default(), + extension_signature: None, }) } } @@ -94,7 +115,114 @@ tendermint_pb_modules! { timestamp: value.timestamp.map(Into::into), validator_address: value.validator_address.into(), validator_index: value.validator_index.into(), - signature: value.signature.map(|s| s.to_bytes()).unwrap_or_default(), + signature: value.signature.map(|s| s.into_bytes()).unwrap_or_default(), + } + } + } +} + +mod v0_37 { + use super::Vote; + use crate::{block, prelude::*, Error, Signature}; + use tendermint_proto::v0_37::types::Vote as RawVote; + use tendermint_proto::Protobuf; + + impl Protobuf for Vote {} + + impl TryFrom for Vote { + type Error = Error; + + fn try_from(value: RawVote) -> Result { + if value.timestamp.is_none() { + return Err(Error::missing_timestamp()); + } + Ok(Vote { + vote_type: value.r#type.try_into()?, + height: value.height.try_into()?, + round: value.round.try_into()?, + // block_id can be nil in the Go implementation + block_id: value + .block_id + .map(TryInto::try_into) + .transpose()? + .filter(|i| i != &block::Id::default()), + timestamp: value.timestamp.map(|t| t.try_into()).transpose()?, + validator_address: value.validator_address.try_into()?, + validator_index: value.validator_index.try_into()?, + signature: Signature::new(value.signature)?, + extension: Default::default(), + extension_signature: None, + }) + } + } + + impl From for RawVote { + fn from(value: Vote) -> Self { + RawVote { + r#type: value.vote_type.into(), + height: value.height.into(), + round: value.round.into(), + block_id: value.block_id.map(Into::into), + timestamp: value.timestamp.map(Into::into), + validator_address: value.validator_address.into(), + validator_index: value.validator_index.into(), + signature: value.signature.map(|s| s.into_bytes()).unwrap_or_default(), + } + } + } +} + +mod v0_38 { + use super::Vote; + use crate::{block, prelude::*, Error, Signature}; + use tendermint_proto::v0_38::types::Vote as RawVote; + use tendermint_proto::Protobuf; + + impl Protobuf for Vote {} + + impl TryFrom for Vote { + type Error = Error; + + fn try_from(value: RawVote) -> Result { + if value.timestamp.is_none() { + return Err(Error::missing_timestamp()); + } + Ok(Vote { + vote_type: value.r#type.try_into()?, + height: value.height.try_into()?, + round: value.round.try_into()?, + // block_id can be nil in the Go implementation + block_id: value + .block_id + .map(TryInto::try_into) + .transpose()? + .filter(|i| i != &block::Id::default()), + timestamp: value.timestamp.map(|t| t.try_into()).transpose()?, + validator_address: value.validator_address.try_into()?, + validator_index: value.validator_index.try_into()?, + signature: Signature::new(value.signature)?, + extension: value.extension, + extension_signature: Signature::new(value.extension_signature)?, + }) + } + } + + impl From for RawVote { + fn from(value: Vote) -> Self { + RawVote { + r#type: value.vote_type.into(), + height: value.height.into(), + round: value.round.into(), + block_id: value.block_id.map(Into::into), + timestamp: value.timestamp.map(Into::into), + validator_address: value.validator_address.into(), + validator_index: value.validator_index.into(), + signature: value.signature.map(|s| s.into_bytes()).unwrap_or_default(), + extension: value.extension, + extension_signature: value + .extension_signature + .map(|s| s.into_bytes()) + .unwrap_or_default(), } } } @@ -157,26 +285,6 @@ impl Vote { } } -/// Default trait. Used in tests. -// FIXME: Does it need to be in public crate API? If not, replace with a helper fn in crate::test? -impl Default for Vote { - fn default() -> Self { - Vote { - vote_type: Type::Prevote, - height: Default::default(), - round: Default::default(), - block_id: None, - timestamp: Some(Time::unix_epoch()), - validator_address: account::Id::new([0; account::LENGTH]), - validator_index: ValidatorIndex::try_from(0_i32).unwrap(), - // Could have reused crate::test::dummy_signature, except that - // this Default impl is defined outside of #[cfg(test)]. - signature: Some(Signature::from(Ed25519Signature::from_bytes( - &[0; Ed25519Signature::BYTE_SIZE], - ))), - } - } -} /// SignedVote is the union of a canonicalized vote, the signature on /// the sign bytes of that vote and the id of the validator who signed it. pub struct SignedVote { diff --git a/tendermint/src/vote/sign_vote.rs b/tendermint/src/vote/sign_vote.rs index e4707150c..d71d8707b 100644 --- a/tendermint/src/vote/sign_vote.rs +++ b/tendermint/src/vote/sign_vote.rs @@ -110,7 +110,7 @@ mod tests { chain::Id as ChainId, hash::Algorithm, prelude::*, - signature::{Ed25519Signature, Signature}, + signature::Signature, vote::{CanonicalVote, SignVoteRequest, Type, ValidatorIndex}, Hash, Vote, }; @@ -144,6 +144,9 @@ mod tests { 192, 133, 130, 193, 115, 32, 206, 152, 91, 173, 10, ]) .unwrap(), + // TODO: test serialization of extensions + extension: vec![], + extension_signature: None, }; let mut got = vec![]; @@ -228,6 +231,9 @@ mod tests { 192, 133, 130, 193, 115, 32, 206, 152, 91, 173, 10, ]) .unwrap(), + // TODO: test serialization of extensions + extension: vec![], + extension_signature: None, }; let request = SignVoteRequest { @@ -278,10 +284,31 @@ mod tests { tendermint_pb_modules! { use super::*; use pb::types::CanonicalVote as RawCanonicalVote; + use crate::{Time, account, signature::Ed25519Signature}; + + /// Returns a dummy value to be used in tests. + pub fn dummy_vote() -> Vote { + Vote { + vote_type: Type::Prevote, + height: Default::default(), + round: Default::default(), + block_id: None, + timestamp: Some(Time::unix_epoch()), + validator_address: account::Id::new([0; account::LENGTH]), + validator_index: ValidatorIndex::try_from(0_i32).unwrap(), + // Could have reused crate::test::dummy_signature, except that + // this Default impl is defined outside of #[cfg(test)]. + signature: Some(Signature::from(Ed25519Signature::from_bytes( + &[0; Ed25519Signature::BYTE_SIZE], + ))), + extension: Default::default(), + extension_signature: None, + } + } #[test] fn test_sign_bytes_compatibility() { - let cv = CanonicalVote::new(Vote::default(), ChainId::try_from("A").unwrap()); + let cv = CanonicalVote::new(dummy_vote(), ChainId::try_from("A").unwrap()); let mut got = vec![]; // SignBytes are encoded using MarshalBinary and not MarshalBinaryBare Protobuf::::encode_length_delimited(&cv, &mut got).unwrap(); @@ -297,7 +324,7 @@ mod tests { height: Height::from(1_u32), round: Round::from(1_u16), vote_type: Type::Precommit, - ..Default::default() + ..dummy_vote() }; println!("{vt_precommit:?}"); let cv_precommit = CanonicalVote::new(vt_precommit, ChainId::try_from("A").unwrap()); @@ -323,7 +350,7 @@ mod tests { height: Height::from(1_u32), round: Round::from(1_u16), vote_type: Type::Prevote, - ..Default::default() + ..dummy_vote() }; let cv_prevote = CanonicalVote::new(vt_prevote, ChainId::try_from("A").unwrap()); @@ -384,6 +411,9 @@ mod tests { .unwrap(), }), signature: Signature::new(vec![1; Ed25519Signature::BYTE_SIZE]).unwrap(), + // TODO: test deserialization of extensions in 0.38 + extension: vec![], + extension_signature: None, }; let want = SignVoteRequest { vote, @@ -428,6 +458,9 @@ mod tests { 192, 133, 130, 193, 115, 32, 206, 152, 91, 173, 10, ]) .unwrap(), + // TODO: test deserialization of extensions in 0.38 + extension: vec![], + extension_signature: None, }; let got = Protobuf::::encode_vec(&vote).unwrap(); let v = >::decode_vec(&got).unwrap(); diff --git a/test/src/test/unit/p2p/secret_connection.rs b/test/src/test/unit/p2p/secret_connection.rs index 75f16f231..fe770adac 100644 --- a/test/src/test/unit/p2p/secret_connection.rs +++ b/test/src/test/unit/p2p/secret_connection.rs @@ -6,7 +6,7 @@ use std::{ use rand_core::OsRng; use tendermint_p2p::secret_connection::{sort32, Handshake, SecretConnection, Version}; -use tendermint_proto::v0_37 as proto; +use tendermint_proto::v0_38 as proto; use x25519_dalek::PublicKey as EphemeralPublic; use crate::pipe; diff --git a/testgen/src/consensus.rs b/testgen/src/consensus.rs index a17204c77..204f5c0b5 100644 --- a/testgen/src/consensus.rs +++ b/testgen/src/consensus.rs @@ -20,5 +20,6 @@ pub fn default_consensus_params() -> consensus::Params { pub_key_types: vec![Algorithm::Ed25519], }, version: Some(VersionParams::default()), + abci: Default::default(), } } diff --git a/testgen/src/vote.rs b/testgen/src/vote.rs index a28a918e6..0555d4f8a 100644 --- a/testgen/src/vote.rs +++ b/testgen/src/vote.rs @@ -135,6 +135,8 @@ impl Generator for Vote { validator_index: ValidatorIndex::try_from(validator_index as u32).unwrap(), signature: Signature::new(vec![0_u8; Ed25519Signature::BYTE_SIZE]) .map_err(|e| SimpleError::new(e.to_string()))?, + extension: vec![], + extension_signature: None, }; let sign_bytes = get_vote_sign_bytes(block_header.chain_id, &vote); diff --git a/tools/proto-compiler/src/constants.rs b/tools/proto-compiler/src/constants.rs index 7485089a9..a6e9b6873 100644 --- a/tools/proto-compiler/src/constants.rs +++ b/tools/proto-compiler/src/constants.rs @@ -19,12 +19,17 @@ pub const TENDERMINT_VERSIONS: &[TendermintVersion] = &[ TendermintVersion { repo: "https://github.com/cometbft/cometbft", ident: "v0_34", - commitish: "v0.34.27", + commitish: "v0.34.28", }, TendermintVersion { repo: "https://github.com/cometbft/cometbft", ident: "v0_37", - commitish: "v0.37.0", + commitish: "v0.37.1", + }, + TendermintVersion { + repo: "https://github.com/cometbft/cometbft", + ident: "v0_38", + commitish: "v0.38.0-alpha.1", }, ]; @@ -93,7 +98,7 @@ pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ (".tendermint.types.Commit", SERIALIZED), (".tendermint.types.CommitSig", SERIALIZED), (".tendermint.types.ValidatorSet", SERIALIZED), - (".tendermint.crypto.PublicKey.sum", SERIALIZED), + (".tendermint.crypto.PublicKey", SERIALIZED), (".tendermint.crypto.PublicKey.sum", TYPE_TAG), (".tendermint.abci.ResponseInfo", SERIALIZED), (".tendermint.types.CanonicalBlockID", SERIALIZED),