Skip to content

Commit 1bcd02f

Browse files
committed
go/consensus: Show a list of available checkpoints
1 parent 92292a2 commit 1bcd02f

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

.changelog/5265.feature.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
go/oasis-node: Display consensus checkpoint heights
2+
3+
A new field `checkpoint_heights` has been added to the
4+
`oasis-node control status` output under the `consensus` status section.
5+
Unless node has no local checkpoints, this field displays a list of local
6+
checkpoint heights.

go/consensus/api/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ type Status struct { // nolint: maligned
375375

376376
// P2P is the P2P status of the node.
377377
P2P *P2PStatus `json:"p2p,omitempty"`
378+
379+
// CheckpointHeights is the list of node's local checkpoint heights.
380+
CheckpointHeights []uint64 `json:"checkpoint_heights,omitempty"`
378381
}
379382

380383
// P2PStatus is the P2P status of a node.

go/consensus/cometbft/full/common.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,18 @@ func (n *commonNode) GetStatus(ctx context.Context) (*consensusAPI.Status, error
840840
// Failed to load validator set.
841841
status.IsValidator = false
842842
}
843+
844+
cps, err := n.mux.State().Storage().GetCheckpoints(ctx, &checkpoint.GetCheckpointsRequest{
845+
Version: 1,
846+
})
847+
switch err {
848+
case nil:
849+
for _, cp := range cps {
850+
status.CheckpointHeights = append(status.CheckpointHeights, cp.Root.Version)
851+
}
852+
default:
853+
return nil, fmt.Errorf("failed to fetch checkpoints: %w", err)
854+
}
843855
}
844856

845857
return status, nil

0 commit comments

Comments
 (0)