Skip to content

Improve JSON-RPC error handling in Consensus/Execution communication#4629

Open
pmikolajczyk41 wants to merge 9 commits intomasterfrom
pmikolajczyk/nit-4738-json-rpc-errors
Open

Improve JSON-RPC error handling in Consensus/Execution communication#4629
pmikolajczyk41 wants to merge 9 commits intomasterfrom
pmikolajczyk/nit-4738-json-rpc-errors

Conversation

@pmikolajczyk41
Copy link
Copy Markdown
Member

@pmikolajczyk41 pmikolajczyk41 commented Apr 10, 2026

The consensus <-> execution RPC boundary previously relied on convertError functions that matched sentinel errors by scanning error message strings with strings.Contains. This approach was fragile (breaks on message rewording or multi-layer wrapping), incomplete (ErrSequencerInsertLockTaken was missing from the execution client; ErrRetrySequencer was missing from the consensus client), and required duplicated conversion logic in two separate clients.

What changed:

  • Introduce execution.RPCError — a struct that carries a JSON-RPC error code and implements both rpc.Error (server side, so go-ethereum embeds the code in the wire response) and a code-based Is method (in-process path). Corresponding jsonError.Is in the go-ethereum fork handles the wire path by comparing ErrorCode() values.
  • Define three sentinel errors (ErrRetrySequencer, ErrSequencerInsertLockTaken, ErrResultNotFound) and numeric constants for their codes, chosen below -32768 to avoid collision with the JSON-RPC 2.0 reserved range.
  • Remove convertError from both execution/rpcclient and consensus/consensusrpcclient; errors now propagate as-is and errors.Is matches by code.
  • Move ResultNotFound from execution/gethexec to the execution package (renamed ErrResultNotFound), removing an unnecessary import of gethexec from arbnode.

closes NIT-4738
pulls in OffchainLabs/go-ethereum#649

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.97%. Comparing base (57d9bf1) to head (d9e7609).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4629      +/-   ##
==========================================
+ Coverage   33.90%   33.97%   +0.07%     
==========================================
  Files         498      499       +1     
  Lines       59879    59870       -9     
==========================================
+ Hits        20303    20342      +39     
+ Misses      36022    35989      -33     
+ Partials     3554     3539      -15     

@github-actions
Copy link
Copy Markdown
Contributor

❌ 6 Tests Failed:

