Skip to content

feat: integrate execute revert#3790

Merged
skosito merged 11 commits intodevelopfrom
integrate-execute-revert
Apr 22, 2025
Merged

feat: integrate execute revert#3790
skosito merged 11 commits intodevelopfrom
integrate-execute-revert

Conversation

@skosito
Copy link
Member

@skosito skosito commented Apr 8, 2025

Description

tried to reuse as much as possible from execute, since these 2 instructions are almost identical, and adding new instruction adds a lot of boilerplate, but let me know if this is not super readable

solana PR zeta-chain/protocol-contracts-solana#101

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 an "execute revert" capability that improves the handling of transaction reversions during deposit and withdrawal operations.
  • Updates
    • Increased transaction compute limits for smoother performance.
    • Enhanced processing logic to clearly differentiate between standard and revert executions.
    • Upgraded underlying dependencies for greater stability.
  • Tests
    • Expanded testing scenarios to ensure robust and reliable processing in revert-related transactions.

@skosito skosito added the SOLANA_TESTS Run make start-solana-test label Apr 8, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 8, 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 integrates an “execute revert” functionality into Solana operations. It adds new changelog entries, test cases, and constants to validate deposit, call, and withdrawal scenarios involving revert behavior. Several structs and methods across modules have been updated to support revert-related data and control flow, including changes in instruction discriminators, message construction, and signature handling. Additionally, dependency versions and compute unit limits have been updated, and new JSON test data reflecting the transaction metadata has been introduced.

Changes

File(s) Change Summary
changelog.md Added new changelog entry for PR [3790] integrating execute revert functionality.
cmd/zetae2e/local/local.go Integrated two new Solana test cases for deposit and call revert operations.
e2e/e2etests/e2etests.go, e2etests/test_solana_deposit_and_call_revert_with_call.go, e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go Added new test constants and functions to validate revert behaviors in deposit and call operations.
e2e/e2etests/test_solana_withdraw_and_call.go, e2etests/test_spl_withdraw_and_call.go Extended ConnectedPdaInfo struct with revert-related fields.
e2e/runner/solana.go Increased compute unit limit from 100,000 to 500,000 for SOL deposit transactions.
go.mod Updated dependency version for github.com/zeta-chain/protocol-contracts-solana/go-idl.
pkg/contracts/solana/gateway.go, pkg/contracts/solana/gateway.json, pkg/contracts/solana/gateway_message.go, pkg/contracts/solana/gateway_message_test.go, pkg/contracts/solana/instruction.go Integrated execute revert functionality: added new discriminators, instructions, message enhancements, and parsing methods.
zetaclient/chains/solana/observer/outbound.go, zetaclient/chains/solana/observer/outbound_test.go Updated outbound instruction parsing to include execution revert handling with additional tests.
zetaclient/chains/solana/signer/execute.go, zetaclient/chains/solana/signer/signer.go Modified message signing and transaction processing to support revert operations and updated sender type handling.
zetaclient/testdata/solana/chain_901_outbound_tx_result_*.json Added new JSON test data file with detailed Solana transaction metadata.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant S as Signer
    participant G as Gateway
    participant B as Blockchain

    C->>S: Submit transaction request (with revert flag)
    S->>S: Evaluate transaction type (Normal vs Revert)
    alt Revert Execution
        S->>S: Call createAndSignMsgExecute(revert=true)
        S->>G: Build executeRevert instruction
    else Normal Execution
        S->>S: Call createAndSignMsgExecute(revert=false)
        S->>G: Build standard execute instruction
    end
    G->>B: Submit instruction to blockchain
    B-->>G: Return transaction result
    G-->>S: Relay transaction status and messages
    S-->>C: Return final status (including revert details if applicable)
Loading

Possibly related PRs

Suggested labels

CONSENSUS_BREAKING_ACK

Suggested reviewers

  • lumtis

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.

@skosito skosito changed the title add execute revert and e2e tests feat: add execute revert and e2e tests Apr 8, 2025
@codecov
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

Attention: Patch coverage is 4.47761% with 64 lines in your changes missing coverage. Please review.

Project coverage is 64.20%. Comparing base (fc1559f) to head (a17b203).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/solana/signer/execute.go 0.00% 34 Missing ⚠️
zetaclient/chains/solana/signer/signer.go 0.00% 24 Missing ⚠️
zetaclient/chains/solana/observer/outbound.go 33.33% 4 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3790      +/-   ##
===========================================
- Coverage    64.28%   64.20%   -0.08%     
===========================================
  Files          463      463              
  Lines        33271    33308      +37     
===========================================
- Hits         21387    21386       -1     
- Misses       10900    10936      +36     
- Partials       984      986       +2     
Files with missing lines Coverage Δ
zetaclient/chains/solana/observer/outbound.go 32.65% <33.33%> (-1.10%) ⬇️
zetaclient/chains/solana/signer/signer.go 10.68% <0.00%> (-0.27%) ⬇️
zetaclient/chains/solana/signer/execute.go 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@skosito skosito changed the title feat: add execute revert and e2e tests feat: integrate execute revert Apr 8, 2025
@github-actions
Copy link

github-actions bot commented Apr 8, 2025

!!!WARNING!!!
nosec detected in the following files: pkg/contracts/solana/gateway_message_test.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Apr 8, 2025
@skosito skosito marked this pull request as ready for review April 9, 2025 16:29
@skosito skosito requested a review from a team as a code owner April 9, 2025 16:29
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: 3

♻️ Duplicate comments (2)
e2e/e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go (2)

24-27: Same TODO issue as previous file.

The TODO comment about repeated reverter contract deployments appears here as well. The same refactoring suggestion applies.

See the refactoring suggestion in test_solana_deposit_and_call_revert_with_call.go for a solution to avoid repeated deployments.


69-78: Duplicate ConnectedPdaInfo definition.

The ConnectedPdaInfo struct is defined here exactly as in the other test file. This reinforces the need for a shared definition.

See the refactoring suggestion in test_solana_deposit_and_call_revert_with_call.go for extracting this struct to a shared location.

🧹 Nitpick comments (11)
e2e/runner/solana.go (2)

458-458: Significant increase in compute unit limit for SOL transactions.

The compute unit limit for SOL transactions has been increased from 100,000 to 500,000, which is a 5x increase. This change is likely necessary to support the more complex execute_revert functionality, but it may have implications for transaction fees.

Consider documenting the rationale for this increase in a comment to provide context for future developers.

-	limit := computebudget.NewSetComputeUnitLimitInstruction(500000).Build() // 500k compute unit limit
+	limit := computebudget.NewSetComputeUnitLimitInstruction(500000).Build() // 500k compute unit limit - increased from 100k to support execute_revert operations

490-490: Consider updating compute unit limit for SOLCall method.

For consistency, you might want to update the compute unit limit in the SOLCall method as well, which still uses 100,000 units. If execute_revert operations require more computational resources, regular call operations might benefit from the increased limit too.

-	limit := computebudget.NewSetComputeUnitLimitInstruction(100000).Build() // 100k compute unit limit
+	limit := computebudget.NewSetComputeUnitLimitInstruction(500000).Build() // 500k compute unit limit - consistent with SOLDepositAndCall
e2e/e2etests/test_solana_deposit_and_call_revert_with_call.go (2)

23-26: Address TODO comment about repeated reverter contract deployments.

The TODO comment indicates a potential optimization opportunity. Consider refactoring to deploy the reverter contract once and reuse it across tests to improve test execution time.

Extract the reverter contract deployment to a shared setup function that can be called by multiple test functions:

-	// TODO: consider removing repeated deployments of reverter contract
-	reverterAddr, _, _, err := testcontract.DeployReverter(r.ZEVMAuth, r.ZEVMClient)
-	require.NoError(r, err)
-	r.Logger.Info("Reverter contract deployed at: %s", reverterAddr.String())
+	reverterAddr := deployOrGetReverterContract(r)

