Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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

Check warning on line 133 in zetaclient/chains/ton/ton.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/ton/ton.go#L133

Added line #L133 was not covered by tests

cctxList, _, err := t.observer.ZetacoreClient().ListPendingCCTX(ctx, chainID)
cctxList, _, err := t.observer.ZetacoreClient().ListPendingCCTX(ctx, chain)

Check warning on line 135 in zetaclient/chains/ton/ton.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/ton/ton.go#L135

Added line #L135 was not covered by tests
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 @@
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)

Check warning on line 17 in zetaclient/zetacore/client_crosschain.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_crosschain.go#L16-L17

Added lines #L16 - L17 were not covered by tests

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)

Check warning on line 22 in zetaclient/zetacore/client_crosschain.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/zetacore/client_crosschain.go#L22

Added line #L22 was not covered by tests
}

return list, total, err
Expand Down