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: use the ZEVM address pulled from memo as Receiver in MsgVoteInbound #3242

Merged
merged 5 commits into from
Dec 10, 2024

Conversation

ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Dec 4, 2024

Description

We've been setting MsgVoteInbound.Receiver to original Solana sender address. This is not correct even though it doesn't bother cctx processing in the zetacore (where the decoded receiver is taken). This PR will be setting the decoded Receiver directly to MsgVoteInbound.Receiver to make it clearer to indexer/explorer.

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

    • Introduced a new telemetry endpoint /systemtime for enhanced monitoring.
  • Bug Fixes

    • Improved handling of unsupported transaction versions for Solana to prevent blocking.
    • Corrected message routing for MsgVoteInbound by setting the receiver from the Solana memo.
    • Implemented separate database file names for Bitcoin signet and testnet4 for better data organization.
  • Tests

    • Enhanced validation in deposit transaction tests to ensure correct receiver addresses are used.

Copy link
Contributor

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

This pull request introduces several significant updates across multiple components of the codebase. A new telemetry endpoint /systemtime is added to the zetaclient, enhancing monitoring capabilities. The handling of inbound vote messages and transaction processing for Solana has been improved, including fixes for unsupported transaction versions and updates to database management. Additionally, various end-to-end tests have been enhanced to verify that the correct receiver addresses are used in cross-chain transactions, ensuring better validation and reliability.

Changes

File Path Change Summary
changelog.md Updated to include new features, tests, refactors, and fixes; added /systemtime endpoint; various fixes for Solana transactions and database management.
e2e/e2etests/test_solana_deposit.go Added assertion to verify Receiver matches expected Ethereum address in TestSolanaDeposit.
e2e/e2etests/test_solana_deposit_call.go Added assertion to confirm Receiver matches expected contract address in TestSolanaDepositAndCall.
e2e/e2etests/test_spl_deposit.go Added assertion to check Receiver matches expected Ethereum address in TestSPLDeposit.
e2e/e2etests/test_spl_deposit_and_call.go Added assertion to verify Receiver matches expected contract address in TestSPLDepositAndCall.
zetaclient/chains/solana/observer/inbound.go Modified FilterInboundEvents and BuildInboundVoteMsgFromEvent to handle Receiver correctly.
zetaclient/chains/solana/observer/inbound_test.go Updated tests to reflect changes in Receiver handling; added compliance checks for event processability.

Possibly related PRs

Suggested labels

TSS_MIGRATION_TESTS, chain:solana, audit, SOLANA_TESTS

Suggested reviewers

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

@ws4charlie ws4charlie marked this pull request as ready for review December 4, 2024 17:37
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: 0

🧹 Outside diff range and nitpick comments (6)
e2e/e2etests/test_solana_deposit_call.go (1)

32-32: LGTM with a minor enhancement suggestion

The receiver address verification is correctly implemented. Consider enhancing the assertion with a custom error message for better debugging:

-require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, contractAddr.Hex())
+require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, contractAddr.Hex(), "receiver address mismatch in outbound params")
e2e/e2etests/test_solana_deposit.go (1)

32-32: Maintain consistency with error messages

The receiver address verification is correct. For consistency with other tests, enhance the assertion with a descriptive error message:

-require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, r.EVMAddress().Hex())
+require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, r.EVMAddress().Hex(), "receiver address mismatch in outbound params")
e2e/e2etests/test_spl_deposit.go (2)

45-45: Maintain consistency with error messages

The receiver address verification is correct. For consistency with other tests, enhance the assertion with a descriptive error message:

-require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, r.EVMAddress().Hex())
+require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, r.EVMAddress().Hex(), "receiver address mismatch in outbound params")

Line range hint 1-67: Consider refactoring common test patterns

The receiver address verification pattern is now repeated across multiple test files. Consider extracting this common verification logic into a helper function in the utils package:

// utils/cctx.go
func RequireCCTXReceiver(t require.TestingT, cctx *crosschaintypes.CrossChainTx, expectedReceiver string, msgAndArgs ...interface{}) {
    require.Equal(t, cctx.GetCurrentOutboundParam().Receiver, expectedReceiver, msgAndArgs...)
}

