Skip to content

chore: update rust toolchain, migrate to 2024 edition #3535

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

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[workspace.package]
edition = "2024"

[workspace]
resolver = "2"
members = [
Expand Down
2 changes: 1 addition & 1 deletion crates/pallet-domains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "pallet-domains"
version = "0.1.0"
authors = ["Subspace Labs <https://subspace.network>"]
edition = "2021"
edition.workspace = true
license = "0BSD"
homepage = "https://subspace.network"
repository = "https://github.com/autonomys/subspace"
Expand Down
22 changes: 11 additions & 11 deletions crates/pallet-domains/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,49 @@
extern crate alloc;

use super::*;
use crate::block_tree::{prune_receipt, BlockTreeNode};
use crate::block_tree::{BlockTreeNode, prune_receipt};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like rustfmt changes the type/function ordering in use between editions. I wonder if this would be better done in a separate PR?

reorder_imports = false might keep things the way they are in this PR.
https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#reorder_imports

This is not a blocker for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this as part of the version migration, so I’ve moved it into a separate commit. I hope that makes it easier for you to review.

use crate::bundle_storage_fund::refund_storage_fee;
use crate::domain_registry::{into_domain_config, DomainConfigParams};
use crate::domain_registry::{DomainConfigParams, into_domain_config};
use crate::runtime_registry::DomainRuntimeUpgradeEntry;
use crate::staking::{
do_convert_previous_epoch_withdrawal, do_mark_operators_as_slashed, do_reward_operators,
Error as StakingError, OperatorConfig, OperatorStatus, WithdrawStake,
do_convert_previous_epoch_withdrawal, do_mark_operators_as_slashed, do_reward_operators,
};
use crate::staking_epoch::{
do_finalize_domain_current_epoch, do_finalize_domain_epoch_staking, do_slash_operator,
operator_take_reward_tax_and_stake,
};
use crate::{
DomainBlockNumberFor, ExecutionReceiptOf, Pallet as Domains, RawOrigin as DomainOrigin,
MAX_NOMINATORS_TO_SLASH,
DomainBlockNumberFor, ExecutionReceiptOf, MAX_NOMINATORS_TO_SLASH, Pallet as Domains,
RawOrigin as DomainOrigin,
};
#[cfg(not(feature = "std"))]
use alloc::borrow::ToOwned;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use frame_benchmarking::v2::*;
use frame_support::assert_ok;
use frame_support::traits::fungible::{Inspect, Mutate};
use frame_support::traits::Hooks;
use frame_support::traits::fungible::{Inspect, Mutate};
use frame_system::{Pallet as System, RawOrigin};
use hex_literal::hex;
use pallet_subspace::BlockRandomness;
use sp_consensus_slots::Slot;
use sp_core::H256;
use sp_core::crypto::{Ss58Codec, UncheckedFrom};
use sp_core::sr25519::vrf::{VrfPreOutput, VrfProof, VrfSignature};
use sp_core::H256;
use sp_domains::merkle_tree::MerkleTree;
use sp_domains::{
dummy_opaque_bundle, BundleHeader, DomainId, ExecutionReceipt, OpaqueBundle, OperatorAllowList,
OperatorId, OperatorPublicKey, OperatorRewardSource, OperatorSignature,
BundleHeader, DomainId, EMPTY_EXTRINSIC_ROOT, ExecutionReceipt, OpaqueBundle,
OperatorAllowList, OperatorId, OperatorPublicKey, OperatorRewardSource, OperatorSignature,
PermissionedActionAllowedBy, ProofOfElection, RuntimeType, SealedBundleHeader,
SealedSingletonReceipt, SingletonReceipt, EMPTY_EXTRINSIC_ROOT,
SealedSingletonReceipt, SingletonReceipt, dummy_opaque_bundle,
};
use sp_domains_fraud_proof::fraud_proof::FraudProof;
use sp_runtime::traits::{CheckedAdd, One, Zero};
use sp_std::collections::btree_set::BTreeSet;
use subspace_core_primitives::pot::PotOutput;
use subspace_core_primitives::Randomness;
use subspace_core_primitives::pot::PotOutput;

const SEED: u32 = 0;
const MAX_NOMINATORS_TO_SLASH_WITHOUT_OPERATOR: u32 = MAX_NOMINATORS_TO_SLASH - 1;
Expand Down
30 changes: 16 additions & 14 deletions crates/pallet-domains/src/block_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use frame_support::{ensure, PalletError};
use frame_support::{PalletError, ensure};
use frame_system::pallet_prelude::BlockNumberFor;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
Expand Down Expand Up @@ -629,9 +629,10 @@ pub(crate) fn prune_receipt<T: Config>(
mod tests {
use super::*;
use crate::tests::{
create_dummy_bundle_with_receipts, create_dummy_receipt, extend_block_tree,
extend_block_tree_from_zero, get_block_tree_node_at, new_test_ext_with_extensions,
register_genesis_domain, run_to_block, BlockTreePruningDepth, Domains, Test,
BlockTreePruningDepth, Domains, Test, create_dummy_bundle_with_receipts,
create_dummy_receipt, extend_block_tree, extend_block_tree_from_zero,
get_block_tree_node_at, new_test_ext_with_extensions, register_genesis_domain,
run_to_block,
};
use crate::{FrozenDomains, RawOrigin as DomainOrigin};
use frame_support::dispatch::RawOrigin;
Expand Down Expand Up @@ -781,11 +782,10 @@ mod tests {
verify_execution_receipt::<Test>(domain_id, &pruned_receipt),
Error::PrunedReceipt
);
assert!(ConsensusBlockHash::<Test>::get(
domain_id,
pruned_receipt.consensus_block_number,
)
.is_none());
assert!(
ConsensusBlockHash::<Test>::get(domain_id, pruned_receipt.consensus_block_number,)
.is_none()
);
});
}

