Skip to content

Commit c65631e

Browse files
committed
chore: update rust toolchain, migrate to 2024 edition
1 parent 5e15f59 commit c65631e

File tree

381 files changed

+1416
-1371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+1416
-1371
lines changed

crates/pallet-domains/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "pallet-domains"
33
version = "0.1.0"
44
authors = ["Subspace Labs <https://subspace.network>"]
5-
edition = "2021"
5+
edition = "2024"
66
license = "0BSD"
77
homepage = "https://subspace.network"
88
repository = "https://github.com/autonomys/subspace"

crates/pallet-domains/src/benchmarking.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
extern crate alloc;
44

55
use super::*;
6-
use crate::block_tree::{prune_receipt, BlockTreeNode};
6+
use crate::block_tree::{BlockTreeNode, prune_receipt};
77
use crate::bundle_storage_fund::refund_storage_fee;
8-
use crate::domain_registry::{into_domain_config, DomainConfigParams};
8+
use crate::domain_registry::{DomainConfigParams, into_domain_config};
99
use crate::staking::{
10-
do_convert_previous_epoch_withdrawal, do_mark_operators_as_slashed, do_reward_operators,
1110
Error as StakingError, OperatorConfig, OperatorStatus, WithdrawStake,
11+
do_convert_previous_epoch_withdrawal, do_mark_operators_as_slashed, do_reward_operators,
1212
};
1313
use crate::staking_epoch::{
1414
do_finalize_domain_current_epoch, do_finalize_domain_epoch_staking, do_slash_operator,
1515
operator_take_reward_tax_and_stake,
1616
};
1717
use crate::{
18-
DomainBlockNumberFor, Pallet as Domains, RawOrigin as DomainOrigin, MAX_NOMINATORS_TO_SLASH,
18+
DomainBlockNumberFor, MAX_NOMINATORS_TO_SLASH, Pallet as Domains, RawOrigin as DomainOrigin,
1919
};
2020
#[cfg(not(feature = "std"))]
2121
use alloc::borrow::ToOwned;
2222
#[cfg(not(feature = "std"))]
2323
use alloc::vec::Vec;
2424
use frame_benchmarking::v2::*;
2525
use frame_support::assert_ok;
26-
use frame_support::traits::fungible::{Inspect, Mutate};
2726
use frame_support::traits::Hooks;
27+
use frame_support::traits::fungible::{Inspect, Mutate};
2828
use frame_system::{Pallet as System, RawOrigin};
2929
use sp_core::crypto::{Ss58Codec, UncheckedFrom};
3030
use sp_domains::{
31-
dummy_opaque_bundle, DomainId, ExecutionReceipt, OperatorAllowList, OperatorId,
32-
OperatorPublicKey, OperatorRewardSource, OperatorSignature, PermissionedActionAllowedBy,
33-
ProofOfElection, RuntimeType, SealedSingletonReceipt, SingletonReceipt,
31+
DomainId, ExecutionReceipt, OperatorAllowList, OperatorId, OperatorPublicKey,
32+
OperatorRewardSource, OperatorSignature, PermissionedActionAllowedBy, ProofOfElection,
33+
RuntimeType, SealedSingletonReceipt, SingletonReceipt, dummy_opaque_bundle,
3434
};
3535
use sp_domains_fraud_proof::fraud_proof::FraudProof;
3636
use sp_runtime::traits::{CheckedAdd, One, Zero};

