File tree Expand file tree Collapse file tree 5 files changed +56
-2
lines changed
Expand file tree Collapse file tree 5 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,10 @@ pub struct Config {
148148 /// Configuration for the minimum message size for which IDONTWANT messages are send in the mesh.
149149 /// Lower the value reduces the optimization effect of the IDONTWANT messages.
150150 pub idontwant_message_size_threshold : usize ,
151+
152+ /// Advertise a false custody group count in metadata.
153+ /// Makes peers think this node custodies more columns than it actually does.
154+ pub advertise_false_custody_group_count : Option < u64 > ,
151155}
152156
153157impl Config {
@@ -372,6 +376,7 @@ impl Default for Config {
372376 invalid_block_storage : None ,
373377 inbound_rate_limiter_config : None ,
374378 idontwant_message_size_threshold : DEFAULT_IDONTWANT_MESSAGE_SIZE_THRESHOLD ,
379+ advertise_false_custody_group_count : None ,
375380 }
376381 }
377382}
Original file line number Diff line number Diff line change @@ -198,8 +198,23 @@ impl<E: EthSpec> Network<E> {
198198
199199 // Construct the metadata
200200 let custody_group_count = ctx. chain_spec . is_peer_das_scheduled ( ) . then ( || {
201- ctx. chain_spec
202- . custody_group_count ( config. subscribe_all_data_column_subnets )
201+ // Use the false custody group count if specified, otherwise use the normal one
202+ if let Some ( false_count) = config. advertise_false_custody_group_count {
203+ // Ensure the false count is within valid range
204+ if ( ctx. chain_spec . custody_requirement ..=ctx. chain_spec . number_of_custody_groups ) . contains ( & false_count) {
205+ warn ! ( log, "Using false custody group count for testing" ; "count" => false_count) ;
206+ false_count
207+ } else {
208+ warn ! ( log, "Specified false custody group count is out of valid range, using normal count" ;
209+ "false_count" => false_count,
210+ "min" => ctx. chain_spec. custody_requirement,
211+ "max" => ctx. chain_spec. number_of_custody_groups
212+ ) ;
213+ ctx. chain_spec . custody_group_count ( config. subscribe_all_data_column_subnets )
214+ }
215+ } else {
216+ ctx. chain_spec . custody_group_count ( config. subscribe_all_data_column_subnets )
217+ }
203218 } ) ;
204219 let meta_data =
205220 utils:: load_or_build_metadata ( & config. network_dir , custody_group_count, & log) ;
Original file line number Diff line number Diff line change @@ -68,6 +68,20 @@ pub fn cli_app() -> Command {
6868 . hide ( true )
6969 . display_order ( 0 )
7070 )
71+ . arg (
72+ // TODO(das): remove this before PeerDAS release
73+ Arg :: new ( "advertise-false-custody-group-count" )
74+ . long ( "advertise-false-custody-group-count" )
75+ . action ( ArgAction :: Set )
76+ . help_heading ( FLAG_HEADER )
77+ . help ( "TESTING ONLY: Advertise a false custody group count in metadata. Makes \
78+ peers think this node custodies more columns than it actually does. \
79+ It's used to override the actual custody group count when building node metadata, \
80+ but only when PeerDAS is scheduled and the value is within valid range.
81+ DO NOT USE IN PRODUCTION." )
82+ . hide ( true )
83+ . display_order ( 0 )
84+ )
7185 . arg (
7286 Arg :: new ( "enable-sampling" )
7387 . long ( "enable-sampling" )
Original file line number Diff line number Diff line change @@ -1180,6 +1180,12 @@ pub fn set_network_config(
11801180 config. shutdown_after_sync = true ;
11811181 }
11821182
1183+ if let Some ( false_custody_group_count) =
1184+ clap_utils:: parse_optional ( cli_args, "advertise-false-custody-group-count" ) ?
1185+ {
1186+ config. advertise_false_custody_group_count = Some ( false_custody_group_count) ;
1187+ }
1188+
11831189 config. set_listening_addr ( parse_listening_addresses ( cli_args, log) ?) ;
11841190
11851191 // A custom target-peers command will overwrite the --proposer-only default.
Original file line number Diff line number Diff line change @@ -2033,6 +2033,20 @@ fn malicious_withhold_count_flag() {
20332033 . with_config ( |config| assert_eq ! ( config. chain. malicious_withhold_count, 128 ) ) ;
20342034}
20352035
2036+ #[ test]
2037+ fn advertise_false_custody_group_count_flag ( ) {
2038+ CommandLineTest :: new ( )
2039+ . flag ( "advertise-false-custody-group-count" , Some ( "128" ) )
2040+ . run_with_zero_port ( )
2041+ . with_config ( |config| {
2042+ let network_config = & config. network ;
2043+ assert_eq ! (
2044+ network_config. advertise_false_custody_group_count,
2045+ Some ( 128 )
2046+ ) ;
2047+ } ) ;
2048+ }
2049+
20362050// Tests for Slasher flags.
20372051// Using `--slasher-max-db-size` to work around https://github.com/sigp/lighthouse/issues/2342
20382052#[ test]
You can’t perform that action at this time.
0 commit comments