Skip to content

Commit 8f30979

Browse files
AgeManningisaac.asimov
authored andcommitted
Shift subnet backbone structure (attnets revamp) (sigp#4304)
This PR address the following spec change: ethereum/consensus-specs#3312 Instead of subscribing to a long-lived subnet for every attached validator to a beacon node, all beacon nodes will subscribe to `SUBNETS_PER_NODE` long-lived subnets. This is currently set to 2 for mainnet. This PR does not include any scoring or advanced discovery mechanisms. A future PR will improve discovery and we can implement scoring after the next hard fork when we expect all client teams and all implementations to respect this spec change. This will be a significant change in the subnet network structure for consensus clients and we will likely have to monitor and tweak our peer management logic.
1 parent c5d17cc commit 8f30979

File tree

11 files changed

+276
-427
lines changed

11 files changed

+276
-427
lines changed

beacon_node/network/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,4 @@ derivative = "2.2.0"
4646
delay_map = "0.3.0"
4747
ethereum-types = { version = "0.14.1", optional = true }
4848
operation_pool = { path = "../operation_pool" }
49-
execution_layer = { path = "../execution_layer" }
50-
51-
[features]
52-
deterministic_long_lived_attnets = [ "ethereum-types" ]
53-
# default = ["deterministic_long_lived_attnets"]
49+
execution_layer = { path = "../execution_layer" }

beacon_node/network/src/service.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ impl<T: BeaconChainTypes> NetworkService<T> {
317317
// attestation subnet service
318318
let attestation_service = AttestationService::new(
319319
beacon_chain.clone(),
320-
#[cfg(feature = "deterministic_long_lived_attnets")]
321-
network_globals.local_enr().node_id().raw().into(),
320+
network_globals.local_enr().node_id(),
322321
config,
323322
&network_log,
324323
);

beacon_node/network/src/subnet_service/attestation_subnets.rs

Lines changed: 61 additions & 327 deletions
Large diffs are not rendered by default.

beacon_node/network/src/subnet_service/tests/mod.rs

Lines changed: 91 additions & 64 deletions
Large diffs are not rendered by default.

common/eth2_network_config/built_in_network_configs/gnosis/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ PROPOSER_SCORE_BOOST: 40
8686
DEPOSIT_CHAIN_ID: 100
8787
DEPOSIT_NETWORK_ID: 100
8888
DEPOSIT_CONTRACT_ADDRESS: 0x0B98057eA310F4d31F2a452B414647007d1645d9
89+
90+
# Network
91+
# ---------------------------------------------------------------
92+
SUBNETS_PER_NODE: 4

common/eth2_network_config/built_in_network_configs/mainnet/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ PROPOSER_SCORE_BOOST: 40
8686
DEPOSIT_CHAIN_ID: 1
8787
DEPOSIT_NETWORK_ID: 1
8888
DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa
89+
90+
# Network
91+
# ---------------------------------------------------------------
92+
SUBNETS_PER_NODE: 2

common/eth2_network_config/built_in_network_configs/prater/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ DEPOSIT_CHAIN_ID: 5
8686
DEPOSIT_NETWORK_ID: 5
8787
# Prater test deposit contract on Goerli Testnet
8888
DEPOSIT_CONTRACT_ADDRESS: 0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b
89+
90+
# Network
91+
# ---------------------------------------------------------------
92+
SUBNETS_PER_NODE: 2

common/eth2_network_config/built_in_network_configs/sepolia/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@ PROPOSER_SCORE_BOOST: 40
7474
DEPOSIT_CHAIN_ID: 11155111
7575
DEPOSIT_NETWORK_ID: 11155111
7676
DEPOSIT_CONTRACT_ADDRESS: 0x7f02C3E3c98b133055B8B348B2Ac625669Ed295D
77+
78+
# Network
79+
# ---------------------------------------------------------------
80+
SUBNETS_PER_NODE: 2

consensus/types/src/chain_spec.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,9 @@ pub struct ChainSpec {
168168
pub maximum_gossip_clock_disparity_millis: u64,
169169
pub target_aggregators_per_committee: u64,
170170
pub attestation_subnet_count: u64,
171-
pub random_subnets_per_validator: u64,
172-
pub epochs_per_random_subnet_subscription: u64,
173171
pub subnets_per_node: u8,
174172
pub epochs_per_subnet_subscription: u64,
175-
attestation_subnet_extra_bits: u8,
173+
pub attestation_subnet_extra_bits: u8,
176174

177175
/*
178176
* Application params
@@ -455,17 +453,7 @@ impl ChainSpec {
455453

456454
#[allow(clippy::integer_arithmetic)]
457455
pub const fn attestation_subnet_prefix_bits(&self) -> u32 {
458-
// maybe use log2 when stable https://github.com/rust-lang/rust/issues/70887
459-
460-
// NOTE: this line is here simply to guarantee that if self.attestation_subnet_count type
461-
// is changed, a compiler warning will be raised. This code depends on the type being u64.
462-
let attestation_subnet_count: u64 = self.attestation_subnet_count;
463-
let attestation_subnet_count_bits = if attestation_subnet_count == 0 {
464-
0
465-
} else {
466-
63 - attestation_subnet_count.leading_zeros()
467-
};
468-
456+
let attestation_subnet_count_bits = self.attestation_subnet_count.ilog2();
469457
self.attestation_subnet_extra_bits as u32 + attestation_subnet_count_bits
470458
}
471459

@@ -625,13 +613,11 @@ impl ChainSpec {
625613
network_id: 1, // mainnet network id
626614
attestation_propagation_slot_range: 32,
627615
attestation_subnet_count: 64,
628-
random_subnets_per_validator: 1,
629-
subnets_per_node: 1,
616+
subnets_per_node: 2,
630617
maximum_gossip_clock_disparity_millis: 500,
631618
target_aggregators_per_committee: 16,
632-
epochs_per_random_subnet_subscription: 256,
633619
epochs_per_subnet_subscription: 256,
634-
attestation_subnet_extra_bits: 6,
620+
attestation_subnet_extra_bits: 0,
635621

636622
/*
637623
* Application specific
@@ -852,13 +838,11 @@ impl ChainSpec {
852838
network_id: 100, // Gnosis Chain network id
853839
attestation_propagation_slot_range: 32,
854840
attestation_subnet_count: 64,
855-
random_subnets_per_validator: 1,
856-
subnets_per_node: 1,
841+
subnets_per_node: 4, // Make this larger than usual to avoid network damage
857842
maximum_gossip_clock_disparity_millis: 500,
858843
target_aggregators_per_committee: 16,
859-
epochs_per_random_subnet_subscription: 256,
860844
epochs_per_subnet_subscription: 256,
861-
attestation_subnet_extra_bits: 6,
845+
attestation_subnet_extra_bits: 0,
862846

863847
/*
864848
* Application specific
@@ -946,6 +930,9 @@ pub struct Config {
946930
shard_committee_period: u64,
947931
#[serde(with = "serde_utils::quoted_u64")]
948932
eth1_follow_distance: u64,
933+
#[serde(default = "default_subnets_per_node")]
934+
#[serde(with = "serde_utils::quoted_u8")]
935+
subnets_per_node: u8,
949936

950937
#[serde(with = "serde_utils::quoted_u64")]
951938
inactivity_score_bias: u64,
@@ -1002,6 +989,10 @@ fn default_safe_slots_to_import_optimistically() -> u64 {
1002989
128u64
1003990
}
1004991

992+
fn default_subnets_per_node() -> u8 {
993+
2u8
994+
}
995+
1005996
impl Default for Config {
1006997
fn default() -> Self {
1007998
let chain_spec = MainnetEthSpec::default_spec();
@@ -1084,6 +1075,7 @@ impl Config {
10841075
min_validator_withdrawability_delay: spec.min_validator_withdrawability_delay,
10851076
shard_committee_period: spec.shard_committee_period,
10861077
eth1_follow_distance: spec.eth1_follow_distance,
1078+
subnets_per_node: spec.subnets_per_node,
10871079

10881080
inactivity_score_bias: spec.inactivity_score_bias,
10891081
inactivity_score_recovery_rate: spec.inactivity_score_recovery_rate,
@@ -1130,6 +1122,7 @@ impl Config {
11301122
min_validator_withdrawability_delay,
11311123
shard_committee_period,
11321124
eth1_follow_distance,
1125+
subnets_per_node,
11331126
inactivity_score_bias,
11341127
inactivity_score_recovery_rate,
11351128
ejection_balance,
@@ -1162,6 +1155,7 @@ impl Config {
11621155
min_validator_withdrawability_delay,
11631156
shard_committee_period,
11641157
eth1_follow_distance,
1158+
subnets_per_node,
11651159
inactivity_score_bias,
11661160
inactivity_score_recovery_rate,
11671161
ejection_balance,

consensus/types/src/config_and_preset.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ pub fn get_extra_fields(spec: &ChainSpec) -> HashMap<String, Value> {
8686
"domain_application_mask".to_uppercase()=> u32_hex(spec.domain_application_mask),
8787
"target_aggregators_per_committee".to_uppercase() =>
8888
spec.target_aggregators_per_committee.to_string().into(),
89-
"random_subnets_per_validator".to_uppercase() =>
90-
spec.random_subnets_per_validator.to_string().into(),
91-
"epochs_per_random_subnet_subscription".to_uppercase() =>
92-
spec.epochs_per_random_subnet_subscription.to_string().into(),
9389
"domain_contribution_and_proof".to_uppercase() =>
9490
u32_hex(spec.domain_contribution_and_proof),
9591
"domain_sync_committee".to_uppercase() => u32_hex(spec.domain_sync_committee),

0 commit comments

Comments
 (0)