Skip to content

Commit 83a73f5

Browse files
feat: add --advertise-false-custody-group-count flag for PeerDAS testing
1 parent d60c24e commit 83a73f5

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

beacon_node/lighthouse_network/src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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

153157
impl 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
}

beacon_node/lighthouse_network/src/service/mod.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,23 @@ impl<E: EthSpec> Network<E> {
199199

200200
// Construct the metadata
201201
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+
}
204219
});
205220
let meta_data = utils::load_or_build_metadata(&config.network_dir, custody_group_count);
206221
let seq_number = *meta_data.seq_number();

beacon_node/src/cli.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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")

beacon_node/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,12 @@ pub fn set_network_config(
11701170

11711171
config.set_listening_addr(parse_listening_addresses(cli_args)?);
11721172

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+
11731179
// A custom target-peers command will overwrite the --proposer-only default.
11741180
if let Some(target_peers_str) = cli_args.get_one::<String>("target-peers") {
11751181
config.target_peers = target_peers_str

lighthouse/tests/beacon_node.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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]

0 commit comments

Comments
 (0)