crates/pallet-domains/src/block_tree.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
};
1313
#[cfg(not(feature = "std"))]
1414
use alloc::vec::Vec;
15-
use frame_support::{ensure, PalletError};
15+
use frame_support::{PalletError, ensure};
1616
use frame_system::pallet_prelude::BlockNumberFor;
1717
use parity_scale_codec::{Decode, Encode};
1818
use scale_info::TypeInfo;
@@ -629,9 +629,10 @@ pub(crate) fn prune_receipt<T: Config>(
629629
mod tests {
630630
use super::*;
631631
use crate::tests::{
632-
create_dummy_bundle_with_receipts, create_dummy_receipt, extend_block_tree,
633-
extend_block_tree_from_zero, get_block_tree_node_at, new_test_ext_with_extensions,
634-
register_genesis_domain, run_to_block, BlockTreePruningDepth, Domains, Test,
632+
BlockTreePruningDepth, Domains, Test, create_dummy_bundle_with_receipts,
633+
create_dummy_receipt, extend_block_tree, extend_block_tree_from_zero,
634+
get_block_tree_node_at, new_test_ext_with_extensions, register_genesis_domain,
635+
run_to_block,
635636
};
636637
use crate::{FrozenDomains, RawOrigin as DomainOrigin};
637638
use frame_support::dispatch::RawOrigin;
@@ -781,11 +782,10 @@ mod tests {
781782
verify_execution_receipt::<Test>(domain_id, &pruned_receipt),
782783
Error::PrunedReceipt
783784
);
784-
assert!(ConsensusBlockHash::<Test>::get(
785-
domain_id,
786-
pruned_receipt.consensus_block_number,
787-
)
788-
.is_none());
785+
assert!(
786+
ConsensusBlockHash::<Test>::get(domain_id, pruned_receipt.consensus_block_number,)
787+
.is_none()
788+
);
789789
});
790790
}
791791

@@ -1091,11 +1091,13 @@ mod tests {
10911091
let mut invalid_execution_trace_receipt = next_receipt;
10921092

10931093
// Receipt with only one element in execution trace vector
1094-
invalid_execution_trace_receipt.execution_trace = vec![invalid_execution_trace_receipt
1095-
.execution_trace
1096-
.first()
1097-
.cloned()
1098-
.expect("First element should be there; qed")];
1094+
invalid_execution_trace_receipt.execution_trace = vec![
1095+
invalid_execution_trace_receipt
1096+
.execution_trace
1097+
.first()
1098+
.cloned()
1099+
.expect("First element should be there; qed"),
1100+
];
10991101
assert_err!(
11001102
verify_execution_receipt::<Test>(domain_id, &invalid_execution_trace_receipt),
11011103
Error::InvalidExecutionTrace

crates/pallet-domains/src/bundle_storage_fund.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
use crate::staking::NewDeposit;
44
use crate::staking_epoch::mint_into_treasury;
55
use crate::{BalanceOf, Config, Event, HoldIdentifier, Operators, Pallet};
6+
use frame_support::PalletError;
7+
use frame_support::traits::Get;
68
use frame_support::traits::fungible::{Inspect, Mutate, MutateHold};
79
use frame_support::traits::tokens::{Fortitude, Precision, Preservation};
8-
use frame_support::traits::Get;
9-
use frame_support::PalletError;
1010
use parity_scale_codec::{Decode, Encode};
1111
use scale_info::TypeInfo;
1212
use sp_domains::OperatorId;
13-
use sp_runtime::traits::{AccountIdConversion, CheckedSub, Zero};
1413
use sp_runtime::Perbill;
14+
use sp_runtime::traits::{AccountIdConversion, CheckedSub, Zero};
1515
use sp_std::collections::btree_map::BTreeMap;
1616
use subspace_runtime_primitives::StorageFee;
1717

crates/pallet-domains/src/domain_registry.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::pallet::{DomainStakingSummary, NextEVMChainId};
88
use crate::runtime_registry::DomainRuntimeInfo;
99
use crate::staking::StakingSummary;
1010
use crate::{
11-
into_complete_raw_genesis, BalanceOf, Config, DomainHashingFor, DomainRegistry,
12-
DomainSudoCalls, ExecutionReceiptOf, HoldIdentifier, NextDomainId, RuntimeRegistry,
11+
BalanceOf, Config, DomainHashingFor, DomainRegistry, DomainSudoCalls, ExecutionReceiptOf,
12+
HoldIdentifier, NextDomainId, RuntimeRegistry, into_complete_raw_genesis,
1313
};
1414
#[cfg(not(feature = "std"))]
1515
use alloc::string::String;
@@ -19,18 +19,18 @@ use domain_runtime_primitives::MultiAccountId;
1919
use frame_support::traits::fungible::{Inspect, Mutate, MutateHold};
2020
use frame_support::traits::tokens::{Fortitude, Precision, Preservation};
2121
use frame_support::weights::Weight;
22-
use frame_support::{ensure, PalletError};
22+
use frame_support::{PalletError, ensure};
2323
use frame_system::pallet_prelude::*;
2424
use parity_scale_codec::{Decode, Encode};
2525
use scale_info::TypeInfo;
2626
use sp_core::Get;
2727
use sp_domains::{
28-
calculate_max_bundle_weight_and_size, derive_domain_block_hash, DomainBundleLimit, DomainId,
29-
DomainRuntimeConfig, DomainSudoCall, DomainsDigestItem, DomainsTransfersTracker,
30-
OnDomainInstantiated, OperatorAllowList, RuntimeId, RuntimeType,
28+
DomainBundleLimit, DomainId, DomainRuntimeConfig, DomainSudoCall, DomainsDigestItem,
29+
DomainsTransfersTracker, OnDomainInstantiated, OperatorAllowList, RuntimeId, RuntimeType,
30+
calculate_max_bundle_weight_and_size, derive_domain_block_hash,
3131
};
32-
use sp_runtime::traits::{CheckedAdd, Zero};
3332
use sp_runtime::DigestItem;
33+
use sp_runtime::traits::{CheckedAdd, Zero};
3434
use sp_std::collections::btree_map::BTreeMap;
3535
use sp_std::collections::btree_set::BTreeSet;
3636

@@ -384,7 +384,7 @@ pub(crate) fn do_update_domain_allow_list<T: Config>(
384384
#[cfg(test)]
385385
mod tests {
386386
use super::*;
387-
use crate::tests::{new_test_ext, Test};
387+
use crate::tests::{Test, new_test_ext};
388388
use domain_runtime_primitives::{AccountId20, AccountId20Converter};
389389
use frame_support::traits::Currency;
390390
use frame_support::{assert_err, assert_ok};

crates/pallet-domains/src/lib.rs

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Pallet Domains
22
33
#![cfg_attr(not(feature = "std"), no_std)]
4-
#![feature(array_windows, let_chains, variant_count)]
4+
#![feature(array_windows, variant_count)]
55

66
#[cfg(feature = "runtime-benchmarks")]
77
mod benchmarking;
@@ -21,13 +21,13 @@ pub mod weights;
2121

2222
extern crate alloc;
2323

24-
use crate::block_tree::{verify_execution_receipt, Error as BlockTreeError};
24+
use crate::block_tree::{Error as BlockTreeError, verify_execution_receipt};
2525
use crate::bundle_storage_fund::{charge_bundle_storage_fee, storage_fund_account};
2626
use crate::domain_registry::{DomainConfig, Error as DomainRegistryError};
2727
use crate::runtime_registry::into_complete_raw_genesis;
2828
#[cfg(feature = "runtime-benchmarks")]
2929
pub use crate::staking::do_register_operator;
30-
use crate::staking::{do_reward_operators, OperatorStatus};
30+
use crate::staking::{OperatorStatus, do_reward_operators};
3131
use crate::staking_epoch::EpochTransitionResult;
3232
use crate::weights::WeightInfo;
3333
#[cfg(not(feature = "std"))]
@@ -48,15 +48,15 @@ use frame_system::pallet_prelude::*;
4848
pub use pallet::*;
4949
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
5050
use scale_info::TypeInfo;
51-
use sp_consensus_subspace::consensus::is_proof_of_time_valid;
5251
use sp_consensus_subspace::WrappedPotOutput;
52+
use sp_consensus_subspace::consensus::is_proof_of_time_valid;
5353
use sp_core::H256;
5454
use sp_domains::bundle_producer_election::BundleProducerElectionParams;
5555
use sp_domains::{
56-
ChainId, DomainBundleLimit, DomainId, DomainInstanceData, ExecutionReceipt, OpaqueBundle,
57-
OperatorId, OperatorPublicKey, OperatorRewardSource, OperatorSignature, ProofOfElection,
58-
RuntimeId, SealedSingletonReceipt, DOMAIN_EXTRINSICS_SHUFFLING_SEED_SUBJECT,
59-
EMPTY_EXTRINSIC_ROOT,
56+
ChainId, DOMAIN_EXTRINSICS_SHUFFLING_SEED_SUBJECT, DomainBundleLimit, DomainId,
57+
DomainInstanceData, EMPTY_EXTRINSIC_ROOT, ExecutionReceipt, OpaqueBundle, OperatorId,
58+
OperatorPublicKey, OperatorRewardSource, OperatorSignature, ProofOfElection, RuntimeId,
59+
SealedSingletonReceipt,
6060
};
6161
use sp_domains_fraud_proof::fraud_proof::{
6262
DomainRuntimeCodeAt, FraudProof, FraudProofVariant, InvalidBlockFeesProof,
@@ -200,45 +200,46 @@ pub(crate) type StateRootOf<T> = <<T as frame_system::Config>::Hashing as Hash>:
200200
#[expect(clippy::useless_conversion, reason = "Macro-generated")]
201201
#[frame_support::pallet]
202202
mod pallet {
203+
#[cfg(not(feature = "runtime-benchmarks"))]
204+
use crate::DomainHashingFor;
205+
#[cfg(not(feature = "runtime-benchmarks"))]
206+
use crate::MAX_NOMINATORS_TO_SLASH;
203207
#[cfg(not(feature = "runtime-benchmarks"))]
204208
use crate::block_tree::AcceptedReceiptType;
205209
use crate::block_tree::{
206-
execution_receipt_type, process_execution_receipt, prune_receipt, Error as BlockTreeError,
207-
ReceiptType,
210+
Error as BlockTreeError, ReceiptType, execution_receipt_type, process_execution_receipt,
211+
prune_receipt,
208212
};
213+
use crate::bundle_storage_fund::Error as BundleStorageFundError;
209214
#[cfg(not(feature = "runtime-benchmarks"))]
210215
use crate::bundle_storage_fund::refund_storage_fee;
211-
use crate::bundle_storage_fund::Error as BundleStorageFundError;
212216
use crate::domain_registry::{
213-
do_instantiate_domain, do_update_domain_allow_list, DomainConfigParams, DomainObject,
214-
Error as DomainRegistryError,
217+
DomainConfigParams, DomainObject, Error as DomainRegistryError, do_instantiate_domain,
218+
do_update_domain_allow_list,
215219
};
216220
use crate::runtime_registry::{
221+
DomainRuntimeUpgradeEntry, Error as RuntimeRegistryError, ScheduledRuntimeUpgrade,
217222
do_register_runtime, do_schedule_runtime_upgrade, do_upgrade_runtimes,
218-
register_runtime_at_genesis, DomainRuntimeUpgradeEntry, Error as RuntimeRegistryError,
219-
ScheduledRuntimeUpgrade,
223+
register_runtime_at_genesis,
220224
};
221225
#[cfg(not(feature = "runtime-benchmarks"))]
222226
use crate::staking::do_reward_operators;
223227
use crate::staking::{
224-
do_deregister_operator, do_mark_operators_as_slashed, do_nominate_operator,
225-
do_register_operator, do_unlock_funds, do_unlock_nominator, do_withdraw_stake, Deposit,
226-
DomainEpoch, Error as StakingError, Operator, OperatorConfig, SharePrice, StakingSummary,
227-
WithdrawStake, Withdrawal,
228+
Deposit, DomainEpoch, Error as StakingError, Operator, OperatorConfig, SharePrice,
229+
StakingSummary, WithdrawStake, Withdrawal, do_deregister_operator,
230+
do_mark_operators_as_slashed, do_nominate_operator, do_register_operator, do_unlock_funds,
231+
do_unlock_nominator, do_withdraw_stake,
228232
};
229233
#[cfg(not(feature = "runtime-benchmarks"))]
230234
use crate::staking_epoch::do_slash_operator;
231-
use crate::staking_epoch::{do_finalize_domain_current_epoch, Error as StakingEpochError};
235+
use crate::staking_epoch::{Error as StakingEpochError, do_finalize_domain_current_epoch};
232236
use crate::storage_proof::InherentExtrinsicData;
233237
use crate::weights::WeightInfo;
234-
#[cfg(not(feature = "runtime-benchmarks"))]
235-
use crate::DomainHashingFor;
236-
#[cfg(not(feature = "runtime-benchmarks"))]
237-
use crate::MAX_NOMINATORS_TO_SLASH;
238238
use crate::{
239239
BalanceOf, BlockSlot, BlockTreeNodeFor, DomainBlockNumberFor, ElectionVerificationParams,
240-
ExecutionReceiptOf, FraudProofFor, HoldIdentifier, NominatorId, OpaqueBundleOf, RawOrigin,
241-
ReceiptHashFor, SingletonReceiptOf, StateRootOf, MAX_BUNDLE_PER_BLOCK, STORAGE_VERSION,
240+
ExecutionReceiptOf, FraudProofFor, HoldIdentifier, MAX_BUNDLE_PER_BLOCK, NominatorId,
241+
OpaqueBundleOf, RawOrigin, ReceiptHashFor, STORAGE_VERSION, SingletonReceiptOf,
242+
StateRootOf,
242243
};
243244
#[cfg(not(feature = "std"))]
244245
use alloc::string::String;
@@ -266,11 +267,11 @@ mod pallet {
266267
use sp_domains_fraud_proof::fraud_proof_runtime_interface::domain_runtime_call;
267268
use sp_domains_fraud_proof::storage_proof::{self, FraudProofStorageKeyProvider};
268269
use sp_domains_fraud_proof::{InvalidTransactionCode, StatelessDomainRuntimeCall};
270+
use sp_runtime::Saturating;
269271
use sp_runtime::traits::{
270272
AtLeast32BitUnsigned, BlockNumberProvider, CheckEqual, CheckedAdd, Header as HeaderT,
271273
MaybeDisplay, One, SimpleBitOps, Zero,
272274
};
273-
use sp_runtime::Saturating;
274275
use sp_std::boxed::Box;
275276
use sp_std::collections::btree_map::BTreeMap;
276277
use sp_std::collections::btree_set::BTreeSet;
@@ -447,11 +448,7 @@ mod pallet {
447448
type MmrHash: Parameter + Member + Default + Clone;
448449

449450
/// MMR proof verifier
450-
type MmrProofVerifier: MmrProofVerifier<
451-
Self::MmrHash,
452-
BlockNumberFor<Self>,
453-
StateRootOf<Self>,
454-
>;
451+
type MmrProofVerifier: MmrProofVerifier<Self::MmrHash, BlockNumberFor<Self>, StateRootOf<Self>>;
455452

456453
/// Fraud proof storage key provider
457454
type FraudProofStorageKeyProvider: FraudProofStorageKeyProvider<BlockNumberFor<Self>>;

crates/pallet-domains/src/runtime_registry.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ use alloc::string::String;
1212
#[cfg(not(feature = "std"))]
1313
use alloc::vec::Vec;
1414
use domain_runtime_primitives::{AccountId20, EVMChainId, MultiAccountId, TryConvertBack};
15-
use frame_support::{ensure, PalletError};
16-
use frame_system::pallet_prelude::*;
15+
use frame_support::{PalletError, ensure};
1716
use frame_system::AccountInfo;
17+
use frame_system::pallet_prelude::*;
1818
use parity_scale_codec::{Decode, Encode};
1919
use scale_info::TypeInfo;
20-
use sp_core::crypto::AccountId32;
2120
use sp_core::Hasher;
21+
use sp_core::crypto::AccountId32;
2222
use sp_domains::storage::{RawGenesis, StorageData, StorageKey};
2323
use sp_domains::{
2424
AutoIdDomainRuntimeConfig, DomainId, DomainRuntimeConfig, DomainsDigestItem,
2525
EvmDomainRuntimeConfig, RuntimeId, RuntimeObject, RuntimeType,
2626
};
27-
use sp_runtime::traits::{CheckedAdd, Zero};
2827
use sp_runtime::DigestItem;
28+
use sp_runtime::traits::{CheckedAdd, Zero};
2929
use sp_std::vec;
3030
use sp_version::RuntimeVersion;
3131

@@ -393,10 +393,10 @@ pub(crate) fn do_upgrade_runtimes<T: Config>(at: BlockNumberFor<T>) {
393393

394394
#[cfg(test)]
395395
mod tests {
396+
use crate::Error;
396397
use crate::pallet::{NextRuntimeId, RuntimeRegistry, ScheduledRuntimeUpgrades};
397398
use crate::runtime_registry::Error as RuntimeRegistryError;
398-
use crate::tests::{new_test_ext, Domains, ReadRuntimeVersion, System, Test};
399-
use crate::Error;
399+
use crate::tests::{Domains, ReadRuntimeVersion, System, Test, new_test_ext};
400400
use frame_support::dispatch::RawOrigin;
401401
use frame_support::traits::OnInitialize;
402402
use frame_support::{assert_err, assert_ok};

0 commit comments

Comments
 (0)