@@ -129,6 +129,71 @@ where
129129        Ok ( ( built_payload,  eth_attr) ) 
130130    } 
131131
132+     pub  async  fn  new_payload_irys ( 
133+         & mut  self , 
134+         // attributes: Engine::PayloadBuilderAttributes, 
135+         attributes_generator :  impl  Fn ( u64 )  -> Engine :: PayloadBuilderAttributes , 
136+     )  -> eyre:: Result < ( Engine :: BuiltPayload ,  Engine :: PayloadBuilderAttributes ) > 
137+     where 
138+         <Engine  as  EngineTypes >:: ExecutionPayloadV1Irys : 
139+             From < Engine :: BuiltPayload >  + PayloadEnvelopeExt , 
140+     { 
141+         // trigger new payload building draining the pool 
142+         // self.payload.payload_builder.new_payload(attributes.clone()).await?; 
143+ 
144+         // let eth_attr = attributes; 
145+ 
146+         let  eth_attr = self . payload . new_payload ( attributes_generator) . await . unwrap ( ) ; 
147+ 
148+         // first event is the payload attributes 
149+         // self.payload.expect_attr_event(eth_attr.clone()).await?; 
150+         // wait for the payload builder to have finished building 
151+         let  p2 = self . payload . wait_for_built_payload ( eth_attr. payload_id ( ) ) . await ; 
152+         // trigger resolve payload via engine api 
153+         let  _ = self . engine_api . get_payload_v1_irys ( eth_attr. payload_id ( ) ) . await ?; 
154+         // ensure we're also receiving the built payload as event 
155+         // let built_payload = self.payload.expect_built_payload().await?; 
156+         // self. 
157+         // Ok((built_payload, eth_attr)) 
158+         Ok ( ( /* execution_payload */  p2,  eth_attr) ) 
159+     } 
160+ 
161+     pub  async  fn  new_payload_irys2 ( 
162+         & mut  self , 
163+         parent :  B256 , 
164+         attributes :  Engine :: PayloadAttributes , 
165+     )  -> eyre:: Result < ( 
166+         Engine :: ExecutionPayloadV1Irys , 
167+         Engine :: BuiltPayload , 
168+         Engine :: PayloadBuilderAttributes , 
169+     ) > 
170+     where 
171+         <Engine  as  EngineTypes >:: ExecutionPayloadV1Irys : 
172+             From < Engine :: BuiltPayload >  + PayloadEnvelopeExt , 
173+     { 
174+         let  payload_builder_attributes =
175+             <Engine  as  reth_node_builder:: PayloadTypes >:: PayloadBuilderAttributes :: try_new ( 
176+                 parent,  attributes, 
177+             ) 
178+             . expect ( "unable to build PayloadBuilderAttributes" ) ; 
179+         use  reth_payload_primitives:: PayloadBuilder ; 
180+         // trigger new payload building draining the pool 
181+         self . payload . payload_builder . new_payload ( payload_builder_attributes. clone ( ) ) . await ?; 
182+ 
183+         let  eth_attr = payload_builder_attributes; 
184+         // first event is the payload attributes 
185+         // self.payload.expect_attr_event(eth_attr.clone()).await?; 
186+         // wait for the payload builder to have finished building 
187+         let  built_payload = self . payload . wait_for_built_payload ( eth_attr. payload_id ( ) ) . await ; 
188+         // trigger resolve payload via engine api 
189+         let  execution_payload = self . engine_api . get_payload_v1_irys ( eth_attr. payload_id ( ) ) . await ?; 
190+         // ensure we're also receiving the built payload as event 
191+         // let built_payload = self.payload.expect_built_payload().await?; 
192+         // self. 
193+         // Ok((built_payload, eth_attr)) 
194+         Ok ( ( execution_payload,  built_payload,  eth_attr) ) 
195+     } 
196+ 
132197    /// Advances the node forward one block 
133198     pub  async  fn  advance_block ( 
134199        & mut  self , 
@@ -157,6 +222,34 @@ where
157222        Ok ( ( payload,  eth_attr) ) 
158223    } 
159224
225+     /// Advances the node forward one block 
226+      pub  async  fn  advance_block_irys ( 
227+         & mut  self , 
228+         versioned_hashes :  Vec < B256 > , 
229+         attributes_generator :  impl  Fn ( u64 )  -> Engine :: PayloadBuilderAttributes , 
230+     )  -> eyre:: Result < ( Engine :: BuiltPayload ,  Engine :: PayloadBuilderAttributes ) > 
231+     where 
232+         <Engine  as  EngineTypes >:: ExecutionPayloadV1Irys : 
233+             From < Engine :: BuiltPayload >  + PayloadEnvelopeExt , 
234+     { 
235+         let  ( payload,  eth_attr)  = self . new_payload_irys ( attributes_generator) . await ?; 
236+ 
237+         let  block_hash = self 
238+             . engine_api 
239+             . submit_payload ( 
240+                 payload. clone ( ) , 
241+                 eth_attr. clone ( ) , 
242+                 PayloadStatusEnum :: Valid , 
243+                 versioned_hashes, 
244+             ) 
245+             . await ?; 
246+ 
247+         // trigger forkchoice update via engine api to commit the block to the blockchain 
248+         self . engine_api . update_forkchoice ( block_hash,  block_hash) . await ?; 
249+ 
250+         Ok ( ( payload,  eth_attr) ) 
251+     } 
252+ 
160253    /// Waits for block to be available on node. 
161254     pub  async  fn  wait_block ( 
162255        & self , 
@@ -221,6 +314,37 @@ where
221314        let  tx = head. tip ( ) . transactions ( ) . next ( ) ; 
222315        assert_eq ! ( tx. unwrap( ) . hash( ) . as_slice( ) ,  tip_tx_hash. as_slice( ) ) ; 
223316
317+         loop  { 
318+             // wait for the block to commit 
319+             tokio:: time:: sleep ( std:: time:: Duration :: from_millis ( 20 ) ) . await ; 
320+             if  let  Some ( latest_block)  =
321+                 self . inner . provider . block_by_number_or_tag ( BlockNumberOrTag :: Latest ) ?
322+             { 
323+                 if  latest_block. number  == block_number { 
324+                     // make sure the block hash we submitted via FCU engine api is the new latest 
325+                     // block using an RPC call 
326+                     assert_eq ! ( latest_block. hash_slow( ) ,  block_hash) ; 
327+                     break ; 
328+                 } 
329+             } 
330+         } 
331+         Ok ( ( ) ) 
332+     } 
333+     /// Asserts that a new block has been added to the blockchain 
334+      /// and the tx has been included in the block. 
335+      /// 
336+      /// Does NOT work for pipeline since there's no stream notification! 
337+      pub  async  fn  assert_new_block2 ( 
338+         & self , 
339+         block_hash :  B256 , 
340+         block_number :  BlockNumber , 
341+     )  -> eyre:: Result < ( ) >  { 
342+         // get head block from notifications stream and verify the tx has been pushed to the 
343+         // pool is actually present in the canonical block 
344+         // let head = self.engine_api.canonical_stream.next().await.unwrap(); 
345+         // let tx = head.tip().transactions().next(); 
346+         // assert_eq!(tx.unwrap().hash().as_slice(), tip_tx_hash.as_slice()); 
347+ 
224348        loop  { 
225349            // wait for the block to commit 
226350            tokio:: time:: sleep ( std:: time:: Duration :: from_millis ( 20 ) ) . await ; 
0 commit comments