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: ask for 3 accounts (signer, pda, system_program) when parsing Sonala inbound signer address #2787

Merged
merged 6 commits into from
Aug 30, 2024

Conversation

ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Aug 28, 2024

Description

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 entry in the changelog detailing the updated deposit process for the Solana gateway, requiring three accounts (signer, PDA, system program).
    • Added a new JSON file representing transaction results from the Solana blockchain, enhancing transaction analysis.
  • Improvements

    • Enhanced error handling for deposit instructions, improving robustness and clarity in execution.
    • Updated configuration to provide a default path for relayer keys, streamlining user setup.
  • Bug Fixes

    • Adjusted the expected number of accounts for deposit instructions from four to three, simplifying the deposit process.
  • Tests

    • Updated test cases to reflect current transaction data and expected outcomes, improving test accuracy.

Copy link
Contributor

coderabbitai bot commented Aug 28, 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

The changes introduce a new feature in the Zeta Chain project related to the Solana gateway deposit process, requiring three specific accounts: a signer, a program-derived address (PDA), and a system program. Additionally, modifications were made to improve the configuration management for relayer keys, streamline deposit instruction handling, and update test cases and transaction result structures to align with the new account requirements.

Changes

File Path Change Summary
changelog.md New entry for Solana gateway deposit feature requiring three accounts.
cmd/zetaclientd/import_relayer_keys.go Modified init function to use config.DefaultRelayerKeyPath instead of hardcoded path for relayer keys.
e2e/runner/solana.go Removed programID from accountSlice in CreateDepositInstruction method.
pkg/contracts/solana/gateway.go Changed AccountsNumDeposit constant from 4 to 3 to reflect new account requirements.
zetaclient/chains/solana/observer/inbound.go Enhanced error handling in ParseInboundAsDeposit and reduced expected accounts from four to three in GetSignerDeposit.
zetaclient/chains/solana/observer/inbound_test.go Updated transaction hashes, expected Amount, Memo, and GatewayAddress in tests.
zetaclient/config/types.go Introduced DefaultRelayerKeyPath constant and modified GetRelayerKeyPath method for improved path retrieval.
zetaclient/testdata/solana/...json New JSON file detailing a transaction result structure from the Solana blockchain.
zetaclient/testutils/constant.go Updated gateway address for chains.SolanaDevnet.ChainId in GatewayAddresses.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 66.65%. Comparing base (91c323d) to head (e49ff53).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/solana/observer/inbound.go 16.66% 4 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2787      +/-   ##
===========================================
- Coverage    66.79%   66.65%   -0.15%     
===========================================
  Files          370      370              
  Lines        20677    20680       +3     
===========================================
- Hits         13811    13784      -27     
- Misses        6230     6261      +31     
+ Partials       636      635       -1     
Files with missing lines Coverage Δ
pkg/contracts/solana/gateway.go 0.00% <ø> (ø)
zetaclient/config/types.go 11.62% <100.00%> (-39.60%) ⬇️
zetaclient/chains/solana/observer/inbound.go 41.39% <16.66%> (-2.39%) ⬇️

... and 1 file with indirect coverage changes

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 26c4fb1 and 0ee070c.

Files selected for processing (9)
  • changelog.md (1 hunks)
  • cmd/zetaclientd/import_relayer_keys.go (2 hunks)
  • e2e/runner/solana.go (1 hunks)
  • pkg/contracts/solana/gateway.go (1 hunks)
  • zetaclient/chains/solana/observer/inbound.go (4 hunks)
  • zetaclient/chains/solana/observer/inbound_test.go (5 hunks)
  • zetaclient/config/types.go (2 hunks)
  • zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json (1 hunks)
  • zetaclient/testutils/constant.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • changelog.md
Additional context used
Path-based instructions (7)
pkg/contracts/solana/gateway.go (1)

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

zetaclient/testutils/constant.go (1)

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

cmd/zetaclientd/import_relayer_keys.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/config/types.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.

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

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

GitHub Check: codecov/patch
zetaclient/config/types.go

[warning] 171-172: zetaclient/config/types.go#L171-L172
Added lines #L171 - L172 were not covered by tests

zetaclient/chains/solana/observer/inbound.go

[warning] 291-294: zetaclient/chains/solana/observer/inbound.go#L291-L294
Added lines #L291 - L294 were not covered by tests

Additional comments not posted (16)
pkg/contracts/solana/gateway.go (1)

17-18: LGTM! But verify the constant usage in the codebase.

The constant AccountsNumDeposit has been correctly updated to reflect the new number of accounts required for the Solana gateway deposit instruction. Ensure that all references to this constant in the codebase are compatible with the new value.

The code changes are approved.

Run the following script to verify the constant usage:

Verification successful

Verification Successful: Consistent Use of AccountsNumDeposit

The constant AccountsNumDeposit has been correctly updated and is consistently used across the codebase. The checks and comments align with the new requirement of 3 accounts.

  • zetaclient/chains/solana/observer/inbound.go: The usage of AccountsNumDeposit is consistent with the updated value.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `AccountsNumDeposit` in the codebase.

# Test: Search for the constant usage. Expect: Only occurrences of the new value.
rg --type go -A 5 $'AccountsNumDeposit'

Length of output: 1044

zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json (1)

1-64: LGTM! Verify the JSON usage in the codebase.

The JSON structure appears to be well-formed and contains all necessary fields for representing transaction data. Ensure that the data aligns with the expected schema and is used correctly in the codebase.

The code changes are approved.

Run the following script to verify the JSON usage:

zetaclient/testutils/constant.go (1)

39-39: LGTM! Verify the variable usage in the codebase.

The gateway address for Solana devnet has been correctly updated. Ensure that all tests relying on this address are updated accordingly.

The code changes are approved.

Run the following script to verify the variable usage:

Verification successful

Verification Successful: Updated Gateway Address is Correctly Used

The updated gateway address for the Solana devnet is correctly referenced in the relevant test files. Ensure that these tests pass to confirm the change's correctness.

  • Files referencing the updated address:
    • zetaclient/chains/solana/observer/inbound_test.go
    • zetaclient/chains/solana/signer/signer_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `GatewayAddresses` in the codebase.

# Test: Search for the variable usage. Expect: Only occurrences of the new value.
rg --type go -A 5 $'GatewayAddresses'

Length of output: 2682

cmd/zetaclientd/import_relayer_keys.go (1)

15-15: LGTM!

The change improves maintainability and configurability by centralizing the default path definition.

The code changes are approved.

Also applies to: 56-58

e2e/runner/solana.go (1)

Line range hint 32-36: Verify the impact of the change on the deposit instruction functionality.

The removal of solana.Meta(programID) from the accountSlice might impact the functionality of the deposit instruction. Ensure that this change does not cause issues in transaction processing or validation within the Solana blockchain context.

Run the following script to verify the impact of the change:

zetaclient/config/types.go (1)

23-25: LGTM!

The introduction of the new constant DefaultRelayerKeyPath enhances the configuration capabilities by providing a predefined path for relayer keys.

The code changes are approved.

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

29-30: LGTM!

The transaction hash update aligns the test with the latest transaction data.

The code changes are approved.


54-55: LGTM!

The transaction hash update aligns the test with the latest transaction data.

The code changes are approved.


64-64: LGTM!

The dynamic retrieval of GatewayAddress enhances the flexibility and maintainability of the test.

The code changes are approved.


76-77: LGTM!

The updates to the Amount and Memo fields ensure the test reflects the expected behavior.

The code changes are approved.


159-160: LGTM!

The transaction hash update aligns the test with the latest transaction data.

The code changes are approved.


172-172: LGTM!

The dynamic retrieval of GatewayAddress enhances the flexibility and maintainability of the test.

The code changes are approved.


183-184: LGTM!

The updates to the Amount and Memo fields ensure the test reflects the expected behavior.

The code changes are approved.

zetaclient/chains/solana/observer/inbound.go (3)

288-294: Enhanced error handling and logging.

The improved error handling and logging for the signer address retrieval enhance the robustness of the method against errors.

The code changes are approved.

Tools
GitHub Check: codecov/patch

[warning] 291-294: zetaclient/chains/solana/observer/inbound.go#L291-L294
Added lines #L291 - L294 were not covered by tests


329-335: Streamlined account validation logic.

The reduction in the expected number of accounts and the simplification of the account validation logic streamline the processing of deposit instructions and improve maintainability.

The code changes are approved.


355-355: LGTM!

The validation condition now correctly checks for the presence of the signer, PDA, and system program accounts.

The code changes are approved.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 26c4fb1 and 0ee070c.

Files selected for processing (9)
  • changelog.md (1 hunks)
  • cmd/zetaclientd/import_relayer_keys.go (2 hunks)
  • e2e/runner/solana.go (1 hunks)
  • pkg/contracts/solana/gateway.go (1 hunks)
  • zetaclient/chains/solana/observer/inbound.go (4 hunks)
  • zetaclient/chains/solana/observer/inbound_test.go (5 hunks)
  • zetaclient/config/types.go (2 hunks)
  • zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json (1 hunks)
  • zetaclient/testutils/constant.go (1 hunks)
Additional context used
Path-based instructions (7)
pkg/contracts/solana/gateway.go (1)

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

zetaclient/testutils/constant.go (1)

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

cmd/zetaclientd/import_relayer_keys.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/config/types.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.

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

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

GitHub Check: codecov/patch
zetaclient/config/types.go

[warning] 171-172: zetaclient/config/types.go#L171-L172
Added lines #L171 - L172 were not covered by tests

zetaclient/chains/solana/observer/inbound.go

[warning] 291-294: zetaclient/chains/solana/observer/inbound.go#L291-L294
Added lines #L291 - L294 were not covered by tests

Additional comments not posted (12)
pkg/contracts/solana/gateway.go (1)

17-18: LGTM!

The change in the number of accounts required for the deposit instruction is clear and the accompanying comment is updated accordingly.

The code changes are approved.

zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json (1)

1-64: LGTM!

The JSON structure is well-formed and the data appears to be comprehensive and accurate.

The code changes are approved.

zetaclient/testutils/constant.go (1)

39-39: LGTM!

The update to the gateway address for the Solana devnet is clear and straightforward.

The code changes are approved.

cmd/zetaclientd/import_relayer_keys.go (1)

15-15: LGTM!

The change to use config.DefaultRelayerKeyPath enhances configurability and maintainability by centralizing the default path in the configuration module.

The code changes are approved.

Also applies to: 56-58

e2e/runner/solana.go (1)

Line range hint 32-36: LGTM! But verify the impact on deposit instruction.

The removal of solana.Meta(programID) from the accountSlice may streamline account handling or address a specific issue. Ensure that this change does not negatively impact the deposit instruction's functionality.

The code changes are approved.

Run the following script to verify the impact on the deposit instruction:

Verification successful

Removal of solana.Meta(programID) is Safe

The removal of solana.Meta(programID) from the accountSlice in the CreateDepositInstruction method does not negatively impact its functionality. The programID is still correctly assigned to inst.ProgID, and the essential components of the accountSlice are maintained. This change streamlines the account handling without affecting the transaction's integrity.

  • The accountSlice includes necessary accounts: signer, computed PDA, and Solana System Program ID.
  • The programID is used in inst.ProgID, ensuring proper association with the program.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing `solana.Meta(programID)` from the `accountSlice`.

# Test: Search for the `CreateDepositInstruction` method usage. Expect: No negative impact on functionality.
rg --type go -A 5 $'CreateDepositInstruction'

Length of output: 821


Script:

#!/bin/bash
# Description: Examine the construction and usage of `accountSlice` in `CreateDepositInstruction`.

# Search for the `accountSlice` within the `CreateDepositInstruction` method to understand its construction and usage.
rg --type go -A 10 'accountSlice' e2e/runner/solana.go

Length of output: 647

zetaclient/config/types.go (1)

23-25: LGTM!

The introduction of DefaultRelayerKeyPath enhances configurability by providing a predefined path for relayer keys, improving usability for users who may not specify a custom path.

The code changes are approved.

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

29-30: LGTM!

The transaction hash update is correctly implemented.

The code changes are approved.


54-55: LGTM!

The transaction hash, dynamic gateway address, and expected values for Amount and Memo fields are correctly updated.

The code changes are approved.

Also applies to: 64-64, 76-77


159-160: LGTM!

The transaction hash, dynamic gateway address, and expected values for Amount and Memo fields are correctly updated.

The code changes are approved.

Also applies to: 172-172, 183-184

zetaclient/chains/solana/observer/inbound.go (2)

288-294: Enhanced error handling for signer address.

The error handling for obtaining the signer address has been improved by logging a detailed error message and returning nil without propagating the error. This change improves the robustness of the function.

The code changes are approved.

Tools
GitHub Check: codecov/patch

[warning] 291-294: zetaclient/chains/solana/observer/inbound.go#L291-L294
Added lines #L291 - L294 were not covered by tests


329-329: Updated account validation logic.

The expected number of accounts for a deposit instruction has been reduced from four to three. The validation logic now only verifies the presence of the signer, PDA, and system accounts, which streamlines the function and aligns it with the updated account structure.

The code changes are approved.

Also applies to: 334-335, 355-355

changelog.md (1)

18-18: Changelog entry added.

The new entry is correctly formatted and provides a clear description of the feature related to the Solana gateway deposit process.

The code changes are approved.

zetaclient/config/types.go Show resolved Hide resolved
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.

Looks good to me but can we rename the PR and give the actual purpose of it?

This is not a backport, the backport is what we merged on v19

changelog.md Outdated Show resolved Hide resolved
@ws4charlie ws4charlie changed the title fix: backport hotfix v19.2.1 fix: ask for 3 accounts (signer, pda, system_program) when parsing Sonala inbound signer address Aug 29, 2024
@ws4charlie
Copy link
Contributor Author

Looks good to me but can we rename the PR and give the actual purpose of it?

This is not a backport, the backport is what we merged on v19

The title of this PR is updated.

@lumtis lumtis added this pull request to the merge queue Aug 30, 2024
Merged via the queue into develop with commit 7b34d1d Aug 30, 2024
30 of 31 checks passed
@lumtis lumtis deleted the solana-hotfix-from-v19.2.1 branch August 30, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants