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 version and apply new clippy suggestions #1345

Merged
merged 1 commit into from
Apr 3, 2023
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 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-01-15
ARG RUSTC_VERSION=nightly-2023-04-02
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-01-15
ARG RUSTC_VERSION=nightly-2023-04-02
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-01-15
ARG RUSTC_VERSION=nightly-2023-04-02
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-01-15
ARG RUSTC_VERSION=nightly-2023-04-02
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-01-15
ARG RUSTC_VERSION=nightly-2023-04-02
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-01-15
ARG RUSTC_VERSION=nightly-2023-04-02
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-01-15
ARG RUSTC_VERSION=nightly-2023-04-02
ARG PROFILE=production
ARG RUSTFLAGS
# Workaround for https://github.com/rust-lang/cargo/issues/10583
Expand Down
4 changes: 1 addition & 3 deletions crates/subspace-service/src/dsn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use sc_client_api::AuxStore;
use sc_consensus_subspace::ArchivedSegmentNotification;
use sc_consensus_subspace_rpc::SegmentHeaderProvider;
use sp_core::traits::SpawnNamed;
use sp_runtime::traits::Block as BlockT;
use std::num::NonZeroUsize;
use std::path::PathBuf;
use std::sync::Arc;
Expand Down Expand Up @@ -88,13 +87,12 @@ pub struct DsnConfig {
type DsnProviderStorage<AS> =
NodeProviderStorage<PieceCache<AS>, Either<ParityDbProviderStorage, MemoryProviderStorage>>;

pub(crate) fn create_dsn_instance<Block, AS>(
pub(crate) fn create_dsn_instance<AS>(
dsn_config: DsnConfig,
piece_cache: PieceCache<AS>,
segment_header_cache: SegmentHeaderCache<AS>,
) -> Result<(Node, NodeRunner<DsnProviderStorage<AS>>), DsnConfigurationError>
where
Block: BlockT,
AS: AuxStore + Sync + Send + 'static,
{
trace!("Subspace networking starting.");
Expand Down
7 changes: 2 additions & 5 deletions crates/subspace-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,8 @@ where
}
});

let (node, mut node_runner) = create_dsn_instance::<Block, _>(
config.clone(),
piece_cache,
segment_header_cache.clone(),
)?;
let (node, mut node_runner) =
create_dsn_instance(config.clone(), piece_cache, segment_header_cache.clone())?;

info!("Subspace networking initialized: Node ID is {}", node.id());

Expand Down
12 changes: 4 additions & 8 deletions domains/client/domain-executor/src/domain_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,9 @@ pub(crate) async fn handle_block_import_notifications<
Box::pin(async move {
while let Some(maybe_block_info) = block_info_receiver.next().await {
if let Some(block_info) = maybe_block_info {
if let Err(error) = block_imported::<Block, PBlock, _>(
&processor,
&mut active_leaves,
block_info,
)
.await
if let Err(error) =
block_imported::<PBlock, _>(&processor, &mut active_leaves, block_info)
.await
{
tracing::error!(?error, "Failed to process primary block");
// Bring down the service as bundles processor is an essential task.
Expand Down Expand Up @@ -225,13 +222,12 @@ where
Ok(())
}

async fn block_imported<Block, PBlock, ProcessorFn>(
async fn block_imported<PBlock, ProcessorFn>(
processor: &ProcessorFn,
active_leaves: &mut HashMap<PBlock::Hash, NumberFor<PBlock>>,
block_info: BlockInfo<PBlock>,
) -> Result<(), ApiError>
where
Block: BlockT,
PBlock: BlockT,
ProcessorFn: Fn(
(PBlock::Hash, NumberFor<PBlock>),
Expand Down
6 changes: 3 additions & 3 deletions domains/pallets/messenger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ mod pallet {

type Tag = (DomainId, ChannelId, Nonce);

fn unsigned_validity<T: Config>(prefix: &'static str, provides: Tag) -> TransactionValidity {
fn unsigned_validity(prefix: &'static str, provides: Tag) -> TransactionValidity {
ValidTransaction::with_tag_prefix(prefix)
.priority(TransactionPriority::MAX)
.and_provides(provides)
Expand Down Expand Up @@ -381,12 +381,12 @@ mod pallet {
should_init_channel: _,
} = Self::do_validate_relay_message(xdm)?;
let provides_tag = (msg.dst_domain_id, msg.channel_id, msg.nonce);
unsigned_validity::<T>("MessengerInbox", provides_tag)
unsigned_validity("MessengerInbox", provides_tag)
}
Call::relay_message_response { msg: xdm } => {
let msg = Self::do_validate_relay_message_response(xdm)?;
let provides_tag = (msg.dst_domain_id, msg.channel_id, msg.nonce);
unsigned_validity::<T>("MessengerOutboxResponse", provides_tag)
unsigned_validity("MessengerOutboxResponse", provides_tag)
}
_ => InvalidTransaction::Call.into(),
}
Expand Down
20 changes: 10 additions & 10 deletions domains/pallets/messenger/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,10 @@ fn initiate_transfer_on_domain(domain_a_ext: &mut TestExternalities) {
+ fee_model.outbox_fee.compute_fee
+ fee_model.outbox_fee.relayer_pool_fee;

assert_eq!(domain_a::Balances::free_balance(&account_id), 500 - fees);
assert_eq!(domain_a::Balances::free_balance(account_id), 500 - fees);
// source domain take 2 fees and dst_domain takes 2
assert_eq!(
domain_a::Balances::free_balance(&domain_a::Messenger::messenger_account_id()),
domain_a::Balances::free_balance(domain_a::Messenger::messenger_account_id()),
fee_model.outbox_fee.compute_fee + fee_model.outbox_fee.relayer_pool_fee
);
assert!(domain_a::Transporter::outgoing_transfers(
Expand Down Expand Up @@ -745,9 +745,9 @@ fn verify_transfer_on_domain(
nonce: U256::one(),
},
));
assert_eq!(domain_a::Balances::free_balance(&account_id), 496);
assert_eq!(domain_a::Balances::free_balance(account_id), 496);
assert_eq!(
domain_a::Balances::free_balance(&domain_a::Messenger::messenger_account_id()),
domain_a::Balances::free_balance(domain_a::Messenger::messenger_account_id()),
1
);
let relayer_a_balance = domain_a::Balances::free_balance(domain_a::RELAYER_ID);
Expand Down Expand Up @@ -777,9 +777,9 @@ fn verify_transfer_on_domain(
relayer_id: domain_b::RELAYER_ID,
},
));
assert_eq!(domain_b::Balances::free_balance(&account_id), 1500);
assert_eq!(domain_b::Balances::free_balance(account_id), 1500);
assert_eq!(
domain_b::Balances::free_balance(&domain_b::Messenger::messenger_account_id()),
domain_b::Balances::free_balance(domain_b::Messenger::messenger_account_id()),
1
);
let relayer_b_balance = domain_b::Balances::free_balance(domain_b::RELAYER_ID);
Expand Down Expand Up @@ -909,7 +909,7 @@ fn test_join_relayer_set() {
let relayer_id = 100;

domain_a_test_ext.execute_with(|| {
assert_eq!(domain_a::Balances::free_balance(&account_id), 1000);
assert_eq!(domain_a::Balances::free_balance(account_id), 1000);
let res = domain_a::Messenger::join_relayer_set(
domain_a::RuntimeOrigin::signed(account_id),
relayer_id,
Expand All @@ -922,7 +922,7 @@ fn test_join_relayer_set() {
deposit_reserved: RelayerDeposit::get(),
}
);
assert_eq!(domain_a::Balances::free_balance(&account_id), 500);
assert_eq!(domain_a::Balances::free_balance(account_id), 500);

// cannot rejoin again
let res = domain_a::Messenger::join_relayer_set(
Expand Down Expand Up @@ -959,7 +959,7 @@ fn test_exit_relayer_set() {

domain_a_test_ext.execute_with(|| {
domain_a::Balances::make_free_balance_be(&account_id, 2000);
assert_eq!(domain_a::Balances::free_balance(&account_id), 2000);
assert_eq!(domain_a::Balances::free_balance(account_id), 2000);
for relayer in [relayer_id_1, relayer_id_2, relayer_id_3] {
let res = domain_a::Messenger::join_relayer_set(
domain_a::RuntimeOrigin::signed(account_id),
Expand All @@ -974,7 +974,7 @@ fn test_exit_relayer_set() {
}
);
}
assert_eq!(domain_a::Balances::free_balance(&account_id), 500);
assert_eq!(domain_a::Balances::free_balance(account_id), 500);

let assigned_relayer_id = domain_a::Messenger::next_relayer().unwrap();
assert_eq!(assigned_relayer_id, RELAYER_ID);
Expand Down
22 changes: 11 additions & 11 deletions domains/pallets/transporter/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::marker::PhantomData;
fn test_initiate_transfer_failed() {
new_test_ext().execute_with(|| {
let account = 100;
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 0);

// transfer 500 to dst_domain id 100
Expand All @@ -34,7 +34,7 @@ fn test_initiate_transfer_failed() {
fn test_initiate_transfer() {
new_test_ext().execute_with(|| {
let account = USER_ACCOUNT;
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 1000);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 1000);
Expand All @@ -47,7 +47,7 @@ fn test_initiate_transfer() {
};
let res = Transporter::transfer(RuntimeOrigin::signed(account), dst_location, 500);
assert_ok!(res);
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 500);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 500);
Expand Down Expand Up @@ -179,7 +179,7 @@ fn test_transfer_response_revert() {
let dst_domain_id: DomainId = 1.into();

// check pre dispatch balances
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 1000);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 1000);
Expand All @@ -188,7 +188,7 @@ fn test_transfer_response_revert() {
initiate_transfer(dst_domain_id, account, amount);

// check post init
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 500);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 500);
Expand All @@ -214,7 +214,7 @@ fn test_transfer_response_revert() {
assert_ok!(res);

// balance changes should be reverted.
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 1000);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 1000);
Expand All @@ -237,7 +237,7 @@ fn test_transfer_response_successful() {
let dst_domain_id: DomainId = 1.into();

// check pre dispatch balances
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 1000);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 1000);
Expand All @@ -246,7 +246,7 @@ fn test_transfer_response_successful() {
initiate_transfer(dst_domain_id, account, amount);

// check post init
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 500);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 500);
Expand All @@ -268,7 +268,7 @@ fn test_transfer_response_successful() {
assert_ok!(res);

// balance changes should be as is.
let balance = Balances::free_balance(&account);
let balance = Balances::free_balance(account);
assert_eq!(balance, 500);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 500);
Expand All @@ -291,7 +291,7 @@ fn test_receive_incoming_transfer() {
let dst_domain_id: DomainId = 1.into();

// check pre dispatch balances
let balance = Balances::free_balance(&receiver);
let balance = Balances::free_balance(receiver);
assert_eq!(balance, 0);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 1000);
Expand All @@ -312,7 +312,7 @@ fn test_receive_incoming_transfer() {
.encode(),
);
assert_ok!(resp);
let balance = Balances::free_balance(&receiver);
let balance = Balances::free_balance(receiver);
assert_eq!(balance, 500);
let total_balance = Balances::total_issuance();
assert_eq!(total_balance, 1500);
Expand Down
Loading