@@ -29,7 +29,7 @@ use sc_utils::mpsc::TracingUnboundedSender;
2929use sp_api:: ProvideRuntimeApi ;
3030use sp_blockchain:: HeaderBackend ;
3131use sp_consensus:: BlockStatus ;
32- use sp_core:: traits:: SpawnNamed ;
32+ use sp_core:: traits:: { CodeExecutor , SpawnNamed } ;
3333use sp_inherents:: CreateInherentDataProviders ;
3434use sp_runtime:: {
3535 generic:: BlockId ,
@@ -62,22 +62,23 @@ use tracing::Instrument;
6262const LOG_TARGET : & str = "cirrus::executor" ;
6363
6464/// The implementation of the Cirrus `Executor`.
65- pub struct Executor < Block : BlockT , Client , TransactionPool , Backend , CIDP > {
65+ pub struct Executor < Block : BlockT , Client , TransactionPool , Backend , CIDP , E > {
6666 // TODO: no longer used in executor, revisit this with ParachainBlockImport together.
6767 parachain_consensus : Box < dyn ParachainConsensus < Block > > ,
6868 client : Arc < Client > ,
69- spawner : Arc < dyn SpawnNamed + Send + Sync > ,
69+ spawner : Box < dyn SpawnNamed + Send + Sync > ,
7070 overseer_handle : OverseerHandle ,
7171 transaction_pool : Arc < TransactionPool > ,
7272 bundle_sender : Arc < TracingUnboundedSender < Bundle < Block :: Extrinsic > > > ,
7373 execution_receipt_sender : Arc < TracingUnboundedSender < ExecutionReceipt < Block :: Hash > > > ,
7474 backend : Arc < Backend > ,
7575 create_inherent_data_providers : Arc < CIDP > ,
76+ code_executor : Arc < E > ,
7677 is_authority : bool ,
7778}
7879
79- impl < Block : BlockT , Client , TransactionPool , Backend , CIDP > Clone
80- for Executor < Block , Client , TransactionPool , Backend , CIDP >
80+ impl < Block : BlockT , Client , TransactionPool , Backend , CIDP , E > Clone
81+ for Executor < Block , Client , TransactionPool , Backend , CIDP , E >
8182{
8283 fn clone ( & self ) -> Self {
8384 Self {
@@ -90,13 +91,14 @@ impl<Block: BlockT, Client, TransactionPool, Backend, CIDP> Clone
9091 execution_receipt_sender : self . execution_receipt_sender . clone ( ) ,
9192 backend : self . backend . clone ( ) ,
9293 create_inherent_data_providers : self . create_inherent_data_providers . clone ( ) ,
94+ code_executor : self . code_executor . clone ( ) ,
9395 is_authority : self . is_authority ,
9496 }
9597 }
9698}
9799
98- impl < Block , Client , TransactionPool , Backend , CIDP >
99- Executor < Block , Client , TransactionPool , Backend , CIDP >
100+ impl < Block , Client , TransactionPool , Backend , CIDP , E >
101+ Executor < Block , Client , TransactionPool , Backend , CIDP , E >
100102where
101103 Block : BlockT ,
102104 Client : HeaderBackend < Block > + BlockBackend < Block > + AuxStore + ProvideRuntimeApi < Block > ,
@@ -114,18 +116,20 @@ where
114116 Backend : sc_client_api:: Backend < Block > + Send + Sync + ' static ,
115117 TransactionPool : sc_transaction_pool_api:: TransactionPool < Block = Block > + ' static ,
116118 CIDP : CreateInherentDataProviders < Block , Hash > + ' static ,
119+ E : CodeExecutor ,
117120{
118121 /// Create a new instance.
119122 fn new (
120123 parachain_consensus : Box < dyn ParachainConsensus < Block > > ,
121124 client : Arc < Client > ,
122- spawner : Arc < dyn SpawnNamed + Send + Sync > ,
125+ spawner : Box < dyn SpawnNamed + Send + Sync > ,
123126 overseer_handle : OverseerHandle ,
124127 transaction_pool : Arc < TransactionPool > ,
125128 bundle_sender : Arc < TracingUnboundedSender < Bundle < Block :: Extrinsic > > > ,
126129 execution_receipt_sender : Arc < TracingUnboundedSender < ExecutionReceipt < Block :: Hash > > > ,
127130 backend : Arc < Backend > ,
128131 create_inherent_data_providers : Arc < CIDP > ,
132+ code_executor : Arc < E > ,
129133 is_authority : bool ,
130134 ) -> Self {
131135 Self {
@@ -138,6 +142,7 @@ where
138142 execution_receipt_sender,
139143 backend,
140144 create_inherent_data_providers,
145+ code_executor,
141146 is_authority,
142147 }
143148 }
@@ -364,8 +369,8 @@ pub enum GossipMessageError {
364369 SendError ,
365370}
366371
367- impl < Block , Client , TransactionPool , Backend , CIDP > GossipMessageHandler < Block >
368- for Executor < Block , Client , TransactionPool , Backend , CIDP >
372+ impl < Block , Client , TransactionPool , Backend , CIDP , E > GossipMessageHandler < Block >
373+ for Executor < Block , Client , TransactionPool , Backend , CIDP , E >
369374where
370375 Block : BlockT ,
371376 Client : HeaderBackend < Block >
@@ -389,6 +394,7 @@ where
389394 Backend : sc_client_api:: Backend < Block > + Send + Sync + ' static ,
390395 TransactionPool : sc_transaction_pool_api:: TransactionPool < Block = Block > + ' static ,
391396 CIDP : CreateInherentDataProviders < Block , Hash > + ' static ,
397+ E : CodeExecutor ,
392398{
393399 type Error = GossipMessageError ;
394400
@@ -525,22 +531,23 @@ where
525531}
526532
527533/// Parameters for [`start_executor`].
528- pub struct StartExecutorParams < Block : BlockT , Spawner , Client , TransactionPool , Backend , CIDP > {
534+ pub struct StartExecutorParams < Block : BlockT , Spawner , Client , TransactionPool , Backend , CIDP , E > {
529535 pub client : Arc < Client > ,
530536 pub announce_block : Arc < dyn Fn ( Block :: Hash , Option < Vec < u8 > > ) + Send + Sync > ,
531537 pub overseer_handle : OverseerHandle ,
532- pub spawner : Spawner ,
538+ pub spawner : Box < Spawner > ,
533539 pub parachain_consensus : Box < dyn ParachainConsensus < Block > > ,
534540 pub transaction_pool : Arc < TransactionPool > ,
535541 pub bundle_sender : TracingUnboundedSender < Bundle < Block :: Extrinsic > > ,
536542 pub execution_receipt_sender : TracingUnboundedSender < ExecutionReceipt < Block :: Hash > > ,
537543 pub backend : Arc < Backend > ,
538544 pub create_inherent_data_providers : Arc < CIDP > ,
545+ pub code_executor : Arc < E > ,
539546 pub is_authority : bool ,
540547}
541548
542549/// Start the executor.
543- pub async fn start_executor < Block , Spawner , Client , TransactionPool , Backend , CIDP > (
550+ pub async fn start_executor < Block , Spawner , Client , TransactionPool , Backend , CIDP , E > (
544551 StartExecutorParams {
545552 client,
546553 announce_block : _,
@@ -552,9 +559,10 @@ pub async fn start_executor<Block, Spawner, Client, TransactionPool, Backend, CI
552559 execution_receipt_sender,
553560 backend,
554561 create_inherent_data_providers,
562+ code_executor,
555563 is_authority,
556- } : StartExecutorParams < Block , Spawner , Client , TransactionPool , Backend , CIDP > ,
557- ) -> Executor < Block , Client , TransactionPool , Backend , CIDP >
564+ } : StartExecutorParams < Block , Spawner , Client , TransactionPool , Backend , CIDP , E > ,
565+ ) -> Executor < Block , Client , TransactionPool , Backend , CIDP , E >
558566where
559567 Block : BlockT ,
560568 Backend : sc_client_api:: Backend < Block > + Send + Sync + ' static ,
@@ -580,17 +588,19 @@ where
580588 TransactionPool :
581589 sc_transaction_pool_api:: TransactionPool < Block = Block > + Send + Sync + ' static ,
582590 CIDP : CreateInherentDataProviders < Block , Hash > + ' static ,
591+ E : CodeExecutor ,
583592{
584593 let executor = Executor :: new (
585594 parachain_consensus,
586595 client,
587- Arc :: new ( spawner) ,
596+ spawner,
588597 overseer_handle. clone ( ) ,
589598 transaction_pool,
590599 Arc :: new ( bundle_sender) ,
591600 Arc :: new ( execution_receipt_sender) ,
592601 backend,
593602 create_inherent_data_providers,
603+ code_executor,
594604 is_authority,
595605 ) ;
596606
0 commit comments