@@ -5,8 +5,12 @@ use crate::{
55use alto_types:: { Activity , Block , Finalization , Scheme , EPOCH , EPOCH_LENGTH , NAMESPACE } ;
66use commonware_broadcast:: buffered;
77use commonware_consensus:: {
8- application:: marshaled:: Marshaled as ConsensusMarshaled ,
9- marshal:: { self , ingress:: handler} ,
8+ marshal:: {
9+ self ,
10+ core:: { Actor as MarshalActor , Mailbox as MarshalMailbox } ,
11+ resolver:: handler,
12+ standard:: { Deferred , Standard } ,
13+ } ,
1014 simplex:: { self , elector:: Random , Engine as Consensus } ,
1115 types:: { Epoch , FixedEpocher , ViewDelta } ,
1216 Reporters ,
@@ -17,7 +21,7 @@ use commonware_cryptography::{
1721 ed25519:: PublicKey ,
1822 sha256:: Digest ,
1923} ;
20- use commonware_p2p:: { Blocker , Receiver , Sender } ;
24+ use commonware_p2p:: { Blocker , Provider , Receiver , Sender } ;
2125use commonware_parallel:: Strategy ;
2226use commonware_resolver:: Resolver ;
2327use commonware_runtime:: {
@@ -40,7 +44,7 @@ use tracing::{error, info, warn};
4044
4145/// Reporter type for [simplex::Engine].
4246type Reporter < E , I > =
43- Reporters < Activity , marshal :: Mailbox < Scheme , Block > , Option < indexer:: Pusher < E , I > > > ;
47+ Reporters < Activity , MarshalMailbox < Scheme , Standard < Block > > , Option < indexer:: Pusher < E , I > > > ;
4448
4549/// To better support peers near tip during network instability, we multiply
4650/// the consensus activity timeout by this factor.
@@ -59,8 +63,14 @@ const MAX_REPAIR: NonZero<usize> = NZUsize!(20);
5963const MAX_PENDING_ACKS : NonZero < usize > = NZUsize ! ( 16 ) ;
6064
6165/// Configuration for the [Engine].
62- pub struct Config < B : Blocker < PublicKey = PublicKey > , I : Indexer , S : Strategy > {
66+ pub struct Config <
67+ B : Blocker < PublicKey = PublicKey > ,
68+ P : Provider < PublicKey = PublicKey > ,
69+ I : Indexer ,
70+ S : Strategy ,
71+ > {
6372 pub blocker : B ,
73+ pub provider : P ,
6474 pub partition_prefix : String ,
6575 pub blocks_freezer_table_initial_size : u32 ,
6676 pub finalized_freezer_table_initial_size : u32 ,
@@ -72,7 +82,7 @@ pub struct Config<B: Blocker<PublicKey = PublicKey>, I: Indexer, S: Strategy> {
7282 pub deque_size : usize ,
7383
7484 pub leader_timeout : Duration ,
75- pub notarization_timeout : Duration ,
85+ pub certification_timeout : Duration ,
7686 pub nullify_retry : Duration ,
7787 pub fetch_timeout : Duration ,
7888 pub activity_timeout : ViewDelta ,
@@ -87,24 +97,25 @@ pub struct Config<B: Blocker<PublicKey = PublicKey>, I: Indexer, S: Strategy> {
8797 pub indexer : Option < I > ,
8898}
8999
90- type Marshaled < E > = ConsensusMarshaled < E , Scheme , Application , Block , FixedEpocher > ;
100+ type Marshaled < E > = Deferred < E , Scheme , Application , Block , FixedEpocher > ;
91101
92102/// The engine that drives the [Application].
93103#[ allow( clippy:: type_complexity) ]
94- pub struct Engine < E , B , S , I >
104+ pub struct Engine < E , B , P , S , I >
95105where
96106 E : BufferPooler + Clock + GClock + Rng + CryptoRng + Spawner + Storage + Metrics ,
97107 B : Blocker < PublicKey = PublicKey > ,
108+ P : Provider < PublicKey = PublicKey > ,
98109 S : Strategy ,
99110 I : Indexer ,
100111{
101112 context : ContextCell < E > ,
102113
103- buffer : buffered:: Engine < E , PublicKey , Block > ,
114+ buffer : buffered:: Engine < E , PublicKey , Block , P > ,
104115 buffer_mailbox : buffered:: Mailbox < PublicKey , Block > ,
105- marshal : marshal :: Actor <
116+ marshal : MarshalActor <
106117 E ,
107- Block ,
118+ Standard < Block > ,
108119 ConstantProvider < Scheme , Epoch > ,
109120 immutable:: Archive < E , Digest , Finalization > ,
110121 immutable:: Archive < E , Digest , Block > ,
@@ -117,15 +128,16 @@ where
117128 Consensus < E , Scheme , Random , B , Digest , Marshaled < E > , Marshaled < E > , Reporter < E , I > , S > ,
118129}
119130
120- impl < E , B , S , I > Engine < E , B , S , I >
131+ impl < E , B , P , S , I > Engine < E , B , P , S , I >
121132where
122133 E : BufferPooler + Clock + GClock + Rng + CryptoRng + Spawner + ThreadPooler + Storage + Metrics ,
123134 B : Blocker < PublicKey = PublicKey > ,
135+ P : Provider < PublicKey = PublicKey > ,
124136 S : Strategy ,
125137 I : Indexer ,
126138{
127139 /// Create a new [Engine].
128- pub async fn new ( context : E , cfg : Config < B , I , S > ) -> Self {
140+ pub async fn new ( context : E , cfg : Config < B , P , I , S > ) -> Self {
129141 // Create the buffer
130142 let ( buffer, buffer_mailbox) = buffered:: Engine :: new (
131143 context. with_label ( "buffer" ) ,
@@ -135,6 +147,7 @@ where
135147 deque_size : cfg. deque_size ,
136148 priority : true ,
137149 codec_config : ( ) ,
150+ peer_provider : cfg. provider ,
138151 } ,
139152 ) ;
140153
@@ -226,7 +239,7 @@ where
226239 . expect ( "failed to create scheme" ) ;
227240 let provider = ConstantProvider :: new ( scheme. clone ( ) ) ;
228241 let epocher = FixedEpocher :: new ( EPOCH_LENGTH ) ;
229- let ( marshal, marshal_mailbox, _) = marshal :: Actor :: init (
242+ let ( marshal, marshal_mailbox, _) = MarshalActor :: init (
230243 context. with_label ( "marshal" ) ,
231244 finalizations_by_height,
232245 finalized_blocks,
@@ -287,8 +300,8 @@ where
287300 partition : format ! ( "{}-consensus" , cfg. partition_prefix) ,
288301 mailbox_size : cfg. mailbox_size ,
289302 leader_timeout : cfg. leader_timeout ,
290- notarization_timeout : cfg. notarization_timeout ,
291- nullify_retry : cfg. nullify_retry ,
303+ certification_timeout : cfg. certification_timeout ,
304+ timeout_retry : cfg. nullify_retry ,
292305 fetch_timeout : cfg. fetch_timeout ,
293306 activity_timeout : cfg. activity_timeout ,
294307 skip_timeout : cfg. skip_timeout ,
@@ -335,8 +348,8 @@ where
335348 impl Receiver < PublicKey = PublicKey > ,
336349 ) ,
337350 marshal : (
338- mpsc:: Receiver < handler:: Message < Block > > ,
339- impl Resolver < Key = handler:: Request < Block > , PublicKey = PublicKey > ,
351+ mpsc:: Receiver < handler:: Message < Digest > > ,
352+ impl Resolver < Key = handler:: Request < Digest > , PublicKey = PublicKey > ,
340353 ) ,
341354 ) -> Handle < ( ) > {
342355 spawn_cell ! (
@@ -366,8 +379,8 @@ where
366379 impl Receiver < PublicKey = PublicKey > ,
367380 ) ,
368381 marshal : (
369- mpsc:: Receiver < handler:: Message < Block > > ,
370- impl Resolver < Key = handler:: Request < Block > , PublicKey = PublicKey > ,
382+ mpsc:: Receiver < handler:: Message < Digest > > ,
383+ impl Resolver < Key = handler:: Request < Digest > , PublicKey = PublicKey > ,
371384 ) ,
372385 ) {
373386 // Start the buffer
0 commit comments