Skip to content

chore: extract mix to logos-co/nim-libp2p-mix#2378

Merged
chaitanyaprem merged 6 commits into
masterfrom
extract-mix-to-nim-libp2p-mix
May 7, 2026
Merged

chore: extract mix to logos-co/nim-libp2p-mix#2378
chaitanyaprem merged 6 commits into
masterfrom
extract-mix-to-nim-libp2p-mix

Conversation

@chaitanyaprem
Copy link
Copy Markdown
Contributor

@chaitanyaprem chaitanyaprem commented Apr 30, 2026

Summary

Mix has been extracted out of nim-libp2p into its own repository at
logos-co/nim-libp2p-mix
so it can evolve independently of the core libp2p library. This PR
removes the mix code from nim-libp2p.

What's removed

  • Source: `libp2p/protocols/mix/` (tree) and `libp2p/protocols/mix.nim` (facade)
  • Tests: `tests/libp2p/mix/`
  • Example: `examples/mix_ping.nim`
  • Peer store: `MixPubKeyBook` from `libp2p/peerstore.nim` (only used by mix)
  • C bindings: 7 `libp2p_mix_*` exported procs, related types/fields, and request processors in `cbind/`
  • Compile flag: `-d:libp2p_mix_experimental_exit_is_dest` from the default test cfg (the new repo sets it in its own nimble file)
  • Docs: `docs/protocols_mix.md`, `docs/protocols_mix_spam_protection.md`, README & copilot-instructions entries

Net change: 49 files deleted, 16 modified (−538 / +6).

Consumer migrations (already up)

These should land before this PR merges, otherwise consumers break:

Verification

  • `nim check` on `libp2p.nim` and `cbind/libp2p.nim` after deletion: clean ✓
  • 5-node mixnet simulation in logos-delivery (chat2mix + lightpush) runs end-to-end with the new `libp2p_mix` package ✓

History preservation

Full mix git history is preserved in `logos-co/nim-libp2p-mix` with original
authors, dates, and PR references rewritten as cross-repo links to
`vacp2p/nim-libp2p#NNNN`.

Test plan

Mix has been moved out of nim-libp2p into its own repository at
https://github.com/logos-co/nim-libp2p-mix so it can evolve independently.

This commit removes the mix code from nim-libp2p:
- libp2p/protocols/mix/ (tree)
- libp2p/protocols/mix.nim (facade)
- tests/libp2p/mix/ (mix tests)
- examples/mix_ping.nim (mix example)
- libp2p/peerstore.nim: drop MixPubKeyBook (was only used by mix)
- cbind: drop the libp2p_mix_* C API and Mix-specific types/fields:
  * 7 libp2p_mix_* exported procs in cbind/libp2p.nim
  * Mix APIs section in cbind/libp2p.h
  * MixCurve25519Key, MixSecp256k1PubKey, MixReadBehaviorKind in ffi_types.nim
  * mix and mixNodeInfo fields on the LibP2P context type
  * MIX_DIAL / MIX_REGISTER_DEST_READ / MIX_SET_NODE_INFO / MIX_NODEPOOL_ADD
    request kinds and their processors
  * cbind/examples/mix.c
- libp2p.nimble: drop -d:libp2p_mix_experimental_exit_is_dest from the
  default test cfg (the new repo sets the flag in its own nimble file)
- docs/protocols_mix.md and docs/protocols_mix_spam_protection.md
- README, docs/README, .github/copilot-instructions: drop mix entries

Consumers have already been migrated:
- logos-co/mix-rln-spam-protection-plugin#6
- logos-messaging/logos-delivery#3842

Net change: 49 files deleted, 16 modified (-538 / +6).

History for the extracted mix code is preserved in
logos-co/nim-libp2p-mix with original authors, dates, and PR references
rewritten as cross-repo links to vacp2p/nim-libp2p#NNNN.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.41%. Comparing base (220a07f) to head (fbc38e9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2378      +/-   ##
==========================================
- Coverage   74.06%   73.41%   -0.65%     
==========================================
  Files         170      149      -21     
  Lines       22357    20027    -2330     
  Branches       19       19              
==========================================
- Hits        16558    14703    -1855     
+ Misses       5799     5324     -475     
Files with missing lines Coverage Δ
libp2p/peerstore.nim 94.89% <ø> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

richard-ramos and others added 2 commits May 5, 2026 11:18
…libp2p-mix

