Skip to content

Commit

Permalink
Merge branch 'master' into web-transport-quic
Browse files Browse the repository at this point in the history
# Conflicts:
#	Cargo.lock
  • Loading branch information
dgarus committed Nov 21, 2023
2 parents 83058d5 + 3e30c20 commit fdcd176
Show file tree
Hide file tree
Showing 29 changed files with 153 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.24.2/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
- run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.25.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
shell: bash
- uses: obi1kenobi/cargo-semver-checks-action@e275dda72e250d4df5b564e969e1348d67fefa52 # v2

Expand Down
31 changes: 16 additions & 15 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ libp2p-webrtc = { version = "0.6.1-alpha", path = "transports/webrtc" }
libp2p-webrtc-utils = { version = "0.1.0", path = "misc/webrtc-utils" }
libp2p-webrtc-websys = { version = "0.2.0-alpha", path = "transports/webrtc-websys" }
libp2p-websocket = { version = "0.43.0", path = "transports/websocket" }
libp2p-websocket-websys = { version = "0.3.0", path = "transports/websocket-websys" }
libp2p-websocket-websys = { version = "0.3.1", path = "transports/websocket-websys" }
libp2p-webtransport-websys = { version = "0.2.0", path = "transports/webtransport-websys" }
libp2p-yamux = { version = "0.45.0", path = "muxers/yamux" }
multiaddr = "0.18.1"
multihash = "0.19.1"
multistream-select = { version = "0.13.0", path = "misc/multistream-select" }
prometheus-client = "0.22.0"
quick-protobuf-codec = { version = "0.2.0", path = "misc/quick-protobuf-codec" }
quick-protobuf-codec = { version = "0.3.0", path = "misc/quick-protobuf-codec" }
quickcheck = { package = "quickcheck-ext", path = "misc/quickcheck-ext" }
rw-stream-sink = { version = "0.4.0", path = "misc/rw-stream-sink" }
unsigned-varint = { version = "0.8.0" }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The main components of this repository are structured as follows:

* `transports/`: Implementations of transport protocols (e.g. TCP) and protocol upgrades
(e.g. for authenticated encryption, compression, ...) based on the `libp2p-core` `Transport`
API .
API.

* `muxers/`: Implementations of the `StreamMuxer` interface of `libp2p-core`,
e.g. (sub)stream multiplexing protocols on top of (typically TCP) connections.
Expand Down
10 changes: 5 additions & 5 deletions docs/coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Below is a set of coding guidelines followed across the rust-libp2p code base.

## Hierarchical State Machines

If you sqint, rust-libp2p is just a big hierarchy of [state
If you squint, rust-libp2p is just a big hierarchy of [state
machines](https://en.wikipedia.org/wiki/Finite-state_machine) where parents pass
events down to their children and children pass events up to their parents.

Expand Down Expand Up @@ -167,7 +167,7 @@ impl Stream for SomeStateMachine {
}
```

This priotization provides:
This prioritization provides:
- Low memory footprint as local queues (here `events_to_return_to_parent`) stay small.
- Low latency as accepted local work is not stuck in queues.
- DOS defense as a remote does not control the size of the local queue, nor starves local work with its remote work.
Expand Down Expand Up @@ -195,7 +195,7 @@ through a side-channel.
### Local queues

As for channels shared across potentially concurrent actors (e.g. future tasks
or OS threads), the same applies for queues owned by a single actor only. E.g.
or OS threads), the same applies to queues owned by a single actor only. E.g.
reading events from a socket into a `Vec<Event>` without some mechanism
bounding the size of that `Vec<Event>` again can lead to unbounded memory
growth and high latencies.
Expand Down Expand Up @@ -241,7 +241,7 @@ shows a speed up when running it concurrently.
## Use `async/await` for sequential execution only

Using `async/await` for sequential execution makes things significantly simpler.
Though unfortunately using `async/await` does not allow accesing methods on the
Though unfortunately using `async/await` does not allow accessing methods on the
object being `await`ed unless paired with some synchronization mechanism like an
`Arc<Mutex<_>>`.

Expand Down Expand Up @@ -308,7 +308,7 @@ response and a previous request. For example, if a user requests two new connect
peer, they should be able to match each new connection to the corresponding previous connection
request without having to guess.

When accepting a **command** that eventually results in a response through an event require that
When accepting a **command** that eventually results in a response through an event requires that
command to contain a unique ID, which is later on contained in the asynchronous response event. One
such example is the `Swarm` accepting a `ToSwarm::Dial` from the `NetworkBehaviour`.

Expand Down
41 changes: 17 additions & 24 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,34 @@ Non-breaking changes are typically merged very quickly and often released as pat

Every crate that we publish on `crates.io` has a `CHANGELOG.md` file.
Substantial PRs should add an entry to each crate they modify.
The next unreleased version is tagged with ` - unreleased`, for example: `0.17.0 - unreleased`.
We have a CI check[^1] that enforces adding a changelog entry if you modify code in a particular crate.
In case the current version is already released (we also check that in CI), you'll have to add a new header at the top.
For example, the top-listed version might be `0.17.3` but it is already released.
In that case, add a new heading `## 0.17.4` with your changelog entry in case it is a non-breaking change.

In case there isn't a version with an ` - unreleased` postfix yet, add one for the next version.
The next version number depends on the impact of your change (breaking vs non-breaking, see above).

If you are making a non-breaking change, please also bump the version number:

- in the `Cargo.toml` manifest of the respective crate
- in the `[workspace.dependencies]` section of the workspace `Cargo.toml` manifest

For breaking changes, a changelog entry itself is sufficient.
Bumping the version in the `Cargo.toml` file would lead to many merge conflicts once we decide to merge them.
Hence, we are going to bump those versions once we work through the milestone that collects the breaking changes.
The version in the crate's `Cargo.toml` and the top-most version in the `CHANGELOG.md` file always have to be in sync.
Additionally, we also enforce that all crates always depend on the latest version of other workspace-crates through workspace inheritance.
As a consequence, you'll also have to bump the version in `[workspace.dependencies]` in the workspace `Cargo.toml` manifest.

## Releasing one or more crates

The above changelog-management strategy means `master` is always in a state where we can make a release.

### Prerequisites

- [cargo release](https://github.com/crate-ci/cargo-release/)

### Steps

1. Remove the ` - unreleased` tag for each crate to be released in the respective `CHANGELOG.md`.
Create a pull request with the changes against the rust-libp2p `master` branch.

2. Once merged, run the two commands below on the (squash-) merged commit on the `master` branch.
1. Run the two commands below on the (squash-) merged commit on the `master` branch.

1. `cargo release publish --execute`

2. `cargo release tag --sign-tag --execute`

3. Confirm that `cargo release` tagged the commit correctly via `git push
$YOUR_ORIGIN --tag --dry-run` and then push the new tags via `git push
$YOUR_ORIGIN --tag`. Make sure not to push unrelated git tags.

Note that dropping the `--no-push` flag on `cargo release` might as well do
the trick.
2. Confirm that `cargo release` tagged the commit correctly via `git push $YOUR_ORIGIN --tag --dry-run`
Push the new tags via `git push $YOUR_ORIGIN --tag`.
Make sure not to push unrelated git tags.

## Patch release

Expand All @@ -65,15 +56,17 @@ Hence, we are going to bump those versions once we work through the milestone th

## Dealing with alphas

Unfortunately, `cargo` has a rather uninutitive behaviour when it comes to dealing with pre-releases like `0.1.0-alpha`.
Unfortunately, `cargo` has a rather unintuitive behaviour when it comes to dealing with pre-releases like `0.1.0-alpha`.
See this internals thread for some context: https://internals.rust-lang.org/t/changing-cargo-semver-compatibility-for-pre-releases

In short, cargo will automatically update from `0.1.0-alpha.1` to `0.1.0-alpha.2` UNLESS you pin the version directly with `=0.1.0-alpha.1`.
However, from a semver perspective, changes between pre-releases can be breaking.

To avoid accidential breaking changes for our users, we employ the following convention for alpha releases:
To avoid accidental breaking changes for our users, we employ the following convention for alpha releases:

- For a breaking change in a crate with an alpha release, bump the "minor" version but retain the "alpha" tag.
Example: `0.1.0-alpha` to `0.2.0-alpha`.
- For a non-breaking change in a crate with an alpha release, bump or append number to the "alpha" tag.
Example: `0.1.0-alpha` to `0.1.0-alpha.1`.

[^1]: See [ci.yml](../.github/workflows/ci.yml) and look for "Ensure manifest and CHANGELOG are properly updated".
1 change: 1 addition & 0 deletions examples/autonat/src/bin/autonat_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
yamux::Config::default,
)?
.with_behaviour(|key| Behaviour::new(key.public()))?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
.build();

swarm.listen_on(
Expand Down
2 changes: 2 additions & 0 deletions examples/autonat/src/bin/autonat_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
use libp2p::{autonat, identify, identity, noise, tcp, yamux};
use std::error::Error;
use std::net::Ipv4Addr;
use std::time::Duration;
use tracing_subscriber::EnvFilter;

#[derive(Debug, Parser)]
Expand All @@ -52,6 +53,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
yamux::Config::default,
)?
.with_behaviour(|key| Behaviour::new(key.public()))?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
.build();

swarm.listen_on(
Expand Down
3 changes: 2 additions & 1 deletion examples/dcutr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use libp2p::{
swarm::{NetworkBehaviour, SwarmEvent},
tcp, yamux, PeerId,
};
use std::error::Error;
use std::str::FromStr;
use std::{error::Error, time::Duration};
use tracing_subscriber::EnvFilter;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -105,6 +105,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
)),
dcutr: dcutr::Behaviour::new(keypair.public().to_peer_id()),
})?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
.build();

swarm
Expand Down
2 changes: 2 additions & 0 deletions examples/distributed-key-value-store/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use libp2p::{
tcp, yamux,
};
use std::error::Error;
use std::time::Duration;
use tracing_subscriber::EnvFilter;

#[async_std::main]
Expand Down Expand Up @@ -65,6 +66,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
)?,
})
})?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
.build();

swarm.behaviour_mut().kademlia.set_mode(Some(Mode::Server));
Expand Down
2 changes: 2 additions & 0 deletions examples/file-sharing/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use libp2p::StreamProtocol;
use serde::{Deserialize, Serialize};
use std::collections::{hash_map, HashMap, HashSet};
use std::error::Error;
use std::time::Duration;

/// Creates the network components, namely:
///
Expand Down Expand Up @@ -58,6 +59,7 @@ pub(crate) async fn new(
request_response::Config::default(),
),
})?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
.build();

swarm
Expand Down
3 changes: 2 additions & 1 deletion examples/identify/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use futures::StreamExt;
use libp2p::{core::multiaddr::Multiaddr, identify, noise, swarm::SwarmEvent, tcp, yamux};
use std::error::Error;
use std::{error::Error, time::Duration};
use tracing_subscriber::EnvFilter;

#[async_std::main]
Expand All @@ -44,6 +44,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
key.public(),
))
})?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
.build();

// Tell the swarm to listen on all interfaces and a random, OS-assigned
Expand Down
3 changes: 2 additions & 1 deletion examples/ipfs-private/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use libp2p::{
swarm::{NetworkBehaviour, SwarmEvent},
tcp, yamux, Multiaddr, Transport,
};
use std::{env, error::Error, fs, path::Path, str::FromStr};
use std::{env, error::Error, fs, path::Path, str::FromStr, time::Duration};
use tokio::{io, io::AsyncBufReadExt, select};
use tracing_subscriber::EnvFilter;

Expand Down Expand Up @@ -151,6 +151,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
ping: ping::Behaviour::new(ping::Config::new()),
})
})?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(60)))
.build();

println!("Subscribing to {gossipsub_topic:?}");
Expand Down
Loading

0 comments on commit fdcd176

Please sign in to comment.