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

test(e2e): improve E2E reliability for tests on live network #3061

Merged
merged 8 commits into from
Oct 30, 2024

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Oct 29, 2024

Description

  • Reduce gas limit used for withdrawAndCall
  • Use random string for the testDapp

Current test that interacts with TestDappV2 during withdrawAndCall tests specify 1M as gas limit.
This makes the cost of tx very expensive on live networks. This PR reduces this number to a smaller value sufficient to run the tests.

The random string for payload allow having tests that have no shared context between each other and therefore run those independently

Summary by CodeRabbit

  • New Features

    • Updated gas limit settings for improved performance.
    • Renamed method for clarity, enhancing user understanding of its functionality.
  • Bug Fixes

    • Adjusted method logic to ensure continued functionality with new gas limits.

@lumtis lumtis added no-changelog Skip changelog CI check V2_TESTS Run make start-v2-test labels Oct 29, 2024
Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces modifications to the e2e/runner/v2_zevm.go file, primarily focusing on the gas limit configuration and renaming of a method. The gas limit variable is updated from 1000000 to 250000, affecting method calls utilizing this variable. The method V2ETHWithdrawAndCall is renamed to V2ETHWithdrawAndArbitraryCall to better reflect its functionality. Additionally, comments have been adjusted for clarity, while the logic for gas limits in related methods is maintained, with a temporary increase to 10000000 for specific calls.

Changes

File Change Summary
e2e/runner/v2_zevm.go - Updated gas limit from 1000000 to 250000.
- Renamed method V2ETHWithdrawAndCall to V2ETHWithdrawAndArbitraryCall.
- Adjusted comments for clarity in line with new naming conventions.
- Maintained gas limit logic in V2ERC20WithdrawAndArbitraryCall and V2ERC20WithdrawAndCall, with a temporary increase to 10000000 for these calls.

Possibly related PRs

Suggested reviewers

  • skosito
  • kingpinXD
  • ws4charlie
  • brewmaster012
  • fbac
  • swift1337

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai 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.

@lumtis lumtis marked this pull request as ready for review October 29, 2024 14:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
e2e/runner/v2_zevm.go (1)

Line range hint 134-146: Consider refactoring gas limit management.

The temporary gas limit increase to 10M in V2ERC20WithdrawAndArbitraryCall and V2ERC20WithdrawAndCall suggests these operations require significantly more gas. Consider:

  1. Document why these specific operations need 40x more gas than the default
  2. Extract the temporary gas limit modification into a helper function
func withTemporaryGasLimit(r *E2ERunner, tempLimit uint64, fn func() (*ethtypes.Transaction, error)) (*ethtypes.Transaction, error) {
    previousLimit := r.ZEVMAuth.GasLimit
    r.ZEVMAuth.GasLimit = tempLimit
    defer func() {
        r.ZEVMAuth.GasLimit = previousLimit
    }()
    return fn()
}

Usage example:

tx, err := withTemporaryGasLimit(r, 10000000, func() (*ethtypes.Transaction, error) {
    return r.GatewayZEVM.WithdrawAndCall0(
        r.ZEVMAuth,
        receiver.Bytes(),
        amount,
        r.ERC20ZRC20Addr,
        payload,
        gatewayzevm.CallOptions{GasLimit: gasLimit, IsArbitraryCall: true},
        revertOptions,
    )
})

Also applies to: 169-181

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d9ee4f3 and 77d5a57.

📒 Files selected for processing (1)
  • e2e/runner/v2_zevm.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
e2e/runner/v2_zevm.go (1)

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

🔇 Additional comments (2)
e2e/runner/v2_zevm.go (2)

Line range hint 34-52: Well-structured method renaming for clarity.

The renaming from V2ETHWithdrawAndCall to V2ETHWithdrawAndArbitraryCall better reflects the method's purpose and aligns with the IsArbitraryCall: true parameter.


14-14: Document the gas limit rationale and verify sufficiency.

While reducing the gas limit from 1M to 250K aligns with the goal of optimizing costs, please add a comment explaining:

  1. Why 250K was chosen as the optimal value
  2. What operations this limit is expected to cover
✅ Verification successful

Based on the search results, I can now verify the gas limit change. Let me analyze the key findings:

  1. The gas limit of 250,000 is used consistently in ZEVM-related operations:

    • In e2e/runner/v2_zevm.go: gasLimit = big.NewInt(250000)
    • Used in various V2 protocol tests for deposits, withdrawals, and arbitrary calls
  2. This value aligns with production gas limits seen in the codebase:

    • EVM transfers use 21,000 (zetaclient/chains/evm/constant.go)
    • ZRC20 operations use between 100,000 to 400,000 gas
    • Complex operations like message passing use up to 400,000 gas
  3. The value is well within safe bounds:

    • Above minimum (100,000) defined in zetaclient/chains/evm/signer/gas.go
    • Below maximum (1,000,000) defined in same file
    • Sufficient for standard cross-chain operations

Gas limit of 250K is appropriate and well-documented through usage patterns.

The reduction from 1M to 250K is justified as:

  1. It's above the minimum required for complex operations
  2. Provides sufficient headroom for standard transactions
  3. Aligns with production gas limits seen across the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential gas-related issues or discussions in the codebase
rg -i "gas.*limit|insufficient.*gas" --type go

Length of output: 110723

Copy link

!!!WARNING!!!
nosec detected in the following files: e2e/e2etests/helpers.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 Oct 29, 2024
@lumtis
Copy link
Member Author

lumtis commented Oct 29, 2024

@fbac pushed some further changes if you want to take a look

@lumtis lumtis changed the title test(e2e): reduce gas limit used for withdraw and call tests test(e2e): improve E2E reliability for tests on live network Oct 29, 2024
@lumtis lumtis added this pull request to the merge queue Oct 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 30, 2024
@lumtis lumtis added this pull request to the merge queue Oct 30, 2024
@lumtis lumtis removed this pull request from the merge queue due to a manual request Oct 30, 2024
Copy link

codecov bot commented Oct 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.33%. Comparing base (d9ee4f3) to head (14c7e83).
Report is 9 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3061      +/-   ##
===========================================
- Coverage    64.47%   64.33%   -0.14%     
===========================================
  Files          412      419       +7     
  Lines        28985    29102     +117     
===========================================
+ Hits         18687    18723      +36     
- Misses        9515     9597      +82     
+ Partials       783      782       -1     

see 15 files with indirect coverage changes

@lumtis lumtis enabled auto-merge October 30, 2024 13:41
@lumtis lumtis added this pull request to the merge queue Oct 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 30, 2024
@lumtis lumtis added this pull request to the merge queue Oct 30, 2024
Merged via the queue into develop with commit 6ef5c57 Oct 30, 2024
35 checks passed
@lumtis lumtis deleted the test/e2e-reduce-gas-limit branch October 30, 2024 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli no-changelog Skip changelog CI check nosec V2_TESTS Run make start-v2-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants