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(e2e): solana upgrade contract e2e test #3536

Merged
merged 29 commits into from
Feb 25, 2025
Merged

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Feb 14, 2025

Description

Related PR from protocol-contracts-solana
zeta-chain/protocol-contracts-solana#81

Refer this issue for more context : #3535

Closes : #3443

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 command for executing end-to-end tests focused on contract upgrades.
    • Enhanced blockchain integration with support for SOL/SPL withdrawals, deposits, and an advanced abort workflow.
    • Upgraded the local testing environment to streamline Solana contract upgrades through automated setup and deployment.
  • Bug Fixes

    • Resolved issues in withdrawal amount verification to improve transaction reliability.
  • Tests

    • Added enhanced verification steps to confirm successful Solana contract upgrades during testing.

Copy link
Contributor

coderabbitai bot commented Feb 14, 2025

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

This pull request introduces a new Makefile target to initiate an end-to-end test for upgrading Solana contracts. It adds and updates several Docker Compose configurations, Dockerfile modifications, and shell scripts to deploy and upgrade Solana programs in a local network environment. Additionally, the changes enhance the testing framework by adding a new verification method and assertion utilities in the test packages, and update the changelog with new features and integrations related to contract upgrades.

Changes

File(s) Summary
Makefile Added a new target start-e2e-test-upgrade-contracts setting environment flags and initiating Docker Compose with a specific upgrade contracts configuration.
changelog.md Updated changelog entries with new features such as the advanced abort workflow, ConfirmationParams, MsgRemoveInboundTracker, new blockchain integrations (SOL, SPL, Sui), and an end-to-end test for upgrading the Solana gateway program.
cmd/zetae2e/local/local.go, e2e/runner/setup_solana.go,
e2e/runner/verify.go, testutil/helpers.go
Enhanced the e2e testing framework: added a new variable requireTrue for assertions, introduced the VerifySolanaContractsUpgrade method to validate contract upgrades, fixed a variable name for withdrawal verification, and added a new utility function True for error checking.
contrib/localnet/docker-compose-upgrade-contracts.yml,
contrib/localnet/solana/Dockerfile,
contrib/localnet/solana/start-solana-upgrade.sh,
contrib/localnet/solana/start-solana.sh
Introduced a new Docker Compose configuration to support contract upgrades, modified the Solana Dockerfile to include a new upgrade script (start-solana-upgrade.sh) and binary (gateway_upgrade.so), added a new shell script to automate keypair generation, validator setup, program deployment, and upgrade process, and updated the existing start script to deploy initial programs.
pkg/contracts/solana/pda.go Added a new struct PdaInfoUpgraded that extends the existing PDA information with an Upgraded boolean flag, used for verifying the contract upgrade process.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Makefile
    participant Docker
    participant SolanaScript
    participant E2ERunner
    participant TestUtil

    User->>Makefile: Run target "start-e2e-test-upgrade-contracts"
    Makefile->>Docker: Execute docker-compose with upgrade configuration
    Docker->>SolanaScript: Launch container with entrypoint "start-solana-upgrade.sh"
    SolanaScript->>SolanaScript: Generate keypair, start validator, perform airdrops, deploy programs, and upgrade gateway program
    Note over SolanaScript: Upgrade contracts process completes
    E2ERunner->>E2ERunner: Invoke VerifySolanaContractsUpgrade()
    E2ERunner->>TestUtil: Use "requireTrue" for assertion check
    TestUtil-->>E2ERunner: Return assertion result
Loading

Possibly related PRs

Suggested labels

E2E, SOLANA_TESTS, UPGRADE_TESTS

Suggested reviewers

  • skosito
  • ws4charlie
  • brewmaster012
  • fbac
  • 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 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.

@kingpinXD kingpinXD changed the title e2e : solana upgrade contract e2e test test : solana upgrade contract e2e test Feb 14, 2025
@kingpinXD kingpinXD changed the title test : solana upgrade contract e2e test test: solana upgrade contract e2e test Feb 18, 2025
@kingpinXD kingpinXD changed the title test: solana upgrade contract e2e test test(e2e): solana upgrade contract e2e test Feb 18, 2025
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.80%. Comparing base (380b545) to head (970d7ba).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3536   +/-   ##
========================================
  Coverage    64.80%   64.80%           
========================================
  Files          462      462           
  Lines        31934    31934           
========================================
  Hits         20694    20694           
  Misses       10332    10332           
  Partials       908      908           

@kingpinXD kingpinXD marked this pull request as ready for review February 18, 2025 18:16
@kingpinXD kingpinXD requested a review from a team as a code owner February 18, 2025 18:16
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

🧹 Nitpick comments (3)
cmd/zetae2e/local/local.go (1)

291-294: Add error context to contract upgrade verification.

While the verification is correct, adding error context would help with debugging failures.

 if upgradeContracts {
   deployerRunner.UpgradeGatewaysAndERC20Custody()
-  requireTrue(deployerRunner.VerifySolanaContractsUpgrade())
+  requireTrue(deployerRunner.VerifySolanaContractsUpgrade(), "Solana contract upgrade verification failed")
 }
contrib/localnet/solana/start-solana-upgrade.sh (1)

1-18: Consider extracting common setup logic.

The initial setup logic is duplicated from start-solana.sh. Consider extracting common setup into a shared script.

Create a new file setup-common.sh:

#!/bin/bash

setup_solana() {
    echo "making an id"
    solana-keygen new -o /root/.config/solana/id.json --no-bip39-passphrase

    solana config set --url localhost
    echo "starting solana test validator..."
    solana-test-validator &

    sleep 5
    # airdrop to e2e sol account
    solana airdrop 1000
    solana airdrop 1000 37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ
}
Makefile (1)

277-281: Clarify the echo message for the new upgrade test target.
The target correctly sets the required environment variable and invokes Docker Compose with the proper profile and Compose file. However, the echo message output as "--> Starting e2e test" is generic and may be ambiguous given the number of similar targets. It would be more informative to modify it to explicitly reference the contract upgrade functionality (for example, "--> Starting e2e test for upgrading Solana gateway contracts").

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 51f83b5 and fb318cf.

⛔ Files ignored due to path filters (3)
  • contrib/localnet/scripts/gateway-upgrade.so is excluded by !**/*.so
  • contrib/localnet/solana/gateway.so is excluded by !**/*.so
  • contrib/localnet/solana/gateway_upgrade.so is excluded by !**/*.so
📒 Files selected for processing (11)
  • Makefile (1 hunks)
  • changelog.md (1 hunks)
  • cmd/zetae2e/local/local.go (2 hunks)
  • contrib/localnet/docker-compose-upgrade-contracts.yml (1 hunks)
  • contrib/localnet/solana/Dockerfile (1 hunks)
  • contrib/localnet/solana/start-solana-upgrade.sh (1 hunks)
  • contrib/localnet/solana/start-solana.sh (1 hunks)
  • e2e/runner/setup_solana.go (1 hunks)
  • e2e/runner/verify.go (1 hunks)
  • pkg/contracts/solana/pda.go (1 hunks)
  • testutil/helpers.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • contrib/localnet/docker-compose-upgrade-contracts.yml
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.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.

  • testutil/helpers.go
  • e2e/runner/verify.go
  • cmd/zetae2e/local/local.go
  • e2e/runner/setup_solana.go
  • pkg/contracts/solana/pda.go
`**/*.sh`: Review the shell scripts, point out issues relati...

**/*.sh: Review the shell scripts, point out issues relative to security, performance, and maintainability.

  • contrib/localnet/solana/start-solana.sh
  • contrib/localnet/solana/start-solana-upgrade.sh
🔇 Additional comments (6)
e2e/runner/verify.go (1)

56-57: LGTM!

The variable renaming improves code clarity and maintains consistent naming conventions.

Also applies to: 60-60

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

58-61: LGTM! Clean variable declarations.

The addition of requireTrue follows the existing pattern and improves code readability.


50-50: LGTM! Well-documented flag addition.

The flagUpgradeContracts follows the established naming convention and its purpose is clear.

contrib/localnet/solana/Dockerfile (1)

5-14: LGTM! Clean Dockerfile modifications.

The changes properly handle script permissions and maintain a consistent structure with existing patterns.

contrib/localnet/solana/start-solana.sh (1)

14-18: Consider conditional program deployment.

As per previous discussions, deploying programs immediately might prevent testing with old contracts. Consider making the deployment conditional based on a flag.

changelog.md (1)

32-35: New Changelog Entry for Solana Gateway Upgrade E2E Test.
The newly added entry for PR 3536 clearly documents the addition of an e2e test for upgrading the Solana gateway program. Ensure that this entry remains consistent with the descriptions in other related sections (such as the Makefile target) and consider emphasizing that this test enhances the reliability of the upgrade workflow.

@kingpinXD kingpinXD requested a review from skosito February 20, 2025 04:01
@kingpinXD kingpinXD requested a review from gartnera February 21, 2025 01:13
@kingpinXD kingpinXD self-assigned this Feb 21, 2025
@kingpinXD kingpinXD added the SOLANA_TESTS Run make start-solana-test label Feb 21, 2025
@kingpinXD kingpinXD requested a review from lumtis February 21, 2025 15:06
Copy link
Contributor

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

@kingpinXD kingpinXD requested a review from gartnera February 24, 2025 17:28
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.

Would be great to get approval from @gartnera before merging

@kingpinXD kingpinXD enabled auto-merge February 25, 2025 16:38
@kingpinXD kingpinXD added this pull request to the merge queue Feb 25, 2025
Merged via the queue into develop with commit d3eb81c Feb 25, 2025
45 checks passed
@kingpinXD kingpinXD deleted the sol-e2e-contract-upgrade branch February 25, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli SOLANA_TESTS Run make start-solana-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Solana Upgrade tests
5 participants