Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Consensus] Log verifier ids for missing approvals #1324

Merged
merged 2 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions engine/consensus/approvals/tracker/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ func (r *SealingRecord) ApprovalsMissing(chunksWithMissingApprovals map[uint64]f
sufficientApprovals := len(chunksWithMissingApprovals) == 0
r.entries["sufficient_approvals_for_sealing"] = sufficientApprovals
if !sufficientApprovals {
indices := make([]uint64, 0, len(chunksWithMissingApprovals))
for i := range chunksWithMissingApprovals {
indices = append(indices, i)
indices := make([]string, 0, len(chunksWithMissingApprovals))
for i, list := range chunksWithMissingApprovals {
indices = append(indices, fmt.Sprintf("chunk_index: %v, verifier_ids: %v", i, list))
}
r.entries["chunks_with_insufficient_approvals"] = indices
Comment on lines +35 to 39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, the sealing observation is structured as a nested json, which allows to post-process the message. I feel, we are flattening the data here, which unnecessarily removes structure:

  • Conceptually, we have pairs: (chunk_index, IDs of verifiers from which we miss approvals)

I feel it would be beneficial to preserve this structure in the json:

chunksInfo := make([]map[string]interface{}, 0, len(chunksWithMissingApprovals))
for i, list := range chunksWithMissingApprovals {
	chunk := make(map[string]interface{})
	chunk["chunk_index"] = i
	chunk["missing_approvals_from_verifiers"] = list
	chunksInfo = append(chunksInfo, chunk)
}
bytes, err := json.Marshal(r)
if err != nil {
	bytes = []byte("failed to marshal data about chunks with missing approvals")
}
r.entries["chunks_with_insufficient_approvals"] = string(bytes)

}

}

func (r *SealingRecord) ApprovalsRequested(requestCount uint) {
Expand Down
20 changes: 19 additions & 1 deletion engine/consensus/approvals/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tracker
import (
"encoding/hex"
"encoding/json"
"fmt"
"time"

"github.com/rs/zerolog"
Expand Down Expand Up @@ -170,7 +171,24 @@ func (st *SealingObservation) Complete() {

// dump observation to Logger
observation = observation.Int64("duration_ms", time.Since(st.startTime).Milliseconds())
observation.Msg("sealing observation")
reason := st.UnsealedReason()
observation.Msgf("sealing observation, unsealed reason: %v", reason)
}

func (st *SealingObservation) UnsealedReason() string {
if st.finalizedBlock == st.latestSealedBlock {
return "all finalized blocks have been sealed"
}

unsealedHeight := st.latestSealedBlock.Height + 1
if len(st.records) == 0 {
return fmt.Sprintf("no result found for next unsealed block at height: %v", unsealedHeight)
}

return fmt.Sprintf("unsealed block at height %v has been executed, the result has been incorporated on %v fork(s), "+
"but no result has received enough approvals, check the chunks_with_insufficient_approvals field for more details",
len(st.records),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
unsealed block at height %v is filled with parameter len(st.records)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
result has been incorporated on %v fork(s) This statement is only valid if there is one result. But we can have execution forks. Tow results might be incorporated in the same fork

unsealedHeight)
}

// latestFinalizedSealInfo returns a json string representation with the most
Expand Down