Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(zetaclient): use chain name in metrics #3484

Merged
merged 1 commit into from
Feb 6, 2025
Merged

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Feb 5, 2025

In v27.0.0 the chain changed from a string name to the integer ID:

root@validator0-us-east-1-testnet:~# zetaclientd version
27.0.1
root@validator0-us-east-1-testncurl -s localhost:8886/metrics | grep zetaclient_pending_txs_total_total
# HELP zetaclient_pending_txs_total Number of pending transactions per chain
# TYPE zetaclient_pending_txs_total gauge
zetaclient_pending_txs_total{chain="11155111"} 0
zetaclient_pending_txs_total{chain="18333"} 0
zetaclient_pending_txs_total{chain="18334"} 0
zetaclient_pending_txs_total{chain="421614"} 0
zetaclient_pending_txs_total{chain="43113"} 1
zetaclient_pending_txs_total{chain="80002"} 0
zetaclient_pending_txs_total{chain="84532"} 0
zetaclient_pending_txs_total{chain="901"} 0
zetaclient_pending_txs_total{chain="97"} 0

revert that to the v26 behavior:

root@zetaclient0:~# curl -s localhost:8886/metrics | grep zetaclient_pending_txs_total
# HELP zetaclient_pending_txs_total Number of pending transactions per chain
# TYPE zetaclient_pending_txs_total gauge
zetaclient_pending_txs_total{chain="btc_regtest"} 0
zetaclient_pending_txs_total{chain="goerli_localnet"} 0

No changelog as it will be released on v27.0.2

Summary by CodeRabbit

  • Documentation

    • Refined method comments to enhance clarity when listing pending cross-chain transactions.
  • Refactor

    • Transitioned from using simple numerical identifiers to a structured chain object across multiple components. This update standardizes the handling of chain data and improves associated metric labeling.

@gartnera gartnera added no-changelog Skip changelog CI check SOLANA_TESTS Run make start-solana-test TON_TESTS Runs TON E2E tests labels Feb 5, 2025
@gartnera gartnera requested a review from a team as a code owner February 5, 2025 19:14
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

📝 Walkthrough

Walkthrough

This pull request refactors the handling of chain identifiers in cross-chain transaction listing. The ListPendingCCTX method and its related calls are updated to use a full chain object instead of a simple integer chainID. These changes span multiple chain implementations, interface definitions, and mock setups, with a minor documentation update to reflect the new parameter type.

Changes

File(s) Change Summary
pkg/rpc/clients_crosschain.go Updated the method comment for ListPendingCCTX to refer to a "chain" rather than "chainID".
zetaclient/.../bitcoin.go, zetaclient/.../evm/evm.go, zetaclient/.../solana/solana.go, zetaclient/.../ton/ton.go In scheduleCCTX (and in TON’s updateChainParams), replaced direct chainID access with assignment of the full chain object, and updated calls to ListPendingCCTX to pass the entire chain.
zetaclient/.../interfaces/interfaces.go, zetaclient/.../mocks/zetacore_client.go, zetaclient/.../client_crosschain.go Changed the signature of ListPendingCCTX to accept a chains.Chain instead of an int64; updated metric labeling in the client to use chain.Name rather than converting a chainID.

Possibly related PRs

Suggested labels

refactor, breaking:cli

Suggested reviewers

  • fbac
  • kingpinXD
  • lumtis
  • skosito
  • brewmaster012
  • swift1337

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
zetaclient/chains/bitcoin/bitcoin.go (1)

133-134: Consider combining chain object usage.

While the implementation is correct, consider combining the chain object usage to reduce variable declarations:

-	chain := b.observer.Chain()
-	chainID := chain.ChainId
+	chain := b.observer.Chain()

Then update line 150 to use chain.ChainId directly:

-		if params.ReceiverChainId != chainID {
+		if params.ReceiverChainId != chain.ChainId {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02bbd81 and dc96c2b.

📒 Files selected for processing (8)
  • pkg/rpc/clients_crosschain.go (1 hunks)
  • zetaclient/chains/bitcoin/bitcoin.go (1 hunks)
  • zetaclient/chains/evm/evm.go (2 hunks)
  • zetaclient/chains/interfaces/interfaces.go (1 hunks)
  • zetaclient/chains/solana/solana.go (2 hunks)
  • zetaclient/chains/ton/ton.go (1 hunks)
  • zetaclient/testutils/mocks/zetacore_client.go (2 hunks)
  • zetaclient/zetacore/client_crosschain.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • pkg/rpc/clients_crosschain.go
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.go`: Review the Go code, point out issues relative to ...

**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

  • zetaclient/chains/evm/evm.go
  • zetaclient/chains/solana/solana.go
  • zetaclient/testutils/mocks/zetacore_client.go
  • zetaclient/chains/ton/ton.go
  • zetaclient/chains/bitcoin/bitcoin.go
  • zetaclient/zetacore/client_crosschain.go
  • zetaclient/chains/interfaces/interfaces.go
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: start-ton-test / e2e
  • GitHub Check: start-solana-test / e2e
  • GitHub Check: start-e2e-test / e2e
  • GitHub Check: Analyze (go)
  • GitHub Check: build-and-test
  • GitHub Check: gosec
🔇 Additional comments (6)
zetaclient/zetacore/client_crosschain.go (1)

16-26: LGTM! Clean implementation of chain name metrics.

The changes effectively implement the requirement to use chain names in metrics, providing better readability and maintainability.

zetaclient/chains/ton/ton.go (1)

133-135: LGTM! Clean chain object usage.

The implementation correctly uses the chain object, maintaining consistency with other chain handlers.

zetaclient/chains/interfaces/interfaces.go (1)

79-79: LGTM! Clean interface update.

The interface change properly reflects the new design pattern of using chain objects directly.

zetaclient/chains/solana/solana.go (1)

137-140: LGTM! Clean refactoring to use chain object.

The changes improve code clarity by explicitly defining the chain object before accessing its ID. This aligns with the PR objective of using chain objects consistently throughout the codebase.

Also applies to: 151-151

zetaclient/chains/evm/evm.go (1)

133-136: LGTM! Consistent refactoring with Solana implementation.

The changes follow the same clean pattern of explicitly defining the chain object before accessing its ID, maintaining consistency across different chain implementations.

Also applies to: 155-155

zetaclient/testutils/mocks/zetacore_client.go (1)

653-688: LGTM! Mock implementation correctly updated.

The auto-generated mock implementation correctly reflects the interface changes, updating the ListPendingCCTX method to use chains.Chain instead of int64.

Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 64.28571% with 5 lines in your changes missing coverage. Please review.

Project coverage is 65.29%. Comparing base (02bbd81) to head (dc96c2b).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/zetacore/client_crosschain.go 0.00% 3 Missing ⚠️
zetaclient/chains/ton/ton.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3484   +/-   ##
========================================
  Coverage    65.28%   65.29%           
========================================
  Files          441      441           
  Lines        30429    30430    +1     
========================================
+ Hits         19865    19868    +3     
+ Misses        9708     9706    -2     
  Partials       856      856           
Files with missing lines Coverage Δ
pkg/rpc/clients_crosschain.go 48.83% <ø> (ø)
zetaclient/chains/bitcoin/bitcoin.go 51.36% <100.00%> (+0.33%) ⬆️
zetaclient/chains/evm/evm.go 57.29% <100.00%> (+0.22%) ⬆️
zetaclient/chains/solana/solana.go 56.60% <100.00%> (+0.27%) ⬆️
zetaclient/chains/ton/ton.go 0.00% <0.00%> (ø)
zetaclient/zetacore/client_crosschain.go 47.05% <0.00%> (+2.61%) ⬆️

@gartnera gartnera enabled auto-merge February 5, 2025 22:02
@gartnera gartnera added this pull request to the merge queue Feb 6, 2025
Merged via the queue into develop with commit 2bcd4f5 Feb 6, 2025
48 of 49 checks passed
@gartnera gartnera deleted the use-chain-name-metrics branch February 6, 2025 08:22
gartnera added a commit that referenced this pull request Feb 6, 2025
* fix(zetaclient): use chain name in metrics (#3484)

* changelog
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
no-changelog Skip changelog CI check SOLANA_TESTS Run make start-solana-test TON_TESTS Runs TON E2E tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants