Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: update Solana last scanned block more frequently #3314

Merged
merged 5 commits into from
Dec 18, 2024

Conversation

ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Dec 17, 2024

Description

The last_scanned_block_number metrics in Solana is updated only when there are new gateway transactions detected. In a low traffic period of time, the value of the metrics won't be increasing and reflecting the actual progress of inbound scanner.

Fix:

  • If there is no new gateway transaction happens, zetaclient simply queries the latest Solana slot and set it to last_scanned_block_number.

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features
    • Introduced a new telemetry endpoint /systemtime in the application.
  • Bug Fixes
    • Enhanced error handling for Solana inbound queries and improved transaction version support.
    • Updated metrics for last_scanned_block_number for more frequent updates.
  • Refactor
    • Comprehensive revamp of the TSS package and initialization process for improved performance and graceful shutdown.
  • Tests
    • Enhanced testing framework with new performance tests for Solana E2E and simulation tests for custom modules.

Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces significant enhancements to the ZetaChain system, focusing primarily on Solana chain integration and observability. The changes encompass improvements in telemetry, transaction handling, testing frameworks, and system robustness. Key modifications include adding a new /systemtime endpoint, refactoring the TSS package, enhancing error handling for Solana transactions, and implementing more sophisticated metrics and logging mechanisms.

Changes

File Change Summary
changelog.md Comprehensive update documenting new features, tests, refactors, and fixes across multiple versions
zetaclient/chains/solana/observer/inbound.go Enhanced signature processing logic, improved error handling for Solana slot querying

Possibly related PRs

Suggested Labels

bug, chain:solana

Suggested Reviewers

  • lumtis
  • fbac
  • kingpinXD
  • skosito
  • brewmaster012

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.

@ws4charlie ws4charlie marked this pull request as ready for review December 17, 2024 19:42
@ws4charlie ws4charlie requested a review from a team as a code owner December 17, 2024 19:42
@ws4charlie ws4charlie added zetaclient Issues related to ZetaClient SOLANA_TESTS Run make start-solana-test labels Dec 17, 2024
Copy link
Contributor

@morde08 morde08 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 61.75%. Comparing base (8d25c74) to head (0aad9ac).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/solana/observer/inbound.go 0.00% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3314      +/-   ##
===========================================
- Coverage    61.77%   61.75%   -0.02%     
===========================================
  Files          440      440              
  Lines        31163    31171       +8     
===========================================
  Hits         19251    19251              
- Misses       11049    11057       +8     
  Partials       863      863              
Files with missing lines Coverage Δ
zetaclient/chains/solana/observer/inbound.go 34.58% <0.00%> (-1.20%) ⬇️

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 (3)
zetaclient/chains/solana/observer/inbound.go (3)

84-89: Consider enhancing error handling for last slot query

The error from GetSlot is logged but not propagated, which could mask underlying RPC connectivity issues. Consider propagating this error or implementing a retry mechanism for critical RPC calls.

 lastSlot, errSlot := ob.solClient.GetSlot(ctx, rpc.CommitmentFinalized)
 if errSlot != nil {
-    ob.Logger().Inbound.Err(errSlot).Msg("unable to get last slot")
+    ob.Logger().Inbound.Error().Err(errSlot).Msg("unable to get last slot")
+    // Consider implementing exponential backoff retry for RPC calls
+    // return errors.Wrap(errSlot, "failed to get last finalized slot")
 }

Line range hint 1-11: Consider making MaxSignaturesPerTicker configurable

While 100 signatures per ticker is a reasonable default, this critical parameter affects system performance and resource usage. Consider making it configurable through chain parameters to allow runtime tuning.


Line range hint 150-300: Consider refactoring FilterInboundEvents for better maintainability

While the function is well-documented, its length and complexity make it harder to maintain. Consider:

  1. Extracting deposit parsing logic into separate methods
  2. Creating a common logging helper for duplicate patterns
  3. Using a strategy pattern for different deposit types
+ // Example refactored structure:
+ func (ob *Observer) parseDeposit(tx *solana.Transaction, i int, slot uint64) (*Deposit, error)
+ func (ob *Observer) parseDepositSPL(tx *solana.Transaction, i int, slot uint64) (*Deposit, error)
+ func (ob *Observer) logDepositEvent(sig string, i int, depositType string)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6730285 and 912a243.

📒 Files selected for processing (2)
  • changelog.md (1 hunks)
  • zetaclient/chains/solana/observer/inbound.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
zetaclient/chains/solana/observer/inbound.go (1)

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

🔇 Additional comments (2)
zetaclient/chains/solana/observer/inbound.go (1)

98-103: LGTM: Well-structured metrics update logic

The implementation correctly updates the last scanned block metric even when no new signatures are found, which aligns with the PR objective to update metrics more frequently. The error check before updating metrics prevents incorrect updates.

changelog.md (1)

31-31: LGTM: Changes properly documented in changelog

The changelog entry accurately reflects the implementation changes for more frequent updates of the last_scanned_block_number metrics.

@CryptoFewka CryptoFewka added this pull request to the merge queue Dec 18, 2024
Merged via the queue into develop with commit 7d93d5a Dec 18, 2024
43 of 44 checks passed
@CryptoFewka CryptoFewka deleted the update-Solana-last-scanned-block-more-frequently branch December 18, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SOLANA_TESTS Run make start-solana-test zetaclient Issues related to ZetaClient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants