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

test: fix local zetae2e run solana tests and balances #3217

Merged
merged 3 commits into from
Nov 26, 2024
Merged

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Nov 26, 2024

Description

Enabling zetae2e run and zetae2e balances to work with solana.
Currently tested on solana tests locally like this:

zetae2e run solana_deposit:1200000 --config cmd/zetae2e/config/local.yml
e2e          | starting tests
e2e          | ⚙️ setting up TSS address
e2e          | ⏳running - deposit SOL into ZEVM
e2e          | ✅ completed in 21.584853917s - deposit SOL into ZEVM
e2e          | tests finished successfully in 26.61211475s
e2e          |  ---📈 E2E Test Report ---
Name              Success    Time             Spent
solana_deposit    ✅          26.598543208s 

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

    • Added support for Solana accounts, including new fields for solana_address and solana_private_key.
    • Enhanced account balance functionality to retrieve and display Solana balances.
  • Bug Fixes

    • Improved error handling for Solana balance retrieval.
  • Documentation

    • Updated logging statements to reflect new Solana balance fields.

@skosito skosito added the no-changelog Skip changelog CI check label Nov 26, 2024
Copy link
Contributor

coderabbitai bot commented Nov 26, 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

Walkthrough

The pull request introduces modifications to the local.yml configuration file and the balances.go file to enhance support for Solana functionalities. In local.yml, new fields for Solana account information are added, alongside updates to existing contract addresses. The balances.go file is updated to include new fields for Solana balances and modifies methods to retrieve and log these balances correctly. These changes collectively expand the system's capabilities to handle multi-chain operations, particularly with Solana.

Changes

File Change Summary
cmd/zetae2e/config/local.yml - Added solana_address and solana_private_key to default_account.
- Updated user_solana to include solana_private_key.
- Updated erc20_zrc20 address and added sol_zrc20 and spl_zrc20 in contracts.
e2e/runner/balances.go - Added SolSOL and SolSPL fields to AccountBalances struct.
- Modified GetAccountBalances to retrieve Solana balances and adjusted error handling.
- Updated logging in PrintAccountBalances to reflect new Solana balance fields.

Possibly related PRs

Suggested labels

SOLANA_TESTS, UPGRADE_TESTS

Suggested reviewers

  • gartnera
  • kingpinXD
  • fbac
  • lumtis
  • brewmaster012
  • swift1337

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 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

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.06%. Comparing base (cad1b36) to head (7a1ffcd).
Report is 10 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3217      +/-   ##
===========================================
- Coverage    62.74%   62.06%   -0.69%     
===========================================
  Files          425      428       +3     
  Lines        30231    30438     +207     
===========================================
- Hits         18969    18890      -79     
- Misses       10425    10708     +283     
- Partials       837      840       +3     

see 29 files with indirect coverage changes

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: 4

🧹 Outside diff range and nitpick comments (2)
cmd/zetae2e/config/local.yml (1)

Line range hint 31-31: Avoid reusing credentials across different accounts

The same Solana private key is used in both default_account and user_solana. For testing clarity and to better simulate production scenarios, consider using unique credentials for each account.

🧰 Tools
🪛 Gitleaks (8.21.2)

5-5: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

e2e/runner/balances.go (1)

101-109: Enhance error handling and use constants for commitment

The error handling could be more specific, and the commitment level should be defined as a constant.

Consider these improvements:

+const defaultCommitment = rpc.CommitmentFinalized
+
 if r.Account.SolanaAddress != "" && r.Account.SolanaPrivateKey != "" {
   solSOLBalance, err := r.SolanaClient.GetBalance(
     r.Ctx,
     solana.MustPublicKeyFromBase58(r.Account.SolanaAddress.String()),
-    rpc.CommitmentFinalized,
+    defaultCommitment,
   )
   if err != nil {
-    return AccountBalances{}, err
+    return AccountBalances{}, fmt.Errorf("failed to get SOL balance: %w", err)
   }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cc3bc86 and b7dfc66.

📒 Files selected for processing (2)
  • cmd/zetae2e/config/local.yml (3 hunks)
  • e2e/runner/balances.go (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
e2e/runner/balances.go (1)

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

🪛 Gitleaks (8.21.2)
cmd/zetae2e/config/local.yml

7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (2)
cmd/zetae2e/config/local.yml (1)

111-111: Verify contract addresses across environments

The contract addresses have been updated to support Solana integration. Please ensure these addresses are:

  1. Correctly deployed and verified
  2. Consistent with other test environments
  3. Compatible with the local test network configuration

Also applies to: 120-121

✅ Verification successful

The previous attempt to verify contract deployment status failed as it required a running local node. Let's instead analyze the configuration files and deployment scripts to understand the contract address usage and verification process across environments.


The previous search was too broad. Let's focus specifically on the configuration files and deployment scripts that might reference these contract addresses to verify their consistency across environments.


Contract addresses are consistently configured across local and example environments

The verification shows that:

  1. The erc20_zrc20 address is identical in both local and example configurations
  2. The new sol_zrc20 and spl_zrc20 addresses are properly added to the local configuration
  3. All addresses follow the correct EVM address format (40 hex characters with 0x prefix)

The contract addresses are properly configured and consistent with the test environment setup.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify contract addresses are properly deployed

# Check if contracts are deployed and accessible
for addr in "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7"; do
  curl -X POST -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\",\"params\":[\"$addr\", \"latest\"],\"id\":1}" http://localhost:9545
done

Length of output: 2255


Script:

#!/bin/bash
# Let's check for contract addresses in configuration files across the repository
rg -g '*.{yml,yaml,json}' -i '0x[a-fA-F0-9]{40}' -B 2 -A 2

# Also check for any contract deployment or verification scripts
fd -e js -e ts -e sh "deploy|verify" --exec head -n 20 {}

Length of output: 131676


Script:

#!/bin/bash
# Let's check for contract addresses in configuration files
rg -g '*.{yml,yaml}' -B 2 -A 2 'erc20_zrc20|sol_zrc20|spl_zrc20'

# Also check for any deployment or verification scripts that might contain contract addresses
fd -e js -e ts -e sh "deploy|verify" --type f --exec grep -l "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" {} \;

Length of output: 1596

e2e/runner/balances.go (1)

10-11: LGTM: Clean integration of Solana support

The new imports and struct fields maintain consistency with the existing codebase patterns.

Also applies to: 30-31

cmd/zetae2e/config/local.yml Show resolved Hide resolved
e2e/runner/balances.go Outdated Show resolved Hide resolved
e2e/runner/balances.go Outdated Show resolved Hide resolved
e2e/runner/balances.go Outdated Show resolved Hide resolved
Copy link

!!!WARNING!!!
nosec detected in the following files: e2e/runner/balances.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 Nov 26, 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.

LGTM

@skosito skosito added this pull request to the merge queue Nov 26, 2024
Merged via the queue into develop with commit 08ff881 Nov 26, 2024
41 checks passed
@skosito skosito deleted the solana-e2e-run branch November 26, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Skip changelog CI check nosec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants