@@ -13,7 +13,7 @@ use pretty_bytes_rust::{pretty_bytes, PrettyBytesOptions};
1313use serde:: Serialize ;
1414use sim_core:: {
1515 clock:: Timestamp ,
16- config:: { NodeId , SimConfiguration } ,
16+ config:: { LeiosVariant , NodeId , SimConfiguration } ,
1717 events:: { BlockRef , Event , Node } ,
1818 model:: { BlockId , TransactionId } ,
1919} ;
@@ -45,6 +45,7 @@ enum OutputFormat {
4545}
4646
4747pub struct EventMonitor {
48+ variant : LeiosVariant ,
4849 node_ids : Vec < NodeId > ,
4950 pool_ids : Vec < NodeId > ,
5051 maximum_ib_age : u64 ,
@@ -69,6 +70,7 @@ impl EventMonitor {
6970 let stage_length = config. stage_length ;
7071 let maximum_ib_age = stage_length * 3 ;
7172 Self {
73+ variant : config. variant ,
7274 node_ids,
7375 pool_ids,
7476 maximum_ib_age,
@@ -100,6 +102,7 @@ impl EventMonitor {
100102 self . pool_ids . into_iter ( ) . map ( |id| ( id, 0.0 ) ) . collect ( ) ;
101103 let mut eb_votes: BTreeMap < EndorserBlockId , f64 > = BTreeMap :: new ( ) ;
102104 let mut ib_txs: BTreeMap < InputBlockId , Vec < TransactionId > > = BTreeMap :: new ( ) ;
105+ let mut eb_txs: BTreeMap < EndorserBlockId , Vec < TransactionId > > = BTreeMap :: new ( ) ;
103106 let mut eb_ibs: BTreeMap < EndorserBlockId , Vec < InputBlockId > > = BTreeMap :: new ( ) ;
104107 let mut eb_ebs: BTreeMap < EndorserBlockId , Vec < EndorserBlockId > > = BTreeMap :: new ( ) ;
105108 let mut leios_tx_bytes: BTreeMap < TransactionId , u64 > = BTreeMap :: new ( ) ;
@@ -241,16 +244,23 @@ impl EventMonitor {
241244 leios_blocks_with_endorsements += 1 ;
242245 pending_ebs. retain ( |eb| eb. slot != endorsement. eb . id . slot ) ;
243246
244- let all_eb_ids = eb_ebs
247+ let all_eb_ids: Vec < _ > = eb_ebs
245248 . get ( & endorsement. eb . id )
246249 . unwrap ( )
247250 . iter ( )
248- . chain ( std:: iter:: once ( & endorsement. eb . id ) ) ;
249- let block_leios_txs: Vec < _ > = all_eb_ids
251+ . chain ( std:: iter:: once ( & endorsement. eb . id ) )
252+ . collect ( ) ;
253+ let block_ib_leios_txs = all_eb_ids
254+ . iter ( )
250255 . flat_map ( |eb| eb_ibs. get ( eb) . unwrap ( ) )
251256 . flat_map ( |ib| ib_txs. get ( ib) . unwrap ( ) )
252- . copied ( )
253- . collect ( ) ;
257+ . copied ( ) ;
258+ let block_eb_leios_txs = all_eb_ids
259+ . iter ( )
260+ . flat_map ( |eb| eb_txs. get ( eb) . unwrap ( ) )
261+ . copied ( ) ;
262+ let block_leios_txs: Vec < _ > =
263+ block_ib_leios_txs. chain ( block_eb_leios_txs) . collect ( ) ;
254264
255265 let mut unique_block_leios_txs: Vec < _ > =
256266 block_leios_txs. iter ( ) . copied ( ) . sorted ( ) . dedup ( ) . collect ( ) ;
@@ -336,6 +346,7 @@ impl EventMonitor {
336346 Event :: EBLotteryWon { .. } => { }
337347 Event :: EBGenerated {
338348 id,
349+ transactions,
339350 input_blocks,
340351 endorser_blocks,
341352 size_bytes,
@@ -344,6 +355,7 @@ impl EventMonitor {
344355 total_leios_bytes += size_bytes;
345356 generated_ebs += 1 ;
346357 pending_ebs. insert ( id. clone ( ) ) ;
358+ eb_txs. insert ( id. clone ( ) , transactions. iter ( ) . map ( |r| r. id ) . collect ( ) ) ;
347359 eb_ibs. insert (
348360 id. clone ( ) ,
349361 input_blocks. iter ( ) . map ( |r| r. id . clone ( ) ) . collect ( ) ,
@@ -352,6 +364,12 @@ impl EventMonitor {
352364 id. clone ( ) ,
353365 endorser_blocks. into_iter ( ) . map ( |r| r. id . clone ( ) ) . collect ( ) ,
354366 ) ;
367+ for BlockRef { id : tx_id } in & transactions {
368+ let tx = txs. get_mut ( tx_id) . unwrap ( ) ;
369+ if tx. included_in_eb . is_none ( ) {
370+ tx. included_in_eb = Some ( time) ;
371+ }
372+ }
355373 for BlockRef { id : ib_id } in & input_blocks {
356374 * ibs_in_eb. entry ( id. clone ( ) ) . or_default ( ) += 1.0 ;
357375 * ebs_containing_ib. entry ( ib_id. clone ( ) ) . or_default ( ) += 1.0 ;
@@ -364,9 +382,10 @@ impl EventMonitor {
364382 }
365383 }
366384 info ! (
367- "Pool {} generated an EB with {} IBs (s) in slot {}." ,
385+ "Pool {} generated an EB with {} IB(s) and {} TX (s) in slot {}." ,
368386 id. producer,
369387 input_blocks. len( ) ,
388+ transactions. len( ) ,
370389 id. slot,
371390 )
372391 }
@@ -546,7 +565,9 @@ impl EventMonitor {
546565 info ! ( "{} L1 block(s) had a Leios endorsement." , leios_blocks_with_endorsements) ;
547566 info ! ( "{} tx(s) were referenced by a Leios endorsement." , unique_leios_txs) ;
548567 info ! ( "{} tx(s) were included directly in a Praos block." , praos_txs) ;
549- info ! ( "Spatial efficiency: {}/{} ({:.3}%) of Leios bytes were transactions." , pretty_bytes( total_leios_tx_bytes, pbo. clone( ) ) , pretty_bytes( total_leios_bytes, pbo. clone( ) ) , space_efficiency * 100. ) ;
568+ if self . variant != LeiosVariant :: FullWithoutIbs {
569+ info ! ( "Spatial efficiency: {}/{} ({:.3}%) of Leios bytes were transactions." , pretty_bytes( total_leios_tx_bytes, pbo. clone( ) ) , pretty_bytes( total_leios_bytes, pbo. clone( ) ) , space_efficiency * 100. ) ;
570+ }
550571 info ! ( "{} tx(s) ({:.3}%) referenced by a Leios endorsement were redundant." , leios_txs - unique_leios_txs, ( leios_txs - unique_leios_txs) as f64 / leios_txs as f64 * 100. ) ;
551572 info ! (
552573 "Each transaction took an average of {:.3}s (stddev {:.3}) to be included in an IB." ,
0 commit comments