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

refactor: configure solana chain during e2e setup #2990

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Oct 10, 2024

Description

Configure solana during e2e setup rather than at genesis to avoid these zetaclient error messages during standard e2e run:

2024-10-10T17:25:42Z ERR PostGasPrice error for chain 902 error="GetSlot error: rpc call getSlot() on http://solana:8899: Post \"http://solana:8899\": dial tcp: lookup solana on 127.0.0.11:53: no such host" chain=902 chain_network=solana module=gasprice
2024-10-10T17:25:42Z ERR WatchInbound: observeInbound error error="error GetFirstSignatureForAddress for chain 902 address 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d: error GetSignaturesForAddressWithOpts for address 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d: rpc call getSignaturesForAddress() on http://solana:8899: Post \"http://solana:8899\": dial tcp: lookup solana on 127.0.0.11:53: no such host" chain=902 chain_network=solana module=inbound

This matches how TON is setup but we also reset the chain nonces like https://github.com/zeta-chain/gov-ops/pull/424

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

    • Updated method for setting up Solana contracts, enhancing initialization logic.
    • Added functionality to ensure Solana chain parameters during setup.
  • Bug Fixes

    • Improved clarity in transaction status checks for Solana withdrawals.
  • Chores

    • Removed Solana chain parameters from initialization and testing files to streamline local testing environments.

@gartnera gartnera added no-changelog Skip changelog CI check SOLANA_TESTS Run make start-solana-test labels Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.05%. Comparing base (a36bc0a) to head (8dd3e10).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2990      +/-   ##
===========================================
- Coverage    66.08%   66.05%   -0.04%     
===========================================
  Files          397      397              
  Lines        22334    22313      -21     
===========================================
- Hits         14760    14739      -21     
  Misses        6806     6806              
  Partials       768      768              
Files with missing lines Coverage Δ
x/observer/genesis.go 100.00% <ø> (ø)
x/observer/types/chain_params.go 92.39% <ø> (-0.49%) ⬇️

@gartnera gartnera marked this pull request as ready for review October 10, 2024 21:26
Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

📝 Walkthrough

Walkthrough

The pull request introduces significant updates to the handling of Solana contracts within the codebase. Key changes include renaming methods related to Solana contract setup, enhancing transaction status checks, and removing references to Solana chain parameters from various files. The modifications streamline the initialization logic for local testing environments and adjust the focus away from Solana, aligning the codebase with current requirements.

Changes

File Path Change Summary
cmd/zetae2e/local/local.go Updated localE2ETest to use deployerRunner.SetupSolana instead of SetSolanaContracts.
e2e/runner/setup_solana.go Renamed SetSolanaContracts to SetupSolana, added ensureSolanaChainParams method.
e2e/runner/solana.go Modified WithdrawSOLZRC20 to include a string argument in utils.RequireTxSuccessful calls.
x/observer/genesis.go Removed Solana chain parameters from InitGenesis, focusing on Bitcoin, Goerli, and Zeta Privnet.
x/observer/genesis_test.go Removed references to Solana chain parameters from test cases.
x/observer/types/chain_params.go Removed GetDefaultSolanaLocalnetChainParams function.
zetaclient/context/app_test.go Updated to remove references to Solana chain parameters and adjusted expected chain IDs.

Possibly related PRs

Suggested labels

UPGRADE_TESTS, UPGRADE_LIGHT_TESTS

Suggested reviewers

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

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

🧹 Outside diff range and nitpick comments (6)
e2e/e2etests/test_solana_withdraw.go (2)

23-23: Enhance error message for insufficient balance check.

While the balance check is crucial, consider improving the error message to provide more context:

require.Equal(r, 1, balanceBefore.Cmp(withdrawAmount), "Insufficient balance for withdrawal. Available: %s, Requested: %s", balanceBefore.String(), withdrawAmount.String())

This modification will offer more detailed information in case of a test failure.


31-31: Refine error message for withdrawal amount comparison.

To enhance clarity, consider modifying the error message as follows:

"Withdrawal amount (%s) must be less than the approved amount (1 SOL = %s lamports)", withdrawAmount.String(), approvedAmount.String()

