From db3044ff3c6eef4f23d561d425b80969512084e1 Mon Sep 17 00:00:00 2001 From: mempirate Date: Thu, 27 Jan 2022 16:24:01 +0100 Subject: [PATCH] rpc: add application info to `status` call (#7701) * rpc/coretypes: add `ApplicationInfo` to `ResultStatus` * internal/rpc/core: return application version Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com> Co-authored-by: M. J. Fromberger --- CHANGELOG_PENDING.md | 1 + internal/rpc/core/status.go | 9 ++++++++- rpc/coretypes/responses.go | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 47f26f2c2..922ed09e3 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -47,6 +47,7 @@ Special thanks to external contributors on this release: ### FEATURES - [rpc] [\#7270](https://github.com/tendermint/tendermint/pull/7270) Add `header` and `header_by_hash` RPC Client queries. (@fedekunze) +- [rpc] [\#7701] Add `ApplicationInfo` to `status` rpc call which contains the application version. (@jonasbostoen) - [cli] [#7033](https://github.com/tendermint/tendermint/pull/7033) Add a `rollback` command to rollback to the previous tendermint state in the event of non-determinstic app hash or reverting an upgrade. - [mempool, rpc] \#7041 Add removeTx operation to the RPC layer. (@tychoish) - [consensus] \#7354 add a new `synchrony` field to the `ConsensusParameter` struct for controlling the parameters of the proposer-based timestamp algorithm. (@williambanfield) diff --git a/internal/rpc/core/status.go b/internal/rpc/core/status.go index 44a2b7469..2f648978a 100644 --- a/internal/rpc/core/status.go +++ b/internal/rpc/core/status.go @@ -3,6 +3,7 @@ package core import ( "bytes" "context" + "fmt" "time" tmbytes "github.com/tendermint/tendermint/libs/bytes" @@ -59,8 +60,14 @@ func (env *Environment) Status(ctx context.Context) (*coretypes.ResultStatus, er } } + var applicationInfo coretypes.ApplicationInfo + if abciInfo, err := env.ABCIInfo(ctx); err == nil { + applicationInfo.Version = fmt.Sprint(abciInfo.Response.AppVersion) + } + result := &coretypes.ResultStatus{ - NodeInfo: env.P2PTransport.NodeInfo(), + NodeInfo: env.P2PTransport.NodeInfo(), + ApplicationInfo: applicationInfo, SyncInfo: coretypes.SyncInfo{ LatestBlockHash: latestBlockHash, LatestAppHash: latestAppHash, diff --git a/rpc/coretypes/responses.go b/rpc/coretypes/responses.go index 39a2755e9..a25d348e3 100644 --- a/rpc/coretypes/responses.go +++ b/rpc/coretypes/responses.go @@ -116,6 +116,10 @@ type SyncInfo struct { BackFillBlocksTotal int64 `json:"backfill_blocks_total,string"` } +type ApplicationInfo struct { + Version string `json:"version"` +} + // Info about the node's validator type ValidatorInfo struct { Address bytes.HexBytes @@ -155,6 +159,7 @@ func (v *ValidatorInfo) UnmarshalJSON(data []byte) error { // Node Status type ResultStatus struct { NodeInfo types.NodeInfo `json:"node_info"` + ApplicationInfo ApplicationInfo `json:"application_info,omitempty"` SyncInfo SyncInfo `json:"sync_info"` ValidatorInfo ValidatorInfo `json:"validator_info"` LightClientInfo types.LightClientInfo `json:"light_client_info,omitempty"`