Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zetaclient): tolerate priorityFee > gasFee #2955

Merged
merged 4 commits into from
Oct 3, 2024

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Oct 2, 2024

Description

Cherry pick changes from #2950 and add one additional comment

Closes: #2951

Summary by CodeRabbit

  • New Features

    • Enhanced gas pricing logic to log warnings instead of returning errors when gasPrice is less than priorityFee.
    • Adjusted handling of gas values in EIP-1559 transactions for improved user experience.
  • Bug Fixes

    • Updated test cases to reflect new gas pricing behavior, ensuring accurate validation of gas parameters.
  • Style

    • Minor formatting adjustments in test cases for improved readability.

@lumtis lumtis added the no-changelog Skip changelog CI check label Oct 2, 2024
Copy link
Contributor

coderabbitai bot commented Oct 2, 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

The changes involve updates to the gasFromCCTX function in the signer package, modifying how it processes the relationship between gasPrice and priorityFee. Instead of returning an error when gasPrice is less than priorityFee, it now logs a warning and adjusts priorityFee to match gasPrice. The gas_test.go file reflects this logic change by updating the corresponding test case to validate the new behavior. Additional logging and comments were added for clarity, while the validation logic for gas limits remains unchanged.

Changes

File Path Change Summary
zetaclient/chains/evm/signer/gas.go Modified gasFromCCTX to log a warning and set priorityFee to gasPrice when gasPrice < priorityFee. Added logging for initial and adjusted values.
zetaclient/chains/evm/signer/gas_test.go Updated TestGasFromCCTX to validate new behavior where gas price is less than priority fee, asserting expected gas values instead of expecting an error. Minor formatting adjustments made.

Assessment against linked issues

Objective Addressed Explanation
Backport priorityFee fix (#2951)

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.

Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.40%. Comparing base (fce09b2) to head (484f62a).
Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2955   +/-   ##
========================================
  Coverage    66.39%   66.40%           
========================================
  Files          389      389           
  Lines        21758    21762    +4     
========================================
+ Hits         14447    14451    +4     
  Misses        6584     6584           
  Partials       727      727           
Files with missing lines Coverage Δ
zetaclient/chains/evm/signer/gas.go 84.12% <100.00%> (+1.07%) ⬆️

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 and nitpick comments (2)
zetaclient/chains/evm/signer/gas_test.go (1)

101-110: Approve changes with a minor suggestion for improvement.

The new test case effectively covers the scenario where gasPrice is less than priorityFee, aligning with the PR objective. The assertion correctly validates that the priorityFee is adjusted to match the gasPrice when it exceeds it.

To enhance clarity, consider adding a comment explaining the expected behavior:

 		{
 			name: "gasPrice is less than priorityFee",
 			cctx: makeCCTX(123_000, gwei(4).String(), gwei(5).String()),
+			// Expected behavior: priorityFee should be adjusted to match gasPrice
 			assert: func(t *testing.T, g Gas) {
 				assert.False(t, g.isLegacy())
 				assertGasEquals(t, Gas{
 					Limit:       123_000,
 					Price:       gwei(4),
 					PriorityFee: gwei(4),
 				}, g)
 			},
 		},

This addition would provide immediate context for the test's purpose and expected outcome.

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

103-103: Correct Typographical Error in Comment

There is a typographical error in the comment. The word "help" should be "helps" to ensure proper subject-verb agreement.

Apply this correction:

-// the gas stability pool mechanism help to mitigate this issue
+// the gas stability pool mechanism helps to mitigate this issue
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5d981aa and 17b201d.

📒 Files selected for processing (2)
  • zetaclient/chains/evm/signer/gas.go (1 hunks)
  • zetaclient/chains/evm/signer/gas_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
zetaclient/chains/evm/signer/gas.go (1)

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

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

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

🔇 Additional comments (1)
zetaclient/chains/evm/signer/gas.go (1)

95-104: Ensure Transaction Validity When Adjusting priorityFee

Adjusting priorityFee to match gasPrice prevents transaction invalidation due to priorityFee exceeding gasPrice. However, there is a potential scenario where the adjusted priorityFee might not cover the baseFee, leading to transaction failure. Consider implementing additional checks to ensure that priorityFee is sufficient to cover the baseFee, or provide fallback mechanisms to handle such cases gracefully.

To assess the impact, you could verify whether the priorityFee meets the minimum requirements using the following script:

✅ Verification successful

Transaction Validity Confirmation

After thorough analysis, it is confirmed that priorityFee adjustments appropriately cover the baseFee, as baseFee is consistently zero across all relevant transactions. No additional checks or fallback mechanisms are required at this time.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that adjusted priorityFee covers the baseFee.

# Expected: There should be no instances where priorityFee is less than baseFee.

# Extract baseFee from relevant transactions
rg --type go 'baseFee.*' -A 3

# Find all occurences where priorityFee may be insufficient
rg --type go 'priorityFee =.*gasPrice' -A 5

Length of output: 37493

zetaclient/chains/evm/signer/gas.go Outdated Show resolved Hide resolved
zetaclient/chains/evm/signer/gas.go Outdated Show resolved Hide resolved
@lumtis lumtis enabled auto-merge October 3, 2024 08:11
@lumtis lumtis added this pull request to the merge queue Oct 3, 2024
Merged via the queue into develop with commit 49d641b Oct 3, 2024
35 checks passed
@lumtis lumtis deleted the port/priority-fee-check-fix branch October 3, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backport priorityFee fix
3 participants