File tree Expand file tree Collapse file tree 5 files changed +33
-2
lines changed
Expand file tree Collapse file tree 5 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -6991,8 +6991,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
69916991 /// Returns true if we should issue a sampling request for this block
69926992 /// TODO(das): check if the block is still within the da_window
69936993 pub fn should_sample_slot ( & self , slot : Slot ) -> bool {
6994- self . spec
6995- . is_peer_das_enabled_for_epoch ( slot. epoch ( T :: EthSpec :: slots_per_epoch ( ) ) )
6994+ self . config . enable_sampling
6995+ && self
6996+ . spec
6997+ . is_peer_das_enabled_for_epoch ( slot. epoch ( T :: EthSpec :: slots_per_epoch ( ) ) )
69966998 }
69976999
69987000 pub fn logger ( & self ) -> & Logger {
Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ pub struct ChainConfig {
8888 pub enable_light_client_server : bool ,
8989 /// Enable malicious PeerDAS mode where node withholds data columns when publishing a block
9090 pub malicious_withhold_count : usize ,
91+ /// Enable peer sampling on blocks.
92+ pub enable_sampling : bool ,
9193}
9294
9395impl Default for ChainConfig {
@@ -121,6 +123,7 @@ impl Default for ChainConfig {
121123 epochs_per_migration : crate :: migrate:: DEFAULT_EPOCHS_PER_MIGRATION ,
122124 enable_light_client_server : false ,
123125 malicious_withhold_count : 0 ,
126+ enable_sampling : false ,
124127 }
125128 }
126129}
Original file line number Diff line number Diff line change @@ -74,6 +74,15 @@ pub fn cli_app() -> Command {
7474 . hide ( true )
7575 . display_order ( 0 )
7676 )
77+ . arg (
78+ Arg :: new ( "enable-sampling" )
79+ . long ( "enable-sampling" )
80+ . action ( ArgAction :: SetTrue )
81+ . help_heading ( FLAG_HEADER )
82+ . help ( "Enable peer sampling on data columns. Disabled by default." )
83+ . hide ( true )
84+ . display_order ( 0 )
85+ )
7786 . arg (
7887 Arg :: new ( "subscribe-all-subnets" )
7988 . long ( "subscribe-all-subnets" )
Original file line number Diff line number Diff line change @@ -181,6 +181,10 @@ pub fn get_config<E: EthSpec>(
181181 client_config. chain . shuffling_cache_size = cache_size;
182182 }
183183
184+ if cli_args. get_flag ( "enable-sampling" ) {
185+ client_config. chain . enable_sampling = true ;
186+ }
187+
184188 /*
185189 * Prometheus metrics HTTP server
186190 */
Original file line number Diff line number Diff line change @@ -830,6 +830,19 @@ fn network_subscribe_all_data_column_subnets_flag() {
830830 . with_config ( |config| assert ! ( config. network. subscribe_all_data_column_subnets) ) ;
831831}
832832#[ test]
833+ fn network_enable_sampling_flag ( ) {
834+ CommandLineTest :: new ( )
835+ . flag ( "enable-sampling" , None )
836+ . run_with_zero_port ( )
837+ . with_config ( |config| assert ! ( config. chain. enable_sampling) ) ;
838+ }
839+ #[ test]
840+ fn network_enable_sampling_flag_default ( ) {
841+ CommandLineTest :: new ( )
842+ . run_with_zero_port ( )
843+ . with_config ( |config| assert ! ( !config. chain. enable_sampling) ) ;
844+ }
845+ #[ test]
833846fn network_subscribe_all_subnets_flag ( ) {
834847 CommandLineTest :: new ( )
835848 . flag ( "subscribe-all-subnets" , None )
You can’t perform that action at this time.
0 commit comments