Categorygithub.com/devlongs/light-devp2p
module
0.0.0-20250108212502-a429d68ae01e
Repository: https://github.com/devlongs/light-devp2p.git
Documentation: pkg.go.dev

# README

light-devp2p

A lightweight implementation of Ethereum's devp2p protocol. This project provides a minimal, educational implementation of peer-to-peer networking using the core concepts of Ethereum's network layer.

Features

  • Minimal devp2p implementation
  • Node discovery and peer management
  • Secure communication using ECDSA keys
  • Configurable network parameters
  • debug logging
  • Bootnode supports

Installation

git clone https://github.com/devlongs/light-devp2p.git
cd light-devp2p
go mod tidy

Running Nodes

  1. Start the first node:
go run main.go -addr :30303
  1. Start the second node:
go run main.go -addr :30304 -bootnode "enode://[public-key]@127.0.0.1:30303"

Configuration

Available command-line options:

FlagDescriptionDefault
-addrListen address":30303"
-bootnodeBootnode enode URL""
-maxpeersMaximum peer connections10
-nodenameNode identifier"MinimalP2PNode"
-metricsEnable metrics collectionfalse

Project Structure

light-devp2p/
├── main.go           # Entry point
├── go.mod           # Go module file
├── node/
│   ├── node.go      # Core node implementation
│   ├── peer.go      # Peer management
│   └── protocol.go  # Protocol implementation
└── config/
    └── config.go    # Configuration handling

Main Components

The implementation is organized around three main components:

  1. Node
  • Manages the P2P server
  • Handles peer connections
  • Implements protocol communication
  1. Peer Manager
  • Tracks active connections
  • Manages peer lifecycle
  • Handles peer state
  1. Protocol
  • Defines message types
  • Implements handshake
  • Manages message exchange

# Packages

No description provided by the author
No description provided by the author
No description provided by the author