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

feat: observation of inbound SOL token deposit #2465

Merged
merged 42 commits into from
Jul 19, 2024

Conversation

ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Jul 11, 2024

Description

Done:

  • Observation of inbound SOL token deposit
  • Observation of inbound tracker for SOL token deposit
  • Inbound related metrics.
  • Some necessary unit tests around above observations.
  • E2E test on gateway program initialization.
  • E2E test on inbound SOL token deposit.
  • Configure Solana config file and chain params in local e2e.
  • test inbound tracker.

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 Solana blockchain support, including inbound SOL token observation.
    • Added a new Solana Docker service for local network setup.
    • Implemented end-to-end testing routines and configurations for Solana.
  • Enhancements
    • Improved error handling and deployment logic for Solana ZRC20 tokens.
    • Enhanced logging and account balance output to include Solana token balances.
  • Bug Fixes
    • Corrected logging statements for Bitcoin and background task processing.
  • Documentation
    • Updated changelog to reflect new Solana functionality and features.

Copy link
Contributor

coderabbitai bot commented Jul 11, 2024

Walkthrough

The recent updates introduce robust support for the Solana blockchain across the project's infrastructure. Key changes encompass modifications to Docker configurations, the Makefile, and multiple Go files, integrating functionalities for Solana chain observation, testing routines, account management, and smart contract interactions. These enhancements are designed to streamline end-to-end testing and foster seamless interactions with the Solana ecosystem within the existing framework.

Changes

