Use effectiveGasPrice for fee calculation on L2 networks#1386
Open
h45hc47 wants to merge 3 commits intotrezor:masterfrom
Open
Use effectiveGasPrice for fee calculation on L2 networks#1386h45hc47 wants to merge 3 commits intotrezor:masterfrom
h45hc47 wants to merge 3 commits intotrezor:masterfrom
Conversation
On L2 networks like Arbitrum, the gasPrice in transaction represents "Gas Price Bid", not the actual price paid. The actual price is returned as effectiveGasPrice in the transaction receipt. This fix: - Adds EffectiveGasPrice field to RpcReceipt struct - Adds EffectiveGasPrice to protobuf schema for storage - Updates fee calculation to use effectiveGasPrice when available, falling back to gasPrice for backward compatibility Fixes incorrect fee display on Arbitrum, Optimism, Base and other L2 networks. Closes trezor#1227
pragmaxim
requested changes
Jan 17, 2026
Contributor
pragmaxim
left a comment
There was a problem hiding this comment.
Hey, thanks for the contribution, it looks great! I found just two little issues :
- API docs still list only
gasPriceinethereumSpecificand do not mentioneffectiveGasPrice.- https://github.com/trezor/blockbook/blob/eth-l2-use-effective_gas_price/docs/api.md#L274
Suggested fix:
- _status_ (`1` OK, `0` Failure, `-1` pending), potential _error_ message, _gasLimit_, _gasUsed_, _gasPrice_, _effectiveGasPrice_, _nonce_, input _data_
- https://github.com/trezor/blockbook/blob/eth-l2-use-effective_gas_price/docs/api.md#L274
And missing L1 fees in balance history fees, with inline comment.
Author
|
Sorry for that to take so long. Do i also need to add this field to blockbook-api.ts? |
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.
Problem
On L2 networks (Arbitrum, Optimism, Base, etc.), the
feesfield in API responses returns incorrect values.Example from issue #1227:
Transaction:
0xc53e311af533dc185732c2299f7c585a8a65f8b5319ab82a1b01f03c86c3e97b66373200000000(incorrect)553110000000(correct)Root Cause
The fee was calculated as
gasPrice * gasUsed, butgasPricefrom the transaction is the "Gas Price Bid" (what user was willing to pay), not the actual price paid.On L2 networks, the actual gas price (
effectiveGasPrice) is returned in the transaction receipt and can differ significantly from the bid price.Solution
EffectiveGasPricefield toRpcReceiptstructPackTx/UnpackTxto serialize/deserialize the new fieldapi/worker.goto useeffectiveGasPricewhen available, with fallback togasPricefor older transactionsFiles Changed
bchain/types_ethereum_type.go- Added EffectiveGasPrice to RpcReceiptbchain/coins/eth/ethtx.proto- Added field to protobuf schemabchain/coins/eth/ethtx.pb.go- Regenerated protobufbchain/coins/eth/ethparser.go- Updated Pack/Unpack andGetEthereumTxDataapi/worker.go- Updated fee calculation logicTesting
Verified on Arbitrum transactions from issue #1227 - fees now match Arbiscan values.