mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-24 20:47:17 +00:00
Expand gossip duplicate cache time (#2542)
## Issue Addressed NA ## Proposed Changes This PR expands the time that entries exist in the gossip-sub duplicate cache. Recent investigations found that this cache is one slot (12s) shorter than the period for which an attestation is permitted to propagate on the gossip network. Before #2540, this was causing peers to be unnecessarily down-scored for sending old attestations. Although that issue has been fixed, the duplicate cache time is increased here to avoid such messages from getting any further up the networking stack then required. ## Additional Info NA
This commit is contained in:
parent
9fb94fbebe
commit
4405425726
@ -21,6 +21,20 @@ pub const GOSSIP_MAX_SIZE: usize = 1_048_576;
|
||||
/// This is a constant to be used in discovery. The lower bound of the gossipsub mesh.
|
||||
pub const MESH_N_LOW: usize = 6;
|
||||
|
||||
/// The cache time is set to accommodate the circulation time of an attestation.
|
||||
///
|
||||
/// The p2p spec declares that we accept attestations within the following range:
|
||||
///
|
||||
/// ```ignore
|
||||
/// ATTESTATION_PROPAGATION_SLOT_RANGE = 32
|
||||
/// attestation.data.slot + ATTESTATION_PROPAGATION_SLOT_RANGE >= current_slot >= attestation.data.slot
|
||||
/// ```
|
||||
///
|
||||
/// Therefore, we must accept attestations across a span of 33 slots (where each slot is 12
|
||||
/// seconds). We add an additional second to account for the 500ms gossip clock disparity, and
|
||||
/// another 500ms for "fudge factor".
|
||||
pub const DUPLICATE_CACHE_TIME: Duration = Duration::from_secs(33 * 12 + 1);
|
||||
|
||||
// We treat uncompressed messages as invalid and never use the INVALID_SNAPPY_DOMAIN as in the
|
||||
// specification. We leave it here for posterity.
|
||||
// const MESSAGE_DOMAIN_INVALID_SNAPPY: [u8; 4] = [0, 0, 0, 0];
|
||||
@ -227,8 +241,7 @@ pub fn gossipsub_config(fork_context: Arc<ForkContext>) -> GossipsubConfig {
|
||||
.history_gossip(3)
|
||||
.validate_messages() // require validation before propagation
|
||||
.validation_mode(ValidationMode::Anonymous)
|
||||
// prevent duplicates for 550 heartbeats(700millis * 550) = 385 secs
|
||||
.duplicate_cache_time(Duration::from_secs(385))
|
||||
.duplicate_cache_time(DUPLICATE_CACHE_TIME)
|
||||
.message_id_fn(gossip_message_id)
|
||||
.fast_message_id_fn(fast_gossip_message_id)
|
||||
.allow_self_origin(true)
|
||||
|
Loading…
Reference in New Issue
Block a user