Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
328 changes: 164 additions & 164 deletions Cargo.lock

Large diffs are not rendered by default.

262 changes: 131 additions & 131 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/pallet-domains/src/fuzz/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn create_genesis_storage(accounts: &[AccountId], mint: u128) -> Storage {
}

pub fn run_staking_fuzz(data: &[u8]) {
let accounts: Vec<AccountId> = (0..5).map(|i| (i as u128)).collect();
let accounts: Vec<AccountId> = (0..5).map(|i| i as u128).collect();
let mint = (u16::MAX as u128) * 2 * AI3;
let genesis = create_genesis_storage(&accounts, mint);
let Ok(data) = bincode::deserialize(data) else {
Expand Down
7 changes: 5 additions & 2 deletions crates/pallet-subspace/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(array_chunks, assert_matches, portable_simd)]
#![feature(assert_matches, portable_simd)]
#![warn(unused_must_use, unsafe_code, unused_variables)]

#[cfg(not(feature = "std"))]
Expand Down Expand Up @@ -639,7 +639,10 @@ pub mod pallet {
) -> DispatchResult {
ensure_root(origin)?;

if slot_iterations.get() % u32::from(PotCheckpoints::NUM_CHECKPOINTS.get() * 2) != 0 {
if !slot_iterations
.get()
.is_multiple_of(u32::from(PotCheckpoints::NUM_CHECKPOINTS.get() * 2))
{
return Err(Error::<T>::NotMultipleOfCheckpoints.into());
}

Expand Down
2 changes: 1 addition & 1 deletion crates/sc-consensus-subspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//!
//! All of the modules here are crucial for consensus, open each module for specific details.
#![feature(try_blocks, duration_constructors_lite)]
#![feature(try_blocks)]
#![forbid(unsafe_code)]
#![warn(missing_docs)]

Expand Down
2 changes: 1 addition & 1 deletion crates/sp-domains-fraud-proof/src/host_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use subspace_runtime_primitives::Balance;
struct DomainRuntimeCodeFetcher(Vec<u8>);

impl FetchRuntimeCode for DomainRuntimeCodeFetcher {
fn fetch_runtime_code(&self) -> Option<Cow<[u8]>> {
fn fetch_runtime_code(&self) -> Option<Cow<'_, [u8]>> {
Some(Cow::Borrowed(self.0.as_ref()))
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/sp-domains/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ where
pub fn receipt(
&self,
) -> ExecutionReceiptRef<
'_,
Number,
Hash,
HeaderNumberFor<DomainHeader>,
Expand Down Expand Up @@ -218,7 +219,7 @@ where
}

/// Returns the sealed header in the Bundle.
pub fn sealed_header(&self) -> SealedBundleHeaderRef<Number, Hash, DomainHeader, Balance> {
pub fn sealed_header(&self) -> SealedBundleHeaderRef<'_, Number, Hash, DomainHeader, Balance> {
match self {
Bundle::V0(bundle) => SealedBundleHeaderRef::V0(&bundle.sealed_header),
}
Expand Down Expand Up @@ -256,6 +257,7 @@ where
pub fn execution_receipt_as_mut(
&mut self,
) -> ExecutionReceiptMutRef<
'_,
Number,
Hash,
HeaderNumberFor<DomainHeader>,
Expand Down
2 changes: 1 addition & 1 deletion crates/sp-domains/src/execution_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ where
/// Returns the Execution receipt as a ref.
pub fn as_execution_receipt_ref(
&self,
) -> ExecutionReceiptRef<Number, Hash, DomainNumber, DomainHash, Balance> {
) -> ExecutionReceiptRef<'_, Number, Hash, DomainNumber, DomainHash, Balance> {
let ExecutionReceipt::V0(receipt) = self;
ExecutionReceiptRef::V0(receipt)
}
Expand Down
1 change: 0 additions & 1 deletion crates/sp-subspace-mmr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Primitives for Subspace MMR.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(result_flattening)]

#[cfg(all(feature = "std", feature = "runtime-benchmarks"))]
pub mod benchmarking;
Expand Down
9 changes: 6 additions & 3 deletions crates/subspace-archiving/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,14 @@ impl Archiver {
for record_offset in 0..RawRecord::NUM_CHUNKS {
// Collect chunks of each record at the same offset
raw_record_shards
.array_chunks::<{ RawRecord::SIZE }>()
.as_chunks::<{ RawRecord::SIZE }>()
.0
.iter()
.map(|record_bytes| {
record_bytes
.array_chunks::<{ ScalarBytes::SAFE_BYTES }>()
.nth(record_offset)
.as_chunks::<{ ScalarBytes::SAFE_BYTES }>()
.0
.get(record_offset)
.expect("Statically known to exist in a record; qed")
})
.map(Scalar::from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ impl Drop for IncrementalRecordCommitmentsProcessor<'_> {
let iter = raw_records_bytes
.map(|raw_record_bytes| {
raw_record_bytes
.array_chunks::<{ ScalarBytes::SAFE_BYTES }>()
.as_chunks::<{ ScalarBytes::SAFE_BYTES }>()
.0
.iter()
.map(Scalar::from)
})
.map(|record_chunks| {
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-archiving/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Collection of modules used for dealing with archived state of Subspace Network.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(array_chunks, iter_collect_into)]
#![feature(iter_collect_into)]

pub mod archiver;
pub mod piece_reconstructor;
Expand Down
10 changes: 2 additions & 8 deletions crates/subspace-core-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(rust_2018_idioms, missing_docs)]
#![cfg_attr(feature = "std", warn(missing_debug_implementations))]
#![feature(
array_chunks,
const_trait_impl,
const_try,
new_zeroed_alloc,
portable_simd,
step_trait
)]
#![feature(const_trait_impl, const_try, portable_simd, step_trait)]

pub mod checksum;
pub mod hashes;
Expand Down Expand Up @@ -266,6 +259,7 @@ impl ScalarBytes {
}

#[expect(clippy::manual_div_ceil)]
#[expect(clippy::double_parens)]
mod private_u256 {
//! This module is needed to scope clippy allows
use parity_scale_codec::{Decode, Encode};
Expand Down
4 changes: 3 additions & 1 deletion crates/subspace-farmer-components/src/auditing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ fn map_winning_chunks(
) -> Option<Vec<ChunkCandidate>> {
// Map all winning chunks
let mut chunk_candidates = s_bucket
.array_chunks::<{ ScalarBytes::FULL_BYTES }>()
.as_chunks::<{ ScalarBytes::FULL_BYTES }>()
.0
.iter()
.enumerate()
.filter_map(|(chunk_offset, chunk)| {
is_within_solution_range(
Expand Down
2 changes: 0 additions & 2 deletions crates/subspace-farmer-components/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
//! These components are used to implement farmer itself, but can also be used independently if necessary.
#![feature(
array_chunks,
const_trait_impl,
exact_size_is_empty,
int_roundings,
iter_collect_into,
never_type,
new_zeroed_alloc,
portable_simd,
try_blocks
)]
Expand Down
11 changes: 8 additions & 3 deletions crates/subspace-farmer-components/src/plotting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,11 @@ pub fn write_sector(
.iter_s_bucket_records(s_bucket)
.expect("S-bucket guaranteed to be in range; qed")
})
.zip(s_buckets_region.array_chunks_mut::<{ ScalarBytes::FULL_BYTES }>())
.zip(
s_buckets_region
.as_chunks_mut::<{ ScalarBytes::FULL_BYTES }>()
.0,
)
{
let num_encoded_record_chunks =
usize::from(num_encoded_record_chunks[usize::from(piece_offset)]);
Expand All @@ -592,8 +596,9 @@ pub fn write_sector(
output.copy_from_slice(&raw_sector.records[usize::from(piece_offset)][chunk_position]);
}

let metadata_chunks =
metadata_region.array_chunks_mut::<{ RecordMetadata::encoded_size() }>();
let metadata_chunks = metadata_region
.as_chunks_mut::<{ RecordMetadata::encoded_size() }>()
.0;
for (record_metadata, output) in raw_sector.metadata.iter().zip(metadata_chunks) {
record_metadata.encode_to(&mut output.as_mut_slice());
}
Expand Down
6 changes: 5 additions & 1 deletion crates/subspace-farmer-components/src/sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,11 @@ impl SectorContentsMap {

let num_encoded_record_chunks = encoded_record_chunks_used
.iter_mut()
.zip(single_records_bit_arrays.array_chunks::<{ SINGLE_RECORD_BIT_ARRAY_SIZE }>())
.zip(
single_records_bit_arrays
.as_chunks::<{ SINGLE_RECORD_BIT_ARRAY_SIZE }>()
.0,
)
.map(|(encoded_record_chunks_used, bytes)| {
encoded_record_chunks_used
.as_raw_mut_slice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use subspace_erasure_coding::ErasureCoding;
use subspace_kzg::Kzg;
use thiserror::Error;
use tokio::task::JoinError;
use tracing::{error, info};
use tracing::info;

#[derive(Debug, Error)]
pub(crate) enum SegmentReconstructionError {
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-farmer/src/bin/subspace-farmer/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(duration_constructors_lite, type_changing_struct_update)]
#![feature(type_changing_struct_update)]

mod commands;

Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-farmer/src/farmer_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ where
let progress = prev_downloaded_pieces_count as f32
/ pieces_to_download_total as f32
* 100.0;
if prev_downloaded_pieces_count % INTERMEDIATE_CACHE_UPDATE_INTERVAL
== 0
if prev_downloaded_pieces_count
.is_multiple_of(INTERMEDIATE_CACHE_UPDATE_INTERVAL)
{
let mut piece_caches = self.piece_caches.write().await;
piece_caches.clone_from(&caches.lock());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ impl PieceCachesState {
piece_indices_to_store: &mut HashMap<KeyWithDistance, PieceIndex>,
) {
self.stored_pieces
.extract_if(|key, _offset| piece_indices_to_store.remove(key).is_none())
.extract_if(.., |key, _offset| {
piece_indices_to_store.remove(key).is_none()
})
.for_each(|(_piece_index, offset)| {
// There is no need to adjust the `last_stored_offset` of the `backend` here,
// as the free_offset will be preferentially taken from the dangling free offsets
Expand Down
4 changes: 0 additions & 4 deletions crates/subspace-farmer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#![feature(
array_chunks,
array_windows,
assert_matches,
btree_extract_if,
duration_constructors_lite,
exact_size_is_empty,
fmt_helpers_for_derive,
future_join,
impl_trait_in_assoc_type,
int_roundings,
iter_collect_into,
never_type,
result_flattening,
trait_alias,
try_blocks,
type_alias_impl_trait,
Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-farmer/src/single_disk_farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ impl SingleDiskFarm {
let _span_guard = span.enter();

let checked_sectors = checked_sectors.fetch_add(1, Ordering::Relaxed);
if checked_sectors > 1 && checked_sectors % 10 == 0 {
if checked_sectors > 1 && checked_sectors.is_multiple_of(10) {
info!(
"Checked {}/{} sectors",
checked_sectors, metadata_header.plotted_sector_count
Expand Down Expand Up @@ -2322,7 +2322,7 @@ impl SingleDiskFarm {
let _span_guard = span.enter();

let checked_elements = checked_elements.fetch_add(1, Ordering::Relaxed);
if checked_elements > 1 && checked_elements % 1000 == 0 {
if checked_elements > 1 && checked_elements.is_multiple_of(1000) {
info!(
"Checked {}/{} cache elements",
checked_elements, number_of_cached_elements
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-gateway-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::ops::{Deref, DerefMut};
use subspace_core_primitives::objects::GlobalObjectMapping;
use subspace_data_retrieval::object_fetcher::{self, ObjectFetcher};
use subspace_data_retrieval::piece_getter::PieceGetter;
use tracing::{debug, error};
use tracing::debug;

const SUBSPACE_ERROR: i32 = 9000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ where
// since the consensus runtime will perform the these checks and reject the bundle directly
BadReceiptType::InboxedBundle => {
let mismatch_index = random_seed as usize % receipt.inboxed_bundles.len();
receipt.inboxed_bundles[mismatch_index].bundle = if random_seed % 2 == 0 {
receipt.inboxed_bundles[mismatch_index].bundle = if random_seed.is_multiple_of(2) {
BundleValidity::Valid(Default::default())
} else {
let extrincis_index = random_seed % 2;
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-networking/src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::{fmt, io, iter};
use subspace_core_primitives::hashes;
use subspace_core_primitives::pieces::Piece;
use thiserror::Error;
use tracing::{debug, error, info};
use tracing::{debug, info};

const DEFAULT_NETWORK_PROTOCOL_VERSION: &str = "dev";
const KADEMLIA_PROTOCOL: &str = "/subspace/kad/0.1.0";
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-networking/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::sync::{Arc, Weak};
use std::task::{Context, Poll};
use thiserror::Error;
use tokio::sync::OwnedSemaphorePermit;
use tracing::{debug, error, trace};
use tracing::{debug, trace};

/// Topic subscription, will unsubscribe when last instance is dropped for a particular topic.
#[derive(Debug)]
Expand Down
14 changes: 10 additions & 4 deletions crates/subspace-proof-of-space/src/chiapos/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,13 @@ fn find_matches<T, Map>(
.expect("r is valid");

const _: () = {
assert!(PARAM_M as usize % FIND_MATCHES_AND_COMPUTE_UNROLL_FACTOR == 0);
assert!((PARAM_M as usize).is_multiple_of(FIND_MATCHES_AND_COMPUTE_UNROLL_FACTOR));
};

for r_targets in left_targets_r
.array_chunks::<{ FIND_MATCHES_AND_COMPUTE_UNROLL_FACTOR }>()
.as_chunks::<{ FIND_MATCHES_AND_COMPUTE_UNROLL_FACTOR }>()
.0
.iter()
.take(usize::from(PARAM_M) / FIND_MATCHES_AND_COMPUTE_UNROLL_FACTOR)
{
let _: [(); FIND_MATCHES_AND_COMPUTE_UNROLL_FACTOR] = seq!(N in 0..8 {
Expand Down Expand Up @@ -514,7 +516,9 @@ where

let mut t_1 = Vec::with_capacity(1_usize << K);
for (x_batch, partial_ys) in partial_ys
.array_chunks::<{ K as usize * COMPUTE_F1_SIMD_FACTOR / u8::BITS as usize }>()
.as_chunks::<{ K as usize * COMPUTE_F1_SIMD_FACTOR / u8::BITS as usize }>()
.0
.iter()
.copied()
.enumerate()
{
Expand Down Expand Up @@ -542,7 +546,9 @@ where

let mut t_1 = Vec::with_capacity(1_usize << K);
for (x_batch, partial_ys) in partial_ys
.array_chunks::<{ K as usize * COMPUTE_F1_SIMD_FACTOR / u8::BITS as usize }>()
.as_chunks::<{ K as usize * COMPUTE_F1_SIMD_FACTOR / u8::BITS as usize }>()
.0
.iter()
.copied()
.enumerate()
{
Expand Down
4 changes: 3 additions & 1 deletion crates/subspace-proof-of-space/src/chiapos/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ where
EvaluatableUsize<{ metadata_size_bytes(K, PARENT_TABLE_NUMBER) }>: Sized,
{
ys_and_metadata
.array_chunks::<2>()
.as_chunks::<2>()
.0
.iter()
.map(|&[(left_y, left_metadata), (right_y, right_metadata)]| {
has_match(left_y, right_y).then_some(compute_fn::<
K,
Expand Down
8 changes: 1 addition & 7 deletions crates/subspace-proof-of-space/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
// `generic_const_exprs` is an incomplete feature
#![allow(incomplete_features)]
#![warn(rust_2018_idioms, missing_debug_implementations, missing_docs)]
#![feature(
array_chunks,
array_windows,
generic_const_exprs,
portable_simd,
step_trait
)]
#![feature(array_windows, generic_const_exprs, portable_simd, step_trait)]

pub mod chia;
pub mod chiapos;
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-proof-of-time/src/aes/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn expand_key(key: &[u8; 16]) -> [uint8x16_t; NUM_ROUND_KEYS] {
)
};

for (i, chunk) in key.array_chunks::<WORD_SIZE>().enumerate() {
for (i, chunk) in key.as_chunks::<WORD_SIZE>().0.iter().enumerate() {
columns[i] = u32::from_ne_bytes(*chunk);
}

Expand Down
Loading
Loading