1- use std:: result;
2-
31use alloy:: {
4- primitives:: B256 ,
5- providers:: { ext:: DebugApi as _, Provider } ,
6- rpc:: types:: eth:: BlockId ,
7- transports:: Transport ,
2+ primitives:: B256 , providers:: Provider , rpc:: types:: eth:: BlockId , transports:: Transport ,
83} ;
94use anyhow:: Context as _;
10- use futures:: future :: join_all ;
5+ use futures:: try_join ;
116use prover:: BlockProverInput ;
127use serde:: Deserialize ;
138use serde_json:: json;
149use trace_decoder:: { BlockTrace , BlockTraceTriePreImages , CombinedPreImages , TxnInfo , TxnMeta } ;
1510
1611use super :: fetch_other_block_data;
17- use crate :: { native:: txn:: { generate_jumpdest_table, structlog_tracing_options} , provider:: CachedProvider } ;
12+ use crate :: {
13+ native:: { self } ,
14+ provider:: CachedProvider ,
15+ } ;
1816
1917/// Transaction traces retrieved from Erigon zeroTracer.
2018#[ derive( Debug , Deserialize ) ]
4139 "debug_traceBlockByNumber" . into ( ) ,
4240 ( target_block_id, json ! ( { "tracer" : "zeroTracer" } ) ) ,
4341 )
44- . await ?;
42+ . await ?
43+ . into_iter ( )
44+ . map ( |ztr| ztr. result )
45+ . collect :: < Vec < _ > > ( ) ;
4546
4647 // Grab block witness info (packed as combined trie pre-images)
4748 let block_witness = cached_provider
@@ -50,48 +51,48 @@ where
5051 . raw_request :: < _ , String > ( "eth_getWitness" . into ( ) , vec ! [ target_block_id] )
5152 . await ?;
5253
53- let other_data =
54- fetch_other_block_data ( cached_provider, target_block_id, checkpoint_state_trie_root)
55- . await ?;
56-
57- let prov = cached_provider. get_provider ( ) . await ?;
58- let structlog_futs = tx_results. into_iter ( ) . map (
59- |ZeroTxResult {
60- tx_hash,
61- result :
62- TxnInfo {
63- traces,
64- meta :
65- TxnMeta {
66- byte_code,
67- new_receipt_trie_node_byte,
68- gas_used,
69- jumpdest_table,
70- } ,
71- } ,
72- } | {
73- let structlog_trace =
74- prov. debug_trace_transaction ( tx_hash, structlog_tracing_options ( ) ) . await ?;
75- let tx = todo ! ( ) ;
76- let jdt_opt =
77- generate_jumpdest_table ( tx, structlog_trace, traces)
78- . map ( Some )
79- . unwrap_or_default ( ) ;
54+ // This is wasteful
55+ let ( native_block_trace, _native_other_data) = try_join ! (
56+ native:: process_block_trace( cached_provider. clone( ) , target_block_id) ,
57+ crate :: fetch_other_block_data(
58+ cached_provider. clone( ) ,
59+ target_block_id,
60+ checkpoint_state_trie_root,
61+ )
62+ ) ?;
8063
81- ZeroTxResult {
82- tx_hash,
83- result : TxnInfo {
64+ // weave in the JDTs
65+ let txn_info = tx_results
66+ . into_iter ( )
67+ . zip ( native_block_trace. txn_info )
68+ . map (
69+ |(
70+ TxnInfo {
8471 traces,
85- meta : TxnMeta {
86- byte_code,
87- new_receipt_trie_node_byte,
88- gas_used,
89- jumpdest_table : jdt_opt,
90- } ,
72+ meta :
73+ TxnMeta {
74+ byte_code,
75+ new_receipt_trie_node_byte,
76+ gas_used,
77+ jumpdest_table : _,
78+ } ,
9179 } ,
92- }
93- } ,
94- ) ;
80+ ntx,
81+ ) | TxnInfo {
82+ traces,
83+ meta : TxnMeta {
84+ byte_code,
85+ new_receipt_trie_node_byte,
86+ gas_used,
87+ jumpdest_table : ntx. meta . jumpdest_table ,
88+ } ,
89+ } ,
90+ )
91+ . collect ( ) ;
92+
93+ let other_data =
94+ fetch_other_block_data ( cached_provider, target_block_id, checkpoint_state_trie_root)
95+ . await ?;
9596
9697 // Assemble
9798 Ok ( BlockProverInput {
@@ -100,7 +101,7 @@ where
100101 compact : hex:: decode ( block_witness. strip_prefix ( "0x" ) . unwrap_or ( & block_witness) )
101102 . context ( "invalid hex returned from call to eth_getWitness" ) ?,
102103 } ) ,
103- txn_info : tx_results . into_iter ( ) . map ( |it| it . result ) . collect ( ) ,
104+ txn_info,
104105 code_db : Default :: default ( ) ,
105106 } ,
106107 other_data,
0 commit comments