Add --semi-supernode support (#8254)

Addresses #8218

A simplified version of #8241 for the initial release.

I've tried to minimise the logic change in this PR, although introducing the `NodeCustodyType` enum still result in quite a bit a of diff, but the actual logic change in `CustodyContext` is quite small.

The main changes are in the `CustdoyContext` struct
* ~~combining `validator_custody_count` and `current_is_supernode` fields into a single `custody_group_count_at_head` field. We persist the cgc of the initial cli values into the `custody_group_count_at_head` field and only allow for increase (same behaviour as before).~~
* I noticed the above approach caused a backward compatibility issue, I've [made a fix](15569bc085) and changed the approach slightly (which was actually what I had originally in mind):
* when initialising, only override the  `validator_custody_count` value if either flag `--supernode` or `--semi-supernode` is used; otherwise leave it as the existing default `0`. Most other logic remains unchanged.

All existing validator custody unit tests are still all passing, and I've added additional tests to cover semi-supernode, and restoring `CustodyContext` from disk.

Note: I've added a `WARN` if the user attempts to switch to a `--semi-supernode` or `--supernode` - this currently has no effect, but once @eserilev column backfill is merged, we should be able to support this quite easily.

Things to test
- [x] cgc in metadata / enr
- [x] cgc in metrics
- [x] subscribed subnets
- [x] getBlobs endpoint


  


Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
Jimmy Chen
2025-10-22 16:23:17 +11:00
committed by GitHub
parent 33e21634cb
commit 43c5e924d7
21 changed files with 420 additions and 114 deletions

View File

@@ -9,6 +9,7 @@ use crate::{
sync::{SyncMessage, manager::BlockProcessType},
};
use beacon_chain::block_verification_types::RpcBlock;
use beacon_chain::custody_context::NodeCustodyType;
use beacon_chain::data_column_verification::validate_data_column_sidecar_for_gossip;
use beacon_chain::kzg_utils::blobs_to_data_column_sidecars;
use beacon_chain::observed_data_sidecars::DoNotObserve;
@@ -94,20 +95,32 @@ impl TestRig {
// This allows for testing voluntary exits without building out a massive chain.
let mut spec = test_spec::<E>();
spec.shard_committee_period = 2;
Self::new_parametric(chain_length, BeaconProcessorConfig::default(), false, spec).await
Self::new_parametric(
chain_length,
BeaconProcessorConfig::default(),
NodeCustodyType::Fullnode,
spec,
)
.await
}
pub async fn new_supernode(chain_length: u64) -> Self {
// This allows for testing voluntary exits without building out a massive chain.
let mut spec = test_spec::<E>();
spec.shard_committee_period = 2;
Self::new_parametric(chain_length, BeaconProcessorConfig::default(), true, spec).await
Self::new_parametric(
chain_length,
BeaconProcessorConfig::default(),
NodeCustodyType::Supernode,
spec,
)
.await
}
pub async fn new_parametric(
chain_length: u64,
beacon_processor_config: BeaconProcessorConfig,
import_data_columns: bool,
node_custody_type: NodeCustodyType,
spec: ChainSpec,
) -> Self {
let spec = Arc::new(spec);
@@ -116,7 +129,7 @@ impl TestRig {
.deterministic_keypairs(VALIDATOR_COUNT)
.fresh_ephemeral_store()
.mock_execution_layer()
.import_all_data_columns(import_data_columns)
.node_custody_type(node_custody_type)
.chain_config(<_>::default())
.build();
@@ -1610,7 +1623,7 @@ async fn test_backfill_sync_processing_rate_limiting_disabled() {
let mut rig = TestRig::new_parametric(
SMALL_CHAIN,
beacon_processor_config,
false,
NodeCustodyType::Fullnode,
test_spec::<E>(),
)
.await;
@@ -1692,7 +1705,13 @@ async fn test_blobs_by_range_spans_fulu_fork() {
spec.fulu_fork_epoch = Some(Epoch::new(1));
spec.gloas_fork_epoch = Some(Epoch::new(2));
let mut rig = TestRig::new_parametric(64, BeaconProcessorConfig::default(), false, spec).await;
let mut rig = TestRig::new_parametric(
64,
BeaconProcessorConfig::default(),
NodeCustodyType::Fullnode,
spec,
)
.await;
let start_slot = 16;
// This will span from epoch 0 (Electra) to epoch 1 (Fulu)