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: update evm gas price to 5gwei #904

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Conversation

zakir-code
Copy link
Contributor

@zakir-code zakir-code commented Jan 15, 2025

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new default gas price of 5 * 10^9
  • Improvements

    • Updated gas pricing configuration across multiple components
    • Reduced base fee and minimum gas price by a factor of 100
  • Configuration Changes

    • Modified gas price settings in genesis and configuration files
    • Updated minimum gas price retrieval method in various system components

Copy link

coderabbitai bot commented Jan 15, 2025

Walkthrough

This pull request introduces comprehensive changes to gas pricing configuration across multiple files in the project. The modifications primarily focus on updating the default gas price from 500_000_000_000 to 5_000_000_000, which represents a reduction by a factor of 100. The changes span configuration files, upgrade logic, and test utilities, ensuring consistent gas price settings throughout the application. The updates leverage a new DefaultGasPrice constant and modify how minimum gas prices are retrieved and set.

Changes

File Change Summary
app/genesis.go Updated BaseFee and MinGasPrice initialization to use fxtypes.DefaultGasPrice
app/genesis.json Reduced base_fee and min_gas_price from 500000000000 to 5000000000
app/upgrades/v8/upgrade.go Added migrateFeemarketGasPrice function to update fee market parameters during upgrade
cmd/config.go, cmd/root.go, testutil/network.go Replaced GetDefGasPrice() with GetDefMinGasPrices() for configuration
types/constant.go Added DefaultGasPrice constant and updated GetDefMinGasPrices() function
x/evm/keeper/msg_server_test.go Updated gas price to use fxtypes.DefaultGasPrice in test transactions

Possibly related PRs

Poem

🐰 Hopping through gas prices so bright,
From hundreds to single digits, what a delight!
Config files dancing, prices taking flight,
A rabbit's leap towards efficiency's might!
Blockchain magic, coded just right! 🚀

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@@ -24,6 +24,8 @@
FXDenom = "FX"

AddrLen = 20

DefaultGasPrice = 5 * 1e9

Check notice

Code scanning / CodeQL

Floating point arithmetic Note

Floating point arithmetic operations are not associative and a possible source of non-determinism
Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed93298 and aecd547.

📒 Files selected for processing (10)
  • app/genesis.go (1 hunks)
  • app/genesis.json (1 hunks)
  • app/upgrades/v8/upgrade.go (4 hunks)
  • cmd/config.go (1 hunks)
  • cmd/config_test.go (1 hunks)
  • cmd/root.go (1 hunks)
  • server/config/config_cmd_test.go (1 hunks)
  • testutil/network.go (1 hunks)
  • types/constant.go (2 hunks)
  • x/evm/keeper/msg_server_test.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeQL
types/constant.go

[notice] 28-28: Floating point arithmetic
Floating point arithmetic operations are not associative and a possible source of non-determinism

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Summary
🔇 Additional comments (12)
server/config/config_cmd_test.go (1)

62-62: LGTM! Function call updated for consistency.

The change from GetDefGasPrice() to GetDefMinGasPrices() aligns with the new gas price configuration approach.

types/constant.go (1)

56-57: Verify the significant gas price reduction.

The gas price has been reduced from 500 gwei to 5 gwei (factor of 100). Please ensure this significant reduction has been thoroughly tested and won't cause issues with:

  1. Transaction processing
  2. Network economics
  3. Spam prevention
✅ Verification successful

Gas price reduction has been properly implemented across the codebase

The gas price reduction from 500 gwei to 5 gwei has been consistently implemented across all necessary components:

  • Base fee and minimum gas price in fee market parameters
  • Default configuration settings
  • Upgrade handlers ensure proper migration
  • Gas price validations remain intact

The change appears to be thorough and well-coordinated across the codebase, maintaining consistency in all relevant components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any hardcoded gas prices that might need updating
rg -l "500.*1e9|500.*000000000" --type go

# Check for any gas price related configurations in JSON files
rg -l "\"base_fee\"|\"min_gas_price\"" --type json

Length of output: 349


Script:

#!/bin/bash
# Check genesis.json content
echo "=== Genesis.json gas settings ==="
cat app/genesis.json | jq '.app_state.feemarket'

# Check context of 500*1e9 occurrences
echo -e "\n=== Context of 500*1e9 occurrences ==="
rg "500.*1e9|500.*000000000" --type go -C 2

# Check gas price related constants
echo -e "\n=== Gas price related constants ==="
rg "GasPrice|gas.*price" --type go -C 2

# Check the previous value in the changed file
echo -e "\n=== Previous gas price value ==="
git log -p types/constant.go | rg -A 5 -B 5 "DefaultGasPrice"

Length of output: 113288


Script:

#!/bin/bash
# Search for gas price constants and their values
echo "=== Gas price constants ==="
rg -A 2 -B 2 "DefaultGasPrice.*=|MinGasPrice.*=|gas.*price.*=" --type go

# Search for gas price validations
echo -e "\n=== Gas price validations ==="
rg -A 2 -B 2 "ValidateBasic.*gas|validate.*gas|check.*gas" --type go

# Search for gas price in test files
echo -e "\n=== Gas price in tests ==="
rg -A 2 -B 2 "gas.*price.*test" --type go

Length of output: 22669

cmd/config.go (1)

56-56: LGTM! Configuration updated consistently.

The change to use GetDefMinGasPrices() maintains consistency with the new gas price implementation.

x/evm/keeper/msg_server_test.go (1)

33-33: LGTM! Test updated to use new gas price constant.

The change to use fxtypes.DefaultGasPrice maintains consistency with the new gas price implementation.

cmd/config_test.go (1)

102-102: LGTM! Consistent gas price configuration update.

The change from GetDefGasPrice to GetDefMinGasPrices aligns with the PR's objective to update gas prices and maintains consistency with other configuration changes.

app/genesis.go (1)

133-134: Verify the economic implications of reduced gas prices.

The significant reduction in gas prices (from 500gwei to 5gwei) warrants careful consideration:

  1. Could this make the network more vulnerable to spam attacks?
  2. How does this compare with gas prices on other EVM chains?
  3. What's the rationale for choosing 5gwei specifically?

Let's analyze the gas price settings across the codebase:

✅ Verification successful

Gas price reduction is well-protected by EIP-1559 mechanisms

The reduction to 5gwei is reasonable and protected against spam attacks:

  • The EIP-1559 dynamic fee mechanism automatically adjusts the base fee based on network demand
  • Validators can set their own minimum gas prices higher if needed
  • 5gwei is still higher than many other EVM chains (e.g., Polygon 30gwei, BSC 3gwei)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all gas price references
echo "Searching for gas price constants and configurations..."
rg -A 2 "DefaultGasPrice|MinGasPrice|BaseFee" --type go

# Search for any comments or documentation about gas price rationale
echo "Searching for gas price documentation..."
rg -i "gas.?price" --type md

Length of output: 37538


Script:

#!/bin/bash
# Search for EIP1559 related files and configurations
echo "Searching for EIP1559 related files..."
rg -i "eip.*1559|dynamic.*fee" --type go -A 3

# Search for documentation
echo "Searching for docs..."
fd -t f . docs/
cat docs/README.md 2>/dev/null || true

# Search for gas price test cases
echo "Searching for gas price test cases..."
rg "TestGasPrice|test.*gas.*price" --type go -A 3

Length of output: 1481


Script:

#!/bin/bash
# Search for fee market module files
echo "Searching for fee market module..."
fd -t f . "feemarket"

# Search for fee market parameters
echo "Searching for fee market parameters..."
rg "feemarket.*param|min.*gas|base.*fee" --type go -A 3

# Search for recent gas price related commits
echo "Searching for gas price related commits..."
git log --oneline -n 10 | grep -i "gas.*price\|fee.*market"

Length of output: 67121

testutil/network.go (1)

74-74: LGTM! Test configuration aligned with new gas price.

The change to use GetDefMinGasPrices maintains consistency with the application's new gas price settings.

Let's verify that all test cases using this configuration remain valid:

✅ Verification successful

Test configuration change verified successfully

The change to use GetDefMinGasPrices() is consistent with how gas prices are configured across the test suite and maintains compatibility with all test cases.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for test cases that might be affected by gas price changes
rg -A 5 "MinGasPrices|gasPrice|fee" --type go --glob "*_test.go"

Length of output: 98116


Script:

#!/bin/bash
# Search for GetDefMinGasPrices usage in test files
rg -A 2 "GetDefMinGasPrices" --type go --glob "*_test.go"

# Search for other min gas price configurations in test files
rg -A 2 "MinGasPrices.*=|SetMinGasPrices" --type go --glob "*_test.go"

Length of output: 1190

cmd/root.go (1)

128-128: Verify upgrade path for existing nodes.

While the change to use GetDefMinGasPrices is consistent with the PR's objective, we should ensure:

  1. The upgrade path handles the gas price change smoothly
  2. Existing nodes can adapt to the new gas price without disruption
  3. Documentation is updated to reflect this significant change

Let's check the upgrade handling:

✅ Verification successful

Default gas price change is configuration-based and safe

The change to use GetDefMinGasPrices() is a safe configuration update that:

  • Only affects default values, not existing state
  • Requires no special upgrade handling
  • Will be naturally adopted by nodes on restart
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for upgrade handlers that might need to handle gas price changes
echo "Checking upgrade handlers..."
rg -A 10 "func.*Upgrade" --type go

# Search for documentation that needs updating
echo "Checking documentation..."
fd -e md -e rst | xargs rg -l "gas.?price"

Length of output: 90956


Script:

#!/bin/bash
# Check for gas price documentation and configuration
echo "Checking gas price documentation and configuration..."
rg -l "GetDefMinGasPrices|MinGasPrices" --type go

# Check for any gas price related configuration or state changes
echo "Checking gas price implementation..."
rg -A 5 "func.*GetDefMinGasPrices" --type go

Length of output: 1065

app/upgrades/v8/upgrade.go (3)

81-83: LGTM!

The error handling for the fee market gas price migration is consistent with the rest of the function.


161-164: LGTM!

The error handling for the fee market gas price migration is consistent with the rest of the function. Correctly returns toVM with the error since other migrations have already been applied.


524-529: LGTM!

The function correctly updates both BaseFee and MinGasPrice to use the new default gas price. The implementation is clean, focused, and has proper error handling.

app/genesis.json (1)

320-321: LGTM!

The fee market parameters are correctly updated to use the new gas price of 5gwei. The changes are consistent with the migration function in upgrade.go.

@@ -24,6 +24,8 @@
FXDenom = "FX"

AddrLen = 20

DefaultGasPrice = 5 * 1e9
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use integer arithmetic instead of floating point.

The current implementation uses floating point arithmetic which could be a source of non-determinism. Consider using integer arithmetic instead.

-DefaultGasPrice = 5 * 1e9
+DefaultGasPrice = 5000000000  // 5 gwei
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
DefaultGasPrice = 5 * 1e9
DefaultGasPrice = 5000000000 // 5 gwei
🧰 Tools
🪛 GitHub Check: CodeQL

[notice] 28-28: Floating point arithmetic
Floating point arithmetic operations are not associative and a possible source of non-determinism

@zakir-code zakir-code merged commit bc7ebab into main Jan 15, 2025
13 checks passed
@zakir-code zakir-code deleted the nulnut/update-evm-params branch January 15, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants