Skip to content

Commit

Permalink
Merge #1332
Browse files Browse the repository at this point in the history
1332: [Consensus] Revert unsealed reason r=zhangchiqing a=zhangchiqing



Co-authored-by: Leo Zhang (zhangchiqing) <zhangchiqing@gmail.com>
Co-authored-by: Leo Zhang <zhangchiqing@gmail.com>
Co-authored-by: Alexander Hentschel <alex.hentschel@axiomzen.co>
  • Loading branch information
3 people committed Oct 3, 2021
2 parents 3e27bfb + aeffa44 commit 58cb618
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
14 changes: 11 additions & 3 deletions engine/consensus/approvals/tracker/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tracker

import (
"encoding/hex"
"encoding/json"
"fmt"

"github.com/onflow/flow-go/model/flow"
Expand Down Expand Up @@ -32,11 +33,18 @@ func (r *SealingRecord) ApprovalsMissing(chunksWithMissingApprovals map[uint64]f
sufficientApprovals := len(chunksWithMissingApprovals) == 0
r.entries["sufficient_approvals_for_sealing"] = sufficientApprovals
if !sufficientApprovals {
indices := make([]string, 0, len(chunksWithMissingApprovals))
chunksInfo := make([]map[string]interface{}, 0, len(chunksWithMissingApprovals))
for i, list := range chunksWithMissingApprovals {
indices = append(indices, fmt.Sprintf("chunk_index: %v, verifier_ids: %v", i, list))
chunk := make(map[string]interface{})
chunk["chunk_index"] = i
chunk["missing_approvals_from_verifiers"] = list
chunksInfo = append(chunksInfo, chunk)
}
r.entries["chunks_with_insufficient_approvals"] = indices
bytes, err := json.Marshal(chunksInfo)
if err != nil {
bytes = []byte("failed to marshal data about chunks with missing approvals")
}
r.entries["chunks_with_insufficient_approvals"] = string(bytes)
}
}

Expand Down
20 changes: 1 addition & 19 deletions engine/consensus/approvals/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tracker
import (
"encoding/hex"
"encoding/json"
"fmt"
"time"

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

// dump observation to Logger
observation = observation.Int64("duration_ms", time.Since(st.startTime).Milliseconds())
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),
unsealedHeight)
observation.Msg("sealing observation")
}

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

0 comments on commit 58cb618

Please sign in to comment.