Skip to content

test: allow custom gasLimit in ERC20 withdrawAndCall E2E test#3972

Merged
ws4charlie merged 7 commits intodevelopfrom
e2e-add-gasLimit-argument-to-erc20-WaC
Jun 13, 2025
Merged

test: allow custom gasLimit in ERC20 withdrawAndCall E2E test#3972
ws4charlie merged 7 commits intodevelopfrom
e2e-add-gasLimit-argument-to-erc20-WaC

Conversation

@ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Jun 11, 2025

Description

The eth_withdraw_and_call takes two arguments amount and gasLimit. Similarly, use same arguments for the erc20_withdraw_and_call E2E test so that they can be adjusted in the CI nightly tests.

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

  • Tests
    • Updated ERC20 withdrawal tests to accept a customizable gas limit parameter, allowing greater flexibility when running end-to-end scenarios involving contract calls.
  • Chores
    • Improved test parameter handling for ERC20 withdrawal and contract call operations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 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 change introduces a configurable gas limit argument to three ERC20 withdrawal end-to-end tests. The corresponding test functions are updated to accept and process the new gas limit parameter. The ZEVM runner's ERC20WithdrawAndCall method is refactored to accept an explicit gas limit, and the default gas limit variable is renamed for clarity. No other logic or control flow is altered.

Changes

File(s) Change Summary
e2e/e2etests/e2etests.go Added a gas limit argument (default "250000") to three ERC20 withdrawal test definitions.
e2e/e2etests/test_erc20_withdraw_and_call.go Updated test to require and parse a second argument for gas limit; passed to method call.
e2e/e2etests/test_erc20_withdraw_and_call_no_message.go Updated test to require and parse a second argument for gas limit; passed to method call.
e2e/e2etests/test_erc20_withdraw_revert_and_abort.go Updated test to require and parse a second argument for gas limit; passed to method call.
e2e/runner/zevm.go Renamed gasLimit to defaultGasLimit; updated references. Modified ERC20WithdrawAndCall to accept a gas limit parameter.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner
    participant ZEVMRunner
    participant ZEVMGateway

    TestRunner->>ZEVMRunner: TestERC20WithdrawAndCall(amount, gasLimit)
    ZEVMRunner->>ZEVMGateway: ERC20WithdrawAndCall(receiver, amount, payload, revertOptions, gasLimit)
    ZEVMGateway-->>ZEVMRunner: Transaction result
    ZEVMRunner-->>TestRunner: Assertion and result
Loading

This diagram illustrates the updated flow where the test runner passes both the amount and the gas limit to the ZEVM runner, which then forwards the gas limit to the ZEVM gateway during the withdrawal and call operation.


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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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 added test Tests related chain:evm labels Jun 11, 2025
@ws4charlie ws4charlie marked this pull request as ready for review June 11, 2025 17:23
@ws4charlie ws4charlie requested a review from a team as a code owner June 11, 2025 17:23
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
e2e/runner/zevm.go (1)

225-233: ⚠️ Potential issue

Gracefully handle nil or zero gasLimit parameter

