Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Glossary

Gossipsub

Gossipsub is a robust and scalable publish-subscribe (pubsub) protocol designed for efficient, topic-based message propagation in decentralized peer-to-peer networks.
Chainscore © 2026
definition
PEER-TO-PEER NETWORK PROTOCOL

What is Gossipsub?

Gossipsub is a robust and scalable peer-to-peer (P2P) messaging protocol designed for blockchain networks, enabling efficient and resilient propagation of messages like transactions and blocks.

Gossipsub is a pubsub (publish-subscribe) protocol that organizes nodes into an unstructured mesh network for reliable message delivery and a structured gossip network for efficient peer discovery. This dual-layer architecture allows nodes to maintain persistent connections with a subset of peers (the mesh) while periodically exchanging metadata about message availability with a broader set of peers (the gossip). This design is a significant evolution from simpler flooding protocols like Floodsub, as it reduces redundant message transmission and network bandwidth consumption while maintaining strong security properties against eclipse attacks and Sybil attacks.

The protocol's core mechanism involves topic-based message routing, where nodes subscribe to specific channels (e.g., blocks, transactions). Key operational parameters control the protocol's behavior: the D parameter defines the desired mesh degree (number of direct connections), D_low and D_high set bounds for maintaining mesh stability, and heartbeat intervals regulate periodic gossip exchanges and peer scoring updates. Peer scoring is a critical security feature that penalizes misbehaving nodes—such as those sending spam or invalid messages—by reducing their score, which can lead to mesh pruning or connection termination.

Gossipsub v1.1, the version most widely implemented, introduced several enhancements for attack resilience. These include Peer eXchange (PX) for secure peer discovery, opportunistic grafting to recover from attacks, and prune backoff to prevent a node from being repeatedly pruned and re-grafted. The protocol's message propagation follows a pull-push model: nodes actively send messages to their mesh peers (push) and can request missing messages via IWant control messages (pull) after hearing about them through gossip.

Originally developed for libp2p, the modular networking stack, Gossipsub is the default pubsub protocol for major blockchain platforms including Ethereum 2.0 (for consensus messages and attestations), Filecoin, and Polkadot. Its design prioritizes scalability for thousands of nodes and resilience in adversarial environments, making it a foundational component for decentralized application (dApp) communication, blockchain data dissemination, and oracle networks that require robust, low-latency messaging.

how-it-works
PEER-TO-PEER NETWORKING

How Gossipsub Works

Gossipsub is a robust and efficient peer-to-peer publish-subscribe protocol designed for blockchain and decentralized networks, balancing message delivery speed with network resilience against attacks.

Gossipsub is a pubsub (publish-subscribe) protocol that organizes network participants into a mesh topology for efficient message propagation. Unlike simple flooding, nodes form long-lived connections with a subset of peers, creating a stable mesh for each topic. Within this mesh, a subset of connections is designated as gossip links, used to periodically exchange metadata about which messages peers have seen. This hybrid structure—a stable mesh for direct delivery and gossip links for metadata exchange—enables the protocol to efficiently discover and fill message gaps without redundant data transmission.

The protocol operates through three core message types: IWANT, IHAVE, and GRAFT/PRUNE. When a node receives a gossip message via an IHAVE notification listing a message ID it hasn't seen, it can request the full content with an IWANT control message. The mesh membership is dynamically managed: peers who consistently forward valid messages may be grafted into the mesh, while inactive or misbehaving peers are pruned. This continuous optimization ensures the mesh remains composed of well-connected, reliable peers, maintaining low latency for message delivery across the network.

Gossipsub's security model is centered on peer scoring and attack resilience. Each peer is assigned a score based on its behavior, penalizing actions like sending invalid messages, spamming control traffic, or failing to forward messages. Peers with low scores are disconnected or ignored, mitigating eclipse attacks and Sybil attacks. The protocol also employs message validation, where applications can define rules to reject invalid data before it is forwarded. This combination of incentive engineering and application-layer validation makes Gossipsub suitable for adversarial environments like public blockchains, where it is used by networks including Filecoin and Ethereum 2.0.

key-features
PROTOCOL MECHANICS

Key Features of Gossipsub

Gossipsub is a robust, extensible pub/sub (publish/subscribe) protocol designed for efficient, resilient, and secure message propagation in peer-to-peer networks. Its core features address the limitations of naive flooding and random peer selection.

01

Topic-Based Mesh Networks

Instead of broadcasting to all peers, nodes organize into topic-specific meshes. A node interested in a topic joins a mesh of other peers subscribed to the same topic, creating a stable, connected overlay network for efficient message delivery within that interest group.

02

Dual Peer Selection: Mesh & Gossip

Gossipsub maintains two sets of peers for each topic to balance efficiency and robustness.

  • Mesh Peers: A connected set of stable peers for direct message forwarding.
  • Gossip Peers: A larger set of peers used to periodically exchange message IDs (through IWANT/IHAVE control messages) to recover missing messages and enhance propagation, acting as a safety net.
03

Heartbeat & Peer Scoring