File(s) Change Summary
Dockerfile-localnet Modified COPY command to include all files in the directory
Makefile Added solana target and renamed start-e2e-test to start-solana-test
changelog.md Documented the addition of Solana inbound SOL token observation
cmd/zetaclientd/utils.go Added imports for Solana and observer types, and creation of Solana chain observer
cmd/zetae2e/config/clients.go, cmd/zetae2e/config/contracts.go Imported Solana RPC and updated client configurations
cmd/zetae2e/config/config.go, cmd/zetae2e/config/localnet.yml Added Solana-related fields and configurations, including new user account and RPC endpoint
cmd/zetae2e/init.go Added new flag for solanaURL
cmd/zetae2e/local/solana.go Introduced solanaTestRoutine function for Solana-related end-to-end tests
contrib/localnet/docker-compose.yml Added a new service solana
contrib/localnet/solana/Dockerfile, contrib/localnet/solana/start-solana.sh Created Dockerfile for Solana environment setup and script for starting the Solana test validator
e2e/config/config.go, e2e/e2etests/e2etests.go Added Solana keys and test functions for new testing scenarios
e2e/runner/runner.go, e2e/runner/setup_solana.go, e2e/runner/setup_zeta.go, e2e/runner/solana.go Integrated Solana fields/methods for account and contract setup
e2e/runner/balances.go, e2e/runner/accounting.go Updated to incorporate Solana balance management and TSS balance checks
e2e/txserver/zeta_tx_server.go Added logic for deploying and handling Solana ZRC20 tokens
pkg/chains/chain.go Added IsSolanaChain function to identify Solana chains
pkg/contract/solana/* Introduced data structures, constants, and functions for Solana gateway program

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant CLI as CLI Tool
    participant Docker as Docker
    participant Solana as Solana Node
    participant Tester as Test Runner
    participant Logger as Logger

    User->>CLI: Start Solana Test
    CLI->>Docker: Build Solana Docker Image
    Docker-->>CLI: Image Ready
    CLI->>Docker: Start Solana Container
    Docker-->>CLI: Container Running
    CLI->>Tester: Initiate Solana Test
    Tester->>Solana: Set Up Accounts
    Tester->>Solana: Deploy Programs
    Tester->>Solana: Run Tests
    Solana-->>Tester: Test Results
    Tester->>Logger: Log Results
    Logger-->>User: Test Complete
Loading

Poem

In Docker's realm, where files abound,
Solana's whispers gently sound.
New targets aim, tests now refined,
Blockchain's path with code aligned.
End-to-end, the journey's clear,
With Solana's light, we persevere.
Code and chains in harmony, cheer!


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

github-actions bot commented Jul 11, 2024

!!!WARNING!!!
nosec detected in the following files: zetaclient/chains/solana/observer/inbound.go, e2e/runner/accounting.go, testutil/sample/crypto.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Jul 11, 2024
cmd/solana/main.go Outdated Show resolved Hide resolved
@ws4charlie ws4charlie marked this pull request as ready for review July 16, 2024 04:31
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: 6

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 39497f4 and 492dcc4.

Files selected for processing (3)
  • zetaclient/chains/solana/observer/inbound.go (1 hunks)
  • zetaclient/chains/solana/observer/inbound_test.go (1 hunks)
  • zetaclient/chains/solana/observer/inbound_tracker.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • zetaclient/chains/solana/observer/inbound.go
  • zetaclient/chains/solana/observer/inbound_test.go
Additional context used
Path-based instructions (1)
zetaclient/chains/solana/observer/inbound_tracker.go (1)

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

Additional comments not posted (1)
zetaclient/chains/solana/observer/inbound_tracker.go (1)

15-16: Ensure context is not nil.

Before using the context, it is good practice to ensure it is not nil to avoid potential panics.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 492dcc4 and 31d09e3.

Files selected for processing (1)
  • zetaclient/chains/base/observer_test.go (18 hunks)
Files skipped from review as they are similar to previous changes (1)
  • zetaclient/chains/base/observer_test.go

@lumtis lumtis added UPGRADE_TESTS Run make start-upgrade-tests ADMIN_TESTS Run make start-admin-tests labels Jul 18, 2024
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a few comments. I'm also gonna run more advanced test in the CI since it is a big change

zetaclient/chains/solana/observer/inbound.go Outdated Show resolved Hide resolved
zetaclient/chains/solana/observer/inbound_tracker.go Outdated Show resolved Hide resolved
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 31d09e3 and 919260b.

Files selected for processing (2)
  • zetaclient/chains/solana/observer/inbound.go (1 hunks)
  • zetaclient/chains/solana/observer/inbound_tracker.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • zetaclient/chains/solana/observer/inbound.go
  • zetaclient/chains/solana/observer/inbound_tracker.go

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

👍

pkg/bg/bg.go Outdated Show resolved Hide resolved
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 919260b and da593ce.

Files selected for processing (1)
  • pkg/bg/bg.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • pkg/bg/bg.go

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between da593ce and 966b56b.

Files selected for processing (1)
  • pkg/bg/bg_test.go (2 hunks)
Additional context used
Path-based instructions (1)
pkg/bg/bg_test.go (1)

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

Additional comments not posted (3)
pkg/bg/bg_test.go (3)

73-78: LGTM! The changes improve the test assertions.

The use of require.Contains is appropriate for checking the presence of substrings in the log output. This ensures that the test will fail immediately if the expected substrings are not found.


Line range hint 39-54:
LGTM! The use of assert.JSONEq is appropriate.

The use of assert.JSONEq ensures that the log output matches the expected JSON structure exactly.


Line range hint 15-28:
LGTM! The use of assertChanClosed is appropriate.

The use of assertChanClosed ensures that the work function has completed and the signal channel is closed.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 966b56b and 9df010d.

Files selected for processing (2)
  • zetaclient/chains/solana/observer/inbound.go (1 hunks)
  • zetaclient/chains/solana/observer/observer.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • zetaclient/chains/solana/observer/inbound.go
  • zetaclient/chains/solana/observer/observer.go

@ws4charlie ws4charlie force-pushed the solana-observe-inbound-SOL branch from 9df010d to b15c080 Compare July 19, 2024 15:46
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: 8

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9df010d and b15c080.

Files selected for processing (2)
  • zetaclient/chains/solana/observer/inbound.go (1 hunks)
  • zetaclient/chains/solana/observer/observer.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • zetaclient/chains/solana/observer/observer.go
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.

@lumtis lumtis added this pull request to the merge queue Jul 19, 2024
Merged via the queue into develop with commit 3ad6f99 Jul 19, 2024
29 of 30 checks passed
@lumtis lumtis deleted the solana-observe-inbound-SOL branch July 19, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADMIN_TESTS Run make start-admin-tests breaking:cli ci Changes to CI pipeline or github actions nosec SOLANA_TESTS Run make start-solana-test UPGRADE_TESTS Run make start-upgrade-tests
Projects
None yet
6 participants