Skip to content

Commit

Permalink
fix address panic in metrics (#666)
Browse files Browse the repository at this point in the history
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v           ✰  Thanks for creating a PR! You're awesome! ✰
v Please note that maintainers will only review those PRs with a
completed PR template.
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Purpose of Changes and their Description

## Link(s) to Ticket(s) or Issue(s) resolved by this PR

## Are these changes tested and documented?

- [ ] If tested, please describe how. If not, why tests are not needed.
- [ ] If documented, please describe where. If not, describe why docs
are not needed.
- [ ] Added to `Unreleased` section of `CHANGELOG.md`?

## Still Left Todo

*Fill this out if this is a Draft PR so others can help.*
  • Loading branch information
spooktheducks committed Nov 12, 2024
1 parent 2f2ea93 commit 8eecf6a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"context"
_ "embed"
"encoding/hex"
"io"
"math/big"
"os"
Expand Down Expand Up @@ -40,7 +41,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cometbft/cometbft/crypto/secp256k1"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server"
Expand Down Expand Up @@ -511,12 +511,6 @@ func (app *AlloraApp) Commit() (*abci.ResponseCommit, error) {
return res, nil
}

func validatorAddr(pubkeyBytes []byte) string {
pubkey := secp256k1.PubKey(pubkeyBytes)
pubKeyConvertedToAddress := sdk.ValAddress(pubkey.Address().Bytes())
return pubKeyConvertedToAddress.String()
}

func logMisbehaviors(mbs []abci.Misbehavior, keys ...string) {
for _, misbehavior := range mbs {
var typ string
Expand All @@ -532,7 +526,8 @@ func logMisbehaviors(mbs []abci.Misbehavior, keys ...string) {
append(append([]string{"allora"}, keys...), "misbehavior"),
float32(1),
[]metrics.Label{
telemetry.NewLabel("validator", validatorAddr(misbehavior.Validator.Address)),
telemetry.NewLabel("validator", sdk.ValAddress(misbehavior.Validator.Address).String()),
telemetry.NewLabel("validator_hex", hex.EncodeToString(misbehavior.Validator.Address)),
telemetry.NewLabel("validator_power", strconv.FormatInt(misbehavior.Validator.Power, 10)),
telemetry.NewLabel("misbehavior_type", typ),
},
Expand Down

0 comments on commit 8eecf6a

Please sign in to comment.