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

fix: integrate withdraw spl create ata fix #3238

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Dec 3, 2024

Description

integrates changes from this PR

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

Release Notes

  • New Features

    • Streamlined Solana setup process by removing unnecessary rent payer initialization logic.
  • Bug Fixes

    • Clarified comments in tests for better understanding of withdrawal processes.
  • Chores

    • Removed outdated rent payer-related constants, functions, and instructions from the codebase to simplify the Solana gateway program.

These changes enhance the efficiency and clarity of the Solana integration, improving user experience during setup and operation.

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

coderabbitai bot commented Dec 3, 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

The pull request introduces several modifications across multiple files, primarily focusing on the removal of functionalities related to the rent payer in the Solana ecosystem. Key changes include the deletion of airdrop commands in the start-solana.sh script, the removal of the rent payer initialization logic in the SetupSolana method, and the elimination of related constants and functions throughout the codebase. The overall structure and functionality of the remaining components are preserved, with an emphasis on simplifying the setup and transaction processes.

Changes

File Change Summary
contrib/localnet/solana/start-solana.sh Simplified comments; removed airdrop command for specific account; retained commands for default and specified accounts.
e2e/e2etests/test_spl_withdraw_and_create_receiver_ata.go Clarified comment for TestSPLWithdrawAndCreateReceiverAta function; logic remains unchanged.
e2e/runner/setup_solana.go Removed rent payer initialization code; streamlined SetupSolana method.
e2e/runner/solana.go Removed SolanaRentPayerPDA method; functionality related to rent payer PDA computation is eliminated.
pkg/contracts/solana/gateway.go Removed RentPayerPDASeed constant and RentPayerPDA function; other aspects remain unchanged.
pkg/contracts/solana/gateway.json Removed initialize_rent_payer instruction and RentPayerPda account; updated withdraw_spl_token instruction.
pkg/contracts/solana/instruction.go Removed InitializeRentPayerParams struct; other structs remain unchanged.
zetaclient/chains/solana/signer/signer.go Removed rentPayerPda field from Signer struct; simplified initialization logic.
zetaclient/chains/solana/signer/withdraw_spl.go Removed signer.rentPayerPda from writable accounts in signWithdrawSPLTx method.

Possibly related PRs

Suggested labels

SOLANA_TESTS, breaking:proto

Suggested reviewers

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

@skosito skosito added the SOLANA_TESTS Run make start-solana-test label Dec 3, 2024
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 (4)
contrib/localnet/solana/start-solana.sh (3)

Line range hint 1-8: Add error handling for critical operations.

The script performs critical operations without proper error handling, which could lead to silent failures in the setup process.

Apply this diff to add error handling:

 #!/bin/bash
+set -euo pipefail
+
+cleanup() {
+    echo "Cleaning up..."
+    pkill solana-test-validator || true
+}
+
+trap cleanup EXIT
 
 echo "making an id"
-solana-keygen new -o /root/.config/solana/id.json --no-bip39-passphrase
+if ! solana-keygen new -o /root/.config/solana/id.json --no-bip39-passphrase; then
+    echo "Failed to generate keypair"
+    exit 1
+fi
 
-solana config set --url localhost
+if ! solana config set --url localhost; then
+    echo "Failed to set Solana config"
+    exit 1
+fi

Line range hint 17-18: Replace static sleep with proper process monitoring.

The static sleep at the end doesn't provide meaningful debugging capabilities.

Apply this diff:

-# leave some time for debug if validator exits due to errors
-sleep 1000
+echo "Setup complete. Monitoring validator..."
+wait $VALIDATOR_PID

Line range hint 1-18: Consider adding logging and environment configuration.

The script would benefit from better logging and configurable parameters.

Add these improvements at the beginning of the script:

 #!/bin/bash
+
+# Configuration
+LOG_FILE="solana_setup.log"
+VALIDATOR_LOG="validator.log"
+SOL_AMOUNT="${SOL_AMOUNT:-100}"  # Amount of SOL to airdrop, configurable via env
+
+# Logging function
+log() {
+    echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
+}
+
+log "Starting Solana setup..."
zetaclient/chains/solana/signer/signer.go (1)

Line range hint 106-166: Consider enhancing context handling in TryProcessOutbound

The TryProcessOutbound method could benefit from explicit context timeout handling to ensure graceful cancellation of long-running operations.

Consider adding timeout handling:

 func (signer *Signer) TryProcessOutbound(
 	ctx context.Context,
 	cctx *types.CrossChainTx,
 	outboundProc *outboundprocessor.Processor,
 	outboundID string,
 	_ interfaces.ChainObserver,
 	zetacoreClient interfaces.ZetacoreClient,
 	height uint64,
 ) {
+	// Add timeout to context
+	ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
+	defer cancel()
+
 	// end outbound process on panic
 	defer func() {
 		outboundProc.EndTryProcess(outboundID)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 30924dc and fdd215c.

⛔ Files ignored due to path filters (1)
  • contrib/localnet/solana/gateway.so is excluded by !**/*.so
📒 Files selected for processing (9)
  • contrib/localnet/solana/start-solana.sh (1 hunks)
  • e2e/e2etests/test_spl_withdraw_and_create_receiver_ata.go (1 hunks)
  • e2e/runner/setup_solana.go (0 hunks)
  • e2e/runner/solana.go (0 hunks)
  • pkg/contracts/solana/gateway.go (0 hunks)
  • pkg/contracts/solana/gateway.json (0 hunks)
  • pkg/contracts/solana/instruction.go (0 hunks)
  • zetaclient/chains/solana/signer/signer.go (1 hunks)
  • zetaclient/chains/solana/signer/withdraw_spl.go (0 hunks)
💤 Files with no reviewable changes (6)
  • pkg/contracts/solana/gateway.json
  • pkg/contracts/solana/instruction.go
  • e2e/runner/solana.go
  • zetaclient/chains/solana/signer/withdraw_spl.go
  • e2e/runner/setup_solana.go
  • pkg/contracts/solana/gateway.go
✅ Files skipped from review due to trivial changes (1)
  • e2e/e2etests/test_spl_withdraw_and_create_receiver_ata.go
🧰 Additional context used
📓 Path-based instructions (2)
zetaclient/chains/solana/signer/signer.go (1)

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

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

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

🔇 Additional comments (2)
zetaclient/chains/solana/signer/signer.go (2)

70-73: LGTM: Clean struct initialization

The struct initialization is concise and well-organized, properly reflecting the removal of the rentPayerPda field.


Line range hint 338-352: Track and address technical debt

These placeholder functions are marked for removal in issue #2532. Consider prioritizing this cleanup to reduce technical debt.

✅ Verification successful

Let me search for these placeholder functions to verify their current state in the codebase.


Technical Debt Confirmation: Empty Interface Methods Present

The issue #2532 is still open and the codebase analysis confirms the presence of empty placeholder methods in Bitcoin, Solana, and TON signers:

  • Empty SetZetaConnectorAddress implementations in:
    • zetaclient/chains/bitcoin/signer/signer.go
    • zetaclient/chains/solana/signer/signer.go
    • zetaclient/chains/ton/signer/signer.go
  • Empty SetERC20CustodyAddress implementations in:
    • zetaclient/chains/bitcoin/signer/signer.go
    • zetaclient/chains/solana/signer/signer.go
    • zetaclient/chains/ton/signer/signer.go

These empty implementations exist solely to satisfy the interfaces.ChainSigner interface, while EVM chains maintain full implementations. Consider refactoring the interface design to avoid these no-op implementations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the issue is still open and relevant
gh issue view 2532 --json state,title,body

Length of output: 562


Script:

#!/bin/bash
# Check for the placeholder functions mentioned in the issue
ast-grep --pattern 'func ($_ *Signer) GetZetaConnectorAddress() common.Address {
  $$$
}'

ast-grep --pattern 'func ($_ *Signer) SetZetaConnectorAddress($_) {
  $$$
}'

ast-grep --pattern 'func ($_ *Signer) GetERC20CustodyAddress() common.Address {
  $$$
}'

ast-grep --pattern 'func ($_ *Signer) SetERC20CustodyAddress($_) {
  $$$
}'

Length of output: 3393

contrib/localnet/solana/start-solana.sh Show resolved Hide resolved
contrib/localnet/solana/start-solana.sh Show resolved Hide resolved
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.82%. Comparing base (30924dc) to head (8984900).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3238      +/-   ##
===========================================
+ Coverage    61.81%   61.82%   +0.01%     
===========================================
  Files          431      431              
  Lines        30763    30751      -12     
===========================================
- Hits         19015    19013       -2     
+ Misses       10890    10881       -9     
+ Partials       858      857       -1     
Files with missing lines Coverage Δ
pkg/contracts/solana/gateway.go 0.00% <ø> (ø)
pkg/contracts/solana/instruction.go 18.57% <ø> (ø)
zetaclient/chains/solana/signer/signer.go 23.14% <100.00%> (-0.35%) ⬇️
zetaclient/chains/solana/signer/withdraw_spl.go 0.00% <ø> (ø)

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.

lgtm

@skosito skosito added this pull request to the merge queue Dec 3, 2024
Merged via the queue into develop with commit e76b443 Dec 3, 2024
41 checks passed
@skosito skosito deleted the gateway-ata-create-fix-integration branch December 3, 2024 21:59
skosito added a commit that referenced this pull request Dec 3, 2024
* integrate withdraw spl create ata fix

* comment
@skosito skosito mentioned this pull request Dec 3, 2024
5 tasks
lumtis pushed a commit that referenced this pull request Dec 4, 2024
* fix: integrate deposit fee and audit fixes (#3232)

* integrate deposit fee and audit fixes

* unit test fix

* latest gateway changes

* latest gateway

* latest gateway

* fix: integrate withdraw spl create ata fix (#3238)

* integrate withdraw spl create ata fix

* comment
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 SOLANA_TESTS Run make start-solana-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants