feat(evmrpc): render unavailable blocks the way geth does - #4107
Draft
alexander-sei wants to merge 1 commit into
Draft
feat(evmrpc): render unavailable blocks the way geth does#4107alexander-sei wants to merge 1 commit into
alexander-sei wants to merge 1 commit into
Conversation
Block, receipt and state lookups return one typed condition, ethrpcerrors.BlockUnavailable, and each endpoint family renders it the way go-ethereum does: null from the block-fetch endpoints, "header not found" / "header for hash not found" from the state-backed ones, "unknown block" from eth_getLogs, "request beyond head block" from eth_feeHistory, go-ethereum's own "block #N not found" from the tracers, and "4444 pruned history unavailable" for pruned history. Pruned state renders as the "missing trie node" class with Sei's height as the detail. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## rfc-009-geth-error-parity #4107 +/- ##
=============================================================
+ Coverage 60.28% 60.29% +0.01%
=============================================================
Files 2088 2089 +1
Lines 180580 180581 +1
=============================================================
+ Hits 108854 108877 +23
+ Misses 61584 61572 -12
+ Partials 10142 10132 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Describe your changes and provide context
Second slice of RFC 009, stacked on #4102 (base branch
rfc-009-geth-error-parity): the block-resolution choke point behind everyeth_*/debug_*endpoint that takes a block identifier.Today the watermark manager and the Tendermint block lookups build a finished Sei message (
requested height N is not yet available; safe latest is M: …,block not found by hash,evm module does not exist on height N, …) at the point of detection, and that one string then leaks into every endpoint family unchanged. go-ethereum renders the same condition differently per family:nullfrom the endpoints that return a block or something inside one,header not found/header for hash not foundfrom the state-backed ones,unknown blockfrometh_getLogs,request beyond head blockfrometh_feeHistory,block #N not foundfrom the tracers, and (since v1.16)4444 pruned history unavailablefor pruned history.This PR makes the producers return one typed condition,
*ethrpcerrors.BlockUnavailable, and each endpoint family render it at its own entry point.ethrpcerrors.BlockUnavailablewith reasonsErrBlockAboveLatest,ErrBlockUnknownHash,ErrBlockNotFound,ErrHistoryPruned,ErrStatePruned;Detail()keeps the heights for logs and tests, the wire message does not (go-ethereum's does not either).WatermarkManager.ResolveHeight/EnsureBlockHeightAvailable/EnsureReceiptHeightAvailable,blockByNumberWithRetry/blockByHashWithRetry,CheckVersion.IsBlockMissing(block-fetch family →null), the condition's ownError()plusForState(state family),ForLogs(eth_getLogs),BeyondHead(eth_feeHistory), and a nil block fromBackend.BlockByNumber/BlockByHashso go-ethereum's tracer API emits its ownblock #N not found.evmrpc/AGENTS.mdgains the family table and the rules that keep it true.Client-visible changes
eth_call,eth_estimateGas,eth_createAccessList,eth_getBalance,eth_getCode,eth_getStorageAt,eth_getTransactionCount-32000 requested height N is not yet available; safe latest is M: block height not yet available-32000 header not found-32000 block not found by hash-32000 header for hash not found-32000 requested height N has been pruned…/evm module does not exist on height N-32000 missing trie node: state at height N is not available[; earliest available is M]eth_getBlockBy*,eth_getBlockReceipts,eth_getBlockTransactionCountBy*,eth_getTransactionByBlock*AndIndex-32000 could not find block for height …null-32000 requested height N has been pruned…/…receipts have been pruned…4444 pruned history unavailableeth_getLogsblockHash[]-32000 unknown blocketh_getLogs-32000 requested fromBlock N is before earliest available block M4444 pruned history unavailableeth_feeHistory-32000 requested last block N is not yet available; safe latest is M-32000 request beyond head block: requested N, head Meth_feeHistory-32000 requested last block is before earliest available height4444 pruned history unavailabledebug_traceBlockBy*,debug_traceCall-32000 block #N not found/block 0x… not found(go-ethereum's own)Decisions for review
4444 pruned history unavailableis go-ethereum'shistory.PrunedHistoryError(v1.16, where history expiry landed;go.modalready requires v1.16.8 before the fork replace). RFC 009 said "no new JSON-RPC error codes"; this is go-ethereum's code, not a Sei one, but it is new to Sei's surface. Alternative: keep-32000with the same text.missing trie nodeis the prefix of the trie error go-ethereum's state endpoints return when the state at a kept header is gone, with Sei's height in place of the node and root hashes. Sei has no trie (evmrpc/AGENTS.md), so this follows the RFC's nearest-sentinel rule rather than describing Sei. Alternative:header not foundfor pruned state too, which loses the "you need an archive node" signal indexers key on.eth_getLogswith an unknownblockHashmoves from[]to-32000 unknown block. The empty array was silently wrong; go-ethereum has always errored here.ComputeBlockBounds(fromBlockabovetoBlock, a range past the head) are not availability conditions and keep their text;invalid block range paramsand geth's clamp-to-head are separate follow-ups.Not in this PR (from the parity audit)
eth_callbare-revert()code 3 +data: "0x";debug_traceTransactionunknown hash →transaction not found(todaytransaction indexing is in progress);eth_getTransactionReceiptfailed to find transaction in block→null;RPCContextProviderpanic onCreateQueryContextfailure;eth_syncing→false,eth_blobBaseFee→ value;filter does not exist→filter not found;eth_feeHistorypercentile messages;PrepareTxante text ondebug_trace*; uncle/header/raw-tx/txpool_*/net_*/web3_sha3inventory;.iox@ expect_error_*directives for the non-send endpoints.Testing performed to validate your change
go test ./evmrpc/ ./evmrpc/tests/ ./evmrpc/ethrpcerrors/ -count=1(full suites, green;scripts/ramtest.shfor the focused subset)evmrpc/ethrpcerrors/block_test.go: golden table per reason,IsBlockMissing/ForLogs/ForState/BeyondHead, Sei-vocabulary negative assertion, JSON-RPC round trip through go-ethereum'srpc.Serverpinning4444survives only when the error is the top-level returnwatermark_manager_test.go,height_availability_test.go,filter_bounds_test.go,info_test.go,tests/state_test.go)integration_test/rpc_tests: the four[divergence]cases this covers (eth_callfar-future and unknown hash,eth_estimateGasfar-future,eth_feeHistoryfar-future) are nowexpectSameErrorparity tests;eth_getTransactionCountfar-future became a parity test;EARLY_STATE_ERRORfollows the new state text;npx tsc --noEmitcleancontracts/test/lib.jstryGetReceiptmatches the new text;node --checkcleango build ./...,go veton the changed packages,make fmtcheck(clean), scopedgolangci-lint run ./evmrpc/...