From 32119dfed66dd605511fe6269381a9e55b7b3292 Mon Sep 17 00:00:00 2001 From: Martin Dyring-Andersen Date: Wed, 14 Jun 2023 08:10:15 +0200 Subject: [PATCH 1/2] Provide earliest block information from /status RPC --- rpc/src/endpoint/status.rs | 14 ++++++++++++++ rpc/tests/kvstore_fixtures/v0_34.rs | 13 +++++++++++++ rpc/tests/kvstore_fixtures/v0_37.rs | 13 +++++++++++++ 3 files changed, 40 insertions(+) diff --git a/rpc/src/endpoint/status.rs b/rpc/src/endpoint/status.rs index 2850eec13..409efb37a 100644 --- a/rpc/src/endpoint/status.rs +++ b/rpc/src/endpoint/status.rs @@ -41,6 +41,20 @@ impl crate::Response for Response {} /// Sync information #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SyncInfo { + /// Earliest block hash + #[serde(with = "tendermint::serializers::hash")] + pub earliest_block_hash: Hash, + + /// Earliest app hash + #[serde(with = "tendermint::serializers::apphash")] + pub earliest_app_hash: AppHash, + + /// Earliest block height + pub earliest_block_height: block::Height, + + /// Earliest block time + pub earliest_block_time: Time, + /// Latest block hash #[serde(with = "tendermint::serializers::hash")] pub latest_block_hash: Hash, diff --git a/rpc/tests/kvstore_fixtures/v0_34.rs b/rpc/tests/kvstore_fixtures/v0_34.rs index 8b8d528ab..9cef68d1f 100644 --- a/rpc/tests/kvstore_fixtures/v0_34.rs +++ b/rpc/tests/kvstore_fixtures/v0_34.rs @@ -710,11 +710,24 @@ fn incoming_fixtures() { ); assert_eq!(result.node_info.version.to_string(), "0.34.21"); assert!(!result.sync_info.catching_up); + assert!(result.sync_info.earliest_app_hash.as_bytes().is_empty()); + assert!(!result.sync_info.earliest_block_hash.is_empty()); + assert_eq!(result.sync_info.earliest_block_height.value(), 1); + assert!( + result + .sync_info + .earliest_block_time + .duration_since(informal_epoch) + .unwrap() + .as_secs() + > 0 + ); assert_eq!( result.sync_info.latest_app_hash.as_bytes(), [6, 0, 0, 0, 0, 0, 0, 0] ); assert!(!result.sync_info.latest_block_hash.is_empty()); + assert_eq!(result.sync_info.latest_block_height.value(), 67); assert!( result .sync_info diff --git a/rpc/tests/kvstore_fixtures/v0_37.rs b/rpc/tests/kvstore_fixtures/v0_37.rs index 9d2fa3550..102bcce03 100644 --- a/rpc/tests/kvstore_fixtures/v0_37.rs +++ b/rpc/tests/kvstore_fixtures/v0_37.rs @@ -709,11 +709,24 @@ fn incoming_fixtures() { ); assert_eq!(result.node_info.version.to_string(), "0.37.0-alpha.3"); assert!(!result.sync_info.catching_up); + assert!(result.sync_info.earliest_app_hash.as_bytes().is_empty()); + assert!(!result.sync_info.earliest_block_hash.is_empty()); + assert_eq!(result.sync_info.earliest_block_height.value(), 1); + assert!( + result + .sync_info + .earliest_block_time + .duration_since(informal_epoch) + .unwrap() + .as_secs() + > 0 + ); assert_eq!( result.sync_info.latest_app_hash.as_bytes(), [6, 0, 0, 0, 0, 0, 0, 0] ); assert!(!result.sync_info.latest_block_hash.is_empty()); + assert_eq!(result.sync_info.latest_block_height.value(), 53); assert!( result .sync_info From 93a3ea2dc948c57f598dcf17b706518830a55853 Mon Sep 17 00:00:00 2001 From: Mikhail Zabaluev Date: Wed, 14 Jun 2023 12:28:35 +0300 Subject: [PATCH 2/2] Changelog entry for #1321 --- .../breaking-changes/1321-status-earliest-block.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changelog/unreleased/breaking-changes/1321-status-earliest-block.md diff --git a/.changelog/unreleased/breaking-changes/1321-status-earliest-block.md b/.changelog/unreleased/breaking-changes/1321-status-earliest-block.md new file mode 100644 index 000000000..6d752c9f7 --- /dev/null +++ b/.changelog/unreleased/breaking-changes/1321-status-earliest-block.md @@ -0,0 +1,5 @@ +- [`tendermint-rpc`] Decode the earliest block data fields of the `sync_info` + object in `/status` response and expose them in the `SyncInfo` struct: + `earliest_block_hash`, `earliest_app_hash`, `earliest_block_height`, + `earliest_block_time` + ([\#1321](https://github.com/informalsystems/tendermint-rs/pull/1321)).