Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC: Provide earliest block information from /status #1321

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
mdyring marked this conversation as resolved.
Show resolved Hide resolved
#[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