Skip to content

Commit

Permalink
ABCI++
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Manning committed May 24, 2021
1 parent 1175d4f commit e235296
Show file tree
Hide file tree
Showing 25 changed files with 977 additions and 539 deletions.
71 changes: 55 additions & 16 deletions abci/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ pub mod kvstore;

use tendermint_proto::abci::request::Value;
use tendermint_proto::abci::{
response, Request, RequestApplySnapshotChunk, RequestBeginBlock, RequestCheckTx,
RequestDeliverTx, RequestEcho, RequestEndBlock, RequestInfo, RequestInitChain,
RequestLoadSnapshotChunk, RequestOfferSnapshot, RequestQuery, Response,
ResponseApplySnapshotChunk, ResponseBeginBlock, ResponseCheckTx, ResponseCommit,
ResponseDeliverTx, ResponseEcho, ResponseEndBlock, ResponseFlush, ResponseInfo,
ResponseInitChain, ResponseListSnapshots, ResponseLoadSnapshotChunk, ResponseOfferSnapshot,
ResponseQuery,
response, Request, RequestApplySnapshotChunk, RequestCheckTx, RequestEcho, RequestExtendVote,
RequestFinalizeBlock, RequestInfo, RequestInitChain, RequestLoadSnapshotChunk,
RequestOfferSnapshot, RequestPrepareProposal, RequestProcessProposal, RequestQuery,
RequestRevertProposal, RequestVerifyHeader, RequestVerifyVoteExtension, Response,
ResponseApplySnapshotChunk, ResponseCheckTx, ResponseCommit, ResponseEcho, ResponseExtendVote,
ResponseFinalizeBlock, ResponseFlush, ResponseInfo, ResponseInitChain, ResponseListSnapshots,
ResponseLoadSnapshotChunk, ResponseOfferSnapshot, ResponsePrepareProposal,
ResponseProcessProposal, ResponseQuery, ResponseRevertProposal, ResponseVerifyHeader,
ResponseVerifyVoteExtension,
};

/// An ABCI application.
Expand Down Expand Up @@ -52,18 +54,41 @@ pub trait Application: Send + Clone + 'static {
Default::default()
}

