Skip to content

internal/ethapi: return standardized error codes for transaction submission#35105

Draft
MysticRyuujin wants to merge 1 commit into
ethereum:masterfrom
MysticRyuujin:feat/standard-tx-error-codes
Draft

internal/ethapi: return standardized error codes for transaction submission#35105
MysticRyuujin wants to merge 1 commit into
ethereum:masterfrom
MysticRyuujin:feat/standard-tx-error-codes

Conversation

@MysticRyuujin

Copy link
Copy Markdown
Contributor

Rationale

eth_sendTransaction and eth_sendRawTransaction currently return the generic -32000 code for submission failures, so callers must string-match the error message to tell a nonce error from an underpriced replacement, insufficient funds, an over-limit gas, etc.

This wires the submission path to the standardized JSON-RPC error-code catalog that EVM clients agreed on in ethereum/execution-apis (introduced in ethereum/execution-apis#650): ExecutionErrors (1–199), GasErrors (800–999), and TxPoolErrors (1000–1199). It mirrors the existing precedent of returning 3 for execution reverts.

Changes

  • internal/ethapi/errors.go: add the catalog codes and a txSubmitError mapper that maps core/txpool sentinel errors to their catalog code via errors.Is, preserving the original error message. Errors without a catalog code are returned unchanged (they keep the existing -32000 default), so this is not a blanket behavior change.
  • internal/ethapi/api.go: wrap the SendTx error in SubmitTransaction (shared by both submission methods).
  • internal/ethapi/errors_test.go: table test covering each mapped error, a wrapped variant (proving errors.Is works through the pool/state message wrapping), and an unmapped passthrough.
core / txpool error code
ErrNonceTooLow / ErrNonceTooHigh 1 / 2
ErrIntrinsicGas 800
txpool.ErrTxGasPriceTooLow 802
txpool.ErrGasLimit 803
ErrTipAboveFeeCap 804
ErrGasUintOverflow 805
ErrFeeCapTooLow 806
ErrTipVeryHigh / ErrFeeCapVeryHigh 807 / 808
ErrInsufficientFunds / ErrInsufficientFundsForTransfer 809
txpool.ErrAlreadyKnown 1000
txpool.ErrInvalidSender 1001
txpool.ErrReplaceUnderpriced 1002

Validation

Beyond the unit tests, this was verified against the spec-conformance fixtures in ethereum/execution-apis#784: regenerating that PR's eth_sendRawTransaction error fixtures with this build — and the PR's temporary error-code-rewrite shim disabled — reproduces them byte-for-byte, and speccheck passes. That allows execution-apis#784 to drop its shim and use go-ethereum as the conformant reference for cross-client rpc-compat testing.

Out of scope

eth_simulateV1's per-call validation errors (txValidationError, currently in the -38xxx range) are intentionally left unchanged. Aligning those to the catalog is a natural follow-up, tied to the execute.yaml error-groups wiring proposed in execution-apis#784, and is kept separate to keep this change focused.

…ission

eth_sendTransaction and eth_sendRawTransaction returned the generic
-32000 code for submission failures, so callers had to string-match the
message to distinguish e.g. a nonce error from an underpriced replacement.

Map submission/pool errors to the standardized JSON-RPC error-code catalog
shared across EVM clients in ethereum/execution-apis (src/error-groups:
ExecutionErrors 1-199, GasErrors 800-999, TxPoolErrors 1000-1199), while
preserving the original error message. Errors without a catalog code are
returned unchanged, keeping the existing -32000 default.
@s1na

s1na commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Blocked on ethereum/execution-apis#784 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants