Skip to content

Commit

Permalink
update node status proto with running flag, fix block ver reported
Browse files Browse the repository at this point in the history
  • Loading branch information
jchappelow committed Oct 5, 2023
1 parent f1dea6d commit 8a57e18
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 68 deletions.
136 changes: 73 additions & 63 deletions api/protobuf/admin/v0/messages.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions internal/app/kwild/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func convertNodeInfo(ni *p2p.DefaultNodeInfo) *types.NodeInfo {
NodeID: string(ni.ID()),
ProtocolVersion: ni.ProtocolVersion.P2P,
AppVersion: ni.ProtocolVersion.App,
BlockVersion: ni.ProtocolVersion.App,
BlockVersion: ni.ProtocolVersion.Block,
ListenAddr: ni.ListenAddr,
RPCAddr: ni.Other.RPCAddress,
}
Expand Down Expand Up @@ -123,7 +123,8 @@ func (wc *wrappedCometBFTClient) Status(ctx context.Context) (*types.Status, err
}
ni, si, vi := &cmtStatus.NodeInfo, &cmtStatus.SyncInfo, &cmtStatus.ValidatorInfo
return &types.Status{
Node: convertNodeInfo(ni),
Running: wc.cl.IsRunning(),
Node: convertNodeInfo(ni),
Sync: &types.SyncInfo{
AppHash: strings.ToLower(si.LatestAppHash.String()),
BestBlockHash: strings.ToLower(si.LatestBlockHash.String()),
Expand Down
1 change: 1 addition & 0 deletions internal/controller/grpc/admin/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (svc *Service) Status(ctx context.Context, req *admpb.StatusRequest) (*admp
return nil, err
}
return &admpb.StatusResponse{
Running: status.Running,
Node: convertNodeInfo(status.Node),
Sync: convertSyncInfo(status.Sync),
Validator: convertValidatorInfo(status.Validator),
Expand Down
12 changes: 11 additions & 1 deletion pkg/admin/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package types

import "time"

// NodeInfo describes a peer node. This may be a peer or a node being
// administered.
type NodeInfo struct {
ChainID string `json:"chain_id"`
Name string `json:"name"`
Expand All @@ -13,6 +15,7 @@ type NodeInfo struct {
RPCAddr string `json:"rpc_addr"`
}

// SyncInfo describes the sync state of a node.
type SyncInfo struct {
AppHash string `json:"app_hash"`
BestBlockHash string `json:"best_block_hash"`
Expand All @@ -22,18 +25,25 @@ type SyncInfo struct {
Syncing bool `json:"syncing"`
}

// ValidatorInfo describes a validator node.
type ValidatorInfo struct {
PubKey HexBytes `json:"pubkey"`
PubKeyType string `json:"pubkey_type"`
Power int64 `json:"power"`
}

// Status includes a comprehensive summary of a nodes status, including if the
// service is running, it's best block and if it is syncing, it's identity on
// the network, and the node's validator identity if it is one. Note that our
// validator is part of the node rather than an external signer.
type Status struct {
Running bool `json:"running"`
Node *NodeInfo `json:"node"`
Sync *SyncInfo `json:"sync"`
Validator *ValidatorInfo `json:"current_validator"`
Validator *ValidatorInfo `json:"validator"`
}

// PeerInfo describes a connected peer node.
type PeerInfo struct {
NodeInfo *NodeInfo `json:"node"`
Inbound bool `json:"inbound"`
Expand Down
3 changes: 2 additions & 1 deletion pkg/grpc/client/admin/v0/admin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func (c *AdminClient) Status(ctx context.Context) (*types.Status, error) {
return nil, err
}
return &types.Status{
Node: convertNodeInfo(resp.Node),
Running: resp.Running,
Node: convertNodeInfo(resp.Node),
Sync: &types.SyncInfo{
AppHash: resp.Sync.AppHash,
BestBlockHash: resp.Sync.BestBlockHash,
Expand Down
2 changes: 1 addition & 1 deletion proto

0 comments on commit 8a57e18

Please sign in to comment.