From 95b9e77a806f9ac4ab26b7dba89a446ea9f4b4a9 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Mon, 4 Mar 2024 18:08:07 +0200 Subject: [PATCH 1/5] Update protos to recent CometBFT in main, with RFC 106 Since CometBFT 1.0.0-alpha.1, there was one significant change: GetLatest* methods were removed from the data companion API as per RFC 106. Regenerate cometbft-proto from a recent cometbft commit that includes the changes. --- proto/src/cometbft.rs | 2 +- proto/src/prost/cometbft.abci.v1.rs | 9 +- proto/src/prost/cometbft.abci.v1beta1.rs | 4 +- proto/src/prost/cometbft.abci.v1beta2.rs | 6 +- proto/src/prost/cometbft.abci.v1beta3.rs | 6 +- proto/src/prost/cometbft.blocksync.v1.rs | 2 +- proto/src/prost/cometbft.blocksync.v1beta1.rs | 2 +- proto/src/prost/cometbft.crypto.v1.rs | 2 +- proto/src/prost/cometbft.services.block.v1.rs | 69 +-------------- .../cometbft.services.block_results.v1.rs | 87 ------------------- proto/src/prost/cometbft.types.v1.rs | 2 +- proto/src/prost/cometbft.types.v1beta1.rs | 2 +- tools/proto-compiler/src/constants.rs | 2 +- 13 files changed, 22 insertions(+), 173 deletions(-) diff --git a/proto/src/cometbft.rs b/proto/src/cometbft.rs index 9e211c5e..b0898e86 100644 --- a/proto/src/cometbft.rs +++ b/proto/src/cometbft.rs @@ -152,5 +152,5 @@ pub mod version { pub mod meta { pub const REPOSITORY: &str = "https://github.com/cometbft/cometbft"; - pub const COMMITISH: &str = "v1.0.0-alpha.1"; + pub const COMMITISH: &str = "b80055e35bebe4db605c9eb5249d852e82b9f02c"; } diff --git a/proto/src/prost/cometbft.abci.v1.rs b/proto/src/prost/cometbft.abci.v1.rs index 3014ab1f..2bb27cea 100644 --- a/proto/src/prost/cometbft.abci.v1.rs +++ b/proto/src/prost/cometbft.abci.v1.rs @@ -422,6 +422,7 @@ pub struct CheckTxResponse { 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")] @@ -504,7 +505,9 @@ pub struct VerifyVoteExtensionResponse { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FinalizeBlockResponse { - /// set of block events emmitted as part of executing the block + /// set of block events emitted as part of executing the block + /// + /// nondeterministic #[prost(message, repeated, tag = "1")] pub events: ::prost::alloc::vec::Vec, /// the result of executing each transaction including the events @@ -646,7 +649,7 @@ pub struct VoteInfo { #[prost(enumeration = "super::super::types::v1::BlockIdFlag", tag = "3")] pub block_id_flag: i32, } -/// ExtendedVoteInfo extends VoteInfo with the vote extentions (non-deterministic). +/// ExtendedVoteInfo extends VoteInfo with the vote extensions (non-deterministic). #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExtendedVoteInfo { @@ -1031,7 +1034,7 @@ pub mod abci_service_server { tonic::Response, tonic::Status, >; - /// ExtendVote extends a vote with application-injected data (vote extentions). + /// ExtendVote extends a vote with application-injected data (vote extensions). async fn extend_vote( &self, request: tonic::Request, diff --git a/proto/src/prost/cometbft.abci.v1beta1.rs b/proto/src/prost/cometbft.abci.v1beta1.rs index 7ae3f835..aee07026 100644 --- a/proto/src/prost/cometbft.abci.v1beta1.rs +++ b/proto/src/prost/cometbft.abci.v1beta1.rs @@ -108,7 +108,7 @@ pub struct RequestQuery { #[prost(bool, tag = "4")] pub prove: bool, } -/// RequestBeginBlock indicates the beginning of commiting the block. +/// RequestBeginBlock indicates the beginning of committing the block. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RequestBeginBlock { @@ -362,7 +362,7 @@ pub struct ResponseCheckTx { #[prost(int64, tag = "10")] pub priority: i64, /// mempool_error is set by CometBFT. - /// ABCI applictions creating a ResponseCheckTX should not set mempool_error. + /// ABCI applications creating a ResponseCheckTX should not set mempool_error. #[prost(string, tag = "11")] pub mempool_error: ::prost::alloc::string::String, } diff --git a/proto/src/prost/cometbft.abci.v1beta2.rs b/proto/src/prost/cometbft.abci.v1beta2.rs index acf9cb1b..5a23bfe9 100644 --- a/proto/src/prost/cometbft.abci.v1beta2.rs +++ b/proto/src/prost/cometbft.abci.v1beta2.rs @@ -81,7 +81,7 @@ pub struct RequestInitChain { #[prost(int64, tag = "6")] pub initial_height: i64, } -/// RequestBeginBlock indicates the beginning of commiting the block. +/// RequestBeginBlock indicates the beginning of committing the block. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RequestBeginBlock { @@ -245,7 +245,7 @@ pub struct ResponseCheckTx { #[prost(int64, tag = "10")] pub priority: i64, /// mempool_error is set by CometBFT. - /// ABCI applictions creating a ResponseCheckTX should not set mempool_error. + /// ABCI applications creating a ResponseCheckTX should not set mempool_error. #[prost(string, tag = "11")] pub mempool_error: ::prost::alloc::string::String, } @@ -395,7 +395,7 @@ pub struct EventAttribute { #[prost(bool, tag = "3")] pub index: bool, } -/// ExtendedVoteInfo extends VoteInfo with the vote extentions (non-deterministic). +/// ExtendedVoteInfo extends VoteInfo with the vote extensions (non-deterministic). #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExtendedVoteInfo { diff --git a/proto/src/prost/cometbft.abci.v1beta3.rs b/proto/src/prost/cometbft.abci.v1beta3.rs index 9d6f4a0d..f3dc2fbc 100644 --- a/proto/src/prost/cometbft.abci.v1beta3.rs +++ b/proto/src/prost/cometbft.abci.v1beta3.rs @@ -345,7 +345,7 @@ pub mod response_verify_vote_extension { #[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 + /// set of block events emitted 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 @@ -376,7 +376,7 @@ pub struct VoteInfo { #[prost(enumeration = "super::super::types::v1beta1::BlockIdFlag", tag = "3")] pub block_id_flag: i32, } -/// ExtendedVoteInfo extends VoteInfo with the vote extentions (non-deterministic). +/// ExtendedVoteInfo extends VoteInfo with the vote extensions (non-deterministic). #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExtendedVoteInfo { @@ -563,7 +563,7 @@ pub mod abci_server { tonic::Response, tonic::Status, >; - /// ExtendVote extends a vote with application-injected data (vote extentions). + /// ExtendVote extends a vote with application-injected data (vote extensions). async fn extend_vote( &self, request: tonic::Request, diff --git a/proto/src/prost/cometbft.blocksync.v1.rs b/proto/src/prost/cometbft.blocksync.v1.rs index 8b8bddfd..f1041999 100644 --- a/proto/src/prost/cometbft.blocksync.v1.rs +++ b/proto/src/prost/cometbft.blocksync.v1.rs @@ -34,7 +34,7 @@ pub struct BlockResponse { #[prost(message, optional, tag = "2")] pub ext_commit: ::core::option::Option, } -/// Message is an abtract blocksync message. +/// Message is an abstract blocksync message. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Message { diff --git a/proto/src/prost/cometbft.blocksync.v1beta1.rs b/proto/src/prost/cometbft.blocksync.v1beta1.rs index c8bf6a5c..458fdb46 100644 --- a/proto/src/prost/cometbft.blocksync.v1beta1.rs +++ b/proto/src/prost/cometbft.blocksync.v1beta1.rs @@ -32,7 +32,7 @@ pub struct StatusResponse { #[prost(int64, tag = "2")] pub base: i64, } -/// Message is an abtract blocksync message. +/// Message is an abstract blocksync message. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Message { diff --git a/proto/src/prost/cometbft.crypto.v1.rs b/proto/src/prost/cometbft.crypto.v1.rs index cf2e7f44..fe44a2ca 100644 --- a/proto/src/prost/cometbft.crypto.v1.rs +++ b/proto/src/prost/cometbft.crypto.v1.rs @@ -69,7 +69,7 @@ pub struct DominoOp { pub output: ::prost::alloc::string::String, } /// ProofOp defines an operation used for calculating Merkle root -/// The data could be arbitrary format, providing nessecary data +/// The data could be arbitrary format, providing necessary data /// for example neighbouring node hash #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/proto/src/prost/cometbft.services.block.v1.rs b/proto/src/prost/cometbft.services.block.v1.rs index 053faf42..c8f75da9 100644 --- a/proto/src/prost/cometbft.services.block.v1.rs +++ b/proto/src/prost/cometbft.services.block.v1.rs @@ -2,7 +2,7 @@ #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetByHeightRequest { - /// The height of the block requested. If set to 0, the latest height will be returned. + /// The height of the block requested. #[prost(int64, tag = "1")] pub height: i64, } @@ -15,19 +15,6 @@ pub struct GetByHeightResponse { #[prost(message, optional, tag = "2")] pub block: ::core::option::Option, } -/// GetLatestRequest is a request for the latest block. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetLatestRequest {} -/// GetLatestResponse contains the latest block ID and the latest block. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetLatestResponse { - #[prost(message, optional, tag = "1")] - pub block_id: ::core::option::Option, - #[prost(message, optional, tag = "2")] - pub block: ::core::option::Option, -} /// GetLatestHeightRequest - empty message since no parameter is required #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -57,14 +44,6 @@ pub mod block_service_server { tonic::Response, tonic::Status, >; - /// GetLatest retrieves the latest block. - async fn get_latest( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; /// Server streaming response type for the GetLatestHeight method. type GetLatestHeightStream: tonic::codegen::tokio_stream::Stream< Item = std::result::Result, @@ -209,52 +188,6 @@ pub mod block_service_server { }; Box::pin(fut) } - "/cometbft.services.block.v1.BlockService/GetLatest" => { - #[allow(non_camel_case_types)] - struct GetLatestSvc(pub Arc); - impl< - T: BlockService, - > tonic::server::UnaryService - for GetLatestSvc { - type Response = super::GetLatestResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_latest(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = GetLatestSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } "/cometbft.services.block.v1.BlockService/GetLatestHeight" => { #[allow(non_camel_case_types)] struct GetLatestHeightSvc(pub Arc); diff --git a/proto/src/prost/cometbft.services.block_results.v1.rs b/proto/src/prost/cometbft.services.block_results.v1.rs index 1f008554..ab133797 100644 --- a/proto/src/prost/cometbft.services.block_results.v1.rs +++ b/proto/src/prost/cometbft.services.block_results.v1.rs @@ -5,10 +5,6 @@ pub struct GetBlockResultsRequest { #[prost(int64, tag = "1")] pub height: i64, } -/// GetLatestBlockResultsRequest is a request for the BlockResults of the latest block. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetLatestBlockResultsRequest {} /// GetBlockResultsResponse contains the block results for the given height. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -34,31 +30,6 @@ pub struct GetBlockResultsResponse { #[prost(bytes = "vec", tag = "6")] pub app_hash: ::prost::alloc::vec::Vec, } -/// GetLatestBlockResultsResponse contains the block results for the latest block. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetLatestBlockResultsResponse { - #[prost(int64, tag = "1")] - pub height: i64, - #[prost(message, repeated, tag = "2")] - pub tx_results: ::prost::alloc::vec::Vec< - super::super::super::abci::v1::ExecTxResult, - >, - #[prost(message, repeated, tag = "3")] - pub finalize_block_events: ::prost::alloc::vec::Vec< - super::super::super::abci::v1::Event, - >, - #[prost(message, repeated, tag = "4")] - pub validator_updates: ::prost::alloc::vec::Vec< - super::super::super::abci::v1::ValidatorUpdate, - >, - #[prost(message, optional, tag = "5")] - pub consensus_param_updates: ::core::option::Option< - super::super::super::types::v1::ConsensusParams, - >, - #[prost(bytes = "vec", tag = "6")] - pub app_hash: ::prost::alloc::vec::Vec, -} /// Generated server implementations. #[cfg(feature = "grpc-server")] pub mod block_results_service_server { @@ -75,14 +46,6 @@ pub mod block_results_service_server { tonic::Response, tonic::Status, >; - /// GetLatestBlockResults returns the BlockResults of the latest committed height. - async fn get_latest_block_results( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; } /// /// BlockResultService provides the block results of a given or latestheight. @@ -215,56 +178,6 @@ pub mod block_results_service_server { }; Box::pin(fut) } - "/cometbft.services.block_results.v1.BlockResultsService/GetLatestBlockResults" => { - #[allow(non_camel_case_types)] - struct GetLatestBlockResultsSvc(pub Arc); - impl< - T: BlockResultsService, - > tonic::server::UnaryService - for GetLatestBlockResultsSvc { - type Response = super::GetLatestBlockResultsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_latest_block_results( - &inner, - request, - ) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let inner = inner.0; - let method = GetLatestBlockResultsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } _ => { Box::pin(async move { Ok( diff --git a/proto/src/prost/cometbft.types.v1.rs b/proto/src/prost/cometbft.types.v1.rs index ee5e0b5b..2953f38b 100644 --- a/proto/src/prost/cometbft.types.v1.rs +++ b/proto/src/prost/cometbft.types.v1.rs @@ -585,7 +585,7 @@ pub struct Block { #[prost(message, optional, tag = "4")] pub last_commit: ::core::option::Option, } -/// EventDataRoundState is emmitted with each new round step. +/// EventDataRoundState is emitted with each new round step. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EventDataRoundState { diff --git a/proto/src/prost/cometbft.types.v1beta1.rs b/proto/src/prost/cometbft.types.v1beta1.rs index 11f424b3..8b41596a 100644 --- a/proto/src/prost/cometbft.types.v1beta1.rs +++ b/proto/src/prost/cometbft.types.v1beta1.rs @@ -526,7 +526,7 @@ pub struct Block { #[prost(message, optional, tag = "4")] pub last_commit: ::core::option::Option, } -/// EventDataRoundState is emmitted with each new round step. +/// EventDataRoundState is emitted with each new round step. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EventDataRoundState { diff --git a/tools/proto-compiler/src/constants.rs b/tools/proto-compiler/src/constants.rs index f71b0d50..8d09d4b0 100644 --- a/tools/proto-compiler/src/constants.rs +++ b/tools/proto-compiler/src/constants.rs @@ -6,7 +6,7 @@ pub const COMETBFT_REPO: &str = "https://github.com/cometbft/cometbft"; /// - Tag: `v1.0.0` /// - Branch: `main` /// - Commit ID (full length): `d7d0ffea13c60c98b812d243ba5a2c375f341c15` -pub const COMETBFT_COMMITISH: &str = "v1.0.0-alpha.1"; +pub const COMETBFT_COMMITISH: &str = "b80055e35bebe4db605c9eb5249d852e82b9f02c"; /// Predefined custom attributes for message annotations const PRIMITIVE_ENUM: &str = r#"#[derive(::num_derive::FromPrimitive, ::num_derive::ToPrimitive)]"#; From da301d52b209e7a7b6ce0317b3342267adee27b6 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Tue, 5 Mar 2024 12:05:00 +0200 Subject: [PATCH 2/5] Update to sign_extension field added in cometbft NOTE: the default is set to true when converting from earlier version. --- cometbft/src/vote/sign_vote.rs | 19 +++++++++++++++++-- proto/src/cometbft.rs | 2 +- proto/src/prost/cometbft.privval.v1.rs | 2 ++ tools/proto-compiler/src/constants.rs | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/cometbft/src/vote/sign_vote.rs b/cometbft/src/vote/sign_vote.rs index ccbb3ec0..713c308c 100644 --- a/cometbft/src/vote/sign_vote.rs +++ b/cometbft/src/vote/sign_vote.rs @@ -10,6 +10,7 @@ pub struct SignVoteRequest { pub vote: Vote, /// Chain ID pub chain_id: chain::Id, + pub sign_extension: bool, } impl SignVoteRequest { @@ -59,7 +60,12 @@ mod v1 { let chain_id = value.chain_id.try_into()?; - Ok(SignVoteRequest { vote, chain_id }) + let sign_extension = value.sign_extension; + Ok(SignVoteRequest { + vote, + chain_id, + sign_extension, + }) } } @@ -68,6 +74,7 @@ mod v1 { RawSignVoteRequest { vote: Some(value.vote.into()), chain_id: value.chain_id.as_str().to_owned(), + sign_extension: value.sign_extension, } } } @@ -113,7 +120,11 @@ mod v1beta1 { let chain_id = value.chain_id.try_into()?; - Ok(SignVoteRequest { vote, chain_id }) + Ok(SignVoteRequest { + vote, + chain_id, + sign_extension: true, + }) } } @@ -209,6 +220,7 @@ mod tests { let request = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), + sign_extension: false, }; // Option 1 using bytes: @@ -294,6 +306,7 @@ mod tests { let request = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), + sign_extension: false, }; let got = request.into_signable_vec(); @@ -479,6 +492,7 @@ mod tests { let want = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), + sign_extension: false, }; let got = >::decode_vec(&encoded).unwrap(); @@ -534,6 +548,7 @@ mod tests { let svr = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), + sign_extension: false, }; let mut got = vec![]; let _have = Protobuf::::encode(svr.clone(), &mut got); diff --git a/proto/src/cometbft.rs b/proto/src/cometbft.rs index b0898e86..450e56f9 100644 --- a/proto/src/cometbft.rs +++ b/proto/src/cometbft.rs @@ -152,5 +152,5 @@ pub mod version { pub mod meta { pub const REPOSITORY: &str = "https://github.com/cometbft/cometbft"; - pub const COMMITISH: &str = "b80055e35bebe4db605c9eb5249d852e82b9f02c"; + pub const COMMITISH: &str = "cb177fed831f74090ecbce9a90c3cdb280900fd4"; } diff --git a/proto/src/prost/cometbft.privval.v1.rs b/proto/src/prost/cometbft.privval.v1.rs index fbc0efaf..751359c2 100644 --- a/proto/src/prost/cometbft.privval.v1.rs +++ b/proto/src/prost/cometbft.privval.v1.rs @@ -31,6 +31,8 @@ pub struct SignVoteRequest { pub vote: ::core::option::Option, #[prost(string, tag = "2")] pub chain_id: ::prost::alloc::string::String, + #[prost(bool, tag = "3")] + pub sign_extension: bool, } /// SignedVoteResponse is a response containing a signed vote or an error #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/tools/proto-compiler/src/constants.rs b/tools/proto-compiler/src/constants.rs index 8d09d4b0..bd6221ea 100644 --- a/tools/proto-compiler/src/constants.rs +++ b/tools/proto-compiler/src/constants.rs @@ -6,7 +6,7 @@ pub const COMETBFT_REPO: &str = "https://github.com/cometbft/cometbft"; /// - Tag: `v1.0.0` /// - Branch: `main` /// - Commit ID (full length): `d7d0ffea13c60c98b812d243ba5a2c375f341c15` -pub const COMETBFT_COMMITISH: &str = "b80055e35bebe4db605c9eb5249d852e82b9f02c"; +pub const COMETBFT_COMMITISH: &str = "cb177fed831f74090ecbce9a90c3cdb280900fd4"; /// Predefined custom attributes for message annotations const PRIMITIVE_ENUM: &str = r#"#[derive(::num_derive::FromPrimitive, ::num_derive::ToPrimitive)]"#; From e62c99af1922d7bdf393d4a532311da4ec3f1cf4 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Wed, 6 Mar 2024 11:14:48 +0200 Subject: [PATCH 3/5] proto: update to skip_extension_signing The cometbft.privval.v1.SignVoteRequest message had the recently added sign_extension field renamed to skip_extension_signing. Change the source commit and regenerate the protos. --- proto/src/cometbft.rs | 2 +- proto/src/prost/cometbft.privval.v1.rs | 3 ++- tools/proto-compiler/src/constants.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/proto/src/cometbft.rs b/proto/src/cometbft.rs index 450e56f9..bcab9fc4 100644 --- a/proto/src/cometbft.rs +++ b/proto/src/cometbft.rs @@ -152,5 +152,5 @@ pub mod version { pub mod meta { pub const REPOSITORY: &str = "https://github.com/cometbft/cometbft"; - pub const COMMITISH: &str = "cb177fed831f74090ecbce9a90c3cdb280900fd4"; + pub const COMMITISH: &str = "ec21d4d2b867476d6e65f824f2207cdb59843286"; } diff --git a/proto/src/prost/cometbft.privval.v1.rs b/proto/src/prost/cometbft.privval.v1.rs index 751359c2..0d65463f 100644 --- a/proto/src/prost/cometbft.privval.v1.rs +++ b/proto/src/prost/cometbft.privval.v1.rs @@ -31,8 +31,9 @@ pub struct SignVoteRequest { pub vote: ::core::option::Option, #[prost(string, tag = "2")] pub chain_id: ::prost::alloc::string::String, + /// if true, the signer may skip signing the extension bytes. #[prost(bool, tag = "3")] - pub sign_extension: bool, + pub skip_extension_signing: bool, } /// SignedVoteResponse is a response containing a signed vote or an error #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/tools/proto-compiler/src/constants.rs b/tools/proto-compiler/src/constants.rs index bd6221ea..53849330 100644 --- a/tools/proto-compiler/src/constants.rs +++ b/tools/proto-compiler/src/constants.rs @@ -6,7 +6,7 @@ pub const COMETBFT_REPO: &str = "https://github.com/cometbft/cometbft"; /// - Tag: `v1.0.0` /// - Branch: `main` /// - Commit ID (full length): `d7d0ffea13c60c98b812d243ba5a2c375f341c15` -pub const COMETBFT_COMMITISH: &str = "cb177fed831f74090ecbce9a90c3cdb280900fd4"; +pub const COMETBFT_COMMITISH: &str = "ec21d4d2b867476d6e65f824f2207cdb59843286"; /// Predefined custom attributes for message annotations const PRIMITIVE_ENUM: &str = r#"#[derive(::num_derive::FromPrimitive, ::num_derive::ToPrimitive)]"#; From 70455f2a15488adef1bf28b6f279fff2da9bc6a5 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Wed, 6 Mar 2024 11:29:26 +0200 Subject: [PATCH 4/5] cometbft: update SignVoteRequest domain type The sign_extension field was renamed to skip_extension_signing with flipped value semantics. --- cometbft/src/vote/sign_vote.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cometbft/src/vote/sign_vote.rs b/cometbft/src/vote/sign_vote.rs index 713c308c..754f0d18 100644 --- a/cometbft/src/vote/sign_vote.rs +++ b/cometbft/src/vote/sign_vote.rs @@ -10,7 +10,8 @@ pub struct SignVoteRequest { pub vote: Vote, /// Chain ID pub chain_id: chain::Id, - pub sign_extension: bool, + /// Whether to skip signing the extension bytes. + pub skip_extension_signing: bool, } impl SignVoteRequest { @@ -60,11 +61,12 @@ mod v1 { let chain_id = value.chain_id.try_into()?; - let sign_extension = value.sign_extension; + let skip_extension_signing = value.skip_extension_signing; + Ok(SignVoteRequest { vote, chain_id, - sign_extension, + skip_extension_signing, }) } } @@ -74,7 +76,7 @@ mod v1 { RawSignVoteRequest { vote: Some(value.vote.into()), chain_id: value.chain_id.as_str().to_owned(), - sign_extension: value.sign_extension, + skip_extension_signing: value.skip_extension_signing, } } } @@ -123,7 +125,7 @@ mod v1beta1 { Ok(SignVoteRequest { vote, chain_id, - sign_extension: true, + skip_extension_signing: false, }) } } @@ -220,7 +222,7 @@ mod tests { let request = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), - sign_extension: false, + skip_extension_signing: false, }; // Option 1 using bytes: @@ -306,7 +308,7 @@ mod tests { let request = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), - sign_extension: false, + skip_extension_signing: false, }; let got = request.into_signable_vec(); @@ -492,7 +494,7 @@ mod tests { let want = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), - sign_extension: false, + skip_extension_signing: false, }; let got = >::decode_vec(&encoded).unwrap(); @@ -548,7 +550,7 @@ mod tests { let svr = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), - sign_extension: false, + skip_extension_signing: false, }; let mut got = vec![]; let _have = Protobuf::::encode(svr.clone(), &mut got); From dfe7bdff33573fda40fe8d5242b31a4f26877cff Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Wed, 6 Mar 2024 11:34:33 +0200 Subject: [PATCH 5/5] Exercise skip_extension_signing set to true in v1 proto --- cometbft/src/vote/sign_vote.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cometbft/src/vote/sign_vote.rs b/cometbft/src/vote/sign_vote.rs index 754f0d18..d5bb0c32 100644 --- a/cometbft/src/vote/sign_vote.rs +++ b/cometbft/src/vote/sign_vote.rs @@ -550,7 +550,7 @@ mod tests { let svr = SignVoteRequest { vote, chain_id: ChainId::from_str("test_chain_id").unwrap(), - skip_extension_signing: false, + skip_extension_signing: true, }; let mut got = vec![]; let _have = Protobuf::::encode(svr.clone(), &mut got);