Skip to content

feat: update base fee via contract #1189

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

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

Thegaram
Copy link

@Thegaram Thegaram commented May 23, 2025

1. Purpose or design rationale of this PR

Revert most changes from #1183.

Update L2 base fee coefficients automatically after block import using a new system contract scroll-tech/scroll-contracts#114.

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • feat: A new feature

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features

    • The system now updates L2 base fee parameters dynamically based on on-chain events, improving responsiveness to configuration changes.
    • Added support for retrieving L2 base fee coefficients directly from blockchain state during initialization.
  • Bug Fixes

    • Removed outdated command-line flags and configuration fields related to L2 base fee settings, reducing potential confusion and misconfiguration.
  • Chores

    • Updated internal version number to 0.0.50.

Copy link

coderabbitai bot commented May 23, 2025

## Walkthrough

This change removes CLI flags, configuration fields, and related logic for L2 base fee scalar and overhead, centralizing their management via package-level variables updated by chain events. It also introduces new configuration fields for the L2 system config address and event topics, and bumps the patch version.

## Changes

| Files / Areas Changed                                                                 | Summary                                                                                                      |
|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
| `cmd/geth/main.go`, `cmd/geth/usage.go`                                              | Removed `L2BaseFeeScalarFlag` and `L2BaseFeeOverheadFlag` from CLI flags and help groups.                    |
| `cmd/utils/flags.go`                                                                 | Deleted flag declarations, flag handling, and the `setBaseFee` function. Removed imports and flag setup.     |
| `consensus/misc/eip1559.go`                                                          | Centralized L2 base fee parameters as package-level variables with mutex; added `UpdateL2BaseFeeScalar` and `UpdateL2BaseFeeOverhead`.     |
| `consensus/misc/eip1559_test.go`                                                     | Updated tests to use `UpdateL2BaseFeeScalar` and `UpdateL2BaseFeeOverhead` instead of direct config assignment.                            |
| `core/blockchain.go`                                                                 | Added logic to update L2 base fee parameters from chain events during block processing; added metrics timer.                      |
| `eth/backend.go`                                                                     | Removed assignment of base fee scalar/overhead to chain config during initialization; added dynamic state-based initialization.                        |
| `eth/ethconfig/config.go`                                                            | Removed `BaseFeeScalar` and `BaseFeeOverhead` fields from `Config` struct.                                   |
| `params/config.go`                                                                   | Added `L2SystemConfigAddress` to `L1Config`. Removed base fee fields from `ScrollConfig`. Updated `String()` and added accessor method.|
| `params/version.go`                                                                  | Bumped `VersionPatch` from 49 to 50.                                                                         |
| `rollup/rcfg/config.go`                                                              | Added variables for L2 base fee update event topics and storage slots with detailed comments.                               |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant BlockChain
    participant Log
    participant misc as EIP1559 Package

    BlockChain->>Log: Process block logs
    alt If log is L2BaseFeeUpdate event
        Log->>misc: UpdateL2BaseFeeScalar or UpdateL2BaseFeeOverhead(new value)
        misc-->>Log: Update internal base fee parameters
    end
    BlockChain->>misc: CalcBaseFee(...)
    misc-->>BlockChain: Return calculated base fee

Possibly related PRs

Suggested labels

bump-version

Suggested reviewers

  • georgehao
  • jonastheis

Poem

The flags are gone, the scalars too,
Now base fees dance when events come through.
No more config fields to clutter the scene,
Updates are locked, atomic, and clean.
With a hop and a skip, the patch ticks anew—
A rabbit’s delight in code review! 🐇✨


<!-- walkthrough_end -->

<!-- announcements_start -->

> [!NOTE]
> <details>
> <summary>⚡️ AI Code Reviews for VS Code, Cursor, Windsurf</summary>
> 
> CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
> Learn more [here](http://coderabbit.ai/ide).
> 
> </details>

<!-- announcements_end -->

---

<details>
<summary>📜 Recent review details</summary>

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


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 7f4a19a307c7a6e1f320f7d2064c1d85236a10dc and e71f55789abfb2f109565f34711063f0621cbc86.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `core/state_processor_test.go` (1 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (1)</summary>

* core/state_processor_test.go

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (2)</summary>

* GitHub Check: test
* GitHub Check: Analyze (go)

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIgAzEmoubG5aahJIATRETMTMiXg0BQxcKjFQ2MgAdxz7bAFmdRp6OQjYTOxcvjgSImc0ZnRkW0gMRwFKSABGaYAOAE5+LFwOyABlBgp8HxhRWEgiQhJVyhJHPxJufER1fBcNGDXmbSxPCmvc/nj21FHUAiXKQUXCQZg3UEMWCYUjIeClba0bAMGLw9A8fyFfBdax2AAUZlmcwAzABKdAYejwZjcaJsUoUnAEF7iBiQVLpGjfdqZAAyaFkUwATJA8byheTsl98goSPF4vAGPB2Mg0PEaHwBF58AwANYoGn3TRPVAcjJg/aYJBDaLAtCw9Hkar2WSIGhDJgItAVGoIKEoZBKXDaaJUrDFfxeDL0TbbXaesre3DIfyfO4uXGiwnTAAspI0bjWo3iO211WQpxKUlK8HwGDQviYrHUyBLFBZ4QYGSOFHgAC94UQeYxoRhSMNHSRnYlqNh/KKEklcLF85AAJKg+EMLzYJSqrBmrmAyvA251lArNYAA24A2YiAA9KfaxgNEcr5AFdFwvDaIrqIOk7OkotL4LI9Kgs+daPL0maoCQAAetKKuoXjyC8FC6jEd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ICFg8oeIAkPmAaAjRb3ZASgIEDEhiQKAlAbgKNEaB/i6wAVOvGVT8iaRFoIUeOBFGZBYgyPeELcDZD9BM4BRIhIqOsSPc8iVADlNiM1HoptRCEPgawLlACAWuxonjDqLmA5CcwDAZTArGNHDJScxuWeqP1dGCitCa/TDOwB/AnJ6WI/SVK6LHSR1t4/9IPOEDm7kB6AC3JiE8l6DKjQYywHWD6kCj8ikIMFOEUiOcRQsoCIJSgEGlJheQxgkUUGo1gwDyB4yJuAiKkjLDdsA0F/L3NEiSZBpb+WDdJnt0TT8ICG/3MqAYHGjxpdWdUAgPTVUQqtSgK0NAGtHi6kR5A7XQaHtBGiHRDA141qOoE/zHlEAn+a4lODoCf5cMIIP8SdCgC9UEhVA2gM1zNHxBVMwg4kJ4ItG8CFgngtAHMBzBoASBaABgQcRyECBYJ14+IF4OIHTACBcwBgNMAOJZDlMDAOIXQHQG0BqJJABidRJ8G0AshaoFAbhMokVRIA1AwiZQLQDEhkhDAFAWgDInTB4gxIdAfEE4HoCDimY6YL4OUxChMJaAFPrQDZBjQxJJACgWhOIGLAVA8QAQEKD4kLAVehA9YhQI8HEgsBBxdwQwAEAMA5gBxWCVeLEmATcAwErOmBOswQTaAn+KqH+KAA== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=scroll-tech/go-ethereum&utm_content=1189):

- 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](https://www.coderabbit.ai/contact-us/support) 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](https://docs.coderabbit.ai/finishing-touches/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.

### 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

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: 2

🧹 Nitpick comments (2)
rollup/rcfg/config.go (1)

52-56: Address TODO comments before deployment.

The L2 base fee configuration variables are initialized with placeholder values and contain TODO comments indicating they need proper assignment. These must be set to correct values before this code can be used in production.

Please ensure these values are properly configured:

  • L2BaseFeeUpdateTopic should contain the actual event topic hash from the L2 system config contract
  • L2BaseFeeOverheadSlot and L2BaseFeeScalarSlot should contain the correct storage slot positions

Do you need help determining the correct values for these variables, or should we create an issue to track setting these properly?

core/blockchain.go (1)

275-293: Review the L2 base fee update implementation for robustness.

The implementation correctly processes L2 system config events to update base fee parameters, but consider these potential improvements:

  1. Event validation: Add validation that the log has sufficient topics before accessing r.Topics[1] and r.Topics[2] to prevent panics.

  2. Error handling: Consider adding error handling around misc.UpdateL2BaseFeeParams() in case the update fails.

  3. Performance consideration: The code iterates through all logs for every block. For blocks with many logs, this could be expensive, but it's likely acceptable given the importance of fee updates.

Example improvement for safety:

 for _, r := range logs {
-	if r.Address == l2SystemConfigAddress && r.Topics[0] == rcfg.L2BaseFeeUpdateTopic {
+	if r.Address == l2SystemConfigAddress && len(r.Topics) >= 3 && r.Topics[0] == rcfg.L2BaseFeeUpdateTopic {
 		scalar := r.Topics[1].Big()
 		overhead := r.Topics[2].Big()
-		misc.UpdateL2BaseFeeParams(scalar, overhead)
+		if err := misc.UpdateL2BaseFeeParams(scalar, overhead); err != nil {
+			log.Warn("Failed to update L2 base fee params", "err", err, "blockNumber", block.NumberU64())
+		} else {
 			log.Info("Updated L2 base fee coefficients", "blockNumber", block.NumberU64(), "blockHash", block.Hash().Hex(), "scalar", scalar, "overhead", overhead)
+		}
 	}
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 141a8df and cf9d97d.

📒 Files selected for processing (11)
  • cmd/geth/main.go (0 hunks)
  • cmd/geth/usage.go (0 hunks)
  • cmd/utils/flags.go (0 hunks)
  • consensus/misc/eip1559.go (3 hunks)
  • consensus/misc/eip1559_test.go (3 hunks)
  • core/blockchain.go (4 hunks)
  • eth/backend.go (0 hunks)
  • eth/ethconfig/config.go (0 hunks)
  • params/config.go (4 hunks)
  • params/version.go (1 hunks)
  • rollup/rcfg/config.go (1 hunks)
💤 Files with no reviewable changes (5)
  • cmd/geth/main.go
  • eth/ethconfig/config.go
  • eth/backend.go
  • cmd/geth/usage.go
  • cmd/utils/flags.go
🧰 Additional context used
🧬 Code Graph Analysis (2)
rollup/rcfg/config.go (1)
common/types.go (2)
  • HexToHash (66-66)
  • BigToHash (62-62)
consensus/misc/eip1559_test.go (1)
consensus/misc/eip1559.go (2)
  • UpdateL2BaseFeeParams (46-52)
  • MinBaseFee (87-89)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test
  • GitHub Check: Analyze (go)
🔇 Additional comments (13)
params/version.go (1)

27-27: LGTM! Version bump is appropriate.

The patch version increment from 49 to 50 correctly reflects the deployment of the new L2 base fee management features introduced in this PR.

consensus/misc/eip1559.go (3)

22-22: LGTM! Proper import for synchronization.

The addition of the sync package is necessary for the mutex-based thread safety implementation.


36-44: LGTM! Well-designed package-level variable structure.

The use of package-level variables with default values and mutex protection is a good architectural choice for centralizing L2 base fee parameter management. The default values match the previous configuration defaults, ensuring backward compatibility.


81-84: LGTM! Proper mutex usage for thread safety.

The read lock acquisition before accessing the package-level variables ensures thread-safe access to the base fee parameters. The defer statement ensures proper lock release.

consensus/misc/eip1559_test.go (3)

125-125: LGTM! Test properly updated for new parameter management.

The test correctly uses UpdateL2BaseFeeParams to set the base fee parameters before testing the calculation logic. The values (10000000, 1) are appropriate for this test scenario.


144-144: LGTM! Test uses correct default values.

The test properly uses the default base fee parameters (34000000000000, 15680000) that match the package-level defaults, ensuring consistency with the refactored implementation.


153-153: LGTM! Test updated to use explicit values.

The test correctly uses explicit big integer values instead of the removed constants, maintaining the same test logic while adapting to the new parameter management approach.

core/blockchain.go (3)

37-37: LGTM! Necessary imports for L2 base fee functionality.

The imports for consensus/misc and rollup/rcfg packages are required for the new L2 base fee update mechanism implemented in this file.

Also applies to: 49-49


60-61: LGTM! Proper metrics for L2 base fee monitoring.

The new metrics follow the existing naming conventions and provide valuable observability for L2 base fee values and update performance.


280-280:

❓ Verification inconclusive

Verify L2SystemConfigAddress configuration is properly set.

The L2 base fee update functionality depends on L2SystemConfigAddress being correctly configured. Currently, this address is set to empty in the chain configurations with TODO comments.

Please ensure that:

  1. The L2SystemConfigAddress is set to the correct deployed contract address for each network
  2. The address corresponds to a contract that emits the expected L2BaseFeeUpdateTopic events
  3. The event structure matches the expected format with scalar and overhead in topics[1] and topics[2]

🏁 Script executed:

#!/bin/bash
# Verify L2SystemConfigAddress configuration across different networks
echo "Checking L2SystemConfigAddress configuration in chain configs:"
rg -A 2 -B 2 "L2SystemConfigAddress.*common\.Address" --type go

Length of output: 1261


Confirm L2SystemConfigAddress Is Configured

The L2 base‐fee update logic in core/blockchain.go will be inactive until L2SystemConfigAddress is set. Currently both Sepolia and Mainnet entries in params/config.go are still defaulting to an empty address:

File: params/config.go

// Sepolia
L2SystemConfigAddress:           common.Address{}, // TODO

// Mainnet
L2SystemConfigAddress:           common.Address{}, // TODO

Please ensure you:

  • Populate L2SystemConfigAddress with the correct deployed L2SystemConfig contract address for each network.
  • Confirm the contract emits the expected L2BaseFeeUpdateTopic events.
  • Verify that topics[1] and topics[2] correspond to scalar and overhead in your event decoding.
params/config.go (3)

719-719: LGTM! Proper field addition to L1Config struct.

The L2SystemConfigAddress field is correctly added with appropriate type and JSON serialization tag.


727-728: LGTM! String method properly updated for new field.

The L1Config String method correctly includes the new L2SystemConfigAddress field with proper hex formatting, maintaining consistency with other address fields.


759-760: LGTM! ScrollConfig String method updated correctly.

The String method properly excludes the removed BaseFeeScalar and BaseFeeOverhead fields, maintaining consistency with the transition to dynamic L2 base fee updates.

colinlyguo
colinlyguo previously approved these changes May 23, 2025
BaseFeePrecision = new(big.Int).SetUint64(1e18)

// scalar and overhead are updated automatically in `Blockchain.writeBlockWithState`.
baseFeeScalar = new(big.Int).SetUint64(34000000000000)
Copy link

@jonastheis jonastheis May 23, 2025

Choose a reason for hiding this comment

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

these parameters are set via UpdateL2BaseFeeParams which is called when processing a block that contains the update event/log. What I don't understand: how is this persisted across node startups? What if a node read and updated these values and shuts down. Now it won't process this block anymore and needs to read from state if these values are at default values no?

Copy link
Author

Choose a reason for hiding this comment

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

I was thinking it would update them when it starts processing blocks. But you're right, it's unlikely that we'll encounter another update event shortly after startup. I'll add code to initialize these from state.

Copy link
Author

Choose a reason for hiding this comment

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

Added in 9bda21c

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.

3 participants