celestia-node icon indicating copy to clipboard operation
celestia-node copied to clipboard

feat: add DisableP2P configuration option for storage-only nodes

Open Copilot opened this issue 8 months ago • 1 comments

This PR adds a new DisableP2P configuration option that allows running Bridge nodes in storage-only mode without any p2p networking components. This addresses the need for hosted RPC providers and other use cases that only require data storage and API serving capabilities.

Changes

Configuration

  • Added DisableP2P bool field to p2p.Config with default value false
  • When enabled, disables all p2p networking modules while preserving core functionality

P2P Module

  • Modified p2p.ConstructModule() to return minimal components when DisableP2P=true
  • Skips initialization of: DHT, PubSub, Host, routing, and other networking components

Share Module

  • Made p2p dependencies optional in shrex, bitswap, and peer management components
  • Added null checks to gracefully handle missing Host and other p2p dependencies
  • Shrex servers/clients return nil when p2p is disabled
  • Bitswap components skip p2p functionality when Host is unavailable

Header Module

  • Made PubSub and Host dependencies optional for Subscriber and ExchangeServer
  • Added null checks to prevent panics when p2p components are unavailable

Fraud Module

  • Made PubSub and Host dependencies optional for ProofService
  • Returns stub service when p2p is disabled

What's Disabled When DisableP2P=true

  • DHT (Distributed Hash Table)
  • PubSub/Gossip networking
  • P2P Host initialization
  • Shrex servers and clients
  • Bitswap servers and clients
  • Peer discovery and management
  • P2P fraud proof distribution

What's Preserved

  • Core gRPC connections to Celestia Core
  • EDS storage functionality
  • RPC/API serving capabilities
  • Header synchronization (from Core)
  • Local fraud detection
  • All non-p2p node functionality

Usage

[P2P]
DisableP2P = true

This configuration enables storage-only mode, ideal for:

  • Hosted RPC providers
  • Data archival services
  • Internal infrastructure nodes
  • Development/testing environments

Testing

  • Added unit tests for DisableP2P configuration option
  • Added integration test for storage-only bridge node creation
  • Verified all modified modules compile successfully
  • Ensured graceful handling of nil p2p dependencies across all components

Fixes #4296.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://168.63.129.16:80/machine/
    • Triggering command: /usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Jun 03 '25 14:06 Copilot

Generally don't construct nil components. If you don't need component, just don't call constructor and don't provide it to fx

Fixed in commit b6f09e6. Refactored all modules to use conditional fx.Provide calls instead of constructing nil components. The fraud, header, and p2p modules now properly use FX dependency injection patterns.

Copilot avatar Jun 03 '25 16:06 Copilot