feat: baseFeePerGas is not a constant#5178
Draft
bootcodes wants to merge 6 commits intohiero-ledger:mainfrom
Draft
feat: baseFeePerGas is not a constant#5178bootcodes wants to merge 6 commits intohiero-ledger:mainfrom
bootcodes wants to merge 6 commits intohiero-ledger:mainfrom
Conversation
…to CommonService.ts Signed-off-by: Thomas Boot <thomas.boot@swirldslabs.com>
…kWorker.ts Signed-off-by: Thomas Boot <thomas.boot@swirldslabs.com>
Signed-off-by: Thomas Boot <thomas.boot@swirldslabs.com>
Signed-off-by: Thomas Boot <thomas.boot@swirldslabs.com>
Signed-off-by: Thomas Boot <thomas.boot@swirldslabs.com>
Signed-off-by: Thomas Boot <thomas.boot@swirldslabs.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue where
baseFeePerGasineth_getBlockByNumber,eth_getBlockByHash, andeth_feeHistorywas always set to the live network gas price, regardless of which block was being queried. This caused incorrect values for historical blocks and made the field meaningless as a signal for actual fees paid in a block.The fix computes baseFeePerGas accurately:
Need #5140 and #5134 to be merged first and this PR needs to be refactored to utilize the latest changes.
Related issue(s)
Fixes #5130
Testing Guide
npx lerna exec --scope @hashgraph/json-rpc-relay -- npx ts-mocha tests/lib/eth/eth_getBlockByNumber.spec.ts --exitnpx lerna exec --scope @hashgraph/json-rpc-relay -- npx ts-mocha tests/lib/eth/eth_feeHistory.spec.ts --exitVerify
eth_getBlockByNumberreturns a baseFeePerGas that reflects actual transaction gas prices for non-empty blocks, and a timestamped fee schedule value for empty blocks.Verify
eth_feeHistorywithETH_FEE_HISTORY_FIXED=falsereturnsbaseFeePerGasvalues that differ across historical blocks when different fees were in effect, and that gasUsedRatio values reflect real block utilization rather than the constant 0.5.Changes from original design (optional)
The original description specified
GET /api/v1/network/exchangerateas the data source for empty-block fallback. That endpoint returns a HBAR/USD exchange rate (cents per HBAR), not a gas price. The implementation usesGET /api/v1/network/fees?timestamp=lte:{block.timestamp.to}instead, which is the direct source of the gas price in tinybars at a given timestamp.Additional work needed (optional)
Acceptance test coverage for the ETH_FEE_HISTORY_FIXED=false code path requires starting the relay server with that flag set, which is a CI configuration change outside the scope of this PR.
Checklist