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(zetaclient): disable EIP-1559 [backport] #3237

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

swift1337
Copy link
Contributor

@swift1337 swift1337 commented Dec 3, 2024

Backport of #3222

Summary by CodeRabbit

  • Bug Fixes

    • Skipped verification of Ethereum transaction receipt type during withdrawal due to an identified issue.
    • Added logging for gas limit adjustments to enhance visibility on minimum and maximum thresholds.
  • New Features

    • Enhanced clarity in the priorityFeeConfig struct with comments indicating support for EIP-1559.
  • Tests

    • Added a new test case for signing dynamic fee transactions, which is currently skipped due to an existing issue.
  • Documentation

    • Improved comments and logging throughout the codebase for better understanding and tracking.

Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several modifications across multiple files. Key changes include the commenting out of Ethereum transaction receipt verification in the TestEtherWithdraw function, updates to the priorityFeeConfig struct in the observer, and enhancements in logging and documentation within the gas handling and signing processes. A new test case for dynamic fee signing has been added but is currently skipped due to an existing issue. Overall, the changes focus on refining existing functionality, improving clarity, and addressing specific issues without altering the fundamental control flow.

Changes

File Path Change Summary
e2e/e2etests/test_eth_withdraw.go Removed verification of Ethereum transaction receipt type in TestEtherWithdraw; commented out mustFetchEthReceipt function, marked as unused.
zetaclient/chains/evm/observer/observer.go Updated priorityFeeConfig struct to include a new supported field and added comments for clarity regarding the checked field.
zetaclient/chains/evm/signer/gas.go Added //nolint:unused directive above isLegacy method; enhanced logging in gasFromCCTX for gas limit adjustments; updated comments regarding gas price handling.
zetaclient/chains/evm/signer/sign_test.go Added a new skipped test case for SignOutbound to verify dynamic fee signing; existing tests remain unchanged.
zetaclient/chains/evm/signer/signer.go Modified newTx function signature to remove chainID parameter; commented out dynamic fee transaction creation logic; enhanced logging in Sign method to include TSS signer public key.

Possibly related PRs

Suggested labels

breaking:cli, no-changelog, UPGRADE_LIGHT_TESTS

Suggested reviewers

  • fbac
  • kingpinXD
  • ws4charlie
  • lumtis
  • skosito
  • brewmaster012

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.

@swift1337 swift1337 added the no-changelog Skip changelog CI check label Dec 3, 2024
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.80%. Comparing base (f10ae08) to head (bf70bb0).
Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3237      +/-   ##
===========================================
- Coverage    61.81%   61.80%   -0.02%     
===========================================
  Files          431      431              
  Lines        30759    30747      -12     
===========================================
- Hits         19015    19003      -12     
  Misses       10886    10886              
  Partials       858      858              
Files with missing lines Coverage Δ
zetaclient/chains/evm/observer/observer.go 69.59% <ø> (ø)
zetaclient/chains/evm/signer/gas.go 86.30% <ø> (ø)
zetaclient/chains/evm/signer/signer.go 44.38% <100.00%> (-1.73%) ⬇️

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 (4)
e2e/e2etests/test_eth_withdraw.go (2)

42-44: Consider using feature flags instead of commented code.

Rather than commenting out the EIP-1559 verification code, consider implementing a feature flag to control this behavior. This would make it easier to enable/disable the feature and maintain test coverage.

-	//Skipped due to https://github.com/zeta-chain/node/issues/3221
-	//withdrawalReceipt := mustFetchEthReceipt(r, cctx)
-	//require.Equal(r, uint8(ethtypes.DynamicFeeTxType), withdrawalReceipt.Type, "receipt type mismatch")
+	if config.IsEIP1559Enabled() {
+		withdrawalReceipt := mustFetchEthReceipt(r, cctx)
+		require.Equal(r, uint8(ethtypes.DynamicFeeTxType), withdrawalReceipt.Type, "receipt type mismatch")
+	}

49-49: Document the temporary nature of the nolint directive.

The nolint:unused directive is tied to issue #3221. Consider adding a TODO comment to remove this directive once the issue is resolved.

-// nolint:unused // https://github.com/zeta-chain/node/issues/3221
+// TODO: Remove nolint directive once https://github.com/zeta-chain/node/issues/3221 is resolved
+// nolint:unused // temporary: https://github.com/zeta-chain/node/issues/3221
zetaclient/chains/evm/signer/gas.go (1)

60-61: Document the method's importance despite being temporarily unused.