Add a helper function to deploy or retrieve the contract:

// deployOrGetReverterContract deploys the reverter contract once or returns the existing address
func deployOrGetReverterContract(r *runner.E2ERunner) common.Address {
	// Use a package-level variable to cache the deployment
	if reverterContractAddr == (common.Address{}) {
		addr, _, _, err := testcontract.DeployReverter(r.ZEVMAuth, r.ZEVMClient)
		require.NoError(r, err)
		r.Logger.Info("Reverter contract deployed at: %s", addr.String())
		reverterContractAddr = addr
	}
	return reverterContractAddr
}

68-78: Consider making ConnectedPdaInfo reusable.

This struct is defined multiple times across different test files. Consider extracting it to a shared package to improve maintainability.

Move the ConnectedPdaInfo struct to a shared location:

-	type ConnectedPdaInfo struct {
-		Discriminator     [8]byte
-		LastSender        [20]byte
-		LastMessage       string
-		LastRevertSender  solana.PublicKey
-		LastRevertMessage string
-	}
-	pda := ConnectedPdaInfo{}
+	pda := utils.ConnectedPdaInfo{}

And define it once in a shared file like e2e/utils/types.go:

// ConnectedPdaInfo represents the structure of data stored in the connected PDA
type ConnectedPdaInfo struct {
	Discriminator     [8]byte
	LastSender        [20]byte
	LastMessage       string
	LastRevertSender  solana.PublicKey
	LastRevertMessage string
}
e2e/e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go (1)

15-17: Function comment has a typo.

There's a typo in the function comment: "revets" should be "reverts".

-// with revert options when call on revert program revets
+// with revert options when call on revert program reverts
zetaclient/chains/solana/signer/execute.go (1)

68-84: New branching for execute_revert serialization.
This is a clear separation of concerns. Verify that you handle any additional fields needed in a real-world revert scenario (e.g., logs or revert reason data) to ensure robust error reporting.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 68-84: zetaclient/chains/solana/signer/execute.go#L68-L84
Added lines #L68 - L84 were not covered by tests

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

344-345: Remove duplicate interface assertion

The assertion var _ OutboundInstruction = (*ExecuteInstructionParams)(nil) already exists on line 273, making this line redundant.

-var _ OutboundInstruction = (*ExecuteInstructionParams)(nil)

355-356: Consider consistency in using field type for Sender

The Sender field type is solana.PublicKey here while the corresponding field in ExecuteInstructionParams (line 284) uses [20]byte. For consistency, consider using the same type across both structs unless there's a specific reason for the difference.


397-399: Correct the function comment

The function comment incorrectly refers to 'execute' but this function parses 'execute_revert'.

-// ParseInstructionExecute tries to parse the instruction as a 'execute_revert'.
-// It returns nil if the instruction can't be parsed as a 'execute_revert'.
+// ParseInstructionExecuteRevert tries to parse the instruction as a 'execute_revert'.
+// It returns nil if the instruction can't be parsed as a 'execute_revert'.
zetaclient/chains/solana/signer/signer.go (1)

407-417: Clearly separate revert message handling logic

The message handling logic now has two branches (revert and non-revert). Consider extracting this into a helper function to improve readability and maintainability.

- isRevert := cctx.CctxStatus.Status == types.CctxStatus_PendingRevert && cctx.RevertOptions.CallOnRevert
- var message []byte
- if isRevert {
-   message = cctx.RevertOptions.RevertMessage
- } else {
-   messageToDecode, err := hex.DecodeString(cctx.RelayedMessage)
-   if err != nil {
-     return nil, errors.Wrapf(err, "decodeString %s error", cctx.RelayedMessage)
-   }
-   message = messageToDecode
- }
+ isRevert := cctx.CctxStatus.Status == types.CctxStatus_PendingRevert && cctx.RevertOptions.CallOnRevert
+ message, err := getExecuteMessage(cctx, isRevert)
+ if err != nil {
+   return nil, err
+ }

// Add this helper function elsewhere in the file
func getExecuteMessage(cctx *types.CrossChainTx, isRevert bool) ([]byte, error) {
    if isRevert {
        return cctx.RevertOptions.RevertMessage, nil
    }
    
    messageToDecode, err := hex.DecodeString(cctx.RelayedMessage)
    if err != nil {
        return nil, errors.Wrapf(err, "decodeString %s error", cctx.RelayedMessage)
    }
    return messageToDecode, nil
}
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 407-416: zetaclient/chains/solana/signer/signer.go#L407-L416
Added lines #L407 - L416 were not covered by tests

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

314-319: Consider using polymorphism instead of conditional logic

The Hash() method now includes conditional logic to determine which instruction byte to use. For better maintainability and extensibility, consider using polymorphism by creating separate message types for execute and execute_revert.

This would involve creating a base message type and two derived types, each with their own Hash() implementation. However, since this would require more extensive refactoring, the current approach is acceptable for now.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 928adc5 and a2e7904.

⛔ Files ignored due to path filters (3)
  • contrib/localnet/solana/connected.so is excluded by !**/*.so
  • contrib/localnet/solana/gateway.so is excluded by !**/*.so
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (19)
  • changelog.md (1 hunks)
  • cmd/zetae2e/local/local.go (1 hunks)
  • e2e/e2etests/e2etests.go (2 hunks)
  • e2e/e2etests/test_solana_deposit_and_call_revert_with_call.go (1 hunks)
  • e2e/e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go (1 hunks)
  • e2e/e2etests/test_solana_withdraw_and_call.go (1 hunks)
  • e2e/e2etests/test_spl_withdraw_and_call.go (1 hunks)
  • e2e/runner/solana.go (1 hunks)
  • go.mod (1 hunks)
  • pkg/contracts/solana/gateway.go (1 hunks)
  • pkg/contracts/solana/gateway.json (1 hunks)
  • pkg/contracts/solana/gateway_message.go (6 hunks)
  • pkg/contracts/solana/gateway_message_test.go (2 hunks)
  • pkg/contracts/solana/instruction.go (1 hunks)
  • zetaclient/chains/solana/observer/outbound.go (1 hunks)
  • zetaclient/chains/solana/observer/outbound_test.go (2 hunks)
  • zetaclient/chains/solana/signer/execute.go (4 hunks)
  • zetaclient/chains/solana/signer/signer.go (3 hunks)
  • zetaclient/testdata/solana/chain_901_outbound_tx_result_4QjCYR4CfS5RFUQuRS8W68ZpBgqd91zZmC5Z1M4uyh4BeZWnB6NtRMxwwZttyre344zX6vTme2Eum94BHQ5Xk9Tf.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

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

  • zetaclient/chains/solana/observer/outbound.go
  • cmd/zetae2e/local/local.go
  • e2e/runner/solana.go
  • pkg/contracts/solana/gateway.go
  • zetaclient/chains/solana/observer/outbound_test.go
  • e2e/e2etests/test_solana_withdraw_and_call.go
  • e2e/e2etests/test_spl_withdraw_and_call.go
  • e2e/e2etests/test_solana_deposit_and_call_revert_with_call.go
  • e2e/e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go
  • e2e/e2etests/e2etests.go
  • zetaclient/chains/solana/signer/execute.go
  • pkg/contracts/solana/instruction.go
  • pkg/contracts/solana/gateway_message_test.go
  • pkg/contracts/solana/gateway_message.go
  • zetaclient/chains/solana/signer/signer.go
🧬 Code Graph Analysis (8)
zetaclient/chains/solana/observer/outbound.go (1)
pkg/contracts/solana/instruction.go (3)
  • ParseInstructionWithdraw (257-271)
  • ParseInstructionExecute (328-342)
  • ParseInstructionExecuteRevert (399-413)
cmd/zetae2e/local/local.go (1)
e2e/e2etests/e2etests.go (2)
  • TestSolanaDepositAndCallRevertWithCallName (69-69)
  • TestSolanaDepositAndCallRevertWithCallThatRevertsName (70-70)