# Conflicts:
#	cbind/libp2p.nim
#	examples/mix_ping.nim
#	libp2p/protocols/mix/mix_node.nim
#	tests/libp2p/mix/component/test_cover_traffic.nim
#	tests/libp2p/mix/component/test_message_delivery.nim
#	tests/libp2p/mix/component/test_node_failures.nim
#	tests/libp2p/mix/component/test_spam_protection.nim
#	tests/libp2p/mix/test_multiaddr.nim
#	tests/libp2p/mix/test_pool.nim
#	tests/libp2p/mix/utils.nim
@chaitanyaprem chaitanyaprem marked this pull request as ready for review May 6, 2026 04:54
@chaitanyaprem chaitanyaprem requested review from a team, Copilot, gmelodie and richard-ramos May 6, 2026 04:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the Mix protocol implementation (and all related tests, docs, examples, peerstore book, build flags, and C bindings) from nim-libp2p, following the extraction of Mix into logos-co/nim-libp2p-mix so it can evolve independently of the core library.

Changes:

  • Deleted the Mix protocol code under libp2p/protocols/mix/ and the libp2p/protocols/mix.nim facade.
  • Removed Mix-specific tests/examples/docs and related references in repository docs and example runner.
  • Removed Mix-related peerstore and C-bindings surface area, including config flags and exported Mix APIs.

Reviewed changes

Copilot reviewed 65 out of 65 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/libp2p/test_peer_store.nim Removes MixPubKeyBook tests from the PeerStore suite.
tests/libp2p/mix/utils.nim Deletes Mix test utilities (switch setup, helpers, fake protocols).
tests/libp2p/mix/test_tag_manager.nim Deletes Mix replay-tag manager tests.
tests/libp2p/mix/test_sphinx.nim Deletes Sphinx packet construction/processing tests.
tests/libp2p/mix/test_spam_protection_interface.nim Deletes Mix spam-protection interface tests.
tests/libp2p/mix/test_serialization.nim Deletes Mix serialization tests (Header/Message/SphinxPacket/SURBs).
tests/libp2p/mix/test_seq_no_generator.nim Deletes Mix seq-no generator tests.
tests/libp2p/mix/test_pool.nim Deletes Mix node pool tests.
tests/libp2p/mix/test_multiaddr.nim Deletes Mix multiaddr serialization/conversion tests.
tests/libp2p/mix/test_mix_message.nim Deletes MixMessage serialization/deserialization tests.
tests/libp2p/mix/test_fragmentation.nim Deletes Mix payload fragmentation/padding tests.
tests/libp2p/mix/test_delay_strategy.nim Deletes Mix delay strategy tests.
tests/libp2p/mix/test_curve25519.nim Deletes Mix curve25519 helper tests.
tests/libp2p/mix/test_crypto.nim Deletes Mix crypto helper tests (AES-CTR/SHA256/HMAC/KDF).
tests/libp2p/mix/test_cover_traffic.nim Deletes Mix cover-traffic unit tests.
tests/libp2p/mix/spam_protection_impl.nim Deletes spam-protection test implementations used by Mix tests.
tests/libp2p/mix/mock_mix.nim Deletes MockMixProtocol used in integration tests.
tests/libp2p/mix/component/test_spam_protection.nim Deletes Mix protocol spam-protection integration tests.
tests/libp2p/mix/component/test_security.nim Deletes Mix protocol security integration tests (replay/failure behavior).
tests/libp2p/mix/component/test_node_failures.nim Deletes Mix node-failure integration tests (multi-SURB, invalid nodes, etc.).
tests/libp2p/mix/component/test_message_delivery.nim Deletes Mix message delivery integration tests (reply/no-reply, delays, concurrency).
tests/libp2p/mix/component/test_cover_traffic.nim Deletes Mix cover-traffic integration tests.
tests/libp2p/mix/component/test_connection_api.nim Deletes Mix connection API integration tests.
README.md Removes Mix from the documented list of implemented protocols.
libp2p/protocols/mix/tag_manager.nim Deletes Mix replay-tag manager implementation.
libp2p/protocols/mix/sphinx.nim Deletes Sphinx packet construction/processing implementation used by Mix.
libp2p/protocols/mix/spam_protection.nim Deletes Mix spam-protection interface and helpers.
libp2p/protocols/mix/serialization.nim Deletes Mix header/message/SphinxPacket/SURB serialization code.
libp2p/protocols/mix/seqno_generator.nim Deletes Mix sequence-number generation logic.
libp2p/protocols/mix/reply_connection.nim Deletes Mix reply connection implementation.
libp2p/protocols/mix/pool.nim Deletes Mix node pool abstraction backed by PeerStore.
libp2p/protocols/mix/multiaddr.nim Deletes Mix-specific multiaddr encoding/decoding helpers.
libp2p/protocols/mix/mix_node.nim Deletes Mix node identity/public-info structures and generators.
libp2p/protocols/mix/mix_metrics.nim Deletes Mix metrics definitions.
libp2p/protocols/mix/mix_message.nim Deletes MixMessage encoding/decoding logic.
libp2p/protocols/mix/fragmentation.nim Deletes Mix message padding/chunking implementation.
libp2p/protocols/mix/exit_layer.nim Deletes Mix exit-layer forwarding/handler logic.
libp2p/protocols/mix/exit_connection.nim Deletes MixExitConnection implementation.
libp2p/protocols/mix/entry_connection.nim Deletes MixEntryConnection and toConnection construction.
libp2p/protocols/mix/delay.nim Deletes Mix Delay type and conversions.
libp2p/protocols/mix/delay_strategy.nim Deletes Mix delay strategy implementations.
libp2p/protocols/mix/curve25519.nim Deletes Mix curve25519 wrapper/utilities.
libp2p/protocols/mix/crypto.nim Deletes Mix crypto helpers (AES-CTR/HMAC/KDF/SHA256).
libp2p/protocols/mix/benchmark.nim Deletes Mix benchmarking metadata/logging helper.
libp2p/protocols/mix.nim Deletes the Mix protocol facade/re-exports and helper read behaviors.
libp2p/peerstore.nim Removes the MixPubKeyBook type and the curve25519 dependency only used by Mix.
libp2p.nimble Removes the default test compile flag for experimental Mix behavior.
examples/mix_ping.nim Deletes the Mix ping example.
examples/examples_run.nim Removes mix_ping from the runnable examples aggregation.
docs/README.md Removes Mix docs links from the docs index.
docs/protocols_mix.md Deletes Mix protocol documentation page.
docs/protocols_mix_spam_protection.md Deletes Mix spam-protection documentation page.
docs/development.md Removes nimble testpath mix from development/testing docs.
cbind/types.nim Removes Mix fields/types from the C bindings LibP2P object.
cbind/libp2p.nim Removes exported C APIs related to Mix (dialing, key helpers, node pool, etc.).
cbind/libp2p.h Removes Mix C API declarations/types and config flag exposure.
cbind/libp2p_thread/inter_thread_communication/requests/libp2p_stream_requests.nim Removes Mix stream request types/fields and request processors.
cbind/libp2p_thread/inter_thread_communication/requests/libp2p_lifecycle_requests.nim Removes Mix protocol mounting/config plumbing.
cbind/libp2p_thread/inter_thread_communication/libp2p_thread_request.nim Removes Mix request dispatch cases from the thread request processor.
cbind/ffi_types.nim Removes Mix-related FFI config fields and key/read-behavior types.
cbind/examples/mix.c Deletes the Mix C-bindings example.
cbind/cbind.nimble Stops building/running the removed Mix C example in the cbind examples task.
.github/copilot-instructions.md Removes Mix-specific repo layout/docs/flags references from contributor instructions.

Comment on lines 133 to 135
peerStore.cleanup(randomPeerId)

check peerStore[AgentBook].len == 30
After the MixPubKeyBook tests were removed, the file no longer
references any Curve25519 symbols. With UnusedImport treated as
an error in config.nims, this would fail strict builds (it's
silently tolerated today only because the surrounding bracketed
import has other still-used entries).
chaitanyaprem added a commit to logos-co/nim-libp2p-mix that referenced this pull request May 6, 2026
Until the deletion PR in nim-libp2p (vacp2p/nim-libp2p#2378) merges
and a new libp2p version is registered, libp2p/peerstore still
exports MixPubKeyBook. Combined with our local definition in
libp2p_mix/pool, this triggers 'ambiguous identifier' in test files
that import both. Use `except MixPubKeyBook` on the libp2p/peerstore
import in those tests; the clause becomes a no-op once the deletion
PR lands.
chaitanyaprem added a commit to logos-co/nim-libp2p-mix that referenced this pull request May 6, 2026
Pin libp2p to the head of vacp2p/nim-libp2p#2378 so libp2p/peerstore no
longer ships MixPubKeyBook. With our local definition in
libp2p_mix/pool, this avoids the transitional 'ambiguous identifier'
errors. Once #2378 merges to master and is published, replace this pin
with a version range.
@richard-ramos
Copy link
Copy Markdown
Member

FYI @gmelodie , merging this will require changes in logos libp2p module

@github-project-automation github-project-automation Bot moved this from new to In Progress in nim-libp2p May 6, 2026
Copilot AI review requested due to automatic review settings May 6, 2026 14:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@chaitanyaprem chaitanyaprem merged commit 7e72c0d into master May 7, 2026
30 checks passed
@chaitanyaprem chaitanyaprem deleted the extract-mix-to-nim-libp2p-mix branch May 7, 2026 10:24
@github-project-automation github-project-automation Bot moved this from In Progress to done in nim-libp2p May 7, 2026
chaitanyaprem added a commit to logos-co/nim-libp2p-mix that referenced this pull request May 8, 2026
…tion

Three follow-ups to the original mix extraction:

1. Move `MixPubKeyBook` from libp2p/peerstore into libp2p_mix/pool.
   The type is mix-specific (Curve25519 keys per peer), only used
   by libp2p_mix's own pool, and shouldn't bleed into core libp2p.
   The peer-store extension mechanism makes this trivial:
   `ref object of PeerBook[Curve25519Key]` defined locally is
   indistinguishable from the previous version at the call site.

2. Drop the stale `{.public.}` pragma from method overrides in
   entry/exit/reply_connection.nim. Upstream nim-libp2p removed the
   marker pragma; our overrides referenced it without an importing
   module that defined it.

3. Bump the libp2p git pin to the tip of vacp2p/nim-libp2p#2378
   (mix-extraction PR, merged). With our local definition in
   libp2p_mix/pool, this avoids ambiguous identifier errors against
   the registered libp2p. We pin to the PR-tip rather than the
   post-merge master commit because libp2p master picked up an
   unrelated boringssl git-pin that nimble's SAT solver can't
   currently resolve. Once a release including #2378 is tagged,
   replace the pin with `libp2p >= <new-version>`.

This re-lands the work originally merged as #5 — that PR was
mistakenly merged into the (already-merged) PR #4 stacked branch
instead of master, so the changes never reached master.
chaitanyaprem added a commit to logos-co/nim-libp2p-mix that referenced this pull request May 8, 2026
…tion

Three follow-ups to the original mix extraction:

1. Move `MixPubKeyBook` from libp2p/peerstore into libp2p_mix/pool.
   The type is mix-specific (Curve25519 keys per peer), only used
   by libp2p_mix's own pool, and shouldn't bleed into core libp2p.
   The peer-store extension mechanism makes this trivial:
   `ref object of PeerBook[Curve25519Key]` defined locally is
   indistinguishable from the previous version at the call site.

2. Drop the stale `{.public.}` pragma from method overrides in
   entry/exit/reply_connection.nim. Upstream nim-libp2p removed the
   marker pragma; our overrides referenced it without an importing
   module that defined it.

3. Bump the libp2p git pin to the master commit that merges
   vacp2p/nim-libp2p#2378 (mix-extraction PR). With our local
   definition in libp2p_mix/pool, this avoids ambiguous identifier
   errors against the registered libp2p. The newer libp2p pulls in
   a git-pinned boringssl dep that nimble's default SAT solver
   can't resolve, so CI now runs `nimble --solver:legacy setup`.
   Drop both the legacy flag and the git pin once a release
   including #2378 is tagged.

This re-lands the work originally merged as #5 — that PR was
mistakenly merged into the (already-merged) PR #4 stacked branch
instead of master, so the changes never reached master.
chaitanyaprem added a commit to logos-co/nim-libp2p-mix that referenced this pull request May 8, 2026
…tion

Three follow-ups to the original mix extraction:

1. Move `MixPubKeyBook` from libp2p/peerstore into libp2p_mix/pool.
   The type is mix-specific (Curve25519 keys per peer), only used
   by libp2p_mix's own pool, and shouldn't bleed into core libp2p.
   The peer-store extension mechanism makes this trivial:
   `ref object of PeerBook[Curve25519Key]` defined locally is
   indistinguishable from the previous version at the call site.

2. Drop the stale `{.public.}` pragma from method overrides in
   entry/exit/reply_connection.nim. Upstream nim-libp2p removed the
   marker pragma; our overrides referenced it without an importing
   module that defined it.

3. Bump the libp2p git pin to the master commit that merges
   vacp2p/nim-libp2p#2378 (mix-extraction PR). With our local
   definition in libp2p_mix/pool, this avoids ambiguous identifier
   errors against the registered libp2p. The newer libp2p pulls in
   a git-pinned boringssl dep that nimble's default SAT solver
   can't resolve, so CI now runs `nimble --solver:legacy setup`.
   Drop both the legacy flag and the git pin once a release
   including #2378 is tagged.

This re-lands the work originally merged as #5 — that PR was
mistakenly merged into the (already-merged) PR #4 stacked branch
instead of master, so the changes never reached master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: done

Development

Successfully merging this pull request may close these issues.

6 participants