While the method is currently unused due to EIP-1559 being disabled, it's a crucial part of the gas handling logic. Consider adding documentation about when this method would be re-enabled.

-//nolint:unused // https://github.com/zeta-chain/node/issues/3221
+// isLegacy determines whether to use legacy transaction format.
+// Currently unused due to EIP-1559 being disabled (https://github.com/zeta-chain/node/issues/3221).
+// Will be re-enabled when EIP-1559 support is restored.
+//nolint:unused // temporary: https://github.com/zeta-chain/node/issues/3221
zetaclient/chains/evm/signer/signer.go (1)

222-222: Consider documenting the ignored chainID parameter

The chainID parameter is now ignored (replaced with _), but this change might not be immediately clear to other developers.

Add a comment explaining why chainID is ignored:

-	_ *big.Int,
+	// chainID is ignored as we're using legacy transactions only
+	_ *big.Int,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f10ae08 and bf70bb0.

📒 Files selected for processing (5)
  • e2e/e2etests/test_eth_withdraw.go (1 hunks)
  • zetaclient/chains/evm/observer/observer.go (1 hunks)
  • zetaclient/chains/evm/signer/gas.go (1 hunks)
  • zetaclient/chains/evm/signer/sign_test.go (1 hunks)
  • zetaclient/chains/evm/signer/signer.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • zetaclient/chains/evm/signer/sign_test.go
🧰 Additional context used
📓 Path-based instructions (4)
e2e/e2etests/test_eth_withdraw.go (1)

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

zetaclient/chains/evm/observer/observer.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.go (1)

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

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

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

🔇 Additional comments (2)
zetaclient/chains/evm/observer/observer.go (1)

56-61: LGTM! Clear and informative documentation.

The added documentation for the priorityFeeConfig struct fields clearly explains their purpose and caching behavior, which is essential for understanding the EIP-1559 support detection mechanism.

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

233-254: Verify impact of disabling EIP-1559 support

The code now exclusively uses legacy transactions by commenting out the dynamic fee transaction logic. While this aligns with the PR objective to disable EIP-1559, we should ensure this doesn't affect chains that might require EIP-1559 transactions.

Let's verify if any connected chains require EIP-1559:

Additionally, consider:

  1. Adding a TODO comment with the issue link
  2. Making the code change more maintainable for future re-enablement

Consider this refactor to improve maintainability:

-// https://github.com/zeta-chain/node/issues/3221
-//if gas.isLegacy() {
+// TODO: EIP-1559 support temporarily disabled
+// See: https://github.com/zeta-chain/node/issues/3221
+const eip1559Enabled = false
+
+if eip1559Enabled && !gas.isLegacy() {
+    return ethtypes.NewTx(&ethtypes.DynamicFeeTx{
+        ChainID:   chainID,
+        To:        &to,
+        Value:     amount,
+        Data:      data,
+        GasFeeCap: gas.Price,
+        GasTipCap: gas.PriorityFee,
+        Gas:       gas.Limit,
+        Nonce:     nonce,
+    }), nil
+}

return ethtypes.NewTx(&ethtypes.LegacyTx{
    To:       &to,
    Value:    amount,
    Data:     data,
    GasPrice: gas.Price,
    Gas:      gas.Limit,
    Nonce:    nonce,
}), nil
✅ Verification successful

EIP-1559 disablement appears safe for current chain configurations

Based on the verification results:

  • The only chain configuration referencing Ethereum (in x/observer/types/chain_params.go) doesn't specify EIP-1559 requirements
  • Tests related to DynamicFeeTx are already skipped with reference to the same issue (Gas pricing: ensure priorityFee < gasFee [EIP-1559] #3221)
  • The isLegacy() function is marked as unused with the same issue reference

The code change aligns with a coordinated effort to disable EIP-1559 across the codebase. The refactoring suggestion in the review would indeed improve maintainability, but the current implementation is acceptable given the temporary nature of the change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for EIP-1559 requirements in chain configurations
fd -t f "chain.*\.go" | xargs rg -A 5 "ChainId.*(?:Ethereum|ETH)"

# Check for any existing dynamic fee transaction usage
rg -A 5 "DynamicFeeTx"

Length of output: 4233

@lumtis lumtis added the UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light label Dec 4, 2024
@lumtis lumtis added this pull request to the merge queue Dec 5, 2024
Merged via the queue into develop with commit 12beccd Dec 5, 2024
48 of 53 checks passed
@lumtis lumtis deleted the backport/feat/disable-eip-1559 branch December 5, 2024 09:31
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 UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants