Skip to content

Commit

Permalink
Remove some metric
Browse files Browse the repository at this point in the history
  • Loading branch information
yzang2019 committed Mar 29, 2024
1 parent 57a2ace commit 4b58623
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
22 changes: 0 additions & 22 deletions internal/consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1852,8 +1852,6 @@ func (cs *State) enterPrevoteWait(height int64, round int32) {
// Lock & precommit the ProposalBlock if we have enough prevotes for it (a POL in this round)
// else, precommit nil otherwise.
func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32, entryLabel string) {
t := debugutil.NewTimer("enterPrecommit")
defer t.Stop()

_, span := cs.tracer.Start(cs.getTracingCtx(ctx), "cs.state.enterPrecommit")
span.SetAttributes(attribute.Int("round", int(round)))
Expand Down Expand Up @@ -1885,70 +1883,55 @@ func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32,
}()

// check for a polka
t = debugutil.NewTimer("checkPolka")
blockID, ok := cs.roundState.Votes().Prevotes(round).TwoThirdsMajority()
t.Stop()

// If we don't have a polka, we must precommit nil.
if !ok {
t = debugutil.NewTimer("noPolkaPreccomitNil")
if cs.roundState.LockedBlock() != nil {
logger.Info("precommit step; no +2/3 prevotes during enterPrecommit while we are locked; precommitting nil")
} else {
logger.Info("precommit step; no +2/3 prevotes during enterPrecommit; precommitting nil")
}

cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
t.Stop()
return
}

// At this point +2/3 prevoted for a particular block or nil.
t = debugutil.NewTimer("publishEventPolka")
if err := cs.eventBus.PublishEventPolka(cs.roundState.RoundStateEvent()); err != nil {
logger.Error("failed publishing polka", "err", err)
}
t.Stop()

// the latest POLRound should be this round.
t = debugutil.NewTimer("polInfo")
polRound, _ := cs.roundState.Votes().POLInfo()
if polRound < round {
panic(fmt.Sprintf("this POLRound should be %v but got %v", round, polRound))
}
t.Stop()

// +2/3 prevoted nil. Precommit nil.
if blockID.IsNil() {
t = debugutil.NewTimer("prevoteNilPreccomitNil")
logger.Info("precommit step: +2/3 prevoted for nil; precommitting nil")
cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
t.Stop()
return
}
// At this point, +2/3 prevoted for a particular block.

// If we never received a proposal for this block, we must precommit nil
if cs.roundState.Proposal() == nil || cs.roundState.ProposalBlock() == nil {
t = debugutil.NewTimer("noBlockProposalPreccomitNil")
logger.Info("precommit step; did not receive proposal, precommitting nil")
cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
t.Stop()
return
}

// If the proposal time does not match the block time, precommit nil.
if !cs.roundState.Proposal().Timestamp.Equal(cs.roundState.ProposalBlock().Header.Time) {
logger.Info("precommit step: proposal timestamp not equal; precommitting nil")
t = debugutil.NewTimer("proposalNotMatchBlockTimePreccomitNil")
cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
t.Stop()
return
}

// If we're already locked on that block, precommit it, and update the LockedRound
if cs.roundState.LockedBlock().HashesTo(blockID.Hash) {
t = debugutil.NewTimer("lockedBlockPreccomit")
logger.Info("precommit step: +2/3 prevoted locked block; relocking")
cs.roundState.SetLockedRound(round)

Expand All @@ -1957,15 +1940,13 @@ func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32,
}

cs.signAddVote(ctx, tmproto.PrecommitType, blockID.Hash, blockID.PartSetHeader)
t.Stop()
return
}

// If greater than 2/3 of the voting power on the network prevoted for
// the proposed block, update our locked block to this block and issue a
// precommit vote for it.
if cs.roundState.ProposalBlock().HashesTo(blockID.Hash) {
t = debugutil.NewTimer("updatedLockedBlockPreccomit")
logger.Info("precommit step: +2/3 prevoted proposal block; locking", "hash", blockID.Hash)

// Validate the block.
Expand All @@ -1982,23 +1963,20 @@ func (cs *State) enterPrecommit(ctx context.Context, height int64, round int32,
}

cs.signAddVote(ctx, tmproto.PrecommitType, blockID.Hash, blockID.PartSetHeader)
t.Stop()
return
}

// There was a polka in this round for a block we don't have.
// Fetch that block, and precommit nil.
logger.Info("precommit step: +2/3 prevotes for a block we do not have; voting nil", "block_id", blockID)

t = debugutil.NewTimer("polkaNotHavePreccomitNil")
if !cs.roundState.ProposalBlockParts().HasHeader(blockID.PartSetHeader) {
cs.roundState.SetProposalBlock(nil)
cs.metrics.MarkBlockGossipStarted()
cs.roundState.SetProposalBlockParts(types.NewPartSetFromHeader(blockID.PartSetHeader))
}

cs.signAddVote(ctx, tmproto.PrecommitType, nil, types.PartSetHeader{})
t.Stop()
}

// Enter: any +2/3 precommits for next round.
Expand Down
7 changes: 0 additions & 7 deletions internal/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,27 +705,22 @@ func FireEvents(
validatorUpdates []*types.Validator,
) {

startTime := time.Now()
if err := eventBus.PublishEventNewBlock(types.EventDataNewBlock{
Block: block,
BlockID: blockID,
ResultFinalizeBlock: *finalizeBlockResponse,
}); err != nil {
logger.Error("failed publishing new block", "err", err)
}
fmt.Printf("[Debug] Publish New block event took %s\n", time.Since(startTime))

startBlockHeaderTime := time.Now()
if err := eventBus.PublishEventNewBlockHeader(types.EventDataNewBlockHeader{
Header: block.Header,
NumTxs: int64(len(block.Txs)),
ResultFinalizeBlock: *finalizeBlockResponse,
}); err != nil {
logger.Error("failed publishing new block header", "err", err)
}
fmt.Printf("[Debug] Publish Block header took %s\n", time.Since(startBlockHeaderTime))

startEvidenceTime := time.Now()
if len(block.Evidence) != 0 {
for _, ev := range block.Evidence {
if err := eventBus.PublishEventNewEvidence(types.EventDataNewEvidence{
Expand All @@ -736,8 +731,6 @@ func FireEvents(
}
}
}
fmt.Printf("[Debug] Publish Evidence took %s\n", time.Since(startEvidenceTime))

// sanity check
if len(finalizeBlockResponse.TxResults) != len(block.Data.Txs) {
panic(fmt.Sprintf("number of TXs (%d) and ABCI TX responses (%d) do not match",
Expand Down

0 comments on commit 4b58623

Please sign in to comment.