A periodic heartbeat process maintains network health by:

  • Pruning and grafting mesh connections to optimize topology.
  • Exchanging control messages with gossip peers.
  • Integrating with a peer scoring system that penalizes malicious behavior (e.g., spamming, lying) and rewards helpful peers, allowing the network to self-heal and resist attacks.
04

Control Message Primitives

Gossipsub uses specific control messages to manage state and efficiency:

  • GRAFT/PRUNE: Manage mesh membership.
  • IHAVE/IWANT: Allow peers to advertise and request missed messages without retransmitting the full payload, reducing duplicate bandwidth usage.
  • Control message piggybacking bundles these signals to minimize overhead.
05

Resistance to Network Attacks

The protocol is designed to mitigate common P2P attacks:

  • Eclipse Attacks: Defended by mesh stability and peer scoring.
  • Spam Attacks: Mitigated by message validation, scoring penalties, and rate limiting.
  • Sybil Attacks: Addressed through resource-costly peer scoring penalties and the requirement for attackers to maintain long-term good behavior within the mesh.
ecosystem-usage
PRACTICAL APPLICATIONS

Where is Gossipsub Used?

Gossipsub is a foundational peer-to-peer messaging protocol, not a standalone application. Its primary role is to provide efficient, scalable, and robust message propagation for decentralized networks.

06

Core Protocol Features in Practice

The specific features of Gossipsub address critical network needs:

  • Topic-Based Messaging: Allows nodes to subscribe only to relevant data (e.g., /eth2/beacon_block), reducing bandwidth.
  • Peer Scoring: Mitigates eclipse attacks and spam by penalizing misbehaving peers, a necessity in permissionless networks.
  • Mesh Formation: Creates stable, efficient connections among subscribers for low-latency propagation, crucial for consensus.
6-12
Default Mesh Degree (D)
3
Default Gossip Factor (D_low)
PROTOCOL COMPARISON

Gossipsub vs. Other PubSub Protocols

A feature and performance comparison of Gossipsub against common pubsub protocol designs.

Feature / MetricGossipsub (libp2p)FloodsubRandomized Epidemic Broadcast

Primary Design Goal

Scalable, attack-resilient message propagation

Simple, reliable broadcast

Fast, probabilistic dissemination

Message Propagation Method

Structured mesh with gossip and heartbeat

Naive flooding to all peers

Random peer selection per round

Network Topology

Dual-layer (mesh for routing, graft/prune for peers)

Unstructured (flat peer list)

Unstructured (random graph)

Bandwidth Efficiency

High (targeted propagation via mesh)

Low (floods entire network)

Medium (probabilistic redundancy)

Latency

Low (optimized direct paths)

High (sequential flooding)

Medium (depends on fanout)

Resistance to Eclipse Attacks

High (peer scoring, mesh maintenance)

None

Low

Resistance to Spam Attacks

High (peer and message scoring)

None

Low

Implementation Complexity

High

Very Low

Medium

technical-components
GOSSIPSUB

Core Technical Components

GossipSub is a peer-to-peer (P2P) pub/sub (publish-subscribe) protocol designed for high-throughput, resilient, and censorship-resistant message propagation in decentralized networks.

01

Mesh & Heartbeat

At its core, GossipSub organizes nodes into a structured overlay network. Each node maintains two peer lists:

  • Mesh Peers: A stable, connected set of peers for direct message delivery.
  • Gossip Peers: A larger set used for periodic metadata exchange to discover new content and peers. A heartbeat protocol runs periodically to maintain these lists, graft/ prune peers, and exchange control messages, ensuring network health and topic-specific connectivity.
02

Topic-Based Flooding

GossipSub uses a topic-based routing model. Nodes subscribe to topics (e.g., block, transaction) they are interested in. Messages are only propagated to peers also subscribed to that topic. This is more efficient than floodsub's naive flooding to all peers. Propagation occurs in two phases:

  1. Direct Push: To all mesh peers in the topic.
  2. Gossip (IHAVE/IWANT): Peers exchange message IDs via gossip; missing messages are explicitly requested, reducing duplicate traffic.
03

Peer Scoring & Attack Mitigation

A key innovation is its peer scoring system to defend against Sybil and eclipse attacks. Each peer is scored based on behavior:

  • Positive actions: Forwarding valid messages promptly.
  • Negative actions: Sending spam, invalid messages, or being unresponsive. Low-scoring peers are penalized (e.g., removed from mesh, blocked). This creates a cost-of-attack and incentivizes honest participation, making the network resilient.
04

Graft & Prune Control Messages

Network topology is dynamically managed via control messages:

  • GRAFT: A request to add a peer to the local mesh for a topic.
  • PRUNE: A request to remove a peer from the mesh. These messages are sent during the heartbeat. Pruning can include a backoff period, preventing a pruned peer from being re-grafted immediately. This allows the network to adapt to churn and optimize connectivity based on peer performance and scoring.
05

IHAVE/IWANT Message Exchange

This lazy pull mechanism optimizes bandwidth. Instead of blindly pushing all messages, peers periodically gossip IHAVE messages containing Message IDs of recent messages they have. If a receiving peer lacks a message and wants it, it responds with an IWANT request for the specific IDs. This pull-based recovery minimizes duplicate data transmission and is crucial for handling message bursts and peers joining late.

security-considerations
GOSSIPSUB

Security Considerations & Attack Vectors

GossipSub is a peer-to-peer pubsub protocol designed for scalability and security, but its design introduces specific attack surfaces that network operators must mitigate.

01

Eclipse Attacks

An attacker isolates a target node by monopolizing its peer connections, controlling all incoming and outgoing message flow. In GossipSub, this can be achieved by:

  • Sybil Attacks: Creating many malicious peer identities.
  • Connection Starvation: Flooding the target's connection slots.
  • Mitigation: Defenses include peer scoring, limiting connections per peer, and using trusted bootnodes.
02

Spam & DoS Attacks

The protocol's mesh structure is vulnerable to resource exhaustion via message flooding. Key vectors include:

  • Message Flooding: Publishing a high volume of invalid or irrelevant messages to waste bandwidth and CPU.
  • Control Message Spam: Sending excessive GRAFT/PRUNE or IHAVE/IWANT messages to disrupt mesh maintenance.
  • Mitigation: Peer scoring penalizes spammers, and rate limiting (e.g., gossipsubD parameters) throttles incoming messages.
03

Peer Scoring & Incentives

GossipSub's primary defense is a cryptoeconomic scoring system that ranks peers based on behavior. Scores influence:

  • Mesh Membership: Poorly scored peers are pruned from the mesh.
  • Message Forwarding: Messages from malicious peers are ignored.
  • Scoring Metrics: Based on message validity, timing, and protocol adherence. A peer's score decays over time, allowing for rehabilitation.
04

Topic Grafting Attacks

Attackers exploit the mesh maintenance protocol to degrade performance or censor messages.

  • Rapid Graft/Prune: An attacker quickly joins and leaves a topic mesh (GRAFT), forcing the victim to waste resources on topology adjustments.
  • Mesh Disruption: By strategically grafting, an attacker can partition the mesh or increase its diameter, delaying message propagation.
  • Mitigation: Implementing graft/prune cooldown periods and using positive scoring for stable peers.
05

Metadata Leakage

The gossip protocol can inadvertently reveal network topology and node relationships.

  • Passive Analysis: Observing IHAVE/IWANT control messages can map which peers are subscribed to which topics.
  • Active Probing: An attacker can join the mesh and analyze graft/prune patterns to infer the network graph.
  • Implication: This weakens privacy and can inform targeted eclipse or spam attacks. Dandelion++ is a related protocol that addresses some message origin privacy concerns.
06

Implementation & Parameter Risks

Security heavily depends on correct implementation and configuration of protocol parameters.

  • Parameter Tuning: Settings for D (mesh degree), D_low, D_high, and heartbeat interval must balance resilience and overhead. Poor tuning can make attacks easier.
  • Score Function: The peer scoring function must be carefully calibrated to avoid false positives (censoring good peers) or false negatives (accepting malicious peers).
  • Reference: The libp2p implementation's default parameters are a starting point, but networks often require customization.
DEBUNKING MYTHS

Common Misconceptions About Gossipsub

Gossipsub is a foundational peer-to-peer pubsub protocol, but its design choices are often misunderstood. This section clarifies prevalent inaccuracies regarding its security, scalability, and operational mechanics.

No, Gossipsub is not designed to be a fully secure or private messaging protocol on its own; it is a scalable message propagation layer that requires additional protocols for confidentiality and strong security. Its primary goals are efficiency and resilience against basic network attacks like eclipse attacks and sybil attacks. For privacy, messages are propagated in plaintext by default. Applications must layer encryption (e.g., via libp2p's Secio or Noise) on top for confidentiality. Furthermore, while it incorporates peer scoring and mesh formation rules to mitigate spam, it does not provide cryptographic guarantees of message integrity or origin authentication at the protocol layer—those must be implemented by the application.

GOSSUPSUB

Frequently Asked Questions (FAQ)

Common questions about Gossipsub, the peer-to-peer messaging protocol used by Ethereum, Filecoin, and other major blockchain networks for efficient and robust data dissemination.

Gossipsub is a pub/sub (publish/subscribe) messaging protocol designed for decentralized peer-to-peer networks, using a hybrid of epidemic (gossip) dissemination and a structured mesh network for efficiency. It works by organizing nodes into two overlapping networks: a mesh of stable, connected peers for message forwarding and a fanout used by publishing nodes to reach their subscribers. Peers in the mesh periodically exchange gossip about messages they have seen, ensuring robust propagation and resistance to attacks like eclipse attacks or sybil attacks. This structure provides low-latency message delivery with strong resilience, making it ideal for block and transaction propagation in blockchains.

ENQUIRY

Get In Touch
today.

Our experts will offer a free quote and a 30min call to discuss your project.

NDA Protected
24h Response
Directly to Engineering Team
10+
Protocols Shipped
$20M+
TVL Overall
NDA Protected Directly to Engineering Team
What is Gossipsub? | Blockchain P2P Protocol | ChainScore Glossary