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 #3222

Open
wants to merge 1 commit into
base: release/v23
Choose a base branch
from

Conversation

swift1337
Copy link
Contributor

@swift1337 swift1337 commented Nov 26, 2024

Related:

Summary by CodeRabbit

  • New Features
    • Enhanced logging for the signing process, now including the public key used for signing.
  • Bug Fixes
    • Skipped a test case for signing dynamic fee transactions due to an existing issue.
  • Refactor
    • Simplified transaction creation logic to focus solely on legacy transactions, removing dynamic fee handling.

@swift1337 swift1337 added the no-changelog Skip changelog CI check label Nov 26, 2024
@swift1337 swift1337 self-assigned this Nov 26, 2024
Copy link
Contributor

coderabbitai bot commented Nov 26, 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

The pull request introduces several changes across three files related to transaction signing and gas handling in the Ethereum Virtual Machine (EVM) context. Key modifications include the addition of a linting directive to the Gas struct, the skipping of a specific test case in the sign_test.go file, and a simplification of the newTx function in signer.go, which now focuses solely on legacy transactions by removing dynamic fee transaction handling. The overall structure and logic of existing functionalities remain intact.

Changes

File Path Change Summary
zetaclient/chains/evm/signer/gas.go Added //nolint:unused directive above the isLegacy method to exempt it from linting checks.
zetaclient/chains/evm/signer/sign_test.go Added t.Skip to the SignOutbound - should successfully sign DynamicFeeTx test case.
zetaclient/chains/evm/signer/signer.go Removed chainID parameter from newTx function, simplified transaction creation to focus on legacy transactions. Enhanced logging in the Sign method.

Possibly related PRs

  • fix(zetaclient): tolerate priorityFee > gasFee #2955: This PR modifies the gasFromCCTX function in the gas.go file, which is directly related to the Gas struct mentioned in the main PR. Both PRs involve changes to gas handling logic, specifically regarding the relationship between gasPrice and priorityFee.
  • test: fix evm signer instability #3133: This PR updates the sign_test.go file, which is relevant because it involves testing the Signer functionality, similar to the changes made in the main PR regarding the Gas struct and its methods.
  • fix(zetaclient): orchestrator: signer resolution #3139: This PR also modifies the signer.go file, which is directly related to the main PR's changes in the Gas struct and its methods, focusing on the handling of Ethereum-related addresses and their logging.

Suggested labels

breaking:cli

Suggested reviewers

  • kingpinXD
  • fbac
  • 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.

@gartnera
Copy link
Member

Shouldn't the base branch be v23?

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 (5)
zetaclient/chains/evm/signer/gas.go (3)

Line range hint 11-12: Consider making gas limits configurable

The minGasLimit and maxGasLimit are hardcoded constants. Consider making these configurable to allow for chain-specific adjustments and easier updates.

-const (
-	minGasLimit = 100_000
-	maxGasLimit = 1_000_000
-)
+type GasConfig struct {
+	MinGasLimit uint64
+	MaxGasLimit uint64
+}

Line range hint 17-29: Consider documenting the EIP-1559 removal strategy

The current code comments extensively document EIP-1559 support, but the implementation is being disabled. Consider updating this documentation to:

  1. Explain why EIP-1559 is being disabled
  2. Document the transition strategy
  3. Clarify how legacy transactions will be handled going forward

EIP-1559 code is already disabled, but priority fee handling should be removed

The code shows that EIP-1559 transaction creation (DynamicFeeTx) is already commented out in zetaclient/chains/evm/signer/signer.go, and only legacy transactions are being created. However, the priority fee handling code in the reviewed file is now redundant since it's not being used in transaction creation. This code should be simplified to only handle legacy gas pricing.

  • Remove priority fee handling in zetaclient/chains/evm/signer/gas.go since it's not used in the legacy transaction creation
  • Consider removing the PriorityFee field from the Gas struct if it's not needed elsewhere
🔗 Analysis chain

Line range hint 92-106: Review priority fee handling for EIP-1559 removal

The code still handles priority fees and includes logic for adjusting them. If EIP-1559 is being disabled, this section might need to be simplified to handle only legacy gas pricing.

Let's verify the transaction creation flow:


Let me search for transaction creation and EIP-1559 related code to verify the concern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for transaction creation code to verify how gas parameters are used
echo "Searching for transaction creation patterns..."
ast-grep --pattern 'func newTx($$$) {
  $$$
}'

# Search for priority fee usage
echo "Searching for priority fee usage..."
rg -A 5 "GasPriorityFee|priorityFee"

Length of output: 65387


Script:

#!/bin/bash
# Search for transaction creation and EIP-1559 related code
echo "Searching for transaction creation and EIP-1559 related code..."
rg -A 10 "NewTx|NewTransaction|NewDynamicFeeTx" zetaclient/chains/evm/

# Search for gas price and priority fee usage in transaction creation
echo "Searching for gas price and priority fee usage in transaction creation..."
ast-grep --pattern 'func $_($$) {
  $$$
  NewTx($$$)
  $$$
}'

Length of output: 2470

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

233-234: Add documentation explaining EIP-1559 disablement

While the issue link provides context, it would be beneficial to add a detailed comment explaining why EIP-1559 is being disabled and any implications this might have on gas optimization.

 // https://github.com/zeta-chain/node/issues/3221
+// EIP-1559 support is temporarily disabled to [explain rationale]
+// Impact: This means we'll use legacy transactions which might result in different gas optimization characteristics

222-222: Consider removing the unused parameter completely

Since the chainID parameter is no longer used in the legacy transaction flow, consider removing it completely from the function signature rather than marking it as unused with an underscore.

-func newTx(
-  _ *big.Int,
+func newTx(
   data []byte,
   to ethcommon.Address,
   amount *big.Int,
   gas Gas,
   nonce uint64,
 ) (*ethtypes.Transaction, error) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ed2352f and 892a488.

📒 Files selected for processing (3)
  • 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 (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/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/signer/gas.go (1)

60-61: Verify complete EIP-1559 removal strategy

While the isLegacy() method is marked as unused, its presence alongside the EIP-1559 related fields (PriorityFee) suggests that the EIP-1559 support removal might be incomplete. Consider whether this method and associated fields should be removed entirely to maintain code clarity.

Let's verify other EIP-1559 related code that might need attention:

✅ Verification successful

EIP-1559 removal is correctly implemented

The code shows that EIP-1559 support has been properly disabled:

  • All transactions are now using LegacyTx type, with DynamicFeeTx code commented out in signer.go
  • The isLegacy() method is correctly marked as unused with a reference to issue Fix all priorityFee edge-cases #3221
  • Tests for DynamicFeeTx are explicitly skipped with the same issue reference
  • The remaining EIP-1559 related fields (PriorityFee) are still used but only for gas price calculations, not for transaction type determination
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for EIP-1559 related patterns in the codebase
echo "Searching for EIP-1559 related code..."
rg -l "EIP-1559|DynamicFeeTx|maxFeePerGas|priorityFee|baseFee" 

# Search for transaction type specifications
echo "Searching for transaction type specifications..."
ast-grep --pattern 'type = "0x2"' # EIP-1559 transaction type

Length of output: 6250


Script:

#!/bin/bash
# Let's examine the specific EIP-1559 related code in the gas.go file and its tests
echo "Checking gas.go implementation:"
rg -A 5 "EIP-1559|DynamicFeeTx|maxFeePerGas|priorityFee|baseFee" zetaclient/chains/evm/signer/gas.go

echo "\nChecking gas_test.go:"
rg -A 5 "EIP-1559|DynamicFeeTx|maxFeePerGas|priorityFee|baseFee" zetaclient/chains/evm/signer/gas_test.go

echo "\nChecking for transaction type usage in signer:"
rg -A 5 "LegacyTx|DynamicFeeTx|LegacyTxType|DynamicFeeTxType" zetaclient/chains/evm/signer/

Length of output: 6173

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

235-241: Verify gas price optimization for legacy transactions

With EIP-1559 disabled, ensure that the gas price calculation in legacy transactions is optimized for the current network conditions. Consider implementing a gas price suggestion mechanism based on network congestion.

zetaclient/chains/evm/signer/signer.go Outdated Show resolved Hide resolved
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 (3)
zetaclient/chains/evm/signer/sign_test.go (1)

Line range hint 62-98: Consider maintaining test coverage with legacy transaction assertions

While skipping the DynamicFeeTx test is appropriate given the removal of EIP-1559 support, consider adding equivalent test cases for legacy transactions to maintain coverage of the gas price handling logic.

Consider adding a test case like this:

t.Run("SignOutbound - should correctly handle gas price for legacy tx", func(t *testing.T) {
    const gasPrice = 3 * 1_000_000_000 // 3 gwei
    
    cctx := getCCTX(t)
    cctx.OutboundParams[0].GasPrice = big.NewInt(gasPrice).String()
    
    txData, skip, err := NewOutboundData(ctx, cctx, 123, makeLogger(t))
    require.False(t, skip)
    require.NoError(t, err)
    
    tx, err := evmSigner.SignConnectorOnReceive(ctx, txData)
    require.NoError(t, err)
    
    assert.Equal(t, ethtypes.LegacyTxType, int(tx.Type()))
    assert.Equal(t, int64(gasPrice), tx.GasPrice().Int64())
})
zetaclient/chains/evm/signer/signer.go (2)

222-222: Consider removing the unused parameter

The chainID parameter is marked as unused with an underscore but could be removed entirely since it's no longer needed after disabling EIP-1559 support.

-func newTx(
-    _ *big.Int,
+func newTx(
    data []byte,
    to ethcommon.Address,
    amount *big.Int,
    gas Gas,
    nonce uint64,
) (*ethtypes.Transaction, error) {

235-242: Clean up commented code

Instead of keeping the commented-out code, consider removing it entirely and tracking the changes in version control. This improves code readability and maintenance.

-	// https://github.com/zeta-chain/node/issues/3221
-	//if gas.isLegacy() {
	return ethtypes.NewTx(&ethtypes.LegacyTx{
		To:       &to,
		Value:    amount,
		Data:     data,
		GasPrice: gas.Price,
		Gas:      gas.Limit,
		Nonce:    nonce,
	}), nil
-	//}
-	//
-	//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
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ed2352f and 892a488.

📒 Files selected for processing (3)
  • 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/gas.go
🧰 Additional context used
📓 Path-based instructions (2)
zetaclient/chains/evm/signer/sign_test.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/signer/sign_test.go (1)

Line range hint 1-98: Test structure and coverage are well-maintained

The overall test structure is robust with comprehensive coverage of signing operations, proper error handling, and consistent test patterns. The changes maintain this quality while appropriately handling the EIP-1559 deprecation.

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

233-254: Verify gas price implications of disabling EIP-1559

The change to use only legacy transactions by removing EIP-1559 support might affect gas price optimization. Legacy transactions use a simpler but less efficient gas pricing model.

Run the following script to analyze gas price patterns in the codebase:

Consider:

  1. Adding a comment explaining why EIP-1559 is disabled
  2. Documenting the gas price strategy for legacy transactions
  3. Monitoring transaction confirmation times after this change
✅ Verification successful

Let me gather more information about the gas price implementation and EIP-1559 support in the codebase.


EIP-1559 support temporarily disabled for stability and consistency

The change to use only legacy transactions is an intentional stability measure, as evidenced by issue #3221 referenced in the code. The EIP-1559 implementation exists but is currently commented out to ensure consistent gas pricing behavior across different EVM chains.

Key findings:

  • The isLegacy() function is marked with //nolint:unused indicating a temporary state
  • Test cases for DynamicFeeTx are skipped with explicit reference to issue Fix all priorityFee edge-cases #3221
  • The codebase maintains the EIP-1559 code structure for future re-enablement

Recommendations:

  • Add a comment explaining the temporary nature of legacy-only transactions:
// Currently using legacy transactions only for stability across EVM chains
// EIP-1559 support is temporarily disabled - see issue #3221
  • Consider adding configuration flags to enable EIP-1559 per chain when the stability issues are resolved
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for gas price calculations and EIP-1559 related code
rg -A 3 "GasPrice|GasFee|GasTip" 

# Look for any remaining EIP-1559 related code
rg -l "DynamicFeeTx|GasFeeCap|GasTipCap"

Length of output: 151144


Script:

#!/bin/bash
# Check for EIP-1559 related code and gas price patterns in the codebase
rg -A 3 "isLegacy|DynamicFeeTx|GasFeeCap|GasTipCap" zetaclient/chains/evm/signer/

# Look for any gas price related comments or documentation
rg -A 3 "https://github.com/zeta-chain/node/issues/3221" zetaclient/

Length of output: 5409

zetaclient/chains/evm/signer/sign_test.go Outdated Show resolved Hide resolved
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

We also need the ZetaClient to not vote new priorityFee, this is actually what would mitigate the bug in the gas stability pool logic

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.63%. Comparing base (bccb1cc) to head (294af38).

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##           release/v23    #3222      +/-   ##
===============================================
- Coverage        62.69%   62.63%   -0.06%     
===============================================
  Files              425      425              
  Lines            30231    30236       +5     
===============================================
- Hits             18954    18939      -15     
- Misses           10437    10461      +24     
+ Partials           840      836       -4     
Files with missing lines Coverage Δ
zetaclient/chains/evm/observer/observer.go 70.45% <100.00%> (+0.86%) ⬆️

... and 1 file with indirect coverage changes

@swift1337
Copy link
Contributor Author

We also need the ZetaClient to not vote new priorityFee, this is actually what would mitigate the bug in the gas stability pool logic

With recent changes, all EVMs should have observer.priorityFeeConfig.supported = false which effectively forces priorityFee to zero for all votes

@swift1337 swift1337 changed the base branch from develop to release/v23 November 27, 2024 14:57
Copy link

gitguardian bot commented Nov 27, 2024

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@@ -95,7 +95,12 @@ func NewObserver(
evmJSONRPC: evmJSONRPC,
outboundConfirmedReceipts: make(map[string]*ethtypes.Receipt),
outboundConfirmedTransactions: make(map[string]*ethtypes.Transaction),
priorityFeeConfig: priorityFeeConfig{},
priorityFeeConfig: priorityFeeConfig{
Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm, to prevent:

  • 1 voting new priorityFee?
  • 2 Using EIP1559 for the transactions?

If we have 1 but not 2, isn't some possible issue of using eip1559 while priorityFee is not updated?

Copy link
Contributor Author

@swift1337 swift1337 Nov 27, 2024

Choose a reason for hiding this comment

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

checked bool means we've already determined whether this chain supports priority fee. from the second time and on it will directly use supported bool

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.

3 participants