forked from informalsystems/tendermint-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebase ABCI Domain Types onto v0.34.20 branch.
There are two issues to fix: * The original ABCI domain types work used `chrono`; this temporarily re-adds `chrono` as a dependency, so that the changes that eliminated it can be replayed on top of this rebasing. * The original ABCI domain types work was, for some reason, mixed in with changes to the RPC test harness for 0.35 compatibility, and that may break this code. I didn't attempt to fix this, because I didn't touch the RPC tests when writing the ABCI domain types. Original concatenation of commit messages follows: Add domain types (updated) and fix integration tests for Tendermint v0.35.0 (informalsystems#1022) * tendermint: add From<Infallible> for Error * Use hex for AppHash Debug formatting * Regenerate protobuf types using tools/proto-compiler. * Regenerate protos against tendermint v0.35.0-rc3. * Remove SetOption-related code in tendermint-abci. * Update imports to reflect protobuf movements. The BlockParams and ConsensusParams structs moved out of the ABCI protos. * Update tendermint-abci to reflect upstream proto changes. * p2p: treat all non-Ed25519 keys as unsupported This fixes a compile error introduced by upstream proto changes that add an Sr25519 variant. * Improve ABCI response code modeling with NonZeroU32 The previous data modeling allowed a user to construct an `Err(0)` value that would be serialized and deserialized as `Ok`. * Use the Bytes type in ABCI protos. * Add conversions between protobuf and chrono types. * tendermint: define Serde for Block in terms of RawBlock This changes the Serialize/Deserialize implementations for Block to convert to/from the proto-generated `RawBlock`, and use the derived serialization for that type. This is much cleaner and more maintainable than keeping Serde annotations for each sub-member of the data structure, because all of the serialization code is kept in one place, and there's only one validation path (the TryFrom conversion from RawBlock to Block) that applies to both kinds of serialization. * tendermint: simpler transaction modeling in Block This changes the Block type to hold the transactions as a plain `Vec<Vec<u8>>`, rather than as a custom `abci::transaction::Data` type (which is itself a wrapper for an `Option<Vec<Transaction>>`, the `Transaction` type being a wrapper for a `Vec<u8>`). This also updates the `Block` getter functions; it's not clear (to me) why they're there, since they access the public fields and aren't used anywhere else. * rpc: take over tendermint::abci The existing contents of the `tendermint::abci` module note that they're only for the purpose of implementing the RPC endpoints, not a general ABCI implementation. Moving that code from the `tendermint` crate to the `tendermint-rpc` crate decouples the RPC interface from improvements to the ABCI domain modeling. Eventually, it would be good to eliminate this code and align it with the new ABCI domain types. * tendermint: 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. * tendermint: eliminate &'static str errors in ABCI domain types. * Merge `abci::params::ConsensusParams` with `consensus::Params`. The code in the `abci` module had more complete documentation from the ABCI docs, so I copied it onto the existing structure. * Add hex encoding Serde attribute to Sr25519 keys. * Replace integers with `block::Height`, `vote::Power` * Replace integer with block::Round * Fix tools build by using correct imports Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix clippy complaints in tools Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix clippy warning Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix clippy lints Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix more clippy lints Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix deprecation notices from ed25519 crate Signed-off-by: Thane Thomson <connect@thanethomson.com> * Regenerate protos for Tendermint v0.35.0 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix raw bytes conversion in tests/docs Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add Tendermint v0.35.0 Docker config Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add Tendermint v0.35.0 Docker image for ABCI integration testing Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove RPC deserialization tests The support files for these tests were manually generated some time ago. We should rather favour testing with the `kvstore_fixtures` tests, whose fixtures are automatically generated by our rpc-probe tool. Signed-off-by: Thane Thomson <connect@thanethomson.com> * Reformat Docker folder readme Signed-off-by: Thane Thomson <connect@thanethomson.com> * Bump version of Tendermint used in ABCI integration test Signed-off-by: Thane Thomson <connect@thanethomson.com> * Bump version of Tendermint used in rpc probe Signed-off-by: Thane Thomson <connect@thanethomson.com> * Bump version of Tendermint used in kvstore integration test Signed-off-by: Thane Thomson <connect@thanethomson.com> * Bump version of Tendermint used in proto-compiler Signed-off-by: Thane Thomson <connect@thanethomson.com> * Regenerate kvstore fixtures with rpc-probe for Tendermint v0.35.0 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update kvstore integration test to accommodate newly generated fixtures Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update RPC tests and data structures to accommodate Tendermint v0.35.0 changes Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update ABCI encoding scheme to accommodate breaking change in tendermint/tendermint#5783 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Bump Tendermint version in GitHub Actions kvstore integration test Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add changelog entries to capture breaking changes Signed-off-by: Thane Thomson <connect@thanethomson.com> * Change tx hash encoding from base64 to hex and update tests Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add changelog entry for /tx endpoint change Signed-off-by: Thane Thomson <connect@thanethomson.com> Co-authored-by: Henry de Valence <hdevalence@penumbra.zone> Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
- Loading branch information
1 parent
2f2e868
commit 84367a6
Showing
218 changed files
with
5,094 additions
and
2,607 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Updated integration testing to test against Tendermint v0.35.0 | ||
([#862](https://github.com/informalsystems/tendermint-rs/issues/862)) |
2 changes: 2 additions & 0 deletions
2
.changelog/unreleased/breaking-changes/862-abci-domain-types.md
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,2 @@ | ||
- `[tendermint]` Added domain types for ABCI | ||
([#862](https://github.com/informalsystems/tendermint-rs/issues/862)) |
3 changes: 3 additions & 0 deletions
3
.changelog/unreleased/breaking-changes/862-abci-wire-protocol.md
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,3 @@ | ||
- `[tendermint-abci]` Changed low-level wire encoding protocol to | ||
accommodate <https://github.com/tendermint/tendermint/issues/5783> | ||
([#862](https://github.com/informalsystems/tendermint-rs/issues/862)) |
5 changes: 5 additions & 0 deletions
5
.changelog/unreleased/breaking-changes/862-rpc-event-events.md
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,5 @@ | ||
- `[tendermint-rpc]` The `event::Event::events` field is now represented as | ||
`Option<Vec<crate::abci::Event>>` as opposed to `Option<HashMap<String, | ||
Vec<String>>>` to accommodate breaking change in Tendermint v0.35.0 | ||
subscription interface ([#862](https://github.com/informalsystems/tendermint- | ||
rs/issues/862)) |
3 changes: 3 additions & 0 deletions
3
.changelog/unreleased/breaking-changes/862-rpc-tx-hash-hex.md
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,3 @@ | ||
- `[tendermint-rpc]` The `/tx` endpoint now encodes | ||
the `hash` parameter as hexadecimal instead of base64 | ||
([#862](https://github.com/informalsystems/tendermint-rs/issues/862)) |
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
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
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
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
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
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,53 @@ | ||
use core::convert::TryInto; | ||
|
||
use chrono::{DateTime, Duration, TimeZone, Utc}; | ||
|
||
use crate::google::protobuf as pb; | ||
|
||
impl From<DateTime<Utc>> for pb::Timestamp { | ||
fn from(dt: DateTime<Utc>) -> pb::Timestamp { | ||
pb::Timestamp { | ||
seconds: dt.timestamp(), | ||
// This can exceed 1_000_000_000 in the case of a leap second, but | ||
// even with a leap second it should be under 2_147_483_647. | ||
nanos: dt | ||
.timestamp_subsec_nanos() | ||
.try_into() | ||
.expect("timestamp_subsec_nanos bigger than i32::MAX"), | ||
} | ||
} | ||
} | ||
|
||
impl From<pb::Timestamp> for DateTime<Utc> { | ||
fn from(ts: pb::Timestamp) -> DateTime<Utc> { | ||
Utc.timestamp(ts.seconds, ts.nanos as u32) | ||
} | ||
} | ||
|
||
// Note: we convert a protobuf::Duration into a chrono::Duration, not a | ||
// std::time::Duration, because std::time::Durations are unsigned, but the | ||
// protobuf duration is signed. | ||
|
||
impl From<Duration> for pb::Duration { | ||
fn from(d: Duration) -> pb::Duration { | ||
// chrono's Duration stores the fractional part as `nanos: i32` | ||
// internally but doesn't provide a way to access it, only a way to get | ||
// the *total* number of nanoseconds. so we have to do this cool and fun | ||
// hoop-jumping maneuver | ||
let seconds = d.num_seconds(); | ||
let nanos = (d - Duration::seconds(seconds)) | ||
.num_nanoseconds() | ||
.expect("we computed the fractional part, so there's no overflow") | ||
.try_into() | ||
.expect("the fractional part fits in i32"); | ||
|
||
pb::Duration { seconds, nanos } | ||
} | ||
} | ||
|
||
impl From<pb::Duration> for Duration { | ||
fn from(d: pb::Duration) -> Duration { | ||
// there's no constructor that supplies both at once | ||
Duration::seconds(d.seconds) + Duration::nanoseconds(d.nanos as i64) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ pub mod google { | |
} | ||
} | ||
|
||
mod chrono; | ||
mod error; | ||
#[allow(warnings)] | ||
mod tendermint; | ||
|
Oops, something went wrong.