zetaclient/chains/solana/observer/outbound_test.go (2)
zetaclient/chains/solana/rpc/rpc.go (1)
  • GetTransaction (130-148)
pkg/contracts/solana/instruction.go (1)
  • ParseInstructionExecuteRevert (399-413)
e2e/e2etests/test_solana_deposit_and_call_revert_with_call.go (8)
e2e/utils/parsing.go (1)
  • ParseBigInt (27-32)
pkg/contracts/solana/gateway.go (2)
  • ComputeConnectedPdaAddress (92-94)
  • ComputePdaAddress (82-89)
e2e/runner/solana.go (1)
  • ConnectedProgramID (24-24)
pkg/contracts/solana/instruction.go (2)
  • GetExecuteMsgAbi (640-662)
  • ExecuteMsg (634-637)
e2e/utils/contracts.go (1)
  • ErrHashRevertFoo (14-14)
e2e/e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go (1)
  • ConnectedPdaInfo (69-75)
e2e/e2etests/test_spl_withdraw_and_call.go (1)
  • ConnectedPdaInfo (92-98)
e2e/e2etests/test_solana_withdraw_and_call.go (1)
  • ConnectedPdaInfo (89-95)
e2e/e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go (5)
e2e/runner/runner.go (1)
  • E2ERunner (80-204)
e2e/utils/parsing.go (1)
  • ParseBigInt (27-32)
e2e/runner/solana.go (1)
  • ConnectedProgramID (24-24)
pkg/contracts/solana/instruction.go (2)
  • GetExecuteMsgAbi (640-662)
  • ExecuteMsg (634-637)
e2e/utils/contracts.go (1)
  • ErrHashRevertFoo (14-14)
e2e/e2etests/e2etests.go (3)
e2e/runner/e2etest.go (3)
  • NewE2ETest (30-47)
  • ArgDefinition (50-53)
  • WithMinimumVersion (13-17)
e2e/e2etests/test_solana_deposit_and_call_revert_with_call.go (1)
  • TestSolanaDepositAndCallRevertWithCall (16-84)
e2e/e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go (1)
  • TestSolanaDepositAndCallRevertWithCallThatReverts (17-81)
zetaclient/chains/solana/signer/execute.go (2)
pkg/contracts/solana/instruction.go (3)
  • AccountMeta (628-631)
  • ExecuteRevertInstructionParams (347-371)
  • ExecuteInstructionParams (276-300)
pkg/contracts/solana/gateway_message.go (1)
  • NewMsgExecute (248-266)
pkg/contracts/solana/instruction.go (3)
zetaclient/chains/solana/signer/signer.go (1)
  • Signer (54-69)
zetaclient/chains/base/signer.go (1)
  • Signer (18-36)
pkg/contracts/solana/gateway.go (1)
  • DiscriminatorExecuteRevert (49-49)
🪛 GitHub Check: codecov/patch
zetaclient/chains/solana/observer/outbound.go

[warning] 344-345: zetaclient/chains/solana/observer/outbound.go#L344-L345
Added lines #L344 - L345 were not covered by tests


[warning] 347-348: zetaclient/chains/solana/observer/outbound.go#L347-L348
Added lines #L347 - L348 were not covered by tests

zetaclient/chains/solana/signer/execute.go

[warning] 46-46: zetaclient/chains/solana/signer/execute.go#L46
Added line #L46 was not covered by tests


[warning] 68-84: zetaclient/chains/solana/signer/execute.go#L68-L84
Added lines #L68 - L84 were not covered by tests


[warning] 86-100: zetaclient/chains/solana/signer/execute.go#L86-L100
Added lines #L86 - L100 were not covered by tests


[warning] 102-102: zetaclient/chains/solana/signer/execute.go#L102
Added line #L102 was not covered by tests

zetaclient/chains/solana/signer/signer.go

[warning] 165-166: zetaclient/chains/solana/signer/signer.go#L165-L166
Added lines #L165 - L166 were not covered by tests


