From da301d52b209e7a7b6ce0317b3342267adee27b6 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Tue, 5 Mar 2024 12:05:00 +0200 Subject: [PATCH] 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)]"#;