Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into lexnv/awaitheader-once
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Apr 22, 2024
2 parents 60f1bf1 + 1f19eac commit f4f0cae
Show file tree
Hide file tree
Showing 61 changed files with 3,458 additions and 2,162 deletions.
145 changes: 145 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: CI

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

# Disable previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# ${{ vars.CI_UNIFIED_IMAGE }} is defined in the repository variables
env:
CI_IMAGE: "paritytech/ci-unified:bullseye-1.75.0-2024-01-22-v20240222"

jobs:
set-image:
# This workaround sets the container image for each job using 'set-image' job output.
# env variables don't work for PR from forks, so we need to use outputs.
runs-on: ubuntu-latest
outputs:
CI_IMAGE: ${{ steps.set_image.outputs.CI_IMAGE }}
steps:
- id: set_image
run: echo "CI_IMAGE=${{ env.CI_IMAGE }}" >> $GITHUB_OUTPUT
fmt:
name: Cargo fmt
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true

- name: Cargo fmt
run: cargo +nightly fmt --all -- --check

machete:
name: Check unused dependencies
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true

- name: Install cargo-machete
run: cargo install cargo-machete

- name: Check unused dependencies
run: cargo machete

check:
name: Cargo check
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true

- name: Cargo check
run: cargo check

doc:
name: Check documentation
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true
- name: Check documentation
run: RUSTDOCFLAGS="-D warnings -D rustdoc::broken_intra_doc_links" cargo doc --workspace --no-deps --document-private-items

clippy:
name: Cargo clippy
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true

# TODO: Allow clippy to fail and do not cancel other tasks.
# Clippy is fixed by: https://github.com/paritytech/litep2p/pull/57.
- name: Run clippy
continue-on-error: true
run: cargo clippy

test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
options: --sysctl net.ipv6.conf.all.disable_ipv6=0
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true

- name: Run tests
run: cargo test
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - 2023-04-05

### Added

- Expose `reuse_port` option for TCP and WebSocket transports ([#69](https://github.com/paritytech/litep2p/pull/69))
- protocol/mdns: Use `SO_REUSEPORT` for the mDNS socket ([#68](https://github.com/paritytech/litep2p/pull/68))
- Add support for protocol/agent version ([#64](https://github.com/paritytech/litep2p/pull/64))

## [0.2.0] - 2023-09-05

This is the second release of litep2p, v0.2.0. The quality of the first release was so bad that this release is a complete rewrite of the library.

Support is added for the following features:

* Transport protocols:
* TCP
* QUIC
* WebRTC
* WebSocket

* Protocols:
* [`/ipfs/identify/1.0.0`](https://github.com/libp2p/specs/tree/master/identify)
* [`/ipfs/ping/1.0.0`](https://github.com/libp2p/specs/blob/master/ping/ping.md)
* [`/ipfs/kad/1.0.0`](https://github.com/libp2p/specs/tree/master/kad-dht)
* [`/ipfs/bitswap/1.2.0`](https://github.com/ipfs/specs/blob/main/BITSWAP.md)
* Request-response protocol
* Notification protocol
* Multicast DNS
* API for creating custom protocols

This time the architecture has been designed to be extensible and integrating new transport and/or user-level protocols should be easier. Additionally, the test coverage is higher both in terms of unit and integration tests. The project also contains conformance tests which test the behavior of `litep2p` against, [`rust-libp2p`](https://github.com/libp2p/rust-libp2p/), [`go-libp2p`](https://github.com/libp2p/go-libp2p/) and Substrate's [`sc-network`](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/client/network). Currently the Substrate conformance tests are not enabled by default as they require unpublished/unaccepted changes to Substrate.

## [0.1.0] - 2023-04-04

This is the first release of `litep2p`, v0.1.0.

Support is added for the following:

* TCP + Noise + Yamux (compatibility with `libp2p`)
* [`/ipfs/identify/1.0.0`](https://github.com/libp2p/specs/tree/master/identify)
* [`/ipfs/ping/1.0.0`](https://github.com/libp2p/specs/blob/master/ping/ping.md)
* Request-response protocol
* Notification protocol

The code quality is atrocious but it works and the second release focuses on providing high test coverage for the library. After that is done and most of the functionality is covered (unit, integration and conformance tests, benchmarks), the focus can be turned to refactoring the code into something clean and efficient.
17 changes: 13 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "litep2p"
description = "Peer-to-peer networking library"
license = "MIT"
version = "0.2.0"
version = "0.3.0"
edition = "2021"

[build-dependencies]
Expand All @@ -15,7 +15,6 @@ bytes = "1.4.0"
cid = "0.10.1"
ed25519-dalek = "1.0.1"
futures = "0.3.27"
futures-rustls = "0.22.2"
futures-timer = "3.0.2"
hex-literal = "0.4.1"
indexmap = { version = "2.0.0", features = ["std"] }
Expand All @@ -37,7 +36,7 @@ simple-dns = "0.5.3"
smallvec = "1.10.0"
snow = { version = "0.9.3", features = ["ring-resolver"], default-features = false }
socket2 = { version = "0.5.5", features = ["all"] }
str0m = "0.2.0"
str0m = "0.4.1"
thiserror = "1.0.39"
tokio-stream = "0.1.12"
tokio-tungstenite = { version = "0.20.0", features = ["rustls-tls-native-roots"] }
Expand Down Expand Up @@ -79,6 +78,7 @@ libp2p = { version = "0.51.3", features = [
"quic",
]}
quickcheck = "1.0.3"
rand_xorshift = "0.3.0"
sc-network = "0.28.0"
sc-utils = "8.0.0"
serde_json = "1.0.108"
Expand Down
13 changes: 12 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# Basic
edition = "2021"
max_width = 100

# Imports
imports_granularity = "Crate"
reorder_imports = true

# Consistency
newline_style = "Unix"

# Misc
chain_width = 80
spaces_around_ranges = false
match_arm_blocks = false
trailing_comma = "Vertical"
edition = "2021"

# Format comments
comment_width = 100
wrap_comments = true
Loading

0 comments on commit f4f0cae

Please sign in to comment.