[warning] 407-416: zetaclient/chains/solana/signer/signer.go#L407-L416
Added lines #L407 - L416 were not covered by tests


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


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

🔇 Additional comments (37)
changelog.md (1)

20-20: LGTM: Clean changelog entry added for PR #3790.

The changelog entry follows the established pattern and clearly indicates the purpose of this pull request.

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

48-49: LGTM: Added discriminator constant for new execute_revert instruction.

The addition follows the established pattern for instruction discriminators and is properly documented with a clear comment.

go.mod (1)

315-315:

Details

✅ Verification successful

Verify updated dependency compatibility.

The protocol-contracts-solana/go-idl dependency has been updated to a newer version (20250408183930 from 20250320221859). This update is likely necessary to support the new execute_revert functionality.


🏁 Script executed:

#!/bin/bash
# Verify the compatibility of the updated dependency with the codebase

# Check if the updated dependency introduces any breaking changes
go list -m -json github.com/zeta-chain/protocol-contracts-solana/go-idl@v0.0.0-20250408183930-aee4e8908b9a

Length of output: 735


Dependency Compatibility Verified – No Issues Found

The metadata for the updated dependency:

github.com/zeta-chain/protocol-contracts-solana/go-idl v0.0.0-20250408183930-aee4e8908b9a

has been verified using the go list -m -json command. The results show the updated module with the expected commit hash, Go version, and checksum values. This update appears to be correctly aligned with the new execute_revert functionality, with no evidence of breaking changes detected.

cmd/zetae2e/local/local.go (1)

444-445: Good addition of test cases to validate the new functionality.

The introduction of these two test cases for Solana deposit operations with revert functionality is appropriate. They complement the existing tests and follow the established naming conventions.

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

340-349:

Details

✅ Verification successful

Streamlined instruction parsing with improved control flow.

The refactored code provides a more maintainable and sequential approach to instruction parsing, appropriately adding support for the new ExecuteRevert instruction type.

However, the static analysis indicates that some of this code lacks test coverage. Consider adding tests that would exercise these new code paths:


🏁 Script executed:

#!/bin/bash
# Check for existing test coverage of ExecuteRevert parsing
rg -A 10 "Test.*ParseInstructionExecuteRevert" --type go

Length of output: 996


Test coverage for ExecuteRevert parsing confirmed

The refactored code for instruction parsing is streamlined and maintainable, with the new ExecuteRevert path adequately covered. The test file zetaclient/chains/solana/observer/outbound_test.go already includes Test_ParseInstructionExecuteRevert, verifying that the new code path is exercised.

No additional test cases are required at this time. Please ensure to keep the tests updated in case of further modifications.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 344-345: zetaclient/chains/solana/observer/outbound.go#L344-L345
Added lines #L344 - L345 were not covered by tests


[warning] 347-348: zetaclient/chains/solana/observer/outbound.go#L347-L348
Added lines #L347 - L348 were not covered by tests

e2e/e2etests/test_solana_withdraw_and_call.go (1)

93-94: Appropriate extension of the data structure for revert operations.

The addition of LastRevertSender and LastRevertMessage fields to the ConnectedPdaInfo struct properly accommodates the new revert functionality. These fields provide essential context for tracking revert operations in tests.

e2e/e2etests/test_spl_withdraw_and_call.go (1)

96-97: Consistent structure extension across related files.

The addition of revert-related fields here maintains consistency with the changes in the test_solana_withdraw_and_call.go file, ensuring uniform handling of revert operations across different token types.

zetaclient/chains/solana/observer/outbound_test.go (4)

55-57: New constant for execute_revert testing looks good.

The addition of executeRevertTxTest follows the established pattern of defining transaction test constants used throughout the test file.


765-794: LGTM: Test structure follows established pattern.

The happy path test case for ParseInstructionExecuteRevert correctly validates the expected behavior by verifying the sender address, gateway nonce, and token amount after parsing.


796-813: Error handling test is implemented appropriately.

The test case properly checks the error handling when invalid instruction data is provided, following the pattern established in other similar test functions.


