Skip to content

Commit 73ab620

Browse files
committed
fix: move subnet filtering to p2p subscription layer, not node import level
Per @anshalshukla review: when no explicit --aggregate-subnet-ids filter is set, trust the p2p subscription (node.zig already subscribes only to validator-derived subnets at libp2p level). Removing the redundant computeSubnetId loop in chain.zig that was rejecting at the node level instead of preventing bandwidth use at the network layer.
1 parent 6143759 commit 73ab620

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pkgs/node/src/chain.zig

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,9 @@ pub const BeamChain = struct {
774774

775775
// Import into forkchoice only if this node is configured as an aggregator
776776
// and the attestation's subnet matches the configured aggregation subnets (if any).
777+
// When no explicit subnet filter is set, trust the p2p subscription layer:
778+
// node.zig already subscribes only to validator-derived subnets at libp2p level,
779+
// so all received attestations are already on the correct subnets.
777780
const should_import = blk: {
778781
if (!self.is_aggregator_enabled) break :blk false;
779782
if (self.aggregation_subnet_ids) |subnet_ids| {
@@ -786,16 +789,9 @@ pub const BeamChain = struct {
786789
}
787790
break :blk found;
788791
}
789-
// Aggregator with no subnet filter: only import if the attestation's subnet
790-
// matches one of our registered validators' computed subnets.
791-
for (self.registered_validator_ids) |vid| {
792-
const my_subnet = types.computeSubnetId(
793-
@intCast(vid),
794-
self.config.spec.attestation_committee_count,
795-
) catch continue;
796-
if (@as(u32, @intCast(my_subnet)) == signed_attestation.subnet_id) break :blk true;
797-
}
798-
break :blk false;
792+
// No explicit subnet filter — p2p subscription already ensures we only
793+
// receive attestations on our validator's subnets. Import everything.
794+
break :blk true;
799795
};
800796

801797
if (should_import) {

0 commit comments

Comments
 (0)