Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rust to latest nightly #2429

Merged
merged 3 commits into from
Jan 20, 2024
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
19 changes: 6 additions & 13 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ jobs:
${{ runner.os }}-cargo-

- name: cargo fmt
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1
with:
command: fmt
args: --all -- --check
run: cargo fmt --all -- --check

cargo-clippy:
strategy:
Expand Down Expand Up @@ -114,10 +111,8 @@ jobs:
${{ runner.os }}-cargo-

- name: cargo clippy
uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d # @v1.0.7
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --locked --all-targets --features "runtime-benchmarks" -- -D warnings
run: |
cargo -Zgitoxide -Zgit clippy --locked --all-targets --features "runtime-benchmarks" -- -D warnings

cargo-docs:
runs-on: ${{ fromJson(github.repository_owner == 'subspace' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-22.04"') }}
Expand All @@ -141,7 +136,7 @@ jobs:
${{ runner.os }}-cargo-

- name: Check Documentation
run: cargo doc --locked --all --no-deps --lib
run: cargo -Zgitoxide -Zgit doc --locked --all --no-deps --lib
env:
RUSTDOCFLAGS: "-D rustdoc::broken-intra-doc-links -D rustdoc::private_intra_doc_links"

Expand Down Expand Up @@ -207,7 +202,5 @@ jobs:
tool: cargo-nextest

- name: cargo nextest run --locked
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1
with:
command: nextest
args: run --locked
run: |
cargo -Zgitoxide -Zgit nextest run --locked
2 changes: 1 addition & 1 deletion .github/workflows/rustdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

# Build the rust crate docs
- name: Build Documentation
run: cargo doc --all --no-deps --lib
run: cargo -Zgitoxide -Zgit doc --all --no-deps --lib
env:
RUSTDOCFLAGS: "-Z unstable-options --enable-index-page"

Expand Down
18 changes: 6 additions & 12 deletions .github/workflows/snapshot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,19 @@ jobs:
${{ runner.os }}-cargo-

- name: Build farmer (Linux and Windows)
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1
with:
command: build
args: --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer
run: |
cargo -Zgitoxide -Zgit build --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer
if: runner.os != 'macOS'

# We build macOS without `numa` feature, primarily because of https://github.com/HadrienG2/hwlocality/issues/31
- name: Build farmer (macOS)
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1
with:
command: build
args: --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer --no-default-features
run: |
cargo -Zgitoxide -Zgit build --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer --no-default-features
if: runner.os == 'macOS'

- name: Build node
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1
with:
command: build
args: --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-node
run: |
cargo -Zgitoxide -Zgit build --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-node

- name: Sign Application (macOS)
run: |
Expand Down
4 changes: 2 additions & 2 deletions 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-2023-10-16
ARG RUSTC_VERSION=nightly-2024-01-19
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down Expand Up @@ -41,7 +41,7 @@ COPY test /code/test
# Up until this line all Rust images in this repo should be the same to share the same layers

RUN \
/root/.cargo/bin/cargo build \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
Expand Down
4 changes: 2 additions & 2 deletions 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-2023-10-16
ARG RUSTC_VERSION=nightly-2024-01-19
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down Expand Up @@ -54,7 +54,7 @@ RUN \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends g++-9-multilib

RUN \
/root/.cargo/bin/cargo build \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-farmer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2023-10-16
ARG RUSTC_VERSION=nightly-2024-01-19
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down Expand Up @@ -41,7 +41,7 @@ COPY test /code/test
# Up until this line all Rust images in this repo should be the same to share the same layers

RUN \
/root/.cargo/bin/cargo build \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
Expand Down
4 changes: 2 additions & 2 deletions 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-2023-10-16
ARG RUSTC_VERSION=nightly-2024-01-19
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down Expand Up @@ -54,7 +54,7 @@ RUN \
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends g++-9-multilib

RUN \
/root/.cargo/bin/cargo build \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-node
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2023-10-16
ARG RUSTC_VERSION=nightly-2024-01-19
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down Expand Up @@ -43,7 +43,7 @@ COPY test /code/test
ARG SUBSTRATE_CLI_GIT_COMMIT_HASH

RUN \
/root/.cargo/bin/cargo build \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
Expand Down
4 changes: 2 additions & 2 deletions 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-2023-10-16
ARG RUSTC_VERSION=nightly-2024-01-19
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down Expand Up @@ -51,7 +51,7 @@ RUN \
libc6-dev-arm64-cross

RUN \
/root/.cargo/bin/cargo build \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-runtime
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

ARG RUSTC_VERSION=nightly-2023-10-16
ARG RUSTC_VERSION=nightly-2024-01-19
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down Expand Up @@ -41,7 +41,7 @@ COPY test /code/test
# Up until this line all Rust images in this repo should be the same to share the same layers

RUN \
/root/.cargo/bin/cargo build \
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
--locked \
-Z build-std \
--profile $PROFILE \
Expand Down
46 changes: 27 additions & 19 deletions crates/pallet-domains/src/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,11 @@ pub(crate) fn do_convert_previous_epoch_deposits<T: Config>(
let maybe_pending_deposit = deposit.pending.take();
// if it is one of the previous domain epoch, then calculate shares for the epoch and update known deposit
deposit.pending = if let Some(PendingDeposit {
effective_domain_epoch,
amount,
}) = maybe_pending_deposit && let Some(epoch_share_price) = OperatorEpochSharePrice::<T>::get(operator_id, effective_domain_epoch)
effective_domain_epoch,
amount,
}) = maybe_pending_deposit
&& let Some(epoch_share_price) =
OperatorEpochSharePrice::<T>::get(operator_id, effective_domain_epoch)
{
let new_shares = epoch_share_price.stake_to_shares::<T>(amount);
deposit.known.shares = deposit
Expand All @@ -411,21 +413,24 @@ pub(crate) fn do_convert_previous_epoch_withdrawal<T: Config>(
withdrawal: &mut Withdrawal<BalanceOf<T>, T::Share, DomainBlockNumberFor<T>>,
) -> Result<(), Error> {
let withdrawal_in_shares = withdrawal.withdrawal_in_shares.take();
withdrawal.withdrawal_in_shares =
if let Some((domain_epoch, domain_block_number, shares)) = withdrawal_in_shares && let Some(epoch_share_price) = OperatorEpochSharePrice::<T>::get(operator_id, domain_epoch){
let withdrawal_amount = epoch_share_price.shares_to_stake::<T>(shares);
withdrawal.total_withdrawal_amount = withdrawal
.total_withdrawal_amount
.checked_add(&withdrawal_amount)
.ok_or(Error::BalanceOverflow)?;
let (domain_id, _) = domain_epoch.deconstruct();
withdrawal
.withdrawals
.push_back((domain_id, domain_block_number, withdrawal_amount));
None
} else {
withdrawal_in_shares
};
withdrawal.withdrawal_in_shares = if let Some((domain_epoch, domain_block_number, shares)) =
withdrawal_in_shares
&& let Some(epoch_share_price) =
OperatorEpochSharePrice::<T>::get(operator_id, domain_epoch)
{
let withdrawal_amount = epoch_share_price.shares_to_stake::<T>(shares);
withdrawal.total_withdrawal_amount = withdrawal
.total_withdrawal_amount
.checked_add(&withdrawal_amount)
.ok_or(Error::BalanceOverflow)?;
let (domain_id, _) = domain_epoch.deconstruct();
withdrawal
.withdrawals
.push_back((domain_id, domain_block_number, withdrawal_amount));
None
} else {
withdrawal_in_shares
};

Ok(())
}
Expand Down Expand Up @@ -836,7 +841,10 @@ pub(crate) fn do_unlock_funds<T: Config>(
*maybe_withdrawal = None;
// if there is no deposit or pending deposits, then clean up the deposit state as well
Deposits::<T>::mutate_exists(operator_id, nominator_id, |maybe_deposit| {
if let Some(deposit) = maybe_deposit && deposit.known.shares.is_zero() && deposit.pending.is_none() {
if let Some(deposit) = maybe_deposit
&& deposit.known.shares.is_zero()
&& deposit.pending.is_none()
{
*maybe_deposit = None
}
});
Expand Down
2 changes: 1 addition & 1 deletion crates/pallet-domains/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ fn test_invalid_domain_extrinsic_root_proof() {
);

let bad_receipt_at = 8;
let valid_bundle_digests = vec![ValidBundleDigest {
let valid_bundle_digests = [ValidBundleDigest {
bundle_index: 0,
bundle_digest: vec![(Some(vec![1, 2, 3]), ExtrinsicDigest::Data(vec![4, 5, 6]))],
}];
Expand Down
4 changes: 2 additions & 2 deletions crates/pallet-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<T: Config> Pallet<T> {
// Block author may equivocate, in which case they'll not be present here
if let Some(block_author) = T::FindBlockRewardAddress::find_block_reward_address() {
let reward = T::BlockReward::get();
T::Currency::deposit_creating(&block_author, reward);
let _imbalance = T::Currency::deposit_creating(&block_author, reward);
T::OnReward::on_reward(block_author.clone(), reward);

Self::deposit_event(Event::BlockReward {
Expand All @@ -127,7 +127,7 @@ impl<T: Config> Pallet<T> {
let reward = T::VoteReward::get();

for voter in T::FindVotingRewardAddresses::find_voting_reward_addresses() {
T::Currency::deposit_creating(&voter, reward);
let _imbalance = T::Currency::deposit_creating(&voter, reward);
T::OnReward::on_reward(voter.clone(), reward);

Self::deposit_event(Event::VoteReward { voter, reward });
Expand Down
7 changes: 4 additions & 3 deletions crates/pallet-transaction-fees/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ where
// Issue storage fees reward.
let storage_fees_reward = storage_fees_escrow_reward + collected_storage_fees_reward;
if !storage_fees_reward.is_zero() {
T::Currency::deposit_creating(&block_author, storage_fees_reward);
let _imbalance = T::Currency::deposit_creating(&block_author, storage_fees_reward);
Self::deposit_event(Event::<T>::StorageFeesReward {
who: block_author.clone(),
amount: storage_fees_reward,
Expand All @@ -273,7 +273,8 @@ where

// Issue compute fees reward.
if !collected_fees.compute.is_zero() {
T::Currency::deposit_creating(&block_author, collected_fees.compute);
let _imbalance =
T::Currency::deposit_creating(&block_author, collected_fees.compute);
Self::deposit_event(Event::<T>::ComputeFeesReward {
who: block_author.clone(),
amount: collected_fees.compute,
Expand All @@ -282,7 +283,7 @@ where

// Issue tips reward.
if !collected_fees.tips.is_zero() {
T::Currency::deposit_creating(&block_author, collected_fees.tips);
let _imbalance = T::Currency::deposit_creating(&block_author, collected_fees.tips);
Self::deposit_event(Event::<T>::TipsReward {
who: block_author,
amount: collected_fees.tips,
Expand Down
5 changes: 2 additions & 3 deletions crates/sp-domains/src/merkle_tree.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::OperatorPublicKey;
use blake2::digest::typenum::U32;
use blake2::digest::FixedOutput;
use blake2::{Blake2b, Digest};
use parity_scale_codec::{Decode, Encode};
Expand Down Expand Up @@ -27,12 +26,12 @@ pub struct Witness {
}

#[derive(Clone)]
pub struct Blake2b256Algorithm(Blake2b<U32>);
pub struct Blake2b256Algorithm;

impl Default for Blake2b256Algorithm {
#[inline]
fn default() -> Self {
Self(Blake2b::new())
Self
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-archiving/tests/integration/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ fn archiver() {

// Check archived bytes for block with index `2` in each archived segment
{
let archived_segment = archived_segments.get(0).unwrap();
let archived_segment = archived_segments.first().unwrap();
let last_archived_block = archived_segment.segment_header.last_archived_block();
assert_eq!(last_archived_block.number, 2);
assert_eq!(last_archived_block.partial_archived(), Some(108352733));
Expand Down Expand Up @@ -360,7 +360,7 @@ fn archiver() {

// Archived segment should fit exactly into the last archived segment (rare case)
{
let archived_segment = archived_segments.get(0).unwrap();
let archived_segment = archived_segments.first().unwrap();
let last_archived_block = archived_segment.segment_header.last_archived_block();
assert_eq!(last_archived_block.number, 3);
assert_eq!(last_archived_block.partial_archived(), None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,7 @@ impl FromStr for DiskFarm {

match key {
"path" => {
plot_directory.replace(
PathBuf::try_from(value).map_err(|error| {
format!("Failed to parse `path` \"{value}\": {error}")
})?,
);
plot_directory.replace(PathBuf::from(value));
}
"size" => {
allocated_plotting_space.replace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ where
RecordKey: From<K>,
K: Clone,
{
// TODO: False-positive in clippy: https://github.com/rust-lang/rust-clippy/issues/12154
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.peer_distance().eq(&other.peer_distance())
}
Expand Down
3 changes: 2 additions & 1 deletion crates/subspace-proof-of-space/src/chiapos/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use alloc::vec::Vec;
use chacha20::cipher::{KeyIvInit, StreamCipher, StreamCipherSeek};
use chacha20::{ChaCha8, Key, Nonce};
use core::mem;
use core::simd::{Simd, SimdUint};
use core::simd::num::SimdUint;
use core::simd::Simd;
#[cfg(any(feature = "parallel", test))]
use rayon::prelude::*;
use seq_macro::seq;
Expand Down
Loading
Loading