Skip to content

Commit

Permalink
Update to sign_extension field added in cometbft
Browse files Browse the repository at this point in the history
NOTE: the default is set to true when converting from earlier version.
  • Loading branch information
mzabaluev committed Mar 5, 2024
1 parent 95b9e77 commit da301d5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
19 changes: 17 additions & 2 deletions cometbft/src/vote/sign_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct SignVoteRequest {
pub vote: Vote,
/// Chain ID
pub chain_id: chain::Id,
pub sign_extension: bool,
}

impl SignVoteRequest {
Expand Down Expand Up @@ -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,
})
}
}

Expand All @@ -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,
}
}
}
Expand Down Expand Up @@ -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,
})
}
}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -479,6 +492,7 @@ mod tests {
let want = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
sign_extension: false,
};
let got =
<SignVoteRequest as Protobuf<RawSignVoteRequest>>::decode_vec(&encoded).unwrap();
Expand Down Expand Up @@ -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::<RawSignVoteRequest>::encode(svr.clone(), &mut got);
Expand Down
2 changes: 1 addition & 1 deletion proto/src/cometbft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
2 changes: 2 additions & 0 deletions proto/src/prost/cometbft.privval.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub struct SignVoteRequest {
pub vote: ::core::option::Option<super::super::types::v1::Vote>,
#[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)]
Expand Down
2 changes: 1 addition & 1 deletion tools/proto-compiler/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]"#;
Expand Down

0 comments on commit da301d5

Please sign in to comment.