File tree 5 files changed +56
-2
lines changed
5 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,10 @@ pub struct Config {
148
148
/// Configuration for the minimum message size for which IDONTWANT messages are send in the mesh.
149
149
/// Lower the value reduces the optimization effect of the IDONTWANT messages.
150
150
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 > ,
151
155
}
152
156
153
157
impl Config {
@@ -372,6 +376,7 @@ impl Default for Config {
372
376
invalid_block_storage : None ,
373
377
inbound_rate_limiter_config : None ,
374
378
idontwant_message_size_threshold : DEFAULT_IDONTWANT_MESSAGE_SIZE_THRESHOLD ,
379
+ advertise_false_custody_group_count : None ,
375
380
}
376
381
}
377
382
}
Original file line number Diff line number Diff line change @@ -199,8 +199,23 @@ impl<E: EthSpec> Network<E> {
199
199
200
200
// Construct the metadata
201
201
let custody_group_count = ctx. chain_spec . is_peer_das_scheduled ( ) . then ( || {
202
- ctx. chain_spec
203
- . custody_group_count ( config. subscribe_all_data_column_subnets )
202
+ // Use the false custody group count if specified, otherwise use the normal one
203
+ if let Some ( false_count) = config. advertise_false_custody_group_count {
204
+ // Ensure the false count is within valid range
205
+ if ( ctx. chain_spec . custody_requirement ..=ctx. chain_spec . number_of_custody_groups ) . contains ( & false_count) {
206
+ warn ! ( log, "Using false custody group count for testing" ; "count" => false_count) ;
207
+ false_count
208
+ } else {
209
+ warn ! ( log, "Specified false custody group count is out of valid range, using normal count" ;
210
+ "false_count" => false_count,
211
+ "min" => ctx. chain_spec. custody_requirement,
212
+ "max" => ctx. chain_spec. number_of_custody_groups
213
+ ) ;
214
+ ctx. chain_spec . custody_group_count ( config. subscribe_all_data_column_subnets )
215
+ }
216
+ } else {
217
+ ctx. chain_spec . custody_group_count ( config. subscribe_all_data_column_subnets )
218
+ }
204
219
} ) ;
205
220
let meta_data = utils:: load_or_build_metadata ( & config. network_dir , custody_group_count) ;
206
221
let seq_number = * meta_data. seq_number ( ) ;
Original file line number Diff line number Diff line change @@ -68,6 +68,20 @@ pub fn cli_app() -> Command {
68
68
. hide ( true )
69
69
. display_order ( 0 )
70
70
)
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
+ )
71
85
. arg (
72
86
Arg :: new ( "enable-sampling" )
73
87
. long ( "enable-sampling" )
Original file line number Diff line number Diff line change @@ -1170,6 +1170,12 @@ pub fn set_network_config(
1170
1170
1171
1171
config. set_listening_addr ( parse_listening_addresses ( cli_args) ?) ;
1172
1172
1173
+ if let Some ( false_custody_group_count) =
1174
+ clap_utils:: parse_optional ( cli_args, "advertise-false-custody-group-count" ) ?
1175
+ {
1176
+ config. advertise_false_custody_group_count = Some ( false_custody_group_count) ;
1177
+ }
1178
+
1173
1179
// A custom target-peers command will overwrite the --proposer-only default.
1174
1180
if let Some ( target_peers_str) = cli_args. get_one :: < String > ( "target-peers" ) {
1175
1181
config. target_peers = target_peers_str
Original file line number Diff line number Diff line change @@ -2033,6 +2033,20 @@ fn malicious_withhold_count_flag() {
2033
2033
. with_config ( |config| assert_eq ! ( config. chain. malicious_withhold_count, 128 ) ) ;
2034
2034
}
2035
2035
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
+
2036
2050
// Tests for Slasher flags.
2037
2051
// Using `--slasher-max-db-size` to work around https://github.com/sigp/lighthouse/issues/2342
2038
2052
#[ test]
You can’t perform that action at this time.
0 commit comments