Expand Down Expand Up @@ -1091,11 +1091,13 @@ mod tests {
let mut invalid_execution_trace_receipt = next_receipt;

// Receipt with only one element in execution trace vector
invalid_execution_trace_receipt.execution_trace = vec![invalid_execution_trace_receipt
.execution_trace
.first()
.cloned()
.expect("First element should be there; qed")];
invalid_execution_trace_receipt.execution_trace = vec![
invalid_execution_trace_receipt
.execution_trace
.first()
.cloned()
.expect("First element should be there; qed"),
];
assert_err!(
verify_execution_receipt::<Test>(domain_id, &invalid_execution_trace_receipt),
Error::InvalidExecutionTrace
Expand Down
6 changes: 3 additions & 3 deletions crates/pallet-domains/src/bundle_storage_fund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
use crate::staking::NewDeposit;
use crate::staking_epoch::mint_into_treasury;
use crate::{BalanceOf, Config, Event, HoldIdentifier, Operators, Pallet};
use frame_support::PalletError;
use frame_support::traits::Get;
use frame_support::traits::fungible::{Inspect, Mutate, MutateHold};
use frame_support::traits::tokens::{Fortitude, Precision, Preservation};
use frame_support::traits::Get;
use frame_support::PalletError;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_domains::OperatorId;
use sp_runtime::traits::{AccountIdConversion, CheckedSub, Zero};
use sp_runtime::Perbill;
use sp_runtime::traits::{AccountIdConversion, CheckedSub, Zero};
use sp_std::collections::btree_map::BTreeMap;
use subspace_runtime_primitives::StorageFee;

Expand Down
18 changes: 9 additions & 9 deletions crates/pallet-domains/src/domain_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::pallet::{DomainStakingSummary, NextEVMChainId};
use crate::runtime_registry::DomainRuntimeInfo;
use crate::staking::StakingSummary;
use crate::{
into_complete_raw_genesis, BalanceOf, Config, DomainHashingFor, DomainRegistry,
DomainSudoCalls, ExecutionReceiptOf, HoldIdentifier, NextDomainId, RuntimeRegistry,
BalanceOf, Config, DomainHashingFor, DomainRegistry, DomainSudoCalls, ExecutionReceiptOf,
HoldIdentifier, NextDomainId, RuntimeRegistry, into_complete_raw_genesis,
};
#[cfg(not(feature = "std"))]
use alloc::string::String;
Expand All @@ -19,18 +19,18 @@ use domain_runtime_primitives::MultiAccountId;
use frame_support::traits::fungible::{Inspect, Mutate, MutateHold};
use frame_support::traits::tokens::{Fortitude, Precision, Preservation};
use frame_support::weights::Weight;
use frame_support::{ensure, PalletError};
use frame_support::{PalletError, ensure};
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_core::Get;
use sp_domains::{
calculate_max_bundle_weight_and_size, derive_domain_block_hash, DomainBundleLimit, DomainId,
DomainRuntimeConfig, DomainSudoCall, DomainsDigestItem, DomainsTransfersTracker,
OnDomainInstantiated, OperatorAllowList, RuntimeId, RuntimeType,
DomainBundleLimit, DomainId, DomainRuntimeConfig, DomainSudoCall, DomainsDigestItem,
DomainsTransfersTracker, OnDomainInstantiated, OperatorAllowList, RuntimeId, RuntimeType,
calculate_max_bundle_weight_and_size, derive_domain_block_hash,
};
use sp_runtime::traits::{CheckedAdd, Zero};
use sp_runtime::DigestItem;
use sp_runtime::traits::{CheckedAdd, Zero};
use sp_std::collections::btree_map::BTreeMap;
use sp_std::collections::btree_set::BTreeSet;

Expand Down Expand Up @@ -384,7 +384,7 @@ pub(crate) fn do_update_domain_allow_list<T: Config>(
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::{new_test_ext, Test, TEST_RUNTIME_APIS};
use crate::tests::{TEST_RUNTIME_APIS, Test, new_test_ext};
use domain_runtime_primitives::{AccountId20, AccountId20Converter};
use frame_support::traits::Currency;
use frame_support::{assert_err, assert_ok};
Expand All @@ -393,7 +393,7 @@ mod tests {
use sp_domains::{EvmDomainRuntimeConfig, EvmType, PermissionedActionAllowedBy, RuntimeObject};
use sp_runtime::traits::Convert;
use sp_std::vec;
use sp_version::{create_apis_vec, RuntimeVersion};
use sp_version::{RuntimeVersion, create_apis_vec};
use subspace_runtime_primitives::SSC;

type Balances = pallet_balances::Pallet<Test>;
Expand Down
2 changes: 1 addition & 1 deletion crates/pallet-domains/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use frame_support::weights::Weight;
use frame_system::pallet_prelude::RuntimeCallFor;
use parity_scale_codec::{Decode, Encode};
use scale_info::prelude::fmt;
use sp_domains_fraud_proof::weights::fraud_proof_verification_weights;
use sp_domains_fraud_proof::InvalidTransactionCode;
use sp_domains_fraud_proof::weights::fraud_proof_verification_weights;
use sp_runtime::impl_tx_ext_default;
use sp_runtime::traits::{
AsSystemOriginSigner, DispatchInfoOf, DispatchOriginOf, Dispatchable, Get, Implication,
Expand Down
Loading
Loading