From 6d840eb783be381ab4c877bc105e428fa508a6ea Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 4 Apr 2025 10:12:22 +0200 Subject: [PATCH] chore: update toolchain to 1.86.0 (#1213) * Updates * Remove unused deps * Fix broken step to create a new GH issue --- .github/workflows/code-check.yml | 2 +- .../workflows/rust-latest-version-check.yml | 2 +- .pre-commit-config.yaml | 2 +- Dockerfile | 2 +- ci/Dockerfile | 2 +- clients/common-http-client/src/lib.rs | 4 ++-- consensus/cryptarchia-engine/src/lib.rs | 17 +++++++------- ledger/nomos-ledger/src/lib.rs | 2 +- nodes/nomos-node/src/config/mod.rs | 2 +- nomos-blend/core/src/conn_maintenance.rs | 2 +- .../core/src/message_blend/temporal.rs | 2 +- nomos-blend/message/src/mock/mod.rs | 2 +- .../message/src/sphinx/layered_cipher.rs | 2 +- nomos-blend/network/src/behaviour.rs | 2 +- nomos-blend/network/src/lib.rs | 2 +- nomos-core/chain-defs/Cargo.toml | 1 - nomos-core/chain-defs/src/header/mod.rs | 4 ++++ nomos-core/chain-defs/src/tx/bundle.rs | 4 ++++ nomos-core/chain-defs/src/wire/bincode.rs | 5 ++-- nomos-core/cl/src/bundle.rs | 8 +++++++ nomos-da/kzgrs-backend/Cargo.toml | 1 - nomos-da/kzgrs-backend/src/encoder.rs | 9 ++++---- nomos-da/kzgrs-backend/src/global.rs | 5 ++-- nomos-da/kzgrs-backend/src/verifier.rs | 5 ++-- nomos-da/kzgrs/Cargo.toml | 1 - nomos-da/kzgrs/benches/fk20.rs | 5 ++-- nomos-da/kzgrs/benches/kzg.rs | 5 ++-- nomos-da/kzgrs/benches/rs.rs | 3 +-- nomos-da/kzgrs/src/common.rs | 7 +++--- nomos-da/kzgrs/src/fk20.rs | 8 +++---- nomos-da/kzgrs/src/kzg.rs | 11 +++++---- nomos-da/kzgrs/src/rs.rs | 7 +++--- .../network/core/src/behaviour/executor.rs | 12 +++++----- .../network/core/src/behaviour/validator.rs | 12 ++++++---- .../protocols/dispersal/executor/behaviour.rs | 2 +- .../src/protocols/replication/behaviour.rs | 21 ++++++++--------- nomos-da/network/core/src/swarm/executor.rs | 2 +- nomos-da/network/core/src/swarm/validator.rs | 2 +- nomos-services/blend/src/lib.rs | 4 ---- .../cryptarchia-consensus/src/lib.rs | 1 - .../data-availability/indexer/src/lib.rs | 4 ---- .../data-availability/network/src/lib.rs | 4 ---- .../sampling/src/backend/kzgrs.rs | 5 ++-- .../data-availability/sampling/src/lib.rs | 4 ---- .../data-availability/verifier/src/lib.rs | 4 ---- .../key-management-system/src/lib.rs | 4 ---- .../mempool/src/network/adapters/mock.rs | 4 ++-- nomos-services/network/src/backends/mock.rs | 6 ++--- nomos-services/network/src/lib.rs | 4 ---- .../storage/src/backends/rocksdb.rs | 13 +++++------ nomos-services/storage/src/lib.rs | 4 ---- nomos-services/system-sig/src/lib.rs | 4 ---- nomos-services/time/src/lib.rs | 4 ---- nomos-services/tracing/src/lib.rs | 7 +++--- nomos-utils/src/lib.rs | 23 +++++++++---------- rust-toolchain.toml | 5 +++- shell.nix | 4 ++-- testnet/Dockerfile | 2 +- tests/Cargo.toml | 1 - tests/src/lib.rs | 21 +++++++++-------- tests/src/nodes/mod.rs | 5 ++-- tests/src/tests/cryptarchia/happy.rs | 4 ---- tests/src/topology/configs/da.rs | 4 ++-- tests/src/topology/mod.rs | 8 +++++++ 64 files changed, 160 insertions(+), 180 deletions(-) diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml index 03aa04e52..66fd028e2 100644 --- a/.github/workflows/code-check.yml +++ b/.github/workflows/code-check.yml @@ -33,7 +33,7 @@ jobs: uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # Version 1.0.6 with: # The same version must be used in the `.pre-commit-config.yaml` file - toolchain: nightly-2025-01-03 + toolchain: nightly-2025-02-16 profile: minimal components: rustfmt override: true diff --git a/.github/workflows/rust-latest-version-check.yml b/.github/workflows/rust-latest-version-check.yml index 88bfe5bec..67b3d21c8 100644 --- a/.github/workflows/rust-latest-version-check.yml +++ b/.github/workflows/rust-latest-version-check.yml @@ -44,7 +44,7 @@ jobs: - name: Checkout repository uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # Version 4.2.2 - name: Create a GH issue (if it does not exist) - uses: JasonEtco/create-an-issue@56fdd2d6f960e970fa9d5ca3cf3884b6ba5af477 # Version 2.9.2 + uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # Version 2.9.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RUST_VERSION: ${{ needs.check-latest-version.outputs.new-version }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cfffa96b7..564c31a8b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: v1.0 hooks: - id: fmt - entry: cargo +nightly-2025-01-03 fmt + entry: cargo +nightly-2025-02-16 fmt - id: clippy - repo: https://github.com/EmbarkStudios/cargo-deny rev: 0.18.0 diff --git a/Dockerfile b/Dockerfile index 1ea16e73e..7eb807f38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # BUILD IMAGE # =========================== -FROM rust:1.85.1-slim-bookworm AS builder +FROM rust:1.86.0-slim-bookworm AS builder LABEL maintainer="augustinas@status.im" \ source="https://github.com/logos-co/nomos-node" \ diff --git a/ci/Dockerfile b/ci/Dockerfile index 96933823f..e8764a291 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.85.1-slim-bookworm +FROM rust:1.86.0-slim-bookworm LABEL maintainer="augustinas@status.im" \ source="https://github.com/logos-co/nomos-node" \ diff --git a/clients/common-http-client/src/lib.rs b/clients/common-http-client/src/lib.rs index 7ccca45bb..e97b7e518 100644 --- a/clients/common-http-client/src/lib.rs +++ b/clients/common-http-client/src/lib.rs @@ -162,8 +162,8 @@ impl CommonHttpClient { let status = response.status(); let shares_stream = response.bytes_stream().filter_map(|item| async move { - item.ok() - .and_then(|bytes| serde_json::from_slice::(&bytes).ok()) + let bytes = item.ok()?; + serde_json::from_slice::(&bytes).ok() }); match status { StatusCode::OK => Ok(shares_stream), diff --git a/consensus/cryptarchia-engine/src/lib.rs b/consensus/cryptarchia-engine/src/lib.rs index a36c597d7..8cbb3d476 100644 --- a/consensus/cryptarchia-engine/src/lib.rs +++ b/consensus/cryptarchia-engine/src/lib.rs @@ -229,15 +229,14 @@ where pub fn get_security_block_header_id(&self) -> Option { (0..self.config.security_param.get()).try_fold(self.tip(), |header, _| { - self.branches.get(&header).and_then(|branch| { - let parent = branch.parent; - if header == parent { - // If the header is the genesis block, we arrived at the end of the chain - None - } else { - Some(parent) - } - }) + let branch = self.branches.get(&header)?; + let parent = branch.parent; + if header == parent { + // If the header is the genesis block, we arrived at the end of the chain + None + } else { + Some(parent) + } }) } } diff --git a/ledger/nomos-ledger/src/lib.rs b/ledger/nomos-ledger/src/lib.rs index beb468789..e1ff6badd 100644 --- a/ledger/nomos-ledger/src/lib.rs +++ b/ledger/nomos-ledger/src/lib.rs @@ -911,6 +911,6 @@ pub mod tests { Some(LedgerError::InvalidSlot { parent, block }) if parent == slot && block == slot2 => {} _ => panic!("error does not match the LedgerError::InvalidSlot pattern"), - }; + } } } diff --git a/nodes/nomos-node/src/config/mod.rs b/nodes/nomos-node/src/config/mod.rs index e6499922e..477e2bced 100644 --- a/nodes/nomos-node/src/config/mod.rs +++ b/nodes/nomos-node/src/config/mod.rs @@ -189,7 +189,7 @@ pub fn update_tracing( LoggerLayerType::Stdout => LoggerLayer::Stdout, LoggerLayerType::Stderr => LoggerLayer::Stderr, } - }; + } if let Some(level_str) = level { tracing.level = match level_str.as_str() { diff --git a/nomos-blend/core/src/conn_maintenance.rs b/nomos-blend/core/src/conn_maintenance.rs index a2e74856a..f8e2cf01f 100644 --- a/nomos-blend/core/src/conn_maintenance.rs +++ b/nomos-blend/core/src/conn_maintenance.rs @@ -106,7 +106,7 @@ impl ConnectionMonitor { } } - fn reset(&mut self) { + const fn reset(&mut self) { self.effective_messages = U57F7::ZERO; self.drop_messages = U57F7::ZERO; } diff --git a/nomos-blend/core/src/message_blend/temporal.rs b/nomos-blend/core/src/message_blend/temporal.rs index ceeb13255..7e000254c 100644 --- a/nomos-blend/core/src/message_blend/temporal.rs +++ b/nomos-blend/core/src/message_blend/temporal.rs @@ -129,7 +129,7 @@ where if let Some(msg) = self.queue.pop_front() { return Poll::Ready(Some(msg)); } - }; + } Poll::Pending } } diff --git a/nomos-blend/message/src/mock/mod.rs b/nomos-blend/message/src/mock/mod.rs index 0f56581fa..fdc27bb64 100644 --- a/nomos-blend/message/src/mock/mod.rs +++ b/nomos-blend/message/src/mock/mod.rs @@ -56,7 +56,7 @@ impl BlendMessage for MockBlendMessage { // Append payload with padding message.extend(payload); message.push(PAYLOAD_PADDING_SEPARATOR); - message.extend(std::iter::repeat(0).take(MAX_PAYLOAD_SIZE - payload.len())); + message.extend(std::iter::repeat_n(0, MAX_PAYLOAD_SIZE - payload.len())); Ok(message) } diff --git a/nomos-blend/message/src/sphinx/layered_cipher.rs b/nomos-blend/message/src/sphinx/layered_cipher.rs index 1ff8a893d..083611a34 100644 --- a/nomos-blend/message/src/sphinx/layered_cipher.rs +++ b/nomos-blend/message/src/sphinx/layered_cipher.rs @@ -226,7 +226,7 @@ impl ConsistentLengthLayeredCipher { let total_data_with_zero_filler = encrypted_total_data .iter() .copied() - .chain(std::iter::repeat(0u8).take(Self::SINGLE_LAYER_SIZE)) + .chain(std::iter::repeat_n(0u8, Self::SINGLE_LAYER_SIZE)) .collect::>(); // Decrypt the extended data. diff --git a/nomos-blend/network/src/behaviour.rs b/nomos-blend/network/src/behaviour.rs index 4d458d187..07253f3ae 100644 --- a/nomos-blend/network/src/behaviour.rs +++ b/nomos-blend/network/src/behaviour.rs @@ -218,7 +218,7 @@ where if remaining_established == 0 { self.negotiated_peers.remove(&peer_id); } - }; + } self.try_wake(); } diff --git a/nomos-blend/network/src/lib.rs b/nomos-blend/network/src/lib.rs index 962dd38da..a92aaa155 100644 --- a/nomos-blend/network/src/lib.rs +++ b/nomos-blend/network/src/lib.rs @@ -76,7 +76,7 @@ mod test { if let SwarmEvent::Behaviour(Event::Message(received_msg)) = event { assert_eq!(received_msg, msg); break; - }; + } } // Proceed swarm2 _ = swarm2.select_next_some() => {} diff --git a/nomos-core/chain-defs/Cargo.toml b/nomos-core/chain-defs/Cargo.toml index 55b583722..5b11d7b96 100644 --- a/nomos-core/chain-defs/Cargo.toml +++ b/nomos-core/chain-defs/Cargo.toml @@ -20,7 +20,6 @@ indexmap = { version = "1.9", features = ["serde"] } nomos-ledger = { workspace = true, features = ["serde"] } nomos_proof_statements = { workspace = true } nomos_risc0_proofs = { path = "../risc0_proofs" } -once_cell = "1.0" risc0-zkvm = { workspace = true } serde = { version = "1.0", features = ["derive"] } thiserror = "1.0" diff --git a/nomos-core/chain-defs/src/header/mod.rs b/nomos-core/chain-defs/src/header/mod.rs index 3dcac68c5..5f0c9f1af 100644 --- a/nomos-core/chain-defs/src/header/mod.rs +++ b/nomos-core/chain-defs/src/header/mod.rs @@ -69,6 +69,10 @@ impl Header { self.slot } + #[expect( + clippy::missing_const_for_fn, + reason = "Using `Deref` which is not const." + )] #[must_use] pub fn orphaned_proofs(&self) -> &[Self] { &self.orphaned_leader_proofs diff --git a/nomos-core/chain-defs/src/tx/bundle.rs b/nomos-core/chain-defs/src/tx/bundle.rs index 714780749..d483b2975 100644 --- a/nomos-core/chain-defs/src/tx/bundle.rs +++ b/nomos-core/chain-defs/src/tx/bundle.rs @@ -25,6 +25,10 @@ impl Bundle { &self.bundle } + #[expect( + clippy::missing_const_for_fn, + reason = "Using `Deref` which is not const." + )] #[must_use] pub fn cm_roots(&self) -> &[[u8; 32]] { &self.cm_roots diff --git a/nomos-core/chain-defs/src/wire/bincode.rs b/nomos-core/chain-defs/src/wire/bincode.rs index b17eb2a8d..fa9354ae4 100644 --- a/nomos-core/chain-defs/src/wire/bincode.rs +++ b/nomos-core/chain-defs/src/wire/bincode.rs @@ -1,3 +1,5 @@ +use std::sync::LazyLock; + use bincode::{ config::{ Bounded, FixintEncoding, LittleEndian, RejectTrailing, WithOtherEndian, @@ -6,7 +8,6 @@ use bincode::{ de::read::SliceReader, Error, ErrorKind, Options, }; -use once_cell::sync::Lazy; // Type composition is cool but also makes naming types a bit awkward pub type BincodeOptions = WithOtherTrailing< @@ -21,7 +22,7 @@ pub type BincodeOptions = WithOtherTrailing< // Risc0 proofs are HUGE (220 Kb) and it's the only reason we need to have this // limit so large pub const DATA_LIMIT: u64 = 1 << 18; // Do not serialize/deserialize more than 256 KiB -pub static OPTIONS: Lazy = Lazy::new(|| { +pub static OPTIONS: LazyLock = LazyLock::new(|| { bincode::DefaultOptions::new() .with_little_endian() .with_limit(DATA_LIMIT) diff --git a/nomos-core/cl/src/bundle.rs b/nomos-core/cl/src/bundle.rs index 9154e50d0..10febad21 100644 --- a/nomos-core/cl/src/bundle.rs +++ b/nomos-core/cl/src/bundle.rs @@ -15,6 +15,10 @@ impl Bundle { Self { partials } } + #[expect( + clippy::missing_const_for_fn, + reason = "Using `Deref` which is not const." + )] #[must_use] pub fn partial_txs(&self) -> &[PartialTx] { &self.partials @@ -42,6 +46,10 @@ impl BundleWitness { ) } + #[expect( + clippy::missing_const_for_fn, + reason = "Using `Deref` which is not const." + )] #[must_use] pub fn partial_witnesses(&self) -> &[PartialTxWitness] { &self.partials diff --git a/nomos-da/kzgrs-backend/Cargo.toml b/nomos-da/kzgrs-backend/Cargo.toml index 74f9a9716..2c1fb7ce5 100644 --- a/nomos-da/kzgrs-backend/Cargo.toml +++ b/nomos-da/kzgrs-backend/Cargo.toml @@ -14,7 +14,6 @@ blake2 = "0.10" itertools = "0.12" kzgrs = { workspace = true } nomos-core = { workspace = true } -once_cell = "1.19" rand = "0.8.5" rayon = { version = "1.10.0", optional = true } serde = { version = "1.0", features = ["derive"] } diff --git a/nomos-da/kzgrs-backend/src/encoder.rs b/nomos-da/kzgrs-backend/src/encoder.rs index e505d5e46..e7b383b13 100644 --- a/nomos-da/kzgrs-backend/src/encoder.rs +++ b/nomos-da/kzgrs-backend/src/encoder.rs @@ -344,7 +344,7 @@ impl nomos_core::da::DaEncoder for DaEncoder { #[cfg(test)] pub mod test { - use std::ops::Div; + use std::{ops::Div, sync::LazyLock}; use ark_ff::PrimeField; use ark_poly::{EvaluationDomain, GeneralEvaluationDomain}; @@ -354,7 +354,6 @@ pub mod test { PolynomialEvaluationDomain, BYTES_PER_FIELD_ELEMENT, }; use nomos_core::da::DaEncoder as _; - use once_cell::sync::Lazy; use rand::RngCore; use crate::{ @@ -363,9 +362,9 @@ pub mod test { }; pub static DOMAIN_SIZE: usize = 16; - pub static PARAMS: Lazy = - Lazy::new(|| DaEncoderParams::default_with(DOMAIN_SIZE)); - pub static ENCODER: Lazy = Lazy::new(|| DaEncoder::new(PARAMS.clone())); + pub static PARAMS: LazyLock = + LazyLock::new(|| DaEncoderParams::default_with(DOMAIN_SIZE)); + pub static ENCODER: LazyLock = LazyLock::new(|| DaEncoder::new(PARAMS.clone())); #[must_use] pub fn rand_data(elements_count: usize) -> Vec { diff --git a/nomos-da/kzgrs-backend/src/global.rs b/nomos-da/kzgrs-backend/src/global.rs index 43efe60ef..ed78d27c5 100644 --- a/nomos-da/kzgrs-backend/src/global.rs +++ b/nomos-da/kzgrs-backend/src/global.rs @@ -1,9 +1,10 @@ +use std::sync::LazyLock; + // Reexport global parameters loading from file. pub use kzgrs::global_parameters_from_file; use kzgrs::{global_parameters_from_randomness, GlobalParameters}; -use once_cell::sync::Lazy; -pub static GLOBAL_PARAMETERS: Lazy = Lazy::new(|| { +pub static GLOBAL_PARAMETERS: LazyLock = LazyLock::new(|| { println!("WARNING: Global parameters are randomly generated. Use for development only."); let mut rng = rand::thread_rng(); global_parameters_from_randomness(&mut rng) diff --git a/nomos-da/kzgrs-backend/src/verifier.rs b/nomos-da/kzgrs-backend/src/verifier.rs index 6e97d970e..65b999a21 100644 --- a/nomos-da/kzgrs-backend/src/verifier.rs +++ b/nomos-da/kzgrs-backend/src/verifier.rs @@ -151,6 +151,8 @@ impl DaVerifier { #[cfg(test)] mod test { + use std::sync::LazyLock; + use ark_bls12_381::Fr; use ark_poly::{EvaluationDomain, GeneralEvaluationDomain}; use kzgrs::{ @@ -159,7 +161,6 @@ mod test { PolynomialEvaluationDomain, Proof, BYTES_PER_FIELD_ELEMENT, }; use nomos_core::da::{blob::Share, DaEncoder}; - use once_cell::sync::Lazy; use crate::{ common::{hash_commitment, share::DaShare, Chunk, Column}, @@ -182,7 +183,7 @@ mod test { fn prepare_column( with_new_global_params: bool, ) -> Result> { - pub static NEW_GLOBAL_PARAMETERS: Lazy = Lazy::new(|| { + pub static NEW_GLOBAL_PARAMETERS: LazyLock = LazyLock::new(|| { let mut rng = rand::thread_rng(); global_parameters_from_randomness(&mut rng) }); diff --git a/nomos-da/kzgrs/Cargo.toml b/nomos-da/kzgrs/Cargo.toml index 38ced9707..5c859c2d7 100644 --- a/nomos-da/kzgrs/Cargo.toml +++ b/nomos-da/kzgrs/Cargo.toml @@ -16,7 +16,6 @@ ark-serialize = { version = "0.4" } blst = "0.3.11" num-bigint = "0.4.4" num-traits = "0.2.18" -once_cell = "1.19" rand = "0.8.5" rayon = { version = "1.10", optional = true } thiserror = "1.0.58" diff --git a/nomos-da/kzgrs/benches/fk20.rs b/nomos-da/kzgrs/benches/fk20.rs index ae49b13fa..6a4ebec8d 100644 --- a/nomos-da/kzgrs/benches/fk20.rs +++ b/nomos-da/kzgrs/benches/fk20.rs @@ -1,4 +1,4 @@ -use std::hint::black_box; +use std::{hint::black_box, sync::LazyLock}; use ark_bls12_381::{Bls12_381, Fr}; use ark_poly::{univariate::DensePolynomial, EvaluationDomain, GeneralEvaluationDomain}; @@ -9,7 +9,6 @@ use kzgrs::{ fk20::{fk20_batch_generate_elements_proofs, Toeplitz1Cache}, GlobalParameters, BYTES_PER_FIELD_ELEMENT, }; -use once_cell::sync::Lazy; use rand::SeedableRng; #[cfg(feature = "parallel")] use rayon::iter::{IntoParallelIterator, ParallelIterator}; @@ -18,7 +17,7 @@ fn main() { divan::main(); } -static GLOBAL_PARAMETERS: Lazy = Lazy::new(|| { +static GLOBAL_PARAMETERS: LazyLock = LazyLock::new(|| { let mut rng = rand::rngs::StdRng::seed_from_u64(1987); KZG10::>::setup(4096, true, &mut rng).unwrap() }); diff --git a/nomos-da/kzgrs/benches/kzg.rs b/nomos-da/kzgrs/benches/kzg.rs index abb93831d..a504e81f2 100644 --- a/nomos-da/kzgrs/benches/kzg.rs +++ b/nomos-da/kzgrs/benches/kzg.rs @@ -1,3 +1,5 @@ +use std::sync::LazyLock; + use ark_bls12_381::{Bls12_381, Fr}; use ark_poly::{univariate::DensePolynomial, EvaluationDomain, GeneralEvaluationDomain}; use ark_poly_commit::kzg10::{UniversalParams, KZG10}; @@ -6,7 +8,6 @@ use kzgrs::{ common::bytes_to_polynomial_unchecked, kzg::{commit_polynomial, generate_element_proof, verify_element_proof}, }; -use once_cell::sync::Lazy; use rand::RngCore; #[cfg(feature = "parallel")] use rayon::iter::IntoParallelIterator; @@ -22,7 +23,7 @@ fn main() { // #[global_allocator] // static ALLOC: AllocProfiler = AllocProfiler::system(); -static GLOBAL_PARAMETERS: Lazy> = Lazy::new(|| { +static GLOBAL_PARAMETERS: LazyLock> = LazyLock::new(|| { let mut rng = rand::thread_rng(); KZG10::>::setup(4096, true, &mut rng).unwrap() }); diff --git a/nomos-da/kzgrs/benches/rs.rs b/nomos-da/kzgrs/benches/rs.rs index 9d1b8dc0f..0363d1e15 100644 --- a/nomos-da/kzgrs/benches/rs.rs +++ b/nomos-da/kzgrs/benches/rs.rs @@ -43,8 +43,7 @@ fn rs_decode(bencher: Bencher, size: usize) { .bench_values(|buff| { black_box(move || { let domain = GeneralEvaluationDomain::::new(size).unwrap(); - let missing_data: Vec<_> = std::iter::repeat(None) - .take(size) + let missing_data: Vec<_> = std::iter::repeat_n(None, size) .chain(buff.evals[size..].iter().copied().map(Some)) .collect(); decode(size, &missing_data, domain) diff --git a/nomos-da/kzgrs/src/common.rs b/nomos-da/kzgrs/src/common.rs index 3228fda6a..62ba65f1d 100644 --- a/nomos-da/kzgrs/src/common.rs +++ b/nomos-da/kzgrs/src/common.rs @@ -138,11 +138,12 @@ pub fn compute_roots_of_unity(size: usize) -> Vec { #[cfg(test)] mod test { + use std::sync::LazyLock; + use ark_bls12_381::fr::Fr; use ark_ff::{BigInteger, PrimeField}; use ark_poly::{EvaluationDomain, GeneralEvaluationDomain, Polynomial}; use blst::BLST_ERROR; - use once_cell::sync::Lazy; use rand::{thread_rng, Fill}; use super::{ @@ -150,8 +151,8 @@ mod test { }; const CHUNK_SIZE: usize = 31; - static DOMAIN: Lazy> = - Lazy::new(|| GeneralEvaluationDomain::new(128).unwrap()); + static DOMAIN: LazyLock> = + LazyLock::new(|| GeneralEvaluationDomain::new(128).unwrap()); #[test] fn encode_random_polynomial() { const N: usize = 100; diff --git a/nomos-da/kzgrs/src/fk20.rs b/nomos-da/kzgrs/src/fk20.rs index 4ff230e53..f9af21db3 100644 --- a/nomos-da/kzgrs/src/fk20.rs +++ b/nomos-da/kzgrs/src/fk20.rs @@ -66,8 +66,7 @@ pub fn fk20_batch_generate_elements_proofs( .collect(); Cow::Owned(toeplitz1(&global_parameters, polynomial_degree)) }; - let toeplitz_coefficients: Vec = std::iter::repeat(Fr::ZERO) - .take(polynomial_degree) + let toeplitz_coefficients: Vec = std::iter::repeat_n(Fr::ZERO, polynomial_degree) .chain(polynomial.coeffs.iter().copied()) .collect(); let h_extended_vector = toeplitz2(&toeplitz_coefficients, &extended_vector); @@ -101,10 +100,11 @@ impl Toeplitz1Cache { #[cfg(test)] mod test { + use std::sync::LazyLock; + use ark_bls12_381::{Bls12_381, Fr}; use ark_poly::{univariate::DensePolynomial, EvaluationDomain, GeneralEvaluationDomain}; use ark_poly_commit::kzg10::KZG10; - use once_cell::sync::Lazy; use rand::SeedableRng; use crate::{ @@ -114,7 +114,7 @@ mod test { GlobalParameters, Proof, BYTES_PER_FIELD_ELEMENT, }; - static GLOBAL_PARAMETERS: Lazy = Lazy::new(|| { + static GLOBAL_PARAMETERS: LazyLock = LazyLock::new(|| { let mut rng = rand::rngs::StdRng::seed_from_u64(1987); KZG10::>::setup(4096, true, &mut rng).unwrap() }); diff --git a/nomos-da/kzgrs/src/kzg.rs b/nomos-da/kzgrs/src/kzg.rs index 0b638431e..d9564fe3c 100644 --- a/nomos-da/kzgrs/src/kzg.rs +++ b/nomos-da/kzgrs/src/kzg.rs @@ -39,7 +39,7 @@ pub fn generate_element_proof( let u = domain.element(element_index); if u.is_zero() { return Err(KzgRsError::DivisionByZeroPolynomial); - }; + } // Instead of evaluating over the polynomial, we can reuse the evaluation points // from the rs encoding let v = polynomial.evaluate(&u); @@ -76,12 +76,13 @@ pub fn verify_element_proof( #[cfg(test)] mod test { + use std::sync::LazyLock; + use ark_bls12_381::{Bls12_381, Fr}; use ark_poly::{ univariate::DensePolynomial, DenseUVPolynomial, EvaluationDomain, GeneralEvaluationDomain, }; use ark_poly_commit::kzg10::{UniversalParams, KZG10}; - use once_cell::sync::Lazy; use rand::{thread_rng, Fill}; use rayon::{ iter::{IndexedParallelIterator, ParallelIterator}, @@ -94,7 +95,7 @@ mod test { }; const COEFFICIENTS_SIZE: usize = 16; - static GLOBAL_PARAMETERS: Lazy> = Lazy::new(|| { + static GLOBAL_PARAMETERS: LazyLock> = LazyLock::new(|| { let mut rng = rand::thread_rng(); KZG10::>::setup( crate::kzg::test::COEFFICIENTS_SIZE - 1, @@ -104,8 +105,8 @@ mod test { .unwrap() }); - static DOMAIN: Lazy> = - Lazy::new(|| GeneralEvaluationDomain::new(COEFFICIENTS_SIZE).unwrap()); + static DOMAIN: LazyLock> = + LazyLock::new(|| GeneralEvaluationDomain::new(COEFFICIENTS_SIZE).unwrap()); #[test] fn test_poly_commit() { let poly = DensePolynomial::from_coefficients_vec((0..10).map(Fr::from).collect()); diff --git a/nomos-da/kzgrs/src/rs.rs b/nomos-da/kzgrs/src/rs.rs index 90dbba154..8c1984b2b 100644 --- a/nomos-da/kzgrs/src/rs.rs +++ b/nomos-da/kzgrs/src/rs.rs @@ -93,9 +93,10 @@ pub fn points_to_bytes(points: &[Fr]) -> Vec { #[cfg(test)] mod test { + use std::sync::LazyLock; + use ark_bls12_381::Fr; use ark_poly::{EvaluationDomain, GeneralEvaluationDomain}; - use once_cell::sync::Lazy; use rand::{thread_rng, Fill}; use crate::{ @@ -104,8 +105,8 @@ mod test { }; const COEFFICIENTS_SIZE: usize = 32; - static DOMAIN: Lazy> = - Lazy::new(|| GeneralEvaluationDomain::new(COEFFICIENTS_SIZE).unwrap()); + static DOMAIN: LazyLock> = + LazyLock::new(|| GeneralEvaluationDomain::new(COEFFICIENTS_SIZE).unwrap()); #[test] fn test_encode_decode() { diff --git a/nomos-da/network/core/src/behaviour/executor.rs b/nomos-da/network/core/src/behaviour/executor.rs index bdf531df8..1d2afd44d 100644 --- a/nomos-da/network/core/src/behaviour/executor.rs +++ b/nomos-da/network/core/src/behaviour/executor.rs @@ -93,27 +93,27 @@ where &self.replication } - pub fn sampling_behaviour_mut(&mut self) -> &mut SamplingBehaviour { + pub const fn sampling_behaviour_mut(&mut self) -> &mut SamplingBehaviour { &mut self.sampling } - pub fn dispersal_executor_behaviour_mut( + pub const fn dispersal_executor_behaviour_mut( &mut self, ) -> &mut DispersalExecutorBehaviour { &mut self.executor_dispersal } - pub fn dispersal_validator_behaviour_mut( + pub const fn dispersal_validator_behaviour_mut( &mut self, ) -> &mut DispersalValidatorBehaviour { &mut self.validator_dispersal } - pub fn replication_behaviour_mut(&mut self) -> &mut ReplicationBehaviour { + pub const fn replication_behaviour_mut(&mut self) -> &mut ReplicationBehaviour { &mut self.replication } - pub fn monitor_behaviour_mut(&mut self) -> &mut ConnectionMonitorBehaviour { + pub const fn monitor_behaviour_mut(&mut self) -> &mut ConnectionMonitorBehaviour { &mut self.monitor } @@ -121,7 +121,7 @@ where &self.monitor } - pub fn balancer_behaviour_mut( + pub const fn balancer_behaviour_mut( &mut self, ) -> &mut ConnectionBalancerBehaviour { &mut self.balancer diff --git a/nomos-da/network/core/src/behaviour/validator.rs b/nomos-da/network/core/src/behaviour/validator.rs index 73146d12e..eb478cf3e 100644 --- a/nomos-da/network/core/src/behaviour/validator.rs +++ b/nomos-da/network/core/src/behaviour/validator.rs @@ -82,19 +82,21 @@ where &self.replication } - pub fn sampling_behaviour_mut(&mut self) -> &mut SamplingBehaviour { + pub const fn sampling_behaviour_mut(&mut self) -> &mut SamplingBehaviour { &mut self.sampling } - pub fn dispersal_behaviour_mut(&mut self) -> &mut DispersalValidatorBehaviour { + pub const fn dispersal_behaviour_mut( + &mut self, + ) -> &mut DispersalValidatorBehaviour { &mut self.dispersal } - pub fn replication_behaviour_mut(&mut self) -> &mut ReplicationBehaviour { + pub const fn replication_behaviour_mut(&mut self) -> &mut ReplicationBehaviour { &mut self.replication } - pub fn monitor_behaviour_mut(&mut self) -> &mut ConnectionMonitorBehaviour { + pub const fn monitor_behaviour_mut(&mut self) -> &mut ConnectionMonitorBehaviour { &mut self.monitor } @@ -102,7 +104,7 @@ where &self.monitor } - pub fn balancer_behaviour_mut( + pub const fn balancer_behaviour_mut( &mut self, ) -> &mut ConnectionBalancerBehaviour { &mut self.balancer diff --git a/nomos-da/network/core/src/protocols/dispersal/executor/behaviour.rs b/nomos-da/network/core/src/protocols/dispersal/executor/behaviour.rs index c2937e701..2509d0cb7 100644 --- a/nomos-da/network/core/src/protocols/dispersal/executor/behaviour.rs +++ b/nomos-da/network/core/src/protocols/dispersal/executor/behaviour.rs @@ -325,7 +325,7 @@ where } else { // There is no pending request, so just idle the stream idle_streams.insert(stream.peer_id, stream); - }; + } } /// Get a pending request if its available diff --git a/nomos-da/network/core/src/protocols/replication/behaviour.rs b/nomos-da/network/core/src/protocols/replication/behaviour.rs index 7e6ce9d4c..3e77003f0 100644 --- a/nomos-da/network/core/src/protocols/replication/behaviour.rs +++ b/nomos-da/network/core/src/protocols/replication/behaviour.rs @@ -129,7 +129,7 @@ enum WriteHalfState { } impl WriteHalfState { - pub fn take(&mut self) -> Self { + pub const fn take(&mut self) -> Self { let mut ret = Self::Busy; std::mem::swap(self, &mut ret); ret @@ -714,18 +714,17 @@ where messages.shift_remove(disconnected); // If the marker pointed to the disconnected peer, move it backwards one step, // wrapping around if necessary - last_scheduled.and_then(|id| { - if id == *disconnected { - let i = i.expect("Valid index"); - if i == 0 { - messages.last().map(|(id, _)| *id) - } else { - messages.get_index(i - 1).map(|(id, _)| *id) - } + let id = last_scheduled?; + if id == *disconnected { + let i = i.expect("Valid index"); + if i == 0 { + messages.last().map(|(id, _)| *id) } else { - None + messages.get_index(i - 1).map(|(id, _)| *id) } - }) + } else { + None + } } #[cfg(test)] diff --git a/nomos-da/network/core/src/swarm/executor.rs b/nomos-da/network/core/src/swarm/executor.rs index 8860d9ce3..a4fe506fe 100644 --- a/nomos-da/network/core/src/swarm/executor.rs +++ b/nomos-da/network/core/src/swarm/executor.rs @@ -230,7 +230,7 @@ where &self.swarm } - pub fn protocol_swarm_mut( + pub const fn protocol_swarm_mut( &mut self, ) -> &mut Swarm< ExecutorBehaviour< diff --git a/nomos-da/network/core/src/swarm/validator.rs b/nomos-da/network/core/src/swarm/validator.rs index 7d5fd11e3..95b83779c 100644 --- a/nomos-da/network/core/src/swarm/validator.rs +++ b/nomos-da/network/core/src/swarm/validator.rs @@ -205,7 +205,7 @@ where &self.swarm } - pub fn protocol_swarm_mut( + pub const fn protocol_swarm_mut( &mut self, ) -> &mut Swarm< ValidatorBehaviour< diff --git a/nomos-services/blend/src/lib.rs b/nomos-services/blend/src/lib.rs index 41ba82381..1aad25032 100644 --- a/nomos-services/blend/src/lib.rs +++ b/nomos-services/blend/src/lib.rs @@ -171,10 +171,6 @@ where }); let mut lifecycle_stream = service_state.lifecycle_handle.message_stream(); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(msg) = persistent_transmission_messages.next() => { diff --git a/nomos-services/cryptarchia-consensus/src/lib.rs b/nomos-services/cryptarchia-consensus/src/lib.rs index f05fca761..bda0cf7cf 100644 --- a/nomos-services/cryptarchia-consensus/src/lib.rs +++ b/nomos-services/cryptarchia-consensus/src/lib.rs @@ -562,7 +562,6 @@ where let mut lifecycle_stream = self.service_state.lifecycle_handle.message_stream(); async { - #[expect(clippy::redundant_pub_crate, reason = "Generated by `tokio::select` macro.")] loop { tokio::select! { Some(block) = incoming_blocks.next() => { diff --git a/nomos-services/data-availability/indexer/src/lib.rs b/nomos-services/data-availability/indexer/src/lib.rs index c96c03a3d..e7f177ba1 100644 --- a/nomos-services/data-availability/indexer/src/lib.rs +++ b/nomos-services/data-availability/indexer/src/lib.rs @@ -528,10 +528,6 @@ where let storage_adapter = DaStorage::new(storage_relay).await; let mut lifecycle_stream = service_state.lifecycle_handle.message_stream(); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(block) = consensus_blocks.next() => { diff --git a/nomos-services/data-availability/network/src/lib.rs b/nomos-services/data-availability/network/src/lib.rs index 66df67863..494fa0143 100644 --- a/nomos-services/data-availability/network/src/lib.rs +++ b/nomos-services/data-availability/network/src/lib.rs @@ -103,10 +103,6 @@ where } = self; let mut lifecycle_stream = lifecycle_handle.message_stream(); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(msg) = inbound_relay.recv() => { diff --git a/nomos-services/data-availability/sampling/src/backend/kzgrs.rs b/nomos-services/data-availability/sampling/src/backend/kzgrs.rs index c278e0f07..f4d1b7510 100644 --- a/nomos-services/data-availability/sampling/src/backend/kzgrs.rs +++ b/nomos-services/data-availability/sampling/src/backend/kzgrs.rs @@ -146,9 +146,8 @@ impl DaSamplingServiceBackend for KzgrsSamplingBackend< } fn get_commitments(&self, blob_id: &Self::BlobId) -> Option> { - self.pending_sampling_blobs - .get(blob_id) - .and_then(|ctx| ctx.commitment.clone()) + let ctx = self.pending_sampling_blobs.get(blob_id)?; + ctx.commitment.clone() } fn add_commitments(&mut self, blob_id: &Self::BlobId, commitments: Self::SharesCommitments) { diff --git a/nomos-services/data-availability/sampling/src/lib.rs b/nomos-services/data-availability/sampling/src/lib.rs index 17b856e38..926f45b79 100644 --- a/nomos-services/data-availability/sampling/src/lib.rs +++ b/nomos-services/data-availability/sampling/src/lib.rs @@ -463,10 +463,6 @@ where let mut next_prune_tick = sampler.prune_interval(); let mut lifecycle_stream = service_state.lifecycle_handle.message_stream(); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(service_message) = service_state.inbound_relay.recv() => { diff --git a/nomos-services/data-availability/verifier/src/lib.rs b/nomos-services/data-availability/verifier/src/lib.rs index 116b4aa38..09026179e 100644 --- a/nomos-services/data-availability/verifier/src/lib.rs +++ b/nomos-services/data-availability/verifier/src/lib.rs @@ -190,10 +190,6 @@ where let storage_adapter = S::new(storage_relay).await; let mut lifecycle_stream = service_state.lifecycle_handle.message_stream(); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(share) = share_stream.next() => { diff --git a/nomos-services/key-management-system/src/lib.rs b/nomos-services/key-management-system/src/lib.rs index 2e78103bd..c92af9622 100644 --- a/nomos-services/key-management-system/src/lib.rs +++ b/nomos-services/key-management-system/src/lib.rs @@ -143,10 +143,6 @@ where mut backend, } = self; let mut lifecycle_stream = service_state.lifecycle_handle.message_stream(); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(msg) = service_state.inbound_relay.recv() => { diff --git a/nomos-services/mempool/src/network/adapters/mock.rs b/nomos-services/mempool/src/network/adapters/mock.rs index 76764bbae..62cfc41fd 100644 --- a/nomos-services/mempool/src/network/adapters/mock.rs +++ b/nomos-services/mempool/src/network/adapters/mock.rs @@ -55,7 +55,7 @@ impl NetworkAdapter for MockAdapter NetworkAdapter for MockAdapter { tracing::error!("error sending message: {:?}", e); } - }; + } } } @@ -224,7 +224,7 @@ impl Mock { Err(e) => { tracing::error!("error sending message: {:?}", e); } - }; + } } Ok(()) } @@ -296,7 +296,7 @@ impl NetworkBackend for Mock { .unwrap_or_default(); let _ = tx.send(msgs); } - }; + } } async fn subscribe(&mut self, kind: Self::EventKind) -> Receiver { diff --git a/nomos-services/network/src/lib.rs b/nomos-services/network/src/lib.rs index 0ba5dddb6..dbb5c15a2 100644 --- a/nomos-services/network/src/lib.rs +++ b/nomos-services/network/src/lib.rs @@ -99,10 +99,6 @@ where mut backend, } = self; let mut lifecycle_stream = lifecycle_handle.message_stream(); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(msg) = inbound_relay.recv() => { diff --git a/nomos-services/storage/src/backends/rocksdb.rs b/nomos-services/storage/src/backends/rocksdb.rs index d7d511127..d5a6e1d5d 100644 --- a/nomos-services/storage/src/backends/rocksdb.rs +++ b/nomos-services/storage/src/backends/rocksdb.rs @@ -135,13 +135,12 @@ impl StorageBackend for RocksBack } async fn remove(&mut self, key: &[u8]) -> Result, Self::Error> { - self.load(key).await.and_then(|val| { - if val.is_some() { - self.rocks.delete(key).map(|()| val) - } else { - Ok(None) - } - }) + let val = self.load(key).await?; + if val.is_some() { + self.rocks.delete(key).map(|()| val) + } else { + Ok(None) + } } async fn execute( diff --git a/nomos-services/storage/src/lib.rs b/nomos-services/storage/src/lib.rs index 50ba86777..7e52280bb 100644 --- a/nomos-services/storage/src/lib.rs +++ b/nomos-services/storage/src/lib.rs @@ -311,10 +311,6 @@ where } = self; let mut lifecycle_stream = lifecycle_handle.message_stream(); let backend = &mut backend; - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(msg) = inbound_relay.recv() => { diff --git a/nomos-services/system-sig/src/lib.rs b/nomos-services/system-sig/src/lib.rs index 2c4208dba..d2099844b 100644 --- a/nomos-services/system-sig/src/lib.rs +++ b/nomos-services/system-sig/src/lib.rs @@ -48,10 +48,6 @@ where let Self { service_state } = self; let mut ctrlc = async_ctrlc::CtrlC::new()?; let mut lifecycle_stream = service_state.lifecycle_handle.message_stream(); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { () = &mut ctrlc => { diff --git a/nomos-services/time/src/lib.rs b/nomos-services/time/src/lib.rs index 6bfc791aa..9da723cd2 100644 --- a/nomos-services/time/src/lib.rs +++ b/nomos-services/time/src/lib.rs @@ -107,10 +107,6 @@ where const SLOTS_BUFFER: usize = 3; let (broadcast_sender, broadcast_receiver) = broadcast::channel(SLOTS_BUFFER); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] loop { tokio::select! { Some(service_message) = inbound_relay.recv() => { diff --git a/nomos-services/tracing/src/lib.rs b/nomos-services/tracing/src/lib.rs index 5b4192094..2f435e7f1 100644 --- a/nomos-services/tracing/src/lib.rs +++ b/nomos-services/tracing/src/lib.rs @@ -290,10 +290,9 @@ mod serde_level { where D: Deserializer<'de>, { - ::deserialize(deserializer).and_then(|v| { - v.parse() - .map_err(|e| D::Error::custom(format!("invalid log level {e}"))) - }) + let v = ::deserialize(deserializer)?; + v.parse() + .map_err(|e| D::Error::custom(format!("invalid log level {e}"))) } #[expect( diff --git a/nomos-utils/src/lib.rs b/nomos-utils/src/lib.rs index 09f43fd83..5d22e0319 100644 --- a/nomos-utils/src/lib.rs +++ b/nomos-utils/src/lib.rs @@ -47,18 +47,17 @@ pub mod serde { deserializer: D, ) -> Result<[u8; N], D::Error> { use serde::Deserialize; - <&[u8]>::deserialize(deserializer).and_then(|bytes| { - if bytes.len() == N { - let mut output = [0u8; N]; - output.copy_from_slice(bytes); - Ok(output) - } else { - Err(::invalid_length( - bytes.len(), - &format!("{N}").as_str(), - )) - } - }) + let bytes = <&[u8]>::deserialize(deserializer)?; + if bytes.len() == N { + let mut output = [0u8; N]; + output.copy_from_slice(bytes); + Ok(output) + } else { + Err(::invalid_length( + bytes.len(), + &format!("{N}").as_str(), + )) + } } pub fn deserialize_bytes_array<'de, const N: usize, D: serde::Deserializer<'de>>( diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a58e28e1e..42a3ef2d6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -4,4 +4,7 @@ # * shell.nix # * ci/Dockerfile # * testnet/Dockerfile -channel = "1.85.1" +# Also, update the version of the nightly toolchain to the latest nightly of the new version specified in the following places: +# * workflows/code-check.yml (fmt job) +# * .pre-commit-config.yml (fmt hook) +channel = "1.86.0" diff --git a/shell.nix b/shell.nix index d37bdf772..aa87f3577 100644 --- a/shell.nix +++ b/shell.nix @@ -6,7 +6,7 @@ overlays = [ (import (fetchGit { url = "https://github.com/oxalica/rust-overlay.git"; - rev = "a0e3395c63cdbc9c1ec17915f8328c077c79c4a1"; + rev = "c4a8327b0f25d1d81edecbb6105f74d7cf9d7382"; })) ]; } @@ -19,7 +19,7 @@ pkgs.mkShell { pkg-config # Updating the version here requires also updating the `rev` version in the `overlays` section above # with a commit that contains the new version in its manifest - rust-bin.stable."1.85.1".default + rust-bin.stable."1.86.0".default clang_14 llvmPackages_14.libclang openssl.dev diff --git a/testnet/Dockerfile b/testnet/Dockerfile index a559d3f05..b96044246 100644 --- a/testnet/Dockerfile +++ b/testnet/Dockerfile @@ -1,6 +1,6 @@ # BUILD IMAGE --------------------------------------------------------- -FROM rust:1.85.1-slim-bookworm AS builder +FROM rust:1.86.0-slim-bookworm AS builder LABEL maintainer="augustinas@status.im" \ source="https://github.com/logos-co/nomos-node" \ diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 3d708a630..1bff8d75c 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -36,7 +36,6 @@ nomos-node = { workspace = true, default-features = false } nomos-time = { workspace = true } nomos-tracing = { workspace = true } nomos-tracing-service = { workspace = true } -once_cell = "1" rand = "0.8" reqwest = { workspace = true, features = ["json"] } serde = { version = "1", features = ["derive"] } diff --git a/tests/src/lib.rs b/tests/src/lib.rs index 64fc81edd..5bbea9781 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -6,21 +6,23 @@ use std::{ env, net::TcpListener, ops::Mul, - sync::atomic::{AtomicU16, Ordering}, + sync::{ + atomic::{AtomicU16, Ordering}, + LazyLock, + }, time::Duration, }; use nomos_libp2p::{Multiaddr, PeerId, Swarm}; -use once_cell::sync::Lazy; use rand::{thread_rng, Rng}; -static NET_PORT: Lazy = - Lazy::new(|| AtomicU16::new(thread_rng().gen_range(8000..10000))); +static NET_PORT: LazyLock = + LazyLock::new(|| AtomicU16::new(thread_rng().gen_range(8000..10000))); -static IS_SLOW_TEST_ENV: Lazy = - Lazy::new(|| env::var("SLOW_TEST_ENV").is_ok_and(|s| s == "true")); +static IS_SLOW_TEST_ENV: LazyLock = + LazyLock::new(|| env::var("SLOW_TEST_ENV").is_ok_and(|s| s == "true")); -pub static GLOBAL_PARAMS_PATH: Lazy = Lazy::new(|| { +pub static GLOBAL_PARAMS_PATH: LazyLock = LazyLock::new(|| { let relative_path = "./kzgrs/kzgrs_test_params"; let current_dir = env::current_dir().expect("Failed to get current directory"); current_dir @@ -33,8 +35,9 @@ pub static GLOBAL_PARAMS_PATH: Lazy = Lazy::new(|| { /// Global flag indicating whether debug tracing configuration is enabled to /// send traces to local grafana stack. -pub static IS_DEBUG_TRACING: Lazy = - Lazy::new(|| env::var("NOMOS_TESTS_TRACING").is_ok_and(|val| val.eq_ignore_ascii_case("true"))); +pub static IS_DEBUG_TRACING: LazyLock = LazyLock::new(|| { + env::var("NOMOS_TESTS_TRACING").is_ok_and(|val| val.eq_ignore_ascii_case("true")) +}); pub fn get_available_port() -> u16 { loop { diff --git a/tests/src/nodes/mod.rs b/tests/src/nodes/mod.rs index d012c328a..764c7d77a 100644 --- a/tests/src/nodes/mod.rs +++ b/tests/src/nodes/mod.rs @@ -1,15 +1,14 @@ pub mod executor; pub mod validator; -use std::ops::Range; +use std::{ops::Range, sync::LazyLock}; -use once_cell::sync::Lazy; use reqwest::Client; use serde::{Deserialize, Serialize}; use tempfile::TempDir; const LOGS_PREFIX: &str = "__logs"; -static CLIENT: Lazy = Lazy::new(Client::new); +static CLIENT: LazyLock = LazyLock::new(Client::new); fn create_tempdir() -> std::io::Result { // It's easier to use the current location instead of OS-default tempfile diff --git a/tests/src/tests/cryptarchia/happy.rs b/tests/src/tests/cryptarchia/happy.rs index b7e301b5f..b89f85ccc 100644 --- a/tests/src/tests/cryptarchia/happy.rs +++ b/tests/src/tests/cryptarchia/happy.rs @@ -31,10 +31,6 @@ async fn happy_test(topology: &Topology) { .floor() as u64; let timeout = adjust_timeout(Duration::from_secs(timeout)); let timeout = tokio::time::sleep(timeout); - #[expect( - clippy::redundant_pub_crate, - reason = "Generated by `tokio::select` macro." - )] { tokio::select! { () = timeout => panic!("timed out waiting for nodes to produce {} blocks", n_blocks), diff --git a/tests/src/topology/configs/da.rs b/tests/src/topology/configs/da.rs index fba57cd79..aa2c5fa24 100644 --- a/tests/src/topology/configs/da.rs +++ b/tests/src/topology/configs/da.rs @@ -3,6 +3,7 @@ use std::{ env, path::PathBuf, str::FromStr, + sync::LazyLock, time::Duration, }; @@ -12,12 +13,11 @@ use nomos_da_network_core::swarm::{ }; use nomos_libp2p::{ed25519, Multiaddr, PeerId}; use nomos_node::NomosDaMembership; -use once_cell::sync::Lazy; use subnetworks_assignations::MembershipHandler; use crate::{get_available_port, secret_key_to_peer_id}; -pub static GLOBAL_PARAMS_PATH: Lazy = Lazy::new(|| { +pub static GLOBAL_PARAMS_PATH: LazyLock = LazyLock::new(|| { let relative_path = "./kzgrs/kzgrs_test_params"; let current_dir = env::current_dir().expect("Failed to get current directory"); current_dir diff --git a/tests/src/topology/mod.rs b/tests/src/topology/mod.rs index 7e966415e..54736b79a 100644 --- a/tests/src/topology/mod.rs +++ b/tests/src/topology/mod.rs @@ -157,11 +157,19 @@ impl Topology { } } + #[expect( + clippy::missing_const_for_fn, + reason = "Using `Deref` which is not const." + )] #[must_use] pub fn validators(&self) -> &[Validator] { &self.validators } + #[expect( + clippy::missing_const_for_fn, + reason = "Using `Deref` which is not const." + )] #[must_use] pub fn executors(&self) -> &[Executor] { &self.executors