This change provides more context and uses the actual values in the error message, aiding in debugging.

e2e/runner/solana.go (1)

165-165: Approval: Consistent enhancement of transaction context.

The addition of the "withdraw" parameter to utils.RequireTxSuccessful is a logical and consistent improvement, mirroring the earlier change. This modification further enhances the clarity and debuggability of the code.

To ensure consistency across the codebase, consider the following suggestion:

// Define constants for transaction types
const (
    TxTypeApprove  = "approve"
    TxTypeWithdraw = "withdraw"
    // Add other transaction types as needed
)

// Use constants in function calls
utils.RequireTxSuccessful(r, receipt, TxTypeApprove)
utils.RequireTxSuccessful(r, receipt, TxTypeWithdraw)

This refactoring would centralize transaction type definitions, reducing the risk of typos and improving maintainability.

zetaclient/context/app_test.go (1)

116-116: Approve the removal of Solana chain ID with a minor suggestion.

The removal of the Solana chain ID from the expectedIDs slice is consistent with the PR objectives and the overall changes to the codebase. This modification appropriately adjusts the test case to focus on the supported chains: Ethereum, Bitcoin, and the custom fancy L2 chain.

To enhance clarity and maintainability, consider using constants or variables for the chain IDs instead of hardcoding them. This approach would make the test more resilient to future changes in chain configurations.

Consider refactoring the line as follows:

expectedIDs := []int64{chains.Ethereum.ChainId, chains.BitcoinMainnet.ChainId, fancyL2.ChainId}

This change would make the test more robust and easier to maintain as it directly references the chain ID constants.

cmd/zetae2e/local/local.go (1)

229-229: Approve the change to SetupSolana and suggest a minor improvement.

The modification from SetSolanaContracts to SetupSolana aligns with the PR objectives of configuring the Solana chain during setup. This change is likely to address the reported issues with RPC calls to the Solana network during standard e2e runs.

To enhance clarity and maintainability, consider adding a brief comment explaining the purpose of this setup step:

 if testSolana {
+    // Configure Solana chain and deploy necessary contracts
     deployerRunner.SetupSolana(conf.AdditionalAccounts.UserSolana.SolanaPrivateKey.String())
 }

This comment will help future developers understand the significance of this step in the e2e test setup process.

e2e/runner/setup_solana.go (1)

4-5: Import Statements: Organize Imports According to Go Conventions

The added import "time" should be grouped appropriately. According to Go conventions, standard library imports should be separated from third-party and project-specific imports.

Consider organizing the imports as follows:

 package runner

-import (
-	"time"
-
-	ethcommon "github.com/ethereum/go-ethereum/common"
-	"github.com/gagliardetto/solana-go"
-	"github.com/gagliardetto/solana-go/rpc"
-	"github.com/near/borsh-go"
-	"github.com/pkg/errors"
-	"github.com/stretchr/testify/require"
-
-	"github.com/zeta-chain/node/e2e/utils"
-	"github.com/zeta-chain/node/pkg/chains"
-	"github.com/zeta-chain/node/pkg/constant"
-	solanacontracts "github.com/zeta-chain/node/pkg/contracts/solana"
-	observertypes "github.com/zeta-chain/node/x/observer/types"
-)
+import (
+	"time"
+	
+	ethcommon "github.com/ethereum/go-ethereum/common"
+	"github.com/gagliardetto/solana-go"
+	"github.com/gagliardetto/solana-go/rpc"
+	"github.com/near/borsh-go"
+	"github.com/pkg/errors"
+	"github.com/stretchr/testify/require"
+
+	"github.com/zeta-chain/node/e2e/utils"
+	"github.com/zeta-chain/node/pkg/chains"
+	"github.com/zeta-chain/node/pkg/constant"
+	solanacontracts "github.com/zeta-chain/node/pkg/contracts/solana"
+	observertypes "github.com/zeta-chain/node/x/observer/types"
+)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a36bc0a and 5faa2f9.

