Skip to content

Commit

Permalink
Merge pull request #2958 from autonomys/update-rust-toolchain
Browse files Browse the repository at this point in the history
Update Rust toolchain to latest nightly
  • Loading branch information
nazar-pc authored Aug 1, 2024
2 parents 4433a77 + 9e730f7 commit 5506663
Show file tree
Hide file tree
Showing 29 changed files with 97 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-bootstrap-node
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2024-04-22
ARG RUSTC_VERSION=nightly-2024-08-01
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-bootstrap-node.aarch64
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2024-04-22
ARG RUSTC_VERSION=nightly-2024-08-01
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-farmer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2024-04-22
ARG RUSTC_VERSION=nightly-2024-08-01
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-farmer.aarch64
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2024-04-22
ARG RUSTC_VERSION=nightly-2024-08-01
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-node
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2024-04-22
ARG RUSTC_VERSION=nightly-2024-08-01
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-node.aarch64
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2024-04-22
ARG RUSTC_VERSION=nightly-2024-08-01
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-runtime
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2024-04-22
ARG RUSTC_VERSION=nightly-2024-08-01
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down
5 changes: 5 additions & 0 deletions crates/pallet-grandpa-finality-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ std = [
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
5 changes: 5 additions & 0 deletions crates/pallet-subspace-mmr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ std = [
"sp-std/std",
"sp-subspace-mmr/std"
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
18 changes: 9 additions & 9 deletions crates/sc-subspace-block-relay/src/consensus/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
//! Consensus related types.
//!
//! The relay protocol needs to expose these data types to be included
//! in the top level data types:
//! 1. The request/response types to be included in
//! [`ProtocolInitialRequest`]/[`ProtocolInitialResponse`].
//! 2. The handshake message to be included in `ProtocolMessage`.
//! The corresponding handshake response is not included in the
//! top level messages, and is private to the protocol
//! implementation.

use crate::protocol::compact_block::{
CompactBlockHandshake, CompactBlockInitialRequest, CompactBlockInitialResponse,
Expand All @@ -24,15 +33,6 @@ const DOWNLOAD_LABEL: &str = "client_download";
const DOWNLOAD_BLOCKS: &str = "blocks";
const DOWNLOAD_BYTES: &str = "bytes";

/// The relay protocol needs to expose these data types to be included
/// in the top level data types:
/// 1. The request/response types to be included in
/// `ProtocolInitialRequest`/`ProtocolInitialResponse`.
/// 2. The handshake message to be included in `ProtocolMessage`.
/// The corresponding handshake response is not included in the
/// top level messages, and is private to the protocol
/// implementation.

/// Client -> server request.
#[derive(From, Encode, Decode)]
pub(crate) enum ConsensusRequest<Block: BlockT, TxHash> {
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-archiving/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

//! Collection of modules used for dealing with archived state of Subspace Network.
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(array_chunks, extract_if, iter_collect_into, slice_flatten)]
#![feature(array_chunks, extract_if, iter_collect_into)]

pub mod archiver;
pub mod piece_reconstructor;
Expand Down
1 change: 0 additions & 1 deletion crates/subspace-core-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
const_try,
new_uninit,
portable_simd,
slice_flatten,
step_trait
)]

Expand Down
10 changes: 5 additions & 5 deletions crates/subspace-core-primitives/src/pieces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ impl Default for RawRecord {
impl AsRef<[u8]> for RawRecord {
#[inline]
fn as_ref(&self) -> &[u8] {
self.0.as_slice().flatten()
self.0.as_slice().as_flattened()
}
}

impl AsMut<[u8]> for RawRecord {
#[inline]
fn as_mut(&mut self) -> &mut [u8] {
self.0.as_mut_slice().flatten_mut()
self.0.as_mut_slice().as_flattened_mut()
}
}

Expand Down Expand Up @@ -487,14 +487,14 @@ impl Default for Record {
impl AsRef<[u8]> for Record {
#[inline]
fn as_ref(&self) -> &[u8] {
self.0.flatten()
self.0.as_flattened()
}
}

impl AsMut<[u8]> for Record {
#[inline]
fn as_mut(&mut self) -> &mut [u8] {
self.0.flatten_mut()
self.0.as_flattened_mut()
}
}

Expand Down Expand Up @@ -604,7 +604,7 @@ impl Record {
length,
)
};
for byte in slice.flatten_mut().flatten_mut() {
for byte in slice.as_flattened_mut().as_flattened_mut() {
byte.write(0);
}
}
Expand Down
8 changes: 5 additions & 3 deletions crates/subspace-core-primitives/src/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,18 @@ impl Default for RecordedHistorySegment {
impl AsRef<[u8]> for RecordedHistorySegment {
#[inline]
fn as_ref(&self) -> &[u8] {
RawRecord::slice_to_repr(&self.0).flatten().flatten()
RawRecord::slice_to_repr(&self.0)
.as_flattened()
.as_flattened()
}
}

impl AsMut<[u8]> for RecordedHistorySegment {
#[inline]
fn as_mut(&mut self) -> &mut [u8] {
RawRecord::slice_mut_to_repr(&mut self.0)
.flatten_mut()
.flatten_mut()
.as_flattened_mut()
.as_flattened_mut()
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/subspace-farmer-components/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
never_type,
new_uninit,
portable_simd,
slice_flatten,
try_blocks
)]
#![warn(rust_2018_idioms, missing_debug_implementations, missing_docs)]
Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-farmer-components/src/plotting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ async fn download_sector_internal<PG: PieceGetter>(
// Fancy way to insert value in order to avoid going through stack (if naive de-referencing
// is used) and potentially causing stack overflow as the result
record
.flatten_mut()
.copy_from_slice(piece.record().flatten());
.as_flattened_mut()
.copy_from_slice(piece.record().as_flattened());
*metadata = RecordMetadata {
commitment: *piece.commitment(),
witness: *piece.witness(),
Expand Down
2 changes: 0 additions & 2 deletions crates/subspace-farmer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
let_chains,
never_type,
result_flattening,
slice_flatten,
split_at_checked,
trait_alias,
try_blocks,
type_alias_impl_trait,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ impl UnbufferedIoFileWindows {
// done with granularity of physical sector size
let offset_in_buffer = (offset % self.physical_sector_size as u64) as usize;
self.file.read_exact_at(
&mut scratch_buffer.flatten_mut()[..(bytes_to_read + offset_in_buffer)
&mut scratch_buffer.as_flattened_mut()[..(bytes_to_read + offset_in_buffer)
.div_ceil(self.physical_sector_size)
* self.physical_sector_size],
offset / self.physical_sector_size as u64 * self.physical_sector_size as u64,
)?;

Ok(&scratch_buffer.flatten()[offset_in_buffer..][..bytes_to_read])
Ok(&scratch_buffer.as_flattened()[offset_in_buffer..][..bytes_to_read])
}

/// Panics on writes over `MAX_READ_SIZE` (including padding on both ends)
Expand All @@ -202,7 +202,7 @@ impl UnbufferedIoFileWindows {
offset: u64,
) -> io::Result<()> {
// This is guaranteed by `UnbufferedIoFileWindows::open()`
assert!(scratch_buffer.flatten().len() >= MAX_READ_SIZE);
assert!(scratch_buffer.as_flattened().len() >= MAX_READ_SIZE);

let aligned_offset =
offset / self.physical_sector_size as u64 * self.physical_sector_size as u64;
Expand All @@ -212,13 +212,13 @@ impl UnbufferedIoFileWindows {
* self.physical_sector_size;

if padding == 0 && bytes_to_read == bytes_to_write.len() {
let scratch_buffer = &mut scratch_buffer.flatten_mut()[..bytes_to_read];
let scratch_buffer = &mut scratch_buffer.as_flattened_mut()[..bytes_to_read];
scratch_buffer.copy_from_slice(bytes_to_write);
self.file.write_all_at(scratch_buffer, offset)?;
} else {
// Read whole pages where `bytes_to_write` will be written
self.read_exact_at_internal(scratch_buffer, bytes_to_read, aligned_offset)?;
let scratch_buffer = &mut scratch_buffer.flatten_mut()[..bytes_to_read];
let scratch_buffer = &mut scratch_buffer.as_flattened_mut()[..bytes_to_read];
// Update contents of existing pages and write into the file
scratch_buffer[padding..][..bytes_to_write.len()].copy_from_slice(bytes_to_write);
self.file.write_all_at(scratch_buffer, aligned_offset)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
//! A request-response protocol works in the following way:
//!
//! - For every emitted request, a new substream is open and the protocol is negotiated. If the
//! remote supports the protocol, the size of the request is sent as a LEB128 number, followed
//! with the request itself. The remote then sends the size of the response as a LEB128 number,
//! followed with the response.
//! remote supports the protocol, the size of the request is sent as a LEB128 number, followed
//! with the request itself. The remote then sends the size of the response as a LEB128 number,
//! followed with the response.
//!
//! - Requests have a certain time limit before they time out. This time includes the time it
//! takes to send/receive the request and response.
//! takes to send/receive the request and response.
//!
//! - If provided, a ["requests processing"](ProtocolConfig::inbound_queue) channel
//! is used to handle incoming requests.

//! is used to handle incoming requests.
//!
//! Original file commit: <https://github.com/paritytech/substrate/commit/c2fc4b3ca0d7a15cc3f9cb1e5f441d99ec8d6e0b>

#[cfg(test)]
Expand Down Expand Up @@ -163,7 +163,7 @@ pub struct IncomingRequest {
/// 1. Drop `pending_response` and thus not changing the reputation of the peer.
///
/// 2. Sending an `Err(())` via `pending_response`, optionally including reputation changes for
/// the given peer.
/// the given peer.
pub pending_response: oneshot::Sender<OutgoingResponse>,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-networking/src/protocols/reserved_peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ use crate::utils::strip_peer_id;
/// Each `ReservedPeerState` can be in one of the following states, represented by the
/// `ConnectionStatus` enum:
/// 1. `NotConnected`: This state indicates that the peer is currently not connected.
/// The time for the next connection attempt is scheduled and can be queried.
/// The time for the next connection attempt is scheduled and can be queried.
/// 2. `PendingConnection`: This state means that a connection attempt to the peer is currently
/// in progress.
/// in progress.
/// 3. `Connected`: This state signals that the peer is currently connected.
///
/// The protocol will attempt to establish a connection to a `NotConnected` peer after a set delay,
Expand Down
6 changes: 3 additions & 3 deletions domains/client/block-preprocessor/src/stateless_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use subspace_runtime_primitives::Moment;
///
/// NOTE:
/// - This is only supposed to be used when no domain client available, i.e., when the
/// caller does not own the entire domain state.
/// caller does not own the entire domain state.
/// - This perfectly fits the runtime APIs that are purely stateless, but it's also usable
/// for the stateful APIs. If some states are used inside a runtime api, these states must
/// be provided and set before dispatching otherwise [`StatelessRuntime`] may give invalid output.
/// for the stateful APIs. If some states are used inside a runtime api, these states must
/// be provided and set before dispatching otherwise [`StatelessRuntime`] may give invalid output.
pub struct StatelessRuntime<CBlock, Block, Executor> {
executor: Arc<Executor>,
runtime_code: Cow<'static, [u8]>,
Expand Down
4 changes: 2 additions & 2 deletions domains/client/consensus-relay-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
//! 2. This parachain candidate is send to the parachain validators that are part of the relay chain.
//!
//! 3. The parachain validators validate at most X different parachain candidates, where X is the
//! total number of parachain validators.
//! total number of parachain validators.
//!
//! 4. The parachain candidate that is backed by the most validators is chosen by the relay-chain
//! block producer to be added as backed candidate on chain.
//! block producer to be added as backed candidate on chain.
//!
//! 5. After the parachain candidate got backed and included, all collators start at 1.

Expand Down
33 changes: 17 additions & 16 deletions domains/client/domain-operator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,31 @@
//! on the execution layer, they provide the necessary computational resources to maintain the
//! blockchain state by running domains. Some deposits as the stake are required to be an operator.
//!
//! Specifically, operators have the responsibity of producing a [`Bundle`] which contains a
//! Specifically, operators have the responsibility of producing a [`Bundle`] which contains a
//! number of [`ExecutionReceipt`]s on each slot notified from the consensus chain. The operators
//! are primarily driven by two events from the consensus chain.
//!
//! - On each new slot, operators will attempt to solve a domain-specific bundle election
//! challenge derived from a global randomness provided by the consensus chain. Upon finding
//! a solution to the challenge, they will start producing a bundle: they will collect a set
//! of extrinsics from the transaction pool which are verified to be able to cover the transaction
//! fee. With these colltected extrinsics, the bundle election solution and proper receipts, a
//! [`Bundle`] can be constructed and then be submitted to the consensus chain. The transactions
//! included in each bundle are uninterpretable blob from the consensus chain's perspective.
//! challenge derived from a global randomness provided by the consensus chain. Upon finding
//! a solution to the challenge, they will start producing a bundle: they will collect a set
//! of extrinsics from the transaction pool which are verified to be able to cover the transaction
//! fee. With these collected extrinsics, the bundle election solution and proper receipts, a
//! [`Bundle`] can be constructed and then be submitted to the consensus chain. The transactions
//! included in each bundle are uninterpretable blob from the consensus chain's perspective.
//!
//! - On each imported consensus block, operators will extract all the needed bundles from it
//! and convert the bundles to a list of extrinsics, construct a custom [`BlockBuilder`] to
//! build a domain block. The execution trace of all the extrinsics and hooks like
//! `initialize_block`/`finalize_block` will be recorded during the domain block execution.
//! Once the domain block is imported successfully, the [`ExecutionReceipt`] of this block
//! will be generated and stored locally.
//! and convert the bundles to a list of extrinsics, construct a custom [`BlockBuilder`] to
//! build a domain block. The execution trace of all the extrinsics and hooks like
//! `initialize_block`/`finalize_block` will be recorded during the domain block execution.
//! Once the domain block is imported successfully, the [`ExecutionReceipt`] of this block
//! will be generated and stored locally.
//!
//! The receipt of each domain block contains all the intermediate state roots during the block
//! execution, which will be gossiped in the domain subnet (in future). All operators whether running as an
//! authority or a full node will compute each block and generate an execution receipt independently,
//! once the execution receipt received from the network does not match the one produced locally,
//! a [`FraudProof`] will be generated and reported to the consensus chain accordingly.
//! execution, which will be gossiped in the domain subnet (in future). All operators whether
//! running as an authority or a full node will compute each block and generate an execution receipt
//! independently, once the execution receipt received from the network does not match the one
//! produced locally, a [`FraudProof`] will be generated and reported to the consensus chain
//! accordingly.
//!
//! [`BlockBuilder`]: ../domain_block_builder/struct.BlockBuilder.html
//! [`FraudProof`]: ../sp_domains/struct.FraudProof.html
Expand Down
1 change: 1 addition & 0 deletions domains/client/domain-operator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ async fn test_long_trace_for_finalize_block_proof_creation_and_verification_shou
/// - 2 to test the `apply_extrinsic` state transition with the inherent `set_consensus_chain_byte_fee` extrinsic
/// - 3 to test the `apply_extrinsic` state transition with regular domain extrinsic
/// - 4 to test the `finalize_block` state transition
///
/// TraceDiffType can be passed as `TraceDiffType::Shorter`, `TraceDiffType::Longer`
/// and `TraceDiffType::Mismatch`
async fn test_invalid_state_transition_proof_creation_and_verification(
Expand Down
5 changes: 5 additions & 0 deletions domains/pallets/block-fees/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ std = [
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
5 changes: 5 additions & 0 deletions domains/pallets/domain-id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ std = [
]

runtime-benchmarks = []
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
Loading

0 comments on commit 5506663

Please sign in to comment.