Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: use connected pda seed for execute and execute spl #3637

Merged
merged 3 commits into from
Mar 5, 2025

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Mar 5, 2025

Description

solana PR for details: zeta-chain/protocol-contracts-solana#88

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

  • Refactor
    • Unified the process for computing program addresses across various components.
    • Removed redundant methods to simplify and standardize address computation while preserving error handling.

@skosito skosito added no-changelog Skip changelog CI check SOLANA_TESTS Run make start-solana-test labels Mar 5, 2025
@skosito skosito requested a review from a team as a code owner March 5, 2025 04:30
Copy link
Contributor

coderabbitai bot commented Mar 5, 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 updates the codebase to replace all calls to the deprecated
ComputeConnectedSPLPdaAddress function with the new ComputeConnectedPdaAddress variant.
The change spans across test files, runner modules, and client operations related to Solana PDA computations. Additionally, the legacy function is removed from the gateway package. Error handling remains unchanged throughout these updates.

Changes

File(s) Change Summary
e2e/e2etests/test_spl_withdraw_and_call.go
e2e/e2etests/test_spl_withdraw_and_call_revert.go
Updated function calls from ComputeConnectedSPLPdaAddress to ComputeConnectedPdaAddress in test cases; error handling remains unchanged.
e2e/runner/setup_solana.go
e2e/runner/solana.go
zetaclient/chains/solana/signer/execute_spl.go
Modified function calls to use ComputeConnectedPdaAddress in setup routines and SPL token operations, preserving existing error checks.
pkg/contracts/solana/gateway.go Removed the legacy ComputeConnectedSPLPdaAddress function to simplify the PDA computation interface.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Test/Runner
    participant Contract as solanacontract.ComputeConnectedPdaAddress
    participant Checker as require.NoError

    Client->>Contract: ComputeConnectedPdaAddress(connected)
    Contract-->>Client: PDA Address or error
    Client->>Checker: Validate error status
Loading

Possibly related PRs

Suggested reviewers

  • lumtis
  • gartnera
  • swift1337

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @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 Mar 5, 2025

Codecov Report

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

Project coverage is 64.56%. Comparing base (f7681d8) to head (6dc37b2).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/solana/signer/execute_spl.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3637   +/-   ##
========================================
  Coverage    64.56%   64.56%           
========================================
  Files          469      469           
  Lines        32772    32772           
========================================
  Hits         21159    21159           
  Misses       10648    10648           
  Partials       965      965           
Files with missing lines Coverage Δ
zetaclient/chains/solana/signer/execute_spl.go 0.00% <0.00%> (ø)

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

🧹 Nitpick comments (1)
zetaclient/chains/solana/signer/execute_spl.go (1)

50-54: Function replacement may need error message adjustment.

The function call has been updated to use ComputeConnectedPdaAddress instead of the previously used ComputeConnectedSPLPdaAddress, which aligns with the systematic refactoring across the codebase. However, the error message on line 53 still references "cannot decode connected spl pda address" which is inconsistent with the generalized function now being used.

Consider updating the error message to reflect the more general PDA computation:

- return nil, errors.Wrap(err, "cannot decode connected spl pda address")
+ return nil, errors.Wrap(err, "cannot compute connected pda address")

Additionally, this code path lacks test coverage according to static analysis, which should be addressed to ensure the refactoring functions correctly.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 51-51: zetaclient/chains/solana/signer/execute_spl.go#L51
Added line #L51 was not covered by tests

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5041002 and d9e5442.