ERC20WithdrawAndCall now trusts external callers to pass a non-nil, sensible gasLimit.
Make the API fool-proof by falling back to the default when the argument is nil or zero:

 func (r *E2ERunner) ERC20WithdrawAndCall(
   …
   gasLimit *big.Int,
 ) *ethtypes.Transaction {
-  // this function take more gas than default 500k
+  if gasLimit == nil || gasLimit.Sign() == 0 {
+      gasLimit = newDefaultGasLimit()
+  }
   // this function take more gas than default 500k

The same guard would be useful in ETHWithdrawAndCall.

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

16-26: Duplicate validation logic

Same gasLimit sanity check as suggested for TestERC20WithdrawAndCall should be added here to keep the tests consistent.

e2e/e2etests/test_erc20_withdraw_revert_and_abort.go (1)

17-22: Validate gasLimit input

Apply the same range validation to avoid flaky abort tests caused by malformed CLI arguments.

🧹 Nitpick comments (3)
e2e/runner/zevm.go (1)

201-208: Comment is outdated – “default 500k” vs 250 000

The comment states “default 500k” while the code uses defaultGasLimit (250 000).
Update the remark to avoid confusion for future maintainers.

e2e/e2etests/test_erc20_withdraw_and_call.go (1)

16-26: Consider validating numeric range of gasLimit argument

require.Len ensures presence, but an out-of-range value (e.g., negative or extremely big) will only surface at execution time. A quick sanity check prevents wasted CI cycles:

require.True(r, gasLimit.Sign() > 0 && gasLimit.Uint64() <= 15_000_000,
	"gasLimit must be between 1 and 15M, got %s", gasLimit)
e2e/e2etests/e2etests.go (1)

490-493: Argument description can be clearer

To align wording with the ETH equivalents (lines 359-370) consider:

- {Description: "gas limit for withdraw and call", …}
+ {Description: "gas limit (ZEVM execution)", …}

Minor, but improves UX for CLI users who scroll through --help.

Also applies to: 500-502, 525-527

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d69ef1 and b7115c3.

📒 Files selected for processing (5)
  • e2e/e2etests/e2etests.go (3 hunks)
  • e2e/e2etests/test_erc20_withdraw_and_call.go (3 hunks)
  • e2e/e2etests/test_erc20_withdraw_and_call_no_message.go (3 hunks)
  • e2e/e2etests/test_erc20_withdraw_revert_and_abort.go (2 hunks)
  • e2e/runner/zevm.go (8 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.

  • e2e/e2etests/test_erc20_withdraw_revert_and_abort.go
  • e2e/e2etests/test_erc20_withdraw_and_call_no_message.go
  • e2e/e2etests/test_erc20_withdraw_and_call.go
  • e2e/e2etests/e2etests.go
  • e2e/runner/zevm.go
🧬 Code Graph Analysis (4)
e2e/e2etests/test_erc20_withdraw_revert_and_abort.go (1)
e2e/utils/parsing.go (1)
  • ParseBigInt (27-32)
e2e/e2etests/test_erc20_withdraw_and_call_no_message.go (1)
e2e/utils/parsing.go (1)
  • ParseBigInt (27-32)
e2e/e2etests/test_erc20_withdraw_and_call.go (1)
e2e/utils/parsing.go (1)
  • ParseBigInt (27-32)
e2e/runner/zevm.go (1)
e2e/contracts/gatewayzevmcaller/GatewayZEVMCaller.go (1)
  • CallOptions (33-36)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: lint
  • GitHub Check: gosec
  • GitHub Check: build-and-test
  • GitHub Check: build-zetanode
  • GitHub Check: analyze (go)
  • GitHub Check: build
🔇 Additional comments (1)
e2e/runner/zevm.go (1)

117-118: Use fresh instances instead of sharing defaultGasLimit

Even if you keep the global constant pointer, each of these call-sites should defensively clone the value:

- gatewayzevm.CallOptions{GasLimit: defaultGasLimit, IsArbitraryCall: true},
+ gatewayzevm.CallOptions{GasLimit: new(big.Int).Set(defaultGasLimit), IsArbitraryCall: true},

Otherwise any unexpected mutation (see previous comment) propagates to all transactions.

Also applies to: 165-168, 215-216, 264-265, 284-285, 307-308

@ws4charlie ws4charlie enabled auto-merge June 12, 2025 17:30
@ws4charlie ws4charlie requested a review from lumtis June 12, 2025 17:33
@ws4charlie ws4charlie added this pull request to the merge queue Jun 13, 2025
Merged via the queue into develop with commit 4a43462 Jun 13, 2025
47 checks passed
@ws4charlie ws4charlie deleted the e2e-add-gasLimit-argument-to-erc20-WaC branch June 13, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chain:evm test Tests related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants