Skip to content

Commit

Permalink
traces prevote delays
Browse files Browse the repository at this point in the history
  • Loading branch information
staheri14 committed Aug 21, 2024
1 parent f48658d commit f64fe43
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,7 @@ func (cs *State) isReadyToPrevote() (bool, time.Duration) {
// Therefore, we've set the wait time to 7 seconds to account for some error margin.
prevoteVoteTime := cs.StartTime.Add(7 * time.Second)
waitTime := time.Until(prevoteVoteTime)
schema.WritePrevoteDelay(cs.traceClient, cs.Height, cs.Round, waitTime.Seconds())
return waitTime <= 0, waitTime
}

Expand Down
22 changes: 22 additions & 0 deletions pkg/trace/schema/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func ConsensusTables() []string {
ConsensusStateTable,
ProposalTable,
PrecommitTimeTable,
PrevoteDelayTable,
}
}

Expand All @@ -40,6 +41,27 @@ func WritePrecommitTime(client trace.Tracer, height int64, round int32, delay fl

}

const (
// PrevoteDelayTable
PrevoteDelayTable = "consensus_prevote_delay"
)

type PrevoteDelay struct {
Height int64 `json:"height"`
Round int32 `json:"round"`
// amount of delay added before casting prevote for this Height and Round
Delay float64 `json:"delay"`
}

func (p PrevoteDelay) Table() string {
return PrevoteDelayTable
}

func WritePrevoteDelay(client trace.Tracer, height int64, round int32, delay float64) {
client.Write(PrevoteDelay{Height: height, Round: round, Delay: delay})

}

// Schema constants for the consensus round state tracing database.
const (
// RoundStateTable is the name of the table that stores the consensus
Expand Down

0 comments on commit f64fe43

Please sign in to comment.