internal/ethapi: return standardized error codes for transaction submission#35105
Draft
MysticRyuujin wants to merge 1 commit into
Draft
internal/ethapi: return standardized error codes for transaction submission#35105MysticRyuujin wants to merge 1 commit into
MysticRyuujin wants to merge 1 commit into
Conversation
…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.
Contributor
|
Blocked on ethereum/execution-apis#784 (comment). |
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.
Rationale
eth_sendTransactionandeth_sendRawTransactioncurrently return the generic-32000code 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), andTxPoolErrors(1000–1199). It mirrors the existing precedent of returning3for execution reverts.Changes
internal/ethapi/errors.go: add the catalog codes and atxSubmitErrormapper that mapscore/txpoolsentinel errors to their catalog code viaerrors.Is, preserving the original error message. Errors without a catalog code are returned unchanged (they keep the existing-32000default), so this is not a blanket behavior change.internal/ethapi/api.go: wrap theSendTxerror inSubmitTransaction(shared by both submission methods).internal/ethapi/errors_test.go: table test covering each mapped error, a wrapped variant (provingerrors.Isworks through the pool/state message wrapping), and an unmapped passthrough.ErrNonceTooLow/ErrNonceTooHighErrIntrinsicGastxpool.ErrTxGasPriceTooLowtxpool.ErrGasLimitErrTipAboveFeeCapErrGasUintOverflowErrFeeCapTooLowErrTipVeryHigh/ErrFeeCapVeryHighErrInsufficientFunds/ErrInsufficientFundsForTransfertxpool.ErrAlreadyKnowntxpool.ErrInvalidSendertxpool.ErrReplaceUnderpricedValidation
Beyond the unit tests, this was verified against the spec-conformance fixtures in ethereum/execution-apis#784: regenerating that PR's
eth_sendRawTransactionerror fixtures with this build — and the PR's temporary error-code-rewrite shim disabled — reproduces them byte-for-byte, andspeccheckpasses. That allows execution-apis#784 to drop its shim and use go-ethereum as the conformant reference for cross-clientrpc-compattesting.Out of scope
eth_simulateV1's per-call validation errors (txValidationError, currently in the-38xxxrange) are intentionally left unchanged. Aligning those to the catalog is a natural follow-up, tied to theexecute.yamlerror-groups wiring proposed in execution-apis#784, and is kept separate to keep this change focused.