-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tendermint: v0.38 ABCI requests and responses
Add the v0_38::abci::{Request,Response} enums and the new domain types representing request and response messages added in CometBFT 0.38.
- Loading branch information
Showing
30 changed files
with
1,214 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#extendvote) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#finalizeblock) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#verifyvoteextension) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#extendvote) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#finalizeblock) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ABCI documentation](https://github.com/cometbft/cometbft/blob/v0.38.x/spec/abci/abci++_methods.md#verifyvoteextension) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ExtendVote> for pb::abci::RequestExtendVote { | ||
fn from(extend_vote: ExtendVote) -> Self { | ||
Self { | ||
hash: extend_vote.hash.into(), | ||
height: extend_vote.height.into(), | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<pb::abci::RequestExtendVote> for ExtendVote { | ||
type Error = crate::Error; | ||
|
||
fn try_from(message: pb::abci::RequestExtendVote) -> Result<Self, Self::Error> { | ||
Ok(Self { | ||
hash: message.hash.try_into()?, | ||
height: message.height.try_into()?, | ||
}) | ||
} | ||
} | ||
|
||
impl Protobuf<pb::abci::RequestExtendVote> for ExtendVote {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Bytes>, | ||
/// 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<Misbehavior>, | ||
/// 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<FinalizeBlock> 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<pb::abci::RequestFinalizeBlock> for FinalizeBlock { | ||
type Error = Error; | ||
|
||
fn try_from(message: pb::abci::RequestFinalizeBlock) -> Result<Self, Self::Error> { | ||
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::<Result<_, _>>()?, | ||
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<pb::abci::RequestFinalizeBlock> for FinalizeBlock {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.