815-835: Discriminator mismatch test is well implemented.

The test validates the error case when the instruction's discriminator doesn't match the expected value for an execute_revert instruction.

pkg/contracts/solana/gateway.json (4)

656-669: Clear documentation for the execute_revert instruction.

The documentation appropriately describes the purpose of the instruction and its arguments, maintaining consistency with other instruction documentation in the file.


670-679: Unique discriminator for execute_revert instruction.

The instruction has a properly defined unique discriminator that differentiates it from other instructions, which is essential for correct instruction parsing.


680-740: Account specification matches execute instruction.

The account specifications for execute_revert follow the same structure as the execute instruction, which is appropriate given their similar functionality.


655-781:

Details

❓ Verification inconclusive

Type inconsistency in sender parameter between execute and execute_revert instructions.

The sender parameter in the execute_revert instruction (line 748) uses a pubkey type, while the execute instruction (line 615) uses an array of bytes "type": {"array": ["u8", 20]}. Verify this inconsistency is intentional and doesn't cause compatibility issues.


🏁 Script executed:

#!/bin/bash
# Check how the sender type is used in execute_revert implementation
rg -A 5 -B 5 "execute_revert.*sender" --glob "**/*.go"

# Check if there are any existing parameters using both types
rg --json "sender.*pubkey|sender.*\[u8, 20\]" --glob "**/*.go" | jq '.data.lines.text'

Length of output: 330


Action: Verify the intended type conversion for the sender parameter across instructions.

The sender parameter in the execute_revert instruction is defined as a pubkey (line 748) while in the execute instruction it is defined as an array of bytes of length 20 (line 615). Preliminary searches did not reveal explicit conversion logic between the two formats in the Go codebase. Please ensure that this discrepancy is intentional and that the conversion (if any) is handled correctly to prevent compatibility issues. If this dual handling is by design (for example, to support legacy interfaces alongside modern representations), consider adding inline comments to clarify the rationale for future maintainers.

e2e/e2etests/test_solana_deposit_and_call_revert_with_call.go (4)

38-51: Good use of ABI encoding for message preparation.

The code correctly uses the ABI encoding functions to prepare the execute message.


52-57: Properly configured revert options for testing.

The test correctly sets up the revert options with the appropriate address, enabling the on_revert call, and providing the encoded message.


59-64: Comprehensive CCTX verification.

The test appropriately verifies that the cross-chain transaction is marked as reverted and contains the expected error message.


79-83: Appropriate verification of state changes.

The test correctly verifies that the last revert message and sender match the expected values, and that the PDA's balance has increased.

e2e/e2etests/test_solana_deposit_and_call_revert_with_call_that_reverts.go (3)

38-51: Message encoding for revert scenario.

The code correctly prepares the message for testing the revert scenario, using the same approach as the previous test file.


59-64: Verify transaction is aborted instead of reverted.

This test properly expects an aborted status (different from the previous test which expected a reverted status), highlighting the different testing scenarios.


80-80: Proper verification of unchanged balance.

The test correctly verifies that the PDA's balance remains unchanged in the abort scenario, which is the expected behavior.

pkg/contracts/solana/gateway_message_test.go (2)

116-116: Confirm normal execution test coverage.
Your usage of the revert parameter set to false here is appropriate for simulating a standard execution scenario. Please ensure you have corresponding test cases covering both revert and non-revert flows to maintain high coverage.


150-171: Good addition of the Test_MsgExecuteRevertHash test.
This dedicated test for verifying the new revert-based execution path enhances confidence in your implementation. Confirm that all edge cases (e.g., zero amounts, unexpected metadata) are tested, so that the revert logic is thoroughly validated.

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

1-114: New JSON fixture for revert scenario looks well-structured.
This file appears to contain no sensitive data and provides detailed logs for debugging. Ensure it remains up to date with any contract log format changes.

e2e/e2etests/e2etests.go (2)

63-81: Comprehensive list of new Solana test constants.
Adding clearly named constants improves maintainability and discoverability of your tests. Good job adhering to naming conventions.


