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

Remove most all usage of sp-std #5010

Merged
merged 13 commits into from
Jul 15, 2024
  •  
  •  
  •  
161 changes: 0 additions & 161 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion cumulus/client/parachain-inherent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ sp-crypto-hashing = { workspace = true, default-features = true }
sp-inherents = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
sp-state-machine = { workspace = true, default-features = true }
sp-std = { workspace = true, default-features = true }
sp-storage = { workspace = true, default-features = true }
sp-trie = { workspace = true, default-features = true }

Expand Down
4 changes: 2 additions & 2 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use std::{pin::Pin, sync::Arc, time::Duration};
use std::{collections::btree_map::BTreeMap, pin::Pin, sync::Arc, time::Duration};

use async_trait::async_trait;
use cumulus_primitives_core::{
Expand All @@ -38,7 +38,7 @@ use sc_client_api::{
use sc_telemetry::TelemetryWorkerHandle;
use sp_api::ProvideRuntimeApi;
use sp_consensus::SyncOracle;
use sp_core::{sp_std::collections::btree_map::BTreeMap, Pair};
use sp_core::Pair;
use sp_state_machine::{Backend as StateBackend, StorageValue};

/// The timeout in seconds after that the waiting for a block should be aborted.
Expand Down
3 changes: 1 addition & 2 deletions cumulus/client/relay-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ use futures::{FutureExt, Stream, StreamExt};
use polkadot_overseer::Handle;

use sc_client_api::StorageProof;
use sp_core::sp_std::collections::btree_map::BTreeMap;
use sp_state_machine::StorageValue;
use sp_storage::StorageKey;
use sp_version::RuntimeVersion;
use std::pin::Pin;
use std::{collections::btree_map::BTreeMap, pin::Pin};

use cumulus_primitives_core::relay_chain::BlockId;
pub use url::Url;
Expand Down
3 changes: 1 addition & 2 deletions cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use jsonrpsee::{
};
use serde::de::DeserializeOwned;
use serde_json::Value as JsonValue;
use std::collections::VecDeque;
use std::collections::{btree_map::BTreeMap, VecDeque};
use tokio::sync::mpsc::Sender as TokioSender;

use codec::{Decode, Encode};
Expand All @@ -47,7 +47,6 @@ use sc_client_api::StorageData;
use sc_rpc_api::{state::ReadProof, system::Health};
use sc_service::TaskManager;
use sp_consensus_babe::Epoch;
use sp_core::sp_std::collections::btree_map::BTreeMap;
use sp_storage::StorageKey;
use sp_version::RuntimeVersion;

Expand Down
2 changes: 0 additions & 2 deletions cumulus/pallets/aura-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pallet-timestamp = { workspace = true }
sp-application-crypto = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

# Cumulus
cumulus-pallet-parachain-system = { workspace = true }
Expand All @@ -44,7 +43,6 @@ std = [
"sp-application-crypto/std",
"sp-consensus-aura/std",
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"cumulus-pallet-parachain-system/try-runtime",
Expand Down
4 changes: 2 additions & 2 deletions cumulus/pallets/aura-ext/src/consensus_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use cumulus_pallet_parachain_system::{
};
use frame_support::pallet_prelude::*;
use sp_consensus_aura::{Slot, SlotDuration};
use sp_std::{marker::PhantomData, num::NonZeroU32};
use core::{marker::PhantomData, num::NonZeroU32};

/// A consensus hook for a fixed block processing velocity and unincluded segment capacity.
///
Expand Down Expand Up @@ -84,7 +84,7 @@ where

(
weight,
NonZeroU32::new(sp_std::cmp::max(C, 1))
NonZeroU32::new(core::cmp::max(C, 1))
.expect("1 is the minimum value and non-zero; qed")
.into(),
)
Expand Down
4 changes: 2 additions & 2 deletions cumulus/pallets/aura-ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub mod pallet {
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
#[serde(skip)]
pub _config: sp_std::marker::PhantomData<T>,
pub _config: core::marker::PhantomData<T>,
}

#[pallet::genesis_build]
Expand All @@ -125,7 +125,7 @@ pub mod pallet {
///
/// When executing the block it will verify the block seal to ensure that the correct author created
/// the block.
pub struct BlockExecutor<T, I>(sp_std::marker::PhantomData<(T, I)>);
pub struct BlockExecutor<T, I>(core::marker::PhantomData<(T, I)>);

impl<Block, T, I> ExecuteBlock<Block> for BlockExecutor<T, I>
where
Expand Down
2 changes: 0 additions & 2 deletions cumulus/pallets/collator-selection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ codec = { features = ["derive"], workspace = true }
rand = { features = ["std_rng"], workspace = true }
scale-info = { features = ["derive"], workspace = true }

sp-std = { workspace = true }
sp-runtime = { workspace = true }
sp-staking = { workspace = true }
frame-support = { workspace = true }
Expand Down Expand Up @@ -65,7 +64,6 @@ std = [
"scale-info/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
]

try-runtime = [
Expand Down
3 changes: 2 additions & 1 deletion cumulus/pallets/collator-selection/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ use frame_support::traits::{Currency, EnsureOrigin, Get, ReservableCurrency};
use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, RawOrigin};
use pallet_authorship::EventHandler;
use pallet_session::{self as session, SessionManager};
use sp_std::{cmp, prelude::*};
use core::cmp;
use alloc::vec::Vec;

pub type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
Expand Down
6 changes: 4 additions & 2 deletions cumulus/pallets/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@

#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

use core::marker::PhantomData;
use frame_support::traits::TypedGet;
pub use pallet::*;
Expand Down Expand Up @@ -118,7 +120,7 @@ pub mod pallet {
RuntimeDebug,
};
use sp_staking::SessionIndex;
use sp_std::vec::Vec;
use alloc::vec::Vec;

/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
Expand Down Expand Up @@ -244,7 +246,7 @@ pub mod pallet {
let duplicate_invulnerables = self
.invulnerables
.iter()
.collect::<sp_std::collections::btree_set::BTreeSet<_>>();
.collect::<alloc::collections::btree_set::BTreeSet<_>>();
assert!(
duplicate_invulnerables.len() == self.invulnerables.len(),
"duplicate invulnerables in genesis."
Expand Down
8 changes: 3 additions & 5 deletions cumulus/pallets/collator-selection/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub mod v2 {
};
use sp_runtime::traits::{Saturating, Zero};
#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;
use alloc::vec::Vec;

/// [`UncheckedMigrationToV2`] wrapped in a
/// [`VersionedMigration`](frame_support::migrations::VersionedMigration), ensuring the
Expand All @@ -51,7 +51,7 @@ pub mod v2 {
>;

/// Migrate to V2.
pub struct UncheckedMigrationToV2<T>(sp_std::marker::PhantomData<T>);
pub struct UncheckedMigrationToV2<T>(PhantomData<T>);
impl<T: Config + pallet_balances::Config> UncheckedOnRuntimeUpgrade for UncheckedMigrationToV2<T> {
fn on_runtime_upgrade() -> Weight {
let mut weight = Weight::zero();
Expand Down Expand Up @@ -123,10 +123,8 @@ pub mod v2 {
pub mod v1 {
use super::*;
use frame_support::pallet_prelude::*;
#[cfg(feature = "try-runtime")]
use sp_std::prelude::*;

pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
pub struct MigrateToV1<T>(PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/collator-selection/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use frame_support::{
traits::Get,
weights::{constants::RocksDbWeight, Weight},
};
use sp_std::marker::PhantomData;
use core::marker::PhantomData;

// The weight info trait for `pallet_collator_selection`.
pub trait WeightInfo {
Expand Down
2 changes: 0 additions & 2 deletions cumulus/pallets/dmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ scale-info = { features = ["derive"], workspace = true }
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-std = { workspace = true }
sp-runtime = { workspace = true }
sp-io = { workspace = true }

Expand All @@ -48,7 +47,6 @@ std = [
"scale-info/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"xcm/std",
]

Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/dmp-queue/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::*;

use frame_benchmarking::v2::*;
use frame_support::{pallet_prelude::*, traits::Hooks};
use sp_std::vec;
use alloc::vec;

#[benchmarks]
mod benchmarks {
Expand Down
2 changes: 2 additions & 0 deletions cumulus/pallets/dmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(deprecated)] // The pallet itself is deprecated.

extern crate alloc;

use migration::*;
pub use pallet::*;

Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/dmp-queue/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use crate::*;
use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
use frame_support::{pallet_prelude::*, storage_alias, traits::HandleMessage};
use sp_std::vec::Vec;
use alloc::vec::Vec;

pub(crate) const LOG: &str = "runtime::dmp-queue-export-xcms";

Expand Down
4 changes: 2 additions & 2 deletions cumulus/pallets/parachain-system/proc-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ pub fn register_validate_block(input: proc_macro::TokenStream) -> proc_macro::To
#[no_mangle]
unsafe fn validate_block(arguments: *mut u8, arguments_len: usize) -> u64 {
// We convert the `arguments` into a boxed slice and then into `Bytes`.
let args = #crate_::validate_block::sp_std::boxed::Box::from_raw(
#crate_::validate_block::sp_std::slice::from_raw_parts_mut(
let args = #crate_::validate_block::alloc::boxed::Box::from_raw(
#crate_::validate_block::alloc::slice::from_raw_parts_mut(
Copy link
Member

Choose a reason for hiding this comment

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

It is not wrong, but also not particularly useful to re-export alloc for a macro.

Copy link
Member

Choose a reason for hiding this comment

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

If it is not re-exported here, the other crates would need to write extern crate alloc explicitly? Because the crate is not pulled in otherwise.

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 changed this to re-export only selected types here instead of re-export the whole alloc crate

arguments,
arguments_len,
)
Expand Down
4 changes: 2 additions & 2 deletions cumulus/pallets/parachain-system/src/consensus_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use super::relay_state_snapshot::RelayChainStateProof;
use frame_support::weights::Weight;
use sp_std::num::NonZeroU32;
use core::num::NonZeroU32;

/// The possible capacity of the unincluded segment.
#[derive(Clone)]
Expand Down Expand Up @@ -95,7 +95,7 @@ impl<const N: u32> ConsensusHook for FixedCapacityUnincludedSegment<N> {
fn on_state_proof(_state_proof: &RelayChainStateProof) -> (Weight, UnincludedSegmentCapacity) {
(
Weight::zero(),
NonZeroU32::new(sp_std::cmp::max(N, 1))
NonZeroU32::new(core::cmp::max(N, 1))
.expect("1 is the minimum value and non-zero; qed")
.into(),
)
Expand Down
13 changes: 8 additions & 5 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
//!
//! Users must ensure that they register this pallet as an inherent provider.

extern crate alloc;

use codec::{Decode, Encode};
use cumulus_primitives_core::{
relay_chain, AbridgedHostConfiguration, ChannelInfo, ChannelStatus, CollationInfo,
Expand Down Expand Up @@ -54,7 +56,8 @@ use sp_runtime::{
},
BoundedSlice, FixedU128, RuntimeDebug, Saturating,
};
use sp_std::{cmp, collections::btree_map::BTreeMap, prelude::*};
use core::cmp;
use alloc::{collections::btree_map::BTreeMap, vec, vec::Vec};
use xcm::{latest::XcmHash, VersionedLocation, VersionedXcm};
use xcm_builder::InspectMessageQueues;

Expand Down Expand Up @@ -938,7 +941,7 @@ pub mod pallet {
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
#[serde(skip)]
pub _config: sp_std::marker::PhantomData<T>,
pub _config: core::marker::PhantomData<T>,
}

#[pallet::genesis_build]
Expand Down Expand Up @@ -1530,7 +1533,7 @@ impl<T: Config> Pallet<T> {
}

/// Type that implements `SetCode`.
pub struct ParachainSetCode<T>(sp_std::marker::PhantomData<T>);
pub struct ParachainSetCode<T>(core::marker::PhantomData<T>);
impl<T: Config> frame_system::SetCode<T> for ParachainSetCode<T> {
fn set_code(code: Vec<u8>) -> DispatchResult {
Pallet::<T>::schedule_code_upgrade(code)
Expand Down Expand Up @@ -1645,7 +1648,7 @@ pub trait CheckInherents<Block: BlockT> {

/// Struct that always returns `Ok` on inherents check, needed for backwards-compatibility.
#[doc(hidden)]
pub struct DummyCheckInherents<Block>(sp_std::marker::PhantomData<Block>);
pub struct DummyCheckInherents<Block>(core::marker::PhantomData<Block>);

#[allow(deprecated)]
impl<Block: BlockT> CheckInherents<Block> for DummyCheckInherents<Block> {
Expand Down Expand Up @@ -1718,7 +1721,7 @@ pub type RelaychainBlockNumberProvider<T> = RelaychainDataProvider<T>;
/// of [`RelayChainState`].
/// - [`current_block_number`](Self::current_block_number): Will return
/// [`Pallet::last_relay_block_number()`].
pub struct RelaychainDataProvider<T>(sp_std::marker::PhantomData<T>);
pub struct RelaychainDataProvider<T>(core::marker::PhantomData<T>);

impl<T: Config> BlockNumberProvider for RelaychainDataProvider<T> {
type BlockNumber = relay_chain::BlockNumber;
Expand Down
3 changes: 2 additions & 1 deletion cumulus/pallets/parachain-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ use frame_support::{
};
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use sp_runtime::{traits::BlakeTwo256, BuildStorage};
use sp_std::{collections::vec_deque::VecDeque, num::NonZeroU32};
use core::num::NonZeroU32;
use alloc::collections::vec_deque::VecDeque;
use sp_version::RuntimeVersion;
use std::cell::RefCell;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use cumulus_primitives_core::{
use scale_info::TypeInfo;
use sp_runtime::traits::HashingFor;
use sp_state_machine::{Backend, TrieBackend, TrieBackendBuilder};
use sp_std::vec::Vec;
use alloc::vec::Vec;
use sp_trie::{HashDBT, MemoryDB, StorageProof, EMPTY_PREFIX};

/// The capacity of the upward message queue of a parachain on the relay chain.
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use hex_literal::hex;
use rand::Rng;
use relay_chain::HrmpChannelId;
use sp_core::H256;
use sp_std::num::NonZeroU32;
use alloc::num::NonZeroU32;

#[test]
#[should_panic]
Expand Down
4 changes: 3 additions & 1 deletion cumulus/pallets/parachain-system/src/unincluded_segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use codec::{Decode, Encode};
use cumulus_primitives_core::{relay_chain, ParaId};
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;
use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData};
use alloc::collections::btree_map::BTreeMap;
use core::marker::PhantomData;

/// Constraints on outbound HRMP channel.
#[derive(Clone, RuntimeDebug)]
Expand Down Expand Up @@ -399,6 +400,7 @@ pub(crate) fn size_after_included<H: PartialEq>(included_hash: H, segment: &[Anc
mod tests {
use super::*;
use assert_matches::assert_matches;
use alloc::{vec, vec::Vec};

#[test]
fn outbound_limits_constructed_correctly() {
Expand Down
Loading