Home

Awesome

<h1 align="center"> <a href="https://libp2p.io"><img width="250" src="./.assets/full-logo.svg?raw=true" alt="nim-libp2p logo" /></a> </h1> <h3 align="center">The <a href="https://nim-lang.org/">Nim</a> implementation of the <a href="https://libp2p.io/">libp2p</a> Networking Stack.</h3> <p align="center"> <a href="https://github.com/vacp2p/nim-libp2p/actions"><img src="https://github.com/vacp2p/nim-libp2p/actions/workflows/ci.yml/badge.svg" /></a> <a href="https://codecov.io/gh/vacp2p/nim-libp2p"><img src="https://codecov.io/gh/vacp2p/nim-libp2p/branch/master/graph/badge.svg?token=UR5JRQ249W"/></a> </p> <p align="center"> <a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" /></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" /></a> <img src="https://img.shields.io/badge/nim-%3E%3D1.2.0-orange.svg?style=flat-square" /> </p>

Table of Contents

Background

libp2p is a Peer-to-Peer networking stack, with implementations in multiple languages derived from the same specifications.

Building large scale peer-to-peer systems has been complex and difficult in the last 15 years and libp2p is a way to fix that. It's striving to be a modular stack, with sane and secure defaults, useful protocols, while remain open and extensible. This implementation in native Nim, relying on chronos for async. It's used in production by a few projects

Learn more about libp2p at libp2p.io and follow libp2p's documentation docs.libp2p.io.

Install

Prerequisite

The currently supported Nim version is 1.6.18.

nimble install libp2p

Getting Started

You'll find the nim-libp2p documentation here.

Testing

Remember you'll need to build the go-libp2p-daemon binary to run the nim-libp2p tests. To do so, please follow the installation instructions in daemonapi.md.

Modules

List of packages modules implemented in nim-libp2p:

NameDescription
Libp2p
libp2pThe core of the project
connmanagerConnection manager
identify / push identifyIdentify protocol
pingPing protocol
libp2p-daemon-clientgo-daemon nim wrapper
interop-libp2pInterop tests
Transports
libp2p-tcpTCP transport
libp2p-wsWebSocket & WebSocket Secure transport
libp2p-torTor Transport
Secure Channels
libp2p-noiseNoise secure channel
libp2p-plaintextPlain Text for development purposes
Stream Multiplexers
libp2p-mplexMPlex multiplexer
libp2p-yamuxYamux multiplexer
Data Types
peer-idCryptographic identifiers
peer-store"Address book" of known peers
multiaddressComposable network addresses
signed envelopeSigned generic data container
routing recordSigned peer dialing informations
discovery managerDiscovery Manager
Utilities
libp2p-cryptoCryptographic backend
libp2p-crypto-secp256k1
Pubsub
libp2p-pubsubPub-Sub generic interface
libp2p-floodsubFloodSub implementation
libp2p-gossipsubGossipSub implementation

Users

nim-libp2p is used by:

Stability

nim-libp2p has been used in production for over a year in high-stake scenarios, so its core is considered stable. Some modules are more recent and less stable.

The versioning follows semver, with some additions:

We aim to be compatible at all time with at least 2 Nim MINOR versions, currently 1.6 & 2.0

Development

Clone and Install dependencies:

git clone https://github.com/vacp2p/nim-libp2p
cd nim-libp2p
# to use dependencies computed by nimble
nimble install -dy
# OR to install the dependencies versions used in CI
nimble install_pinned

Run unit tests:

# run all the unit tests
nimble test

This requires the go daemon to be available. To only run native tests, use nimble testnative. Or use nimble tasks to show all available tasks.

Contribute

The libp2p implementation in Nim is a work in progress. We welcome contributors to help out! Specifically, you can:

Contributors

<a href="https://github.com/vacp2p/nim-libp2p/graphs/contributors"><img src="https://contrib.rocks/image?repo=vacp2p/nim-libp2p" alt="nim-libp2p contributors"></a>

Core Maintainers

<table> <tbody> <tr> <td align="center"><a href="https://github.com/Menduist"><img src="https://avatars.githubusercontent.com/u/13471753?v=4?s=100" width="100px;" alt="Tanguy"/><br /><sub><b>Tanguy (Menduist)</b></sub></a></td> <td align="center"><a href="https://github.com/lchenut"><img src="https://avatars.githubusercontent.com/u/11214565?v=4?s=100" width="100px;" alt="Ludovic"/><br /><sub><b>Ludovic</b></sub></a></td> <td align="center"><a href="https://github.com/diegomrsantos"><img src="https://avatars.githubusercontent.com/u/7316595?v=4?s=100" width="100px;" alt="Diego"/><br /><sub><b>Diego</b></sub></a></td> </tr> </tbody> </table>

Compile time flags

Enable expensive metrics (ie, metrics with per-peer cardinality):

nim c -d:libp2p_expensive_metrics some_file.nim

Set list of known libp2p agents for metrics:

nim c -d:libp2p_agents_metrics -d:KnownLibP2PAgents=nimbus,lighthouse,lodestar,prysm,teku some_file.nim

Specify gossipsub specific topics to measure in the metrics:

nim c -d:KnownLibP2PTopics=topic1,topic2,topic3 some_file.nim

License

Licensed and distributed under either of

or

at your option. These files may not be copied, modified, or distributed except according to those terms.