Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update protos to recent CometBFT in main, with RFC 106 and skip_extension_signing #17

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions cometbft/src/vote/sign_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub struct SignVoteRequest {
pub vote: Vote,
/// Chain ID
pub chain_id: chain::Id,
/// Whether to skip signing the extension bytes.
pub skip_extension_signing: bool,
}

impl SignVoteRequest {
Expand Down Expand Up @@ -59,7 +61,13 @@ mod v1 {

let chain_id = value.chain_id.try_into()?;

Ok(SignVoteRequest { vote, chain_id })
let skip_extension_signing = value.skip_extension_signing;

Ok(SignVoteRequest {
vote,
chain_id,
skip_extension_signing,
})
}
}

Expand All @@ -68,6 +76,7 @@ mod v1 {
RawSignVoteRequest {
vote: Some(value.vote.into()),
chain_id: value.chain_id.as_str().to_owned(),
skip_extension_signing: value.skip_extension_signing,
}
}
}
Expand Down Expand Up @@ -113,7 +122,11 @@ mod v1beta1 {

let chain_id = value.chain_id.try_into()?;

Ok(SignVoteRequest { vote, chain_id })
Ok(SignVoteRequest {
vote,
chain_id,
skip_extension_signing: false,
})
}
}

Expand Down Expand Up @@ -209,6 +222,7 @@ mod tests {
let request = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
skip_extension_signing: false,
};

// Option 1 using bytes:
Expand Down Expand Up @@ -294,6 +308,7 @@ mod tests {
let request = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
skip_extension_signing: false,
};

let got = request.into_signable_vec();
Expand Down Expand Up @@ -479,6 +494,7 @@ mod tests {
let want = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
skip_extension_signing: false,
};
let got =
<SignVoteRequest as Protobuf<RawSignVoteRequest>>::decode_vec(&encoded).unwrap();
Expand Down Expand Up @@ -534,6 +550,7 @@ mod tests {
let svr = SignVoteRequest {
vote,
chain_id: ChainId::from_str("test_chain_id").unwrap(),
skip_extension_signing: true,
};
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 = "v1.0.0-alpha.1";
pub const COMMITISH: &str = "ec21d4d2b867476d6e65f824f2207cdb59843286";
}
9 changes: 6 additions & 3 deletions proto/src/prost/cometbft.abci.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Event>,
#[prost(string, tag = "8")]
Expand Down Expand Up @@ -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<Event>,
/// the result of executing each transaction including the events
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -1031,7 +1034,7 @@ pub mod abci_service_server {
tonic::Response<super::ProcessProposalResponse>,
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<super::ExtendVoteRequest>,
Expand Down
4 changes: 2 additions & 2 deletions proto/src/prost/cometbft.abci.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
Expand Down
6 changes: 3 additions & 3 deletions proto/src/prost/cometbft.abci.v1beta2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions proto/src/prost/cometbft.abci.v1beta3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<super::v1beta2::Event>,
/// the result of executing each transaction including the events
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -563,7 +563,7 @@ pub mod abci_server {
tonic::Response<super::super::v1beta2::ResponseProcessProposal>,
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<super::RequestExtendVote>,
Expand Down
2 changes: 1 addition & 1 deletion proto/src/prost/cometbft.blocksync.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct BlockResponse {
#[prost(message, optional, tag = "2")]
pub ext_commit: ::core::option::Option<super::super::types::v1::ExtendedCommit>,
}
/// 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 {
Expand Down
2 changes: 1 addition & 1 deletion proto/src/prost/cometbft.blocksync.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion proto/src/prost/cometbft.crypto.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 3 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,9 @@ pub struct SignVoteRequest {
pub vote: ::core::option::Option<super::super::types::v1::Vote>,
#[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 skip_extension_signing: bool,
}
/// SignedVoteResponse is a response containing a signed vote or an error
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
69 changes: 1 addition & 68 deletions proto/src/prost/cometbft.services.block.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -15,19 +15,6 @@ pub struct GetByHeightResponse {
#[prost(message, optional, tag = "2")]
pub block: ::core::option::Option<super::super::super::types::v1::Block>,
}
/// 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<super::super::super::types::v1::BlockId>,
#[prost(message, optional, tag = "2")]
pub block: ::core::option::Option<super::super::super::types::v1::Block>,
}
/// GetLatestHeightRequest - empty message since no parameter is required
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -57,14 +44,6 @@ pub mod block_service_server {
tonic::Response<super::GetByHeightResponse>,
tonic::Status,
>;
/// GetLatest retrieves the latest block.
async fn get_latest(
&self,
request: tonic::Request<super::GetLatestRequest>,
) -> std::result::Result<
tonic::Response<super::GetLatestResponse>,
tonic::Status,
>;
/// Server streaming response type for the GetLatestHeight method.
type GetLatestHeightStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::GetLatestHeightResponse, tonic::Status>,
Expand Down Expand Up @@ -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<T: BlockService>(pub Arc<T>);
impl<
T: BlockService,
> tonic::server::UnaryService<super::GetLatestRequest>
for GetLatestSvc<T> {
type Response = super::GetLatestResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetLatestRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as BlockService>::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<T: BlockService>(pub Arc<T>);
Expand Down
Loading
Loading