@@ -596,6 +596,14 @@ impl Node {
596596 }
597597 }
598598
599+ fn find_available_eb_shards ( & self , slot : u64 ) -> Vec < u64 > {
600+ if !matches ! ( self . sim_config. variant, LeiosVariant :: FullWithoutIbs ) {
601+ // EBs only need shards if we don't have IBs.
602+ return vec ! [ 0 ] ;
603+ }
604+ self . find_available_ib_shards ( slot)
605+ }
606+
599607 fn find_available_ib_shards ( & self , slot : u64 ) -> Vec < u64 > {
600608 let period = slot / self . sim_config . ib_shard_period_slots ;
601609 let group = period % self . sim_config . ib_shard_groups ;
@@ -610,21 +618,24 @@ impl Node {
610618 // Don't generate EBs before that pipeline, because they would just be empty.
611619 return ;
612620 }
621+ let shards = self . find_available_eb_shards ( slot) ;
613622 for next_p in vrf_probabilities ( self . sim_config . eb_generation_probability ) {
614- if self . run_vrf ( next_p) . is_some ( ) {
623+ if let Some ( vrf ) = self . run_vrf ( next_p) {
615624 self . tracker . track_eb_lottery_won ( EndorserBlockId {
616625 slot,
617626 pipeline,
618627 producer : self . id ,
619628 } ) ;
620- let txs = self . select_txs_for_eb ( pipeline) ;
629+ let shard = shards[ vrf as usize % shards. len ( ) ] ;
630+ let txs = self . select_txs_for_eb ( shard, pipeline) ;
621631 let ibs = self . select_ibs_for_eb ( pipeline) ;
622632 let ebs = self . select_ebs_for_eb ( pipeline) ;
623633 let bytes = self . sim_config . sizes . eb ( txs. len ( ) , ibs. len ( ) , ebs. len ( ) ) ;
624634 let eb = EndorserBlock {
625635 slot,
626636 pipeline,
627637 producer : self . id ,
638+ shard,
628639 bytes,
629640 txs,
630641 ibs,
@@ -1407,27 +1418,15 @@ impl Node {
14071418 vec ! [ Arc :: new( tx) ]
14081419 } else {
14091420 let ledger_state = self . resolve_ledger_state ( rb_ref) ;
1410- let ib_shards = self . sim_config . ib_shards ;
1411- let tx_may_use_shard = |tx : & Transaction , ib_shard : u64 | {
1412- for shard in tx. shard ..=tx. shard + tx. overcollateralization_factor {
1413- let shard = shard % ib_shards;
1414- if shard == ib_shard {
1415- return true ;
1416- }
1417- }
1418- false
1419- } ;
14201421 self . select_txs (
1421- |seen| {
1422- tx_may_use_shard ( & seen. tx , shard)
1423- && !ledger_state. spent_inputs . contains ( & seen. tx . input_id )
1424- } ,
1422+ shard,
1423+ |seen| !ledger_state. spent_inputs . contains ( & seen. tx . input_id ) ,
14251424 self . sim_config . max_ib_size ,
14261425 )
14271426 }
14281427 }
14291428
1430- fn select_txs_for_eb ( & mut self , pipeline : u64 ) -> Vec < TransactionId > {
1429+ fn select_txs_for_eb ( & mut self , shard : u64 , pipeline : u64 ) -> Vec < TransactionId > {
14311430 if self . sim_config . variant != LeiosVariant :: FullWithoutIbs {
14321431 return vec ! [ ] ;
14331432 }
@@ -1440,6 +1439,7 @@ impl Node {
14401439 let max_seen_at = Timestamp :: from_secs ( last_legal_slot) ;
14411440
14421441 self . select_txs (
1442+ shard,
14431443 |seen| seen. seen_at <= max_seen_at,
14441444 self . sim_config . max_eb_size ,
14451445 )
@@ -1448,16 +1448,31 @@ impl Node {
14481448 . collect ( )
14491449 }
14501450
1451- fn select_txs < C > ( & mut self , condition : C , max_size : u64 ) -> Vec < Arc < Transaction > >
1451+ fn select_txs < C > (
1452+ & mut self ,
1453+ container_shard : u64 ,
1454+ condition : C ,
1455+ max_size : u64 ,
1456+ ) -> Vec < Arc < Transaction > >
14521457 where
14531458 C : Fn ( & SeenTransaction ) -> bool ,
14541459 {
1460+ let ib_shards = self . sim_config . ib_shards ;
1461+ let tx_may_use_shard = |tx : & Transaction | {
1462+ for shard in tx. shard ..=tx. shard + tx. overcollateralization_factor {
1463+ let shard = shard % ib_shards;
1464+ if shard == container_shard {
1465+ return true ;
1466+ }
1467+ }
1468+ false
1469+ } ;
14551470 let mut candidate_txs: Vec < _ > = self
14561471 . leios
14571472 . mempool
14581473 . values ( )
14591474 . filter_map ( |seen| {
1460- if condition ( seen) {
1475+ if tx_may_use_shard ( & seen . tx ) && condition ( seen) {
14611476 Some ( ( seen. tx . id , seen. tx . bytes , seen. tx . input_id ) )
14621477 } else {
14631478 None
0 commit comments