/// Signals the beginning of a new block, prior to any `DeliverTx` calls.
fn begin_block(&self, _request: RequestBeginBlock) -> ResponseBeginBlock {
/// Finalize block
fn finalize_block(&self, _request: RequestFinalizeBlock) -> ResponseFinalizeBlock {
Default::default()
}

/// Apply a transaction to the application's state.
fn deliver_tx(&self, _request: RequestDeliverTx) -> ResponseDeliverTx {
/// Prepare proposal
fn prepare_proposal(&self, _request: RequestPrepareProposal) -> ResponsePrepareProposal {
Default::default()
}

/// Signals the end of a block.
fn end_block(&self, _request: RequestEndBlock) -> ResponseEndBlock {
/// Verify header
fn verify_header(&self, _request: RequestVerifyHeader) -> ResponseVerifyHeader {
Default::default()
}

/// Process proposal
fn process_proposal(&self, _request: RequestProcessProposal) -> ResponseProcessProposal {
Default::default()
}

/// Process proposal
fn revert_proposal(&self, _request: RequestRevertProposal) -> ResponseRevertProposal {
Default::default()
}

/// Extend vote
fn extend_vote(&self, _request: RequestExtendVote) -> ResponseExtendVote {
Default::default()
}

/// Verify vote extension
fn verify_vote_extension(
&self,
_request: RequestVerifyVoteExtension,
) -> ResponseVerifyVoteExtension {
Default::default()
}

Expand Down Expand Up @@ -120,10 +145,7 @@ impl<A: Application> RequestDispatcher for A {
Value::Info(req) => response::Value::Info(self.info(req)),
Value::InitChain(req) => response::Value::InitChain(self.init_chain(req)),
Value::Query(req) => response::Value::Query(self.query(req)),
Value::BeginBlock(req) => response::Value::BeginBlock(self.begin_block(req)),
Value::CheckTx(req) => response::Value::CheckTx(self.check_tx(req)),
Value::DeliverTx(req) => response::Value::DeliverTx(self.deliver_tx(req)),
Value::EndBlock(req) => response::Value::EndBlock(self.end_block(req)),
Value::Commit(_) => response::Value::Commit(self.commit()),
Value::ListSnapshots(_) => response::Value::ListSnapshots(self.list_snapshots()),
Value::OfferSnapshot(req) => {
Expand All @@ -135,6 +157,23 @@ impl<A: Application> RequestDispatcher for A {
Value::ApplySnapshotChunk(req) => {
response::Value::ApplySnapshotChunk(self.apply_snapshot_chunk(req))
}
Value::FinalizeBlock(req) => {
response::Value::FinalizeBlock(self.finalize_block(req))
}
Value::PrepareProposal(req) => {
response::Value::PrepareProposal(self.prepare_proposal(req))
}
Value::VerifyHeader(req) => response::Value::VerifyHeader(self.verify_header(req)),
Value::ProcessProposal(req) => {
response::Value::ProcessProposal(self.process_proposal(req))
}
Value::RevertProposal(req) => {
response::Value::RevertProposal(self.revert_proposal(req))
}
Value::ExtendVote(req) => response::Value::ExtendVote(self.extend_vote(req)),
Value::VerifyVoteExtension(req) => {
response::Value::VerifyVoteExtension(self.verify_vote_extension(req))
}
}),
}
}
Expand Down
4 changes: 2 additions & 2 deletions light-client/src/light_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ impl LightClient {
/// should be trusted based on a previously verified light block.
/// - When doing _forward_ verification, the Scheduler component decides which height to try to
/// verify next, in case the current block pass verification but cannot be trusted yet.
/// - When doing _backward_ verification, the Hasher component is used to determine
/// whether the `last_block_id` hash of a block matches the hash of the block right below it.
/// - When doing _backward_ verification, the Hasher component is used to determine whether the
/// `last_block_id` hash of a block matches the hash of the block right below it.
///
/// ## Implements
/// - [LCV-DIST-SAFE.1]
Expand Down
1 change: 1 addition & 0 deletions p2p/src/secret_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ impl Handshake<AwaitingAuthSig> {
ed25519::PublicKey::from_bytes(bytes).ok()
}
proto::crypto::public_key::Sum::Secp256k1(_) => None,
proto::crypto::public_key::Sum::Sr25519(_) => None,
})
.ok_or(Error::CryptoError)?;

Expand Down
161 changes: 114 additions & 47 deletions proto/src/prost/tendermint.abci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Request {
#[prost(oneof="request::Value", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14")]
#[prost(oneof="request::Value", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18")]
pub value: ::core::option::Option<request::Value>,
}
/// Nested message and enum types in `Request`.
Expand All @@ -25,23 +25,31 @@ pub mod request {
#[prost(message, tag="5")]
Query(super::RequestQuery),
#[prost(message, tag="6")]
BeginBlock(super::RequestBeginBlock),
FinalizeBlock(super::RequestFinalizeBlock),
#[prost(message, tag="7")]
CheckTx(super::RequestCheckTx),
#[prost(message, tag="8")]
DeliverTx(super::RequestDeliverTx),
Commit(super::RequestCommit),
#[prost(message, tag="9")]
EndBlock(super::RequestEndBlock),
ListSnapshots(super::RequestListSnapshots),
#[prost(message, tag="10")]
Commit(super::RequestCommit),
OfferSnapshot(super::RequestOfferSnapshot),
#[prost(message, tag="11")]
ListSnapshots(super::RequestListSnapshots),
LoadSnapshotChunk(super::RequestLoadSnapshotChunk),
#[prost(message, tag="12")]
OfferSnapshot(super::RequestOfferSnapshot),
ApplySnapshotChunk(super::RequestApplySnapshotChunk),
#[prost(message, tag="13")]
LoadSnapshotChunk(super::RequestLoadSnapshotChunk),
PrepareProposal(super::RequestPrepareProposal),
#[prost(message, tag="14")]
ApplySnapshotChunk(super::RequestApplySnapshotChunk),
VerifyHeader(super::RequestVerifyHeader),
#[prost(message, tag="15")]
ProcessProposal(super::RequestProcessProposal),
#[prost(message, tag="16")]
RevertProposal(super::RequestRevertProposal),
#[prost(message, tag="17")]
ExtendVote(super::RequestExtendVote),
#[prost(message, tag="18")]
VerifyVoteExtension(super::RequestVerifyVoteExtension),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -90,15 +98,7 @@ pub struct RequestQuery {
pub prove: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestBeginBlock {
#[prost(bytes="bytes", tag="1")]
pub hash: ::prost::bytes::Bytes,
#[prost(message, optional, tag="2")]
pub header: ::core::option::Option<super::types::Header>,
#[prost(message, optional, tag="3")]
pub last_commit_info: ::core::option::Option<LastCommitInfo>,
#[prost(message, repeated, tag="4")]
pub byzantine_validators: ::prost::alloc::vec::Vec<Evidence>,
pub struct RequestFinalizeBlock {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestCheckTx {
Expand All @@ -108,16 +108,6 @@ pub struct RequestCheckTx {
pub r#type: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestDeliverTx {
#[prost(bytes="bytes", tag="1")]
pub tx: ::prost::bytes::Bytes,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestEndBlock {
#[prost(int64, tag="1")]
pub height: i64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestCommit {
}
/// lists available snapshots
Expand Down Expand Up @@ -154,12 +144,47 @@ pub struct RequestApplySnapshotChunk {
#[prost(string, tag="3")]
pub sender: ::prost::alloc::string::String,
}
/// Prepare proposal
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestPrepareProposal {
}
/// Verify header
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestVerifyHeader {
#[prost(bool, tag="1")]
pub is_validator: bool,
}
/// Process proposal
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestProcessProposal {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestRevertProposal {
#[prost(uint64, tag="1")]
pub height: u64,
#[prost(uint64, tag="2")]
pub round: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestExtendVote {
#[prost(uint64, tag="1")]
pub height: u64,
#[prost(uint64, tag="2")]
pub round: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RequestVerifyVoteExtension {
#[prost(bytes="bytes", tag="1")]
pub signed_app_vote_data: ::prost::bytes::Bytes,
#[prost(bytes="bytes", tag="2")]
pub self_authenticating_app_vote_data: ::prost::bytes::Bytes,
}
//----------------------------------------
// Response types

#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Response {
#[prost(oneof="response::Value", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15")]
#[prost(oneof="response::Value", tags="1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19")]
pub value: ::core::option::Option<response::Value>,
}
/// Nested message and enum types in `Response`.
Expand All @@ -179,23 +204,31 @@ pub mod response {
#[prost(message, tag="6")]
Query(super::ResponseQuery),
#[prost(message, tag="7")]
BeginBlock(super::ResponseBeginBlock),
FinalizeBlock(super::ResponseFinalizeBlock),
#[prost(message, tag="8")]
CheckTx(super::ResponseCheckTx),
#[prost(message, tag="9")]
DeliverTx(super::ResponseDeliverTx),
Commit(super::ResponseCommit),
#[prost(message, tag="10")]
EndBlock(super::ResponseEndBlock),
ListSnapshots(super::ResponseListSnapshots),
#[prost(message, tag="11")]
Commit(super::ResponseCommit),
OfferSnapshot(super::ResponseOfferSnapshot),
#[prost(message, tag="12")]
ListSnapshots(super::ResponseListSnapshots),
LoadSnapshotChunk(super::ResponseLoadSnapshotChunk),
#[prost(message, tag="13")]
OfferSnapshot(super::ResponseOfferSnapshot),
ApplySnapshotChunk(super::ResponseApplySnapshotChunk),
#[prost(message, tag="14")]
LoadSnapshotChunk(super::ResponseLoadSnapshotChunk),
PrepareProposal(super::ResponsePrepareProposal),
#[prost(message, tag="15")]
ApplySnapshotChunk(super::ResponseApplySnapshotChunk),
VerifyHeader(super::ResponseVerifyHeader),
#[prost(message, tag="16")]
ProcessProposal(super::ResponseProcessProposal),
#[prost(message, tag="17")]
RevertProposal(super::ResponseRevertProposal),
#[prost(message, tag="18")]
ExtendVote(super::ResponseExtendVote),
#[prost(message, tag="19")]
VerifyVoteExtension(super::ResponseVerifyVoteExtension),
}
}
/// nondeterministic
Expand Down Expand Up @@ -265,9 +298,11 @@ pub struct ResponseQuery {
pub codespace: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseBeginBlock {
#[prost(message, repeated, tag="1")]
pub events: ::prost::alloc::vec::Vec<Event>,
pub struct ResponseFinalizeBlock {
#[prost(message, optional, tag="1")]
pub updates: ::core::option::Option<ConsensusUpdates>,
#[prost(message, repeated, tag="2")]
pub tx_results: ::prost::alloc::vec::Vec<ResponseTx>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseCheckTx {
Expand All @@ -291,7 +326,7 @@ pub struct ResponseCheckTx {
pub codespace: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseDeliverTx {
pub struct ResponseTx {
#[prost(uint32, tag="1")]
pub code: u32,
#[prost(bytes="bytes", tag="2")]
Expand All @@ -313,7 +348,7 @@ pub struct ResponseDeliverTx {
pub codespace: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseEndBlock {
pub struct ConsensusUpdates {
#[prost(message, repeated, tag="1")]
pub validator_updates: ::prost::alloc::vec::Vec<ValidatorUpdate>,
#[prost(message, optional, tag="2")]
Expand Down Expand Up @@ -393,6 +428,38 @@ pub mod response_apply_snapshot_chunk {
RejectSnapshot = 5,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponsePrepareProposal {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseVerifyHeader {
#[prost(bool, tag="1")]
pub accept_header: bool,
#[prost(message, repeated, tag="2")]
pub evidence: ::prost::alloc::vec::Vec<Evidence>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseProcessProposal {
#[prost(bool, tag="1")]
pub accept_block: bool,
#[prost(message, repeated, tag="2")]
pub evidence: ::prost::alloc::vec::Vec<Evidence>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseRevertProposal {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseExtendVote {
#[prost(bytes="bytes", tag="1")]
pub unsigned_app_vote_data: ::prost::bytes::Bytes,
#[prost(bytes="bytes", tag="2")]
pub self_authenticating_app_data: ::prost::bytes::Bytes,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResponseVerifyVoteExtension {
#[prost(bool, tag="1")]
pub result: bool,
}
//----------------------------------------
// Misc.

Expand All @@ -416,10 +483,10 @@ pub struct Event {
/// EventAttribute is a single key-value pair, associated with an event.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EventAttribute {
#[prost(bytes="bytes", tag="1")]
pub key: ::prost::bytes::Bytes,
#[prost(bytes="bytes", tag="2")]
pub value: ::prost::bytes::Bytes,
#[prost(string, tag="1")]
pub key: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub value: ::prost::alloc::string::String,
/// nondeterministic
#[prost(bool, tag="3")]
pub index: bool,
Expand All @@ -436,7 +503,7 @@ pub struct TxResult {
#[prost(bytes="bytes", tag="3")]
pub tx: ::prost::bytes::Bytes,
#[prost(message, optional, tag="4")]
pub result: ::core::option::Option<ResponseDeliverTx>,
pub result: ::core::option::Option<ResponseTx>,
}
//----------------------------------------
// Blockchain Types
Expand Down
Loading

0 comments on commit e235296

Please sign in to comment.