diff --git a/pkg/rpc/clients_crosschain.go b/pkg/rpc/clients_crosschain.go index f1ef8f5e34..3a42bc4d7b 100644 --- a/pkg/rpc/clients_crosschain.go +++ b/pkg/rpc/clients_crosschain.go @@ -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} diff --git a/zetaclient/chains/bitcoin/bitcoin.go b/zetaclient/chains/bitcoin/bitcoin.go index 72b7ebaf93..ff09782ba2 100644 --- a/zetaclient/chains/bitcoin/bitcoin.go +++ b/zetaclient/chains/bitcoin/bitcoin.go @@ -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") } diff --git a/zetaclient/chains/evm/evm.go b/zetaclient/chains/evm/evm.go index 80bdbbc441..ab1b6795f6 100644 --- a/zetaclient/chains/evm/evm.go +++ b/zetaclient/chains/evm/evm.go @@ -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) @@ -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") } diff --git a/zetaclient/chains/interfaces/interfaces.go b/zetaclient/chains/interfaces/interfaces.go index b34afcb98a..5213997033 100644 --- a/zetaclient/chains/interfaces/interfaces.go +++ b/zetaclient/chains/interfaces/interfaces.go @@ -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) diff --git a/zetaclient/chains/solana/solana.go b/zetaclient/chains/solana/solana.go index c0f5a22e62..980c2f539d 100644 --- a/zetaclient/chains/solana/solana.go +++ b/zetaclient/chains/solana/solana.go @@ -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) @@ -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") } diff --git a/zetaclient/chains/ton/ton.go b/zetaclient/chains/ton/ton.go index f4ab4db498..8dc6382e28 100644 --- a/zetaclient/chains/ton/ton.go +++ b/zetaclient/chains/ton/ton.go @@ -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") } diff --git a/zetaclient/testutils/mocks/zetacore_client.go b/zetaclient/testutils/mocks/zetacore_client.go index a9df971c2a..79a3c273e3 100644 --- a/zetaclient/testutils/mocks/zetacore_client.go +++ b/zetaclient/testutils/mocks/zetacore_client.go @@ -650,9 +650,9 @@ func (_m *ZetacoreClient) GetZetaHotKeyBalance(ctx context.Context) (math.Int, e return r0, r1 } -// ListPendingCCTX provides a mock function with given fields: ctx, chainID -func (_m *ZetacoreClient) ListPendingCCTX(ctx context.Context, chainID int64) ([]*types.CrossChainTx, uint64, error) { - ret := _m.Called(ctx, chainID) +// ListPendingCCTX provides a mock function with given fields: ctx, chain +func (_m *ZetacoreClient) ListPendingCCTX(ctx context.Context, chain chains.Chain) ([]*types.CrossChainTx, uint64, error) { + ret := _m.Called(ctx, chain) if len(ret) == 0 { panic("no return value specified for ListPendingCCTX") @@ -661,25 +661,25 @@ func (_m *ZetacoreClient) ListPendingCCTX(ctx context.Context, chainID int64) ([ var r0 []*types.CrossChainTx var r1 uint64 var r2 error - if rf, ok := ret.Get(0).(func(context.Context, int64) ([]*types.CrossChainTx, uint64, error)); ok { - return rf(ctx, chainID) + if rf, ok := ret.Get(0).(func(context.Context, chains.Chain) ([]*types.CrossChainTx, uint64, error)); ok { + return rf(ctx, chain) } - if rf, ok := ret.Get(0).(func(context.Context, int64) []*types.CrossChainTx); ok { - r0 = rf(ctx, chainID) + if rf, ok := ret.Get(0).(func(context.Context, chains.Chain) []*types.CrossChainTx); ok { + r0 = rf(ctx, chain) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]*types.CrossChainTx) } } - if rf, ok := ret.Get(1).(func(context.Context, int64) uint64); ok { - r1 = rf(ctx, chainID) + if rf, ok := ret.Get(1).(func(context.Context, chains.Chain) uint64); ok { + r1 = rf(ctx, chain) } else { r1 = ret.Get(1).(uint64) } - if rf, ok := ret.Get(2).(func(context.Context, int64) error); ok { - r2 = rf(ctx, chainID) + if rf, ok := ret.Get(2).(func(context.Context, chains.Chain) error); ok { + r2 = rf(ctx, chain) } else { r2 = ret.Error(2) } diff --git a/zetaclient/zetacore/client_crosschain.go b/zetaclient/zetacore/client_crosschain.go index c3a3970de4..2155f10bd6 100644 --- a/zetaclient/zetacore/client_crosschain.go +++ b/zetaclient/zetacore/client_crosschain.go @@ -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