Skip to content

Commit

Permalink
Upgrade Rust to latest nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jan 19, 2024
1 parent 20b167e commit adbf8fc
Show file tree
Hide file tree
Showing 22 changed files with 64 additions and 54 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-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
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-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
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-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
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-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
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-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
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-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
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-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
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
3 changes: 1 addition & 2 deletions domains/client/eth-service/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use fc_rpc::{
Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer,
EthSigner, Net, NetApiServer, Web3, Web3ApiServer,
};
pub use fc_rpc::{EthBlockDataCacheTask, EthConfig, StorageOverride};
pub use fc_rpc::{EthBlockDataCacheTask, EthConfig};
pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
pub use fc_storage::overrides_handle;
use fc_storage::OverrideHandle;
use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi};
use jsonrpsee::RpcModule;
Expand Down
2 changes: 0 additions & 2 deletions domains/client/eth-service/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pub use fc_consensus::FrontierBlockImport;
pub use fc_db::kv::frontier_database_dir;
use fc_mapping_sync::kv::MappingSyncWorker;
use fc_mapping_sync::SyncStrategy;
use fc_rpc::{EthTask, OverrideHandle};
Expand Down
6 changes: 3 additions & 3 deletions domains/pallets/transporter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ mod pallet {
let sender = ensure_signed(origin)?;

// burn transfer amount
T::Currency::withdraw(
let _imbalance = T::Currency::withdraw(
&sender,
amount,
WithdrawReasons::TRANSFER,
Expand Down Expand Up @@ -266,7 +266,7 @@ mod pallet {
let account_id = T::AccountIdConverter::try_convert_back(req.receiver.account_id)
.ok_or(Error::<T>::InvalidAccountId)?;

T::Currency::deposit_creating(&account_id, req.amount);
let _imbalance = T::Currency::deposit_creating(&account_id, req.amount);
frame_system::Pallet::<T>::deposit_event(Into::<<T as Config>::RuntimeEvent>::into(
Event::<T>::IncomingTransferSuccessful {
chain_id: src_chain_id,
Expand Down Expand Up @@ -314,7 +314,7 @@ mod pallet {
let account_id =
T::AccountIdConverter::try_convert_back(transfer.sender.account_id)
.ok_or(Error::<T>::InvalidAccountId)?;
T::Currency::deposit_creating(&account_id, transfer.amount);
let _imbalance = T::Currency::deposit_creating(&account_id, transfer.amount);
frame_system::Pallet::<T>::deposit_event(
Into::<<T as Config>::RuntimeEvent>::into(
Event::<T>::OutgoingTransferFailed {
Expand Down
6 changes: 6 additions & 0 deletions domains/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ where
let (engine, sync_service, block_announce_config) = SyncingEngine::new(
Roles::from(&config.role),
client.clone(),
// TODO: False-positive in clippy: https://github.com/rust-lang/rust-clippy/issues/12148
#[allow(clippy::useless_asref)]
config
.prometheus_config
.as_ref()
Expand Down Expand Up @@ -212,6 +214,8 @@ where
genesis_hash,
protocol_id,
fork_id: config.chain_spec.fork_id().map(ToOwned::to_owned),
// TODO: False-positive in clippy: https://github.com/rust-lang/rust-clippy/issues/12148
#[allow(clippy::useless_asref)]
metrics_registry: config
.prometheus_config
.as_ref()
Expand All @@ -234,6 +238,8 @@ where
transaction_pool,
client.clone(),
)),
// TODO: False-positive in clippy: https://github.com/rust-lang/rust-clippy/issues/12148
#[allow(clippy::useless_asref)]
config
.prometheus_config
.as_ref()
Expand Down
6 changes: 3 additions & 3 deletions orml/vesting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn add_new_vesting_schedule_merges_with_current_locked_balance_and_until() {
));

assert_eq!(
PalletBalances::locks(BOB).get(0),
PalletBalances::locks(BOB).first(),
Some(&BalanceLock {
id: VESTING_LOCK_ID,
amount: 17u64,
Expand Down Expand Up @@ -348,7 +348,7 @@ fn claim_for_works() {
assert_ok!(Vesting::claim_for(RuntimeOrigin::signed(ALICE), BOB));

assert_eq!(
PalletBalances::locks(BOB).get(0),
PalletBalances::locks(BOB).first(),
Some(&BalanceLock {
id: VESTING_LOCK_ID,
amount: 20u64,
Expand Down Expand Up @@ -411,7 +411,7 @@ fn update_vesting_schedules_works() {
// empty vesting schedules cleanup the storage and unlock the fund
assert!(VestingSchedules::<Runtime>::contains_key(BOB));
assert_eq!(
PalletBalances::locks(BOB).get(0),
PalletBalances::locks(BOB).first(),
Some(&BalanceLock {
id: VESTING_LOCK_ID,
amount: 10u64,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2023-10-16"
channel = "nightly-2024-01-19"
components = ["rust-src"]
targets = ["wasm32-unknown-unknown"]
profile = "default"

0 comments on commit adbf8fc

Please sign in to comment.