Feedback
Sign in./start

Site navigation

Theme

Learn

  • Roadmaps

Build

  • Projects
  • Developer Tools

Contribute

  • Open Source Projects
  • Issues
  • Reviews
  • First Contribution
  • BountiesSoon
  • Feedback

Prove

  • Builders

Ecosystem

  • Partners
  • Get Funded↗
  • HackathonsSoon
Sign in./start-building

Become an Open Source Builder. Learn. Build. Contribute. Prove.

Feedback welcome — open a GitHub issue.

Learn

RoadmapsStart Building

Build

ProjectsDeveloper Tools

Contribute

Open Source ProjectsIssuesReviewsFirst ContributionSupportFeedback

Prove

Builders Directory

Account

Sign in

Legal

PrivacyTermsCredits

© 2026 Pull // code MIT · curriculum CC BY-SA 4.0

PrivacyTermsCredits

lesson // bitcoin

P2P Network

How nodes discover peers, relay transactions, and gossip blocks.

intermediate5 days

Public lesson — sign in to track progress on this roadmap.

./sign-in

On this page

Learning objectives

  • Describe peer discovery and relay at a high level
  • Explain compact block relay and why it matters
  • Know privacy tradeoffs of filters and light clients

study // plan

Lessons are primers. Start with Step 1 (required reading) when present, then follow the numbered steps in the article. Depth comes from primary sources, labs, reflection, and evidence.

Research on Bitcoin Search
BIP152BIP157

Step 1 // Required reading

Complete these before the numbered steps in the lesson body. Links are listed here once — not repeated below.

  • bookMastering Bitcoin

    Ch. 10: Bitcoin Network

Reflection prompts

  1. Explain P2P Network to a teammate without jargon - what problem does it solve?
  2. What would break in production if you misunderstood P2P Network?
  3. Which BIP, book chapter, or Core doc is authoritative here, and what did you verify?

Lab // Peer view on regtest

Complete Steps 2–3. On regtest (or Polar), inspect getpeerinfo / getnetworkinfo and note peer count, inbound/outbound, and sync state.

evidence required

  • ·getnetworkinfo or getpeerinfo excerpt (peer count / connections)
  • ·One sentence on what you observed vs expected for a healthy node
  • ·Link to Mastering Bitcoin Ch. 10 section you used
  1. 01

    Worked mental model

    Re-read the diagrams in this lesson once out loud in plain language. If you cannot explain the flow to a friend without jargon, pause and revisit the Mastering Bitcoin / Mastering Lightning chapters linked in Resources. Chapter references are intentional, not decorative.

  2. 02

    Hands-on habit

    Every protocol idea should be paired with one local experiment. That habit turns reading into builder instinct.

    1. Reproduce the happy path on regtest (or Polar for Lightning)
    2. Break it on purpose (wrong fee, expired invoice, offline peer)
    3. Write down what error you saw and which layer produced it (wallet, node, mempool, peer)
  3. 03

    Glossary check

    Pick three terms from this lesson and define them in one sentence each without opening notes. Weak definitions mean the lesson is not finished yet.

  4. 04

    Resource order

    Use Resources in order: narrative book chapter first, then BIP/BOLT for precision, then implementation docs for commands. Jumping straight to RPC flags without the mental model creates brittle knowledge.

Bitcoin is a gossip network of peers. There is no central server that “is Bitcoin.” Your node connects to other nodes, validates rules, and relays data.

Complete Step 1 // Required reading in the study plan above, then continue here. This opens Protocol Depth.

Step 2 — Core idea: discover, validate, gossip

Wallet backends, explorers, and Lightning nodes depend on healthy P2P connectivity. Sync problems, eclipse risks, and privacy leaks start at the network layer.

Analogy: Nodes as neighbors on radios. When someone announces a new transaction or block, others rebroadcast after validation. Compact tricks let them share “what’s new” without repeating everything they already have.

Loading diagram…

Peers validate then gossip; compact blocks reduce bandwidth.
  • Compact block relay (BIP-152) reconstructs new blocks using mempool txs already known
  • Compact block filters (BIP-157/158) help light clients find relevant txs with better privacy than old bloom filters

Light client privacy

Querying a random server for “txs to my address” leaks ownership. Prefer filters, client-side scanning, or your own node.

Builder habits

  • Run your own node for production backends when possible
  • Monitor peer count and IBD/sync state
  • Rate-limit and authenticate RPC — never expose it publicly

Done when: You can explain why compact blocks speed gossip without skipping validation.

Step 3 — Try it: inspect peers (lab)

bitcoin-cli -regtest getnetworkinfo
bitcoin-cli -regtest getpeerinfo

On a solo regtest node, peer count may be zero — that is fine. Note connection fields and sync/IBD-related status. On Polar or a mainnet/testnet node, compare peer diversity.

Common mistakes

  • Exposing bitcoind RPC to the internet
  • Assuming one explorer API equals full network view
  • Ignoring that different peers may temporarily see different mempools

Done when: Lab evidence (network/peer excerpt + observation + source link) is complete.

Next lesson

P2P Adversarial Thinking — eclipse, partitions, and hardening habits for operators.

further reading

  • bipBIP-152 Compact Block Relay
  • bipBIP-157/158 Compact Block Filters

review // club

Review club

Practice on real Bitcoin OSS changes tied to this chapter. Read the diff, use the checklist, and optionally paste your review comment URL in your lab notes.

  • BIP-152 compact block relay

    Read BIP-152 and explain how compact blocks reduce relay bandwidth during block propagation.

    spec review
    bandwidthmempool reconstruction
    45 min·advancedopen on GitHub
review checklist
  1. Does the change solve the stated problem?
  2. Are edge cases and rollout behavior covered?
  3. Are tests or test vectors included?
  4. Is the diff minimal and clearly explained?

More repos and GFIs on /discover and /issues.

progress // sign in

Reading is public. Sign in to mark lessons complete, sync across devices, and unlock your roadmap.

./sign-in-to-track

discussion

Discussion

prevMempool & FeesnextP2P Adversarial Thinking

On this page

Press Shift + ? for keyboard shortcuts.

Press R to research on Bitcoin Search.

No questions yet — be the first to ask.