12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- use core:: { fmt:: Debug , mem:: take, str:: from_utf8} ;
16
- use std:: collections:: HashSet ;
17
-
18
15
use alloy_consensus:: { constants:: BEACON_ROOTS_ADDRESS , TxEnvelope } ;
19
16
use alloy_primitives:: { TxKind , U256 } ;
20
17
use anyhow:: { anyhow, bail, ensure, Context , Error , Result } ;
18
+ use core:: { fmt:: Debug , mem:: take, str:: from_utf8} ;
21
19
#[ cfg( feature = "std" ) ]
22
20
use log:: debug;
23
21
use revm:: {
@@ -28,6 +26,8 @@ use revm::{
28
26
} ,
29
27
taiko, Database , DatabaseCommit , Evm , JournaledState ,
30
28
} ;
29
+ use std:: collections:: HashSet ;
30
+ use tracing:: trace;
31
31
cfg_if:: cfg_if! {
32
32
if #[ cfg( feature = "tracer" ) ] {
33
33
use std:: { fs:: { OpenOptions , File } , io:: { BufWriter , Write } , sync:: { Arc , Mutex } } ;
@@ -48,7 +48,6 @@ use crate::{
48
48
print_duration,
49
49
time:: { AddAssign , Duration , Instant } ,
50
50
utils:: { check_anchor_tx, generate_transactions} ,
51
- Measurement ,
52
51
} ;
53
52
54
53
/// Minimum supported protocol version: SHANGHAI
@@ -83,7 +82,7 @@ impl TxExecStrategy for TkoTxExecStrategy {
83
82
let chain_spec = & block_builder. input . chain_spec ;
84
83
let chain_id = chain_spec. chain_id ( ) ;
85
84
let is_taiko = chain_spec. is_taiko ( ) ;
86
- println ! ( "spec_id: {spec_id:?}" ) ;
85
+ trace ! ( "spec_id: {spec_id:?}" ) ;
87
86
88
87
// generate the transactions from the tx list
89
88
// For taiko blocks, insert the anchor tx as the first transaction
@@ -176,7 +175,11 @@ impl TxExecStrategy for TkoTxExecStrategy {
176
175
let mut actual_tx_no = 0usize ;
177
176
let num_transactions = transactions. len ( ) ;
178
177
for ( tx_no, tx) in take ( & mut transactions) . into_iter ( ) . enumerate ( ) {
179
- inplace_print ( & format ! ( "\r processing tx {tx_no}/{num_transactions}..." ) ) ;
178
+ if !is_optimistic {
179
+ inplace_print ( & format ! ( "\r processing tx {tx_no}/{num_transactions}..." ) ) ;
180
+ } else {
181
+ trace ! ( "\r processing tx {tx_no}/{num_transactions}..." ) ;
182
+ }
180
183
181
184
#[ cfg( feature = "tracer" ) ]
182
185
let trace = set_trace_writer (
@@ -284,7 +287,7 @@ impl TxExecStrategy for TkoTxExecStrategy {
284
287
}
285
288
} ;
286
289
#[ cfg( feature = "std" ) ]
287
- debug ! ( " Ok: {result:?}" ) ;
290
+ trace ! ( " Ok: {result:?}" ) ;
288
291
289
292
#[ cfg( feature = "tracer" ) ]
290
293
// Flush the trace writer
@@ -332,14 +335,15 @@ impl TxExecStrategy for TkoTxExecStrategy {
332
335
333
336
tx_misc_duration. add_assign ( start. elapsed ( ) ) ;
334
337
}
335
- clear_line ( ) ;
336
- print_duration ( "Tx transact time: " , tx_transact_duration) ;
337
- print_duration ( "Tx misc time: " , tx_misc_duration) ;
338
+ if !is_optimistic {
339
+ clear_line ( ) ;
340
+ print_duration ( "Tx transact time: " , tx_transact_duration) ;
341
+ print_duration ( "Tx misc time: " , tx_misc_duration) ;
342
+ }
338
343
339
344
let mut db = & mut evm. context . evm . db ;
340
345
341
346
// process withdrawals unconditionally after any transactions
342
- let measurement = Measurement :: start ( "Processing withdrawals..." , true ) ;
343
347
let mut withdrawals_trie = MptNode :: default ( ) ;
344
348
for ( i, withdrawal) in block_builder. input . withdrawals . iter ( ) . enumerate ( ) {
345
349
// the withdrawal amount is given in Gwei
@@ -354,10 +358,8 @@ impl TxExecStrategy for TkoTxExecStrategy {
354
358
. insert_rlp ( & i. to_rlp ( ) , withdrawal)
355
359
. with_context ( || "failed to insert withdrawal" ) ?;
356
360
}
357
- measurement. stop ( ) ;
358
361
359
362
// Update result header with computed values
360
- let measurement = Measurement :: start ( "Generating block header..." , true ) ;
361
363
header. transactions_root = tx_trie. hash ( ) ;
362
364
header. receipts_root = receipt_trie. hash ( ) ;
363
365
header. logs_bloom = logs_bloom;
@@ -368,7 +370,6 @@ impl TxExecStrategy for TkoTxExecStrategy {
368
370
if spec_id >= SpecId :: CANCUN {
369
371
header. blob_gas_used = Some ( blob_gas_used. into ( ) ) ;
370
372
}
371
- measurement. stop ( ) ;
372
373
373
374
// Leak memory, save cycles
374
375
guest_mem_forget ( [ tx_trie, receipt_trie, withdrawals_trie] ) ;
0 commit comments