fix(eth_call): return descriptive error when maxFeePerGas is below block base fee #11190
Conversation
|
@claude review |
|
@svlachakis can you check this? |
|
@claude review |
|
Claude finished @DarkLord017's task in 3m 12s —— View job Code Review
The fix is correct and well-scoped. The Issue 1 — Redundant ternary in
|
|
| public static TransactionResult CreateMinerPremiumNegative(Transaction tx, in UInt256 baseFee) | ||
| { | ||
| string detail = $"err: max fee per gas less than block base fee: address {tx.SenderAddress?.ToString() ?? "unknown"}, maxFeePerGas: {tx.MaxFeePerGas}, baseFee: {baseFee} (supplied gas {tx.GasLimit})"; | ||
| return new TransactionResult(ErrorType.MinerPremiumNegative) { SubstateError = detail }; |
There was a problem hiding this comment.
maybe define it as a private const above Error Description(line like just so that all error messages are together (line 1052)
private const string MinerPremiumNegativeMessageTemplate =
"err: max fee per gas less than block base fee: address {0}, maxFeePerGas: {1}, baseFee: {2} (supplied gas {3})";There was a problem hiding this comment.
The suggestion is reasonable for grouping, but since this
template is used exactly once, extracting it to a private const
adds ceremony without real benefit:
- A
private constwith{0}..{3}placeholders forces
string.Formatwhich is less readable than the inline
interpolated string we have now. - The coding style prefers not extracting one-off operations into
abstractions. - The other messages in
ErrorDescriptionare inline literals
too ,making this one a named const would be inconsistent with
the rest of the switch.
Happy to change it if there's a stronger reason (e.g. the
template is reused elsewhere), but for a single callsite the
interpolated string inline is cleaner.
|
@claude review |
|
Claude finished @DarkLord017's task in 2m 15s —— View job Code Review
The previous issues (1–3) have been addressed correctly. Here's a focused review of the current state. Addressed from previous review ✅
Issue 1 — DarkLord017's
|
| Assert.That(callOutput.Error, Is.EqualTo("miner premium is negative")); | ||
| } | ||
|
|
||
| [Test] |
There was a problem hiding this comment.
Shoud I collapse the 4 tests into 2 using a shared
[TestCaseSource] ?
There was a problem hiding this comment.
Done,
I have collapsed 4 individual tests - 2 [TestCaseSource] tests sharing a single MinerPremiumNegativeCases() source
Source yields two cases: Fallback (static field, "miner premium is negative") and Descriptive (factory, Geth-style message)
Both Call_tx_returns_MinerPremiumIsNegativeError and EstimateGas_tx_returns_MinerPremiumIsNegativeError consume the same source — the only difference between them is which bridge method they call
Added using System.Collections.Generic for IEnumerable<TestCaseData>
…eePerGas validation
|
@svlachakis, |
|
@divi2806 tests need to pass, looks like there are failures.. |
|
Thankyou @svlachakis , ("TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS", "max fee
per gas less than block base fee"), |
|
@claude re-review |
|
Claude finished @svlachakis's task in 1m 54s —— View job Code Review
All previously raised blockers are resolved. Here's the focused review of the current state. Addressed from previous reviews ✅
Issue 1 — Magic address literal (low)
Issue 2 —
|
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
|
@LukaszRozmej @svlachakis, is the PR good to be merged? |
|
LGTM |
|
cool, thanks. |
|
@LukaszRozmej the json rpc error is because of this issue? |
Fixes #11177
Changes
TransactionResult.CreateMinerPremiumNegative(Transaction tx, UInt256 baseFee)factory method that builds aGeth-compatible error message including the sender address,
provided fee cap, block base fee, and supplied gas
TransactionResult.ErrorDescriptionforMinerPremiumNegativeto use the contextual message whenavailable, falling back to
"miner premium is negative"forcases without context
TransactionProcessor.BuyGasto useCreateMinerPremiumNegativeinstead of the static field soeth_callandeth_estimateGasreturn the descriptive messageOptimismTransactionProcessor.BuyGaswith the same fixboth
eth_callandeth_estimateGaspathsTypes of changes
What types of changes does your code introduce?
functionality not to work as expected)
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Added
Call_tx_returns_descriptive_MinerPremiumIsNegativeErrorand
EstimateGas_tx_returns_descriptive_MinerPremiumIsNegativeErrorin
Nethermind.Facade.Test/BlockchainBridgeTests.cs. Existingtests covering the static fallback message continue to pass.
Documentation
Requires documentation update
Requires explanation in Release Notes
eth_callandeth_estimateGasnow return a Geth-compatibleerror message when
maxFeePerGas(orgasPrice) is below theblock base fee, e.g.:
err: max fee per gas less than block base fee: address 0x..., maxFeePerGas: 140000000000, baseFee: 146283608928 (supplied gas 56786)