Skip to content

Commit c7ea2ff

Browse files
authored
rename log-fields according to latest SSV changes (#112)
* rename log-fields according to latest SSV changes * preserve backward-compatibility
1 parent f2fba67 commit c7ea2ff

File tree

8 files changed

+82
-73
lines changed

8 files changed

+82
-73
lines changed

internal/analyzer/parser/commit/log.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import (
77
)
88

99
type commitLogEntry struct {
10-
Timestamp parser.MultiFormatTime `json:"T"`
11-
Round uint8 `json:"round"`
12-
DutyID string `json:"duty_id"`
13-
Message string `json:"M"`
14-
CommitSigners []parser.SignerID `json:"commit_signers"` //NOTE: This array always contains 1 item
10+
Timestamp parser.MultiFormatTime `json:"T"`
11+
// Round is deprecated by https://github.com/ssvlabs/ssv/pull/2453#discussion_r2287196265 but kept for now
12+
// for backward-compatibility, use QBFTRound instead (we can remove Round later).
13+
Round uint8 `json:"round"`
14+
QBFTRound uint8 `json:"qbft_round"`
15+
DutyID string `json:"duty_id"`
16+
Message string `json:"M"`
17+
CommitSigners []parser.SignerID `json:"commit_signers"` //NOTE: This array always contains 1 item
1518
}
1619

1720
func (p *commitLogEntry) UnmarshalJSON(data []byte) error {

internal/analyzer/parser/commit/log_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import (
1212
func Test_GivenCommitLogEntry_WhenMultipleSignersFormats_ThenUnmarshalSucceeds(t *testing.T) {
1313
jsonData1 := `{
1414
"T": "2024-09-27T05:48:39.348Z",
15-
"round": 1,
15+
"qbft_round": 1,
1616
"duty_id": "1234",
1717
"M": "Commit message",
1818
"commit_signers": [1, 2, 3]
1919
}`
2020

2121
jsonData2 := `{
2222
"T": "2024-09-27T05:48:39.348Z",
23-
"round": 1,
23+
"qbft_round": 1,
2424
"duty_id": "1234",
2525
"M": "Commit message",
2626
"commit-signers": [4, 5, 6]
@@ -40,7 +40,7 @@ func Test_GivenCommitLogEntry_WhenMultipleSignersFormats_ThenUnmarshalSucceeds(t
4040
input: jsonData1,
4141
expected: commitLogEntry{
4242
Timestamp: expectedTime,
43-
Round: 1,
43+
QBFTRound: 1,
4444
DutyID: "1234",
4545
Message: "Commit message",
4646
CommitSigners: []parser.SignerID{1, 2, 3},
@@ -52,7 +52,7 @@ func Test_GivenCommitLogEntry_WhenMultipleSignersFormats_ThenUnmarshalSucceeds(t
5252
input: jsonData2,
5353
expected: commitLogEntry{
5454
Timestamp: expectedTime,
55-
Round: 1,
55+
QBFTRound: 1,
5656
DutyID: "1234",
5757
Message: "Commit message",
5858
CommitSigners: []parser.SignerID{4, 5, 6},

internal/analyzer/parser/commit/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (s *Service) Analyze() (map[parser.SignerID]Stats, error) {
6666
proposeTime[entry.DutyID] = entry.Timestamp.Time
6767
}
6868

69-
if strings.Contains(entry.Message, commitMsg) && entry.Round == 1 {
69+
if strings.Contains(entry.Message, commitMsg) && (entry.Round == 1 || entry.QBFTRound == 1) {
7070
if _, exists := commitTimes[entry.DutyID]; !exists {
7171
commitTimes[entry.DutyID] = make(map[parser.SignerID]time.Time)
7272
}

internal/analyzer/parser/consensus/service.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ const (
2424

2525
type (
2626
logEntry struct {
27-
Timestamp parser.MultiFormatTime `json:"T"`
28-
Message string `json:"M"`
29-
DutyID string `json:"duty_id"`
30-
Slot uint64 `json:"slot"`
31-
Round uint8 `json:"round"`
32-
Signers []parser.SignerID `json:"signers"`
33-
ConsensusTime string `json:"consensus_time"`
34-
BlockRoot string `json:"block_root,omitempty"`
27+
Timestamp parser.MultiFormatTime `json:"T"`
28+
Message string `json:"M"`
29+
DutyID string `json:"duty_id"`
30+
Slot uint64 `json:"slot"`
31+
// Round is deprecated by https://github.com/ssvlabs/ssv/pull/2453#discussion_r2287196265 but kept for now
32+
// for backward-compatibility, use QBFTRound instead (we can remove Round later).
33+
Round uint8 `json:"round"`
34+
QBFTRound uint8 `json:"qbft_round"`
35+
Signers []parser.SignerID `json:"signers"`
36+
ConsensusTime string `json:"consensus_time"`
37+
BlockRoot string `json:"block_root,omitempty"`
3538
}
3639

3740
OperatorStats struct {
@@ -112,7 +115,7 @@ func (s *Service) Analyze() (Stats, error) {
112115

113116
//only consensus times with round 1 are not diluted
114117
if strings.Contains(entry.Message, attestationSubmissionLogRecord) {
115-
if entry.Round == 1 {
118+
if entry.Round == 1 || entry.QBFTRound == 1 {
116119
consensusDuration, err := stringToDuration(entry.ConsensusTime, time.Second)
117120
if err != nil {
118121
return stats, err

internal/analyzer/parser/prepare/log.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import (
77
)
88

99
type prepareLogEntry struct {
10-
Timestamp parser.MultiFormatTime `json:"T"`
11-
Round uint8 `json:"round"`
12-
DutyID string `json:"duty_id"`
13-
Message string `json:"M"`
14-
PrepareSigners []parser.SignerID `json:"prepare_signers"`
10+
Timestamp parser.MultiFormatTime `json:"T"`
11+
// Round is deprecated by https://github.com/ssvlabs/ssv/pull/2453#discussion_r2287196265 but kept for now
12+
//for backward-compatibility, use QBFTRound instead (we can remove Round later).
13+
Round uint8 `json:"round"`
14+
QBFTRound uint8 `json:"qbft_round"`
15+
DutyID string `json:"duty_id"`
16+
Message string `json:"M"`
17+
PrepareSigners []parser.SignerID `json:"prepare_signers"`
1518
}
1619

1720
func (p *prepareLogEntry) UnmarshalJSON(data []byte) error {

internal/analyzer/parser/prepare/log_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import (
1212
func Test_GivenPrepareLogEntry_WhenMultipleSignersFormats_ThenUnmarshalSucceeds(t *testing.T) {
1313
jsonData1 := `{
1414
"T": "2024-09-27T05:48:39.348Z",
15-
"round": 1,
15+
"qbft_round": 1,
1616
"duty_id": "1234",
1717
"M": "Prepare message",
1818
"prepare_signers": [1, 2, 3]
1919
}`
2020

2121
jsonData2 := `{
2222
"T": "2024-09-27T05:48:39.348Z",
23-
"round": 1,
23+
"qbft_round": 1,
2424
"duty_id": "1234",
2525
"M": "Prepare message",
2626
"prepare-signers": [4, 5, 6]
@@ -40,7 +40,7 @@ func Test_GivenPrepareLogEntry_WhenMultipleSignersFormats_ThenUnmarshalSucceeds(
4040
input: jsonData1,
4141
expected: prepareLogEntry{
4242
Timestamp: expectedTime,
43-
Round: 1,
43+
QBFTRound: 1,
4444
DutyID: "1234",
4545
Message: "Prepare message",
4646
PrepareSigners: []parser.SignerID{1, 2, 3},
@@ -52,7 +52,7 @@ func Test_GivenPrepareLogEntry_WhenMultipleSignersFormats_ThenUnmarshalSucceeds(
5252
input: jsonData2,
5353
expected: prepareLogEntry{
5454
Timestamp: expectedTime,
55-
Round: 1,
55+
QBFTRound: 1,
5656
DutyID: "1234",
5757
Message: "Prepare message",
5858
PrepareSigners: []parser.SignerID{4, 5, 6},

internal/analyzer/parser/prepare/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (s *Service) Analyze() (map[parser.SignerID]Stats, error) {
6666
leaderProposeTime[entry.DutyID] = entry.Timestamp.Time
6767
}
6868

69-
if strings.Contains(entry.Message, prepareMsg) && entry.Round == 1 {
69+
if strings.Contains(entry.Message, prepareMsg) && (entry.Round == 1 || entry.QBFTRound == 1) {
7070
if _, exists := prepareSignerTimes[entry.DutyID]; !exists {
7171
prepareSignerTimes[entry.DutyID] = make(map[parser.SignerID]time.Time)
7272
}

0 commit comments

Comments
 (0)