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

feat: support for fast outbound confirmation for EVM/Bitcoin chain #3619

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from

Conversation

ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Mar 3, 2025

Description

The main contents of this PR:

  • Create a method IsOutboundEligibleForFastConfirmation to determine if an outbound can be fast confirmed.
  • Add proper confirmation mode FAST | SAFE to message MsgVoteOutbound.
  • Move Bitcoin block mining logic MineBlocksIfLocalBitcoin out from individual E2E tests, so that all tests will be running on a constant Regnet block time.
  • Move PostVoteOutbound to base observer to simply and unify outbound vote logic for both EVM and Bitcoin chain.
  • E2E tests for both FAST ETH withdraw and FAST BTC withdraw.
  • Fix the repetitive outbound tracker submissions in local environment.

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 outbound fast confirmation for both Ethereum and Bitcoin networks, complementing the existing inbound confirmation process. This enhancement streamlines withdrawal workflows and improves overall transaction responsiveness.
  • Performance Improvements

    • Optimized confirmation parameters and timing settings to reduce wait times, resulting in more efficient and reliable transaction processing across supported chains.

ws4charlie and others added 22 commits February 18, 2025 23:01
…lace argument type string with common.Address
…ove divisor related file to chains pkg; renaming and comments
Copy link

github-actions bot commented Mar 3, 2025

!!!WARNING!!!
nosec detected in the following files: zetaclient/chains/bitcoin/observer/outbound.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 Mar 3, 2025
@ws4charlie ws4charlie added zetaclient Issues related to ZetaClient feature:protocol Feature extending the capability of the protocol CONSENSUS_BREAKING_ACK Acknowledge a consensus breaking change labels Mar 3, 2025
Copy link
Contributor

coderabbitai bot commented Mar 3, 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 introduces outbound fast confirmation support for both EVM and Bitcoin chains. It adds new test cases and modifies existing end-to-end tests to adjust parameters and remove legacy local mining procedures. Additionally, the changes refactor several functions—including updates to method signatures, introduction of new helper methods for BTC withdrawals, and enhancements to outbound vote processing in observer components—to streamline transaction confirmation handling across the system.

Changes

