Download Latest Version v2.0.0 source code.tar.gz (848.7 kB)
Email in envelope

Get an email when there's a new version of libp2p

Home / v2.0.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2026-06-01 36.1 kB
v2.0.0 source code.tar.gz 2026-06-01 848.7 kB
v2.0.0 source code.zip 2026-06-01 1.1 MB
Totals: 3 Items   2.0 MB 0

Highlights

  • Connection management gained high/low watermark pruning, peer scoring, protected peers, decaying tags, and composable hard-limit + trimming modes, exposed through SwitchBuilder.withWatermarkPolicy, withPeerScoring, withMaxConnections, and withMaxInOut.
  • LPProtocol now supports incoming/outgoing stream budgets, including total and per-peer limits.
  • Service Discovery landed, including advertiser, registrar, discoverer, signed extended peer records, routing-table management, component tests, and C binding support.
  • C bindings were significantly expanded with configurable transports and muxers, Kademlia validators/selectors, circuit relay, AutoNAT, peerstore APIs, service discovery APIs, and custom protocol handlers.
  • SwitchBuilder and connection management were reworked around connection limits, watermarks, peer scoring, address policies, announced addresses, NAT configuration, hole punching, and Identify Push.
  • GossipSub gained extension-based ping/pong, preamble, and partial-message support, H/M/L message priorities, slow-peer scoring controls, improved queue behavior, and broader interoperability coverage.
  • Kademlia gained metrics, configurable record TTLs, provider rejection/spillover support, optional bootstrapping disablement, privacy-preserving connection-status hiding, and several race fixes.
  • Transport and stream handling improved with QUIC multi-address listening, stream reset support, stricter transport start errors, WebSocket accept concurrency fixes, and better cancellation propagation.
  • Crypto and dependency handling were hardened with a libp2p-owned Rng abstraction, BoringSSL wiring, deterministic Ed25519 keys from seed, RSA key-size validation, and refreshed Nim/Nimble/Nix dependency metadata.
  • New network simulation tooling, Gossipsub/transport unified-testing interop helpers, and many flaky-test fixes were added.
  • Identify Push support was added as a switch service, enabled by default in SwitchBuilder and configurable with withIdentifyPusher, so peers can be notified when local peer information changes.
  • Address announcement support improved with withAnnouncedAddresses, withPrivateAddressFilter.
  • PubSub and stream write paths now use sink in several hot paths to reduce message/buffer copies.

Breaking changes

  • The minimum supported Nim version is now 2.2.4. The tested versions are 2.2.4 and 2.2.10.
  • The Mix protocol was extracted from this repository into logos-co/nim-libp2p-mix. Imports under libp2p/protocols/mix, Mix tests/examples/docs, MixPubKeyBook, and the libp2p_mix_* C APIs were removed.
  • Public APIs that used std/options.Option now use results.Opt. Migrate some(...) / none(...) call sites to Opt.some(...) / Opt.none(...) where required.
  • Public RNG-facing APIs now use the libp2p Rng type instead of ref HmacDrbgContext / var HmacDrbgContext. Use newRng() or wrap existing BearSSL RNG state with the compatibility helper where needed.
  • newStandardSwitch and newStandardSwitchBuilder were removed from the public API. Use SwitchBuilder.new()...build() instead.
  • Manual switch construction changed: newSwitch was removed, and SwitchBuilder is now the supported stable path for building switches.
  • SwitchBuilder.withServices was removed. Service is now an internal switch lifecycle abstraction; externally created background work should be managed by the application. Service methods changed as well: setup is synchronous and may raise ServiceSetupError, run was renamed to start, and lifecycle methods no longer return bool.
  • Connection limit configuration changed. withMaxIn and withMaxOut were removed; use withMaxInOut(...), withMaxConnections(...), or withConnectionLimits(...). Also, maxConnsPerPeer now enforces the configured value exactly; custom values may allow one fewer connection than before because an off-by-one bug was fixed.
  • ConnManager.new now takes structured limit/watermark/scoring configuration instead of the old maxConnections, maxIn, and maxOut argument set.
  • Several public buffer APIs now take sink seq[byte] and may consume buffers with move(...) to reduce copies, including PubSub publish and stream/protobuf write paths. Normal call sites usually continue to compile, but custom overrides, wrapper proc types, or code that reuses/mutates a buffer after passing it to libp2p may need updates.
  • PubSub/GossipSub priority APIs changed from boolean priority flags to MessagePriority.High, MessagePriority.Medium, and MessagePriority.Low. Deprecated send / broadcast overloads taking isHighPriority were removed.
  • GossipSubParams.maxNumElementsInNonPriorityQueue was removed. Use maxMediumPriorityQueueLen and maxLowPriorityQueueLen.
  • PubSub custom connection naming was changed to stream naming: for example useCustomConn became useCustomStream, and custom connection callbacks became custom stream callbacks.
  • GossipSub preamble and ping/pong behavior moved to the extension system. Do not rely on -d:libp2p_gossipsub_1_4; configure the relevant extension through GossipSubParams.
  • LPProtocol stream limits changed. maxIncomingStreams was replaced by total/per-peer incoming and outgoing stream limit fields: maxIncomingStreamsTotal, maxIncomingStreamsPerPeer, maxOutgoingStreamsTotal, and maxOutgoingStreamsPerPeer.
  • Kademlia module/type names changed in a few places: routingtable was renamed to routing_table, and TimeStamp was renamed to Timestamp.
  • Kademlia now hides connection status by default when encoding peer records. Pass the relevant config/encode option if your application intentionally needs the old behavior.
  • Kademlia locally stored value records now expire after the configured TTL. Code relying on indefinite local PUT_VALUE retention should set an appropriate recordExpirationInterval.
  • Transport start behavior is stricter. TCP, WebSocket, QUIC, and Tor transports now raise TransportStartError on unsupported or non-wire addresses instead of silently skipping or accepting them.
  • RSA key handling is stricter: imported RSA keys below 2048 bits and RSA keys above 4096 bits are rejected.
  • The C binding ABI changed. libp2p_config_t no longer uses the old flags bitmask, stream callbacks were renamed from connection-oriented names to stream-oriented names, Mix APIs were removed, and users should rebuild against the v2 header.

Switch creation

newStandardSwitch and newStandardSwitchBuilder were removed. Use SwitchBuilder:

:::nim
let switch = SwitchBuilder
  .new()
  .withAddress(MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet())
  .withTcpTransport()
  .withMplex()
  .build()

Options API

Public APIs moved from std/options.Option to results.Opt:

:::nim
# before
publishParams = some(PublishParams(...))

# after
publishParams = Opt.some(PublishParams(...))

RNG API

Public RNG-facing APIs now use libp2p Rng:

:::nim
# before
let rng: ref HmacDrbgContext = newRng()

# after
let rng: Rng = newRng()

Connection limits

Use structured connection limit configuration:

:::nim
# before
.withMaxIn(30)
.withMaxOut(20)

# after
.withMaxInOut(30, 20)

Pubsub sink/move

:::nim
var data = @[byte 1, 2, 3]
discard await pubsub.publish(topic, move(data))
# Do not read or mutate `data` after this point.

What's Changed

New Contributors

Full Changelog: https://github.com/vacp2p/nim-libp2p/compare/v1.15.3...v2.0.0

Source: README.md, updated 2026-06-01