Skip to content

Commit

Permalink
Don't update proposer metric if block heights don't match (#54)
Browse files Browse the repository at this point in the history
* Don't update proposer metric if block heights don't match

* Merge chains/coreum into wojtek/proposer-metric
  • Loading branch information
wojtek-coreum authored Jan 26, 2024
1 parent 914575c commit bfd158f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ module github.com/forbole/bdjuno/v4

go 1.20

replace github.com/forbole/juno/v5 => github.com/CoreumFoundation/junov5/v5 v5.2.1-0.20231110094554-b0ce2d473cd4
replace github.com/forbole/juno/v5 => github.com/CoreumFoundation/junov5/v5 v5.2.1-0.20240126121118-d3d301084ce7

require (
cosmossdk.io/math v1.1.2
cosmossdk.io/simapp v0.0.0-20230831152633-2e9e5d6eea24
github.com/CoreumFoundation/coreum/v3 v3.0.0-20231109135250-9c76e4fab1d0
github.com/CosmWasm/wasmd v0.44.0
github.com/cometbft/cometbft v0.37.2
github.com/cosmos/cosmos-sdk v0.47.5
github.com/cosmos/gogoproto v1.4.10
github.com/forbole/juno/v5 v5.2.0
github.com/go-co-op/gocron v1.35.0
github.com/gogo/protobuf v1.3.2
github.com/golangci/golangci-lint v1.54.2
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.9
Expand Down Expand Up @@ -52,6 +50,7 @@ require (
github.com/Antonboom/nilnil v0.1.7 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/CosmWasm/wasmd v0.44.0 // indirect
github.com/CosmWasm/wasmvm v1.5.0 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.1.0 // indirect
Expand Down Expand Up @@ -138,6 +137,7 @@ require (
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:
github.com/CoreumFoundation/coreum-tools v0.4.0 h1:ATmoiaDdcoGx1TqheTekkNEYb3u0fpp1H4+Qnxz3dmg=
github.com/CoreumFoundation/coreum/v3 v3.0.0-20231109135250-9c76e4fab1d0 h1:wOXoLAhYfTlS9odimKOErMUsOLhSyKG5C/jAkGn5AnM=
github.com/CoreumFoundation/coreum/v3 v3.0.0-20231109135250-9c76e4fab1d0/go.mod h1:wITBS5Wyvo0Y+fjIIB9EOPd3e0/6fxUFM4OCe/HfdEI=
github.com/CoreumFoundation/junov5/v5 v5.2.1-0.20231110094554-b0ce2d473cd4 h1:1luEsFtm8fsbxPleuam85rbXTU2YHyaDtTcizKV/BCQ=
github.com/CoreumFoundation/junov5/v5 v5.2.1-0.20231110094554-b0ce2d473cd4/go.mod h1:wl9jxyKnDx6rElBkc6Zn8i9DInBpMwMeoX6Kxkp71KM=
github.com/CoreumFoundation/junov5/v5 v5.2.1-0.20240126121118-d3d301084ce7 h1:kx/HTRLZ1KARVFJPbqEun0K2vkUJmnum8ULOUQzKWLw=
github.com/CoreumFoundation/junov5/v5 v5.2.1-0.20240126121118-d3d301084ce7/go.mod h1:wl9jxyKnDx6rElBkc6Zn8i9DInBpMwMeoX6Kxkp71KM=
github.com/CosmWasm/wasmd v0.44.0 h1:2sbcoCAvfjCs1O0SWt53xULKjkV06dbSFthEViIC6Zg=
github.com/CosmWasm/wasmd v0.44.0/go.mod h1:tDyYN050qUcdd7LOxGeo2e185sEShyO3nJGl2Cf59+k=
github.com/CosmWasm/wasmvm v1.5.0 h1:3hKeT9SfwfLhxTGKH3vXaKFzBz1yuvP8SlfwfQXbQfw=
Expand Down
47 changes: 22 additions & 25 deletions modules/actions/logging/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ var BlockTimeGauge = prometheus.NewGaugeVec(
},
)

// ProposalCounter represents the Telemetry counter used to track proposals
var ProposalCounter = prometheus.NewSummaryVec(
// ProposalSummary represents the Telemetry summary used to track proposals
var ProposalSummary = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: "bdjuno_proposal",
Help: "Counts successful proposals.",
Expand All @@ -47,29 +47,26 @@ var ProposalCounter = prometheus.NewSummaryVec(
},
)

func init() {
err := prometheus.Register(ActionResponseTime)
if err != nil {
panic(err)
}

err = prometheus.Register(ActionCounter)
if err != nil {
panic(err)
}

err = prometheus.Register(ActionErrorCounter)
if err != nil {
panic(err)
}

err = prometheus.Register(BlockTimeGauge)
if err != nil {
panic(err)
}
// ValidatorBlockMismatchCounter represents the Telemetry counter used to track cases when height in processed block
// differs from the one in returned validator set.
var ValidatorBlockMismatchCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "bdjuno_validator_block_mismatch",
Help: "Total number of mismatched block heights in validator set.",
},
)

err = prometheus.Register(ProposalCounter)
if err != nil {
panic(err)
func init() {
for _, c := range []prometheus.Collector{
ActionResponseTime,
ActionCounter,
ActionErrorCounter,
BlockTimeGauge,
ProposalSummary,
ValidatorBlockMismatchCounter,
} {
if err := prometheus.Register(c); err != nil {
panic(err)
}
}
}
9 changes: 8 additions & 1 deletion modules/consensus/handle_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ func (m *Module) updateBlockTimeFromGenesis(block *tmctypes.ResultBlock) error {
}

func (m *Module) countProposalsByValidator(block *tmctypes.ResultBlock, vals *tmctypes.ResultValidators) {
if block.Block.Height != vals.BlockHeight {
log.Warn().Int64("blockHeight", block.Block.Height).Int64("valHeight", vals.BlockHeight).
Msg("block height and validator height don't match")
logging.ValidatorBlockMismatchCounter.Inc()
return
}

expectedNextProposer := vals.Validators[0]
if len(vals.Validators) > 1 {
for _, v := range vals.Validators[1:] {
Expand Down Expand Up @@ -100,5 +107,5 @@ func updateProposerMetric(expected, real tmtypes.Address) {
if bytes.Equal(expected, real) {
value = 1.0
}
logging.ProposalCounter.WithLabelValues(sdk.ConsAddress(expected).String()).Observe(value)
logging.ProposalSummary.WithLabelValues(sdk.ConsAddress(expected).String()).Observe(value)
}

0 comments on commit bfd158f

Please sign in to comment.