File(s) Change Summary
changelog.md Added new entry under "Features" noting outbound fast confirmation support for both EVM and Bitcoin chains (PR 3619).
cmd/zetae2e/local/{bitcoin.go, evm.go, local.go} Updated Bitcoin tests: changed function signatures, adjusted test routines, removed legacy mining calls, and added an ETH withdrawal fast confirmation test case.
e2e/e2etests/* (multiple test files: test_bitcoin_deposit*, test_bitcoin_withdraw*, test_eth_deposit*, test_eth_withdraw*, test_crosschain_swap, test_migrate_tss.go) Added new test cases for fast confirmation and withdrawal scenarios; modified confirmation parameters; removed local Bitcoin mining setup from several tests; introduced stop mining cleanup in appropriate flows.
e2e/runner/{bitcoin.go, evm.go, setup_bitcoin.go, zevm.go} Adjusted Bitcoin regnet block time (from 6s to 5s); added new methods (ApproveBTCZRC20 in EVM runner and BTCWithdraw in ZEVM runner); removed block generation for funding the deployer address.
e2e/utils/zetacore.go Introduced GetCCTXByInboundHash and WaitOutboundTracker functions; removed the WaitForZetaBlocks function.
testutil/sample/crosschain.go Added OutboundVoteFromRand to generate sample outbound vote messages using randomness.
x/observer/types/{chain_params.go,chain_params_test.go} Added IsOutboundFastConfirmationEnabled method with corresponding tests to determine outbound fast confirmation status via chain parameters.
zetaclient/chains/base/{confirmation.go,confirmation_test.go,observer.go,observer_test.go} Added IsOutboundEligibleForFastConfirmation and PostVoteOutbound methods along with tests, enhancing outbound vote eligibility checks and posting logic.
zetaclient/chains/bitcoin/observer/{outbound.go,outbound_test.go} Refactored outbound vote flow by introducing a new helper newOutboundVote and updating test cases for VoteOutboundIfConfirmed.
zetaclient/chains/evm/observer/{observer_test.go,outbound.go,outbound_test.go} Removed postVoteOutbound, added newOutboundVote; updated test suite configuration and renamed tests to align with the new outbound vote processing.
zetaclient/chains/evm/signer/outbound_tracker_reporter.go Added logic to retrieve the current cross-chain transaction context and skip reporting if the transaction is finalized.

Sequence Diagram(s)

sequenceDiagram
    participant T as Test
    participant R as E2ERunner
    participant G as GatewayZEVM
    participant O as Observer
    participant N as Node

    T->>R: Initiate BTCWithdraw(receiver, amount, options)
    R->>G: Call Withdraw API
    G-->>R: Return Transaction (tx)
    R->>O: Notify Observer with tx details
    O->>N: Poll for confirmations
    N-->>O: Confirmations reached
    O->>O: Evaluate fast confirmation eligibility
    O->>G: If eligible, call PostVoteOutbound to cast vote
Loading

Possibly related PRs

Suggested labels

chain:bitcoin, TSS_MIGRATION_TESTS

Suggested reviewers

  • fbac
  • kingpinXD
  • lumtis
  • skosito
  • gartnera

🪧 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.

@ws4charlie ws4charlie changed the title Feat: WIP, support for fast outbound confirmation for EVM/Bitcoin chain feat: WIP, support for fast outbound confirmation for EVM/Bitcoin chain Mar 3, 2025
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

Attention: Patch coverage is 83.01887% with 27 lines in your changes missing coverage. Please review.

Project coverage is 64.85%. Comparing base (5bac6f9) to head (093590d).

Files with missing lines Patch % Lines
zetaclient/chains/bitcoin/observer/outbound.go 79.59% 7 Missing and 3 partials ⚠️
zetaclient/chains/evm/observer/outbound.go 81.48% 6 Missing and 4 partials ⚠️
...ent/chains/evm/signer/outbound_tracker_reporter.go 0.00% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3619      +/-   ##
===========================================
+ Coverage    64.59%   64.85%   +0.26%     
===========================================
  Files          469      469              
  Lines        32911    32940      +29     
===========================================
+ Hits         21259    21364     +105     
+ Misses       10687    10607      -80     
- Partials       965      969       +4     
Files with missing lines Coverage Δ
x/crosschain/types/message_vote_outbound.go 100.00% <100.00%> (ø)
x/observer/types/chain_params.go 94.97% <100.00%> (+0.03%) ⬆️
zetaclient/chains/base/confirmation.go 100.00% <100.00%> (ø)
zetaclient/chains/base/observer.go 82.69% <100.00%> (+1.78%) ⬆️
...ent/chains/evm/signer/outbound_tracker_reporter.go 38.18% <0.00%> (-5.57%) ⬇️
zetaclient/chains/bitcoin/observer/outbound.go 53.52% <79.59%> (+19.76%) ⬆️
zetaclient/chains/evm/observer/outbound.go 61.86% <81.48%> (-0.75%) ⬇️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -68,6 +69,15 @@ func (signer *Signer) reportToOutboundTracker(
continue
}

// stop if the cctx is already finalized
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw a lots unnecessary outbound tracker submissions in E2E tests. I tracked down the root cause:

the outbound ballot finalizes so fast in local network and the tracker reporter is still submitting tracker without checking the CCTX's status. This will not happen on mainnet due to the slow finality.

@ws4charlie ws4charlie changed the title feat: WIP, support for fast outbound confirmation for EVM/Bitcoin chain feat: support for fast outbound confirmation for EVM/Bitcoin chain Mar 5, 2025
@ws4charlie ws4charlie marked this pull request as ready for review March 5, 2025 05:58
@ws4charlie ws4charlie requested a review from a team as a code owner March 5, 2025 05:58
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 comments (1)
e2e/runner/bitcoin.go (1)

392-394: 🛠️ Refactor suggestion

Error handling in goroutine should be improved.

The error handling in the goroutine calls require.NoError(r, err) which could potentially panic and terminate the goroutine unexpectedly. In long-running goroutines, it's better to handle errors gracefully.

Implement proper error logging instead of using require.NoError in the goroutine:

-				_, err := r.GenerateToAddressIfLocalBitcoin(1, r.BTCDeployerAddress)
-				require.NoError(r, err)
+				if _, err := r.GenerateToAddressIfLocalBitcoin(1, r.BTCDeployerAddress); err != nil {
+					r.Logger.Error("Failed to generate blocks in MineBlocksIfLocalBitcoin: %v", err)
+					time.Sleep(BTCRegnetBlockTime) // Still sleep to avoid tight loop on persistent errors
+					continue
+				}

This approach prevents the goroutine from terminating on error and provides helpful error logs for debugging.

🧹 Nitpick comments (21)
e2e/runner/bitcoin.go (1)

379-403: MineBlocksIfLocalBitcoin implementation is sound but could be enhanced with context support.

The current implementation of continuous block mining is well-structured with a clean stop mechanism. However, it would be more robust to use a context-based cancellation approach rather than a custom stop channel.

Consider implementing context-based cancellation for more idiomatic Go code:

-func (r *E2ERunner) MineBlocksIfLocalBitcoin() func() {
+func (r *E2ERunner) MineBlocksIfLocalBitcoin() context.CancelFunc {
 	require.NotNil(r, r.BTCDeployerAddress, "E2ERunner.BTCDeployerAddress is nil")
 
-	stopChan := make(chan struct{})
+	ctx, cancel := context.WithCancel(r.Ctx)
 	go func() {
 		for {
 			select {
-			case <-stopChan:
+			case <-ctx.Done():
 				return
 			default:
 				_, err := r.GenerateToAddressIfLocalBitcoin(1, r.BTCDeployerAddress)
 				require.NoError(r, err)
 
 				time.Sleep(BTCRegnetBlockTime)
 			}
 		}
 	}()
 
-	return func() {
-		close(stopChan)
-	}
+	return cancel
}

This approach leverages Go's standard context package for cancellation, which is the idiomatic way to handle goroutine cancellation in Go. It would also require adding context to the imports if not already present.

zetaclient/chains/evm/signer/outbound_tracker_reporter.go (1)

74-79: Improve error handling for CCTX retrieval failure.

The current implementation logs the error when unable to retrieve the CCTX but continues execution, which could potentially lead to unnecessary outbound tracker submissions if the error is transient. Consider implementing a retry mechanism or adding more contextual information to the error message.

if err != nil {
-	logger.Err(err).Msg("unable to get cctx for outbound")
+	logger.Err(err).
+		Str("chain_id", fmt.Sprintf("%d", chainID)).
+		Str("nonce", fmt.Sprintf("%d", nonce)).
+		Msg("unable to get cctx for outbound, will continue with tracker submission")
} else if !crosschainkeeper.IsPending(cctx) {
	logger.Info().Msg("cctx already finalized")
	return nil
}

This improved error logging would provide more diagnostic information for troubleshooting while maintaining the existing behavior.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 73-79: zetaclient/chains/evm/signer/outbound_tracker_reporter.go#L73-L79
Added lines #L73 - L79 were not covered by tests

testutil/sample/crosschain.go (1)

371-390: Well-implemented test utility for outbound vote generation.

This function properly creates sample outbound vote messages with randomized data for testing purposes. It mirrors the structure of the existing InboundVoteFromRand function and correctly implements randomization for all necessary fields.

Consider adding brief comments to explain the significance of specific fields, particularly for the Status field where specific values are chosen from an enumeration.

 // OutboundVoteFromRand creates a sample outbound vote message from a random source of randomness
 func OutboundVoteFromRand(to int64, r *rand.Rand) types.MsgVoteOutbound {
+    // Randomly select between success and failed status for the outbound transaction
     status := []chains.ReceiveStatus{chains.ReceiveStatus_success, chains.ReceiveStatus_failed}
 
     return types.MsgVoteOutbound{
         Creator:                           Bech32AccAddress().String(),
         CctxHash:                          GetCctxIndexFromString("sampleCctxIndex"),
         ObservedOutboundHash:              Hash().String(),
         ObservedOutboundBlockHeight:       uint64(r.Uint32()),
         ObservedOutboundGasUsed:           uint64(r.Uint32()),
         ObservedOutboundEffectiveGasPrice: sdkmath.NewInt(r.Int63()),
         ObservedOutboundEffectiveGasLimit: uint64(r.Uint32()),
         ValueReceived:                     sdkmath.NewUint(r.Uint64()),
+        // Randomly select transaction status to simulate different outcome scenarios
         Status:                            status[r.Intn(len(status))],
         OutboundChain:                     to,
         OutboundTssNonce:                  uint64(r.Uint32()),
         CoinType:                          CoinTypeFromRand(r),
+        // Randomize confirmation mode (FAST or SAFE)
         ConfirmationMode:                  ConfirmationModeFromRand(r),
     }
 }
e2e/runner/zevm.go (1)

27-43: Well-structured BTCWithdraw implementation.

The new BTCWithdraw method follows the established pattern of other withdrawal methods in the codebase and provides a clean interface for Bitcoin withdrawals through the Gateway. The implementation correctly:

  1. Accepts a Bitcoin address, amount, and revert options
  2. Encodes the Bitcoin address appropriately
  3. Calls the Gateway contract with proper parameters
  4. Returns the transaction object for further processing

Consider adding a more descriptive comment similar to other withdrawal methods for consistency.

-// BTCWithdraw calls Withdraw of Gateway with gas token on ZEVM
+// BTCWithdraw calls Withdraw of Gateway with Bitcoin token on ZEVM
e2e/e2etests/test_eth_withdraw_fast_confirmation.go (4)

29-43: Consider dynamic block intervals for fast vs. safe
The hardcoded SafeOutboundCount = 10 and FastOutboundCount = 1 seem tuned for a local environment. If block times vary or multiple tests run in parallel, consider making them configurable to ensure reliability.


49-67: Include a sanity check on tracker readiness
You're introducing a 1-block wait before retrieving the CCTX. Consider adding an explicit readiness check or shorter block wait for faster tests. Otherwise, a single block might not always be sufficient if block production is delayed.


70-99: Reusing chain parameter toggles
The pattern for disabling fast confirmation mirrors enabling it. Consider extracting the enabling/disabling logic into a helper to reduce duplication and improve clarity.


100-105: Ensure meaningful performance thresholds
Using a fixed threshold of 3 seconds might be risky if the environment is inconsistent. Consider using a margin tied to block production metrics or mocking clock times for more robust comparisons.

zetaclient/chains/bitcoin/observer/outbound.go (6)

102-108: Variable initialization
Declaring local variables from cctx.GetCurrentOutboundParam() clarifies usage. However, if you plan to add more logic around them, consider grouping them into a struct for clarity.


153-155: Add unit test coverage
Lines 153–155 are not covered by tests according to static analysis. Consider including a test scenario where res.Confirmations meets the safe threshold, ensuring this branch is tested.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 153-155: zetaclient/chains/bitcoin/observer/outbound.go#L153-L155
Added lines #L153 - L155 were not covered by tests


170-184: Posting outbound vote
The logic to skip fast confirmation eligibility if IsOutboundEligibleForFastConfirmation(msg) == false is reasonable. However, consider logging the reason for ineligibility to aid troubleshooting.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 175-176: zetaclient/chains/bitcoin/observer/outbound.go#L175-L176
Added lines #L175 - L176 were not covered by tests


[warning] 180-181: zetaclient/chains/bitcoin/observer/outbound.go#L180-L181
Added lines #L180 - L181 were not covered by tests


175-176: Add unit test coverage
Lines 175–176 related to checking outbound eligibility for fast confirmation aren’t covered by tests. Introducing a targeted test case would ensure that the skip logic is validated.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 175-176: zetaclient/chains/bitcoin/observer/outbound.go#L175-L176
Added lines #L175 - L176 were not covered by tests


180-181: Add unit test coverage
Lines 180–181, which handle errors from PostVoteOutbound, are untested per static analysis. Include a scenario where PostVoteOutbound fails to confirm robust error handling.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 180-181: zetaclient/chains/bitcoin/observer/outbound.go#L180-L181
Added lines #L180 - L181 were not covered by tests


186-226: Refactored outbound vote construction
This new function consolidates the data needed for a Bitcoin outbound vote. The usage of NewMsgVoteOutbound is clear. If you foresee adding additional fields (e.g., metadata for debugging), consider constructing a local struct and converting it into MsgVoteOutbound to maintain clarity.

zetaclient/chains/evm/observer/outbound.go (5)

146-157: Posting the outbound vote
Consider adding structured logs here for better traceability, especially before posting. If PostVoteOutbound is a frequent failure point, more logs or metrics around this call might help.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 156-156: zetaclient/chains/evm/observer/outbound.go#L156
Added line #L156 was not covered by tests


156-156: Add unit test coverage
Line 156 is uncovered by tests per static analysis. A test scenario where PostVoteOutbound fails (or returns an error) would ensure robust coverage.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 156-156: zetaclient/chains/evm/observer/outbound.go#L156
Added line #L156 was not covered by tests


162-195: newOutboundVote for EVM
Similar to the Bitcoin observer changes, constructing MsgVoteOutbound in a separate method centralizes logic. This fosters consistency and reduces duplication.


227-229: Test coverage for restricted cctx
These lines handle restricted cross-chain transactions by returning early. Ensure that you have coverage for a scenario where compliance restrictions apply, to validate the logic.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 227-229: zetaclient/chains/evm/observer/outbound.go#L227-L229
Added lines #L227 - L229 were not covered by tests


470-471: Coverage for fast confirmation
These lines enable fast confirmation checks. Please add a test scenario that targets partial confirmation or boundary conditions, ensuring coverage of the transition from unconfirmed to fast-confirmed.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 470-471: zetaclient/chains/evm/observer/outbound.go#L470-L471
Added lines #L470 - L471 were not covered by tests

zetaclient/chains/bitcoin/observer/outbound_test.go (1)

293-340: Consider standardizing default configuration values

The test suite setup provides flexibility through a functional options pattern, which is excellent. However, you might consider extracting the default values into constants for better maintainability.

+// Default values for test configuration
+const (
+    defaultLastBlock uint64 = 100
+)

 func newTestSuite(t *testing.T, opts ...func(*testSuiteConfig)) *testSuite {
     var cfg testSuiteConfig
     for _, opt := range opts {
         opt(&cfg)
     }

     chain := chains.BitcoinMainnet
     if cfg.chain != nil {
         chain = *cfg.chain
     }

     params := mocks.MockChainParams(chain.ChainId, 10)
     if cfg.ConfirmationParams != nil {
         params.ConfirmationParams = cfg.ConfirmationParams
     }

     btcClient := mocks.NewBitcoinClient(t)
-    btcClient.On("GetBlockCount", mock.Anything).Return(int64(100), nil)
+    btcClient.On("GetBlockCount", mock.Anything).Return(int64(defaultLastBlock), nil)
e2e/utils/zetacore.go (1)

46-62: Function implementation follows best practices but could benefit from enhanced documentation

The GetCCTXByInboundHash function provides a clear and concise way to retrieve a cross-chain transaction by its inbound hash. The implementation correctly handles error checking and assertion on the expected result length.

Consider enhancing the function's documentation to provide more details about its behavior, particularly in error cases:

-// GetCCTXByInboundHash gets cctx by inbound hash
+// GetCCTXByInboundHash retrieves a cross-chain transaction (CCTX) by its inbound hash.
+// It queries the client for the CCTX data associated with the provided inbound hash,
+// asserts that exactly one CCTX is returned, and returns a pointer to that CCTX.
+// The function will cause a test failure if an error occurs or if no/multiple CCTXs are found.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5041002 and 068145a.

📒 Files selected for processing (42)
  • changelog.md (1 hunks)
  • cmd/zetae2e/local/bitcoin.go (7 hunks)
  • cmd/zetae2e/local/evm.go (1 hunks)
  • cmd/zetae2e/local/local.go (1 hunks)
  • e2e/e2etests/e2etests.go (4 hunks)
  • e2e/e2etests/helpers.go (2 hunks)
  • e2e/e2etests/test_bitcoin_deposit_and_call_revert.go (0 hunks)
  • e2e/e2etests/test_bitcoin_deposit_and_withdraw_with_dust.go (0 hunks)
  • e2e/e2etests/test_bitcoin_deposit_fast_confirmation.go (2 hunks)
  • e2e/e2etests/test_bitcoin_std_deposit_and_call_revert.go (0 hunks)
  • e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_and_abort.go (0 hunks)
  • e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go (0 hunks)
  • e2e/e2etests/test_bitcoin_withdraw_fast_confirmation.go (1 hunks)
  • e2e/e2etests/test_bitcoin_withdraw_invalid_address.go (0 hunks)
  • e2e/e2etests/test_bitcoin_withdraw_legacy.go (2 hunks)
  • e2e/e2etests/test_bitcoin_withdraw_p2sh.go (2 hunks)
  • e2e/e2etests/test_bitcoin_withdraw_p2wsh.go (2 hunks)
  • e2e/e2etests/test_bitcoin_withdraw_restricted_address.go (2 hunks)
  • e2e/e2etests/test_bitcoin_withdraw_segwit.go (2 hunks)
  • e2e/e2etests/test_bitcoin_withdraw_taproot.go (2 hunks)
  • e2e/e2etests/test_crosschain_swap.go (0 hunks)
  • e2e/e2etests/test_eth_deposit_fast_confirmation.go (2 hunks)
  • e2e/e2etests/test_eth_withdraw_fast_confirmation.go (1 hunks)
  • e2e/e2etests/test_migrate_tss.go (0 hunks)
  • e2e/runner/bitcoin.go (1 hunks)
  • e2e/runner/evm.go (1 hunks)
  • e2e/runner/setup_bitcoin.go (0 hunks)
  • e2e/runner/zevm.go (2 hunks)
  • e2e/utils/zetacore.go (2 hunks)
  • testutil/sample/crosschain.go (1 hunks)
  • x/observer/types/chain_params.go (1 hunks)
  • x/observer/types/chain_params_test.go (1 hunks)
  • zetaclient/chains/base/confirmation.go (1 hunks)
  • zetaclient/chains/base/confirmation_test.go (2 hunks)
  • zetaclient/chains/base/observer.go (2 hunks)
  • zetaclient/chains/base/observer_test.go (2 hunks)
  • zetaclient/chains/bitcoin/observer/outbound.go (4 hunks)
  • zetaclient/chains/bitcoin/observer/outbound_test.go (4 hunks)
  • zetaclient/chains/evm/observer/observer_test.go (4 hunks)
  • zetaclient/chains/evm/observer/outbound.go (4 hunks)
  • zetaclient/chains/evm/observer/outbound_test.go (3 hunks)
  • zetaclient/chains/evm/signer/outbound_tracker_reporter.go (2 hunks)
💤 Files with no reviewable changes (9)
  • e2e/e2etests/test_bitcoin_std_deposit_and_call_revert.go
  • e2e/e2etests/test_bitcoin_deposit_and_withdraw_with_dust.go
  • e2e/e2etests/test_migrate_tss.go
  • e2e/e2etests/test_bitcoin_deposit_and_call_revert.go
  • e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_and_abort.go
  • e2e/e2etests/test_crosschain_swap.go
  • e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go
  • e2e/runner/setup_bitcoin.go
  • e2e/e2etests/test_bitcoin_withdraw_invalid_address.go
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.go`: Review the Go code, point out issues relative to ...

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

  • cmd/zetae2e/local/evm.go
  • x/observer/types/chain_params.go
  • e2e/runner/bitcoin.go
  • zetaclient/chains/base/confirmation.go
  • e2e/e2etests/test_bitcoin_withdraw_p2wsh.go
  • e2e/e2etests/test_bitcoin_withdraw_segwit.go
  • e2e/e2etests/test_bitcoin_withdraw_legacy.go
  • e2e/e2etests/test_bitcoin_withdraw_taproot.go
  • e2e/runner/evm.go
  • e2e/e2etests/test_bitcoin_deposit_fast_confirmation.go
  • e2e/e2etests/test_bitcoin_withdraw_fast_confirmation.go
  • x/observer/types/chain_params_test.go
  • e2e/runner/zevm.go
  • cmd/zetae2e/local/local.go
  • e2e/utils/zetacore.go
  • zetaclient/chains/base/observer_test.go
  • e2e/e2etests/helpers.go
  • zetaclient/chains/evm/signer/outbound_tracker_reporter.go
  • e2e/e2etests/test_bitcoin_withdraw_p2sh.go
  • e2e/e2etests/test_eth_withdraw_fast_confirmation.go
  • zetaclient/chains/evm/observer/observer_test.go
  • e2e/e2etests/test_eth_deposit_fast_confirmation.go
  • zetaclient/chains/base/confirmation_test.go
  • e2e/e2etests/test_bitcoin_withdraw_restricted_address.go
  • cmd/zetae2e/local/bitcoin.go
  • zetaclient/chains/evm/observer/outbound.go
  • zetaclient/chains/evm/observer/outbound_test.go
  • zetaclient/chains/bitcoin/observer/outbound.go
  • testutil/sample/crosschain.go
  • zetaclient/chains/base/observer.go
  • zetaclient/chains/bitcoin/observer/outbound_test.go
  • e2e/e2etests/e2etests.go
🪛 GitHub Check: codecov/patch
zetaclient/chains/evm/signer/outbound_tracker_reporter.go

[warning] 73-79: zetaclient/chains/evm/signer/outbound_tracker_reporter.go#L73-L79
Added lines #L73 - L79 were not covered by tests

zetaclient/chains/evm/observer/outbound.go

[warning] 156-156: zetaclient/chains/evm/observer/outbound.go#L156
Added line #L156 was not covered by tests


[warning] 227-229: zetaclient/chains/evm/observer/outbound.go#L227-L229
Added lines #L227 - L229 were not covered by tests


[warning] 470-471: zetaclient/chains/evm/observer/outbound.go#L470-L471
Added lines #L470 - L471 were not covered by tests

zetaclient/chains/bitcoin/observer/outbound.go

[warning] 153-155: zetaclient/chains/bitcoin/observer/outbound.go#L153-L155
Added lines #L153 - L155 were not covered by tests


[warning] 175-176: zetaclient/chains/bitcoin/observer/outbound.go#L175-L176
Added lines #L175 - L176 were not covered by tests


[warning] 180-181: zetaclient/chains/bitcoin/observer/outbound.go#L180-L181
Added lines #L180 - L181 were not covered by tests

🔇 Additional comments (83)
e2e/runner/bitcoin.go (2)

31-31: BTCRegnetBlockTime reduction appears correct for fast confirmation support.

The reduction of the block time from 6 seconds to 5 seconds aligns with the PR objective of supporting fast outbound confirmations for Bitcoin chains. This change will allow blocks to be generated more frequently in the local regnet environment during testing.


380-380: Update function documentation to reflect new block time.

The function documentation states "mines blocks on the local BTC chain at a rate of 1 blocks every 5 seconds" which now accurately matches the updated BTCRegnetBlockTime constant. This shows good attention to documentation consistency.

zetaclient/chains/evm/signer/outbound_tracker_reporter.go (1)

11-11: Import added correctly for crosschain keeper.

The added import provides access to the necessary functions for checking CCTX status, properly supporting the new finalization check.

e2e/e2etests/helpers.go (1)

25-32: Function signature and implementation improved for Bitcoin withdrawals.

The withdrawBTCZRC20 function has been refactored to return an Ethereum transaction type and streamline the implementation. This is a well-executed change that aligns with the PR's goal of supporting fast outbound confirmations.

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

23-23: Test case addition for fast confirmation support.

Adding the TestETHWithdrawFastConfirmationName test case to the happy path testing workflow is appropriate and aligns with the PR objectives to validate fast confirmation for Ethereum withdrawals.

x/observer/types/chain_params.go (1)

174-178: Well-implemented outbound fast confirmation check.

The IsOutboundFastConfirmationEnabled method follows a consistent pattern with the existing inbound check function. It correctly verifies that fast confirmation is properly configured by ensuring the fast count is both enabled (> 0) and provides an actual benefit (< safe count).

This method is an essential component for the fast outbound confirmation feature, allowing the system to determine when transactions are eligible for expedited processing.

e2e/runner/evm.go (1)

196-199: Bitcoin ZRC20 approval helper follows established patterns.

The addition of the ApproveBTCZRC20 method is well-designed, maintaining consistency with the existing token approval methods and adhering to the DRY principle by reusing the underlying approveZRC20 implementation.

changelog.md (1)

31-31: Well-documented feature addition.

This addition to the changelog clearly documents the new feature for outbound fast confirmation support for both EVM chain and Bitcoin chain. The entry follows the consistent format of the changelog, providing a link to the PR and a concise description.

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

305-307: Improved resource management with proper cleanup.

The change now correctly captures the return value from startBitcoinTests as a cleanup function and ensures it's called when the test completes through the use of defer. This follows the resource acquisition is initialization (RAII) pattern, ensuring Bitcoin mining resources are properly released even in error scenarios.

x/observer/types/chain_params_test.go (1)

346-361: Comprehensive test coverage for the new fast outbound confirmation functionality.

This test thoroughly validates the IsOutboundFastConfirmationEnabled method with proper test cases covering:

  1. When fast confirmation should be enabled (SafeOutboundCount > FastOutboundCount > 0)
  2. When fast confirmation should be disabled due to zero FastOutboundCount
  3. When fast confirmation should be disabled due to equal SafeOutboundCount and FastOutboundCount

The test structure aligns with existing patterns in the file and provides good coverage of the method's behavior.

e2e/e2etests/test_bitcoin_withdraw_p2wsh.go (2)

9-9: Import addition is appropriate for the enhanced transaction status validation.

The addition of the crosschaintypes import is necessary for accessing the CctxStatus_OutboundMined constant used in the transaction verification process.


21-26: Well-structured transaction execution and verification flow.

The enhanced implementation properly separates transaction execution from verification, improving test clarity and robustness. The code now:

  1. Executes the withdrawal and captures the transaction
  2. Waits for the cross-chain transaction to be mined
  3. Verifies the transaction status matches the expected outcome

This approach ensures complete end-to-end validation of the Bitcoin withdrawal process.

e2e/e2etests/test_bitcoin_withdraw_legacy.go (2)

9-9: Import addition is appropriate for the enhanced transaction status validation.

The addition of the crosschaintypes import is necessary for accessing the CctxStatus_OutboundMined constant used in the transaction verification process.


22-29: Well-structured test with clear phases and enhanced verification.

The implementation follows a clear Arrange-Act-Assert pattern with explicit comments demarcating test phases. The transaction flow is properly structured with:

  1. Execution of the withdrawal operation
  2. Waiting for the cross-chain transaction to be mined
  3. Verification of the expected transaction status

This approach enhances test readability and ensures thorough validation of the withdrawal process.

e2e/e2etests/test_bitcoin_withdraw_taproot.go (2)

9-9: Import addition is appropriate for the enhanced transaction status validation.

The addition of the crosschaintypes import is necessary for accessing the CctxStatus_OutboundMined constant used in the transaction verification process.


21-26: Well-structured transaction execution and verification flow.

The enhanced implementation properly separates transaction execution from verification, improving test clarity and robustness. The code now:

  1. Executes the withdrawal and captures the transaction
  2. Waits for the cross-chain transaction to be mined
  3. Verifies the transaction status matches the expected outcome

This approach ensures complete end-to-end validation of the Bitcoin withdrawal process, maintaining consistency with other test implementations.

zetaclient/chains/base/confirmation.go (1)

94-104:

✅ Verification successful

Well-implemented fast confirmation eligibility check with clear business logic.

The IsOutboundEligibleForFastConfirmation method is well-designed with:

  1. Appropriate chain parameter validation first
  2. Clear business logic for determining eligibility based on transaction status
  3. Comprehensive comments explaining the reasoning behind excluding non-successful statuses

The method follows the established pattern of other confirmation-related functions in the codebase and properly supports the new fast outbound confirmation feature for EVM/Bitcoin chains.

Consider adding unit tests for this method to validate its behavior under various conditions.


🏁 Script executed:

#!/bin/bash
# Check if there are tests for the new IsOutboundEligibleForFastConfirmation method

echo "Searching for test files that might contain tests for IsOutboundEligibleForFastConfirmation..."
fd "confirmation_test.go" --exec grep -l "IsOutboundEligibleForFastConfirmation" {} \;

Length of output: 332


Approval: Fast Confirmation Eligibility Logic Verified

The IsOutboundEligibleForFastConfirmation method is implemented with clear chain parameter validation and concise business logic. The presence of tests in the file zetaclient/chains/base/confirmation_test.go confirms that the feature is being vetted against various conditions. Please ensure that the test cases comprehensively cover all edge scenarios.

zetaclient/chains/evm/observer/observer_test.go (4)

395-399: Clear and structured enhancements to testSuiteConfig.

The addition of LastBlock and ConfirmationParams fields to the testSuiteConfig struct provides necessary configuration options for testing different confirmation scenarios in line with the PR objectives.


413-415: Good null-safety check for ConfirmationParams.

The code correctly checks if cfg.ConfirmationParams is not nil before assigning it to chainParams.ConfirmationParams, which is a proper defensive programming practice.


424-426: Proper initialization with OperatorAddress.

The addition of the OperatorAddress to the keys setup ensures that the test environment correctly simulates the operational context for outbound confirmations.


446-448: Appropriate conditional block for LastBlock configuration.

The code correctly checks if cfg.LastBlock > 0 before applying it, maintaining backward compatibility with existing tests while enabling new configuration capabilities.

e2e/e2etests/test_bitcoin_withdraw_p2sh.go (2)

9-9: Appropriate crosschain type import.

The addition of the crosschaintypes import is necessary for accessing the CctxStatus constants used in transaction verification.


22-27: Enhanced transaction verification flow.

This change improves the test by properly capturing the transaction result and verifying its completion status. The implementation now ensures that the Bitcoin P2SH withdrawal completes successfully by:

  1. Storing the transaction result
  2. Waiting for the transaction to be mined
  3. Verifying the final status matches the expected OutboundMined state

This aligns with the PR objective of implementing fast outbound confirmation support.

e2e/e2etests/test_bitcoin_withdraw_segwit.go (2)

9-9: Appropriate crosschain type import.

The addition of the crosschaintypes import is necessary for accessing the CctxStatus constants used in transaction verification.


21-26: Enhanced transaction verification flow.

This change improves the test by properly capturing the transaction result and verifying its completion status. The implementation now ensures that the Bitcoin SegWit withdrawal completes successfully by following the same pattern as the P2SH implementation:

  1. Storing the transaction result
  2. Waiting for the transaction to be mined
  3. Verifying the final status matches the expected OutboundMined state

The consistent implementation across different Bitcoin withdrawal types is a good practice.

e2e/runner/zevm.go (1)

8-8: Appropriate btcutil import.

The addition of the btcutil import is necessary for the new BTCWithdraw method's parameter type.

e2e/e2etests/test_bitcoin_deposit_fast_confirmation.go (4)

34-34: Parameter change improves test efficiency

Reducing SafeInboundCount from 6 to 4 decreases the test execution time from approximately 36 seconds to 20 seconds while still maintaining a sufficient interval compared to the fast confirmation time.


36-37: Good practice: Preserving existing parameters

Using values from resOldChainParams rather than hardcoded values ensures test isolation and prevents interference with other test cases that may rely on these parameters.


44-44: API consistency improvement

Replacing utils.WaitForZetaBlocks with r.WaitForBlocks(2) standardizes the block waiting mechanism across the codebase.


102-105: Well-structured test teardown with clear documentation

The selective restoration of only inbound parameters with an explanatory comment prevents interference with other tests that may depend on outbound parameters while ensuring proper test cleanup.

zetaclient/chains/base/observer_test.go (6)

5-11: Appropriate imports added for extended functionality

New imports for error handling, random number generation, and time management support the expanded test functionality.


548-551: Well-structured test setup

The test setup properly initializes the context and creates a random generator with a time-based seed for enhanced test reliability and determinism.


553-561: Comprehensive successful case test

This test case thoroughly validates the happy path for outbound vote posting, properly mocking the ZetacoreClient's expected behavior.


563-574: Proper validation error handling test

The test correctly verifies that invalid message parameters are detected and reported with appropriate error messages before making any external calls.


576-585: RPC failure handling verification

This test ensures the method propagates errors from the underlying ZetacoreClient correctly, which is crucial for maintaining reliable error reporting throughout the system.


587-596: Already voted case handling

The test validates the proper handling of the case where a vote has already been cast, ensuring no duplicate votes are submitted and no errors are returned.

zetaclient/chains/base/observer.go (4)

394-396: Code simplification improves readability

Direct field references from the message object streamline the code by eliminating unnecessary local variables, making it more concise and easier to maintain.


423-436: Well-structured function initialization with appropriate validation

The new PostVoteOutbound function properly initializes gas limits based on message status and performs basic validation to prevent unnecessary RPC calls with invalid data.


437-446: Comprehensive logging fields

The logger field setup captures all relevant information for tracing and debugging, including method name, transaction hash, nonce, coin type, confirmation mode, and ballot digest.


447-462: Robust error handling with appropriate log levels

The function implements proper error propagation and uses different log levels based on the context (error for failures, debug for already voted cases to prevent log pollution, info for successful operations).

e2e/e2etests/test_eth_deposit_fast_confirmation.go (3)

39-40: Preserving system state integrity

Using values from resOldChainParams rather than hardcoded values ensures that the test respects the current system configuration and doesn't interfere with other test cases.


47-47: Simplified block waiting implementation

The direct use of r.WaitForBlocks(2) improves code clarity by eliminating an unnecessary abstraction layer.


106-110: Selective parameter restoration prevents test interference

Restoring only the inbound confirmation parameters during teardown rather than the entire chain parameters prevents potential conflicts with other tests that may rely on outbound parameters.

e2e/e2etests/test_bitcoin_withdraw_restricted_address.go (4)

6-6: New import added appropriately

The import for chainhash from the btcsuite package is correctly added to support converting hash strings to hash objects.


33-44: Improved transaction tracking flow

The implementation now correctly stores the transaction reference and properly retrieves the cross-chain transaction status. This approach is more robust as it follows the actual transaction through the system rather than invoking the withdrawal function multiple times.


40-43: Well-structured transaction hash extraction

The extraction of the Bitcoin transaction hash from the cross-chain transaction and conversion to a proper chainhash object follows best practices.


46-47: Appropriate use of BTC RPC client

The function properly utilizes the BTC RPC client to retrieve the raw transaction details using the extracted hash.

e2e/e2etests/test_bitcoin_withdraw_fast_confirmation.go (5)

14-15: Well-documented test function

The test function includes a clear comment describing its purpose, which helps maintainers understand the test's intent.


23-41: Robust chain parameter modification

The implementation correctly retrieves the existing chain parameters, preserves the necessary values, and updates only the confirmation parameters needed for the test. This approach prevents unintended side effects on other tests.


43-63: Clear test execution and verification

The test has a clear structure with appropriate comments marking the stages of the test (ACT-1, ASSERT-1). The code properly waits for the outbound tracker submission before measuring confirmation time, ensuring accurate timing measurements.


94-99: Effective time comparison verification

The time comparison logic correctly asserts that fast confirmation is indeed faster than safe confirmation by a meaningful amount (at least one Bitcoin block time).


100-106: Proper test cleanup

The test properly restores the original chain parameters in its teardown phase, ensuring that subsequent tests aren't affected by this test's changes. The comment about not restoring the complete resOldChainParams provides valuable context for future maintainers.

e2e/e2etests/e2etests.go (4)

23-23: Consistent naming convention

The new constant TestETHWithdrawFastConfirmationName follows the established naming pattern in the codebase.


120-120: Appropriate positioning of new test

The new TestBitcoinWithdrawFastConfirmationName constant is correctly placed within the Bitcoin tests section, maintaining the code organization.


305-313: Complete test registration

The Ethereum withdrawal fast confirmation test is properly registered with appropriate descriptions and defaults. The minimum version requirement ensures it only runs on compatible versions.


906-914: Consistent test registration pattern

The Bitcoin withdrawal fast confirmation test registration follows the same pattern as other tests, providing consistent user experience.

zetaclient/chains/base/confirmation_test.go (5)

6-8: Appropriate import additions

The additions of math/rand and time imports are necessary for the new test function that uses randomization with appropriate seeding.


16-16: Import for sample package

The sample package import is correctly added to support generating test data for the new test cases.


419-474: Well-structured and comprehensive test cases

The test function Test_IsOutboundEligibleForFastConfirmation is well-designed with:

  1. Appropriate test cases covering both positive and negative scenarios
  2. Clear test case descriptions
  3. Good separation of ARRANGE, ACT, ASSERT phases
  4. Use of random data generation for increased test coverage

The test appropriately verifies the conditions under which outbound transactions are eligible for fast confirmation.


420-421: Proper random number generation

The random number generator is correctly seeded with the current time to ensure different test data on each run, while still being deterministic within a single test run.


464-465: Effective use of test utilities

The test properly uses the sample.OutboundVoteFromRand utility to generate realistic test data, and correctly modifies the status field to test the specific scenario.

e2e/e2etests/test_eth_withdraw_fast_confirmation.go (2)

16-19: Validate argument length and usage
This check ensures the test is invoked with the correct number of arguments. The approach is clean.


106-113: Restore chain parameters
The final code properly restores chain params, helping maintain test isolation. This is crucial if subsequent tests rely on the original settings.

zetaclient/chains/bitcoin/observer/outbound.go (2)

7-7: Math/big import
The addition of "math/big" is appropriate for handling large integer calculations in confirmations and amounts.


142-155: Dual confirmation mode check
The logic here neatly handles both safe and fast confirmations. Maintain caution about partial confirmations (e.g., if res.Confirmations changes mid-flow). Ensure the difference between OutboundConfirmationSafe and OutboundConfirmationFast is validated to avoid ambiguous conditions.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 153-155: zetaclient/chains/bitcoin/observer/outbound.go#L153-L155
Added lines #L153 - L155 were not covered by tests

zetaclient/chains/evm/observer/outbound.go (2)

119-126: Local variable definitions
Good practice extracting necessary fields (chainID, txHash, etc.) from the context. Improves readability and ensures you only pass around relevant data.


143-144: Graceful error handling
Returning the parse error ensures the function handles outbound event failures cleanly. This helps debugging if unexpected transaction logs occur.

zetaclient/chains/bitcoin/observer/outbound_test.go (5)

26-40: Well-structured test setup with clear scenarios

The test function is organized with a comprehensive setup for validating outbound confirmation voting behavior. The confirmParams structure initialization is clearly defined with appropriate threshold values.


36-75: Comprehensive test cases with clear expectations

The table-driven test approach provides excellent coverage of different scenarios, including both SAFE and FAST confirmation paths. Each test case has descriptive naming and clear expected outcomes.


97-139: Well-implemented test execution flow

The execution of each test case follows a clear arrangement-action-assertion pattern, providing good readability and maintainability. Mock setup is appropriately scoped to each test case.


150-151: Updated to use new test suite pattern consistently

The existing test functions have been updated to use the new test suite setup, which promotes consistency across the test file.

Also applies to: 232-233


342-348: Well-designed test suite structure

The test suite structure offers a clean composition of dependencies, making it easy to access and manipulate test components as needed.

cmd/zetae2e/local/bitcoin.go (7)

24-25: Function signature improved to support cleanup functionality

The function now returns a cleanup function, which is a good practice for proper resource management.


42-43: Appropriate test organization for new functionality

The test organization has been updated to include fast confirmation tests in the appropriate test groups, keeping the test structure clean.

Also applies to: 52-54


67-79: Proper implementation of mining control

The function now returns a stopMining function and passes it to the caller, enabling proper control of the mining process during tests.


90-91: Enhanced function signature to support cleanup

The function signature has been updated to return an additional function for stopping mining, improving resource management.


119-122: Centralized mining control for consistent test environment

This change ensures all E2E tests run with a consistent block time, which is crucial for deterministic testing. This is a significant improvement that aligns with the PR objectives.


126-133: Simplified initial fund allocation

The updated code more clearly handles sending BTC block rewards to the deployer address as initial funds, improving code readability.


145-146: Updated return statement for consistent interface

The function return statement now includes the new stopMining function, ensuring consistency with the updated function signature.

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

21-21: Test function renamed to better reflect its purpose

The function name has been updated from Test_IsOutboundProcessed to Test_VoteOutboundIfConfirmed, which better reflects its focus on voting behavior based on confirmation status.


46-61: Updated test case to match new function behavior

The test description and expectations have been adjusted to accurately reflect that the function should post a vote and return false if outbound is processed, which aligns with the PR objectives.


77-92: Added test case for fast confirmation eligibility

This new test case specifically verifies the behavior when an outbound transaction is not eligible for fast confirmation, providing good coverage for the new functionality.


95-95: Test function renamed for consistency

The function name update maintains consistency with the other renamed test functions, ensuring a cohesive test suite.

@lumtis
Copy link
Member

lumtis commented Mar 5, 2025

Let's keep it out of the release for now

Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's chat about the importance of this feature.

I'm not sure how it would benefit users in general, but I can see it being useful in a few rare situations where we need to perform something in ZEVM after confirming an outbound.

Let me know what you think. cc @lumtis

client crosschaintypes.QueryClient,
chainID int64,
nonce uint64,
hashCount int,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this hashCount param?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hashCount > 1 can happen on outbound replacement (gas price increase), so I wanted to make it general.

@lumtis
Copy link
Member

lumtis commented Mar 6, 2025

Let's chat about the importance of this feature.

I'm not sure how it would benefit users in general, but I can see it being useful in a few rare situations where we need to perform something in ZEVM after confirming an outbound.

Let me know what you think. cc @lumtis

Exactly, this has benefits once you have logic to handle response from the cctx.

There will be benefits once we integrate #2966, user will have funds refunded faster. Although this feature is mostly benefitial for crosschain call that doesn't concern fast observation for now.
Even in the future, with a hook like onAcknowledgement the fast observation might be disable because you couldn't recover from double spend.

In general the benefits will be minimal in all cases. If this PR is not too complex let's still move forward and merge it, you can disable the fast move by setting the same value as safe.

@ws4charlie ws4charlie requested a review from swift1337 March 6, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli CONSENSUS_BREAKING_ACK Acknowledge a consensus breaking change feature:protocol Feature extending the capability of the protocol nosec zetaclient Issues related to ZetaClient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants