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: fix solana inbounds #3261

Merged
merged 2 commits into from
Dec 10, 2024
Merged

fix: fix solana inbounds #3261

merged 2 commits into from
Dec 10, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Dec 9, 2024

Description

cherry-pick fix for solana inbounds #3255

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

    • Enhanced contract call verification with the addition of message data.
    • New functions added for deposit and call instructions, improving transaction flexibility.
    • Introduction of new constants for Solana gateway program instructions.
  • Bug Fixes

    • Improved error handling in deposit instruction parsing and account validation.
  • Tests

    • Expanded test coverage for deposit and call functionalities, including new scenarios and updated expected values.
  • Chores

    • Updated transaction data files to reflect recent changes in the Solana blockchain.

@skosito skosito added no-changelog Skip changelog CI check SOLANA_TESTS Run make start-solana-test labels Dec 9, 2024
@skosito skosito requested a review from a team as a code owner December 9, 2024 18:34
Copy link
Contributor

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

Walkthrough

The pull request introduces several modifications across multiple files, primarily enhancing the verification of contract calls in Solana-related tests. Key changes include the introduction of a new method for checking contract calls with additional message data, updates to deposit instruction creation logic to incorporate a data parameter, and enhancements to parsing logic for deposit instructions. New constants and types related to deposit and call operations have also been added, alongside updates to test cases to reflect new transaction data. Additionally, new JSON files documenting transaction results have been introduced, while some outdated files have been removed.

Changes

File Change Summary
e2e/e2etests/test_solana_deposit_call.go Updated TestSolanaDepositAndCall to use MustHaveCalledExampleContractWithMsg for verifying contract calls with message data.
e2e/e2etests/test_spl_deposit_and_call.go Modified TestSPLDepositAndCall to utilize MustHaveCalledExampleContractWithMsg, including a message parameter.
e2e/runner/solana.go Altered CreateDepositInstruction and CreateDepositSPLInstruction to conditionally handle the data parameter for deposit instructions.
e2e/utils/contracts.go Introduced MustHaveCalledExampleContractWithMsg function for verifying contract calls with message data.
pkg/contracts/solana/gateway.go Added constants DiscriminatorDepositAndCall and DiscriminatorDepositSPLAndCall for new instructions.
pkg/contracts/solana/inbound.go Enhanced ParseInboundAsDeposit and ParseInboundAsDepositSPL to handle new deposit and call instructions, introduced new parsing functions.
pkg/contracts/solana/inbound_test.go Updated test cases for deposit parsing with new transaction data and scenarios.
pkg/contracts/solana/instruction.go Modified instruction parameter types to replace Memo with Receiver, added new instruction parameter types for deposits and calls.
pkg/contracts/solana/testdata/*.json Introduced new JSON files documenting specific transaction results, updated existing files with new transaction data.
testutil/contracts/Example.abi Added lastMessage function to the ABI of the Example contract.
testutil/contracts/Example.go Updated contract methods to include lastMessage, modified ABI retrieval.
testutil/contracts/Example.json Added lastMessage function to the contract's ABI.
testutil/contracts/Example.sol Introduced public state variable lastMessage to the Example contract.
zetaclient/chains/solana/observer/inbound_test.go Updated test cases with new transaction hashes and expected values.
zetaclient/testdata/solana/*.json Added new JSON files for inbound transaction results, removed outdated transaction result files.

Possibly related PRs

Suggested labels

bug, chain:solana

Suggested reviewers

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

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. (Experiment)
  • @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 Dec 9, 2024

Codecov Report

Attention: Patch coverage is 91.54930% with 6 lines in your changes missing coverage. Please review.

Project coverage is 61.84%. Comparing base (1329066) to head (ba3cd55).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
pkg/contracts/solana/inbound.go 91.54% 4 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3261      +/-   ##
===========================================
+ Coverage    61.78%   61.84%   +0.05%     
===========================================
  Files          431      431              
  Lines        30786    30848      +62     
===========================================
+ Hits         19021    19077      +56     
- Misses       10909    10913       +4     
- Partials       856      858       +2     
Files with missing lines Coverage Δ
pkg/contracts/solana/gateway.go 0.00% <ø> (ø)
pkg/contracts/solana/instruction.go 18.57% <ø> (ø)
pkg/contracts/solana/inbound.go 87.23% <91.54%> (+2.42%) ⬆️

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)
pkg/contracts/solana/inbound.go (1)

23-24: Update function comment to reflect new return values

The function ParseInboundAsDeposit now returns both a *Deposit and an error. The comment should be updated to accurately describe the return values, ensuring it reflects the current function signature.

e2e/utils/contracts.go (2)

35-56: Refactor to eliminate code duplication

The new function MustHaveCalledExampleContractWithMsg duplicates logic from MustHaveCalledExampleContract. Consider refactoring to extract common assertions into a shared helper function or modifying the original function to accept an optional message parameter. This will improve maintainability and reduce redundancy in the test utilities.


55-55: Use bytes.Equal for message comparison

When comparing byte slices, it's preferable to use bytes.Equal(msg, lastMsg) instead of casting them to strings. This ensures accurate comparison of the message data, especially if it contains non-UTF8 encoded bytes.

pkg/contracts/solana/gateway.go (1)

30-31: Fix incorrect comment for DiscriminatorDepositAndCall

The comment incorrectly states "DiscriminatorDeposit" instead of "DiscriminatorDepositAndCall".

Apply this fix:

-// DiscriminatorDeposit returns the discriminator for Solana gateway 'deposit_and_call' instruction
+// DiscriminatorDepositAndCall returns the discriminator for Solana gateway 'deposit_and_call' instruction
e2e/runner/solana.go (1)

39-56: Consider extracting common serialization logic.

The deposit instruction serialization logic is duplicated between CreateDepositInstruction and CreateDepositSPLInstruction. Consider extracting the common pattern into a helper function to improve maintainability.

Example refactor:

+func serializeDepositParams(discriminator uint8, amount uint64, receiver ethcommon.Address, data []byte) ([]byte, error) {
+    if data == nil {
+        return borsh.Serialize(solanacontract.DepositInstructionParams{
+            Discriminator: discriminator,
+            Amount:       amount,
+            Receiver:     receiver,
+        })
+    }
+    return borsh.Serialize(solanacontract.DepositAndCallInstructionParams{
+        Discriminator: discriminator + 1, // Assuming AndCall discriminators are offset by 1
+        Amount:       amount,
+        Receiver:     receiver,
+        Memo:        data,
+    })
+}

Then use it in both functions:

depositData, err := serializeDepositParams(solanacontract.DiscriminatorDeposit, amount, receiver, data)

Also applies to: 102-119

pkg/contracts/solana/inbound_test.go (1)

Line range hint 42-63: Consider using test data constants for better maintainability.

The test data (transaction hashes, addresses, expected values) is duplicated across test functions. Consider extracting these into constants or test fixtures to improve maintainability and make updates easier.

Example refactor:

const (
    depositTxHash = "8UeJoxY6RbMg6bffsUtZ9f79vSnd4HCRdk5EQgNbAEDYQWXNraiKDtGDZBLp91oyF5eQyWdv6pEwW1vcitiB4px"
    depositAndCallTxHash = "5b7ShhHf8dvUjUBHgMvgH8FFqpfAd7vAGygZLaeNPhugXtY5fatPSACVkn13o7sw6Awob8EJnrwAuiKYqvi7ZkHa"
    e2eDeployerAccount = "37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ"
)

type testCase struct {
    name string
    txHash string
    expectedDeposit *Deposit
}

Also applies to: 145-181, 354-378

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1329066 and 87bf74f.

⛔ Files ignored due to path filters (1)
  • testutil/contracts/Example.bin is excluded by !**/*.bin
📒 Files selected for processing (19)
  • e2e/e2etests/test_solana_deposit_call.go (1 hunks)
  • e2e/e2etests/test_spl_deposit_and_call.go (1 hunks)
  • e2e/runner/solana.go (2 hunks)
  • e2e/utils/contracts.go (1 hunks)
  • pkg/contracts/solana/gateway.go (1 hunks)
  • pkg/contracts/solana/inbound.go (5 hunks)
  • pkg/contracts/solana/inbound_test.go (8 hunks)
  • pkg/contracts/solana/instruction.go (1 hunks)
  • pkg/contracts/solana/testdata/22s5ERRRZmZXAuDMRdwUU33VnWZ7m8NHUZM6hyLH52JQPz5R7mXEkFcvHx88ujq3xDnt3z7sZdZ21JK2FC7vPw1o.json (1 hunks)
  • pkg/contracts/solana/testdata/5b7ShhHf8dvUjUBHgMvgH8FFqpfAd7vAGygZLaeNPhugXtY5fatPSACVkn13o7sw6Awob8EJnrwAuiKYqvi7ZkHa.json (1 hunks)
  • pkg/contracts/solana/testdata/5bXSQaq6BY1WhhF3Qm4pLHXxuyM9Mz1MrdMeoCFbimxw4uv11raQgAj4HGULPEQExPKB231rMhm6666dQMwf9fNN.json (4 hunks)
  • pkg/contracts/solana/testdata/8UeJoxY6RbMg6bffsUtZ9f79vSnd4HCRdk5EQgNbAEDYQWXNraiKDtGDZBLp91oyF5eQyWdv6pEwW1vcitiB4px.json (3 hunks)
  • testutil/contracts/Example.abi (1 hunks)
  • testutil/contracts/Example.go (4 hunks)
  • testutil/contracts/Example.json (2 hunks)
  • testutil/contracts/Example.sol (2 hunks)
  • zetaclient/chains/solana/observer/inbound_test.go (3 hunks)
  • zetaclient/testdata/solana/chain_901_inbound_tx_result_24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr.json (1 hunks)
  • zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json (0 hunks)
💤 Files with no reviewable changes (1)
  • zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json
✅ Files skipped from review due to trivial changes (2)
  • zetaclient/testdata/solana/chain_901_inbound_tx_result_24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr.json
  • pkg/contracts/solana/testdata/5b7ShhHf8dvUjUBHgMvgH8FFqpfAd7vAGygZLaeNPhugXtY5fatPSACVkn13o7sw6Awob8EJnrwAuiKYqvi7ZkHa.json
🧰 Additional context used
📓 Path-based instructions (10)
pkg/contracts/solana/gateway.go (1)

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

e2e/utils/contracts.go (1)

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

e2e/e2etests/test_solana_deposit_call.go (1)

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

pkg/contracts/solana/inbound_test.go (1)

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

pkg/contracts/solana/instruction.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.

testutil/contracts/Example.go (1)

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

pkg/contracts/solana/inbound.go (1)

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

zetaclient/chains/solana/observer/inbound_test.go (1)

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

e2e/e2etests/test_spl_deposit_and_call.go (1)

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

🪛 GitHub Check: codecov/patch
pkg/contracts/solana/inbound.go

[warning] 93-94: pkg/contracts/solana/inbound.go#L93-L94
Added lines #L93 - L94 were not covered by tests


[warning] 180-181: pkg/contracts/solana/inbound.go#L180-L181
Added lines #L180 - L181 were not covered by tests

🔇 Additional comments (20)
pkg/contracts/solana/inbound.go (1)

69-69: Verify consistency of Memo field assignment across parsing functions

There is an inconsistency in how the Memo field is constructed between the deposit functions and the deposit-and-call functions. In tryParseAsDeposit and tryParseAsDepositSPL, Memo is assigned inst.Receiver[:], whereas in tryParseAsDepositAndCall and tryParseAsDepositSPLAndCall, it is assigned append(instDepositAndCall.Receiver[:], instDepositAndCall.Memo...). Please verify whether this difference is intentional and ensure that the Memo field consistently represents the intended data across all parsing functions.

Also applies to: 104-104, 156-156, 191-191

testutil/contracts/Example.sol (2)

15-15: LGTM

The addition of the lastMessage public variable is appropriate and correctly declared. This enables the contract to store and expose the last received message as intended.


44-44: LGTM

Assigning the message parameter to lastMessage within onCrossChainCall properly records the incoming message, enhancing the contract's functionality.

e2e/e2etests/test_solana_deposit_call.go (1)

34-34: LGTM

Updating the test to use MustHaveCalledExampleContractWithMsg ensures that both the deposit amount and the message are validated. This enhances the test's coverage and accuracy.

testutil/contracts/Example.abi (1)

53-65: LGTM: New lastMessage function is well-structured

The function signature is correctly defined with appropriate mutability and return type for message retrieval operations.

Let's verify the function implementation:

✅ Verification successful

Verified: lastMessage function is correctly implemented and integrated

The lastMessage public state variable in the Solidity contract automatically generates the view function in the ABI. The variable is properly updated in the onCrossChainCall function, storing the cross-chain message data. The implementation aligns perfectly with the ABI definition and follows Solidity best practices for state variable accessibility and message handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify lastMessage function implementation
# Look for the function implementation in the contract source
ast-grep --pattern 'function lastMessage() public view returns (bytes) {
  $$$
}'

Length of output: 83


Script:

#!/bin/bash
# First, let's find the contract implementation file
fd -e sol Example

# Then, let's search for lastMessage function implementation with context
rg -U "function lastMessage" -A 5

Length of output: 1404


Script:

#!/bin/bash
# Let's examine the actual Solidity contract implementation
cat testutil/contracts/Example.sol

Length of output: 868

pkg/contracts/solana/testdata/8UeJoxY6RbMg6bffsUtZ9f79vSnd4HCRdk5EQgNbAEDYQWXNraiKDtGDZBLp91oyF5eQyWdv6pEwW1vcitiB4px.json (2)

37-38: Balance changes correctly reflect deposit operation

The pre and post balances show a transfer of 14000000 lamports (12000000 deposit + 2000000 fee) from the sender to the receiver account.


58-61: Transaction logs properly document the deposit operation

The log messages clearly indicate:

  1. Deposit instruction execution
  2. System program invocation
  3. Detailed deposit information including amount and receiver
pkg/contracts/solana/gateway.go (1)

30-38: LGTM: New discriminators properly integrated

The new discriminators for deposit_and_call and deposit_spl_token_and_call operations are correctly initialized using the IDLGateway interface.

Let's verify the instruction handling for these discriminators:

✅ Verification successful

Let me verify the instruction handling for these discriminators by checking the implementation of the deposit and call functionality.


Let me verify the SPL deposit and call instruction handling since it wasn't found in the previous search.


Let me do one final check to verify the SPL deposit instruction handling implementation.


Discriminators properly integrated with complete instruction handling

The verification confirms that both deposit_and_call and deposit_spl_token_and_call discriminators are correctly integrated with proper instruction handling:

  • The DepositAndCallInstructionParams structure properly handles deposit_and_call with discriminator validation
  • The DepositSPLAndCallInstructionParams structure properly handles deposit_spl_token_and_call with discriminator validation
  • Both discriminators are correctly initialized from the IDLGateway interface
  • The instruction parsing logic in inbound.go correctly validates the discriminators and processes the instructions
  • End-to-end tests exist for both instruction types, validating the complete flow
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify instruction handling for new discriminators
# Look for instruction handling code
rg -A 10 "deposit_and_call|deposit_spl_token_and_call" --type go

Length of output: 25932


Script:

#!/bin/bash
# Search for deposit and call instruction handling implementation
ast-grep --pattern 'func $_(tx *solana.Transaction, $_, $_) (*Deposit, error) {
  $$$
  instDepositAndCall := DepositAndCallInstructionParams{}
  $$$
}'

Length of output: 2288


Script:

#!/bin/bash
# Search for SPL deposit and call instruction handling
ast-grep --pattern 'func $_(tx *solana.Transaction, $_, $_) (*DepositSPL, error) {
  $$$
  instDepositSPLAndCall := DepositSPLAndCallInstructionParams{}
  $$$
}'

Length of output: 163


Script:

#!/bin/bash
# Check for deposit instruction parameter structures
ast-grep --pattern 'type DepositSPLAndCallInstructionParams struct {
  $$$
}'

Length of output: 965


Script:

#!/bin/bash
# Search for SPL deposit and call instruction handling with a broader pattern
ast-grep --pattern 'func $_(tx *solana.Transaction, $_, $_) (*DepositSPL, error) {
  $$$
  if inst$_.Discriminator == DiscriminatorDepositSPLAndCall {
    $$$
  }
  $$$
}'

Length of output: 173


Script:

#!/bin/bash
# Alternative search for SPL deposit handling
rg -A 10 "DiscriminatorDepositSPLAndCall" --type go

Length of output: 2375


Script:

#!/bin/bash
# Search for SPL deposit parsing function
ast-grep --pattern 'func tryParseAsDepositSPL(tx *solana.Transaction, $_, $_) (*DepositSPL, error) {
  $$$
}'

Length of output: 111


Script:

#!/bin/bash
# Search for SPL deposit instruction parameter structure
ast-grep --pattern 'type DepositSPLInstructionParams struct {
  $$$
}'

Length of output: 743

e2e/e2etests/test_spl_deposit_and_call.go (1)

54-54: LGTM! Enhanced contract call verification

The update to use MustHaveCalledExampleContractWithMsg improves test coverage by verifying both the amount and message data.

pkg/contracts/solana/testdata/5bXSQaq6BY1WhhF3Qm4pLHXxuyM9Mz1MrdMeoCFbimxw4uv11raQgAj4HGULPEQExPKB231rMhm6666dQMwf9fNN.json (1)

Line range hint 95-95: Review the compute units consumption

The computeUnitsConsumed value of 274902869112 appears unusually high for a simple deposit transaction. Standard Solana transactions typically consume far fewer compute units.

Let's verify typical compute unit consumption for similar transactions:

pkg/contracts/solana/testdata/22s5ERRRZmZXAuDMRdwUU33VnWZ7m8NHUZM6hyLH52JQPz5R7mXEkFcvHx88ujq3xDnt3z7sZdZ21JK2FC7vPw1o.json (1)

78-85: LGTM! Well-structured transaction logs

The log messages clearly show the transaction flow:

  1. Program invocation
  2. Instruction type (DepositSplTokenAndCall)
  3. Transfer execution
  4. Successful completion
zetaclient/chains/solana/observer/inbound_test.go (2)

29-30: LGTM: Test data update

The transaction hash update maintains test functionality while using new test data.


80-88: Verify the significant amount change

The test amount has increased by 1000x (from 100000 to 100000000). While this appears to be intentional, please verify that this significant change in test values aligns with the expected behavior.

✅ Verification successful

The search results show that the amount 100000000 appears in various test files and contracts across the codebase, often representing different denominations in different contexts (BTC, ETH, etc.). Let's verify if this specific amount in the Solana test is consistent with other Solana-related tests.


Amount change in test is consistent with Solana test patterns

The amount change from 100000 to 100000000 in the test case is consistent with the existing Solana test patterns, as evidenced by the matching amount in other Solana test files. This appears to be a deliberate standardization of test values rather than an issue.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other test cases or constants using similar amounts
rg -g '*.go' "100000000" --context 3

Length of output: 65573


Script:

#!/bin/bash
# Search for amount patterns in Solana-related files
rg -g '*.go' -B 3 -A 3 "Amount.*[0-9]{8,}" zetaclient/chains/solana/

Length of output: 611

testutil/contracts/Example.json (1)

54-66: LGTM: Well-structured ABI addition

The new lastMessage function follows standard ABI patterns for view functions.

pkg/contracts/solana/instruction.go (4)

33-35: LGTM: Enhanced type safety

The change from variable-length []byte to fixed-size [20]byte for the receiver address improves type safety and clarity.


37-50: LGTM: Well-structured instruction params

The new struct clearly separates deposit and call parameters while maintaining good documentation.


52-62: LGTM: Consistent parameter structure

The changes maintain consistency with the non-SPL deposit instruction while properly documenting SPL-specific context.


64-77: LGTM: Consistent instruction parameter pattern

The new struct maintains consistency with other instruction parameter types while properly handling SPL-specific functionality.

testutil/contracts/Example.go (2)

243-272: LGTM! The generated code for LastMessage looks correct.

The auto-generated bindings for the new LastMessage method are properly implemented with appropriate error handling and type conversions.


167-171: LGTM! The updated bindExample implementation is correct.

The change from direct ABI usage to GetAbi() is a good practice as it ensures consistency with the metadata.

@lumtis lumtis added this pull request to the merge queue Dec 10, 2024
Merged via the queue into develop with commit 5f35a90 Dec 10, 2024
41 checks passed
@lumtis lumtis deleted the cherry-pick-fix-solana-inbounds branch December 10, 2024 08:54
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.

3 participants