consensus, ethapi: embed gas target and base fee params in block header extra field (post Giugliano HF)#2135
Conversation
…er extra field (Giugliano HF)
Code ReviewBug found in consensus/bor/bor.go line 993: setGiuglianoExtraFields passes the current block header to CalcGasTarget and BaseFeeChangeDenominator, but both functions expect the parent header. CalcGasTarget wraps calcParentGasTarget which reads parent.GasLimit, parent.BaseFee, parent.Number. At Prepare() time, the current header has different values (GasLimit adjusted by CalcGasLimit, BaseFee is the new value, Number is parent+1). The fix is to pass the parent header, available via chain.GetHeaderByHash(header.ParentHash). |
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (82.20%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #2135 +/- ##
===========================================
+ Coverage 51.48% 51.49% +0.01%
===========================================
Files 881 882 +1
Lines 153870 154110 +240
===========================================
+ Hits 79216 79359 +143
- Misses 69482 69584 +102
+ Partials 5172 5167 -5
... and 24 files with indirect coverage changes
🚀 New features to boost your workflow:
|
marcello33
left a comment
There was a problem hiding this comment.
Some warning/errors detected from SonarCloud
Other than that, LGTM
|
@claude - review this PR |
|
Claude finished @pratikspatil024's task in 4m 30s —— View job PR Review: Embed gas target and base fee params in block header extra field (post Giugliano HF)
Overall AssessmentWell-structured PR with good test coverage. The original bug I flagged (passing the current header instead of the parent to Issues Found1. Verification only checks presence, not correctness (Medium)
This matters because RPC consumers will trust these values. If the intent is informational-only and the actual base fee calculation uses its own computation (which it does in // Option: validate correctness
expectedGasTarget := eip1559.CalcGasTarget(c.chainConfig, parent)
expectedBfcd := params.BaseFeeChangeDenominator(c.config, parent.Number)
if *gasTarget != expectedGasTarget || *bfcd != expectedBfcd {
return fmt.Errorf("post-Giugliano block %d: gas params mismatch", number)
}2.
|
|



Description
BlockExtraDatawith two optional RLP fields (GasTarget,BaseFeeChangeDenominator) so full node operators and RPC users can determine the EIP-1559 parameters a block producer usedPrepare()forpost-Giuglianoblocks and verifies their presence during block import inverifyCascadingFields()eip1559.CalcGasTarget()for use by consensus codebor_getBlockGasParamsRPC method returning both values for any block (post Giugliano block)borExtraparameter toeth_getBlockByNumberandeth_getBlockByHash, when set to true, the response includes ablockExtraDataobject with parsedgasTarget,baseFeeChangeDenominator, andtxDependencyfrom the header extra field, eliminating the need for a second RPC callHeader.DecodeBlockExtraData()for single-pass RLP decoding of the full BlockExtraData structGetBaseFeeParamsextraction testsChanges
Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it
Nodes audience
In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)
Checklist
Cross repository changes
Testing
Manual tests
Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it
Additional comments
Please post additional comments in this section if you have them, otherwise delete it