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

Bump Rust version to 1.81.0 #691

Merged
merged 5 commits into from
Oct 4, 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
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
path: binaries
- name: Unit tests
run: |
cargo test --release --all --features=fast-runtime
cargo test --release --all --features=fast-runtime --exclude tc-consensus
- name: Typescript Tests Tanssi (Dev Service)
uses: ./.github/workflow-templates/typescript-tests-moonwall
with:
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@ correctness = { level = "deny", priority = 1 }
suspicious = { level = "deny", priority = 1 }

# Add some additional lints
as_underscore = { level = "warn", priority = 1 }
cast_lossless = { level = "warn", priority = 1 }
cast_possible_wrap = { level = "warn", priority = 1 }
cast_precision_loss = { level = "warn", priority = 1 }
cast_sign_loss = { level = "warn", priority = 1 }
debug_assert_with_mut_call = { level = "warn", priority = 1 }
fn_to_numeric_cast_any = { level = "warn", priority = 1 }
invalid_upcast_comparisons = { level = "warn", priority = 1 }
as_underscore = { level = "warn", priority = 2 }
cast_lossless = { level = "warn", priority = 2 }
cast_possible_wrap = { level = "warn", priority = 2 }
cast_precision_loss = { level = "warn", priority = 2 }
cast_sign_loss = { level = "warn", priority = 2 }
debug_assert_with_mut_call = { level = "warn", priority = 2 }
fn_to_numeric_cast_any = { level = "warn", priority = 2 }
invalid_upcast_comparisons = { level = "warn", priority = 2 }

# Allow annoying lints and false positives
erasing_op = { level = "allow", priority = 2 }
identity_op = { level = "allow", priority = 2 }
too-many-arguments = { level = "allow", priority = 2 }
type_complexity = { level = "allow", priority = 2 }
erasing_op = { level = "allow", priority = 3 }
identity_op = { level = "allow", priority = 3 }
manual_inspect = { level = "allow", priority = 3 }
too-many-arguments = { level = "allow", priority = 3 }
type_complexity = { level = "allow", priority = 3 }

[workspace.lints.rust]
unsafe-code = { level = "deny", priority = 1 }
Expand Down
4 changes: 2 additions & 2 deletions client/consensus/src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ impl MockRuntimeApi {
if let Some(para_id) = self.0 {
let _ =
sender.send(Ok(vec![CoreState::Scheduled(ScheduledCore {
para_id: para_id,
para_id,
collator: None,
})]));
} else {
Expand Down Expand Up @@ -889,7 +889,7 @@ impl CollatorLookaheadTestBuilder {
CancellationToken,
) {
// Creation of keystore
let _ = sp_tracing::try_init_simple();
sp_tracing::try_init_simple();
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
let keystore = LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore.");
let alice_public = keystore
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async fn claim_slot_respects_min_slot_freq() {
#[tokio::test]
async fn collate_returns_correct_block() {
let net = AuraTestNet::new(4);
let _ = sp_tracing::try_init_simple();
sp_tracing::try_init_simple();

let keystore_path = tempfile::tempdir().expect("Creates keystore path");
let keystore = LocalKeystore::open(keystore_path.path(), None).expect("Creates keystore.");
Expand Down
39 changes: 18 additions & 21 deletions client/service-container-chain/src/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,12 +883,11 @@ async fn get_latest_container_block_number_from_orchestrator(
container_chain_para_id: ParaId,
) -> Option<u32> {
// Get the container chain's latest block from orchestrator chain and compare with client's one
let last_container_block_from_orchestrator = orchestrator_chain_interface

orchestrator_chain_interface
.latest_block_number(orchestrator_block_hash, container_chain_para_id)
.await
.unwrap_or_default();

last_container_block_from_orchestrator
.unwrap_or_default()
}

#[derive(Debug)]
Expand Down Expand Up @@ -924,23 +923,21 @@ async fn db_needs_removal(
let last_container_block_temp = container_chain_client.chain_info().best_number;
if last_container_block_temp == 0 {
// Don't remove an empty database, as it may be in the process of a warp sync
} else {
if get_latest_container_block_number_from_orchestrator(
orchestrator_chain_interface,
orchestrator_block_hash,
container_chain_para_id,
)
.await
.unwrap_or(0)
.abs_diff(last_container_block_temp)
> MAX_BLOCK_DIFF_FOR_FULL_SYNC
{
// if the diff is big, delete db and restart using warp sync
return Ok(Some(DbRemovalReason::HighBlockDiff {
best_block_number_db: last_container_block_temp,
best_block_number_onchain: last_container_block_temp,
}));
}
} else if get_latest_container_block_number_from_orchestrator(
orchestrator_chain_interface,
orchestrator_block_hash,
container_chain_para_id,
)
.await
.unwrap_or(0)
.abs_diff(last_container_block_temp)
> MAX_BLOCK_DIFF_FOR_FULL_SYNC
{
// if the diff is big, delete db and restart using warp sync
return Ok(Some(DbRemovalReason::HighBlockDiff {
best_block_number_db: last_container_block_temp,
best_block_number_onchain: last_container_block_temp,
}));
}
}

Expand Down
1 change: 0 additions & 1 deletion container-chains/nodes/frontier/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,4 @@ pub struct RpcConfig {
pub eth_statuses_cache: usize,
pub fee_history_limit: u64,
pub max_past_logs: u32,
pub relay_chain_rpc_urls: Vec<url::Url>,
}
1 change: 0 additions & 1 deletion container-chains/nodes/frontier/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ pub fn run() -> Result<()> {
eth_statuses_cache: cli.run.eth_statuses_cache,
fee_history_limit: cli.run.fee_history_limit,
max_past_logs: cli.run.max_past_logs,
relay_chain_rpc_urls: cli.run.base.relay_chain_rpc_urls,
};

let extension = chain_spec::Extensions::try_get(&*config.chain_spec);
Expand Down
1 change: 1 addition & 0 deletions container-chains/nodes/frontier/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub struct FullDeps<C, P, A: ChainApi, BE> {
// TODO: log indexer?
pub frontier_backend: Arc<dyn fc_api::Backend<Block>>,
/// Backend.
#[allow(dead_code)] // not used but keep nice type inference
pub backend: Arc<BE>,
/// Maximum number of logs in a query.
pub max_past_logs: u32,
Expand Down
3 changes: 1 addition & 2 deletions node/src/command/solochain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ impl SolochainRunner {
/// 2020-06-03 16:14:21 ⛓ Native runtime: node-251 (substrate-node-1.tx1.au10)
/// ```
fn print_node_infos(&self) {
use chrono::offset::Local;
use chrono::Datelike;
use chrono::{offset::Local, Datelike};
type C = ContainerChainCli;
info!("{}", C::impl_name());
info!("✌️ version {}", C::impl_version());
Expand Down
2 changes: 1 addition & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ pub async fn start_solochain_node(
.base_path
.as_ref()
.expect("base_path is always set");
let config_dir = build_solochain_config_dir(&base_path);
let config_dir = build_solochain_config_dir(base_path);
let keystore = keystore_config(container_chain_cli.keystore_params(), &config_dir)
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;

Expand Down
15 changes: 5 additions & 10 deletions pallets/author-noting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ impl<T: Config> LatestAuthorInfoFetcher<T::AccountId> for Pallet<T> {

/// This pallet has slightly different behavior when used in a parachain vs when used in a relay chain
/// (solochain). The main difference is:
/// * In relay mode, we don't need a storage proof, so the inherent doesn't need any input argument,
/// In relay mode, we don't need a storage proof, so the inherent doesn't need any input argument,
/// and instead of reading from a storage proof we read from storage directly.
pub trait RelayOrPara {
type InherentArg: TypeInfo + Clone + PartialEq + Encode + Decode + core::fmt::Debug;
Expand Down Expand Up @@ -466,13 +466,10 @@ impl<RCSP: RelaychainStateProvider> RelayOrPara for ParaMode<RCSP> {
type GenericStorageReader = GenericStateProof<cumulus_primitives_core::relay_chain::Block>;

fn create_inherent_arg(data: &InherentData) -> Self::InherentArg {
let data/*: tp_author_noting_inherent::OwnParachainInherentData*/ = data
.get_data(&INHERENT_IDENTIFIER)
data.get_data(&INHERENT_IDENTIFIER)
.ok()
.flatten()
.expect("there is not data to be posted; qed");

data
.expect("there is not data to be posted; qed")
}

fn create_storage_reader(data: Self::InherentArg) -> Self::GenericStorageReader {
Expand All @@ -482,11 +479,9 @@ impl<RCSP: RelaychainStateProvider> RelayOrPara for ParaMode<RCSP> {

let relay_chain_state = RCSP::current_relay_chain_state();
let relay_storage_root = relay_chain_state.state_root;
let relay_storage_rooted_proof =
GenericStateProof::new(relay_storage_root, relay_storage_proof)
.expect("Invalid relay chain state proof");

relay_storage_rooted_proof
GenericStateProof::new(relay_storage_root, relay_storage_proof)
.expect("Invalid relay chain state proof")
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
14 changes: 7 additions & 7 deletions pallets/collator-assignment/src/assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ where
///
/// If the available number of collators is:
/// * lower than the min of the first chain: we assign all the collators to the first chain. This is the
/// orchestrator chain and we always want it to have collators.
/// orchestrator chain and we always want it to have collators.
/// * lower than the sum of all the min: we cannot assign collators to all the chains. So remove chains until
/// we can. The order is important, the first chains will be assigned collators and the last ones will not.
/// we can. The order is important, the first chains will be assigned collators and the last ones will not.
/// * lower than the sum of all the max: we can assign the min value to all the chains, and have some leftover.
/// We use the same order to decide where this extra collators will go, by filling the max of the first chain,
/// then the max of the second chain, and so on.
/// We use the same order to decide where this extra collators will go, by filling the max of the first chain,
/// then the max of the second chain, and so on.
/// * greater than the sum of all the max: all the chains will be assigned their max number of collators.
///
/// # Params
Expand Down Expand Up @@ -340,12 +340,12 @@ where
///
/// * `old_assigned` does not need to be a subset of `collators`: collators are checked and removed.
/// * `old_assigned` does not need to be a subset of `chains`, unused para ids are removed. Collators
/// assigned to a para_id not present in `chains` may be reassigned to another para_id.
/// assigned to a para_id not present in `chains` may be reassigned to another para_id.
/// * `chains` `num_collators` can be 0. In that case an empty vec is returned for that para id.
/// * `old_assigned` must not have duplicate collators.
/// * `shuffle` is used to shuffle the list collators. The list will be truncated to only have
/// the number of required collators, to ensure that shuffling doesn't cause a collator with low
/// priority to be assigned instead of a collator with higher priority.
/// the number of required collators, to ensure that shuffling doesn't cause a collator with low
/// priority to be assigned instead of a collator with higher priority.
///
/// # Returns
///
Expand Down
5 changes: 1 addition & 4 deletions pallets/collator-assignment/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@

//! Benchmarking setup for pallet-invulnerables

#![cfg(feature = "runtime-benchmarks")]

use super::*;

#[allow(unused)]
use {
super::*,
crate::Pallet,
frame_benchmarking::{account, impl_benchmark_test_suite, v2::*, BenchmarkError},
frame_support::{
Expand Down
10 changes: 5 additions & 5 deletions pallets/collator-assignment/src/tests/with_core_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>

use crate::assignment::ChainNumCollators;
use crate::mock::*;
use crate::{CoreAllocationConfiguration, Pallet};
use sp_runtime::Perbill;
use tp_traits::ParaId;
use {
crate::{assignment::ChainNumCollators, mock::*, CoreAllocationConfiguration, Pallet},
sp_runtime::Perbill,
tp_traits::ParaId,
};

fn create_blank_chain_num_collator(id: u32) -> ChainNumCollators {
ChainNumCollators {
Expand Down
2 changes: 1 addition & 1 deletion pallets/inflation-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub mod pallet {

// We only add 1 extra chain to number_of_chains if we are
// in a parachain context with an orchestrator configured.
if let Some(_) = T::GetSelfChainBlockAuthor::get_block_author() {
if T::GetSelfChainBlockAuthor::get_block_author().is_some() {
number_of_chains = number_of_chains.saturating_add(1u32.into());
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/initializer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<T: Config> Pallet<T> {

// Allow to trigger `on_new_session` in tests, this is needed as long as `pallet_session` is not
// implemented in mock.
#[cfg(any(test, feature = "runtime-benchmarks"))]
#[cfg(test)]
pub(crate) fn test_trigger_on_new_session<'a, I>(
changed: bool,
session_index: T::SessionIndex,
Expand Down
2 changes: 0 additions & 2 deletions pallets/invulnerables/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

//! Benchmarking setup for pallet-invulnerables

#![cfg(feature = "runtime-benchmarks")]

use super::*;

#[allow(unused)]
Expand Down
7 changes: 2 additions & 5 deletions pallets/pooled-staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>

#![cfg(feature = "runtime-benchmarks")]

use {super::*, crate::Pallet as PooledStaking};

use {
super::*,
crate::{
pools::Pool,
traits::{IsCandidateEligible, Timer},
HoldReason,
HoldReason, Pallet as PooledStaking,
PendingOperationKey::{JoiningAutoCompounding, JoiningManualRewards},
},
frame_benchmarking::{account, v2::*, BenchmarkError},
Expand Down
3 changes: 1 addition & 2 deletions pallets/pooled-staking/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>

use parity_scale_codec::MaxEncodedLen;
use {
core::{fmt::Debug, marker::PhantomData},
frame_system::pallet_prelude::BlockNumberFor,
parity_scale_codec::FullCodec,
parity_scale_codec::{FullCodec, MaxEncodedLen},
scale_info::TypeInfo,
sp_runtime::traits::{CheckedAdd, Get},
};
Expand Down
4 changes: 2 additions & 2 deletions pallets/registrar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ pub mod pallet {
//
// We only downgrade if the paraId is a parachain in the context of
// this pallet.
if let None = ParathreadParams::<T>::get(para_id) {
if ParathreadParams::<T>::get(para_id).is_none() {
T::InnerRegistrar::schedule_para_downgrade(para_id)?;
}

Expand Down Expand Up @@ -977,7 +977,7 @@ pub mod pallet {
//
// We only upgrade if the paraId is a parachain in the context of
// this pallet.
if let None = ParathreadParams::<T>::get(para_id) {
if ParathreadParams::<T>::get(para_id).is_none() {
T::InnerRegistrar::schedule_para_upgrade(para_id)?;
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#[cfg(feature = "try-runtime")]
use frame_support::ensure;
use sp_runtime::Perbill;
use {
cumulus_primitives_core::ParaId,
frame_support::{
Expand All @@ -54,6 +53,7 @@ use {
pallet_migrations::{GetMigrations, Migration},
pallet_registrar::HoldReason,
sp_core::Get,
sp_runtime::Perbill,
sp_std::{collections::btree_set::BTreeSet, marker::PhantomData, prelude::*},
};

Expand Down
Loading
Loading