From 3d71e90f6901e030ecbbb6acc1e7357b409b6d94 Mon Sep 17 00:00:00 2001
From: Peter Nose <peter.nose@gmail.com>
Date: Thu, 12 Oct 2023 17:31:56 +0200
Subject: [PATCH] go/worker/common: Display additional information in the
 liveness status

---
 .changelog/5402.trivial.md         | 0
 go/roothash/api/liveness.go        | 4 ++--
 go/worker/common/api/api.go        | 8 ++++++++
 go/worker/common/committee/node.go | 2 ++
 4 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 .changelog/5402.trivial.md

diff --git a/.changelog/5402.trivial.md b/.changelog/5402.trivial.md
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/go/roothash/api/liveness.go b/go/roothash/api/liveness.go
index 5d35b556b1c..7f4e0ef5998 100644
--- a/go/roothash/api/liveness.go
+++ b/go/roothash/api/liveness.go
@@ -11,14 +11,14 @@ type LivenessStatistics struct {
 	LiveRounds []uint64 `json:"good_rounds"`
 
 	// FinalizedProposals is a list that records the number of finalized rounds when a node
-	// acted as a proposer.
+	// acted as a proposer with the highest rank.
 	//
 	// The list is ordered according to the committee arrangement (i.e., the counter at index i
 	// holds the value for the node at index i in the committee).
 	FinalizedProposals []uint64 `json:"finalized_proposals"`
 
 	// MissedProposals is a list that records the number of failed rounds when a node
-	// acted as a proposer.
+	// acted as a proposer with the highest rank.
 	//
 	// The list is ordered according to the committee arrangement (i.e., the counter at index i
 	// holds the value for the node at index i in the committee).
diff --git a/go/worker/common/api/api.go b/go/worker/common/api/api.go
index d4d6d4961f6..41e0a46ff7d 100644
--- a/go/worker/common/api/api.go
+++ b/go/worker/common/api/api.go
@@ -144,4 +144,12 @@ type LivenessStatus struct {
 
 	// LiveRounds is the number of rounds in which the node positively contributed.
 	LiveRounds uint64 `json:"live_rounds"`
+
+	// FinalizedProposals is the number of finalized rounds when a node acted as a proposer
+	// with the highest rank.
+	FinalizedProposals uint64 `json:"finalized_proposals"`
+
+	// MissedProposals is the number of failed rounds when a node acted as a proposer
+	// with the highest rank.
+	MissedProposals uint64 `json:"missed_proposals"`
 }
diff --git a/go/worker/common/committee/node.go b/go/worker/common/committee/node.go
index e105072d600..b4f2be18a31 100644
--- a/go/worker/common/committee/node.go
+++ b/go/worker/common/committee/node.go
@@ -320,6 +320,8 @@ func (n *Node) GetStatus() (*api.Status, error) {
 
 				for _, index := range cmte.Indices {
 					status.Liveness.LiveRounds += rs.LivenessStatistics.LiveRounds[index]
+					status.Liveness.FinalizedProposals += rs.LivenessStatistics.FinalizedProposals[index]
+					status.Liveness.MissedProposals += rs.LivenessStatistics.MissedProposals[index]
 				}
 			}
 		}