Skip to content

Commit ceda3ba

Browse files
authored
Merge branch 'libp2p:main' into main
2 parents 45a64c8 + 7ed1818 commit ceda3ba

454 files changed

Lines changed: 40840 additions & 4168 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: OSO Health Report
2+
3+
on:
4+
schedule:
5+
- cron: "0 6 * * 1"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
health-report:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 20
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install package
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install .
26+
27+
- name: Generate report
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
OSO_API_KEY: ${{ secrets.OSO_API_KEY }}
31+
run: |
32+
python scripts/oso/collect_health_metrics.py \
33+
--repo-root . \
34+
--repo-slug libp2p/py-libp2p \
35+
--json-output reports/health_metrics.json \
36+
--md-output reports/health_report.md
37+
38+
- name: Upload artifacts
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: oso-health-report
42+
path: |
43+
reports/health_metrics.json
44+
reports/health_report.md
45+
46+
- name: Job summary
47+
run: |
48+
echo "## OSO Health Report" >> "$GITHUB_STEP_SUMMARY"
49+
echo "" >> "$GITHUB_STEP_SUMMARY"
50+
echo "Generated files:" >> "$GITHUB_STEP_SUMMARY"
51+
echo "- reports/health_metrics.json" >> "$GITHUB_STEP_SUMMARY"
52+
echo "- reports/health_report.md" >> "$GITHUB_STEP_SUMMARY"

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ fabric.properties
138138

139139
# Django stuff:
140140
*.log
141+
*.pem
142+
*.key
141143
local_settings.py
142144
db.sqlite3
143145

@@ -190,3 +192,11 @@ tests/interop/js_libp2p/js_node/src/package-lock.json
190192

191193
# Sphinx documentation build
192194
_build/
195+
196+
# Attack simulation test results
197+
tests/security/attack_simulation/results/
198+
libp2p-forge
199+
200+
# OSO health report generated outputs
201+
reports/*.json
202+
reports/*.md

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@ repos:
4949
language: system
5050
always_run: true
5151
pass_filenames: false
52+
- repo: local
53+
hooks:
54+
- id: path-audit
55+
name: Cross-platform path handling audit (P0/P1)
56+
entry: python scripts/audit_paths.py --summary-only --fail-on-p1
57+
language: system
58+
always_run: true
59+
pass_filenames: false

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ PB = libp2p/crypto/pb/crypto.proto \
6565
libp2p/discovery/rendezvous/pb/rendezvous.proto \
6666
libp2p/bitswap/pb/bitswap.proto \
6767
libp2p/bitswap/pb/dag_pb.proto \
68-
libp2p/bitswap/pb/unixfs.proto
68+
libp2p/bitswap/pb/unixfs.proto \
69+
libp2p/records/pb/ipns.proto
6970

7071
PY = $(PB:.proto=_pb2.py)
7172
PYI = $(PB:.proto=_pb2.pyi)

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
[![Python versions](https://img.shields.io/pypi/pyversions/libp2p.svg)](https://pypi.python.org/pypi/libp2p)
1212
[![Build Status](https://img.shields.io/github/actions/workflow/status/libp2p/py-libp2p/tox.yml?branch=main&label=build%20status)](https://github.com/libp2p/py-libp2p/actions/workflows/tox.yml)
1313
[![Docs build](https://readthedocs.org/projects/py-libp2p/badge/?version=latest)](http://py-libp2p.readthedocs.io/en/latest/?badge=latest)
14-
<a href="https://filecoin.drips.network/app/projects/github/libp2p/py-libp2p" target="_blank"><img src="https://filecoin.drips.network/api/embed/project/https%3A%2F%2Fgithub.com%2Flibp2p%2Fpy-libp2p/support.png?background=light&style=drips&text=project&stat=support" alt="Support py-libp2p on drips.network" height="32"></a>
1514

1615
> py-libp2p has moved beyond its experimental roots and is steadily progressing toward production readiness. The core features are stable, and we’re focused on refining performance, expanding protocol support, and ensuring smooth interop with other libp2p implementations. We welcome contributions and real-world usage feedback to help us reach full production maturity.
1716
@@ -140,3 +139,7 @@ _(non-normative, useful for team notes, not a reference)_
140139
**Communication over one connection with multiple protocols**: X and Y can communicate over the same connection using different protocols and the multiplexer will appropriately route messages for a given protocol to a particular handler function for that protocol, which allows for each host to handle different protocols with separate functions. Furthermore, we can use multiple streams for a given protocol that allow for the same protocol and same underlying connection to be used for communication about separate topics between nodes X and Y.
141140

142141
**Why use multiple streams?**: The purpose of using the same connection for multiple streams to communicate over is to avoid the overhead of having multiple connections between X and Y. In order for X and Y to differentiate between messages on different streams and different protocols, a multiplexer is used to encode the messages when a message will be sent and decode a message when a message is received. The multiplexer encodes the message by adding a header to the beginning of any message to be sent that contains the stream id (along with some other info). Then, the message is sent across the raw connection and the receiving host will use its multiplexer to decode the message, i.e. determine which stream id the message should be routed to.
142+
143+
### Support
144+
145+
<a href="https://filecoin.drips.network/app/projects/github/libp2p/py-libp2p" target="_blank"><img src="https://filecoin.drips.network/api/embed/project/https%3A%2F%2Fgithub.com%2Flibp2p%2Fpy-libp2p/support.png?background=light&style=drips&text=project&stat=support" alt="Support py-libp2p on drips.network" height="32"></a>

docs/conf.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,26 @@
1212

1313
# If extensions (or modules to document with autodoc) are in another directory,
1414
# add these directories to sys.path here. If the directory is relative to the
15-
# documentation root, use os.path.abspath to make it absolute, like shown here.
15+
# documentation root, use pathlib to resolve it cross-platform.
1616

1717
import doctest
18-
import os
18+
from pathlib import Path
1919
import sys
20-
21-
sys.path.insert(0, os.path.abspath(".."))
2220
from unittest.mock import MagicMock
2321

22+
# Add project root to path (cross-platform)
23+
_docs_dir = Path(__file__).resolve().parent
24+
_project_root = _docs_dir.parent
25+
sys.path.insert(0, str(_project_root))
26+
2427
try:
2528
import tomllib
2629
except ModuleNotFoundError:
2730
# For Python < 3.11
2831
import tomli as tomllib # type: ignore (In case of >3.11 Pyrefly doesnt find tomli , which is right but a false flag)
2932

30-
# Path to pyproject.toml (assuming conf.py is in a 'docs' subdirectory)
31-
pyproject_path = os.path.join(os.path.dirname(__file__), "..", "pyproject.toml")
33+
# Path to pyproject.toml (conf.py is in 'docs', project root is parent)
34+
pyproject_path = _project_root / "pyproject.toml"
3235

3336
with open(pyproject_path, "rb") as f:
3437
pyproject_data = tomllib.load(f)

docs/contributing.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,19 @@ This library uses type hints, which are enforced by the ``mypy`` tool (part of t
354354
``pre-commit`` checks). All new code is required to land with type hints, with the
355355
exception of code within the ``tests`` directory.
356356

357+
Path handling
358+
^^^^^^^^^^^^^
359+
360+
Use the cross-platform path utilities in ``libp2p.utils.paths`` instead of ``os.path``
361+
or hard-coded separators. Prefer ``join_paths()`` over ``os.path.join()``,
362+
``get_script_dir(__file__)`` over ``os.path.dirname(__file__)``, and ``create_temp_file()``
363+
or ``get_temp_dir()`` over hard-coded ``/tmp/`` or ``C:\\``. This keeps the codebase
364+
working on Windows, macOS, and Linux. Run ``python scripts/audit_paths.py`` to check
365+
for path issues; the same audit runs in ``pre-commit`` and fails on P0/P1 issues.
366+
367+
For the full API reference, see :mod:`libp2p.utils.paths`. A working example is
368+
available in :doc:`examples.path_handling`.
369+
357370
Documentation
358371
~~~~~~~~~~~~~
359372

@@ -393,14 +406,15 @@ To add a new example (e.g., identify):
393406
.. code:: sh
394407
395408
.....
396-
Activate with `source /tmp/tmpb9ybjgtg/package-smoke-test/bin/activate`
409+
Activate with ``source <temp-dir>/package-smoke-test/bin/activate``
410+
(The exact path is shown by the script; use that path.)
397411
Press enter when the test has completed. The directory will be deleted.
398412
399413
Then test the example:
400414

401415
.. code:: sh
402416
403-
source /tmp/tmpb9ybjgtg/package-smoke-test/bin/activate
417+
source <temp-dir>/package-smoke-test/bin/activate
404418
(package-smoke-test) $ identify-demo
405419
406420
Pull Requests

docs/dependency_graph/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated dependency graph files
2+
# These can be regenerated by running the scripts
3+
*.png
4+
*.svg
5+
*.json
6+
*.dot
7+
*.mmd
8+
9+
# Keep documentation files
10+
!README.md
11+
!OSO_INFO.md
12+
!OSO_INTEGRATION.md
13+
!PREVIEW.md
14+
!QUICK_PREVIEW.md
15+
!SUMMARY.md
16+
17+
# Keep the markdown summary (it's documentation, not generated data)
18+
!dependencies.md

docs/dependency_graph/PREVIEW.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Previewing the Dependency Graph
2+
3+
This document explains how to preview the generated dependency graphs in different formats.
4+
5+
## 1. Mermaid Format (Recommended for GitHub)
6+
7+
The Mermaid format can be viewed directly in GitHub or using online Mermaid editors.
8+
9+
### Option A: View in GitHub
10+
11+
1. Open `docs/dependency_graph/dependencies.mmd` in GitHub
12+
1. GitHub will automatically render Mermaid diagrams
13+
14+
### Option B: Online Mermaid Editor
15+
16+
1. Copy the contents of `dependencies.mmd`
17+
1. Paste into one of these online editors:
18+
- https://mermaid.live/
19+
- https://mermaid-js.github.io/mermaid-live-editor/
20+
21+
### Option C: View in VS Code
22+
23+
If you have the Mermaid extension installed in VS Code, it will preview automatically.
24+
25+
## 2. DOT Format (Graphviz)
26+
27+
### Option A: Convert to Image (if Graphviz is installed)
28+
29+
```bash
30+
# Generate PNG
31+
dot -Tpng docs/dependency_graph/dependencies.dot -o docs/dependency_graph/dependencies.png
32+
33+
# Generate SVG (scalable)
34+
dot -Tsvg docs/dependency_graph/dependencies.dot -o docs/dependency_graph/dependencies.svg
35+
36+
# Generate PDF
37+
dot -Tpdf docs/dependency_graph/dependencies.dot -o docs/dependency_graph/dependencies.pdf
38+
```
39+
40+
### Option B: Online Graphviz Editors
41+
42+
1. Copy the contents of `dependencies.dot`
43+
1. Paste into one of these online tools:
44+
- https://dreampuf.github.io/GraphvizOnline/
45+
- https://edotor.net/
46+
- https://graphviz.christine.website/
47+
48+
## 3. JSON Format
49+
50+
### Option A: Pretty Print in Terminal
51+
52+
```bash
53+
cat docs/dependency_graph/dependencies.json | python3 -m json.tool | less
54+
```
55+
56+
### Option B: View in Browser
57+
58+
```bash
59+
# Open in default browser (if you have a JSON viewer extension)
60+
xdg-open docs/dependency_graph/dependencies.json # Linux
61+
open docs/dependency_graph/dependencies.json # macOS
62+
```
63+
64+
### Option C: Use jq (if installed)
65+
66+
```bash
67+
jq '.' docs/dependency_graph/dependencies.json | less
68+
```
69+
70+
## 4. Markdown Summary
71+
72+
Simply view the file:
73+
74+
```bash
75+
cat docs/dependency_graph/dependencies.md
76+
# or
77+
less docs/dependency_graph/dependencies.md
78+
```
79+
80+
Or open in any Markdown viewer/editor.
81+
82+
## Quick Preview Commands
83+
84+
Here are some quick commands to preview each format:
85+
86+
```bash
87+
# View Mermaid (copy to online editor)
88+
cat docs/dependency_graph/dependencies.mmd
89+
90+
# View Markdown summary
91+
cat docs/dependency_graph/dependencies.md
92+
93+
# View JSON (pretty printed)
94+
python3 -m json.tool docs/dependency_graph/dependencies.json | less
95+
96+
# Generate PNG from DOT (if Graphviz installed)
97+
dot -Tpng docs/dependency_graph/dependencies.dot -o /tmp/deps.png && xdg-open /tmp/deps.png
98+
```
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Quick Preview Guide
2+
3+
## 🎯 Fastest Ways to Preview
4+
5+
### 1. **Markdown Summary** (Text-based, instant)
6+
7+
```bash
8+
cat docs/dependency_graph/dependencies.md
9+
```
10+
11+
Shows a clean list of all dependencies with version specs.
12+
13+
### 2. **Mermaid Diagram** (Visual, works in GitHub)
14+
15+
```bash
16+
# Copy the file content and paste into:
17+
# https://mermaid.live/
18+
cat docs/dependency_graph/dependencies.mmd
19+
```
20+
21+
### 3. **PNG Image** (Visual, already generated)
22+
23+
```bash
24+
# View the generated PNG
25+
xdg-open docs/dependency_graph/dependencies.png # Linux
26+
open docs/dependency_graph/dependencies.png # macOS
27+
```
28+
29+
### 4. **SVG Image** (Scalable, already generated)
30+
31+
```bash
32+
# View the generated SVG
33+
xdg-open docs/dependency_graph/dependencies.svg # Linux
34+
open docs/dependency_graph/dependencies.svg # macOS
35+
```
36+
37+
### 5. **DOT Graph** (Online visualization)
38+
39+
```bash
40+
# Copy content and paste into:
41+
# https://dreampuf.github.io/GraphvizOnline/
42+
cat docs/dependency_graph/dependencies.dot
43+
```
44+
45+
## 📊 Current Graph Stats
46+
47+
- **Project**: libp2p v0.4.0
48+
- **Runtime dependencies**: 20
49+
- **Optional dependencies**: 32
50+
- **Total nodes**: 44
51+
- **Total edges**: 52
52+
53+
## 🔄 Regenerate Images
54+
55+
If you modify the dependencies and want to regenerate the images:
56+
57+
```bash
58+
# Regenerate all formats
59+
python3 scripts/oso/generate_dependency_graph.py
60+
61+
# Regenerate PNG
62+
dot -Tpng docs/dependency_graph/dependencies.dot -o docs/dependency_graph/dependencies.png
63+
64+
# Regenerate SVG
65+
dot -Tsvg docs/dependency_graph/dependencies.dot -o docs/dependency_graph/dependencies.svg
66+
```

0 commit comments

Comments
 (0)