Skip to content

node, networking, forkchoice: import-subnet-ids for subnet network topology#482

Merged
ch4r10t33r merged 7 commits intoleanEthereum:mainfrom
ch4r10t33r:mesh-changes
Mar 25, 2026
Merged

node, networking, forkchoice: import-subnet-ids for subnet network topology#482
ch4r10t33r merged 7 commits intoleanEthereum:mainfrom
ch4r10t33r:mesh-changes

Conversation

@ch4r10t33r
Copy link
Collaborator

Summary

  • Add import_subnet_ids to control which attestation subnets a node subscribes to and collects from, independently of the aggregator role.
  • Subscription (p2p layer): aggregators subscribe to their validator-derived subnet; non-aggregators with no import subnets skip attestation subscriptions entirely (saves bandwidth); import_subnet_ids are always subscribed regardless of aggregator flag (for proposer nodes that need attestations for block inclusion); the two sets are additive and deduplicated.
  • Signature collection (forkchoice layer): existing aggregator path collects from validators sharing the same subnet; new import-subnet path always collects from explicitly listed subnets regardless of is_aggregator.
  • Adds --import-subnet-ids CLI flag (comma-separated, e.g. "0,1,2") wired through run_node, _init_from_genesis, _init_from_checkpoint, NodeConfig, SyncService, and NetworkService.

Test plan

  • uvx tox -e all-checks passes (ruff, ty, codespell, mdformat)
  • 3 new tests in TestOnGossipAttestationSubnetFiltering:
    • test_import_subnet_stores_without_aggregator — import subnets work without is_aggregator
    • test_import_subnet_ignored_for_other_subnets — only explicitly listed subnets are collected
    • test_import_subnet_combined_with_aggregator — both paths are additive when used together
  • All 7 tests in TestOnGossipAttestationSubnetFiltering pass

…pology

Add `import_subnet_ids` to control which attestation subnets a node
subscribes to and collects signatures from, independently of aggregator role.

Subscription changes (p2p layer):
- Aggregator nodes subscribe to their validator-derived subnet only.
- Non-aggregator nodes with no import subnets skip attestation subscriptions
  entirely, saving bandwidth on subnets they have no use for.
- import_subnet_ids are always subscribed regardless of aggregator flag,
  allowing proposer nodes to gather attestations from specific subnets
  for block inclusion without enabling full aggregation mode.
- The two sets are additive and deduplicated.

Signature collection changes (forkchoice layer):
- Aggregator path (existing): collects from validators sharing its subnet.
- Import-subnet path (new): always collects from explicitly listed subnets
  regardless of is_aggregator. Enables proposers to gather raw signatures.

The --import-subnet-ids CLI flag accepts comma-separated subnet IDs (e.g.
"0,1,2") and is passed through run_node, _init_from_genesis, and
_init_from_checkpoint into NodeConfig, SyncService, and NetworkService.

Tests: three new cases in TestOnGossipAttestationSubnetFiltering covering
import-only storage, subnet boundary enforcement, and additive combination
with aggregator mode.
MockForkchoiceStore.on_gossip_attestation and the inline reject_unknown
stub in the sync service tests were missing the import_subnet_ids keyword
argument added to the real Store.on_gossip_attestation, causing TypeError
in CI.
@ch4r10t33r ch4r10t33r marked this pull request as ready for review March 25, 2026 15:20
Copy link
Collaborator

@tcoratger tcoratger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, makes sense!

Copy link
Collaborator

@anshalshukla anshalshukla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality is not what we had initially discussed, we want to add a flag to pass aggregate-subnet-ids so that a aggregator with a powerful machine can aggregate signatures from subnets outside it's default subnet. This flag should be protected for nodes with is_aggregator set.

Along with that the nodes should regardless of them being an aggregator should subscribe to their designated subnet as this would help create a mesh for the attestation gossiping, we should not overly rely on fanout for attestation gossiping. These attestations can be skipped and not be imported in the store though as for non aggregators populating store is not of much use at the moment although this can change in future.

@ch4r10t33r
Copy link
Collaborator Author

ch4r10t33r commented Mar 25, 2026

The functionality is not what we had initially discussed, we want to add a flag to pass aggregate-subnet-ids so that a aggregator with a powerful machine can aggregate signatures from subnets outside it's default subnet. This flag should be protected for nodes with is_aggregator set.

Along with that the nodes should regardless of them being an aggregator should subscribe to their designated subnet as this would help create a mesh for the attestation gossiping, we should not overly rely on fanout for attestation gossiping. These attestations can be skipped and not be imported in the store though as for non aggregators populating store is not of much use at the moment although this can change in future.

My spec changes are based on this PR. blockblaz/zeam#685. However, I notice the discrepancy now. I am pushing a fix.

Three behavioral changes to match the final merged zeam PR #685:

1. Subscription gating:
   - All nodes with validators now subscribe to their validator-derived
     subnets regardless of is_aggregator flag (forms mesh for propagation).
   - aggregate_subnet_ids subscription is gated on is_aggregator (only
     aggregators need explicit extra subnets for signature collection).
   - Non-aggregator nodes with no validators skip attestation subscriptions.

2. Import gating (store + sync):
   - Gossip attestation import is gated solely on is_aggregator.
   - Remove the independent import_subnet_ids path in on_gossip_attestation
     that stored signatures without aggregator role. No such path exists in
     the zeam final code.
   - on_gossip_attestation no longer accepts import_subnet_ids kwarg.

3. Rename import_subnet_ids -> aggregate_subnet_ids throughout:
   - CLI flag: --import-subnet-ids -> --aggregate-subnet-ids
   - NodeConfig, SyncService, NetworkService fields renamed.
   - Tests updated: three import_subnet_ids tests replaced with two tests
     that verify the correct aggregator-only import semantics.
@ch4r10t33r ch4r10t33r requested a review from anshalshukla March 25, 2026 17:35
…bnet-ids without aggregator

Subnet filtering now happens at the p2p subscription layer. Anything
that reaches on_gossip_attestation on an aggregator can be stored
directly — no need to compare attester subnet against current validator.

Also error out early in __main__ if --aggregate-subnet-ids is set
without --is-aggregator, since that combination is meaningless.

Update tests to reflect the new semantics: aggregators store all
received attestations, non-aggregators drop all.
@ch4r10t33r ch4r10t33r requested a review from anshalshukla March 25, 2026 18:31
@ch4r10t33r ch4r10t33r merged commit 9748533 into leanEthereum:main Mar 25, 2026
12 checks passed
@unnawut unnawut added the specs Scope: Changes to the specifications label Mar 26, 2026
@unnawut unnawut added this to the pq-devnet-3 milestone Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

specs Scope: Changes to the specifications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants