Skip to content

Commit 4bf310b

Browse files
committed
Add ABCI domain types.
These types mirror the generated types in tendermint_proto, but have better naming. The documentation for each request type is adapted from the ABCI Methods and Types spec document. However, the same logical request may appear three times, as a struct with the request data, as a Request variant, and as a CategoryRequest variant. To avoid duplication, this PR uses the `#[doc = include_str!(...)]` functionality stabilized in Rust 1.54 to keep common definitions of the documentation.
1 parent 1848cbc commit 4bf310b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3034
-0
lines changed

tendermint/src/abci.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//! Application BlockChain Interface ([ABCI]) is the interface between Tendermint
2+
//! (a consensus engine for Byzantine-fault-tolerant replication of a state
3+
//! machine) and an application (the state machine to be replicated).
4+
//!
5+
//! Using ABCI involves writing an application driven by ABCI methods, exposing
6+
//! that application as an ABCI server, and having Tendermint connect to the
7+
//! server as an ABCI client.
8+
//!
9+
//! This module does not include an ABCI server implementation itself. Instead,
10+
//! it provides a common set of Rust domain types that model the ABCI protocol,
11+
//! which can be used by both ABCI applications and ABCI server implementations.
12+
//!
13+
//! One ABCI server implementation is provided by the [`tendermint_abci`][tmabci]
14+
//! crate.
15+
//!
16+
//! Each ABCI method corresponds to a request/response pair. ABCI requests are
17+
//! modeled by the [`Request`] enum, and responses are modeled by the
18+
//! [`Response`] enum. As described in the [methods and types][mat] page, ABCI
19+
//! methods are split into four categories. Tendermint opens one ABCI connection
20+
//! for each category of messages. These categories are modeled by the
21+
//! [`MethodKind`] enum and by per-category request and response enums:
22+
//!
23+
//! * [`ConsensusRequest`] / [`ConsensusResponse`] for [`MethodKind::Consensus`] methods;
24+
//! * [`MempoolRequest`] / [`MempoolResponse`] for [`MethodKind::Mempool`] methods;
25+
//! * [`InfoRequest`] / [`InfoResponse`] for [`MethodKind::Info`] methods;
26+
//! * [`SnapshotRequest`] / [`SnapshotResponse`] for [`MethodKind::Snapshot`] methods.
27+
//!
28+
//! The domain types in this module have conversions to and from the Protobuf
29+
//! types defined in the [`tendermint_proto`] crate. These conversions are
30+
//! required for ABCI server implementations, which use the protobufs to
31+
//! communicate with Tendermint, but should not be required for ABCI
32+
//! applications, which should use the domain types in an interface defined by
33+
//! their choice of ABCI server implementation.
34+
//!
35+
//! [ABCI]: https://docs.tendermint.com/master/spec/abci/
36+
//! [mat]: https://docs.tendermint.com/master/spec/abci/abci.html
37+
//! [tmabci]: https://github.com/informalsystems/tendermint-rs/tree/master/abci
38+
39+
mod event;
40+
mod kind;
41+
42+
pub mod params;
43+
pub mod request;
44+
pub mod response;
45+
pub mod types;
46+
47+
pub use event::{Event, EventAttribute, EventAttributeIndexExt};
48+
49+
#[doc(inline)]
50+
pub use self::{
51+
kind::MethodKind,
52+
request::{ConsensusRequest, InfoRequest, MempoolRequest, Request, SnapshotRequest},
53+
response::{ConsensusResponse, InfoResponse, MempoolResponse, Response, SnapshotResponse},
54+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Applies a snapshot chunk.
2+
3+
The application can choose to refetch chunks and/or ban P2P peers as
4+
appropriate. Tendermint will not do this unless instructed by the
5+
application.
6+
7+
The application may want to verify each chunk, e.g., by attaching chunk
8+
hashes in [`Snapshot::metadata`] and/or incrementally verifying contents
9+
against `app_hash`.
10+
11+
When all chunks have been accepted, Tendermint will make an ABCI [`Info`]
12+
request to verify that `last_block_app_hash` and `last_block_height` match
13+
the expected values, and record the `app_version` in the node state. It then
14+
switches to fast sync or consensus and joins the network.
15+
16+
If Tendermint is unable to retrieve the next chunk after some time (e.g.,
17+
because no suitable peers are available), it will reject the snapshot and try
18+
a different one via `OfferSnapshot`. The application should be prepared to
19+
reset and accept it or abort as appropriate.
20+
21+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#applysnapshotchunk)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Signals the beginning of a new block.
2+
3+
Called prior to any [`DeliverTx`]s. The `header` contains the height,
4+
timestamp, and more -- it exactly matches the Tendermint block header.
5+
6+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#beginblock)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Check whether a transaction should be included in the mempool.
2+
3+
`CheckTx` is not involved in processing blocks, only in deciding whether a
4+
transaction should be included in the mempool. Every node runs `CheckTx`
5+
before adding a transaction to its local mempool. The transaction may come
6+
from an external user or another node. `CheckTx` need not execute the
7+
transaction in full, but can instead perform lightweight or statateful
8+
validation (e.g., checking signatures or account balances) instead of more
9+
expensive checks (like running code in a virtual machine).
10+
11+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#checktx)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Signals the application that it can write the queued state transitions
2+
from the block to its state.
3+
4+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#commit)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Execute a transaction against the application state.
2+
3+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#delivertx)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Echoes a string to test an ABCI implementation.
2+
3+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#echo)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Signals the end of a block.
2+
3+
Called after all transactions, and prior to each `Commit`.
4+
5+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#endblock)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Indicates that any pending requests should be completed and their responses flushed.
2+
3+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#flush)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Requests information about the application state.
2+
3+
[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#info)

0 commit comments

Comments
 (0)