@@ -715,7 +715,10 @@ where
715
715
pub fn set_mock_builder (
716
716
& mut self ,
717
717
beacon_url : SensitiveUrl ,
718
- ) -> impl futures:: Future < Output = ( ) > + ' static {
718
+ strict_registrations : bool ,
719
+ apply_operations : bool ,
720
+ broadcast_to_bn : bool ,
721
+ ) -> impl futures:: Future < Output = ( ) > + use < E , Hot , Cold > {
719
722
let mock_el = self
720
723
. mock_execution_layer
721
724
. as_ref ( )
@@ -727,6 +730,9 @@ where
727
730
let ( mock_builder, ( addr, mock_builder_server) ) = MockBuilder :: new_for_testing (
728
731
mock_el_url,
729
732
beacon_url,
733
+ strict_registrations,
734
+ apply_operations,
735
+ broadcast_to_bn,
730
736
self . spec . clone ( ) ,
731
737
self . runtime . task_executor . clone ( ) ,
732
738
) ;
@@ -903,8 +909,65 @@ where
903
909
state : BeaconState < E > ,
904
910
slot : Slot ,
905
911
) -> ( SignedBlindedBeaconBlock < E > , BeaconState < E > ) {
906
- let ( unblinded, new_state) = self . make_block ( state, slot) . await ;
907
- ( ( * unblinded. 0 ) . clone ( ) . into ( ) , new_state)
912
+ self . make_blinded_block_with_modifier ( state, slot, |_| { } )
913
+ . await
914
+ }
915
+
916
+ pub async fn make_blinded_block_with_modifier (
917
+ & self ,
918
+ mut state : BeaconState < E > ,
919
+ slot : Slot ,
920
+ block_modifier : impl FnOnce ( & mut BlindedBeaconBlock < E > ) ,
921
+ ) -> ( SignedBlindedBeaconBlock < E > , BeaconState < E > ) {
922
+ assert_ne ! ( slot, 0 , "can't produce a block at slot 0" ) ;
923
+ assert ! ( slot >= state. slot( ) ) ;
924
+
925
+ complete_state_advance ( & mut state, None , slot, & self . spec )
926
+ . expect ( "should be able to advance state to slot" ) ;
927
+
928
+ state. build_caches ( & self . spec ) . expect ( "should build caches" ) ;
929
+
930
+ let proposer_index = state. get_beacon_proposer_index ( slot, & self . spec ) . unwrap ( ) ;
931
+
932
+ // If we produce two blocks for the same slot, they hash up to the same value and
933
+ // BeaconChain errors out with `DuplicateFullyImported`. Vary the graffiti so that we produce
934
+ // different blocks each time.
935
+ let graffiti = Graffiti :: from ( self . rng . lock ( ) . random :: < [ u8 ; 32 ] > ( ) ) ;
936
+
937
+ let randao_reveal = self . sign_randao_reveal ( & state, proposer_index, slot) ;
938
+
939
+ // Always use the builder, so that we produce a "real" blinded payload.
940
+ let builder_boost_factor = Some ( u64:: MAX ) ;
941
+
942
+ let BeaconBlockResponseWrapper :: Blinded ( block_response) = self
943
+ . chain
944
+ . produce_block_on_state (
945
+ state,
946
+ None ,
947
+ slot,
948
+ randao_reveal,
949
+ Some ( graffiti) ,
950
+ ProduceBlockVerification :: VerifyRandao ,
951
+ builder_boost_factor,
952
+ BlockProductionVersion :: V3 ,
953
+ )
954
+ . await
955
+ . unwrap ( )
956
+ else {
957
+ panic ! ( "Should always be a blinded payload response" ) ;
958
+ } ;
959
+
960
+ let mut block = block_response. block ;
961
+ block_modifier ( & mut block) ;
962
+
963
+ let signed_block = block. sign (
964
+ & self . validator_keypairs [ proposer_index] . sk ,
965
+ & block_response. state . fork ( ) ,
966
+ block_response. state . genesis_validators_root ( ) ,
967
+ & self . spec ,
968
+ ) ;
969
+
970
+ ( signed_block, block_response. state )
908
971
}
909
972
910
973
/// Returns a newly created block, signed by the proposer for the given slot.
0 commit comments