Tests completed Failed Passed Skipped
4866 6 4860 0
View the top 3 failed tests by shortest run time
TestAnyTrustRekey
Stack Traces | 11.330s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
        	/opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1934 +0xea
        created by testing.(*T).Run in goroutine 1
        	/opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1997 +0x465
        
    common_test.go:998: �[31;1m [failed to deploy ArbDebug] nonce too low: address 0x26E554a8acF9003b83495c7f45F06edCB803d4e3, tx: 1 state: 3 �[0;0m
INFO [04-10|14:47:09.945] Imported new potential chain segment     number=15 hash=14ab88..3771c9 blocks=1  txs=1  mgas=1.860  elapsed=38.506ms    mgasps=48.309   triediffs=53.02KiB  triedirty=0.00B
--- FAIL: TestAnyTrustRekey (11.33s)
WARN [04-10|14:47:09.947] Sequencer ReadFromTxQueueTimeout is higher than MaxBlockSpeed ReadFromTxQueueTimeout=1s MaxBlockSpeed=10ms
WARN [04-10|14:47:09.948] Sanitizing invalid node buffer size      provided=1024.00MiB updated=256.00MiB
INFO [04-10|14:47:09.948] Load database journal from disk
INFO [04-10|14:47:09.948] Resuming snapshot generation             root=56e81f..63b421 accounts=0 slots=0 storage=0.00B dangling=0 elapsed=12.160ms
INFO [04-10|14:47:09.948] Generated snapshot                       accounts=0 slots=0 storage=0.00B dangling=0 elapsed=12.414ms
INFO [04-10|14:47:09.950] Chain head was updated                   number=15 hash=14ab88..3771c9 root=12cdb7..7861cf elapsed=2.470359ms
WARN [04-10|14:47:09.952] error posting batch                      err="error getting latest batch metadata: batchMetadata not available for seqNum: 0 greater than head MEL state batch count: 0"
INFO [04-10|14:47:09.956] Submitted transaction                    hash=0xe078c466a3cac48685b7644f55ccbdedd18d22cba469ae5d574d89755b24f4ee from=0xaF24Ca6c2831f4d4F629418b50C227DF0885613A nonce=54  recipient=0x83Be5D4253572c11A975bcDF6998B9d4DB53c3E3 value=200,003
INFO [04-10|14:47:09.958] wrote genesis block                      number=0  hash=900eda..256170
WARN [04-10|14:47:09.958] Sanitizing invalid node buffer size      provided=1024.00MiB updated=256.00MiB
INFO [04-10|14:47:09.958] Load database journal from disk
INFO [04-10|14:47:09.958] Failed to load journal, discard it       err="journal not found"
INFO [04-10|14:47:09.958] Submitted transaction                    hash=0x0ecc43a6f4c051c998453a2cec2658afb396169afea36322e3a5b0fa2e1ad33e from=0xb386a74Dcab67b66F8AC07B4f08365d37495Dd23 nonce=0   recipient=0x8310D695B6879978f435a315c42fe7455e5F1Cb0 value=0
TestRetryableFilteringFanoutAutoRedeemDirtyLast
Stack Traces | 15.920s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
INFO [04-10|14:48:39.904] Updated payload                          id=0x03b4ccca65d2bad2 number=543 hash=a5189a..d5e4a1 txs=0  withdrawals=0 gas=0          fees=0              root=2493bc..8fcc2f elapsed=1.387ms
INFO [04-10|14:48:39.905] Imported new potential chain segment     number=314 hash=6e0ef3..45bd05 blocks=1  txs=0  mgas=0.000  elapsed=1.448ms      mgasps=0.000    triediffs=737.00KiB triedirty=144.86KiB
INFO [04-10|14:48:39.905] Chain head was updated                   number=314 hash=6e0ef3..45bd05 root=5de673..aba1be elapsed="47.091µs"
INFO [04-10|14:48:39.907] Stopping work on payload                 id=0x03b4ccca65d2bad2 reason=delivery
INFO [04-10|14:48:39.910] Imported new potential chain segment     number=543 hash=a5189a..d5e4a1 blocks=1  txs=0  mgas=0.000  elapsed=5.223ms      mgasps=0.000    triediffs=805.34KiB triedirty=298.94KiB
INFO [04-10|14:48:39.910] Chain head was updated                   number=543 hash=a5189a..d5e4a1 root=2493bc..8fcc2f elapsed="60.241µs"
INFO [04-10|14:48:39.911] Submitted transaction                    hash=0xfbea06ec710b158e20803d1ce9ccc5852f62cba6ae1a951e15486bf5ba849048 from=0xaF24Ca6c2831f4d4F629418b50C227DF0885613A nonce=60  recipient=0xaF24Ca6c2831f4d4F629418b50C227DF0885613A value=1,000,000,000,000
INFO [04-10|14:48:39.916] Starting work on payload                 id=0x030206735d7442a7
INFO [04-10|14:48:39.918] Updated payload                          id=0x030206735d7442a7 number=106 hash=dd703d..352526 txs=1  withdrawals=0 gas=21000      fees=0.002099997271 root=da53ec..d3cf6c elapsed=1.252ms
INFO [04-10|14:48:39.919] Stopping work on payload                 id=0x030206735d7442a7 reason=delivery
INFO [04-10|14:48:39.920] Imported new potential chain segment     number=106 hash=dd703d..352526 blocks=1  txs=1  mgas=0.021  elapsed=2.080ms      mgasps=10.092   triediffs=473.79KiB triedirty=0.00B
INFO [04-10|14:48:39.920] Chain head was updated                   number=106 hash=dd703d..352526 root=da53ec..d3cf6c elapsed="72.849µs"
INFO [04-10|14:48:39.922] Submitted transaction                    hash=0xeeb701b0f2d083ff17d2f2d4aabc71960b4fc4ab3d246993ba9e446cee08c193 from=0xaF24Ca6c2831f4d4F629418b50C227DF0885613A nonce=55  recipient=0xaF24Ca6c2831f4d4F629418b50C227DF0885613A value=1,000,000,000,000
INFO [04-10|14:48:39.923] Transaction pool stopped
INFO [04-10|14:48:39.923] Persisting dirty state                   head=31  root=6a7fab..fa9a53 layers=31
INFO [04-10|14:48:39.924] Starting work on payload                 id=0x03bd344574cdd2ed
INFO [04-10|14:48:39.925] Persisted dirty state to disk            size=148.46KiB  elapsed=2.501ms
INFO [04-10|14:48:39.926] Blockchain stopped
INFO [04-10|14:48:39.926] Submitted transaction                    hash=0x813a33a843ca4628029195ee8b7a0735b1960f6100084189e40f5df0699ef48d from=0xaF24Ca6c2831f4d4F629418b50C227DF0885613A nonce=185 recipient=0x7E23C8862920797d81916d62c274dd9217113e28 value=1
--- FAIL: TestRetryableFilteringFanoutAutoRedeemDirtyLast (15.92s)
TestStakersCooperative
Stack Traces | 17.450s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
DEBUG[04-10|14:41:53.494] Journaled pathdb diff layer              root=c3387c..d032e8 parent=43dba4..1c6d63 id=434                block=433
DEBUG[04-10|14:41:53.494] Journaled pathdb diff layer              root=af0680..df57dd parent=c3387c..d032e8 id=435                block=434
DEBUG[04-10|14:41:53.494] Journaled pathdb diff layer              root=c95b09..0b5526 parent=af0680..df57dd id=436                block=435
DEBUG[04-10|14:41:53.494] Journaled pathdb diff layer              root=7192e0..5e00b2 parent=c95b09..0b5526 id=437                block=436
DEBUG[04-10|14:41:53.494] Journaled pathdb diff layer              root=806881..4a2835 parent=7192e0..5e00b2 id=438                block=437
DEBUG[04-10|14:41:53.494] Journaled pathdb diff layer              root=2e918f..9ecbc5 parent=806881..4a2835 id=439                block=438
DEBUG[04-10|14:41:53.494] Journaled pathdb diff layer              root=d38008..bd83be parent=2e918f..9ecbc5 id=440                block=439
INFO [04-10|14:41:53.495] Persisted dirty state to disk            size=929.14KiB elapsed=17.857ms
INFO [04-10|14:41:53.523] Blockchain stopped
TRACE[04-10|14:41:53.524] P2P networking is spinning down
DEBUG[04-10|14:41:53.524] Dereferenced trie from memory database   nodes=23  size=5.22KiB   time=17.90441ms  gcnodes=3445 gcsize=774.52KiB gctime=28.361119ms livenodes=0    livesize=0.00B
DEBUG[04-10|14:41:53.524] RPC server shutting down
DEBUG[04-10|14:41:53.524] RPC connection read error                err="read tcp 127.0.0.1:44097-&gt;127.0.0.1:57900: use of closed network connection"
DEBUG[04-10|14:41:53.524] RPC connection read error                err="websocket: close 1006 (abnormal closure): unexpected EOF"
DEBUG[04-10|14:41:53.524] RPC connection read error                err="read tcp 127.0.0.1:44097-&gt;127.0.0.1:57910: use of closed network connection"
INFO [04-10|14:41:53.524] HTTP server stopped                      endpoint=127.0.0.1:44097
DEBUG[04-10|14:41:53.524] RPC server shutting down
TRACE[04-10|14:41:53.524] P2P networking is spinning down
DEBUG[04-10|14:41:53.524] RPC connection read error                err="websocket: close 1006 (abnormal closure): unexpected EOF"
--- FAIL: TestStakersCooperative (17.45s)

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants