Skip to content

feat: implement DCUtR hole punching, file chunking, and resumable transfers - #7

Open
adarshxsh wants to merge 25 commits into
devlup-labs:p2p-transportfrom
adarshxsh:main
Open

feat: implement DCUtR hole punching, file chunking, and resumable transfers#7
adarshxsh wants to merge 25 commits into
devlup-labs:p2p-transportfrom
adarshxsh:main

Conversation

@adarshxsh

Copy link
Copy Markdown
Collaborator

Description

This pull request introduces the core public milestone release of the CIPHER P2P Transport module, completely overhauling the codebase to support robust peer-to-peer connection establishment and resilient, large-scale file transfers.

At the connection layer, this PR implements Direct Connection Upgrade through Relay (DCUtR) and abstracts the transport layer. This enables peers to successfully dial each other and perform hole punching through NATs, securely falling back to relay nodes when direct connections are not immediately possible.

At the data transfer layer, this PR introduces a robust Content Engine featuring file chunking, CAS (Content-Addressable Storage) sharding, and resumable downloads. Transfers are now resilient to network interruptions; if a connection drops, the download can seamlessly resume from the last verified chunk. Additionally, a CLI download progress bar has been added for improved user experience.

Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Extensive manual testing and simulated network configurations were used to verify connection behavior and data integrity:

  • Relay & Hole Punching (DCUtR): Verified connections could route through a relay node (using relaxed limits for heavy fallback testing) and successfully upgrade to a direct connection via hole punching. Tested edge cases forcing relay usage and isolating peers without relays.
  • Resumable Transfers: Manually interrupted active file transfers and verified that the transport successfully resumed downloading only the missing chunks upon reconnection.
  • Data Integrity: Verified chunking and reassembly logic using SHA-256 validation to ensure the final downloaded file exactly matches the source.
  • CLI Progress: Verified the progress bar accurately reflects real-time download status across multiple chunks.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Adarsh added 22 commits July 7, 2026 18:53
- Establish decoupled pipeline architecture for Content Engine
- Implement stream splitting (chunking) based on dynamic size
- Implement XChaCha20-Poly1305 for independent chunk encryption
- Implement SHA-256 Digest for content hashing and integrity checks
- Create local FS ChunkSource and ChunkSink
- Generate immutable Manifest containing chunk IDs and metadata
- Create cmd/content-test for manual end-to-end testing
- Update documentation and test matrix
Content Engine : Chunking and Encryption
This commit officially bridges the decoupled Content Engine to the libp2p network layer via the new /cipher/chunk/1.0.0 protocol.

Key Highlights:
- Implemented a unified, symmetric Message envelope (Version, Type, Payload) to eliminate silent stream failures.
- Stream Handler: Implemented sequential stream routing that queries the local ContentEngine for Manifests and Chunks.
- Client Downloader: Enforces strict Verify-Then-Store semantics (SHA-256 verification of ciphertext) before committing any chunk to the CAS store and issuing an ACK.
- Decoupled Crypto: Reassembly tests confirm that network transmission (Manifest) is successfully decoupled from decryption rights (Key).
- Benchmarking: Base transport pipeline benchmarks at ~490 MB/s over local loopback using strict sequential streaming.
- CLI: Updated cmd/peer to support new '-ingest', '-fetch', '-key', and '-reassemble' flags. Deprecated the legacy /cipher/filetransfer/1.0.0 protocol.
- Docs: Frozen protocol/chunk.proto.md spec and migrated to internal/protocol/chunk/. Updated architecture and testing matrices.
* feat(transport): Milestone 9 resumable transfers

* docs: update architecture and testing matrices for Milestone 9
@1amKhush

Copy link
Copy Markdown
Member

@adarshxsh

  • Chunk sizes are too large (currently 256kb), reduce them down to 32kb
  • Use ChaCha20-Poly1305 and use deterministic 12-byte nonces derived from the chunk index: nonce_i = first_12_bytes(SHA-256("cipher-nonce" || uint64(i)))

@adarshxsh
adarshxsh force-pushed the main branch 5 times, most recently from f488993 to 1709f19 Compare July 17, 2026 15:35
- Added libp2p Circuit Relay v2 support and connection protection
- Enabled AutoNAT service and forced Private Reachability for hole punching
- Added chaos testing flags
- Updated testing matrix with long-distance Azure VM hole punching validation
Adarsh added 2 commits July 17, 2026 22:22
- Reduced chunk size from 256KB to 32KB for better streaming and deduplication
- Replaced XChaCha20 (random 24-byte nonces) with ChaCha20 (deterministic 12-byte nonces)
- Derived nonces from chunk index to remove random generation overhead
- Updated ChunkHeader and manifest CryptoDescriptor accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants