fix(ethereum): handle trace_filter traces missing result.output via c…#6535
fix(ethereum): handle trace_filter traces missing result.output via c…#6535ibrahim1023 wants to merge 3 commits intographprotocol:masterfrom
Conversation
There was a problem hiding this comment.
Thanks for the PR
A few thoughts:
-
RpcError::DeserErroralready has the failing response text on it (see alloy'stry_deserialize_ok: https://github.com/alloy-rs/alloy/blob/main/crates/json-rpc/src/result.rs#L65-L68). So you can match the variant and reusetextrather than firing a second RPC. That also gets you offto_string().contains(...), which is wider than what you actually want to catch. -
patch_missing_trace_outputprobably belongs ingraph/src/components/ethereum/json_patch.rsnext topatch_receipts.PatchingHttpalready uses that module for the same kind of thing (alloy being stricter than rust-web3 was), and putting it there means you can unit test it without spinning up a provider mock. -
On tests, a few
json!()cases for the patch fn would be nice (missing output, already set, create-style result, noresultat all), plus one that runs it on the Sonic fixture from the issue and checksVec<LocalizedTransactionTrace>actually deserializes. The mock test is fine, just a bit heavy for what it ends up asserting. -
I opened alloy-rs/alloy#3931 (issue alloy-rs/alloy#3930) for the upstream fix, same shape they used in alloy#1102 for
TraceResults.output. Once that ships and we bump alloy this whole thing goes away, so a// TODO: remove after alloy #3931would help future-us find it.
|
Thanks for the detailed review, this is all addressed now.
|
Summary
Fixes #6489
This PR fixes a regression where
trace_filterresponses fail to deserialize when a traceresultis missing theoutputfield (for example, some Sonic traces), causing repeated retries and trace ingestion failure.Root Cause
Graph Node now uses Alloy trace types for
trace_filterresponses. Some providers return traces whereresult.gasUsedis present butresult.outputis omitted. Alloy deserialization treats that as an invalidTraceOutputvariant and fails the entire response.What Changed
trace_filterrequest path unchanged for healthy responses.data did not match any variant of untagged enum TraceOutputtrace_filteras raw JSONresult.outputby injecting"output": "0x"whenresult.gasUsedexistsVec<LocalizedTransactionTrace>ethereum_adaptertests for:result.outputWhy This Is Safe
resultalready indicates execution output context (gasUsed) butoutputis omitted.Validation
Executed locally:
cargo test -p graph-chain-ethereum missing_output_trace_repro -- --nocapturecargo test -p graph-chain-ethereumResult: all tests passed (
50 passed, 0 failedforgraph-chain-ethereum).