This would improve maintainability and ensure consistent verification across all tests.

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

Line range hint 276-282: Consider adding error handling for memo decoding

While the current implementation works, it might be beneficial to add specific error handling for different memo decoding scenarios.

Consider adding structured error handling:

 err := event.DecodeMemo()
 if err != nil {
+    if errors.Is(err, types.ErrInvalidMemoFormat) {
+        ob.Logger().Inbound.Warn().Fields(lf).Msg("invalid memo format")
+    } else if errors.Is(err, types.ErrMemoTooShort) {
+        ob.Logger().Inbound.Warn().Fields(lf).Msg("memo too short")
+    }
     ob.Logger().Inbound.Info().Fields(lf).Msgf("invalid memo bytes: %s", hex.EncodeToString(event.Memo))
     return nil
 }
changelog.md (1)

22-22: Consider enhancing the changelog entry with more context.

The current entry could be more informative by explaining:

  1. The impact of the incorrect receiver assignment
  2. The benefits of using the decoded ZEVM address from memo
  3. The affected components (indexers/explorers)

Suggested enhancement:

-* [3242](https://github.com/zeta-chain/node/pull/3242) - set the `Receiver` of `MsgVoteInbound` to the address pulled from solana memo
+* [3242](https://github.com/zeta-chain/node/pull/3242) - set the `Receiver` of `MsgVoteInbound` to the ZEVM address decoded from Solana memo instead of the original Solana sender address. While this fix does not affect CCTX processing in the zetacore, it improves clarity for indexers and explorers by using the correct decoded receiver address.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a8236ed and 61692ea.

📒 Files selected for processing (7)
  • changelog.md (1 hunks)
  • e2e/e2etests/test_solana_deposit.go (1 hunks)
  • e2e/e2etests/test_solana_deposit_call.go (1 hunks)
  • e2e/e2etests/test_spl_deposit.go (1 hunks)
  • e2e/e2etests/test_spl_deposit_and_call.go (1 hunks)
  • zetaclient/chains/solana/observer/inbound.go (3 hunks)
  • zetaclient/chains/solana/observer/inbound_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
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.

e2e/e2etests/test_spl_deposit.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.

e2e/e2etests/test_solana_deposit.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.

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.

🔇 Additional comments (4)
e2e/e2etests/test_spl_deposit_and_call.go (1)

52-52: LGTM: Good addition of receiver address verification

The assertion correctly verifies that the cross-chain transaction's receiver matches the deployed contract address, enhancing the test coverage.

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

126-127: LGTM: Enhanced test coverage for receiver address handling

The test modifications properly verify that the receiver address from the event is correctly propagated to the vote message.

Also applies to: 131-132

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

215-215: LGTM: Proper initialization of receiver field

The receiver field is correctly initialized as empty, with a clear comment indicating it will be populated from the memo later. This change aligns with the PR objective and improves code clarity.

Also applies to: 243-243


291-291: LGTM: Fixed receiver address assignment in vote message

The vote message now correctly uses the decoded receiver address from the event instead of the sender address, fixing the core issue described in the PR objectives.

@ws4charlie ws4charlie requested a review from a team as a code owner December 10, 2024 04:55
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 61.78%. Comparing base (1329066) to head (7ebfef6).
Report is 1 commits behind head on develop.

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

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3242   +/-   ##
========================================
  Coverage    61.78%   61.78%           
========================================
  Files          431      431           
  Lines        30786    30786           
========================================
  Hits         19021    19021           
  Misses       10909    10909           
  Partials       856      856           
Files with missing lines Coverage Δ
zetaclient/chains/solana/observer/inbound.go 35.77% <66.66%> (ø)

@ws4charlie ws4charlie added this pull request to the merge queue Dec 10, 2024
Merged via the queue into develop with commit edac8fa Dec 10, 2024
41 checks passed
@ws4charlie ws4charlie deleted the fix-solana-MsgVoteInbound-Receiver-address branch December 10, 2024 05:50
skosito pushed a commit that referenced this pull request Dec 10, 2024
…und (#3242)

* use the ZEVM address decoded from memo as Receiver in MsgVoteInbound

* add Receiver check in unit test

* add changelog entry

* fix unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants