Skip to content

feat: basefee caculation for fip0115#6528

Open
LinZexiao wants to merge 4 commits intomasterfrom
feat/basefee-calculation-for-fip0115
Open

feat: basefee caculation for fip0115#6528
LinZexiao wants to merge 4 commits intomasterfrom
feat/basefee-calculation-for-fip0115

Conversation

@LinZexiao
Copy link
Copy Markdown
Collaborator

@LinZexiao LinZexiao commented Mar 19, 2026

关联的Issues (Related Issues)

ref #6525

改动 (Proposed Changes)

  • add ComputeNextBaseFeeFromPremiums

附注 (Additional Info)

自查清单 (Checklist)

在你认为本 PR 满足被审阅的标准之前,需要确保 / Before you mark the PR ready for review, please make sure that:

  • 符合Venus项目管理规范中关于PR的相关标准 / The PR follows the PR standards set out in the Venus project management guidelines
  • 具有清晰明确的commit message / All commits have a clear commit message.
  • 包含相关的的测试用例或者不需要新增测试用例 / This PR has tests for new functionality or change in behaviour or not need to add new tests.
  • 存在兼容性问题(接口, 配置,数据,灰度),如果存在需要进行文档说明 / This PR has compatibility issues (API, Configuration, Data, GrayRelease), if so, need to be documented.
  • 包含相关的的指南以及文档或者不需要新增文档 / This PR has updated usage guidelines and documentation or not need
  • 通过必要的检查项 / All checks are green

@LinZexiao LinZexiao mentioned this pull request Mar 19, 2026
10 tasks
@LinZexiao LinZexiao force-pushed the feat/basefee-calculation-for-fip0115 branch from 0918376 to 8a6c43a Compare March 19, 2026 07:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements the FIP-0115 base fee update path by deriving the next base fee from message gas premiums (rather than utilization), and updates effective gas premium calculation to clamp negative rewards to zero.

Changes:

  • Add premium-based base fee computation (ComputeNextBaseFeeFromPremiums) and supporting weighted percentile selection logic.
  • Clamp EffectiveGasPremium to never return a negative value when GasFeeCap < BaseFee.
  • Add/adjust tests covering EffectiveGasPremium, weighted selection, and next-base-fee-from-premium formula.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
venus-shared/actors/types/message.go Clamp effective gas premium to zero when GasFeeCap is below BaseFee.
venus-shared/actors/types/message_test.go New unit tests for EffectiveGasPremium edge cases.
pkg/chain/message_store.go Add premium-based base fee computation + weighted quickselect percentile helper.
pkg/chain/message_store_test.go Add tests for weighted quickselect determinism and next-base-fee-from-premium formula.
pkg/chain/export_test.go Expose internal helpers for testing.
pkg/constants/chain_parameters.go Add BlockGasTargetIndex constant for percentile selection.
pkg/config/config.go Add new fork upgrade height field (currently placeholder-named) and minor comment formatting.
app/submodule/eth/eth_test.go Update reward expectation to match clamped premium behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 59.30233% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 22%. Comparing base (4249868) to head (9f686c0).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #6528   +/-   ##
======================================
  Coverage      22%     22%           
======================================
  Files         775     775           
  Lines       81995   82083   +88     
======================================
+ Hits        18349   18410   +61     
- Misses      60777   60805   +28     
+ Partials     2869    2868    -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LinZexiao LinZexiao force-pushed the feat/basefee-calculation-for-fip0115 branch from c860b7e to 9f686c0 Compare March 20, 2026 08:54
@LinZexiao
Copy link
Copy Markdown
Collaborator Author

@wjmelements Would you mind reviewing this pr, please?

Copy link
Copy Markdown

@wjmelements wjmelements left a comment

Choose a reason for hiding this comment

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

base fee adjustment, activation, and tests look good to me

{maxFeePerGas: big.NewInt(600), maxPriorityFeePerGas: big.NewInt(500), answer: big.NewInt(500)},
{maxFeePerGas: big.NewInt(600), maxPriorityFeePerGas: big.NewInt(600), answer: big.NewInt(500)},
{maxFeePerGas: big.NewInt(600), maxPriorityFeePerGas: big.NewInt(1000), answer: big.NewInt(500)},
{maxFeePerGas: big.NewInt(50), maxPriorityFeePerGas: big.NewInt(200), answer: big.NewInt(-50)},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Check that you weren't previously using this method for the block reward calculation. For the block reward it is possible for the max fee per gas to be less than the base fee, and in that case a part of the base fee is paid by the storage provider.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it's not about the block reward.

Copy link
Copy Markdown
Collaborator

@y-ang2010 y-ang2010 left a comment

Choose a reason for hiding this comment

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

lgtm

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.

5 participants