648-665: Inclusion of new revert-with-call tests.
These entries successfully expand coverage of Solana deposit and revert scenarios. Verify that any newly introduced dependencies or minimum version logic is satisfied in your CI environment.

zetaclient/chains/solana/signer/execute.go (4)

7-7: New import for Ethereum address handling.
The addition of github.com/ethereum/go-ethereum/common is appropriate for parsing and validating addresses from a string. No concerns here.


46-46: Instantiation of NewMsgExecute with revert logic.
Be sure to handle edge cases, such as when sender might be empty or invalid. To confirm correctness, consider adding further code-level or test-level checks preventing invalid addresses.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 46-46: zetaclient/chains/solana/signer/execute.go#L46
Added line #L46 was not covered by tests


86-100: Fallback to standard ExecuteInstructionParams.
The non-revert block is consistent; it parallels the new structure, preserving backward compatibility. Code readability remains good.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 86-100: zetaclient/chains/solana/signer/execute.go#L86-L100
Added lines #L86 - L100 were not covered by tests


102-102: Data bytes assignment for the instruction.
Unit tests exercising both revert and non-revert branches are crucial. Guard against regressions by confirming coverage of this assignment logic in your test suite.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 102-102: zetaclient/chains/solana/signer/execute.go#L102
Added line #L102 was not covered by tests

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

346-371: LGTM: New struct defined for execute_revert operation

The ExecuteRevertInstructionParams struct is well-defined with appropriate fields and documentation. The struct properly follows the pattern established for other instruction parameter types.


400-412: LGTM: Parsing function is correctly implemented

The ParseInstructionExecuteRevert function correctly deserializes the instruction data and verifies the discriminator.

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

20-20: LGTM: New instruction identifier added

The addition of InstructionExecuteRevert with value 8 follows the existing pattern for instruction identifiers.


240-242: LGTM: New revert field for distinguishing execution types

Adding the revert boolean field is a clear way to distinguish between normal execution and revert execution.


304-306: LGTM: Added accessor method for new field

The Revert() method properly exposes the new field, following the pattern established for other fields.


235-235:

Details

❓ Verification inconclusive

Verify impacts of changing sender field type

The type of the sender field has been changed from [20]byte to string. Ensure this change doesn't impact other parts of the codebase that might be relying on the original type.


🏁 Script executed:

#!/bin/bash
# Check for usages of MsgExecute.sender to identify potential impacts

echo "Checking for direct references to MsgExecute.sender field..."
rg "\.sender" --type go | grep -i "msgexecute"

echo "Checking for calls to Sender() method..."
rg "\.Sender\(\)" --type go | grep -i "msgexecute"

Length of output: 319


Action Required: Verify Field Type Change Impact for MsgExecute.sender

Based on the automated search, there are no direct references to either the MsgExecute.sender field or calls to the Sender() method, which suggests that changing its type from [20]byte to string may have minimal impact. However, given the limited output from the search, please manually verify that no dependent code relies on the original [20]byte type.

  • Confirm that no modules or interfaces expect a [20]byte for sender.
  • Ensure that any indirect or implicit usages in the codebase (e.g., serialization or interfacing code) are updated accordingly.

@lumtis
Copy link
Contributor

lumtis commented Apr 10, 2025

Should the PR in the Solana contract repo be put ready for review?

@skosito skosito mentioned this pull request Apr 11, 2025
5 tasks
@skosito
Copy link
Member Author

skosito commented Apr 11, 2025

Should the PR in the Solana contract repo be put ready for review?

i updated solana PR in PR description here

@skosito skosito requested a review from lumtis April 11, 2025 18:27
@skosito skosito requested a review from swift1337 April 18, 2025 06:23
@skosito skosito added this pull request to the merge queue Apr 22, 2025
Merged via the queue into develop with commit 0cce92f Apr 22, 2025
45 of 46 checks passed
@skosito skosito deleted the integrate-execute-revert branch April 22, 2025 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:cli nosec SOLANA_TESTS Run make start-solana-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants