Move from "nightly" toolchain to "stable".

Intended to address tau RefID "Gifn1u".

There are still a few things that require nightly.
- cargo +nightly fmt
- fuzzing
This commit is contained in:
Paul Otten
2025-04-14 14:30:53 -04:00
parent b02fb8481a
commit 721502a468
35 changed files with 133 additions and 99 deletions

View File

@@ -20,17 +20,17 @@ jobs:
with:
python-version: 3.9
- name: Install Rust (nightly)
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-04-10
toolchain: stable
components: rustfmt, clippy
override: true
- name: Install Rust (wasm32)
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-04-10
toolchain: stable
target: wasm32-unknown-unknown
override: true
@@ -56,7 +56,7 @@ jobs:
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "bookworm"
cd doc
make CARGO="cargo +nightly-2025-04-10" github
make github
git checkout gh-pages
- name: Push changes

View File

@@ -13,11 +13,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-04-10
toolchain: stable
override: true
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-04-10
toolchain: stable
target: wasm32-unknown-unknown
override: true
- uses: actions/setup-python@v1
@@ -37,11 +37,11 @@ jobs:
- name: Run test units
run: |
make CARGO="cargo +nightly-2025-04-10" test
make test
- name: Compile all bins
run: |
make CARGO="cargo +nightly-2025-04-10"
make
feature-powerset:
name: Test crate feature powerset on ${{ matrix.os }}
@@ -54,11 +54,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-04-10
toolchain: stable
override: true
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-04-10
toolchain: stable
target: wasm32-unknown-unknown
override: true
- uses: taiki-e/install-action@cargo-hack
@@ -75,7 +75,7 @@ jobs:
- name: Run feature powerset builds
run: |
make CARGO="cargo +nightly-2025-04-10" check
make check
fmt:
name: rustfmt
@@ -85,8 +85,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-04-10
toolchain: nightly
components: rustfmt
override: true
- run: |
cargo +nightly-2025-04-10 fmt -- --check
cargo +nightly fmt -- --check

View File

@@ -1,23 +1,23 @@
name: Nightly lints
name: Lints
# We only run these on trial-merges of PRs to reduce noise.
on: pull_request
jobs:
clippy:
name: Clippy (nightly)
name: Clippy
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2025-04-10
toolchain: stable
components: clippy
override: true
- name: Run Clippy
uses: actions-rs/clippy-check@v1
with:
name: Clippy (stable)
name: Clippy
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --release -- -D warnings

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target for system binaries
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
@@ -149,7 +149,7 @@ fu:
# -- END OF BINS --
fmt:
$(CARGO) fmt --all
$(CARGO) +nightly fmt --all
# cargo install cargo-hack
check: explorerd_bundle_contracts_src $(PROOFS_BIN)

View File

@@ -44,17 +44,12 @@ This project requires the Rust compiler to be installed.
Please visit [Rustup](https://rustup.rs/) for instructions.
You have to install a native toolchain, which is set up during Rust installation,
nightly toolchain and wasm32 target.
To install nightly toolchain, execute:
```shell
% rustup toolchain install nightly
```
and wasm32 target.
To install wasm32 target, execute:
```shell
% rustup target add wasm32-unknown-unknown
% rustup target add wasm32-unknown-unknown --toolchain nightly
```
Minimum Rust version supported is **1.77.0 (nightly)**.
Minimum Rust version supported is **1.77.0**.
The following dependencies are also required:
@@ -110,34 +105,6 @@ If you want to hack on the source code, make sure to read some
introductory advice in the
[DarkFi book](https://darkrenaissance.github.io/darkfi/dev/dev.html).
### Living on the cutting edge
Since the project uses the nightly toolchain, breaking changes are bound
to happen from time to time. As a workaround, we can configure an older
nightly version, which was known to work:
```shell
% rustup toolchain install nightly-2025-04-10
% rustup target add wasm32-unknown-unknown --toolchain nightly-2025-04-10
```
Now we can use that toolchain in `make` directly:
```shell
% make CARGO="cargo +nightly-2025-04-10" {target}
```
Or, if we are lazy, we can modify the `Makefile` to always use that:
```shell
% sed -i Makefile -e "s|nightly|nightly-2025-04-10|g"
```
Under no circumstances commit or push the Makefile change.
When using `cargo` directly, you have to add the `+nightly-2025-04-10` flag,
in order for it to use the older nightly version.
## Install
This will install the binaries on your system (`/usr/local` by

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -7,7 +7,7 @@ MAKEFLAGS += --no-print-directory
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -123,7 +123,7 @@ if there is a version mismatch.
$ sh contrib/dependency_setup.sh
```
* Ensure that you are using the nightly toolchain and are building for `wasm32-unknown-unknown`.
* Ensure that you are building for `wasm32-unknown-unknown`.
Check `README.md` for instructions.
* When running a `cargo` command, use the flag `--all-features`.

View File

@@ -41,6 +41,10 @@ exit 0
Inside the darkfi project repo, place this script in `.git/hooks/pre-commit`
and make sure it's executable by running `chmod +x .git/hooks/pre-commit`.
Code style formatting(rustfmt) requires a nightly rust toolchain. To install nightly toolchain, execute:
```
$ rustup toolchain install nightly
```
## Testing crate features
@@ -101,8 +105,8 @@ binaries from our codebase. A short setup using a Debian system and
```
Inside the container, once attached, we have to install the required
dependencies. We will have to use `rustup` to get the latest rust
nightly, and we also have to compile `sqlcipher` on our own.
dependencies. We will have to use `rustup` to get the latest rust,
and we also have to compile `sqlcipher` on our own.
```
# apk add rustup git musl-dev make gcc openssl-dev openssl-libs-static tcl-dev zlib-static
@@ -113,9 +117,9 @@ nightly, and we also have to compile `sqlcipher` on our own.
# make -j$(nproc)
# make install
# cd ~
# rustup-init --default-toolchain nightly -y
# rustup-init --default-toolchain stable -y
# source ~/.cargo/env
# rustup target add wasm32-unknown-unknown --toolchain nightly
# rustup target add wasm32-unknown-unknown --toolchain stable
```
And now we should be able to build a statically linked binary:
@@ -134,7 +138,7 @@ In certain cases, it might also be possible to build natively by
installing the musl toolchain:
```
$ rustup target add x86_64-unknown-linux-musl --toolchain nightly
$ rustup target add x86_64-unknown-linux-musl --toolchain stable
## Uncomment RUSTFLAGS in the main Makefile
$ sed -e 's,^#RUSTFLAGS ,RUSTFLAGS ,' -i Makefile
$ make RUST_TARGET=x86_64-unknown-linux-musl darkirc

View File

@@ -199,16 +199,11 @@ interacts within the network. dnet log information is created in
You can ping any node to make sure it's online by using the provided
`ping` tool located at `${DARKFI_REPO}/script/ping`. Select a peer from
your hostlist file. You can now use the `ping` tool by
running this command (assuming nightly is default):
running this command:
```
$ cargo run -- tcp+tls://example_peer:26661
```
If nightly isn't default, use this command:
```
$ cargo +nightly run -- tcp+tls://example_peer:26661
```
If the peers are reachable, you'll receive a `Connected!` output.

View File

@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# wasm build target
WASM_TARGET = wasm32-unknown-unknown

View File

@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly"
channel = "stable"

View File

@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
BIN = evgrd

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
@@ -24,7 +24,7 @@ $(BIN): $(SRC)
cp -f target/$(RUST_TARGET)/release/$@ $@
fmt:
$(CARGO) fmt --all
$(CARGO) +nightly fmt --all
clippy:
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
@@ -24,7 +24,7 @@ $(BIN): $(SRC)
cp -f target/$(RUST_TARGET)/release/$@ $@
fmt:
$(CARGO) fmt --all
$(CARGO) +nightly fmt --all
clippy:
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \

View File

@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
@@ -24,7 +24,7 @@ $(BIN): $(SRC)
cp -f target/$(RUST_TARGET)/release/$@ $@
fmt:
$(CARGO) fmt --all
$(CARGO) +nightly fmt --all
clippy:
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \

View File

@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target for system binaries
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target for system binaries
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
CARGO = cargo +nightly
CARGO = cargo
# Compile target for system binaries
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// cargo +nightly test --release --features=event-graph --lib eventgraph_propagation -- --include-ignored
// cargo test --release --features=event-graph --lib eventgraph_propagation -- --include-ignored
use std::sync::Arc;

View File

@@ -16,8 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#![feature(ip)]
pub mod error;
pub use error::{ClientFailed, ClientResult, Error, Result};

View File

@@ -23,7 +23,7 @@ use std::{
collections::HashMap,
fmt, fs,
fs::File,
net::{IpAddr, Ipv6Addr},
net::{IpAddr, Ipv4Addr, Ipv6Addr},
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex as SyncMutex, RwLock,
@@ -1177,12 +1177,12 @@ impl Hosts {
// Filter private IP ranges
match url.host().unwrap() {
url::Host::Ipv4(ip) => {
if !ip.is_global() {
if !ip.unstable_is_global() {
return true
}
}
url::Host::Ipv6(ip) => {
if !ip.is_global() {
if !ip.unstable_is_global() {
return true
}
}
@@ -1592,6 +1592,76 @@ impl Hosts {
}
}
/// We need a convenience method from Rust's unstable feature "ip".
/// When <https://github.com/rust-lang/rust/issues/27709> is stablized we can remove this.
trait UnstableFeatureIp {
fn unstable_is_global(&self) -> bool;
}
impl UnstableFeatureIp for Ipv4Addr {
// Copied from: https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L839
#[inline]
fn unstable_is_global(&self) -> bool {
!(self.octets()[0] == 0 // "This network"
|| self.is_private()
// is_shared https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L875
|| self.octets()[0] == 100 && (self.octets()[1] & 0b1100_0000 == 0b0100_0000)
|| self.is_loopback()
|| self.is_link_local()
// addresses reserved for future protocols (`192.0.0.0/24`)
// .9 and .10 are documented as globally reachable so they're excluded
|| (
self.octets()[0] == 192 && self.octets()[1] == 0 && self.octets()[2] == 0
&& self.octets()[3] != 9 && self.octets()[3] != 10
)
|| self.is_documentation()
// is_benchmarking https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L902
|| self.octets()[0] == 198 && (self.octets()[1] & 0xfe) == 18
// is_reserved https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L938
|| self.octets()[0] & 240 == 240 && !self.is_broadcast()
|| self.is_broadcast())
}
}
impl UnstableFeatureIp for Ipv6Addr {
// Copied from: https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L1598
#[inline]
fn unstable_is_global(&self) -> bool {
!(self.is_unspecified()
|| self.is_loopback()
// IPv4-mapped Address (`::ffff:0:0/96`)
|| matches!(self.segments(), [0, 0, 0, 0, 0, 0xffff, _, _])
// IPv4-IPv6 Translat. (`64:ff9b:1::/48`)
|| matches!(self.segments(), [0x64, 0xff9b, 1, _, _, _, _, _])
// Discard-Only Address Block (`100::/64`)
|| matches!(self.segments(), [0x100, 0, 0, 0, _, _, _, _])
// IETF Protocol Assignments (`2001::/23`)
|| (matches!(self.segments(), [0x2001, b, _, _, _, _, _, _] if b < 0x200)
&& !(
// Port Control Protocol Anycast (`2001:1::1`)
u128::from_be_bytes(self.octets()) == 0x2001_0001_0000_0000_0000_0000_0000_0001
// Traversal Using Relays around NAT Anycast (`2001:1::2`)
|| u128::from_be_bytes(self.octets()) == 0x2001_0001_0000_0000_0000_0000_0000_0002
// AMT (`2001:3::/32`)
|| matches!(self.segments(), [0x2001, 3, _, _, _, _, _, _])
// AS112-v6 (`2001:4:112::/48`)
|| matches!(self.segments(), [0x2001, 4, 0x112, _, _, _, _, _])
// ORCHIDv2 (`2001:20::/28`)
// Drone Remote ID Protocol Entity Tags (DETs) Prefix (`2001:30::/28`)`
|| matches!(self.segments(), [0x2001, b, _, _, _, _, _, _] if (0x20..=0x3F).contains(&b))
))
// 6to4 (`2002::/16`) it's not explicitly documented as globally reachable,
// IANA says N/A.
|| matches!(self.segments(), [0x2002, _, _, _, _, _, _, _])
// is_documentation https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L1754
|| matches!(self.segments(), [0x2001, 0xdb8, ..] | [0x3fff, 0..=0x0fff, ..])
// Segment Routing (SRv6) SIDs (`5f00::/16`)
|| matches!(self.segments(), [0x5f00, ..])
|| self.is_unique_local()
|| self.is_unicast_link_local())
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// cargo +nightly test --release --features=net --lib p2p -- --include-ignored
// cargo test --release --features=net --lib p2p -- --include-ignored
use std::{collections::HashSet, net::TcpListener, panic, sync::Arc};