⛔ Files ignored due to path filters (1)
  • contrib/localnet/solana/connected_spl.so is excluded by !**/*.so
📒 Files selected for processing (6)
  • e2e/e2etests/test_spl_withdraw_and_call.go (1 hunks)
  • e2e/e2etests/test_spl_withdraw_and_call_revert.go (1 hunks)
  • e2e/runner/setup_solana.go (1 hunks)
  • e2e/runner/solana.go (1 hunks)
  • pkg/contracts/solana/gateway.go (0 hunks)
  • zetaclient/chains/solana/signer/execute_spl.go (2 hunks)
💤 Files with no reviewable changes (1)
  • pkg/contracts/solana/gateway.go
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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.

  • e2e/e2etests/test_spl_withdraw_and_call_revert.go
  • e2e/runner/solana.go
  • e2e/e2etests/test_spl_withdraw_and_call.go
  • e2e/runner/setup_solana.go
  • zetaclient/chains/solana/signer/execute_spl.go
🪛 GitHub Check: codecov/patch
zetaclient/chains/solana/signer/execute_spl.go

[warning] 51-51: zetaclient/chains/solana/signer/execute_spl.go#L51
Added line #L51 was not covered by tests


[warning] 110-110: zetaclient/chains/solana/signer/execute_spl.go#L110
Added line #L110 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: start-solana-test / e2e
  • GitHub Check: start-e2e-test / e2e
🔇 Additional comments (4)
e2e/e2etests/test_spl_withdraw_and_call_revert.go (1)

53-53: Updated function name to use generic PDA computation

The function call has been updated from ComputeConnectedSPLPdaAddress to ComputeConnectedPdaAddress, which aligns with the standardization of PDA address computation across the codebase. This change provides consistency with the related Solana PR mentioned in the objectives.

e2e/e2etests/test_spl_withdraw_and_call.go (1)

56-56: Updated function name to use generic PDA computation

The function call has been updated from ComputeConnectedSPLPdaAddress to ComputeConnectedPdaAddress, which consolidates the PDA computation logic. This is consistent with the changes in other files and follows the refactoring approach outlined in the PR objectives.

e2e/runner/solana.go (1)

578-578:

✅ Verification successful

Updated function name to use generic PDA computation

The function call has been updated from ComputeConnectedSPLPdaAddress to ComputeConnectedPdaAddress. This change maintains functional equivalence while providing a more consistent API for PDA address computation.


🏁 Script executed:

#!/bin/bash
# Verify if there are any remaining instances of ComputeConnectedSPLPdaAddress in the codebase
echo "Searching for any remaining references to ComputeConnectedSPLPdaAddress:"
rg "ComputeConnectedSPLPdaAddress" --type go
echo "Done."

Length of output: 218


Update Verified: Consistent API Naming for PDA Computation

The change from ComputeConnectedSPLPdaAddress to ComputeConnectedPdaAddress has been verified. The shell script search confirmed that no references to the deprecated function remain in the codebase. The updated function call at e2e/runner/solana.go at line 578 now consistently uses the generic naming convention, ensuring a more uniform API.

e2e/runner/setup_solana.go (1)

98-98:

✅ Verification successful

Updated function name to use generic PDA computation

The function call has been updated from ComputeConnectedSPLPdaAddress to ComputeConnectedPdaAddress. This change is part of the standardization of PDA address computation across the codebase, making it more maintainable and consistent.


🏁 Script executed:

#!/bin/bash
# Check if the implementation of ComputeConnectedPdaAddress properly handles SPL-specific cases
echo "Examining the implementation of ComputeConnectedPdaAddress:"
rg -A 10 "func ComputeConnectedPdaAddress" --type go
echo "Done."

Length of output: 446


Standardized PDA Computation Verified

The updated function call in e2e/runner/setup_solana.go now uses ComputeConnectedPdaAddress, and verification confirms that its implementation in pkg/contracts/solana/gateway.go correctly delegates to ComputePdaAddress with appropriate parameters. This change achieves the intended standardization of PDA address computation across the codebase without any unintended SPL-specific handling remaining.

  • File: pkg/contracts/solana/gateway.go
    • Detail: The function ComputeConnectedPdaAddress calls ComputePdaAddress(connected, []byte("connected")).

No further modifications are required.

@skosito skosito enabled auto-merge March 5, 2025 15:33
@skosito skosito added this pull request to the merge queue Mar 5, 2025
Merged via the queue into develop with commit 052d7d7 Mar 5, 2025
44 of 45 checks passed
@skosito skosito deleted the fix-connected-pda-seed branch March 5, 2025 16:08
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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