Skip to content

Commit

Permalink
fix(zetaclient): use chain name in metrics (#3484) (#3493)
Browse files Browse the repository at this point in the history
* fix(zetaclient): use chain name in metrics (#3484)

* changelog
  • Loading branch information
gartnera authored Feb 6, 2025
1 parent 3dc1eda commit e33f8ab
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 27 deletions.
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CHANGELOG

## v27.0.2

This is a zetaclient only release.

### Fixes

* [3482](https://github.com/zeta-chain/node/pull/3482) - fix evm healthcheck to reduce log spam
* [3484](https://github.com/zeta-chain/node/pull/3484) - use chain name in metrics


## v27.0.1

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpc/clients_crosschain.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *Clients) ListPendingCCTXWithinRateLimit(
return resp, nil
}

// ListPendingCCTX returns a list of pending cctxs for a given chainID
// ListPendingCCTX returns a list of pending cctxs for a given chain
// - The max size of the list is crosschainkeeper.MaxPendingCctxs
func (c *Clients) ListPendingCCTX(ctx context.Context, chainID int64) ([]*types.CrossChainTx, uint64, error) {
in := &types.QueryListPendingCctxRequest{ChainId: chainID}
Expand Down
5 changes: 3 additions & 2 deletions zetaclient/chains/bitcoin/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ func (b *Bitcoin) scheduleCCTX(ctx context.Context) error {

// #nosec G115 always in range
zetaHeight := uint64(zetaBlock.Block.Height)
chainID := b.observer.Chain().ChainId
chain := b.observer.Chain()
chainID := chain.ChainId
lookahead := b.observer.ChainParams().OutboundScheduleLookahead

cctxList, _, err := b.observer.ZetacoreClient().ListPendingCCTX(ctx, chainID)
cctxList, _, err := b.observer.ZetacoreClient().ListPendingCCTX(ctx, chain)
if err != nil {
return errors.Wrap(err, "unable to list pending cctx")
}
Expand Down
5 changes: 3 additions & 2 deletions zetaclient/chains/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ func (e *EVM) scheduleCCTX(ctx context.Context) error {
time.Sleep(delay)

var (
chainID = e.observer.Chain().ChainId
chain = e.observer.Chain()
chainID = chain.ChainId

// #nosec G115 always in range
zetaHeight = uint64(zetaBlock.Block.Height)
Expand All @@ -151,7 +152,7 @@ func (e *EVM) scheduleCCTX(ctx context.Context) error {
outboundScheduleLookBack = uint64(float64(lookahead) * outboundLookBackFactor)
)

cctxList, _, err := e.observer.ZetacoreClient().ListPendingCCTX(ctx, chainID)
cctxList, _, err := e.observer.ZetacoreClient().ListPendingCCTX(ctx, chain)
if err != nil {
return errors.Wrap(err, "unable to list pending cctx")
}
Expand Down
2 changes: 1 addition & 1 deletion zetaclient/chains/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type ZetacoreClient interface {

GetBlockHeight(ctx context.Context) (int64, error)

ListPendingCCTX(ctx context.Context, chainID int64) ([]*crosschaintypes.CrossChainTx, uint64, error)
ListPendingCCTX(ctx context.Context, chain chains.Chain) ([]*crosschaintypes.CrossChainTx, uint64, error)
ListPendingCCTXWithinRateLimit(
ctx context.Context,
) (*crosschaintypes.QueryListPendingCctxWithinRateLimitResponse, error)
Expand Down
5 changes: 3 additions & 2 deletions zetaclient/chains/solana/solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ func (s *Solana) scheduleCCTX(ctx context.Context) error {
time.Sleep(delay)

var (
chainID = s.observer.Chain().ChainId
chain = s.observer.Chain()
chainID = chain.ChainId

// #nosec G115 positive
zetaHeight = uint64(zetaBlock.Block.Height)
Expand All @@ -147,7 +148,7 @@ func (s *Solana) scheduleCCTX(ctx context.Context) error {
needsProcessingCtr = 0
)

cctxList, _, err := s.observer.ZetacoreClient().ListPendingCCTX(ctx, chainID)
cctxList, _, err := s.observer.ZetacoreClient().ListPendingCCTX(ctx, chain)
if err != nil {
return errors.Wrap(err, "unable to list pending cctx")
}
Expand Down
4 changes: 2 additions & 2 deletions zetaclient/chains/ton/ton.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ func (t *TON) scheduleCCTX(ctx context.Context) error {

// #nosec G115 always in range
zetaHeight := uint64(zetaBlock.Block.Height)
chainID := t.observer.Chain().ChainId
chain := t.observer.Chain()

cctxList, _, err := t.observer.ZetacoreClient().ListPendingCCTX(ctx, chainID)
cctxList, _, err := t.observer.ZetacoreClient().ListPendingCCTX(ctx, chain)
if err != nil {
return errors.Wrap(err, "unable to list pending cctx")
}
Expand Down
22 changes: 11 additions & 11 deletions zetaclient/testutils/mocks/zetacore_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions zetaclient/zetacore/client_crosschain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@ package zetacore
import (
"context"
"sort"
"strconv"

"cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/zeta-chain/node/pkg/chains"
"github.com/zeta-chain/node/x/crosschain/types"
"github.com/zeta-chain/node/zetaclient/chains/interfaces"
"github.com/zeta-chain/node/zetaclient/metrics"
)

func (c *Client) ListPendingCCTX(ctx context.Context, chainID int64) ([]*types.CrossChainTx, uint64, error) {
list, total, err := c.Clients.ListPendingCCTX(ctx, chainID)
func (c *Client) ListPendingCCTX(ctx context.Context, chain chains.Chain) ([]*types.CrossChainTx, uint64, error) {
list, total, err := c.Clients.ListPendingCCTX(ctx, chain.ChainId)

if err == nil {
// #nosec G115 always in range
label := strconv.Itoa(int(chainID))
value := float64(total)

metrics.PendingTxsPerChain.WithLabelValues(label).Set(value)
metrics.PendingTxsPerChain.WithLabelValues(chain.Name).Set(value)
}

return list, total, err
Expand Down

0 comments on commit e33f8ab

Please # to comment.