11use std:: { collections:: BTreeSet , sync:: Arc } ;
22
33use futures:: TryFutureExt ;
4- use miden_node_utils:: { ErrorReport , FlattenResult , tracing:: OpenTelemetrySpanExt } ;
4+ use miden_node_utils:: { ErrorReport , tracing:: OpenTelemetrySpanExt } ;
55use miden_objects:: {
66 TransactionInputError , Word ,
77 account:: { Account , AccountId } ,
@@ -20,7 +20,7 @@ use miden_tx::{
2020} ;
2121use rand:: seq:: SliceRandom ;
2222use tokio:: task:: JoinError ;
23- use tracing:: instrument;
23+ use tracing:: { Instrument , instrument, instrument :: Instrumented } ;
2424
2525use crate :: { COMPONENT , block_producer:: BlockProducerClient , state:: TransactionCandidate } ;
2626
@@ -71,32 +71,42 @@ impl NtxContext {
7171
7272 // Work-around for `TransactionExecutor` not being `Send`.
7373 tokio:: task:: spawn_blocking ( move || {
74- let rt = tokio:: runtime:: Builder :: new_current_thread ( )
75- . enable_all ( )
76- . build ( )
77- . expect ( "runtime should be built" ) ;
78-
79- rt. block_on ( async move {
80- let mut notes = notes
81- . into_iter ( )
82- . map ( |note| InputNote :: Unauthenticated { note : note. into ( ) } )
83- . collect :: < Vec < _ > > ( ) ;
84- // We shuffle the notes here to prevent having a failing note always in front.
85- notes. shuffle ( & mut rand:: rng ( ) ) ;
86- let notes = InputNotes :: new ( notes) . map_err ( NtxError :: InputNotes ) ?;
87-
88- let data_store = NtxDataStore :: new ( account, self . genesis_header . clone ( ) ) ;
89-
90- self . filter_notes ( & data_store, notes)
91- . and_then ( |notes| self . execute ( & data_store, notes) )
92- . and_then ( |tx| self . prove ( tx) )
93- . and_then ( |tx| self . submit ( tx) )
94- . await
95- } )
74+ {
75+ {
76+ let rt = tokio:: runtime:: Builder :: new_current_thread ( )
77+ . enable_all ( )
78+ . build ( )
79+ . expect ( "runtime should be built" ) ;
80+
81+ rt. block_on (
82+ async move {
83+ let mut notes = notes
84+ . into_iter ( )
85+ . map ( |note| InputNote :: Unauthenticated { note : note. into ( ) } )
86+ . collect :: < Vec < _ > > ( ) ;
87+ // We shuffle the notes here to prevent having a failing note always in
88+ // front.
89+ notes. shuffle ( & mut rand:: rng ( ) ) ;
90+ let notes = InputNotes :: new ( notes) . map_err ( NtxError :: InputNotes ) ?;
91+
92+ let data_store =
93+ NtxDataStore :: new ( account, self . genesis_header . clone ( ) ) ;
94+
95+ self . filter_notes ( & data_store, notes)
96+ . and_then ( |notes| self . execute ( & data_store, notes) )
97+ . and_then ( |tx| self . prove ( tx) )
98+ . and_then ( |tx| self . submit ( tx) )
99+ . await
100+ }
101+ . in_current_span ( ) ,
102+ )
103+ }
104+ }
105+ . in_current_span ( )
96106 } )
97- . map_err ( NtxError :: Panic )
98107 . await
99- . flatten_result ( )
108+ . map_err ( NtxError :: Panic )
109+ . and_then ( Instrumented :: into_inner)
100110 . inspect_err ( |err| tracing:: Span :: current ( ) . set_error ( err) )
101111 }
102112
0 commit comments