increase the max topic subscriptions #4581 (#4588)

* increase the max topic subscriptions #4581

* make the max_subscription limitation based off constants / configuration

* format

* wording & add deneb topic array

* reduce max_subscriptions_per_request to 2x

* format

* update comment
This commit is contained in:
Stefan 2023-09-13 09:06:33 +02:00 committed by GitHub
parent 8e7b57a794
commit 4a31e369bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -15,7 +15,8 @@ use crate::service::behaviour::BehaviourEvent;
pub use crate::service::behaviour::Gossipsub;
use crate::types::{
fork_core_topics, subnet_from_topic_hash, GossipEncoding, GossipKind, GossipTopic,
SnappyTransform, Subnet, SubnetDiscovery,
SnappyTransform, Subnet, SubnetDiscovery, ALTAIR_CORE_TOPICS, BASE_CORE_TOPICS,
CAPELLA_CORE_TOPICS, DENEB_CORE_TOPICS, LIGHT_CLIENT_GOSSIP_TOPICS,
};
use crate::EnrExt;
use crate::Eth2Enr;
@ -224,6 +225,15 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
// Set up a scoring update interval
let update_gossipsub_scores = tokio::time::interval(params.decay_interval);
let max_topics = ctx.chain_spec.attestation_subnet_count as usize
+ SYNC_COMMITTEE_SUBNET_COUNT as usize
+ BLOB_SIDECAR_SUBNET_COUNT as usize
+ BASE_CORE_TOPICS.len()
+ ALTAIR_CORE_TOPICS.len()
+ CAPELLA_CORE_TOPICS.len()
+ DENEB_CORE_TOPICS.len()
+ LIGHT_CLIENT_GOSSIP_TOPICS.len();
let possible_fork_digests = ctx.fork_context.all_fork_digests();
let filter = gossipsub::MaxCountSubscriptionFilter {
filter: utils::create_whitelist_filter(
@ -232,9 +242,10 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
SYNC_COMMITTEE_SUBNET_COUNT,
BLOB_SIDECAR_SUBNET_COUNT,
),
max_subscribed_topics: 200,
// during a fork we subscribe to both the old and new topics
max_subscribed_topics: max_topics * 4,
// 162 in theory = (64 attestation + 4 sync committee + 7 core topics + 6 blob topics) * 2
max_subscriptions_per_request: 160,
max_subscriptions_per_request: max_topics * 2,
};
let gossipsub_config_params = GossipsubConfigParams {

View File

@ -18,5 +18,6 @@ pub use subnet::{Subnet, SubnetDiscovery};
pub use sync_state::{BackFillState, SyncState};
pub use topics::{
core_topics_to_subscribe, fork_core_topics, subnet_from_topic_hash, GossipEncoding, GossipKind,
GossipTopic, LIGHT_CLIENT_GOSSIP_TOPICS,
GossipTopic, ALTAIR_CORE_TOPICS, BASE_CORE_TOPICS, CAPELLA_CORE_TOPICS, DENEB_CORE_TOPICS,
LIGHT_CLIENT_GOSSIP_TOPICS,
};