Skip to content

Commit

Permalink
Merge PR: add block producer tag (#1201)
Browse files Browse the repository at this point in the history
* add block producer tag

* "Set TimeoutPropose"

* address review comments

* refine
  • Loading branch information
zhongqiuwood authored Nov 18, 2021
1 parent 1d915b2 commit f95ef13
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions dev/testnet/testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ run() {
--consensus.timeout_commit 3s \
--log_level ${LOG_LEVEL} \
--chain-id ${CHAIN_ID} \
--elapsed DeliverTxs=1,Round=1,CommitRound=1,Produce=1 \
--rest.laddr tcp://localhost:8545 \
--keyring-backend test >cache/exchaind.${index}.log 2>&1 &

Expand Down
17 changes: 15 additions & 2 deletions libs/tendermint/cmd/tendermint/commands/run_node_exchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ func addMoreFlags(cmd *cobra.Command) {
//pprof flags
cmd.Flags().String("prof_laddr", config.ProfListenAddress,
"Node listen address. (0.0.0.0:0 means any interface, any port)")

cmd.Flags().Duration("consensus.timeout_commit", config.Consensus.TimeoutCommit, "Set node block interval time")

cmd.Flags().Duration("consensus.timeout_propose", config.Consensus.TimeoutPropose,
"Set TimeoutPropose")
cmd.Flags().Duration("consensus.timeout_propose_delta", config.Consensus.TimeoutProposeDelta,
"Set TimeoutProposeDelta")
cmd.Flags().Duration("consensus.timeout_prevote", config.Consensus.TimeoutPrevote,
"Set TimeoutPrevote")
cmd.Flags().Duration("consensus.timeout_prevote_delta", config.Consensus.TimeoutPrevoteDelta,
"Set TimeoutPrevoteDelta")
cmd.Flags().Duration("consensus.timeout_precommit", config.Consensus.TimeoutPrecommit,
"Set TimeoutPrecommit")
cmd.Flags().Duration("consensus.timeout_precommit_delta", config.Consensus.TimeoutPrecommitDelta,
"Set TimeoutPrecommitDelta")
cmd.Flags().Duration("consensus.timeout_commit", config.Consensus.TimeoutCommit,
"Set TimeoutCommit")
}
18 changes: 16 additions & 2 deletions libs/tendermint/consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,19 @@ func (cs *State) needProofBlock(height int64) bool {
return !bytes.Equal(cs.state.AppHash, lastBlockMeta.Header.AppHash)
}

func (cs *State) isBlockProducer() string {
isBlockProducer := "n"
if cs.privValidator != nil && cs.privValidatorPubKey != nil {
address := cs.privValidatorPubKey.Address()

if cs.isProposer != nil && cs.isProposer(address) {
isBlockProducer = "y"
}
}

return isBlockProducer
}

// Enter (CreateEmptyBlocks): from enterNewRound(height,round)
// Enter (CreateEmptyBlocks, CreateEmptyBlocksInterval > 0 ):
// after enterNewRound(height,round), after timeout of CreateEmptyBlocksInterval
Expand All @@ -927,7 +940,8 @@ func (cs *State) enterPropose(height int64, round int) {
cs.Step))
return
}
cs.trc.Pin("Propose-%d", round)

cs.trc.Pin("Propose-%d-%s", round, cs.isBlockProducer())

logger.Info(fmt.Sprintf("enterPropose(%v/%v). Current: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))

Expand Down Expand Up @@ -961,7 +975,7 @@ func (cs *State) enterPropose(height int64, round int) {
return
}
address := cs.privValidatorPubKey.Address()

// if not a validator, we're done
if !cs.Validators.HasAddress(address) {
logger.Debug("This node is not a validator", "addr", address, "vals", cs.Validators)
Expand Down

0 comments on commit f95ef13

Please sign in to comment.