📒 Files selected for processing (8)
  • cmd/zetae2e/local/local.go (1 hunks)
  • e2e/e2etests/test_solana_withdraw.go (1 hunks)
  • e2e/runner/setup_solana.go (3 hunks)
  • e2e/runner/solana.go (2 hunks)
  • x/observer/genesis.go (0 hunks)
  • x/observer/genesis_test.go (0 hunks)
  • x/observer/types/chain_params.go (0 hunks)
  • zetaclient/context/app_test.go (1 hunks)
💤 Files with no reviewable changes (3)
  • x/observer/genesis.go
  • x/observer/genesis_test.go
  • x/observer/types/chain_params.go
🧰 Additional context used
📓 Path-based instructions (5)
cmd/zetae2e/local/local.go (1)

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

e2e/e2etests/test_solana_withdraw.go (1)

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

e2e/runner/setup_solana.go (1)

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

e2e/runner/solana.go (1)

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

zetaclient/context/app_test.go (1)

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

🔇 Additional comments (5)
e2e/e2etests/test_solana_withdraw.go (1)

16-17: Commendable introduction of a descriptive variable.

The addition of withdrawAmount enhances code clarity and separates concerns effectively.

e2e/runner/solana.go (2)

156-156: Approval: Enhanced transaction context provided.

The addition of the "approve" parameter to utils.RequireTxSuccessful is a commendable improvement. It enhances the clarity and debuggability of the code by providing specific context for the transaction being verified. This modification aligns with best practices for error handling and logging in production-grade software.


Line range hint 1-170: Summary: Improvements in transaction context and suggestion for further enhancement.

The changes made to the WithdrawSOLZRC20 method in e2e/runner/solana.go are beneficial, enhancing code clarity and debuggability. The consistent addition of transaction type parameters to utils.RequireTxSuccessful calls is commendable.

To further elevate the code quality:

  1. Consider implementing the suggested refactoring using constants for transaction types.
  2. Ensure this pattern is applied consistently across the entire codebase where similar transaction verifications occur.

These modifications contribute to a more robust and maintainable e2e testing framework for Solana interactions.

zetaclient/context/app_test.go (1)

Line range hint 1-265: Overall assessment: Changes are consistent and maintain test integrity.

The modifications to this test file, particularly the removal of Solana-related code, are consistent with the PR objectives. The changes maintain the integrity of the test cases for the supported chains (Ethereum, Bitcoin, and the custom fancy L2 chain) while removing unnecessary Solana-specific tests.

The overall structure and purpose of the test file remain intact, ensuring that the AppContext functionality is still thoroughly tested for the remaining supported chains. No further modifications appear necessary for this file.

e2e/runner/setup_solana.go (1)

29-30: Function Renaming: Ensure Consistency Across the Codebase

The function SetSolanaContracts has been renamed to SetupSolana. Please ensure that all references to the old function name throughout the codebase have been updated to prevent potential runtime errors.

Run the following script to find any outdated references:

e2e/runner/setup_solana.go Show resolved Hide resolved
e2e/runner/setup_solana.go Show resolved Hide resolved
@gartnera gartnera force-pushed the solana-dynamic-chain-params branch from 5faa2f9 to 5f48e79 Compare October 11, 2024 02:43
@gartnera gartnera changed the title chore(e2e): configure solana chain during setup refactor: configure solana chain during setup Oct 11, 2024
@gartnera gartnera changed the title refactor: configure solana chain during setup refactor: configure solana chain during e2e setup Oct 11, 2024
e2e/runner/setup_solana.go Show resolved Hide resolved
zetaclient/context/app_test.go Outdated Show resolved Hide resolved
cmd/zetae2e/local/local.go Show resolved Hide resolved
e2e/runner/setup_solana.go Show resolved Hide resolved
@gartnera gartnera requested a review from swift1337 October 11, 2024 15:39
@gartnera gartnera added this pull request to the merge queue Oct 11, 2024
Merged via the queue into develop with commit 404bd96 Oct 11, 2024
35 checks passed
@gartnera gartnera deleted the solana-dynamic-chain-params branch October 11, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli no-changelog Skip changelog CI check SOLANA_TESTS Run make start-solana-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants