Skip to content

Commit cd606d2

Browse files
lupin012Sahil-4555
andauthored
[3.5] rpc: cherry-pick fix base fee too low error code (#21418) (#21902)
NethermindEth/nethermind#11412 Closes: #21239 update also Hive/execution-apis refs --------- --------- Co-authored-by: Sahil Sojitra <88416181+Sahil-4555@users.noreply.github.com>
1 parent ebfa613 commit cd606d2

6 files changed

Lines changed: 49 additions & 6 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"hive_ref": "15750c964cf8dec6f793447ee830f4a483eafcd5",
3-
"execution_apis_ref": "8d6b784cc57047ef10e4044ec2efc1c60950dd7f"
2+
"hive_ref": "88c3e1ab1c9a6d6183b6e7e88df5981bbedf81aa",
3+
"execution_apis_ref": "c27d979e4880ea33bf551eccb16045ebb2e1e2bc"
44
}

.github/workflows/test-hive.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ jobs:
6868
exec_mode: parallel
6969
- sim: ethereum/rpc-compat
7070
sim-limit: ".*"
71-
max-allowed-failures: 0
71+
max-allowed-failures: 1
7272
exec_mode: serial
7373
- sim: ethereum/rpc-compat
7474
sim-limit: ".*"
75-
max-allowed-failures: 0
75+
max-allowed-failures: 1
7676
exec_mode: parallel
7777
- sim: devp2p
7878
sim-limit: eth

ChangeLog.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## [3.6.0]
4+
5+
### Breaking Changes
6+
7+
#### `eth_simulateV1`: base fee too low error code corrected to `-38012`
8+
9+
Aligns Erigon with the `eth_simulateV1` error code specification ([NethermindEth/nethermind#11412](https://github.com/NethermindEth/nethermind/issues/11412)).
10+
11+
**What changed:**
12+
13+
| Aspect | Before | After |
14+
|---|---|---|
15+
| `ErrFeeCapTooLow` error code | `-32602` (generic "Invalid params") | `-38012` (spec-mandated "baseFeePerGas is too low") |
16+
17+
**Migration:**
18+
19+
- If your tooling matches on error code `-32602` to detect base-fee-too-low conditions in `eth_simulateV1` responses, update it to match `-38012` instead.
20+
21+
---
22+
323
## [3.5.0] "Tidal Tails" – TBD
424

525
Erigon 3.5.0 is a major release headlined by **parallel block execution becoming the default** and **initial support for Ethereum's upcoming Glamsterdam hardfork**. It is a drop-in upgrade for 3.4.x users — no re-sync required; existing datadirs upgrade their prune configuration automatically (see Breaking Changes).

rpc/errors.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ var (
3636
)
3737

3838
const (
39-
ErrCodeNonceTooHigh = -38011
4039
ErrCodeNonceTooLow = -38010
40+
ErrCodeNonceTooHigh = -38011
41+
ErrCodeBaseFeeTooLow = -38012
4142
ErrCodeIntrinsicGas = -38013
4243
ErrCodeInsufficientFunds = -38014
4344
ErrCodeBlockGasLimitReached = -38015

rpc/jsonrpc/eth_simulation.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,9 @@ func txValidationError(err error) error {
925925
case errors.Is(err, protocol.ErrTipAboveFeeCap):
926926
return &rpc.CustomError{Message: err.Error(), Code: rpc.ErrCodeInvalidParams}
927927
case errors.Is(err, protocol.ErrFeeCapTooLow):
928-
return &rpc.CustomError{Message: err.Error(), Code: rpc.ErrCodeInvalidParams}
928+
// "fee cap too low" means maxFeePerGas is below the current baseFee,
929+
// which the RPC API reports as "base fee too low".
930+
return &rpc.CustomError{Message: err.Error(), Code: rpc.ErrCodeBaseFeeTooLow}
929931
case errors.Is(err, protocol.ErrInsufficientFunds):
930932
return &rpc.CustomError{Message: err.Error(), Code: rpc.ErrCodeInsufficientFunds}
931933
case errors.Is(err, protocol.ErrIntrinsicGas):

rpc/jsonrpc/eth_simulation_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/erigontech/erigon/db/datadir"
2020
"github.com/erigontech/erigon/db/kv/rawdbv3"
2121
"github.com/erigontech/erigon/execution/chain"
22+
"github.com/erigontech/erigon/execution/protocol"
2223
"github.com/erigontech/erigon/execution/types"
2324
"github.com/erigontech/erigon/execution/vm/evmtypes"
2425
"github.com/erigontech/erigon/rpc"
@@ -419,6 +420,25 @@ func TestTxValidationErrorNil(t *testing.T) {
419420
assert.Nil(t, txValidationError(nil))
420421
}
421422

423+
// TestTxValidationErrorBaseFeeTooLow verifies that txValidationError maps
424+
// ErrFeeCapTooLow to ErrCodeBaseFeeTooLow (-38012) as required by the Ethereum
425+
// execution API specification for eth_simulateV1.
426+
//
427+
// Regression guard: this mapping was previously incorrect (returned the generic
428+
// -32602 "Invalid params" code) and was corrected to -38012. This test prevents
429+
// silent regression if the mapping is accidentally reverted in a future refactor.
430+
func TestTxValidationErrorBaseFeeTooLow(t *testing.T) {
431+
err := fmt.Errorf("%w: address 0x1, feeCap: 0 baseFee: 7", protocol.ErrFeeCapTooLow)
432+
433+
result := txValidationError(err)
434+
435+
var customErr *rpc.CustomError
436+
require.ErrorAs(t, result, &customErr)
437+
assert.Equal(t, rpc.ErrCodeBaseFeeTooLow, customErr.Code,
438+
"ErrFeeCapTooLow must map to ErrCodeBaseFeeTooLow (-38012), not ErrCodeInvalidParams (-32602)")
439+
assert.Equal(t, err.Error(), customErr.Message)
440+
}
441+
422442
// ─── error helper tests ──────────────────────────────────────────────────────
423443

424444
func TestErrorHelpers(t *testing.T) {

0 commit comments

Comments
 (0)