Skip to content

Commit

Permalink
RPC: Provide earliest block information from /status (#1321)
Browse files Browse the repository at this point in the history
* Provide earliest block information from /status RPC

---------

Co-authored-by: Mikhail Zabaluev <mikhail@informal.systems>
  • Loading branch information
mdyring and mzabaluev authored Jun 14, 2023
1 parent 32dad52 commit dba8242
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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)).
14 changes: 14 additions & 0 deletions rpc/src/endpoint/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions rpc/tests/kvstore_fixtures/v0_34.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions rpc/tests/kvstore_fixtures/v0_37.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dba8242

Please sign in to comment.