From 291210aa0fafa97d9b924fe82d68c023bdb0a340 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Mon, 15 Jul 2024 18:45:49 +0800 Subject: [PATCH 01/13] Use sp_runtime::traits::BadOrigin (#5011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It says `Will be removed after July 2023` but that's not true šŸ˜ƒ --------- Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Bastian Kƶcher --- .../pallets/collective-content/src/tests.rs | 3 +- .../runtime/common/src/paras_registrar/mod.rs | 6 ++-- .../src/assigner_on_demand/tests.rs | 3 +- polkadot/runtime/parachains/src/hrmp/tests.rs | 3 +- prdoc/pr_5011.prdoc | 29 +++++++++++++++++++ substrate/frame/alliance/src/tests.rs | 3 +- substrate/frame/contracts/src/lib.rs | 3 +- substrate/frame/democracy/src/lib.rs | 3 +- substrate/frame/nomination-pools/src/lib.rs | 2 +- .../frame/ranked-collective/src/tests.rs | 6 ++-- substrate/frame/utility/src/tests.rs | 3 +- 11 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 prdoc/pr_5011.prdoc diff --git a/cumulus/parachains/pallets/collective-content/src/tests.rs b/cumulus/parachains/pallets/collective-content/src/tests.rs index 4910b30b89af8..7fee5eea101db 100644 --- a/cumulus/parachains/pallets/collective-content/src/tests.rs +++ b/cumulus/parachains/pallets/collective-content/src/tests.rs @@ -16,7 +16,8 @@ //! Tests. use super::{mock::*, *}; -use frame_support::{assert_noop, assert_ok, error::BadOrigin, pallet_prelude::Pays}; +use frame_support::{assert_noop, assert_ok, pallet_prelude::Pays}; +use sp_runtime::traits::BadOrigin; /// returns CID hash of 68 bytes of given `i`. fn create_cid(i: u8) -> OpaqueCid { diff --git a/polkadot/runtime/common/src/paras_registrar/mod.rs b/polkadot/runtime/common/src/paras_registrar/mod.rs index 6b9191f7c6f2d..606883b7119b4 100644 --- a/polkadot/runtime/common/src/paras_registrar/mod.rs +++ b/polkadot/runtime/common/src/paras_registrar/mod.rs @@ -718,9 +718,7 @@ mod tests { mock::conclude_pvf_checking, paras_registrar, traits::Registrar as RegistrarTrait, }; use frame_support::{ - assert_noop, assert_ok, derive_impl, - error::BadOrigin, - parameter_types, + assert_noop, assert_ok, derive_impl, parameter_types, traits::{OnFinalize, OnInitialize}, }; use frame_system::limits; @@ -731,7 +729,7 @@ mod tests { use sp_io::TestExternalities; use sp_keyring::Sr25519Keyring; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BadOrigin, BlakeTwo256, IdentityLookup}, transaction_validity::TransactionPriority, BuildStorage, Perbill, }; diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs b/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs index 3d01ba655d3f4..a6074b305b4eb 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs @@ -30,11 +30,12 @@ use crate::{ }, paras::{ParaGenesisArgs, ParaKind}, }; -use frame_support::{assert_noop, assert_ok, error::BadOrigin}; +use frame_support::{assert_noop, assert_ok}; use pallet_balances::Error as BalancesError; use polkadot_primitives::{ BlockNumber, SessionIndex, ValidationCode, ON_DEMAND_MAX_QUEUE_MAX_SIZE, }; +use sp_runtime::traits::BadOrigin; use sp_std::{ cmp::{Ord, Ordering}, collections::btree_map::BTreeMap, diff --git a/polkadot/runtime/parachains/src/hrmp/tests.rs b/polkadot/runtime/parachains/src/hrmp/tests.rs index 4fcbc69e98ad8..52db932c7962b 100644 --- a/polkadot/runtime/parachains/src/hrmp/tests.rs +++ b/polkadot/runtime/parachains/src/hrmp/tests.rs @@ -27,8 +27,9 @@ use crate::{ }, shared, }; -use frame_support::{assert_noop, assert_ok, error::BadOrigin}; +use frame_support::{assert_noop, assert_ok}; use polkadot_primitives::{BlockNumber, InboundDownwardMessage}; +use sp_runtime::traits::BadOrigin; use std::collections::BTreeMap; pub(crate) fn run_to_block(to: BlockNumber, new_session: Option>) { diff --git a/prdoc/pr_5011.prdoc b/prdoc/pr_5011.prdoc new file mode 100644 index 0000000000000..cb827bae6c591 --- /dev/null +++ b/prdoc/pr_5011.prdoc @@ -0,0 +1,29 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "Use `BadOrigin` from `sp_runtime`" + +doc: + - audience: Runtime Dev + description: | + This PR refactor usages of deprecated `frame_support::error::BadOrigin` to `sp_runtime::traits::BadOrigin` + +crates: +- name: pallet-collective-content + bump: patch +- name: polkadot-runtime-common + bump: patch +- name: polkadot-runtime-parachains + bump: patch +- name: pallet-alliance + bump: patch +- name: pallet-contracts + bump: patch +- name: pallet-democracy + bump: patch +- name: pallet-nomination-pools + bump: patch +- name: pallet-ranked-collective + bump: patch +- name: pallet-utility + bump: patch diff --git a/substrate/frame/alliance/src/tests.rs b/substrate/frame/alliance/src/tests.rs index edb515b8115a5..ec31ebf6a47ae 100644 --- a/substrate/frame/alliance/src/tests.rs +++ b/substrate/frame/alliance/src/tests.rs @@ -17,8 +17,9 @@ //! Tests for the alliance pallet. -use frame_support::{assert_noop, assert_ok, error::BadOrigin}; +use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase}; +use sp_runtime::traits::BadOrigin; use super::*; use crate::{self as alliance, mock::*}; diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index 47772e0a5a0bc..33083c7ebe76a 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -119,7 +119,6 @@ use environmental::*; use frame_support::{ dispatch::{GetDispatchInfo, Pays, PostDispatchInfo, RawOrigin, WithPostDispatchInfo}, ensure, - error::BadOrigin, traits::{ fungible::{Inspect, Mutate, MutateHold}, ConstU32, Contains, Get, Randomness, Time, @@ -135,7 +134,7 @@ use frame_system::{ use scale_info::TypeInfo; use smallvec::Array; use sp_runtime::{ - traits::{Convert, Dispatchable, Saturating, StaticLookup, Zero}, + traits::{BadOrigin, Convert, Dispatchable, Saturating, StaticLookup, Zero}, DispatchError, RuntimeDebug, }; use sp_std::{fmt::Debug, prelude::*}; diff --git a/substrate/frame/democracy/src/lib.rs b/substrate/frame/democracy/src/lib.rs index 19cdc754659d3..e3b4696f8b2af 100644 --- a/substrate/frame/democracy/src/lib.rs +++ b/substrate/frame/democracy/src/lib.rs @@ -155,7 +155,6 @@ use codec::{Decode, Encode}; use frame_support::{ ensure, - error::BadOrigin, traits::{ defensive_prelude::*, schedule::{v3::Named as ScheduleNamed, DispatchTime}, @@ -166,7 +165,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; use sp_runtime::{ - traits::{Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, + traits::{BadOrigin, Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, DispatchResult, }; use sp_std::prelude::*; diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index 2b5fe8b604121..641f2b1457727 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -2600,7 +2600,7 @@ pub mod pallet { ) -> DispatchResult { let mut bonded_pool = match ensure_root(origin.clone()) { Ok(()) => BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?, - Err(frame_support::error::BadOrigin) => { + Err(sp_runtime::traits::BadOrigin) => { let who = ensure_signed(origin)?; let bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; diff --git a/substrate/frame/ranked-collective/src/tests.rs b/substrate/frame/ranked-collective/src/tests.rs index a7827bcc1aa37..3a85928b76d5e 100644 --- a/substrate/frame/ranked-collective/src/tests.rs +++ b/substrate/frame/ranked-collective/src/tests.rs @@ -20,14 +20,12 @@ use std::collections::BTreeMap; use frame_support::{ - assert_noop, assert_ok, derive_impl, - error::BadOrigin, - parameter_types, + assert_noop, assert_ok, derive_impl, parameter_types, traits::{ConstU16, EitherOf, MapSuccess, Polling}, }; use sp_core::Get; use sp_runtime::{ - traits::{MaybeConvert, ReduceBy, ReplaceWithDefault}, + traits::{BadOrigin, MaybeConvert, ReduceBy, ReplaceWithDefault}, BuildStorage, }; diff --git a/substrate/frame/utility/src/tests.rs b/substrate/frame/utility/src/tests.rs index eb2047aac28af..0a58a92b4c9ea 100644 --- a/substrate/frame/utility/src/tests.rs +++ b/substrate/frame/utility/src/tests.rs @@ -25,14 +25,13 @@ use crate as utility; use frame_support::{ assert_err_ignore_postinfo, assert_noop, assert_ok, derive_impl, dispatch::{DispatchErrorWithPostInfo, Pays}, - error::BadOrigin, parameter_types, storage, traits::{ConstU64, Contains}, weights::Weight, }; use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_runtime::{ - traits::{BlakeTwo256, Dispatchable, Hash}, + traits::{BadOrigin, BlakeTwo256, Dispatchable, Hash}, BuildStorage, DispatchError, TokenError, }; From 7ecf3f757a5d6f622309cea7f788e8a547a5dce8 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Mon, 15 Jul 2024 21:50:25 +0800 Subject: [PATCH 02/13] Remove most all usage of `sp-std` (#5010) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should remove nearly all usage of `sp-std` except: - bridge and bridge-hubs - a few of frames re-export `sp-std`, keep them for now - there is a usage of `sp_std::Writer`, I don't have an idea how to move it Please review proc-macro carefully. I'm not sure I'm doing it the right way. Note: need `/bot fmt` --------- Co-authored-by: Bastian Kƶcher Co-authored-by: command-bot <> --- Cargo.lock | 159 ------------------ cumulus/client/parachain-inherent/Cargo.toml | 1 - .../src/lib.rs | 4 +- .../relay-chain-rpc-interface/src/lib.rs | 3 +- .../src/rpc_client.rs | 3 +- cumulus/pallets/aura-ext/Cargo.toml | 2 - .../pallets/aura-ext/src/consensus_hook.rs | 4 +- cumulus/pallets/aura-ext/src/lib.rs | 4 +- cumulus/pallets/collator-selection/Cargo.toml | 2 - .../collator-selection/src/benchmarking.rs | 3 +- cumulus/pallets/collator-selection/src/lib.rs | 6 +- .../collator-selection/src/migration.rs | 10 +- .../pallets/collator-selection/src/weights.rs | 2 +- cumulus/pallets/dmp-queue/Cargo.toml | 2 - cumulus/pallets/dmp-queue/src/benchmarking.rs | 2 +- cumulus/pallets/dmp-queue/src/lib.rs | 2 + cumulus/pallets/dmp-queue/src/migration.rs | 2 +- .../parachain-system/proc-macro/src/lib.rs | 4 +- .../parachain-system/src/consensus_hook.rs | 4 +- cumulus/pallets/parachain-system/src/lib.rs | 13 +- cumulus/pallets/parachain-system/src/mock.rs | 3 +- .../src/relay_state_snapshot.rs | 2 +- cumulus/pallets/parachain-system/src/tests.rs | 2 +- .../src/unincluded_segment.rs | 4 +- .../src/validate_block/implementation.rs | 8 +- .../src/validate_block/mod.rs | 3 + .../src/validate_block/trie_cache.rs | 6 +- .../src/validate_block/trie_recorder.rs | 4 +- .../pallets/parachain-system/src/weights.rs | 2 +- .../pallets/session-benchmarking/Cargo.toml | 2 - .../pallets/session-benchmarking/src/inner.rs | 2 +- .../pallets/session-benchmarking/src/lib.rs | 2 + cumulus/pallets/solo-to-para/Cargo.toml | 2 - cumulus/pallets/solo-to-para/src/lib.rs | 4 +- cumulus/pallets/xcm/Cargo.toml | 2 - cumulus/pallets/xcm/src/lib.rs | 1 - cumulus/pallets/xcmp-queue/Cargo.toml | 2 - .../pallets/xcmp-queue/src/benchmarking.rs | 1 + cumulus/pallets/xcmp-queue/src/bridging.rs | 4 +- cumulus/pallets/xcmp-queue/src/lib.rs | 4 +- cumulus/pallets/xcmp-queue/src/migration.rs | 1 + .../pallets/xcmp-queue/src/migration/v5.rs | 1 + cumulus/parachains/common/Cargo.toml | 2 - cumulus/parachains/common/src/impls.rs | 3 +- cumulus/parachains/common/src/lib.rs | 2 + .../parachains/common/src/message_queue.rs | 2 +- cumulus/parachains/common/src/xcm_config.rs | 2 +- .../pallets/collective-content/Cargo.toml | 2 - .../pallets/collective-content/src/lib.rs | 1 - .../pallets/parachain-info/Cargo.toml | 2 - .../pallets/parachain-info/src/lib.rs | 2 +- cumulus/parachains/pallets/ping/Cargo.toml | 2 - cumulus/parachains/pallets/ping/src/lib.rs | 4 +- .../assets/asset-hub-rococo/Cargo.toml | 2 - .../assets/asset-hub-rococo/src/lib.rs | 14 +- .../cumulus_pallet_parachain_system.rs | 2 +- .../src/weights/pallet_message_queue.rs | 2 +- .../asset-hub-rococo/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_fungible.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- .../assets/asset-hub-rococo/src/xcm_config.rs | 22 +-- .../assets/asset-hub-rococo/tests/tests.rs | 14 +- .../assets/asset-hub-westend/Cargo.toml | 2 - .../assets/asset-hub-westend/src/lib.rs | 14 +- .../cumulus_pallet_parachain_system.rs | 2 +- .../src/weights/pallet_message_queue.rs | 2 +- .../asset-hub-westend/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_fungible.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- .../asset-hub-westend/src/xcm_config.rs | 12 +- .../assets/asset-hub-westend/tests/tests.rs | 12 +- .../runtimes/assets/common/Cargo.toml | 2 - .../runtimes/assets/common/src/benchmarks.rs | 2 +- .../assets/common/src/foreign_creators.rs | 4 +- .../assets/common/src/fungible_conversion.rs | 3 +- .../runtimes/assets/common/src/lib.rs | 2 + .../common/src/local_and_foreign_assets.rs | 2 +- .../runtimes/assets/common/src/matching.rs | 8 +- .../runtimes/assets/common/src/runtime_api.rs | 2 +- .../runtimes/assets/test-utils/Cargo.toml | 2 - .../src/bridge_to_bulletin_config.rs | 2 +- .../src/bridge_to_westend_config.rs | 6 +- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 10 +- .../cumulus_pallet_parachain_system.rs | 2 +- .../src/weights/pallet_message_queue.rs | 2 +- .../bridge-hub-rococo/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_fungible.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- .../bridge-hub-rococo/src/xcm_config.rs | 2 +- .../src/bridge_to_rococo_config.rs | 6 +- .../bridge-hubs/bridge-hub-westend/src/lib.rs | 12 +- .../cumulus_pallet_parachain_system.rs | 2 +- .../src/weights/pallet_message_queue.rs | 2 +- .../bridge-hub-westend/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_fungible.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- .../runtimes/bridge-hubs/common/Cargo.toml | 2 - .../bridge-hubs/common/src/message_queue.rs | 2 +- .../bridge-hubs/test-utils/Cargo.toml | 2 - .../bridge-hubs/test-utils/src/lib.rs | 2 + .../src/test_cases/from_grandpa_chain.rs | 3 +- .../src/test_cases/from_parachain.rs | 3 +- .../test-utils/src/test_cases/helpers.rs | 4 +- .../collectives-westend/Cargo.toml | 2 - .../collectives-westend/src/impls.rs | 3 +- .../collectives-westend/src/lib.rs | 11 +- .../cumulus_pallet_parachain_system.rs | 2 +- .../src/weights/pallet_message_queue.rs | 2 +- .../contracts/contracts-rococo/Cargo.toml | 2 - .../contracts/contracts-rococo/src/lib.rs | 10 +- .../coretime/coretime-rococo/Cargo.toml | 2 - .../coretime/coretime-rococo/src/lib.rs | 8 +- .../coretime-rococo/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_fungible.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- .../coretime/coretime-westend/Cargo.toml | 2 - .../coretime/coretime-westend/src/lib.rs | 8 +- .../coretime-westend/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_fungible.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- .../glutton/glutton-westend/Cargo.toml | 2 - .../glutton/glutton-westend/src/lib.rs | 8 +- .../runtimes/people/people-rococo/Cargo.toml | 2 - .../runtimes/people/people-rococo/src/lib.rs | 8 +- .../people/people-rococo/src/people.rs | 7 +- .../cumulus_pallet_parachain_system.rs | 2 +- .../src/weights/pallet_message_queue.rs | 2 +- .../people-rococo/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_fungible.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- .../runtimes/people/people-westend/Cargo.toml | 2 - .../runtimes/people/people-westend/src/lib.rs | 8 +- .../people/people-westend/src/people.rs | 3 +- .../cumulus_pallet_parachain_system.rs | 2 +- .../src/weights/pallet_message_queue.rs | 2 +- .../people-westend/src/weights/xcm/mod.rs | 2 +- .../xcm/pallet_xcm_benchmarks_fungible.rs | 2 +- .../xcm/pallet_xcm_benchmarks_generic.rs | 2 +- .../runtimes/starters/seedling/Cargo.toml | 2 - .../runtimes/starters/seedling/src/lib.rs | 6 +- .../runtimes/starters/shell/Cargo.toml | 2 - .../runtimes/starters/shell/src/lib.rs | 8 +- .../parachains/runtimes/test-utils/Cargo.toml | 2 - .../parachains/runtimes/test-utils/src/lib.rs | 2 +- .../runtimes/testing/penpal/Cargo.toml | 2 - .../runtimes/testing/penpal/src/lib.rs | 6 +- .../testing/rococo-parachain/Cargo.toml | 2 - .../testing/rococo-parachain/src/lib.rs | 6 +- .../asset_hub_polkadot_aura.rs | 2 +- .../src/fake_runtime_api/aura.rs | 2 +- cumulus/primitives/aura/Cargo.toml | 2 - cumulus/primitives/core/Cargo.toml | 2 - cumulus/primitives/core/src/lib.rs | 10 +- .../primitives/parachain-inherent/Cargo.toml | 2 - .../primitives/parachain-inherent/src/lib.rs | 4 +- .../storage-weight-reclaim/Cargo.toml | 2 - .../storage-weight-reclaim/src/lib.rs | 4 +- cumulus/primitives/timestamp/Cargo.toml | 2 - cumulus/primitives/timestamp/src/lib.rs | 2 +- cumulus/primitives/utility/Cargo.toml | 2 - cumulus/primitives/utility/src/lib.rs | 7 +- cumulus/templates/xcm-bench-template.hbs | 2 +- cumulus/test/relay-sproof-builder/Cargo.toml | 2 - cumulus/test/relay-sproof-builder/src/lib.rs | 4 +- cumulus/test/runtime/Cargo.toml | 2 - cumulus/test/runtime/src/lib.rs | 7 +- cumulus/test/runtime/src/test_pallet.rs | 4 +- cumulus/xcm/xcm-emulator/src/lib.rs | 5 +- .../chain_spec_runtime/Cargo.toml | 2 - .../chain_spec_runtime/src/lib.rs | 2 + .../chain_spec_runtime/src/pallets.rs | 1 + .../chain_spec_runtime/src/presets.rs | 4 +- .../chain_spec_runtime/src/runtime.rs | 1 + polkadot/core-primitives/Cargo.toml | 2 - polkadot/core-primitives/src/lib.rs | 12 +- polkadot/parachain/Cargo.toml | 2 - polkadot/parachain/src/lib.rs | 2 + polkadot/parachain/src/primitives.rs | 20 +-- polkadot/parachain/src/wasm_api.rs | 2 +- .../test-parachains/adder/Cargo.toml | 3 +- .../test-parachains/adder/src/lib.rs | 2 + .../adder/src/wasm_validation.rs | 8 +- .../test-parachains/undying/Cargo.toml | 2 - .../test-parachains/undying/src/lib.rs | 4 +- .../undying/src/wasm_validation.rs | 4 +- polkadot/primitives/Cargo.toml | 2 - polkadot/primitives/src/lib.rs | 2 + polkadot/primitives/src/runtime_api.rs | 8 +- polkadot/primitives/src/v7/async_backing.rs | 1 + polkadot/primitives/src/v7/executor_params.rs | 31 ++-- polkadot/primitives/src/v7/metrics.rs | 6 +- polkadot/primitives/src/v7/mod.rs | 24 +-- polkadot/primitives/src/v7/signed.rs | 12 +- polkadot/primitives/src/v7/slashing.rs | 2 +- polkadot/primitives/src/vstaging/mod.rs | 1 - polkadot/runtime/common/Cargo.toml | 2 - .../common/slot_range_helper/Cargo.toml | 3 +- .../common/slot_range_helper/src/lib.rs | 2 +- .../common/src/assigned_slots/migration.rs | 6 +- .../runtime/common/src/assigned_slots/mod.rs | 2 +- polkadot/runtime/common/src/auctions.rs | 3 +- polkadot/runtime/common/src/claims.rs | 17 +- .../runtime/common/src/crowdloan/migration.rs | 2 +- polkadot/runtime/common/src/crowdloan/mod.rs | 7 +- .../runtime/common/src/identity_migrator.rs | 2 +- polkadot/runtime/common/src/impls.rs | 4 +- .../runtime/common/src/integration_tests.rs | 2 +- polkadot/runtime/common/src/lib.rs | 6 +- polkadot/runtime/common/src/mock.rs | 2 +- .../common/src/paras_registrar/migration.rs | 2 +- .../runtime/common/src/paras_registrar/mod.rs | 7 +- .../runtime/common/src/paras_sudo_wrapper.rs | 2 +- polkadot/runtime/common/src/purchase.rs | 2 +- polkadot/runtime/common/src/slots/mod.rs | 6 +- polkadot/runtime/common/src/traits.rs | 2 +- polkadot/runtime/common/src/try_runtime.rs | 2 +- polkadot/runtime/common/src/xcm_sender.rs | 12 +- polkadot/runtime/metrics/Cargo.toml | 2 - polkadot/runtime/metrics/src/lib.rs | 2 + .../metrics/src/with_runtime_metrics.rs | 3 +- polkadot/runtime/parachains/Cargo.toml | 2 - .../parachains/src/assigner_coretime/mod.rs | 3 +- .../parachains/src/assigner_coretime/tests.rs | 2 +- .../src/assigner_on_demand/benchmarking.rs | 1 + .../src/assigner_on_demand/migration.rs | 8 +- .../parachains/src/assigner_on_demand/mod.rs | 1 - .../src/assigner_on_demand/tests.rs | 6 +- .../src/assigner_on_demand/types.rs | 5 +- .../src/assigner_parachains/tests.rs | 2 +- polkadot/runtime/parachains/src/builder.rs | 14 +- .../runtime/parachains/src/configuration.rs | 6 +- .../src/configuration/migration/v10.rs | 4 +- .../src/configuration/migration/v11.rs | 4 +- .../src/configuration/migration/v12.rs | 4 +- .../src/configuration/migration/v6.rs | 4 +- .../src/configuration/migration/v7.rs | 4 +- .../src/configuration/migration/v8.rs | 4 +- .../src/configuration/migration/v9.rs | 4 +- .../parachains/src/coretime/migration.rs | 7 +- .../runtime/parachains/src/coretime/mod.rs | 3 +- polkadot/runtime/parachains/src/disputes.rs | 3 +- .../parachains/src/disputes/migration.rs | 4 +- .../parachains/src/disputes/slashing.rs | 14 +- polkadot/runtime/parachains/src/dmp.rs | 3 +- polkadot/runtime/parachains/src/hrmp.rs | 13 +- .../parachains/src/inclusion/migration.rs | 4 +- .../runtime/parachains/src/inclusion/mod.rs | 13 +- .../runtime/parachains/src/initializer.rs | 4 +- polkadot/runtime/parachains/src/lib.rs | 2 + polkadot/runtime/parachains/src/mock.rs | 7 +- polkadot/runtime/parachains/src/origin.rs | 2 +- .../parachains/src/paras/benchmarking.rs | 1 + .../src/paras/benchmarking/pvf_check.rs | 1 + polkadot/runtime/parachains/src/paras/mod.rs | 5 +- .../src/paras_inherent/benchmarking.rs | 3 +- .../parachains/src/paras_inherent/misc.rs | 3 +- .../parachains/src/paras_inherent/mod.rs | 14 +- .../parachains/src/paras_inherent/tests.rs | 4 +- .../runtime/parachains/src/reward_points.rs | 4 +- .../parachains/src/runtime_api_impl/v10.rs | 2 +- .../src/runtime_api_impl/vstaging.rs | 6 +- polkadot/runtime/parachains/src/scheduler.rs | 22 ++- .../parachains/src/scheduler/migration.rs | 5 +- .../runtime/parachains/src/scheduler/tests.rs | 2 +- .../runtime/parachains/src/session_info.rs | 2 +- polkadot/runtime/parachains/src/shared.rs | 8 +- polkadot/runtime/parachains/src/ump_tests.rs | 1 - polkadot/runtime/parachains/src/util.rs | 4 +- polkadot/runtime/rococo/Cargo.toml | 2 - .../rococo/src/genesis_config_presets.rs | 8 +- polkadot/runtime/rococo/src/impls.rs | 3 +- polkadot/runtime/rococo/src/lib.rs | 17 +- .../runtime/rococo/src/validator_manager.rs | 2 +- .../rococo/src/weights/pallet_session.rs | 2 +- .../runtime/rococo/src/weights/xcm/mod.rs | 2 +- polkadot/runtime/test-runtime/Cargo.toml | 2 - polkadot/runtime/test-runtime/src/lib.rs | 13 +- .../runtime/test-runtime/src/xcm_config.rs | 2 +- polkadot/runtime/westend/Cargo.toml | 2 - polkadot/runtime/westend/src/impls.rs | 3 +- polkadot/runtime/westend/src/lib.rs | 15 +- .../runtime/westend/src/weights/xcm/mod.rs | 2 +- .../relay_token_transactor/parachain/mod.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml | 2 - .../src/fungible/benchmarking.rs | 4 +- .../src/generic/benchmarking.rs | 2 +- polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs | 4 +- polkadot/xcm/pallet-xcm/Cargo.toml | 2 - polkadot/xcm/pallet-xcm/src/benchmarking.rs | 1 - polkadot/xcm/pallet-xcm/src/lib.rs | 15 +- polkadot/xcm/pallet-xcm/src/migration.rs | 4 +- polkadot/xcm/pallet-xcm/src/mock.rs | 2 +- polkadot/xcm/xcm-builder/Cargo.toml | 2 - .../xcm/xcm-builder/src/asset_conversion.rs | 2 +- polkadot/xcm/xcm-builder/src/barriers.rs | 2 +- polkadot/xcm/xcm-builder/src/controller.rs | 2 +- .../xcm/xcm-builder/src/currency_adapter.rs | 2 +- .../xcm-builder/src/filter_asset_location.rs | 11 +- .../xcm/xcm-builder/src/fungible_adapter.rs | 2 +- .../xcm/xcm-builder/src/fungibles_adapter.rs | 8 +- polkadot/xcm/xcm-builder/src/lib.rs | 2 + .../xcm-builder/src/location_conversion.rs | 5 +- .../xcm/xcm-builder/src/matches_location.rs | 6 +- polkadot/xcm/xcm-builder/src/matches_token.rs | 2 +- .../xcm-builder/src/nonfungible_adapter.rs | 2 +- .../xcm-builder/src/nonfungibles_adapter.rs | 2 +- .../xcm/xcm-builder/src/origin_aliases.rs | 2 +- .../xcm/xcm-builder/src/origin_conversion.rs | 2 +- polkadot/xcm/xcm-builder/src/pay.rs | 5 +- .../xcm-builder/src/process_xcm_message.rs | 3 +- polkadot/xcm/xcm-builder/src/routing.rs | 5 +- polkadot/xcm/xcm-builder/src/test_utils.rs | 2 +- polkadot/xcm/xcm-builder/src/tests/mock.rs | 10 +- polkadot/xcm/xcm-builder/src/tests/mod.rs | 1 + .../xcm/xcm-builder/src/universal_exports.rs | 7 +- polkadot/xcm/xcm-builder/src/weight.rs | 2 +- polkadot/xcm/xcm-builder/tests/mock/mod.rs | 2 +- polkadot/xcm/xcm-executor/Cargo.toml | 2 - polkadot/xcm/xcm-executor/src/assets.rs | 10 +- polkadot/xcm/xcm-executor/src/lib.rs | 9 +- .../xcm/xcm-executor/src/traits/asset_lock.rs | 2 +- .../xcm/xcm-executor/src/traits/conversion.rs | 2 +- .../xcm-executor/src/traits/on_response.rs | 3 +- .../xcm-executor/src/traits/should_execute.rs | 2 +- .../xcm-executor/src/traits/token_matching.rs | 2 +- .../xcm-executor/src/traits/transact_asset.rs | 2 +- .../xcm/xcm-executor/src/traits/weight.rs | 2 +- polkadot/xcm/xcm-runtime-apis/Cargo.toml | 2 - .../xcm/xcm-runtime-apis/src/conversions.rs | 2 +- polkadot/xcm/xcm-runtime-apis/src/dry_run.rs | 2 +- polkadot/xcm/xcm-runtime-apis/src/fees.rs | 2 +- polkadot/xcm/xcm-runtime-apis/src/lib.rs | 2 + polkadot/xcm/xcm-runtime-apis/tests/mock.rs | 2 +- .../example/src/parachain/mod.rs | 3 +- .../xcm/xcm-simulator/fuzzer/src/parachain.rs | 1 - polkadot/xcm/xcm-simulator/src/lib.rs | 5 +- .../xcm-simulator/src/mock_message_queue.rs | 1 - substrate/bin/node/runtime/src/assets_api.rs | 2 +- substrate/bin/node/runtime/src/impls.rs | 5 +- substrate/bin/node/runtime/src/lib.rs | 6 +- .../client/executor/runtime-test/Cargo.toml | 2 - .../client/executor/runtime-test/src/lib.rs | 7 +- substrate/client/sysinfo/src/sysinfo.rs | 4 +- substrate/frame/Cargo.toml | 2 - substrate/frame/alliance/Cargo.toml | 2 - substrate/frame/alliance/src/lib.rs | 4 +- substrate/frame/alliance/src/types.rs | 2 +- substrate/frame/asset-conversion/Cargo.toml | 2 - .../frame/asset-conversion/ops/Cargo.toml | 2 - .../asset-conversion/ops/src/benchmarking.rs | 1 - .../frame/asset-conversion/ops/src/lib.rs | 4 +- .../frame/asset-conversion/ops/src/mock.rs | 1 - .../asset-conversion/src/benchmarking.rs | 3 +- substrate/frame/asset-conversion/src/lib.rs | 4 +- substrate/frame/asset-rate/Cargo.toml | 2 - substrate/frame/asset-rate/src/lib.rs | 4 +- substrate/frame/assets/Cargo.toml | 2 - substrate/frame/assets/src/benchmarking.rs | 4 +- substrate/frame/assets/src/functions.rs | 7 +- substrate/frame/assets/src/impl_fungibles.rs | 1 + substrate/frame/assets/src/lib.rs | 4 +- substrate/frame/atomic-swap/Cargo.toml | 2 - substrate/frame/atomic-swap/src/lib.rs | 4 +- substrate/frame/aura/Cargo.toml | 2 - substrate/frame/aura/src/lib.rs | 10 +- .../frame/authority-discovery/Cargo.toml | 2 - .../frame/authority-discovery/src/lib.rs | 7 +- substrate/frame/authorship/Cargo.toml | 2 - substrate/frame/authorship/src/lib.rs | 1 - substrate/frame/babe/Cargo.toml | 2 - substrate/frame/babe/src/equivocation.rs | 4 +- substrate/frame/babe/src/lib.rs | 12 +- substrate/frame/bags-list/Cargo.toml | 2 - .../frame/bags-list/remote-tests/src/lib.rs | 1 - substrate/frame/bags-list/src/benchmarks.rs | 1 + substrate/frame/bags-list/src/lib.rs | 8 +- substrate/frame/bags-list/src/list/mod.rs | 30 ++-- substrate/frame/bags-list/src/migrations.rs | 6 +- substrate/frame/balances/Cargo.toml | 2 - substrate/frame/balances/src/impl_currency.rs | 2 +- substrate/frame/balances/src/lib.rs | 17 +- substrate/frame/beefy-mmr/Cargo.toml | 2 - substrate/frame/beefy-mmr/src/lib.rs | 6 +- substrate/frame/beefy/Cargo.toml | 2 - substrate/frame/beefy/src/equivocation.rs | 4 +- substrate/frame/beefy/src/lib.rs | 4 +- substrate/frame/benchmarking/Cargo.toml | 2 - substrate/frame/benchmarking/pov/Cargo.toml | 2 - .../benchmarking/pov/src/benchmarking.rs | 22 +-- substrate/frame/benchmarking/pov/src/lib.rs | 4 +- substrate/frame/benchmarking/src/baseline.rs | 2 +- substrate/frame/benchmarking/src/lib.rs | 4 +- substrate/frame/benchmarking/src/tests.rs | 2 - .../frame/benchmarking/src/tests_instance.rs | 2 - substrate/frame/benchmarking/src/utils.rs | 2 +- substrate/frame/benchmarking/src/v1.rs | 4 +- substrate/frame/bounties/Cargo.toml | 2 - substrate/frame/bounties/src/benchmarking.rs | 1 + substrate/frame/bounties/src/lib.rs | 4 +- substrate/frame/broker/Cargo.toml | 2 - substrate/frame/broker/src/benchmarking.rs | 2 +- .../frame/broker/src/coretime_interface.rs | 3 +- substrate/frame/broker/src/lib.rs | 6 +- substrate/frame/broker/src/migration.rs | 4 +- substrate/frame/broker/src/mock.rs | 2 +- .../frame/broker/src/nonfungible_impl.rs | 2 +- substrate/frame/broker/src/test_fungibles.rs | 2 +- substrate/frame/broker/src/tick_impls.rs | 2 +- substrate/frame/child-bounties/Cargo.toml | 2 - .../frame/child-bounties/src/benchmarking.rs | 2 + substrate/frame/child-bounties/src/lib.rs | 4 +- substrate/frame/collective/Cargo.toml | 2 - substrate/frame/collective/src/lib.rs | 7 +- .../frame/contracts/mock-network/Cargo.toml | 2 - .../mock-network/src/mocks/msg_queue.rs | 1 - .../contracts/mock-network/src/parachain.rs | 1 - .../frame/contracts/proc-macro/src/lib.rs | 2 +- .../src/benchmarking/call_builder.rs | 2 +- .../frame/contracts/src/benchmarking/code.rs | 4 +- .../frame/contracts/src/benchmarking/mod.rs | 4 +- .../frame/contracts/src/chain_extension.rs | 5 +- substrate/frame/contracts/src/exec.rs | 7 +- substrate/frame/contracts/src/lib.rs | 3 +- substrate/frame/contracts/src/migration.rs | 7 +- .../frame/contracts/src/migration/v09.rs | 4 +- .../frame/contracts/src/migration/v10.rs | 8 +- .../frame/contracts/src/migration/v11.rs | 4 +- .../frame/contracts/src/migration/v12.rs | 4 +- .../frame/contracts/src/migration/v13.rs | 1 - .../frame/contracts/src/migration/v14.rs | 6 +- .../frame/contracts/src/migration/v15.rs | 4 +- .../frame/contracts/src/migration/v16.rs | 1 - substrate/frame/contracts/src/primitives.rs | 2 +- substrate/frame/contracts/src/storage.rs | 3 +- .../frame/contracts/src/storage/meter.rs | 3 +- substrate/frame/contracts/src/tests.rs | 2 +- substrate/frame/contracts/src/wasm/mod.rs | 2 +- substrate/frame/contracts/src/wasm/prepare.rs | 6 +- substrate/frame/contracts/src/wasm/runtime.rs | 5 +- substrate/frame/conviction-voting/Cargo.toml | 2 - .../conviction-voting/src/benchmarking.rs | 2 +- substrate/frame/conviction-voting/src/lib.rs | 7 +- .../frame/conviction-voting/src/types.rs | 2 +- substrate/frame/conviction-voting/src/vote.rs | 1 - substrate/frame/core-fellowship/Cargo.toml | 2 - .../frame/core-fellowship/src/benchmarking.rs | 1 + substrate/frame/core-fellowship/src/lib.rs | 5 +- .../frame/core-fellowship/src/migration.rs | 2 + substrate/frame/delegated-staking/Cargo.toml | 2 - .../frame/delegated-staking/src/impls.rs | 2 +- substrate/frame/delegated-staking/src/lib.rs | 6 +- substrate/frame/democracy/Cargo.toml | 2 - substrate/frame/democracy/src/benchmarking.rs | 2 +- substrate/frame/democracy/src/lib.rs | 10 +- .../unlock_and_unreserve_all_funds.rs | 6 +- substrate/frame/democracy/src/vote.rs | 1 - .../election-provider-multi-phase/Cargo.toml | 2 - .../src/helpers.rs | 2 +- .../election-provider-multi-phase/src/lib.rs | 8 +- .../src/migrations.rs | 4 +- .../src/signed.rs | 10 +- .../src/unsigned.rs | 11 +- .../test-staking-e2e/src/mock.rs | 1 - .../election-provider-support/Cargo.toml | 2 - .../benchmarking/Cargo.toml | 2 - .../benchmarking/src/inner.rs | 2 +- .../benchmarking/src/lib.rs | 2 + .../solution-type/src/codec.rs | 20 +-- .../solution-type/src/single_page.rs | 16 +- .../election-provider-support/src/lib.rs | 19 ++- .../election-provider-support/src/onchain.rs | 3 +- .../election-provider-support/src/traits.rs | 3 +- substrate/frame/elections-phragmen/Cargo.toml | 2 - substrate/frame/elections-phragmen/src/lib.rs | 5 +- .../unlock_and_unreserve_all_funds.rs | 6 +- .../elections-phragmen/src/migrations/v3.rs | 2 +- .../elections-phragmen/src/migrations/v5.rs | 1 + substrate/frame/examples/basic/Cargo.toml | 2 - substrate/frame/examples/basic/src/lib.rs | 4 +- substrate/frame/examples/basic/src/tests.rs | 2 +- .../frame/examples/default-config/Cargo.toml | 2 - .../frame/examples/default-config/src/lib.rs | 4 +- substrate/frame/examples/dev-mode/Cargo.toml | 2 - substrate/frame/examples/dev-mode/src/lib.rs | 4 +- .../frame/examples/kitchensink/Cargo.toml | 2 - .../frame/examples/kitchensink/src/lib.rs | 2 + .../frame/examples/offchain-worker/Cargo.toml | 2 - .../frame/examples/offchain-worker/src/lib.rs | 6 +- .../examples/offchain-worker/src/tests.rs | 2 +- .../single-block-migrations/Cargo.toml | 2 - .../single-block-migrations/src/lib.rs | 3 + .../src/migrations/v1.rs | 4 +- substrate/frame/examples/split/Cargo.toml | 2 - substrate/frame/examples/tasks/Cargo.toml | 2 - substrate/frame/executive/Cargo.toml | 2 - substrate/frame/executive/src/lib.rs | 6 +- substrate/frame/fast-unstake/Cargo.toml | 2 - .../frame/fast-unstake/src/benchmarking.rs | 2 +- substrate/frame/fast-unstake/src/lib.rs | 4 +- .../frame/fast-unstake/src/migrations.rs | 4 +- substrate/frame/fast-unstake/src/mock.rs | 1 - substrate/frame/fast-unstake/src/types.rs | 3 +- substrate/frame/glutton/Cargo.toml | 2 - substrate/frame/glutton/src/lib.rs | 6 +- substrate/frame/grandpa/Cargo.toml | 2 - substrate/frame/grandpa/src/equivocation.rs | 4 +- substrate/frame/grandpa/src/lib.rs | 6 +- substrate/frame/grandpa/src/migrations/v5.rs | 3 +- substrate/frame/identity/Cargo.toml | 2 - substrate/frame/identity/src/benchmarking.rs | 1 + substrate/frame/identity/src/legacy.rs | 3 +- substrate/frame/identity/src/lib.rs | 4 +- substrate/frame/identity/src/types.rs | 7 +- substrate/frame/im-online/Cargo.toml | 2 - substrate/frame/im-online/src/lib.rs | 8 +- substrate/frame/im-online/src/migration.rs | 1 + substrate/frame/indices/Cargo.toml | 2 - substrate/frame/indices/src/lib.rs | 4 +- .../Cargo.toml | 2 - substrate/frame/lottery/Cargo.toml | 2 - substrate/frame/lottery/src/benchmarking.rs | 1 + substrate/frame/lottery/src/lib.rs | 4 +- substrate/frame/membership/Cargo.toml | 2 - substrate/frame/membership/src/lib.rs | 6 +- .../frame/merkle-mountain-range/Cargo.toml | 2 - .../frame/merkle-mountain-range/src/lib.rs | 12 +- .../merkle-mountain-range/src/mmr/mmr.rs | 2 +- .../merkle-mountain-range/src/mmr/storage.rs | 7 +- substrate/frame/message-queue/Cargo.toml | 2 - .../frame/message-queue/src/benchmarking.rs | 1 - substrate/frame/message-queue/src/lib.rs | 13 +- substrate/frame/message-queue/src/mock.rs | 2 +- .../frame/message-queue/src/mock_helpers.rs | 1 + substrate/frame/migrations/Cargo.toml | 2 - substrate/frame/migrations/src/lib.rs | 14 +- .../frame/migrations/src/mock_helpers.rs | 2 +- substrate/frame/mixnet/Cargo.toml | 2 - substrate/frame/mixnet/src/lib.rs | 5 +- substrate/frame/multisig/Cargo.toml | 2 - substrate/frame/multisig/src/lib.rs | 4 +- .../frame/nft-fractionalization/Cargo.toml | 2 - .../nft-fractionalization/src/benchmarking.rs | 1 - .../frame/nft-fractionalization/src/lib.rs | 2 +- substrate/frame/nfts/Cargo.toml | 2 - substrate/frame/nfts/runtime-api/Cargo.toml | 3 +- substrate/frame/nfts/runtime-api/src/lib.rs | 4 +- substrate/frame/nfts/src/benchmarking.rs | 1 - substrate/frame/nfts/src/common_functions.rs | 1 + substrate/frame/nfts/src/features/metadata.rs | 1 + substrate/frame/nfts/src/features/roles.rs | 2 +- substrate/frame/nfts/src/impl_nonfungibles.rs | 1 - substrate/frame/nfts/src/lib.rs | 4 +- substrate/frame/nfts/src/tests.rs | 1 - substrate/frame/nfts/src/types.rs | 1 + substrate/frame/nis/Cargo.toml | 2 - substrate/frame/nis/src/benchmarking.rs | 1 - substrate/frame/nis/src/lib.rs | 12 +- substrate/frame/node-authorization/Cargo.toml | 2 - substrate/frame/node-authorization/src/lib.rs | 4 +- substrate/frame/nomination-pools/Cargo.toml | 2 - .../nomination-pools/benchmarking/Cargo.toml | 2 - .../benchmarking/src/inner.rs | 2 +- .../nomination-pools/benchmarking/src/lib.rs | 2 + .../nomination-pools/runtime-api/Cargo.toml | 3 +- .../frame/nomination-pools/src/adapter.rs | 2 +- substrate/frame/nomination-pools/src/lib.rs | 9 +- .../frame/nomination-pools/src/migration.rs | 22 +-- substrate/frame/offences/Cargo.toml | 2 - .../frame/offences/benchmarking/Cargo.toml | 2 - .../frame/offences/benchmarking/src/inner.rs | 2 +- .../frame/offences/benchmarking/src/lib.rs | 2 + substrate/frame/offences/src/lib.rs | 5 +- substrate/frame/offences/src/migration.rs | 4 +- substrate/frame/paged-list/Cargo.toml | 2 - substrate/frame/paged-list/src/lib.rs | 4 +- substrate/frame/paged-list/src/paged_list.rs | 6 +- substrate/frame/parameters/Cargo.toml | 2 - substrate/frame/preimage/Cargo.toml | 2 - substrate/frame/preimage/src/benchmarking.rs | 2 +- substrate/frame/preimage/src/lib.rs | 4 +- substrate/frame/preimage/src/migration.rs | 4 +- substrate/frame/proxy/Cargo.toml | 2 - substrate/frame/proxy/src/benchmarking.rs | 1 + substrate/frame/proxy/src/lib.rs | 4 +- substrate/frame/proxy/src/tests.rs | 1 + substrate/frame/ranked-collective/Cargo.toml | 2 - .../ranked-collective/src/benchmarking.rs | 1 + substrate/frame/ranked-collective/src/lib.rs | 4 +- substrate/frame/recovery/Cargo.toml | 2 - substrate/frame/recovery/src/benchmarking.rs | 1 + substrate/frame/recovery/src/lib.rs | 4 +- substrate/frame/referenda/Cargo.toml | 2 - substrate/frame/referenda/src/benchmarking.rs | 5 +- substrate/frame/referenda/src/lib.rs | 7 +- substrate/frame/referenda/src/types.rs | 2 +- substrate/frame/remark/Cargo.toml | 2 - substrate/frame/remark/src/benchmarking.rs | 2 +- substrate/frame/remark/src/lib.rs | 4 +- substrate/frame/root-offences/src/mock.rs | 2 +- substrate/frame/root-testing/Cargo.toml | 2 - substrate/frame/safe-mode/Cargo.toml | 2 - substrate/frame/salary/Cargo.toml | 2 - substrate/frame/sassafras/Cargo.toml | 2 - substrate/frame/sassafras/src/lib.rs | 6 +- substrate/frame/scheduler/Cargo.toml | 2 - substrate/frame/scheduler/src/benchmarking.rs | 2 +- substrate/frame/scheduler/src/lib.rs | 5 +- substrate/frame/scheduler/src/migration.rs | 2 +- substrate/frame/scored-pool/Cargo.toml | 2 - substrate/frame/scored-pool/src/lib.rs | 5 +- substrate/frame/session/Cargo.toml | 2 - .../frame/session/benchmarking/Cargo.toml | 2 - .../frame/session/benchmarking/src/inner.rs | 2 +- .../frame/session/benchmarking/src/lib.rs | 2 + substrate/frame/session/src/historical/mod.rs | 8 +- .../frame/session/src/historical/offchain.rs | 6 +- .../frame/session/src/historical/onchain.rs | 2 +- .../frame/session/src/historical/shared.rs | 2 +- substrate/frame/session/src/lib.rs | 14 +- substrate/frame/society/Cargo.toml | 2 - substrate/frame/society/src/benchmarking.rs | 1 + substrate/frame/society/src/lib.rs | 6 +- substrate/frame/society/src/migrations.rs | 1 + substrate/frame/src/lib.rs | 8 +- substrate/frame/staking/Cargo.toml | 2 - substrate/frame/staking/src/benchmarking.rs | 3 +- substrate/frame/staking/src/ledger.rs | 1 - substrate/frame/staking/src/lib.rs | 16 +- substrate/frame/staking/src/migrations.rs | 8 +- substrate/frame/staking/src/pallet/impls.rs | 12 +- substrate/frame/staking/src/pallet/mod.rs | 4 +- substrate/frame/staking/src/slashing.rs | 12 +- substrate/frame/staking/src/testing_utils.rs | 1 - substrate/frame/staking/src/tests.rs | 1 - .../frame/state-trie-migration/Cargo.toml | 2 - .../frame/state-trie-migration/src/lib.rs | 20 ++- substrate/frame/statement/Cargo.toml | 2 - substrate/frame/statement/src/lib.rs | 2 +- substrate/frame/sudo/Cargo.toml | 2 - substrate/frame/sudo/src/benchmarking.rs | 1 + substrate/frame/sudo/src/extension.rs | 2 +- substrate/frame/sudo/src/lib.rs | 5 +- .../src/construct_runtime/expand/inherent.rs | 6 +- .../src/construct_runtime/expand/metadata.rs | 4 +- .../src/construct_runtime/expand/origin.rs | 34 ++-- .../procedural/src/construct_runtime/mod.rs | 22 +-- .../procedural/src/pallet/expand/constants.rs | 6 +- .../src/pallet/expand/documentation.rs | 4 +- .../procedural/src/pallet/expand/error.rs | 8 +- .../procedural/src/pallet/expand/hooks.rs | 4 +- .../src/pallet/expand/pallet_struct.rs | 14 +- .../procedural/src/pallet/expand/storage.rs | 8 +- .../procedural/src/pallet/expand/tasks.rs | 7 +- .../src/pallet/parse/tests/tasks.rs | 4 +- .../procedural/src/runtime/expand/mod.rs | 2 +- substrate/frame/support/src/dispatch.rs | 8 +- .../frame/support/src/dispatch_context.rs | 6 +- .../support/src/genesis_builder_helper.rs | 2 +- substrate/frame/support/src/hash.rs | 2 +- substrate/frame/support/src/lib.rs | 25 ++- substrate/frame/support/src/migrations.rs | 21 +-- .../support/src/storage/bounded_btree_map.rs | 2 +- .../support/src/storage/bounded_btree_set.rs | 2 +- substrate/frame/support/src/storage/child.rs | 2 +- .../src/storage/generator/double_map.rs | 3 +- .../support/src/storage/generator/map.rs | 6 +- .../support/src/storage/generator/mod.rs | 1 + .../support/src/storage/generator/nmap.rs | 4 +- substrate/frame/support/src/storage/hashed.rs | 2 +- .../frame/support/src/storage/migration.rs | 6 +- substrate/frame/support/src/storage/mod.rs | 3 +- .../support/src/storage/storage_noop_guard.rs | 12 +- .../frame/support/src/storage/stream_iter.rs | 22 +-- .../support/src/storage/types/counted_map.rs | 2 +- .../support/src/storage/types/counted_nmap.rs | 3 +- .../support/src/storage/types/double_map.rs | 2 +- .../frame/support/src/storage/types/key.rs | 10 +- .../frame/support/src/storage/types/map.rs | 2 +- .../frame/support/src/storage/types/mod.rs | 4 +- .../frame/support/src/storage/types/nmap.rs | 3 +- .../frame/support/src/storage/types/value.rs | 2 +- .../frame/support/src/storage/unhashed.rs | 2 +- .../support/src/traits/dynamic_params.rs | 2 +- substrate/frame/support/src/traits/filter.rs | 4 +- substrate/frame/support/src/traits/hooks.rs | 5 +- substrate/frame/support/src/traits/members.rs | 3 +- .../frame/support/src/traits/messages.rs | 2 +- .../frame/support/src/traits/metadata.rs | 13 +- substrate/frame/support/src/traits/misc.rs | 33 ++-- .../frame/support/src/traits/preimages.rs | 8 +- .../frame/support/src/traits/schedule.rs | 9 +- substrate/frame/support/src/traits/storage.rs | 2 +- substrate/frame/support/src/traits/tasks.rs | 6 +- .../src/traits/tokens/currency/reservable.rs | 2 +- .../src/traits/tokens/fungible/imbalance.rs | 14 +- .../src/traits/tokens/fungible/item_of.rs | 4 +- .../support/src/traits/tokens/fungible/mod.rs | 4 +- .../src/traits/tokens/fungible/regular.rs | 2 +- .../src/traits/tokens/fungible/union_of.rs | 6 +- .../src/traits/tokens/fungibles/imbalance.rs | 14 +- .../src/traits/tokens/fungibles/metadata.rs | 2 +- .../src/traits/tokens/fungibles/regular.rs | 2 +- .../src/traits/tokens/fungibles/union_of.rs | 4 +- .../traits/tokens/imbalance/on_unbalanced.rs | 2 +- .../tokens/imbalance/signed_imbalance.rs | 2 +- .../traits/tokens/imbalance/split_two_ways.rs | 2 +- .../frame/support/src/traits/tokens/misc.rs | 4 +- .../support/src/traits/tokens/nonfungible.rs | 4 +- .../src/traits/tokens/nonfungible_v2.rs | 4 +- .../support/src/traits/tokens/nonfungibles.rs | 2 +- .../src/traits/tokens/nonfungibles_v2.rs | 2 +- .../frame/support/src/traits/tokens/pay.rs | 2 +- .../traits/try_runtime/decode_entire_state.rs | 6 +- .../support/src/traits/try_runtime/mod.rs | 16 +- .../frame/support/src/traits/validation.rs | 2 +- substrate/frame/support/src/traits/voting.rs | 4 +- substrate/frame/support/test/Cargo.toml | 2 - substrate/frame/support/test/src/lib.rs | 2 +- .../frame/support/test/tests/issue2219.rs | 2 +- substrate/frame/support/test/tests/origin.rs | 4 +- substrate/frame/support/test/tests/pallet.rs | 2 +- .../support/test/tests/pallet_instance.rs | 4 +- substrate/frame/support/test/tests/runtime.rs | 6 +- .../test/tests/runtime_legacy_ordering.rs | 6 +- .../support/test/tests/versioned_migration.rs | 4 +- .../frame/system/benchmarking/Cargo.toml | 2 - .../frame/system/benchmarking/src/inner.rs | 2 +- .../frame/system/benchmarking/src/lib.rs | 2 + .../system/src/extensions/check_genesis.rs | 10 +- .../system/src/extensions/check_mortality.rs | 10 +- .../src/extensions/check_non_zero_sender.rs | 12 +- .../system/src/extensions/check_nonce.rs | 10 +- .../src/extensions/check_spec_version.rs | 10 +- .../system/src/extensions/check_tx_version.rs | 10 +- .../system/src/extensions/check_weight.rs | 12 +- substrate/frame/system/src/lib.rs | 27 +-- substrate/frame/system/src/migrations/mod.rs | 1 - substrate/frame/system/src/offchain.rs | 6 +- substrate/frame/timestamp/Cargo.toml | 2 - substrate/frame/timestamp/src/lib.rs | 16 +- substrate/frame/tips/Cargo.toml | 2 - substrate/frame/tips/src/lib.rs | 4 +- .../tips/src/migrations/unreserve_deposits.rs | 8 +- .../frame/transaction-payment/Cargo.toml | 2 - .../asset-conversion-tx-payment/Cargo.toml | 2 - .../asset-conversion-tx-payment/src/lib.rs | 10 +- .../src/payment.rs | 3 +- .../asset-tx-payment/Cargo.toml | 2 - .../asset-tx-payment/src/lib.rs | 10 +- .../asset-tx-payment/src/payment.rs | 2 +- .../skip-feeless-payment/Cargo.toml | 2 - .../skip-feeless-payment/src/lib.rs | 10 +- .../skip-feeless-payment/src/mock.rs | 2 +- .../frame/transaction-payment/src/lib.rs | 15 +- .../frame/transaction-payment/src/types.rs | 1 - .../frame/transaction-storage/Cargo.toml | 2 - .../transaction-storage/src/benchmarking.rs | 2 +- .../frame/transaction-storage/src/lib.rs | 5 +- substrate/frame/treasury/Cargo.toml | 2 - substrate/frame/treasury/src/lib.rs | 6 +- substrate/frame/try-runtime/Cargo.toml | 2 - substrate/frame/tx-pause/Cargo.toml | 2 - substrate/frame/tx-pause/src/benchmarking.rs | 1 + substrate/frame/tx-pause/src/lib.rs | 4 +- substrate/frame/uniques/Cargo.toml | 2 - substrate/frame/uniques/src/benchmarking.rs | 2 +- .../frame/uniques/src/impl_nonfungibles.rs | 2 +- substrate/frame/uniques/src/lib.rs | 4 +- substrate/frame/uniques/src/tests.rs | 1 - substrate/frame/utility/Cargo.toml | 2 - substrate/frame/utility/src/benchmarking.rs | 1 + substrate/frame/utility/src/lib.rs | 8 +- substrate/frame/vesting/Cargo.toml | 2 - substrate/frame/vesting/src/lib.rs | 5 +- substrate/frame/vesting/src/migrations.rs | 1 + substrate/frame/whitelist/Cargo.toml | 2 - substrate/frame/whitelist/src/benchmarking.rs | 4 +- substrate/frame/whitelist/src/lib.rs | 4 +- substrate/primitives/api/Cargo.toml | 2 - substrate/primitives/api/src/lib.rs | 7 +- .../primitives/application-crypto/Cargo.toml | 2 - .../application-crypto/src/bandersnatch.rs | 2 +- .../application-crypto/src/bls377.rs | 2 +- .../application-crypto/src/ecdsa.rs | 2 +- .../application-crypto/src/ecdsa_bls377.rs | 2 +- .../application-crypto/src/ed25519.rs | 2 +- .../primitives/application-crypto/src/lib.rs | 10 +- .../application-crypto/src/sr25519.rs | 2 +- .../application-crypto/src/traits.rs | 7 +- substrate/primitives/arithmetic/Cargo.toml | 2 - substrate/primitives/core/src/address_uri.rs | 10 +- substrate/primitives/core/src/bandersnatch.rs | 2 +- substrate/primitives/core/src/bls.rs | 2 +- substrate/primitives/core/src/crypto.rs | 28 ++- substrate/primitives/core/src/crypto_bytes.rs | 12 +- substrate/primitives/core/src/ecdsa.rs | 4 +- substrate/primitives/core/src/ed25519.rs | 2 +- substrate/primitives/core/src/hexdisplay.rs | 10 +- substrate/primitives/core/src/lib.rs | 13 +- substrate/primitives/core/src/offchain/mod.rs | 2 +- .../primitives/core/src/paired_crypto.rs | 2 +- substrate/primitives/core/src/sr25519.rs | 12 +- substrate/primitives/io/Cargo.toml | 2 - substrate/primitives/io/src/lib.rs | 6 +- .../proc-macro/src/pass_by/enum_.rs | 2 +- .../primitives/runtime-interface/src/impls.rs | 8 +- .../primitives/runtime-interface/src/lib.rs | 2 + .../runtime-interface/src/pass_by.rs | 4 +- .../runtime-interface/test-wasm/Cargo.toml | 2 - .../runtime-interface/test-wasm/src/lib.rs | 7 +- .../primitives/runtime/src/generic/block.rs | 2 +- .../primitives/runtime/src/generic/digest.rs | 7 +- .../src/generic/unchecked_extrinsic.rs | 11 +- substrate/primitives/runtime/src/lib.rs | 23 ++- .../primitives/runtime/src/multiaddress.rs | 2 +- .../primitives/runtime/src/offchain/http.rs | 4 +- .../primitives/runtime/src/runtime_logger.rs | 2 +- .../primitives/runtime/src/runtime_string.rs | 4 +- substrate/primitives/runtime/src/traits.rs | 44 ++--- .../runtime/src/transaction_validity.rs | 2 +- substrate/primitives/version/src/lib.rs | 12 +- substrate/test-utils/runtime/src/lib.rs | 1 - templates/minimal/runtime/src/lib.rs | 3 + templates/parachain/runtime/src/lib.rs | 2 +- templates/solochain/runtime/src/lib.rs | 2 +- 825 files changed, 1835 insertions(+), 1938 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a7d47eb0f780..9972285780f35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -896,7 +896,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -1026,7 +1025,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -1062,7 +1060,6 @@ dependencies = [ "parity-scale-codec", "sp-io", "sp-runtime", - "sp-std 14.0.0", "staging-parachain-info", "staging-xcm", "staging-xcm-builder", @@ -1085,7 +1082,6 @@ dependencies = [ "scale-info", "sp-api", "sp-runtime", - "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -2036,7 +2032,6 @@ dependencies = [ "snowbridge-core", "sp-core", "sp-runtime", - "sp-std 14.0.0", "staging-xcm", ] @@ -2216,7 +2211,6 @@ dependencies = [ "sp-io", "sp-keyring", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "staging-xcm", "staging-xcm-builder", @@ -2616,7 +2610,6 @@ dependencies = [ "sp-genesis-builder", "sp-keyring", "sp-runtime", - "sp-std 14.0.0", "staging-chain-spec-builder", "substrate-wasm-builder", ] @@ -2966,7 +2959,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -3223,7 +3215,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -3321,7 +3312,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -3386,7 +3376,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -3910,7 +3899,6 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-trie", "tracing", @@ -4002,7 +3990,6 @@ dependencies = [ "sp-application-crypto", "sp-consensus-aura", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -4019,7 +4006,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "staging-xcm", ] @@ -4093,7 +4079,6 @@ dependencies = [ "pallet-session", "parity-scale-codec", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -4108,7 +4093,6 @@ dependencies = [ "polkadot-primitives", "scale-info", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -4122,7 +4106,6 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0", "staging-xcm", ] @@ -4147,7 +4130,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -4164,7 +4146,6 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 14.0.0", "staging-xcm", ] @@ -4178,7 +4159,6 @@ dependencies = [ "sp-api", "sp-consensus-aura", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -4192,7 +4172,6 @@ dependencies = [ "scale-info", "sp-api", "sp-runtime", - "sp-std 14.0.0", "sp-trie", "staging-xcm", ] @@ -4209,7 +4188,6 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-std 14.0.0", "sp-trie", ] @@ -4240,7 +4218,6 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-trie", ] @@ -4252,7 +4229,6 @@ dependencies = [ "futures", "parity-scale-codec", "sp-inherents", - "sp-std 14.0.0", "sp-timestamp", ] @@ -4269,7 +4245,6 @@ dependencies = [ "polkadot-runtime-parachains", "sp-io", "sp-runtime", - "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -4439,7 +4414,6 @@ dependencies = [ "polkadot-primitives", "sp-runtime", "sp-state-machine", - "sp-std 14.0.0", "sp-trie", ] @@ -4478,7 +4452,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-transaction-pool", "sp-version", "staging-parachain-info", @@ -5729,7 +5702,6 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-runtime-interface 24.0.0", - "sp-std 14.0.0", "sp-storage 19.0.0", "static_assertions", ] @@ -5794,7 +5766,6 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -5828,7 +5799,6 @@ dependencies = [ "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -5866,7 +5836,6 @@ dependencies = [ "sp-inherents", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "sp-version", ] @@ -6046,7 +6015,6 @@ dependencies = [ "sp-metadata-ir", "sp-runtime", "sp-state-machine", - "sp-std 14.0.0", "sp-version", "static_assertions", "trybuild", @@ -6121,7 +6089,6 @@ dependencies = [ "sp-externalities 0.25.0", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-version", ] @@ -6142,7 +6109,6 @@ dependencies = [ "parity-scale-codec", "sp-api", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -6480,7 +6446,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -9665,7 +9630,6 @@ dependencies = [ "sp-crypto-hashing", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9686,7 +9650,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9707,7 +9670,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9725,7 +9687,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-storage 19.0.0", ] @@ -9742,7 +9703,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9763,7 +9723,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-storage 19.0.0", ] @@ -9814,7 +9773,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9832,7 +9790,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9849,7 +9806,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9864,7 +9820,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9892,7 +9847,6 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0", ] [[package]] @@ -9912,7 +9866,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", ] @@ -9960,7 +9913,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -9988,7 +9940,6 @@ dependencies = [ "sp-session", "sp-staking", "sp-state-machine", - "sp-std 14.0.0", ] [[package]] @@ -10013,7 +9964,6 @@ dependencies = [ "sp-runtime", "sp-staking", "sp-state-machine", - "sp-std 14.0.0", ] [[package]] @@ -10031,7 +9981,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10161,7 +10110,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", ] @@ -10181,7 +10129,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10205,7 +10152,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0", "sp-tracing 16.0.0", ] @@ -10222,7 +10168,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10237,7 +10182,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10330,7 +10274,6 @@ dependencies = [ "sp-io", "sp-keystore", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "staging-xcm", "staging-xcm-builder", @@ -10374,7 +10317,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10392,7 +10334,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10406,7 +10347,6 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10427,7 +10367,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0", "sp-tracing 16.0.0", "substrate-test-utils", ] @@ -10449,7 +10388,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10465,7 +10403,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10515,7 +10452,6 @@ dependencies = [ "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "strum 0.26.2", ] @@ -10530,7 +10466,6 @@ dependencies = [ "parity-scale-codec", "sp-npos-elections", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10549,7 +10484,6 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-staking", - "sp-std 14.0.0", "sp-tracing 16.0.0", "substrate-test-utils", ] @@ -10568,7 +10502,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10594,7 +10527,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10625,7 +10557,6 @@ dependencies = [ "sp-io", "sp-keystore", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10644,7 +10575,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-version", ] @@ -10660,7 +10590,6 @@ dependencies = [ "scale-info", "sp-core", "sp-io", - "sp-std 14.0.0", ] [[package]] @@ -10676,7 +10605,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10714,7 +10642,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0", "sp-tracing 16.0.0", "substrate-test-utils", ] @@ -10735,7 +10662,6 @@ dependencies = [ "sp-inherents", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10765,7 +10691,6 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0", ] [[package]] @@ -10784,7 +10709,6 @@ dependencies = [ "sp-io", "sp-keystore", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10804,7 +10728,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0", ] [[package]] @@ -10821,7 +10744,6 @@ dependencies = [ "sp-io", "sp-keyring", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10836,7 +10758,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10853,7 +10774,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10869,7 +10789,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10891,7 +10810,6 @@ dependencies = [ "sp-crypto-hashing", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "sp-weights", ] @@ -10915,7 +10833,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "sp-version", ] @@ -10945,7 +10862,6 @@ dependencies = [ "sp-io", "sp-mixnet", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10965,7 +10881,6 @@ dependencies = [ "sp-io", "sp-mmr-primitives", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -10981,7 +10896,6 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11019,7 +10933,6 @@ dependencies = [ "sp-io", "sp-keystore", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11029,7 +10942,6 @@ dependencies = [ "pallet-nfts", "parity-scale-codec", "sp-api", - "sp-std 14.0.0", ] [[package]] @@ -11046,7 +10958,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11061,7 +10972,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11078,7 +10988,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0", "sp-tracing 16.0.0", ] @@ -11104,7 +11013,6 @@ dependencies = [ "sp-runtime", "sp-runtime-interface 24.0.0", "sp-staking", - "sp-std 14.0.0", ] [[package]] @@ -11129,7 +11037,6 @@ dependencies = [ "pallet-nomination-pools", "parity-scale-codec", "sp-api", - "sp-std 14.0.0", ] [[package]] @@ -11196,7 +11103,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0", ] [[package]] @@ -11223,7 +11129,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 14.0.0", ] [[package]] @@ -11240,7 +11145,6 @@ dependencies = [ "sp-io", "sp-metadata-ir", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11285,7 +11189,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11302,7 +11205,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11319,7 +11221,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11337,7 +11238,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11353,7 +11253,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11375,7 +11274,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11391,7 +11289,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11426,7 +11323,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11446,7 +11342,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11464,7 +11359,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11483,7 +11377,6 @@ dependencies = [ "sp-crypto-hashing", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11501,7 +11394,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-weights", "substrate-test-utils", ] @@ -11518,7 +11410,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11538,7 +11429,6 @@ dependencies = [ "sp-session", "sp-staking", "sp-state-machine", - "sp-std 14.0.0", "sp-trie", ] @@ -11562,7 +11452,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-session", - "sp-std 14.0.0", ] [[package]] @@ -11574,7 +11463,6 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11595,7 +11483,6 @@ dependencies = [ "sp-crypto-hashing", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11623,7 +11510,6 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-staking", - "sp-std 14.0.0", "sp-tracing 16.0.0", "substrate-test-utils", ] @@ -11673,7 +11559,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "substrate-state-trie-migration-rpc", "thousands", @@ -11696,7 +11581,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-statement-store", - "sp-std 14.0.0", ] [[package]] @@ -11712,7 +11596,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11744,7 +11627,6 @@ dependencies = [ "sp-inherents", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-timestamp", ] @@ -11765,7 +11647,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-storage 19.0.0", ] @@ -11783,7 +11664,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11829,7 +11709,6 @@ dependencies = [ "sp-inherents", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-transaction-storage-proof", ] @@ -11850,7 +11729,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11869,7 +11747,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11905,7 +11782,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11922,7 +11798,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11940,7 +11815,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -11962,7 +11836,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -11986,7 +11859,6 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "staging-xcm", "staging-xcm-builder", @@ -12179,7 +12051,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "staging-parachain-info", "staging-xcm", "staging-xcm-executor", @@ -12224,7 +12095,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-tracing 16.0.0", "staging-parachain-info", "staging-xcm", @@ -12498,7 +12368,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -12596,7 +12465,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -12694,7 +12562,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -13075,7 +12942,6 @@ dependencies = [ "scale-info", "sp-core", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -13970,7 +13836,6 @@ dependencies = [ "serde", "sp-core", "sp-runtime", - "sp-std 14.0.0", "sp-weights", ] @@ -13997,7 +13862,6 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-staking", - "sp-std 14.0.0", ] [[package]] @@ -14095,7 +13959,6 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -14110,7 +13973,6 @@ dependencies = [ "frame-benchmarking", "parity-scale-codec", "polkadot-primitives", - "sp-std 14.0.0", "sp-tracing 16.0.0", ] @@ -14165,7 +14027,6 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0", "sp-tracing 16.0.0", "staging-xcm", "staging-xcm-executor", @@ -14671,7 +14532,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-transaction-pool", "sp-version", @@ -15031,7 +14891,6 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0", "sp-transaction-pool", "sp-trie", "sp-version", @@ -16457,7 +16316,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-transaction-pool", "sp-version", "staging-parachain-info", @@ -16559,7 +16417,6 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-tracing 16.0.0", "sp-transaction-pool", @@ -18198,7 +18055,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-runtime-interface 24.0.0", - "sp-std 14.0.0", "substrate-wasm-builder", ] @@ -18788,7 +18644,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-transaction-pool", "sp-version", "staging-parachain-info", @@ -19112,7 +18967,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std 14.0.0", "sp-transaction-pool", "sp-version", "staging-parachain-info", @@ -19219,7 +19073,6 @@ dependencies = [ "parity-scale-codec", "paste", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -19853,7 +19706,6 @@ dependencies = [ "sp-runtime", "sp-runtime-interface 24.0.0", "sp-state-machine", - "sp-std 14.0.0", "sp-test-primitives", "sp-trie", "sp-version", @@ -19906,7 +19758,6 @@ dependencies = [ "serde", "sp-core", "sp-io", - "sp-std 14.0.0", ] [[package]] @@ -19934,7 +19785,6 @@ dependencies = [ "scale-info", "serde", "sp-crypto-hashing", - "sp-std 14.0.0", "static_assertions", ] @@ -20350,7 +20200,6 @@ dependencies = [ "sp-keystore", "sp-runtime-interface 24.0.0", "sp-state-machine", - "sp-std 14.0.0", "sp-tracing 16.0.0", "sp-trie", "tracing", @@ -20596,7 +20445,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime-interface 24.0.0", - "sp-std 14.0.0", "substrate-wasm-builder", ] @@ -21024,7 +20872,6 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -21076,7 +20923,6 @@ dependencies = [ "sp-arithmetic", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-weights", "staging-xcm", "staging-xcm-executor", @@ -21096,7 +20942,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std 14.0.0", "sp-weights", "staging-xcm", "tracing", @@ -21893,7 +21738,6 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "sp-io", - "sp-std 14.0.0", "substrate-wasm-builder", "tiny-keccak", ] @@ -21941,7 +21785,6 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "sp-io", - "sp-std 14.0.0", "substrate-wasm-builder", "tiny-keccak", ] @@ -23640,7 +23483,6 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 14.0.0", "sp-storage 19.0.0", "sp-tracing 16.0.0", "sp-transaction-pool", @@ -24195,7 +24037,6 @@ dependencies = [ "scale-info", "sp-api", "sp-io", - "sp-std 14.0.0", "sp-weights", "staging-xcm", "staging-xcm-builder", diff --git a/cumulus/client/parachain-inherent/Cargo.toml b/cumulus/client/parachain-inherent/Cargo.toml index d81f727b41b9f..0d82cf6487432 100644 --- a/cumulus/client/parachain-inherent/Cargo.toml +++ b/cumulus/client/parachain-inherent/Cargo.toml @@ -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 } diff --git a/cumulus/client/relay-chain-inprocess-interface/src/lib.rs b/cumulus/client/relay-chain-inprocess-interface/src/lib.rs index 8f8d666bd1433..38ba84748c1e3 100644 --- a/cumulus/client/relay-chain-inprocess-interface/src/lib.rs +++ b/cumulus/client/relay-chain-inprocess-interface/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -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::{ @@ -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. diff --git a/cumulus/client/relay-chain-rpc-interface/src/lib.rs b/cumulus/client/relay-chain-rpc-interface/src/lib.rs index 692a1fb537a83..e32ec6a41a4bf 100644 --- a/cumulus/client/relay-chain-rpc-interface/src/lib.rs +++ b/cumulus/client/relay-chain-rpc-interface/src/lib.rs @@ -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; diff --git a/cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs b/cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs index a5d7c22a2ec89..c7eaa45958b0b 100644 --- a/cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs +++ b/cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs @@ -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}; @@ -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; diff --git a/cumulus/pallets/aura-ext/Cargo.toml b/cumulus/pallets/aura-ext/Cargo.toml index 1b6ac4cf07dff..c08148928b7ce 100644 --- a/cumulus/pallets/aura-ext/Cargo.toml +++ b/cumulus/pallets/aura-ext/Cargo.toml @@ -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 } @@ -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", diff --git a/cumulus/pallets/aura-ext/src/consensus_hook.rs b/cumulus/pallets/aura-ext/src/consensus_hook.rs index 560d477b2a850..c1a8568bdd834 100644 --- a/cumulus/pallets/aura-ext/src/consensus_hook.rs +++ b/cumulus/pallets/aura-ext/src/consensus_hook.rs @@ -20,6 +20,7 @@ //! The velocity `V` refers to the rate of block processing by the relay chain. use super::{pallet, Aura}; +use core::{marker::PhantomData, num::NonZeroU32}; use cumulus_pallet_parachain_system::{ self as parachain_system, consensus_hook::{ConsensusHook, UnincludedSegmentCapacity}, @@ -27,7 +28,6 @@ use cumulus_pallet_parachain_system::{ }; use frame_support::pallet_prelude::*; use sp_consensus_aura::{Slot, SlotDuration}; -use sp_std::{marker::PhantomData, num::NonZeroU32}; /// A consensus hook for a fixed block processing velocity and unincluded segment capacity. /// @@ -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(), ) diff --git a/cumulus/pallets/aura-ext/src/lib.rs b/cumulus/pallets/aura-ext/src/lib.rs index 4605dd325bee5..4c9e61458a87c 100644 --- a/cumulus/pallets/aura-ext/src/lib.rs +++ b/cumulus/pallets/aura-ext/src/lib.rs @@ -109,7 +109,7 @@ pub mod pallet { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -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(sp_std::marker::PhantomData<(T, I)>); +pub struct BlockExecutor(core::marker::PhantomData<(T, I)>); impl ExecuteBlock for BlockExecutor where diff --git a/cumulus/pallets/collator-selection/Cargo.toml b/cumulus/pallets/collator-selection/Cargo.toml index 206700b7d606c..b3512dc2ae6c9 100644 --- a/cumulus/pallets/collator-selection/Cargo.toml +++ b/cumulus/pallets/collator-selection/Cargo.toml @@ -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 } @@ -65,7 +64,6 @@ std = [ "scale-info/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", ] try-runtime = [ diff --git a/cumulus/pallets/collator-selection/src/benchmarking.rs b/cumulus/pallets/collator-selection/src/benchmarking.rs index c6b6004452825..24823661383b5 100644 --- a/cumulus/pallets/collator-selection/src/benchmarking.rs +++ b/cumulus/pallets/collator-selection/src/benchmarking.rs @@ -21,13 +21,14 @@ use super::*; #[allow(unused)] use crate::Pallet as CollatorSelection; +use alloc::vec::Vec; use codec::Decode; +use core::cmp; use frame_benchmarking::{account, v2::*, whitelisted_caller, BenchmarkError}; 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::*}; pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; diff --git a/cumulus/pallets/collator-selection/src/lib.rs b/cumulus/pallets/collator-selection/src/lib.rs index 2fa384367528a..17dc1a552c2de 100644 --- a/cumulus/pallets/collator-selection/src/lib.rs +++ b/cumulus/pallets/collator-selection/src/lib.rs @@ -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::*; @@ -101,6 +103,7 @@ const LOG_TARGET: &str = "runtime::collator-selection"; #[frame_support::pallet] pub mod pallet { pub use crate::weights::WeightInfo; + use alloc::vec::Vec; use core::ops::Div; use frame_support::{ dispatch::{DispatchClass, DispatchResultWithPostInfo}, @@ -118,7 +121,6 @@ pub mod pallet { RuntimeDebug, }; use sp_staking::SessionIndex; - use sp_std::vec::Vec; /// The in-code storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); @@ -244,7 +246,7 @@ pub mod pallet { let duplicate_invulnerables = self .invulnerables .iter() - .collect::>(); + .collect::>(); assert!( duplicate_invulnerables.len() == self.invulnerables.len(), "duplicate invulnerables in genesis." diff --git a/cumulus/pallets/collator-selection/src/migration.rs b/cumulus/pallets/collator-selection/src/migration.rs index 425acdd8bfb59..c52016948069a 100644 --- a/cumulus/pallets/collator-selection/src/migration.rs +++ b/cumulus/pallets/collator-selection/src/migration.rs @@ -17,6 +17,8 @@ //! A module that is responsible for migration of storage for Collator Selection. use super::*; +#[cfg(feature = "try-runtime")] +use alloc::vec::Vec; use frame_support::traits::{OnRuntimeUpgrade, UncheckedOnRuntimeUpgrade}; use log; @@ -29,8 +31,6 @@ pub mod v2 { traits::{Currency, ReservableCurrency}, }; use sp_runtime::traits::{Saturating, Zero}; - #[cfg(feature = "try-runtime")] - use sp_std::vec::Vec; /// [`UncheckedMigrationToV2`] wrapped in a /// [`VersionedMigration`](frame_support::migrations::VersionedMigration), ensuring the @@ -51,7 +51,7 @@ pub mod v2 { >; /// Migrate to V2. - pub struct UncheckedMigrationToV2(sp_std::marker::PhantomData); + pub struct UncheckedMigrationToV2(PhantomData); impl UncheckedOnRuntimeUpgrade for UncheckedMigrationToV2 { fn on_runtime_upgrade() -> Weight { let mut weight = Weight::zero(); @@ -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(sp_std::marker::PhantomData); + pub struct MigrateToV1(PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { fn on_runtime_upgrade() -> Weight { let on_chain_version = Pallet::::on_chain_storage_version(); diff --git a/cumulus/pallets/collator-selection/src/weights.rs b/cumulus/pallets/collator-selection/src/weights.rs index 1c01ad6cd6fe8..12e6b755e9769 100644 --- a/cumulus/pallets/collator-selection/src/weights.rs +++ b/cumulus/pallets/collator-selection/src/weights.rs @@ -18,11 +18,11 @@ #![allow(unused_parens)] #![allow(unused_imports)] +use core::marker::PhantomData; use frame_support::{ traits::Get, weights::{constants::RocksDbWeight, Weight}, }; -use sp_std::marker::PhantomData; // The weight info trait for `pallet_collator_selection`. pub trait WeightInfo { diff --git a/cumulus/pallets/dmp-queue/Cargo.toml b/cumulus/pallets/dmp-queue/Cargo.toml index 052a2547e788b..936526290d93e 100644 --- a/cumulus/pallets/dmp-queue/Cargo.toml +++ b/cumulus/pallets/dmp-queue/Cargo.toml @@ -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 } @@ -48,7 +47,6 @@ std = [ "scale-info/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm/std", ] diff --git a/cumulus/pallets/dmp-queue/src/benchmarking.rs b/cumulus/pallets/dmp-queue/src/benchmarking.rs index 91d1e0eab7e40..432d6f3bc7ae5 100644 --- a/cumulus/pallets/dmp-queue/src/benchmarking.rs +++ b/cumulus/pallets/dmp-queue/src/benchmarking.rs @@ -19,9 +19,9 @@ use crate::*; +use alloc::vec; use frame_benchmarking::v2::*; use frame_support::{pallet_prelude::*, traits::Hooks}; -use sp_std::vec; #[benchmarks] mod benchmarks { diff --git a/cumulus/pallets/dmp-queue/src/lib.rs b/cumulus/pallets/dmp-queue/src/lib.rs index 9b3ec684febab..cedca6f3fb97f 100644 --- a/cumulus/pallets/dmp-queue/src/lib.rs +++ b/cumulus/pallets/dmp-queue/src/lib.rs @@ -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::*; diff --git a/cumulus/pallets/dmp-queue/src/migration.rs b/cumulus/pallets/dmp-queue/src/migration.rs index 349635cce547d..b1945e8eb37b8 100644 --- a/cumulus/pallets/dmp-queue/src/migration.rs +++ b/cumulus/pallets/dmp-queue/src/migration.rs @@ -17,9 +17,9 @@ //! Migrates the storage from the previously deleted DMP pallet. use crate::*; +use alloc::vec::Vec; use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber; use frame_support::{pallet_prelude::*, storage_alias, traits::HandleMessage}; -use sp_std::vec::Vec; pub(crate) const LOG: &str = "runtime::dmp-queue-export-xcms"; diff --git a/cumulus/pallets/parachain-system/proc-macro/src/lib.rs b/cumulus/pallets/parachain-system/proc-macro/src/lib.rs index 8ab5d81efdcf4..f284fbdc64c60 100644 --- a/cumulus/pallets/parachain-system/proc-macro/src/lib.rs +++ b/cumulus/pallets/parachain-system/proc-macro/src/lib.rs @@ -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::Box::from_raw( + #crate_::validate_block::slice::from_raw_parts_mut( arguments, arguments_len, ) diff --git a/cumulus/pallets/parachain-system/src/consensus_hook.rs b/cumulus/pallets/parachain-system/src/consensus_hook.rs index 91353fc7bbda7..3062396a4e786 100644 --- a/cumulus/pallets/parachain-system/src/consensus_hook.rs +++ b/cumulus/pallets/parachain-system/src/consensus_hook.rs @@ -18,8 +18,8 @@ //! of parachain blocks ready to submit to the relay chain, as well as some basic implementations. use super::relay_state_snapshot::RelayChainStateProof; +use core::num::NonZeroU32; use frame_support::weights::Weight; -use sp_std::num::NonZeroU32; /// The possible capacity of the unincluded segment. #[derive(Clone)] @@ -95,7 +95,7 @@ impl ConsensusHook for FixedCapacityUnincludedSegment { 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(), ) diff --git a/cumulus/pallets/parachain-system/src/lib.rs b/cumulus/pallets/parachain-system/src/lib.rs index bbb74a1b05388..9e0a68d09a14a 100644 --- a/cumulus/pallets/parachain-system/src/lib.rs +++ b/cumulus/pallets/parachain-system/src/lib.rs @@ -27,7 +27,11 @@ //! //! Users must ensure that they register this pallet as an inherent provider. +extern crate alloc; + +use alloc::{collections::btree_map::BTreeMap, vec, vec::Vec}; use codec::{Decode, Encode}; +use core::cmp; use cumulus_primitives_core::{ relay_chain, AbridgedHostConfiguration, ChannelInfo, ChannelStatus, CollationInfo, GetChannelInfo, InboundDownwardMessage, InboundHrmpMessage, ListChannelInfos, MessageSendError, @@ -54,7 +58,6 @@ use sp_runtime::{ }, BoundedSlice, FixedU128, RuntimeDebug, Saturating, }; -use sp_std::{cmp, collections::btree_map::BTreeMap, prelude::*}; use xcm::{latest::XcmHash, VersionedLocation, VersionedXcm}; use xcm_builder::InspectMessageQueues; @@ -938,7 +941,7 @@ pub mod pallet { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -1530,7 +1533,7 @@ impl Pallet { } /// Type that implements `SetCode`. -pub struct ParachainSetCode(sp_std::marker::PhantomData); +pub struct ParachainSetCode(core::marker::PhantomData); impl frame_system::SetCode for ParachainSetCode { fn set_code(code: Vec) -> DispatchResult { Pallet::::schedule_code_upgrade(code) @@ -1645,7 +1648,7 @@ pub trait CheckInherents { /// Struct that always returns `Ok` on inherents check, needed for backwards-compatibility. #[doc(hidden)] -pub struct DummyCheckInherents(sp_std::marker::PhantomData); +pub struct DummyCheckInherents(core::marker::PhantomData); #[allow(deprecated)] impl CheckInherents for DummyCheckInherents { @@ -1718,7 +1721,7 @@ pub type RelaychainBlockNumberProvider = RelaychainDataProvider; /// of [`RelayChainState`]. /// - [`current_block_number`](Self::current_block_number): Will return /// [`Pallet::last_relay_block_number()`]. -pub struct RelaychainDataProvider(sp_std::marker::PhantomData); +pub struct RelaychainDataProvider(core::marker::PhantomData); impl BlockNumberProvider for RelaychainDataProvider { type BlockNumber = relay_chain::BlockNumber; diff --git a/cumulus/pallets/parachain-system/src/mock.rs b/cumulus/pallets/parachain-system/src/mock.rs index da904c0079a00..7bea72224b8ba 100644 --- a/cumulus/pallets/parachain-system/src/mock.rs +++ b/cumulus/pallets/parachain-system/src/mock.rs @@ -20,7 +20,9 @@ use super::*; +use alloc::collections::vec_deque::VecDeque; use codec::Encode; +use core::num::NonZeroU32; use cumulus_primitives_core::{ relay_chain::BlockNumber as RelayBlockNumber, AggregateMessageOrigin, InboundDownwardMessage, InboundHrmpMessage, PersistedValidationData, @@ -37,7 +39,6 @@ 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 sp_version::RuntimeVersion; use std::cell::RefCell; diff --git a/cumulus/pallets/parachain-system/src/relay_state_snapshot.rs b/cumulus/pallets/parachain-system/src/relay_state_snapshot.rs index 60eccfb072f41..323aaf6503808 100644 --- a/cumulus/pallets/parachain-system/src/relay_state_snapshot.rs +++ b/cumulus/pallets/parachain-system/src/relay_state_snapshot.rs @@ -16,6 +16,7 @@ //! Relay chain state proof provides means for accessing part of relay chain storage for reads. +use alloc::vec::Vec; use codec::{Decode, Encode}; use cumulus_primitives_core::{ relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId, @@ -23,7 +24,6 @@ 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 sp_trie::{HashDBT, MemoryDB, StorageProof, EMPTY_PREFIX}; /// The capacity of the upward message queue of a parachain on the relay chain. diff --git a/cumulus/pallets/parachain-system/src/tests.rs b/cumulus/pallets/parachain-system/src/tests.rs index 5ff15036fb6e4..51c6e83c11319 100755 --- a/cumulus/pallets/parachain-system/src/tests.rs +++ b/cumulus/pallets/parachain-system/src/tests.rs @@ -19,6 +19,7 @@ use super::*; use crate::mock::*; +use core::num::NonZeroU32; use cumulus_primitives_core::{AbridgedHrmpChannel, InboundDownwardMessage, InboundHrmpMessage}; use frame_support::{assert_ok, parameter_types, weights::Weight}; use frame_system::RawOrigin; @@ -26,7 +27,6 @@ use hex_literal::hex; use rand::Rng; use relay_chain::HrmpChannelId; use sp_core::H256; -use sp_std::num::NonZeroU32; #[test] #[should_panic] diff --git a/cumulus/pallets/parachain-system/src/unincluded_segment.rs b/cumulus/pallets/parachain-system/src/unincluded_segment.rs index 1e83a945c4ee3..814bb83aa1acb 100644 --- a/cumulus/pallets/parachain-system/src/unincluded_segment.rs +++ b/cumulus/pallets/parachain-system/src/unincluded_segment.rs @@ -21,11 +21,12 @@ //! sent to relay chain. use super::relay_state_snapshot::{MessagingStateSnapshot, RelayDispatchQueueRemainingCapacity}; +use alloc::collections::btree_map::BTreeMap; use codec::{Decode, Encode}; +use core::marker::PhantomData; use cumulus_primitives_core::{relay_chain, ParaId}; use scale_info::TypeInfo; use sp_runtime::RuntimeDebug; -use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData}; /// Constraints on outbound HRMP channel. #[derive(Clone, RuntimeDebug)] @@ -398,6 +399,7 @@ pub(crate) fn size_after_included(included_hash: H, segment: &[Anc #[cfg(test)] mod tests { use super::*; + use alloc::{vec, vec::Vec}; use assert_matches::assert_matches; #[test] diff --git a/cumulus/pallets/parachain-system/src/validate_block/implementation.rs b/cumulus/pallets/parachain-system/src/validate_block/implementation.rs index 956962fce157d..42311ca9d8340 100644 --- a/cumulus/pallets/parachain-system/src/validate_block/implementation.rs +++ b/cumulus/pallets/parachain-system/src/validate_block/implementation.rs @@ -26,6 +26,7 @@ use polkadot_parachain_primitives::primitives::{ HeadData, RelayChainBlockNumber, ValidationResult, }; +use alloc::vec::Vec; use codec::Encode; use frame_support::traits::{ExecuteBlock, ExtrinsicCall, Get, IsSubType}; @@ -33,7 +34,6 @@ use sp_core::storage::{ChildInfo, StateVersion}; use sp_externalities::{set_and_run_with_externalities, Externalities}; use sp_io::KillStorageResult; use sp_runtime::traits::{Block as BlockT, Extrinsic, HashingFor, Header as HeaderT}; -use sp_std::prelude::*; use sp_trie::{MemoryDB, ProofSizeProvider}; use trie_recorder::SizeOnlyRecorderProvider; @@ -124,7 +124,7 @@ where Err(_) => panic!("Compact proof decoding failure."), }; - sp_std::mem::drop(storage_proof); + core::mem::drop(storage_proof); let mut recorder = SizeOnlyRecorderProvider::new(); let cache_provider = trie_cache::CacheProvider::new(); @@ -294,7 +294,7 @@ fn host_storage_read(key: &[u8], value_out: &mut [u8], value_offset: u32) -> Opt Some(value) => { let value_offset = value_offset as usize; let data = &value[value_offset.min(value.len())..]; - let written = sp_std::cmp::min(data.len(), value_out.len()); + let written = core::cmp::min(data.len(), value_out.len()); value_out[..written].copy_from_slice(&data[..written]); Some(value.len() as u32) }, @@ -368,7 +368,7 @@ fn host_default_child_storage_read( Some(value) => { let value_offset = value_offset as usize; let data = &value[value_offset.min(value.len())..]; - let written = sp_std::cmp::min(data.len(), value_out.len()); + let written = core::cmp::min(data.len(), value_out.len()); value_out[..written].copy_from_slice(&data[..written]); Some(value.len() as u32) }, diff --git a/cumulus/pallets/parachain-system/src/validate_block/mod.rs b/cumulus/pallets/parachain-system/src/validate_block/mod.rs index 763a4cffd77f9..3a00d4d352a69 100644 --- a/cumulus/pallets/parachain-system/src/validate_block/mod.rs +++ b/cumulus/pallets/parachain-system/src/validate_block/mod.rs @@ -30,6 +30,9 @@ mod trie_cache; #[doc(hidden)] mod trie_recorder; +#[cfg(not(feature = "std"))] +#[doc(hidden)] +pub use alloc::{boxed::Box, slice}; #[cfg(not(feature = "std"))] #[doc(hidden)] pub use bytes; diff --git a/cumulus/pallets/parachain-system/src/validate_block/trie_cache.rs b/cumulus/pallets/parachain-system/src/validate_block/trie_cache.rs index 5d785910fbe02..5999b3ce87f9d 100644 --- a/cumulus/pallets/parachain-system/src/validate_block/trie_cache.rs +++ b/cumulus/pallets/parachain-system/src/validate_block/trie_cache.rs @@ -15,12 +15,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -use sp_state_machine::TrieCacheProvider; -use sp_std::{ +use alloc::{ boxed::Box, - cell::{RefCell, RefMut}, collections::btree_map::{BTreeMap, Entry}, }; +use core::cell::{RefCell, RefMut}; +use sp_state_machine::TrieCacheProvider; use sp_trie::NodeCodec; use trie_db::{node::NodeOwned, Hasher}; diff --git a/cumulus/pallets/parachain-system/src/validate_block/trie_recorder.rs b/cumulus/pallets/parachain-system/src/validate_block/trie_recorder.rs index 48310670c074d..1980134071952 100644 --- a/cumulus/pallets/parachain-system/src/validate_block/trie_recorder.rs +++ b/cumulus/pallets/parachain-system/src/validate_block/trie_recorder.rs @@ -22,11 +22,11 @@ use codec::Encode; -use sp_std::{ - cell::{RefCell, RefMut}, +use alloc::{ collections::{btree_map::BTreeMap, btree_set::BTreeSet}, rc::Rc, }; +use core::cell::{RefCell, RefMut}; use sp_trie::{NodeCodec, ProofSizeProvider, StorageProof}; use trie_db::{Hasher, RecordedForKey, TrieAccess}; diff --git a/cumulus/pallets/parachain-system/src/weights.rs b/cumulus/pallets/parachain-system/src/weights.rs index da7f64237e9b6..5c61879b4d36b 100644 --- a/cumulus/pallets/parachain-system/src/weights.rs +++ b/cumulus/pallets/parachain-system/src/weights.rs @@ -50,7 +50,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions needed for cumulus_pallet_parachain_system. pub trait WeightInfo { diff --git a/cumulus/pallets/session-benchmarking/Cargo.toml b/cumulus/pallets/session-benchmarking/Cargo.toml index df671566cdc24..e182ac45edebd 100644 --- a/cumulus/pallets/session-benchmarking/Cargo.toml +++ b/cumulus/pallets/session-benchmarking/Cargo.toml @@ -17,7 +17,6 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } @@ -39,5 +38,4 @@ std = [ "frame-system/std", "pallet-session/std", "sp-runtime/std", - "sp-std/std", ] diff --git a/cumulus/pallets/session-benchmarking/src/inner.rs b/cumulus/pallets/session-benchmarking/src/inner.rs index 36411d3d71afa..8d5954304878d 100644 --- a/cumulus/pallets/session-benchmarking/src/inner.rs +++ b/cumulus/pallets/session-benchmarking/src/inner.rs @@ -15,7 +15,7 @@ //! Benchmarking setup for pallet-session. -use sp_std::{prelude::*, vec}; +use alloc::{vec, vec::Vec}; use codec::Decode; use frame_benchmarking::{benchmarks, whitelisted_caller}; diff --git a/cumulus/pallets/session-benchmarking/src/lib.rs b/cumulus/pallets/session-benchmarking/src/lib.rs index a95d6fb7d5914..f5bfef0061690 100644 --- a/cumulus/pallets/session-benchmarking/src/lib.rs +++ b/cumulus/pallets/session-benchmarking/src/lib.rs @@ -20,6 +20,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(feature = "runtime-benchmarks")] pub mod inner; diff --git a/cumulus/pallets/solo-to-para/Cargo.toml b/cumulus/pallets/solo-to-para/Cargo.toml index ced1b24f1d2bf..5fd1939e93a03 100644 --- a/cumulus/pallets/solo-to-para/Cargo.toml +++ b/cumulus/pallets/solo-to-para/Cargo.toml @@ -18,7 +18,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } pallet-sudo = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } # Polkadot polkadot-primitives = { workspace = true } @@ -37,7 +36,6 @@ std = [ "polkadot-primitives/std", "scale-info/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "cumulus-pallet-parachain-system/try-runtime", diff --git a/cumulus/pallets/solo-to-para/src/lib.rs b/cumulus/pallets/solo-to-para/src/lib.rs index da948615d4e90..b42cc74f1cf32 100644 --- a/cumulus/pallets/solo-to-para/src/lib.rs +++ b/cumulus/pallets/solo-to-para/src/lib.rs @@ -16,12 +16,14 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use cumulus_pallet_parachain_system as parachain_system; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; pub use pallet::*; use polkadot_primitives::PersistedValidationData; -use sp_std::vec::Vec; #[frame_support::pallet] pub mod pallet { diff --git a/cumulus/pallets/xcm/Cargo.toml b/cumulus/pallets/xcm/Cargo.toml index 1f0cef70e3a72..35d7a083b061d 100644 --- a/cumulus/pallets/xcm/Cargo.toml +++ b/cumulus/pallets/xcm/Cargo.toml @@ -13,7 +13,6 @@ workspace = true codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } frame-support = { workspace = true } @@ -33,7 +32,6 @@ std = [ "scale-info/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm/std", ] try-runtime = [ diff --git a/cumulus/pallets/xcm/src/lib.rs b/cumulus/pallets/xcm/src/lib.rs index 90a0ec76defe2..e31df8471c266 100644 --- a/cumulus/pallets/xcm/src/lib.rs +++ b/cumulus/pallets/xcm/src/lib.rs @@ -25,7 +25,6 @@ use cumulus_primitives_core::ParaId; pub use pallet::*; use scale_info::TypeInfo; use sp_runtime::{traits::BadOrigin, RuntimeDebug}; -use sp_std::prelude::*; use xcm::latest::{ExecuteXcm, Outcome}; #[frame_support::pallet] diff --git a/cumulus/pallets/xcmp-queue/Cargo.toml b/cumulus/pallets/xcmp-queue/Cargo.toml index c542fa373b5ed..9c7470eda6da4 100644 --- a/cumulus/pallets/xcmp-queue/Cargo.toml +++ b/cumulus/pallets/xcmp-queue/Cargo.toml @@ -20,7 +20,6 @@ frame-system = { workspace = true } sp-io = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } pallet-message-queue = { workspace = true } # Polkadot @@ -68,7 +67,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/cumulus/pallets/xcmp-queue/src/benchmarking.rs b/cumulus/pallets/xcmp-queue/src/benchmarking.rs index 49e2cc8367348..9cb1301addfe5 100644 --- a/cumulus/pallets/xcmp-queue/src/benchmarking.rs +++ b/cumulus/pallets/xcmp-queue/src/benchmarking.rs @@ -17,6 +17,7 @@ use crate::*; +use alloc::vec; use codec::DecodeAll; use frame_benchmarking::v2::*; use frame_support::traits::Hooks; diff --git a/cumulus/pallets/xcmp-queue/src/bridging.rs b/cumulus/pallets/xcmp-queue/src/bridging.rs index 9db4b6e74c398..eff4a37b0cef7 100644 --- a/cumulus/pallets/xcmp-queue/src/bridging.rs +++ b/cumulus/pallets/xcmp-queue/src/bridging.rs @@ -21,7 +21,7 @@ use frame_support::pallet_prelude::Get; /// both `OutboundXcmpStatus` and `InboundXcmpStatus` for defined `ParaId` if any of those is /// suspended. pub struct InAndOutXcmpChannelStatusProvider( - sp_std::marker::PhantomData<(SiblingBridgeHubParaId, Runtime)>, + core::marker::PhantomData<(SiblingBridgeHubParaId, Runtime)>, ); impl, Runtime: crate::Config> bp_xcm_bridge_hub_router::XcmChannelStatusProvider @@ -45,7 +45,7 @@ impl, Runtime: crate::Config> /// Adapter implementation for `bp_xcm_bridge_hub_router::XcmChannelStatusProvider` which checks /// only `OutboundXcmpStatus` for defined `SiblingParaId` if is suspended. pub struct OutXcmpChannelStatusProvider( - sp_std::marker::PhantomData<(SiblingBridgeHubParaId, Runtime)>, + core::marker::PhantomData<(SiblingBridgeHubParaId, Runtime)>, ); impl, Runtime: crate::Config> bp_xcm_bridge_hub_router::XcmChannelStatusProvider diff --git a/cumulus/pallets/xcmp-queue/src/lib.rs b/cumulus/pallets/xcmp-queue/src/lib.rs index 45126a9425d4c..8c4446a925d4d 100644 --- a/cumulus/pallets/xcmp-queue/src/lib.rs +++ b/cumulus/pallets/xcmp-queue/src/lib.rs @@ -50,6 +50,9 @@ pub mod bridging; pub mod weights; pub use weights::WeightInfo; +extern crate alloc; + +use alloc::vec::Vec; use bounded_collections::BoundedBTreeSet; use codec::{Decode, DecodeLimit, Encode, MaxEncodedLen}; use cumulus_primitives_core::{ @@ -69,7 +72,6 @@ use polkadot_runtime_parachains::FeeTracker; use scale_info::TypeInfo; use sp_core::MAX_POSSIBLE_ALLOCATION; use sp_runtime::{FixedU128, RuntimeDebug, Saturating, WeakBoundedVec}; -use sp_std::prelude::*; use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm, WrapVersion, MAX_XCM_DECODE_DEPTH}; use xcm_builder::InspectMessageQueues; use xcm_executor::traits::ConvertOrigin; diff --git a/cumulus/pallets/xcmp-queue/src/migration.rs b/cumulus/pallets/xcmp-queue/src/migration.rs index b64982a893029..d0657aaea9fd0 100644 --- a/cumulus/pallets/xcmp-queue/src/migration.rs +++ b/cumulus/pallets/xcmp-queue/src/migration.rs @@ -19,6 +19,7 @@ pub mod v5; use crate::{Config, OverweightIndex, Pallet, QueueConfig, QueueConfigData, DEFAULT_POV_SIZE}; +use alloc::vec::Vec; use cumulus_primitives_core::XcmpMessageFormat; use frame_support::{ pallet_prelude::*, diff --git a/cumulus/pallets/xcmp-queue/src/migration/v5.rs b/cumulus/pallets/xcmp-queue/src/migration/v5.rs index 247adab7108fa..818365f36f605 100644 --- a/cumulus/pallets/xcmp-queue/src/migration/v5.rs +++ b/cumulus/pallets/xcmp-queue/src/migration/v5.rs @@ -17,6 +17,7 @@ //! Migrates the storage to version 5. use crate::*; +use alloc::vec::Vec; use cumulus_primitives_core::ListChannelInfos; use frame_support::{pallet_prelude::*, traits::UncheckedOnRuntimeUpgrade}; diff --git a/cumulus/parachains/common/Cargo.toml b/cumulus/parachains/common/Cargo.toml index 6eac9a0967267..6d436bdf799a4 100644 --- a/cumulus/parachains/common/Cargo.toml +++ b/cumulus/parachains/common/Cargo.toml @@ -29,7 +29,6 @@ sp-consensus-aura = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } # Polkadot pallet-xcm = { workspace = true } @@ -73,7 +72,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm-executor/std", "xcm/std", ] diff --git a/cumulus/parachains/common/src/impls.rs b/cumulus/parachains/common/src/impls.rs index 16cda1a4ed838..42ea50c75a8d4 100644 --- a/cumulus/parachains/common/src/impls.rs +++ b/cumulus/parachains/common/src/impls.rs @@ -16,6 +16,8 @@ //! Auxiliary struct/enums for parachain runtimes. //! Taken from polkadot/runtime/common (at a21cd64) and adapted for parachains. +use alloc::boxed::Box; +use core::marker::PhantomData; use frame_support::traits::{ fungible, fungibles, tokens::imbalance::ResolveTo, Contains, ContainsPair, Currency, Defensive, Get, Imbalance, OnUnbalanced, OriginTrait, @@ -23,7 +25,6 @@ use frame_support::traits::{ use pallet_asset_tx_payment::HandleCredit; use pallet_collator_selection::StakingPotAccountId; use sp_runtime::traits::Zero; -use sp_std::{marker::PhantomData, prelude::*}; use xcm::latest::{ Asset, AssetId, Fungibility, Fungibility::Fungible, Junction, Junctions::Here, Location, Parent, WeightLimit, diff --git a/cumulus/parachains/common/src/lib.rs b/cumulus/parachains/common/src/lib.rs index b01d623d2b93d..3cffb69daac3f 100644 --- a/cumulus/parachains/common/src/lib.rs +++ b/cumulus/parachains/common/src/lib.rs @@ -15,6 +15,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + pub mod impls; pub mod message_queue; pub mod xcm_config; diff --git a/cumulus/parachains/common/src/message_queue.rs b/cumulus/parachains/common/src/message_queue.rs index 0c9f4b840c916..511d6243cb8c4 100644 --- a/cumulus/parachains/common/src/message_queue.rs +++ b/cumulus/parachains/common/src/message_queue.rs @@ -16,10 +16,10 @@ //! Helpers to deal with configuring the message queue in the runtime. +use core::marker::PhantomData; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::traits::{QueueFootprint, QueuePausedQuery}; use pallet_message_queue::OnQueueChanged; -use sp_std::marker::PhantomData; /// Narrow the scope of the `Inner` query from `AggregateMessageOrigin` to `ParaId`. /// diff --git a/cumulus/parachains/common/src/xcm_config.rs b/cumulus/parachains/common/src/xcm_config.rs index a9756af7aed24..7c58a2b2405c7 100644 --- a/cumulus/parachains/common/src/xcm_config.rs +++ b/cumulus/parachains/common/src/xcm_config.rs @@ -14,13 +14,13 @@ // limitations under the License. use crate::impls::AccountIdOf; +use core::marker::PhantomData; use cumulus_primitives_core::{IsSystem, ParaId}; use frame_support::{ traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, Contains, ContainsPair}, weights::Weight, }; use sp_runtime::traits::Get; -use sp_std::marker::PhantomData; use xcm::latest::prelude::*; /// A `ChargeFeeInFungibles` implementation that converts the output of diff --git a/cumulus/parachains/pallets/collective-content/Cargo.toml b/cumulus/parachains/pallets/collective-content/Cargo.toml index 61cbe78500901..c52021f67e362 100644 --- a/cumulus/parachains/pallets/collective-content/Cargo.toml +++ b/cumulus/parachains/pallets/collective-content/Cargo.toml @@ -19,7 +19,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-io = { workspace = true } @@ -48,5 +47,4 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] diff --git a/cumulus/parachains/pallets/collective-content/src/lib.rs b/cumulus/parachains/pallets/collective-content/src/lib.rs index b1c960ad6a0d3..7ea3c2d79fa79 100644 --- a/cumulus/parachains/pallets/collective-content/src/lib.rs +++ b/cumulus/parachains/pallets/collective-content/src/lib.rs @@ -46,7 +46,6 @@ pub use weights::WeightInfo; use frame_support::{traits::schedule::DispatchTime, BoundedVec}; use sp_core::ConstU32; -use sp_std::prelude::*; /// IPFS compatible CID. // Worst case 2 bytes base and codec, 2 bytes hash type and size, 64 bytes hash digest. diff --git a/cumulus/parachains/pallets/parachain-info/Cargo.toml b/cumulus/parachains/pallets/parachain-info/Cargo.toml index 7369c3a2c1576..e0bed23c4f8c0 100644 --- a/cumulus/parachains/pallets/parachain-info/Cargo.toml +++ b/cumulus/parachains/pallets/parachain-info/Cargo.toml @@ -17,7 +17,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } cumulus-primitives-core = { workspace = true } @@ -30,7 +29,6 @@ std = [ "frame-system/std", "scale-info/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/cumulus/parachains/pallets/parachain-info/src/lib.rs b/cumulus/parachains/pallets/parachain-info/src/lib.rs index a4ef448a6b6b9..0aaa7adaa51c0 100644 --- a/cumulus/parachains/pallets/parachain-info/src/lib.rs +++ b/cumulus/parachains/pallets/parachain-info/src/lib.rs @@ -41,7 +41,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, pub parachain_id: ParaId, } diff --git a/cumulus/parachains/pallets/ping/Cargo.toml b/cumulus/parachains/pallets/ping/Cargo.toml index f74328207b843..51fc384a4f140 100644 --- a/cumulus/parachains/pallets/ping/Cargo.toml +++ b/cumulus/parachains/pallets/ping/Cargo.toml @@ -13,7 +13,6 @@ workspace = true codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } @@ -33,7 +32,6 @@ std = [ "frame-system/std", "scale-info/std", "sp-runtime/std", - "sp-std/std", "xcm/std", ] diff --git a/cumulus/parachains/pallets/ping/src/lib.rs b/cumulus/parachains/pallets/ping/src/lib.rs index a738c05e0366b..729494cbd251d 100644 --- a/cumulus/parachains/pallets/ping/src/lib.rs +++ b/cumulus/parachains/pallets/ping/src/lib.rs @@ -18,12 +18,14 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_xcm::{ensure_sibling_para, Origin as CumulusOrigin}; use cumulus_primitives_core::ParaId; use frame_support::{parameter_types, BoundedVec}; use frame_system::Config as SystemConfig; use sp_runtime::traits::Saturating; -use sp_std::prelude::*; use xcm::latest::prelude::*; pub use pallet::*; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml b/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml index 9ef0aa0072c96..98df41090a407 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/Cargo.toml @@ -53,7 +53,6 @@ sp-genesis-builder = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -241,7 +240,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index e8772c0b48303..f09647854cd01 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -27,6 +27,9 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use assets_common::{ foreign_creators::ForeignCreators, local_and_foreign_assets::{LocalFromLeft, TargetFromLeft}, @@ -45,7 +48,6 @@ use sp_runtime::{ }; use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -1161,7 +1163,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -1445,7 +1447,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } @@ -1515,7 +1517,7 @@ impl_runtime_apis! { } fn set_up_complex_asset_transfer( - ) -> Option<(XcmAssets, u32, Location, Box)> { + ) -> Option<(XcmAssets, u32, Location, alloc::boxed::Box)> { // Transfer to Relay some local AH asset (local-reserve-transfer) while paying // fees using teleported native token. // (We don't care that Relay doesn't accept incoming unknown AH local asset) @@ -1550,7 +1552,7 @@ impl_runtime_apis! { let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 }; // verify transferred successfully - let verify = Box::new(move || { + let verify = alloc::boxed::Box::new(move || { // verify native balance after transfer, decreased by transferred fee amount // (plus transport fees) assert!(Balances::free_balance(&who) <= balance - fee_amount); @@ -1584,7 +1586,7 @@ impl_runtime_apis! { let bridged_asset_hub = xcm_config::bridging::to_westend::AssetHubWestend::get(); let _ = PolkadotXcm::force_xcm_version( RuntimeOrigin::root(), - Box::new(bridged_asset_hub.clone()), + alloc::boxed::Box::new(bridged_asset_hub.clone()), XCM_VERSION, ).map_err(|e| { log::error!( diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/cumulus_pallet_parachain_system.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/cumulus_pallet_parachain_system.rs index c1e5c6a742939..fc63a0814d0a4 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/cumulus_pallet_parachain_system.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/cumulus_pallet_parachain_system.rs @@ -47,7 +47,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_parachain_system`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_message_queue.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_message_queue.rs index 45531ccfa797c..cd72703104ad0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_message_queue.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_message_queue.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_message_queue`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs index 8e675ad0cf8e6..8c52ecd9f1b1f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/mod.rs @@ -18,10 +18,10 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use alloc::vec::Vec; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 7fab35842509d..03d3785dccbd7 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::fungible`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 4454494badcbf..bee6bcdf21cf3 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index 03de2c971b7ff..c736d3ee44204 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -511,8 +511,8 @@ impl pallet_assets::BenchmarkHelper for XcmBenchmarkHelper { /// All configuration related to bridging pub mod bridging { use super::*; + use alloc::collections::btree_set::BTreeSet; use assets_common::matching; - use sp_std::collections::btree_set::BTreeSet; // common/shared parameters parameter_types! { @@ -541,13 +541,13 @@ pub mod bridging { /// (`AssetId` has to be aligned with `BridgeTable`) pub XcmBridgeHubRouterFeeAssetId: AssetId = TokenLocation::get().into(); - pub BridgeTable: sp_std::vec::Vec = - sp_std::vec::Vec::new().into_iter() + pub BridgeTable: alloc::vec::Vec = + alloc::vec::Vec::new().into_iter() .chain(to_westend::BridgeTable::get()) .collect(); - pub EthereumBridgeTable: sp_std::vec::Vec = - sp_std::vec::Vec::new().into_iter() + pub EthereumBridgeTable: alloc::vec::Vec = + alloc::vec::Vec::new().into_iter() .chain(to_ethereum::BridgeTable::get()) .collect(); } @@ -578,10 +578,10 @@ pub mod bridging { /// Set up exporters configuration. /// `Option` represents static "base fee" which is used for total delivery fee calculation. - pub BridgeTable: sp_std::vec::Vec = sp_std::vec![ + pub BridgeTable: alloc::vec::Vec = alloc::vec![ NetworkExportTableItem::new( WestendNetwork::get(), - Some(sp_std::vec![ + Some(alloc::vec![ AssetHubWestend::get().interior.split_global().expect("invalid configuration for AssetHubWestend").1, ]), SiblingBridgeHub::get(), @@ -595,7 +595,7 @@ pub mod bridging { /// Universal aliases pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( - sp_std::vec![ + alloc::vec![ (SiblingBridgeHubWithBridgeHubWestendInstance::get(), GlobalConsensus(WestendNetwork::get())) ] ); @@ -643,10 +643,10 @@ pub mod bridging { /// Set up exporters configuration. /// `Option` represents static "base fee" which is used for total delivery fee calculation. - pub BridgeTable: sp_std::vec::Vec = sp_std::vec![ + pub BridgeTable: alloc::vec::Vec = alloc::vec![ NetworkExportTableItem::new( EthereumNetwork::get(), - Some(sp_std::vec![Junctions::Here]), + Some(alloc::vec![Junctions::Here]), SiblingBridgeHub::get(), Some(( XcmBridgeHubRouterFeeAssetId::get(), @@ -657,7 +657,7 @@ pub mod bridging { /// Universal aliases pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( - sp_std::vec![ + alloc::vec![ (SiblingBridgeHubWithEthereumInboundQueueInstance::get(), GlobalConsensus(EthereumNetwork::get())), ] ); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs index f670c5f424efe..ee1461b7f9c85 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs @@ -34,6 +34,7 @@ use asset_test_utils::{ ExtBuilder, SlotDurations, }; use codec::{Decode, Encode}; +use core::ops::Mul; use cumulus_primitives_utility::ChargeWeightInFungibles; use frame_support::{ assert_noop, assert_ok, @@ -48,7 +49,6 @@ use frame_support::{ use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance}; use sp_consensus_aura::SlotDuration; use sp_runtime::traits::MaybeEquivalence; -use sp_std::ops::Mul; use std::convert::Into; use testnet_parachains_constants::rococo::{consensus::*, currency::UNITS, fee::WeightToFee}; use xcm::latest::prelude::{Assets as XcmAssets, *}; @@ -1277,7 +1277,7 @@ mod asset_hub_rococo_tests { collator_session_keys(), bridging_to_asset_hub_westend, || { - sp_std::vec![ + vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Xcm, @@ -1287,16 +1287,16 @@ mod asset_hub_rococo_tests { bp_asset_hub_rococo::XcmBridgeHubRouterCall::report_bridge_status { bridge_id: Default::default(), is_congested: true, - } + }, ) .encode() .into(), - } + }, ] .into() }, || { - sp_std::vec![ + vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Xcm, @@ -1306,11 +1306,11 @@ mod asset_hub_rococo_tests { bp_asset_hub_rococo::XcmBridgeHubRouterCall::report_bridge_status { bridge_id: Default::default(), is_congested: false, - } + }, ) .encode() .into(), - } + }, ] .into() }, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml b/cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml index 7e618d950b19a..6b1bf769ace35 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/Cargo.toml @@ -53,7 +53,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -240,7 +239,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 55c8a9f0b265d..178b886fc3e84 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -27,6 +27,9 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use assets_common::{ local_and_foreign_assets::{LocalFromLeft, TargetFromLeft}, AssetIdForTrustBackedAssetsConvert, @@ -68,7 +71,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Perbill, Permill, RuntimeDebug, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -1206,7 +1208,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -1536,7 +1538,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } @@ -1601,7 +1603,7 @@ impl_runtime_apis! { } fn set_up_complex_asset_transfer( - ) -> Option<(XcmAssets, u32, Location, Box)> { + ) -> Option<(XcmAssets, u32, Location, alloc::boxed::Box)> { // Transfer to Relay some local AH asset (local-reserve-transfer) while paying // fees using teleported native token. // (We don't care that Relay doesn't accept incoming unknown AH local asset) @@ -1636,7 +1638,7 @@ impl_runtime_apis! { let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 }; // verify transferred successfully - let verify = Box::new(move || { + let verify = alloc::boxed::Box::new(move || { // verify native balance after transfer, decreased by transferred fee amount // (plus transport fees) assert!(Balances::free_balance(&who) <= balance - fee_amount); @@ -1675,7 +1677,7 @@ impl_runtime_apis! { let bridged_asset_hub = xcm_config::bridging::to_rococo::AssetHubRococo::get(); let _ = PolkadotXcm::force_xcm_version( RuntimeOrigin::root(), - Box::new(bridged_asset_hub.clone()), + alloc::boxed::Box::new(bridged_asset_hub.clone()), XCM_VERSION, ).map_err(|e| { log::error!( diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_parachain_system.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_parachain_system.rs index c1e5c6a742939..fc63a0814d0a4 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_parachain_system.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_parachain_system.rs @@ -47,7 +47,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_parachain_system`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_message_queue.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_message_queue.rs index 45531ccfa797c..cd72703104ad0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_message_queue.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_message_queue.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_message_queue`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 8c77774da2dd7..d39052c5c03b8 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -17,10 +17,10 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use alloc::vec::Vec; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index eaf07aac52cef..fe8d186139256 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -42,7 +42,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::fungible`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index fc196abea0f5e..127bc173c1037 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -42,7 +42,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index fc2e68c599fd1..2deeb73eb127b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -519,8 +519,8 @@ impl pallet_assets::BenchmarkHelper for XcmBenchmarkHelper { /// All configuration related to bridging pub mod bridging { use super::*; + use alloc::collections::btree_set::BTreeSet; use assets_common::matching; - use sp_std::collections::btree_set::BTreeSet; parameter_types! { /// Base price of every byte of the Westend -> Rococo message. Can be adjusted via @@ -548,8 +548,8 @@ pub mod bridging { /// (`AssetId` has to be aligned with `BridgeTable`) pub XcmBridgeHubRouterFeeAssetId: AssetId = WestendLocation::get().into(); - pub BridgeTable: sp_std::vec::Vec = - sp_std::vec::Vec::new().into_iter() + pub BridgeTable: alloc::vec::Vec = + alloc::vec::Vec::new().into_iter() .chain(to_rococo::BridgeTable::get()) .collect(); } @@ -580,10 +580,10 @@ pub mod bridging { /// Set up exporters configuration. /// `Option` represents static "base fee" which is used for total delivery fee calculation. - pub BridgeTable: sp_std::vec::Vec = sp_std::vec![ + pub BridgeTable: alloc::vec::Vec = alloc::vec![ NetworkExportTableItem::new( RococoNetwork::get(), - Some(sp_std::vec![ + Some(alloc::vec![ AssetHubRococo::get().interior.split_global().expect("invalid configuration for AssetHubRococo").1, ]), SiblingBridgeHub::get(), @@ -597,7 +597,7 @@ pub mod bridging { /// Universal aliases pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( - sp_std::vec![ + alloc::vec![ (SiblingBridgeHubWithBridgeHubRococoInstance::get(), GlobalConsensus(RococoNetwork::get())) ] ); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs index b5957dd5df92f..48e6c11d268c7 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs @@ -1258,7 +1258,7 @@ fn report_bridge_status_from_xcm_bridge_router_for_rococo_works() { collator_session_keys(), bridging_to_asset_hub_rococo, || { - sp_std::vec![ + vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Xcm, @@ -1268,16 +1268,16 @@ fn report_bridge_status_from_xcm_bridge_router_for_rococo_works() { bp_asset_hub_westend::XcmBridgeHubRouterCall::report_bridge_status { bridge_id: Default::default(), is_congested: true, - } + }, ) .encode() .into(), - } + }, ] .into() }, || { - sp_std::vec![ + vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Xcm, @@ -1287,11 +1287,11 @@ fn report_bridge_status_from_xcm_bridge_router_for_rococo_works() { bp_asset_hub_westend::XcmBridgeHubRouterCall::report_bridge_status { bridge_id: Default::default(), is_congested: false, - } + }, ) .encode() .into(), - } + }, ] .into() }, diff --git a/cumulus/parachains/runtimes/assets/common/Cargo.toml b/cumulus/parachains/runtimes/assets/common/Cargo.toml index 94612506f510e..c6740269339d8 100644 --- a/cumulus/parachains/runtimes/assets/common/Cargo.toml +++ b/cumulus/parachains/runtimes/assets/common/Cargo.toml @@ -18,7 +18,6 @@ impl-trait-for-tuples = { workspace = true } # Substrate frame-support = { workspace = true } sp-api = { workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } pallet-asset-conversion = { workspace = true } @@ -48,7 +47,6 @@ std = [ "scale-info/std", "sp-api/std", "sp-runtime/std", - "sp-std/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/cumulus/parachains/runtimes/assets/common/src/benchmarks.rs b/cumulus/parachains/runtimes/assets/common/src/benchmarks.rs index 44bda1eb3709c..d59fddc4e8f02 100644 --- a/cumulus/parachains/runtimes/assets/common/src/benchmarks.rs +++ b/cumulus/parachains/runtimes/assets/common/src/benchmarks.rs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +use core::marker::PhantomData; use cumulus_primitives_core::ParaId; use sp_runtime::traits::Get; -use sp_std::marker::PhantomData; use xcm::latest::prelude::*; /// Creates asset pairs for liquidity pools with `Target` always being the first asset. diff --git a/cumulus/parachains/runtimes/assets/common/src/foreign_creators.rs b/cumulus/parachains/runtimes/assets/common/src/foreign_creators.rs index a9fd79bf939f5..95edb31da06e5 100644 --- a/cumulus/parachains/runtimes/assets/common/src/foreign_creators.rs +++ b/cumulus/parachains/runtimes/assets/common/src/foreign_creators.rs @@ -23,7 +23,7 @@ use xcm_executor::traits::ConvertLocation; /// `EnsureOriginWithArg` impl for `CreateOrigin` that allows only XCM origins that are locations /// containing the class location. pub struct ForeignCreators( - sp_std::marker::PhantomData<(IsForeign, AccountOf, AccountId, L)>, + core::marker::PhantomData<(IsForeign, AccountOf, AccountId, L)>, ); impl< IsForeign: ContainsPair, @@ -41,7 +41,7 @@ where fn try_origin( origin: RuntimeOrigin, asset_location: &L, - ) -> sp_std::result::Result { + ) -> core::result::Result { let origin_location = EnsureXcm::::try_origin(origin.clone())?; if !IsForeign::contains(asset_location, &origin_location) { return Err(origin) diff --git a/cumulus/parachains/runtimes/assets/common/src/fungible_conversion.rs b/cumulus/parachains/runtimes/assets/common/src/fungible_conversion.rs index e21203485a764..27ee2d6b5653c 100644 --- a/cumulus/parachains/runtimes/assets/common/src/fungible_conversion.rs +++ b/cumulus/parachains/runtimes/assets/common/src/fungible_conversion.rs @@ -16,9 +16,10 @@ //! Runtime API definition for assets. use crate::runtime_api::FungiblesAccessError; +use alloc::vec::Vec; +use core::borrow::Borrow; use frame_support::traits::Contains; use sp_runtime::traits::MaybeEquivalence; -use sp_std::{borrow::Borrow, vec::Vec}; use xcm::latest::{Asset, Location}; use xcm_builder::{ConvertedConcreteId, MatchedConvertedConcreteId}; use xcm_executor::traits::MatchesFungibles; diff --git a/cumulus/parachains/runtimes/assets/common/src/lib.rs b/cumulus/parachains/runtimes/assets/common/src/lib.rs index 431b5766147ae..4bb593f98929e 100644 --- a/cumulus/parachains/runtimes/assets/common/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/common/src/lib.rs @@ -23,6 +23,8 @@ pub mod local_and_foreign_assets; pub mod matching; pub mod runtime_api; +extern crate alloc; + use crate::matching::{LocalLocationPattern, ParentLocation}; use frame_support::traits::{Equals, EverythingBut}; use parachains_common::{AssetIdForTrustBackedAssets, CollectionId, ItemId}; diff --git a/cumulus/parachains/runtimes/assets/common/src/local_and_foreign_assets.rs b/cumulus/parachains/runtimes/assets/common/src/local_and_foreign_assets.rs index 58f5d2d57a766..8a89089c71877 100644 --- a/cumulus/parachains/runtimes/assets/common/src/local_and_foreign_assets.rs +++ b/cumulus/parachains/runtimes/assets/common/src/local_and_foreign_assets.rs @@ -13,13 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +use core::marker::PhantomData; use frame_support::traits::Get; use sp_runtime::{ traits::{Convert, MaybeEquivalence}, Either, Either::{Left, Right}, }; -use sp_std::marker::PhantomData; use xcm::latest::Location; /// Converts a given [`Location`] to [`Either::Left`] when equal to `Target`, or diff --git a/cumulus/parachains/runtimes/assets/common/src/matching.rs b/cumulus/parachains/runtimes/assets/common/src/matching.rs index f356cb541315f..9bb35d0c5328b 100644 --- a/cumulus/parachains/runtimes/assets/common/src/matching.rs +++ b/cumulus/parachains/runtimes/assets/common/src/matching.rs @@ -28,7 +28,7 @@ frame_support::parameter_types! { } /// Accepts an asset if it is from the origin. -pub struct IsForeignConcreteAsset(sp_std::marker::PhantomData); +pub struct IsForeignConcreteAsset(core::marker::PhantomData); impl> ContainsPair for IsForeignConcreteAsset { @@ -41,7 +41,7 @@ impl> ContainsPair /// Checks if `a` is from sibling location `b`. Checks that `Location-a` starts with /// `Location-b`, and that the `ParaId` of `b` is not equal to `a`. pub struct FromSiblingParachain( - sp_std::marker::PhantomData<(SelfParaId, L)>, + core::marker::PhantomData<(SelfParaId, L)>, ); impl, L: TryFrom + TryInto + Clone> ContainsPair for FromSiblingParachain @@ -65,7 +65,7 @@ impl, L: TryFrom + TryInto + Clone> /// Checks if `a` is from the expected global consensus network. Checks that `Location-a` /// starts with `Location-b`, and that network is a foreign consensus system. pub struct FromNetwork( - sp_std::marker::PhantomData<(UniversalLocation, ExpectedNetworkId, L)>, + core::marker::PhantomData<(UniversalLocation, ExpectedNetworkId, L)>, ); impl< UniversalLocation: Get, @@ -100,7 +100,7 @@ impl< /// Accept an asset if it is native to `AssetsAllowedNetworks` and it is coming from /// `OriginLocation`. pub struct RemoteAssetFromLocation( - sp_std::marker::PhantomData<(AssetsAllowedNetworks, OriginLocation)>, + core::marker::PhantomData<(AssetsAllowedNetworks, OriginLocation)>, ); impl, OriginLocation: Get> ContainsPair for RemoteAssetFromLocation diff --git a/cumulus/parachains/runtimes/assets/common/src/runtime_api.rs b/cumulus/parachains/runtimes/assets/common/src/runtime_api.rs index 19977cbedab07..799b2f45b4dfb 100644 --- a/cumulus/parachains/runtimes/assets/common/src/runtime_api.rs +++ b/cumulus/parachains/runtimes/assets/common/src/runtime_api.rs @@ -18,7 +18,7 @@ use codec::{Codec, Decode, Encode}; use sp_runtime::RuntimeDebug; #[cfg(feature = "std")] -use {sp_std::vec::Vec, xcm::latest::Asset}; +use {alloc::vec::Vec, xcm::latest::Asset}; /// The possible errors that can happen querying the storage of assets. #[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)] diff --git a/cumulus/parachains/runtimes/assets/test-utils/Cargo.toml b/cumulus/parachains/runtimes/assets/test-utils/Cargo.toml index a7aad361e84e1..529d6460fc4e4 100644 --- a/cumulus/parachains/runtimes/assets/test-utils/Cargo.toml +++ b/cumulus/parachains/runtimes/assets/test-utils/Cargo.toml @@ -21,7 +21,6 @@ pallet-timestamp = { workspace = true } pallet-session = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } # Cumulus cumulus-pallet-parachain-system = { workspace = true } @@ -68,7 +67,6 @@ std = [ "parachains-runtimes-test-utils/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_bulletin_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_bulletin_config.rs index 39ea636925528..d97e6a1d88e1b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_bulletin_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_bulletin_config.rs @@ -87,7 +87,7 @@ parameter_types! { XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, ); /// All active routes and their destinations. - pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![ + pub ActiveLanes: alloc::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = alloc::vec![ ( FromRococoPeopleToRococoBulletinRoute::get(), (RococoBulletinGlobalConsensusNetwork::get(), Here) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_westend_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_westend_config.rs index 07bb718bd13d6..fe854e20c2445 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_westend_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_westend_config.rs @@ -71,7 +71,7 @@ parameter_types! { ParentThen([Parachain(AssetHubRococoParaId::get().into())].into()).into(), XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, ); - pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![ + pub ActiveLanes: alloc::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = alloc::vec![ ( FromAssetHubRococoToAssetHubWestendRoute::get(), (WestendGlobalConsensusNetwork::get(), [Parachain(AssetHubWestendParaId::get().into())].into()) @@ -91,8 +91,8 @@ parameter_types! { } pub const XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND: LaneId = LaneId([0, 0, 0, 2]); -fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec> { - sp_std::vec![ +fn build_congestion_message(is_congested: bool) -> alloc::vec::Vec> { + alloc::vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Xcm, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 8ca5898d1a104..512c1199f4392 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -35,6 +35,9 @@ pub mod bridge_to_westend_config; mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use bridge_runtime_common::extensions::{ check_obsolete_extension::{ CheckAndBoostBridgeGrandpaTransactions, CheckAndBoostBridgeParachainsTransactions, @@ -58,7 +61,6 @@ use sp_runtime::{ ApplyExtrinsicResult, FixedU128, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -110,6 +112,8 @@ use parachains_common::{ AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO, }; +#[cfg(feature = "runtime-benchmarks")] +use alloc::boxed::Box; #[cfg(feature = "runtime-benchmarks")] use benchmark_helpers::DoNothingRouter; @@ -862,7 +866,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -1197,7 +1201,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/cumulus_pallet_parachain_system.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/cumulus_pallet_parachain_system.rs index dc480c391636a..8fcd7b10d931b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/cumulus_pallet_parachain_system.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/cumulus_pallet_parachain_system.rs @@ -47,7 +47,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_parachain_system`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_message_queue.rs index 2fcd573ceb277..b6fee47d14351 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_message_queue.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_message_queue`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index 4f5bae0fe597b..b40cbfeeb8f27 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -17,11 +17,11 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use alloc::vec::Vec; use codec::Encode; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index d7e8c41ff8ac4..057dc4313510f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::fungible`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index bafc973bdac44..9c58072d402c9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index a0d2e91dffd2e..5ec545ee0590f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -22,6 +22,7 @@ use super::{ use bp_messages::LaneId; use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams}; use bp_runtime::ChainId; +use core::marker::PhantomData; use frame_support::{ parameter_types, traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing}, @@ -41,7 +42,6 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice; use snowbridge_runtime_common::XcmExportFeeToSibling; use sp_core::Get; use sp_runtime::traits::AccountIdConversion; -use sp_std::marker::PhantomData; use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; use xcm::latest::prelude::*; use xcm_builder::{ diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_rococo_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_rococo_config.rs index 09d55f4323ab5..42d5ef3eebdb3 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_rococo_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_rococo_config.rs @@ -78,7 +78,7 @@ parameter_types! { ParentThen([Parachain(AssetHubWestendParaId::get().into())].into()).into(), XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO, ); - pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![ + pub ActiveLanes: alloc::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = alloc::vec![ ( FromAssetHubWestendToAssetHubRococoRoute::get(), (RococoGlobalConsensusNetwork::get(), [Parachain(AssetHubRococoParaId::get().into())].into()) @@ -98,8 +98,8 @@ parameter_types! { } pub const XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO: LaneId = LaneId([0, 0, 0, 2]); -fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec> { - sp_std::vec![ +fn build_congestion_message(is_congested: bool) -> alloc::vec::Vec> { + alloc::vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Xcm, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 993f604324587..5d4c35d6610a0 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -32,6 +32,9 @@ pub mod bridge_to_rococo_config; mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use bridge_runtime_common::extensions::{ check_obsolete_extension::{ CheckAndBoostBridgeGrandpaTransactions, CheckAndBoostBridgeParachainsTransactions, @@ -49,7 +52,6 @@ use sp_runtime::{ ApplyExtrinsicResult, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -612,7 +614,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -886,7 +888,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } @@ -928,7 +930,7 @@ impl_runtime_apis! { } fn set_up_complex_asset_transfer( - ) -> Option<(Assets, u32, Location, Box)> { + ) -> Option<(Assets, u32, Location, alloc::boxed::Box)> { // BH only supports teleports to system parachain. // Relay/native token can be teleported between BH and Relay. let native_location = Parent.into(); @@ -1051,7 +1053,7 @@ impl_runtime_apis! { // save XCM version for remote bridge hub let _ = PolkadotXcm::force_xcm_version( RuntimeOrigin::root(), - Box::new(bridge_to_rococo_config::BridgeHubRococoLocation::get()), + alloc::boxed::Box::new(bridge_to_rococo_config::BridgeHubRococoLocation::get()), XCM_VERSION, ).map_err(|e| { log::error!( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/cumulus_pallet_parachain_system.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/cumulus_pallet_parachain_system.rs index dc480c391636a..8fcd7b10d931b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/cumulus_pallet_parachain_system.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/cumulus_pallet_parachain_system.rs @@ -47,7 +47,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_parachain_system`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_message_queue.rs index 2fcd573ceb277..b6fee47d14351 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_message_queue.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_message_queue`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs index e8950678b40fd..3961cc6d5cdd6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/mod.rs @@ -18,11 +18,11 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use alloc::vec::Vec; use codec::Encode; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 295abd481d7dc..4310b24564758 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::fungible`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 73bea66bf7107..ba434ff29629f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml index fd0eed1c05a1a..3ae43075000ba 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml @@ -10,7 +10,6 @@ license = "Apache-2.0" codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } frame-support = { workspace = true } -sp-std = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } cumulus-primitives-core = { workspace = true } @@ -29,7 +28,6 @@ std = [ "snowbridge-core/std", "sp-core/std", "sp-runtime/std", - "sp-std/std", "xcm/std", ] diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs index c1bba65b0abc3..5f91897262f4b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs @@ -14,6 +14,7 @@ // limitations under the License. //! Runtime configuration for MessageQueue pallet use codec::{Decode, Encode, MaxEncodedLen}; +use core::marker::PhantomData; use cumulus_primitives_core::{AggregateMessageOrigin as CumulusAggregateMessageOrigin, ParaId}; use frame_support::{ traits::{ProcessMessage, ProcessMessageError, QueueFootprint, QueuePausedQuery}, @@ -22,7 +23,6 @@ use frame_support::{ use pallet_message_queue::OnQueueChanged; use scale_info::TypeInfo; use snowbridge_core::ChannelId; -use sp_std::{marker::PhantomData, prelude::*}; use xcm::v4::{Junction, Location}; /// The aggregate origin of an inbound message. diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml index fb96d29a497a3..44a8646142d6c 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml @@ -21,7 +21,6 @@ sp-core = { workspace = true } sp-io = { workspace = true } sp-keyring = { workspace = true, default-features = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-tracing = { workspace = true, default-features = true } pallet-balances = { workspace = true } pallet-utility = { workspace = true } @@ -81,7 +80,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs index 1874f38de2df1..0b3463f0df974 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs @@ -19,6 +19,8 @@ pub mod test_cases; pub mod test_data; +extern crate alloc; + pub use bp_test_utils::test_header; pub use parachains_runtimes_test_utils::*; use sp_runtime::Perbill; diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_grandpa_chain.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_grandpa_chain.rs index 8f3c7de61f840..d6dfa93731a7d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_grandpa_chain.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_grandpa_chain.rs @@ -22,6 +22,7 @@ use crate::{ test_data, }; +use alloc::{boxed::Box, vec}; use bp_header_chain::ChainWithGrandpa; use bp_messages::{LaneId, UnrewardedRelayersState}; use bp_relayers::{RewardsAccountOwner, RewardsAccountParams}; @@ -61,7 +62,7 @@ pub trait WithRemoteGrandpaChainHelper { /// Adapter struct that implements [`WithRemoteGrandpaChainHelper`]. pub struct WithRemoteGrandpaChainHelperAdapter( - sp_std::marker::PhantomData<(Runtime, AllPalletsWithoutSystem, GPI, MPI)>, + core::marker::PhantomData<(Runtime, AllPalletsWithoutSystem, GPI, MPI)>, ); impl WithRemoteGrandpaChainHelper diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_parachain.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_parachain.rs index 6580648e66063..728b4e76b1055 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_parachain.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_parachain.rs @@ -22,6 +22,7 @@ use crate::{ test_data, }; +use alloc::{boxed::Box, vec}; use bp_header_chain::ChainWithGrandpa; use bp_messages::{LaneId, UnrewardedRelayersState}; use bp_polkadot_core::parachains::ParaHash; @@ -66,7 +67,7 @@ pub trait WithRemoteParachainHelper { /// Adapter struct that implements `WithRemoteParachainHelper`. pub struct WithRemoteParachainHelperAdapter( - sp_std::marker::PhantomData<(Runtime, AllPalletsWithoutSystem, GPI, PPI, MPI)>, + core::marker::PhantomData<(Runtime, AllPalletsWithoutSystem, GPI, PPI, MPI)>, ); impl WithRemoteParachainHelper diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/helpers.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/helpers.rs index c990c6e5307cb..78b8a170f0d4b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/helpers.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/helpers.rs @@ -23,6 +23,7 @@ use bp_messages::{LaneId, MessageNonce}; use bp_polkadot_core::parachains::{ParaHash, ParaId}; use bp_relayers::RewardsAccountParams; use codec::Decode; +use core::marker::PhantomData; use frame_support::{ assert_ok, traits::{OnFinalize, OnInitialize, PalletInfoAccess}, @@ -37,7 +38,6 @@ use parachains_runtimes_test_utils::{ use sp_core::Get; use sp_keyring::AccountKeyring::*; use sp_runtime::{traits::TrailingZeroInput, AccountId32}; -use sp_std::marker::PhantomData; use xcm::latest::prelude::*; /// Verify that the transaction has succeeded. @@ -290,7 +290,7 @@ pub fn relayed_incoming_message_works( // value here is tricky - there are several transaction payment pallets and we don't // want to introduce additional bounds and traits here just for that, so let's just // select some presumably large value - sp_std::cmp::max::(Runtime::ExistentialDeposit::get(), 1u32.into()) * + core::cmp::max::(Runtime::ExistentialDeposit::get(), 1u32.into()) * 100_000_000u32.into(), )], || { diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml b/cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml index 87cf42ba87d83..43fc9083937c3 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/Cargo.toml @@ -54,7 +54,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -229,7 +228,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/impls.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/impls.rs index e5b176fc77873..ed5d4870e4a6d 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/impls.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/impls.rs @@ -14,6 +14,8 @@ // limitations under the License. use crate::OriginCaller; +use alloc::boxed::Box; +use core::{cmp::Ordering, marker::PhantomData}; use frame_support::{ dispatch::DispatchResultWithPostInfo, traits::{Currency, PrivilegeCmp}, @@ -21,7 +23,6 @@ use frame_support::{ }; use pallet_alliance::{ProposalIndex, ProposalProvider}; use sp_runtime::DispatchError; -use sp_std::{cmp::Ordering, marker::PhantomData, prelude::*}; type AccountIdOf = ::AccountId; diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index f37af88c28436..d843d6f6f776e 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -42,8 +42,12 @@ mod weights; pub mod xcm_config; // Fellowship configurations. pub mod fellowship; + +extern crate alloc; + pub use ambassador::pallet_ambassador_origins; +use alloc::{vec, vec::Vec}; use ambassador::AmbassadorCoreInstance; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use fellowship::{pallet_fellowship_origins, Fellows, FellowshipCoreInstance}; @@ -57,7 +61,6 @@ use sp_runtime::{ ApplyExtrinsicResult, Perbill, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -837,7 +840,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -1047,7 +1050,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } @@ -1096,7 +1099,7 @@ impl_runtime_apis! { } fn set_up_complex_asset_transfer( - ) -> Option<(Assets, u32, Location, Box)> { + ) -> Option<(Assets, u32, Location, alloc::boxed::Box)> { // Collectives only supports teleports to system parachain. // Relay/native token can be teleported between Collectives and Relay. let native_location = Parent.into(); diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/cumulus_pallet_parachain_system.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/cumulus_pallet_parachain_system.rs index 0b7a2fc21cde4..92c8c88b51547 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/cumulus_pallet_parachain_system.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/cumulus_pallet_parachain_system.rs @@ -47,7 +47,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_parachain_system`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_message_queue.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_message_queue.rs index 4bd71c4e7d497..0bb6d3d0f1c45 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_message_queue.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_message_queue.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_message_queue`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/Cargo.toml b/cumulus/parachains/runtimes/contracts/contracts-rococo/Cargo.toml index 4fb4bcde02351..1fcebb3f16a96 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/Cargo.toml @@ -31,7 +31,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -133,7 +132,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index d2fe0689f5155..47ce6f3628ecd 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -29,6 +29,9 @@ mod contracts; mod weights; mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use cumulus_primitives_core::AggregateMessageOrigin; use sp_api::impl_runtime_apis; @@ -40,7 +43,6 @@ use sp_runtime::{ ApplyExtrinsicResult, Perbill, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -487,7 +489,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -765,7 +767,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } @@ -815,7 +817,7 @@ impl_runtime_apis! { } fn set_up_complex_asset_transfer( - ) -> Option<(Assets, u32, Location, Box)> { + ) -> Option<(Assets, u32, Location, alloc::boxed::Box)> { // Contracts-System-Para only supports teleports to system parachain. // Relay/native token can be teleported between Contracts-System-Para and Relay. let native_location = Parent.into(); diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml b/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml index 57a0782b1ef66..2920bc428d90b 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml @@ -49,7 +49,6 @@ sp-genesis-builder = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -133,7 +132,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index 6e36539c7bf79..9fd0093840d3f 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -33,6 +33,9 @@ mod coretime; mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::{ @@ -66,7 +69,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -552,7 +554,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -774,7 +776,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs index 9f79cea831aed..b8db473f10662 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/mod.rs @@ -18,10 +18,10 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use alloc::vec::Vec; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 7ff1cce2e0723..73a7198053070 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::fungible`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 16412eb49a526..676048f92ad93 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml b/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml index d3bf6b43a7ed7..07a4332800d7f 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml @@ -48,7 +48,6 @@ sp-genesis-builder = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -131,7 +130,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 74fdd971f5ce0..7907f252cf8e4 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -33,6 +33,9 @@ mod coretime; mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::{ @@ -66,7 +69,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -543,7 +545,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -765,7 +767,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs index 99af88812da2b..f35f7bfc188dc 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/mod.rs @@ -17,10 +17,10 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use alloc::vec::Vec; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 8e1461c4a99e2..ddfc599fa579d 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::fungible`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 9657fa55c1f2f..7390f35e39740 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -43,7 +43,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/glutton/glutton-westend/Cargo.toml b/cumulus/parachains/runtimes/glutton/glutton-westend/Cargo.toml index c201c8375be0d..d20b62a557b95 100644 --- a/cumulus/parachains/runtimes/glutton/glutton-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/glutton/glutton-westend/Cargo.toml @@ -35,7 +35,6 @@ pallet-message-queue = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -109,7 +108,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs b/cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs index a204bb7276cfe..1b505ad3acbf7 100644 --- a/cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs @@ -47,6 +47,9 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); pub mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -57,7 +60,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -345,7 +347,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -455,7 +457,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } diff --git a/cumulus/parachains/runtimes/people/people-rococo/Cargo.toml b/cumulus/parachains/runtimes/people/people-rococo/Cargo.toml index 890de672e0b5e..a732bec2352d2 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/people/people-rococo/Cargo.toml @@ -45,7 +45,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -128,7 +127,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index ff31aba8a2771..4f007c3fc39db 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -22,6 +22,9 @@ pub mod people; mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::{ @@ -59,7 +62,6 @@ use sp_runtime::{ ApplyExtrinsicResult, }; pub use sp_runtime::{MultiAddress, Perbill, Permill}; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -521,7 +523,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -737,7 +739,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/people.rs b/cumulus/parachains/runtimes/people/people-rococo/src/people.rs index 88a89711019d5..8211447d68c8a 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/people.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/people.rs @@ -28,7 +28,6 @@ use sp_runtime::{ traits::{AccountIdConversion, Verify}, RuntimeDebug, }; -use sp_std::prelude::*; parameter_types! { // 27 | Min encoded size of `Registration` @@ -94,8 +93,8 @@ pub enum IdentityField { )] #[codec(mel_bound())] pub struct IdentityInfo { - /// A reasonable display name for the controller of the account. This should be whatever the - /// account is typically known as and should not be confusable with other entities, given + /// A reasonable display name for the controller of the account. This should be whatever the + /// account is typically known as and should not be confusable with other entities, given /// reasonable context. /// /// Stored as UTF-8. @@ -151,7 +150,7 @@ impl IdentityInformationProvider for IdentityInfo { #[cfg(feature = "runtime-benchmarks")] fn create_identity_info() -> Self { - let data = Data::Raw(vec![0; 32].try_into().unwrap()); + let data = Data::Raw(alloc::vec![0; 32].try_into().unwrap()); IdentityInfo { display: data.clone(), diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/cumulus_pallet_parachain_system.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/cumulus_pallet_parachain_system.rs index fcea5fd1bf679..5715d56c21868 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/cumulus_pallet_parachain_system.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/cumulus_pallet_parachain_system.rs @@ -20,7 +20,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_parachain_system`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_message_queue.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_message_queue.rs index fe1911b77a72d..47c6790140736 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_message_queue.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_message_queue.rs @@ -20,7 +20,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_message_queue`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs index 4afd65bdcfea1..11c1bad9aa178 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/mod.rs @@ -17,10 +17,10 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use alloc::vec::Vec; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index b279399e7a96b..2364798596d50 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -42,7 +42,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::fungible`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index e2be324ee2d48..a50c8860c48f8 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -42,7 +42,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/people/people-westend/Cargo.toml b/cumulus/parachains/runtimes/people/people-westend/Cargo.toml index 83068e489d2eb..20c7e691ebc88 100644 --- a/cumulus/parachains/runtimes/people/people-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/people/people-westend/Cargo.toml @@ -45,7 +45,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -127,7 +126,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index 6adaa4b4e5020..1378324ce7b02 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -22,6 +22,9 @@ pub mod people; mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::{ @@ -59,7 +62,6 @@ use sp_runtime::{ ApplyExtrinsicResult, }; pub use sp_runtime::{MultiAddress, Perbill, Permill}; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -521,7 +523,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -737,7 +739,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime { - fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + fn setup_set_code_requirements(code: &alloc::vec::Vec) -> Result<(), BenchmarkError> { ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); Ok(()) } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/people.rs b/cumulus/parachains/runtimes/people/people-westend/src/people.rs index a5c0e66a3f882..0255fd074b111 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/people.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/people.rs @@ -28,7 +28,6 @@ use sp_runtime::{ traits::{AccountIdConversion, Verify}, RuntimeDebug, }; -use sp_std::prelude::*; parameter_types! { // 27 | Min encoded size of `Registration` @@ -151,7 +150,7 @@ impl IdentityInformationProvider for IdentityInfo { #[cfg(feature = "runtime-benchmarks")] fn create_identity_info() -> Self { - let data = Data::Raw(vec![0; 32].try_into().unwrap()); + let data = Data::Raw(alloc::vec![0; 32].try_into().unwrap()); IdentityInfo { display: data.clone(), diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/cumulus_pallet_parachain_system.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/cumulus_pallet_parachain_system.rs index fcea5fd1bf679..5715d56c21868 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/cumulus_pallet_parachain_system.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/cumulus_pallet_parachain_system.rs @@ -20,7 +20,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_parachain_system`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_message_queue.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_message_queue.rs index fe1911b77a72d..47c6790140736 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_message_queue.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_message_queue.rs @@ -20,7 +20,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_message_queue`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs index b2579230c9ed7..b1fc7ad8ed832 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/mod.rs @@ -17,10 +17,10 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use alloc::vec::Vec; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index efffd31881710..92d08a2461807 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -42,7 +42,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::fungible`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index d7b10f95c792a..861f038199596 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -42,7 +42,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `pallet_xcm_benchmarks::generic`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/parachains/runtimes/starters/seedling/Cargo.toml b/cumulus/parachains/runtimes/starters/seedling/Cargo.toml index 8a7c5922362e8..c76c09a31234e 100644 --- a/cumulus/parachains/runtimes/starters/seedling/Cargo.toml +++ b/cumulus/parachains/runtimes/starters/seedling/Cargo.toml @@ -30,7 +30,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -74,7 +73,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", diff --git a/cumulus/parachains/runtimes/starters/seedling/src/lib.rs b/cumulus/parachains/runtimes/starters/seedling/src/lib.rs index 461133f6cfc06..1fe72604d3731 100644 --- a/cumulus/parachains/runtimes/starters/seedling/src/lib.rs +++ b/cumulus/parachains/runtimes/starters/seedling/src/lib.rs @@ -27,6 +27,9 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -37,7 +40,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -310,7 +312,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } diff --git a/cumulus/parachains/runtimes/starters/shell/Cargo.toml b/cumulus/parachains/runtimes/starters/shell/Cargo.toml index 4a1271ca65840..8f3b2204cfe34 100644 --- a/cumulus/parachains/runtimes/starters/shell/Cargo.toml +++ b/cumulus/parachains/runtimes/starters/shell/Cargo.toml @@ -29,7 +29,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } pallet-message-queue = { workspace = true } @@ -77,7 +76,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", diff --git a/cumulus/parachains/runtimes/starters/shell/src/lib.rs b/cumulus/parachains/runtimes/starters/shell/src/lib.rs index 7422b580cc3e0..1dfbe2b6c41c8 100644 --- a/cumulus/parachains/runtimes/starters/shell/src/lib.rs +++ b/cumulus/parachains/runtimes/starters/shell/src/lib.rs @@ -31,6 +31,9 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use cumulus_primitives_core::AggregateMessageOrigin; @@ -45,7 +48,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -280,7 +282,7 @@ impl sp_runtime::traits::SignedExtension for DisallowSigned { type Pre = (); fn additional_signed( &self, - ) -> sp_std::result::Result<(), sp_runtime::transaction_validity::TransactionValidityError> { + ) -> core::result::Result<(), sp_runtime::transaction_validity::TransactionValidityError> { Ok(()) } fn pre_dispatch( @@ -368,7 +370,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } diff --git a/cumulus/parachains/runtimes/test-utils/Cargo.toml b/cumulus/parachains/runtimes/test-utils/Cargo.toml index 5e895271ab17f..01d7fcc2b5c8b 100644 --- a/cumulus/parachains/runtimes/test-utils/Cargo.toml +++ b/cumulus/parachains/runtimes/test-utils/Cargo.toml @@ -21,7 +21,6 @@ pallet-timestamp = { workspace = true } sp-consensus-aura = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-tracing = { workspace = true, default-features = true } sp-core = { workspace = true } @@ -68,7 +67,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm-executor/std", "xcm/std", ] diff --git a/cumulus/parachains/runtimes/test-utils/src/lib.rs b/cumulus/parachains/runtimes/test-utils/src/lib.rs index 3c84243306fbe..3fc3822a63eb9 100644 --- a/cumulus/parachains/runtimes/test-utils/src/lib.rs +++ b/cumulus/parachains/runtimes/test-utils/src/lib.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use sp_std::marker::PhantomData; +use core::marker::PhantomData; use codec::{Decode, DecodeLimit}; use cumulus_primitives_core::{ diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index bdd0dfac60657..1a2737f3aa224 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -51,7 +51,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -128,7 +127,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index 8d03f8332764f..bf39c02a3f594 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -32,6 +32,9 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod weights; pub mod xcm_config; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use codec::Encode; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; @@ -69,7 +72,6 @@ use sp_runtime::{ ApplyExtrinsicResult, }; pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Permill}; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -737,7 +739,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } diff --git a/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml b/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml index 7cbb614babe79..a0ad248bb7048 100644 --- a/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml @@ -35,7 +35,6 @@ sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -106,7 +105,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", diff --git a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs index 40f2b78ffd6d5..dff7046f19726 100644 --- a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs @@ -22,6 +22,9 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +extern crate alloc; + +use alloc::{vec, vec::Vec}; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; use sp_api::impl_runtime_apis; @@ -32,7 +35,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -711,7 +713,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } diff --git a/cumulus/polkadot-parachain/src/fake_runtime_api/asset_hub_polkadot_aura.rs b/cumulus/polkadot-parachain/src/fake_runtime_api/asset_hub_polkadot_aura.rs index 0b79d338c1681..7d54e9b4be043 100644 --- a/cumulus/polkadot-parachain/src/fake_runtime_api/asset_hub_polkadot_aura.rs +++ b/cumulus/polkadot-parachain/src/fake_runtime_api/asset_hub_polkadot_aura.rs @@ -53,7 +53,7 @@ sp_api::impl_runtime_apis! { unimplemented!() } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> Vec { unimplemented!() } } diff --git a/cumulus/polkadot-parachain/src/fake_runtime_api/aura.rs b/cumulus/polkadot-parachain/src/fake_runtime_api/aura.rs index 823eb9ab584a0..ca5fc8bdf119b 100644 --- a/cumulus/polkadot-parachain/src/fake_runtime_api/aura.rs +++ b/cumulus/polkadot-parachain/src/fake_runtime_api/aura.rs @@ -53,7 +53,7 @@ sp_api::impl_runtime_apis! { unimplemented!() } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> Vec { unimplemented!() } } diff --git a/cumulus/primitives/aura/Cargo.toml b/cumulus/primitives/aura/Cargo.toml index f17c2035edd66..062b9ce736e7f 100644 --- a/cumulus/primitives/aura/Cargo.toml +++ b/cumulus/primitives/aura/Cargo.toml @@ -16,7 +16,6 @@ codec = { features = ["derive"], workspace = true } sp-api = { workspace = true } sp-consensus-aura = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } # Polkadot polkadot-core-primitives = { workspace = true } @@ -31,5 +30,4 @@ std = [ "sp-api/std", "sp-consensus-aura/std", "sp-runtime/std", - "sp-std/std", ] diff --git a/cumulus/primitives/core/Cargo.toml b/cumulus/primitives/core/Cargo.toml index f41213e9485e2..533d368d3b00e 100644 --- a/cumulus/primitives/core/Cargo.toml +++ b/cumulus/primitives/core/Cargo.toml @@ -16,7 +16,6 @@ scale-info = { features = ["derive"], workspace = true } # Substrate sp-api = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-trie = { workspace = true } # Polkadot @@ -35,7 +34,6 @@ std = [ "scale-info/std", "sp-api/std", "sp-runtime/std", - "sp-std/std", "sp-trie/std", "xcm/std", ] diff --git a/cumulus/primitives/core/src/lib.rs b/cumulus/primitives/core/src/lib.rs index 29216d5134651..6eafecfc3ff57 100644 --- a/cumulus/primitives/core/src/lib.rs +++ b/cumulus/primitives/core/src/lib.rs @@ -18,11 +18,13 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use polkadot_parachain_primitives::primitives::HeadData; use scale_info::TypeInfo; use sp_runtime::RuntimeDebug; -use sp_std::prelude::*; pub use polkadot_core_primitives::InboundDownwardMessage; pub use polkadot_parachain_primitives::primitives::{ @@ -202,7 +204,7 @@ pub struct ParachainBlockData { /// The header of the parachain block. header: B::Header, /// The extrinsics of the parachain block. - extrinsics: sp_std::vec::Vec, + extrinsics: alloc::vec::Vec, /// The data that is required to emulate the storage accesses executed by all extrinsics. storage_proof: sp_trie::CompactProof, } @@ -211,7 +213,7 @@ impl ParachainBlockData { /// Creates a new instance of `Self`. pub fn new( header: ::Header, - extrinsics: sp_std::vec::Vec<::Extrinsic>, + extrinsics: alloc::vec::Vec<::Extrinsic>, storage_proof: sp_trie::CompactProof, ) -> Self { Self { header, extrinsics, storage_proof } @@ -243,7 +245,7 @@ impl ParachainBlockData { } /// Deconstruct into the inner parts. - pub fn deconstruct(self) -> (B::Header, sp_std::vec::Vec, sp_trie::CompactProof) { + pub fn deconstruct(self) -> (B::Header, alloc::vec::Vec, sp_trie::CompactProof) { (self.header, self.extrinsics, self.storage_proof) } } diff --git a/cumulus/primitives/parachain-inherent/Cargo.toml b/cumulus/primitives/parachain-inherent/Cargo.toml index c07fe07545614..172af4b9ec63e 100644 --- a/cumulus/primitives/parachain-inherent/Cargo.toml +++ b/cumulus/primitives/parachain-inherent/Cargo.toml @@ -19,7 +19,6 @@ sp-core = { workspace = true } sp-inherents = { workspace = true } sp-runtime = { optional = true, workspace = true } sp-state-machine = { optional = true, workspace = true } -sp-std = { workspace = true } sp-trie = { workspace = true } # Cumulus @@ -36,6 +35,5 @@ std = [ "sp-inherents/std", "sp-runtime?/std", "sp-state-machine?/std", - "sp-std/std", "sp-trie/std", ] diff --git a/cumulus/primitives/parachain-inherent/src/lib.rs b/cumulus/primitives/parachain-inherent/src/lib.rs index 75a56693958e6..ad4b39b547c5f 100644 --- a/cumulus/primitives/parachain-inherent/src/lib.rs +++ b/cumulus/primitives/parachain-inherent/src/lib.rs @@ -27,14 +27,16 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + use cumulus_primitives_core::{ relay_chain::{BlakeTwo256, Hash as RelayHash, HashT as _}, InboundDownwardMessage, InboundHrmpMessage, ParaId, PersistedValidationData, }; +use alloc::{collections::btree_map::BTreeMap, vec::Vec}; use scale_info::TypeInfo; use sp_inherents::InherentIdentifier; -use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; /// The identifier for the parachain inherent. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"sysi1337"; diff --git a/cumulus/primitives/storage-weight-reclaim/Cargo.toml b/cumulus/primitives/storage-weight-reclaim/Cargo.toml index af32fb68d8bb2..3a98fdd017aef 100644 --- a/cumulus/primitives/storage-weight-reclaim/Cargo.toml +++ b/cumulus/primitives/storage-weight-reclaim/Cargo.toml @@ -18,7 +18,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } cumulus-primitives-core = { workspace = true } cumulus-primitives-proof-size-hostfunction = { workspace = true } @@ -41,6 +40,5 @@ std = [ "scale-info/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-trie/std", ] diff --git a/cumulus/primitives/storage-weight-reclaim/src/lib.rs b/cumulus/primitives/storage-weight-reclaim/src/lib.rs index 35fa334f51c69..f48dd927ee962 100644 --- a/cumulus/primitives/storage-weight-reclaim/src/lib.rs +++ b/cumulus/primitives/storage-weight-reclaim/src/lib.rs @@ -18,6 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; +use core::marker::PhantomData; use cumulus_primitives_core::Weight; use cumulus_primitives_proof_size_hostfunction::{ storage_proof_size::storage_proof_size, PROOF_RECORDING_DISABLED, @@ -33,7 +34,6 @@ use sp_runtime::{ transaction_validity::TransactionValidityError, DispatchResult, }; -use sp_std::marker::PhantomData; const LOG_TARGET: &'static str = "runtime::storage_reclaim"; @@ -199,6 +199,7 @@ where #[cfg(test)] mod tests { use super::*; + use core::marker::PhantomData; use frame_support::{ assert_ok, dispatch::{DispatchClass, PerDispatchClass}, @@ -206,7 +207,6 @@ mod tests { }; use frame_system::{BlockWeight, CheckWeight}; use sp_runtime::{AccountId32, BuildStorage}; - use sp_std::marker::PhantomData; use sp_trie::proof_size_extension::ProofSizeExt; type Test = cumulus_test_runtime::Runtime; diff --git a/cumulus/primitives/timestamp/Cargo.toml b/cumulus/primitives/timestamp/Cargo.toml index f7bf53a9d7d7c..a50011bc3f0e9 100644 --- a/cumulus/primitives/timestamp/Cargo.toml +++ b/cumulus/primitives/timestamp/Cargo.toml @@ -15,7 +15,6 @@ futures = { workspace = true } # Substrate sp-inherents = { workspace = true } -sp-std = { workspace = true } sp-timestamp = { workspace = true } # Cumulus @@ -27,6 +26,5 @@ std = [ "codec/std", "cumulus-primitives-core/std", "sp-inherents/std", - "sp-std/std", "sp-timestamp/std", ] diff --git a/cumulus/primitives/timestamp/src/lib.rs b/cumulus/primitives/timestamp/src/lib.rs index e6aba6d0bb740..5365f83efdf11 100644 --- a/cumulus/primitives/timestamp/src/lib.rs +++ b/cumulus/primitives/timestamp/src/lib.rs @@ -27,9 +27,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +use core::time::Duration; use cumulus_primitives_core::relay_chain::Slot; use sp_inherents::{Error, InherentData}; -use sp_std::time::Duration; pub use sp_timestamp::{InherentType, INHERENT_IDENTIFIER}; diff --git a/cumulus/primitives/utility/Cargo.toml b/cumulus/primitives/utility/Cargo.toml index a2fa2dd9806dc..82d18c8c0aac6 100644 --- a/cumulus/primitives/utility/Cargo.toml +++ b/cumulus/primitives/utility/Cargo.toml @@ -17,7 +17,6 @@ log = { workspace = true } frame-support = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } pallet-asset-conversion = { workspace = true } # Polkadot @@ -42,7 +41,6 @@ std = [ "polkadot-runtime-parachains/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/cumulus/primitives/utility/src/lib.rs b/cumulus/primitives/utility/src/lib.rs index 64784eb36f846..9d5bf4e231eb0 100644 --- a/cumulus/primitives/utility/src/lib.rs +++ b/cumulus/primitives/utility/src/lib.rs @@ -19,7 +19,11 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{vec, vec::Vec}; use codec::Encode; +use core::marker::PhantomData; use cumulus_primitives_core::{MessageSendError, UpwardMessageSender}; use frame_support::{ defensive, @@ -33,7 +37,6 @@ use sp_runtime::{ traits::{Saturating, Zero}, SaturatedConversion, }; -use sp_std::{marker::PhantomData, prelude::*}; use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm, WrapVersion}; use xcm_builder::{InspectMessageQueues, TakeRevenue}; use xcm_executor::{ @@ -803,7 +806,7 @@ mod test_trader { /// needed. #[cfg(feature = "runtime-benchmarks")] pub struct ToParentDeliveryHelper( - sp_std::marker::PhantomData<(XcmConfig, ExistentialDeposit, PriceForDelivery)>, + core::marker::PhantomData<(XcmConfig, ExistentialDeposit, PriceForDelivery)>, ); #[cfg(feature = "runtime-benchmarks")] diff --git a/cumulus/templates/xcm-bench-template.hbs b/cumulus/templates/xcm-bench-template.hbs index 5d0ded403f634..119924bca2ee1 100644 --- a/cumulus/templates/xcm-bench-template.hbs +++ b/cumulus/templates/xcm-bench-template.hbs @@ -17,7 +17,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weights for `{{pallet}}`. pub struct WeightInfo(PhantomData); diff --git a/cumulus/test/relay-sproof-builder/Cargo.toml b/cumulus/test/relay-sproof-builder/Cargo.toml index 454266c90ba74..e266b5807081a 100644 --- a/cumulus/test/relay-sproof-builder/Cargo.toml +++ b/cumulus/test/relay-sproof-builder/Cargo.toml @@ -16,7 +16,6 @@ codec = { features = ["derive"], workspace = true } sp-runtime = { workspace = true } sp-state-machine = { workspace = true } sp-trie = { workspace = true } -sp-std = { workspace = true } # Polkadot polkadot-primitives = { workspace = true } @@ -32,6 +31,5 @@ std = [ "polkadot-primitives/std", "sp-runtime/std", "sp-state-machine/std", - "sp-std/std", "sp-trie/std", ] diff --git a/cumulus/test/relay-sproof-builder/src/lib.rs b/cumulus/test/relay-sproof-builder/src/lib.rs index fbd2692a36b46..d1016085c8073 100644 --- a/cumulus/test/relay-sproof-builder/src/lib.rs +++ b/cumulus/test/relay-sproof-builder/src/lib.rs @@ -14,12 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . +extern crate alloc; + +use alloc::collections::btree_map::BTreeMap; use cumulus_primitives_core::{ relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId, }; use polkadot_primitives::UpgradeGoAhead; use sp_runtime::traits::HashingFor; -use sp_std::collections::btree_map::BTreeMap; use sp_trie::PrefixedMemoryDB; /// Builds a sproof (portmanteau of 'spoof' and 'proof') of the relay chain state. diff --git a/cumulus/test/runtime/Cargo.toml b/cumulus/test/runtime/Cargo.toml index d5582f2d2a23b..54b83e2dfedae 100644 --- a/cumulus/test/runtime/Cargo.toml +++ b/cumulus/test/runtime/Cargo.toml @@ -36,7 +36,6 @@ sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } sp-consensus-aura = { workspace = true } -sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } @@ -87,7 +86,6 @@ std = [ "sp-offchain/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", diff --git a/cumulus/test/runtime/src/lib.rs b/cumulus/test/runtime/src/lib.rs index 97cb02ab779ef..274f16ab630d6 100644 --- a/cumulus/test/runtime/src/lib.rs +++ b/cumulus/test/runtime/src/lib.rs @@ -33,6 +33,10 @@ pub mod elastic_scaling { } mod test_pallet; + +extern crate alloc; + +use alloc::{vec, vec::Vec}; use frame_support::{derive_impl, traits::OnRuntimeUpgrade, PalletId}; use sp_api::{decl_runtime_apis, impl_runtime_apis}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -44,7 +48,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, MultiSignature, }; -use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -454,7 +457,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> Vec { Runtime::metadata_versions() } } diff --git a/cumulus/test/runtime/src/test_pallet.rs b/cumulus/test/runtime/src/test_pallet.rs index 7f43f713fadc4..61195386ae79d 100644 --- a/cumulus/test/runtime/src/test_pallet.rs +++ b/cumulus/test/runtime/src/test_pallet.rs @@ -42,7 +42,7 @@ pub mod pallet { #[pallet::weight(0)] pub fn set_custom_validation_head_data( _: OriginFor, - custom_header: sp_std::vec::Vec, + custom_header: alloc::vec::Vec, ) -> DispatchResult { cumulus_pallet_parachain_system::Pallet::::set_custom_validation_head_data( custom_header, @@ -79,7 +79,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index 1a3f3930cb347..8de3660c22362 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +extern crate alloc; + pub use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; pub use lazy_static::lazy_static; pub use log; @@ -24,6 +26,8 @@ pub use std::{ }; // Substrate +pub use alloc::collections::vec_deque::VecDeque; +pub use core::{cell::RefCell, fmt::Debug}; pub use cumulus_primitives_core::AggregateMessageOrigin as CumulusAggregateMessageOrigin; pub use frame_support::{ assert_ok, @@ -44,7 +48,6 @@ pub use sp_core::{parameter_types, sr25519, storage::Storage, Pair}; pub use sp_crypto_hashing::blake2_256; pub use sp_io::TestExternalities; pub use sp_runtime::BoundedSlice; -pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, fmt::Debug}; pub use sp_tracing; // Cumulus diff --git a/docs/sdk/src/reference_docs/chain_spec_runtime/Cargo.toml b/docs/sdk/src/reference_docs/chain_spec_runtime/Cargo.toml index 9cf921a492a51..0284957120328 100644 --- a/docs/sdk/src/reference_docs/chain_spec_runtime/Cargo.toml +++ b/docs/sdk/src/reference_docs/chain_spec_runtime/Cargo.toml @@ -33,7 +33,6 @@ pallet-transaction-payment-rpc-runtime-api = { workspace = true } sp-genesis-builder = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-core = { workspace = true } -sp-std = { workspace = true } sp-keyring = { workspace = true } sp-application-crypto = { features = ["serde"], workspace = true } @@ -63,7 +62,6 @@ std = [ "sp-genesis-builder/std", "sp-keyring/std", "sp-runtime/std", - "sp-std/std", "serde/std", "serde_json/std", diff --git a/docs/sdk/src/reference_docs/chain_spec_runtime/src/lib.rs b/docs/sdk/src/reference_docs/chain_spec_runtime/src/lib.rs index 4606104fb9680..e7effce1bd669 100644 --- a/docs/sdk/src/reference_docs/chain_spec_runtime/src/lib.rs +++ b/docs/sdk/src/reference_docs/chain_spec_runtime/src/lib.rs @@ -19,6 +19,8 @@ //! A minimal runtime that shows runtime genesis state. +extern crate alloc; + pub mod pallets; pub mod presets; pub mod runtime; diff --git a/docs/sdk/src/reference_docs/chain_spec_runtime/src/pallets.rs b/docs/sdk/src/reference_docs/chain_spec_runtime/src/pallets.rs index be4455aa21979..2ff2d9539e2db 100644 --- a/docs/sdk/src/reference_docs/chain_spec_runtime/src/pallets.rs +++ b/docs/sdk/src/reference_docs/chain_spec_runtime/src/pallets.rs @@ -17,6 +17,7 @@ //! Pallets for the chain-spec demo runtime. +use alloc::vec::Vec; use frame::prelude::*; #[docify::export] diff --git a/docs/sdk/src/reference_docs/chain_spec_runtime/src/presets.rs b/docs/sdk/src/reference_docs/chain_spec_runtime/src/presets.rs index c51947f6cc7cb..02c2d90f7c827 100644 --- a/docs/sdk/src/reference_docs/chain_spec_runtime/src/presets.rs +++ b/docs/sdk/src/reference_docs/chain_spec_runtime/src/presets.rs @@ -18,10 +18,10 @@ //! Presets for the chain-spec demo runtime. use crate::pallets::{FooEnum, SomeFooData1, SomeFooData2}; +use alloc::vec; use serde_json::{json, to_string, Value}; use sp_application_crypto::Ss58Codec; use sp_keyring::AccountKeyring; -use sp_std::vec; /// A demo preset with strings only. pub const PRESET_1: &str = "preset_1"; @@ -122,7 +122,7 @@ fn preset_invalid() -> Value { /// /// If no preset with given `id` exits `None` is returned. #[docify::export] -pub fn get_builtin_preset(id: &sp_genesis_builder::PresetId) -> Option> { +pub fn get_builtin_preset(id: &sp_genesis_builder::PresetId) -> Option> { let preset = match id.try_into() { Ok(PRESET_1) => preset_1(), Ok(PRESET_2) => preset_2(), diff --git a/docs/sdk/src/reference_docs/chain_spec_runtime/src/runtime.rs b/docs/sdk/src/reference_docs/chain_spec_runtime/src/runtime.rs index 6d9bc1260b11f..c45f0126337e5 100644 --- a/docs/sdk/src/reference_docs/chain_spec_runtime/src/runtime.rs +++ b/docs/sdk/src/reference_docs/chain_spec_runtime/src/runtime.rs @@ -25,6 +25,7 @@ use crate::{ pallets::{pallet_bar, pallet_foo}, presets::*, }; +use alloc::{vec, vec::Vec}; use frame::{ deps::frame_support::{ genesis_builder_helper::{build_state, get_preset}, diff --git a/polkadot/core-primitives/Cargo.toml b/polkadot/core-primitives/Cargo.toml index 800434670f83b..42ca27953738e 100644 --- a/polkadot/core-primitives/Cargo.toml +++ b/polkadot/core-primitives/Cargo.toml @@ -11,7 +11,6 @@ workspace = true [dependencies] sp-core = { workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } scale-info = { features = ["derive"], workspace = true } codec = { features = ["derive"], workspace = true } @@ -23,5 +22,4 @@ std = [ "scale-info/std", "sp-core/std", "sp-runtime/std", - "sp-std/std", ] diff --git a/polkadot/core-primitives/src/lib.rs b/polkadot/core-primitives/src/lib.rs index 072c045a8c703..666636def4604 100644 --- a/polkadot/core-primitives/src/lib.rs +++ b/polkadot/core-primitives/src/lib.rs @@ -20,6 +20,8 @@ //! //! These core Polkadot types are used by the relay chain and the Parachains. +extern crate alloc; + use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ @@ -81,8 +83,8 @@ impl std::fmt::Display for CandidateHash { } } -impl sp_std::fmt::Debug for CandidateHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Debug for CandidateHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{:?}", self.0) } } @@ -119,7 +121,7 @@ pub type Remark = [u8; 32]; /// A message sent from the relay-chain down to a parachain. /// /// The size of the message is limited by the `config.max_downward_message_size` parameter. -pub type DownwardMessage = sp_std::vec::Vec; +pub type DownwardMessage = alloc::vec::Vec; /// A wrapped version of `DownwardMessage`. The difference is that it has attached the block number /// when the message was sent. @@ -139,7 +141,7 @@ pub struct InboundHrmpMessage { /// enacted. pub sent_at: BlockNumber, /// The message payload. - pub data: sp_std::vec::Vec, + pub data: alloc::vec::Vec, } /// An HRMP message seen from the perspective of a sender. @@ -148,7 +150,7 @@ pub struct OutboundHrmpMessage { /// The para that will get this message in its downward message queue. pub recipient: Id, /// The message payload. - pub data: sp_std::vec::Vec, + pub data: alloc::vec::Vec, } /// `V2` primitives. diff --git a/polkadot/parachain/Cargo.toml b/polkadot/parachain/Cargo.toml index 1491af0148e0b..9d0518fd46ade 100644 --- a/polkadot/parachain/Cargo.toml +++ b/polkadot/parachain/Cargo.toml @@ -15,7 +15,6 @@ workspace = true # various unnecessary Substrate-specific endpoints. codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive", "serde"], workspace = true } -sp-std = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-core = { features = ["serde"], workspace = true } sp-weights = { workspace = true } @@ -37,7 +36,6 @@ std = [ "serde/std", "sp-core/std", "sp-runtime/std", - "sp-std/std", "sp-weights/std", ] runtime-benchmarks = ["sp-runtime/runtime-benchmarks"] diff --git a/polkadot/parachain/src/lib.rs b/polkadot/parachain/src/lib.rs index bd75296bf8371..8941b7fbb911e 100644 --- a/polkadot/parachain/src/lib.rs +++ b/polkadot/parachain/src/lib.rs @@ -51,3 +51,5 @@ mod wasm_api; #[cfg(all(not(feature = "std"), feature = "wasm-api"))] pub use wasm_api::*; + +extern crate alloc; diff --git a/polkadot/parachain/src/primitives.rs b/polkadot/parachain/src/primitives.rs index d92bbee8d28d1..c5757928c3fc2 100644 --- a/polkadot/parachain/src/primitives.rs +++ b/polkadot/parachain/src/primitives.rs @@ -17,7 +17,7 @@ //! Primitive types which are strictly necessary from a parachain-execution point //! of view. -use sp_std::vec::Vec; +use alloc::vec::Vec; use bounded_collections::{BoundedVec, ConstU32}; use codec::{CompactAs, Decode, Encode, MaxEncodedLen}; @@ -89,14 +89,14 @@ impl ValidationCode { #[derive(Clone, Copy, Encode, Decode, Hash, Eq, PartialEq, PartialOrd, Ord, TypeInfo)] pub struct ValidationCodeHash(Hash); -impl sp_std::fmt::Display for ValidationCodeHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Display for ValidationCodeHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { self.0.fmt(f) } } -impl sp_std::fmt::Debug for ValidationCodeHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Debug for ValidationCodeHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{:?}", self.0) } } @@ -119,9 +119,9 @@ impl From<[u8; 32]> for ValidationCodeHash { } } -impl sp_std::fmt::LowerHex for ValidationCodeHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { - sp_std::fmt::LowerHex::fmt(&self.0, f) +impl core::fmt::LowerHex for ValidationCodeHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + core::fmt::LowerHex::fmt(&self.0, f) } } @@ -225,7 +225,7 @@ impl IsSystem for Id { } } -impl sp_std::ops::Add for Id { +impl core::ops::Add for Id { type Output = Self; fn add(self, other: u32) -> Self { @@ -233,7 +233,7 @@ impl sp_std::ops::Add for Id { } } -impl sp_std::ops::Sub for Id { +impl core::ops::Sub for Id { type Output = Self; fn sub(self, other: u32) -> Self { diff --git a/polkadot/parachain/src/wasm_api.rs b/polkadot/parachain/src/wasm_api.rs index f0c832666284c..1c557c9ae5058 100644 --- a/polkadot/parachain/src/wasm_api.rs +++ b/polkadot/parachain/src/wasm_api.rs @@ -22,7 +22,7 @@ /// function's entry point. #[cfg(not(feature = "std"))] pub unsafe fn load_params(params: *const u8, len: usize) -> crate::primitives::ValidationParams { - let mut slice = sp_std::slice::from_raw_parts(params, len); + let mut slice = core::slice::from_raw_parts(params, len); codec::Decode::decode(&mut slice).expect("Invalid input data") } diff --git a/polkadot/parachain/test-parachains/adder/Cargo.toml b/polkadot/parachain/test-parachains/adder/Cargo.toml index 1661112a7b326..7a150b75d5cdb 100644 --- a/polkadot/parachain/test-parachains/adder/Cargo.toml +++ b/polkadot/parachain/test-parachains/adder/Cargo.toml @@ -14,7 +14,6 @@ workspace = true [dependencies] polkadot-parachain-primitives = { features = ["wasm-api"], workspace = true } codec = { features = ["derive"], workspace = true } -sp-std = { workspace = true } tiny-keccak = { features = ["keccak"], workspace = true } dlmalloc = { features = ["global"], workspace = true } @@ -26,4 +25,4 @@ substrate-wasm-builder = { workspace = true, default-features = true } [features] default = ["std"] -std = ["codec/std", "polkadot-parachain-primitives/std", "sp-io/std", "sp-std/std"] +std = ["codec/std", "polkadot-parachain-primitives/std", "sp-io/std"] diff --git a/polkadot/parachain/test-parachains/adder/src/lib.rs b/polkadot/parachain/test-parachains/adder/src/lib.rs index 28914f02511de..7e8d1bb1e1383 100644 --- a/polkadot/parachain/test-parachains/adder/src/lib.rs +++ b/polkadot/parachain/test-parachains/adder/src/lib.rs @@ -18,6 +18,8 @@ #![no_std] +extern crate alloc; + use codec::{Decode, Encode}; use tiny_keccak::{Hasher as _, Keccak}; diff --git a/polkadot/parachain/test-parachains/adder/src/wasm_validation.rs b/polkadot/parachain/test-parachains/adder/src/wasm_validation.rs index 7dba7a964d3b0..9c3c77f7350b9 100644 --- a/polkadot/parachain/test-parachains/adder/src/wasm_validation.rs +++ b/polkadot/parachain/test-parachains/adder/src/wasm_validation.rs @@ -17,10 +17,10 @@ //! WASM validation for adder parachain. use crate::{BlockData, HeadData}; +use alloc::vec::Vec; use codec::{Decode, Encode}; use core::panic; use polkadot_parachain_primitives::primitives::{HeadData as GenericHeadData, ValidationResult}; -use sp_std::vec::Vec; #[no_mangle] pub extern "C" fn validate_block(params: *const u8, len: usize) -> u64 { @@ -37,10 +37,8 @@ pub extern "C" fn validate_block(params: *const u8, len: usize) -> u64 { polkadot_parachain_primitives::write_result(&ValidationResult { head_data: GenericHeadData(new_head.encode()), new_validation_code: None, - upward_messages: sp_std::vec::Vec::new().try_into().expect("empty vec fits into bounds"), - horizontal_messages: sp_std::vec::Vec::new() - .try_into() - .expect("empty vec fits into bounds"), + upward_messages: alloc::vec::Vec::new().try_into().expect("empty vec fits into bounds"), + horizontal_messages: alloc::vec::Vec::new().try_into().expect("empty vec fits into bounds"), processed_downward_messages: 0, hrmp_watermark: params.relay_parent_number, }) diff --git a/polkadot/parachain/test-parachains/undying/Cargo.toml b/polkadot/parachain/test-parachains/undying/Cargo.toml index 2466c6a0d69d7..4b2e12ebf4354 100644 --- a/polkadot/parachain/test-parachains/undying/Cargo.toml +++ b/polkadot/parachain/test-parachains/undying/Cargo.toml @@ -14,7 +14,6 @@ workspace = true [dependencies] polkadot-parachain-primitives = { features = ["wasm-api"], workspace = true } codec = { features = ["derive"], workspace = true } -sp-std = { workspace = true } tiny-keccak = { features = ["keccak"], workspace = true } dlmalloc = { features = ["global"], workspace = true } log = { workspace = true } @@ -32,5 +31,4 @@ std = [ "log/std", "polkadot-parachain-primitives/std", "sp-io/std", - "sp-std/std", ] diff --git a/polkadot/parachain/test-parachains/undying/src/lib.rs b/polkadot/parachain/test-parachains/undying/src/lib.rs index dc056e64fa23f..e4ec7e99346bb 100644 --- a/polkadot/parachain/test-parachains/undying/src/lib.rs +++ b/polkadot/parachain/test-parachains/undying/src/lib.rs @@ -18,8 +18,10 @@ #![no_std] +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode}; -use sp_std::vec::Vec; use tiny_keccak::{Hasher as _, Keccak}; #[cfg(not(feature = "std"))] diff --git a/polkadot/parachain/test-parachains/undying/src/wasm_validation.rs b/polkadot/parachain/test-parachains/undying/src/wasm_validation.rs index 23fac43a3c731..46b66aa518e49 100644 --- a/polkadot/parachain/test-parachains/undying/src/wasm_validation.rs +++ b/polkadot/parachain/test-parachains/undying/src/wasm_validation.rs @@ -37,8 +37,8 @@ pub extern "C" fn validate_block(params: *const u8, len: usize) -> u64 { polkadot_parachain_primitives::write_result(&ValidationResult { head_data: GenericHeadData(new_head.encode()), new_validation_code: None, - upward_messages: sp_std::vec::Vec::new().try_into().expect("empty vec fits within bounds"), - horizontal_messages: sp_std::vec::Vec::new() + upward_messages: alloc::vec::Vec::new().try_into().expect("empty vec fits within bounds"), + horizontal_messages: alloc::vec::Vec::new() .try_into() .expect("empty vec fits within bounds"), processed_downward_messages: 0, diff --git a/polkadot/primitives/Cargo.toml b/polkadot/primitives/Cargo.toml index c0b510a8fe9d0..8f7ec314ecffe 100644 --- a/polkadot/primitives/Cargo.toml +++ b/polkadot/primitives/Cargo.toml @@ -28,7 +28,6 @@ sp-consensus-slots = { features = ["serde"], workspace = true } sp-io = { workspace = true } sp-keystore = { optional = true, workspace = true } sp-staking = { features = ["serde"], workspace = true } -sp-std = { workspace = true } polkadot-core-primitives = { workspace = true } polkadot-parachain-primitives = { workspace = true } @@ -55,7 +54,6 @@ std = [ "sp-keystore?/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", ] runtime-benchmarks = [ "polkadot-parachain-primitives/runtime-benchmarks", diff --git a/polkadot/primitives/src/lib.rs b/polkadot/primitives/src/lib.rs index 061794ca06d1b..73736fd4a3d6b 100644 --- a/polkadot/primitives/src/lib.rs +++ b/polkadot/primitives/src/lib.rs @@ -31,6 +31,8 @@ pub mod vstaging; // unstable functions. pub mod runtime_api; +extern crate alloc; + // Current primitives not requiring versioning are exported here. // Primitives requiring versioning must not be exported and must be referred by an exact version. pub use v7::{ diff --git a/polkadot/primitives/src/runtime_api.rs b/polkadot/primitives/src/runtime_api.rs index 7bd92be35c159..b4816ad15075d 100644 --- a/polkadot/primitives/src/runtime_api.rs +++ b/polkadot/primitives/src/runtime_api.rs @@ -121,12 +121,12 @@ use crate::{ SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, ValidatorSignature, }; -use polkadot_core_primitives as pcp; -use polkadot_parachain_primitives::primitives as ppp; -use sp_std::{ +use alloc::{ collections::{btree_map::BTreeMap, vec_deque::VecDeque}, - prelude::*, + vec::Vec, }; +use polkadot_core_primitives as pcp; +use polkadot_parachain_primitives::primitives as ppp; sp_api::decl_runtime_apis! { /// The API for querying the state of parachains on-chain. diff --git a/polkadot/primitives/src/v7/async_backing.rs b/polkadot/primitives/src/v7/async_backing.rs index a82d843d28bf1..55d436e30de07 100644 --- a/polkadot/primitives/src/v7/async_backing.rs +++ b/polkadot/primitives/src/v7/async_backing.rs @@ -18,6 +18,7 @@ use super::*; +use alloc::vec::Vec; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_core::RuntimeDebug; diff --git a/polkadot/primitives/src/v7/executor_params.rs b/polkadot/primitives/src/v7/executor_params.rs index e58cf3e76cc2c..bfd42ec30bd39 100644 --- a/polkadot/primitives/src/v7/executor_params.rs +++ b/polkadot/primitives/src/v7/executor_params.rs @@ -22,11 +22,12 @@ //! done in `polkadot-node-core-pvf`. use crate::{BlakeTwo256, HashT as _, PvfExecKind, PvfPrepKind}; +use alloc::{collections::btree_map::BTreeMap, vec, vec::Vec}; use codec::{Decode, Encode}; +use core::{ops::Deref, time::Duration}; use polkadot_core_primitives::Hash; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; -use sp_std::{collections::btree_map::BTreeMap, ops::Deref, time::Duration, vec, vec::Vec}; /// Default maximum number of wasm values allowed for the stack during execution of a PVF. pub const DEFAULT_LOGICAL_STACK_MAX: u32 = 65536; @@ -134,21 +135,21 @@ impl ExecutorParamsHash { } } -impl sp_std::fmt::Display for ExecutorParamsHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Display for ExecutorParamsHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { self.0.fmt(f) } } -impl sp_std::fmt::Debug for ExecutorParamsHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Debug for ExecutorParamsHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{:?}", self.0) } } -impl sp_std::fmt::LowerHex for ExecutorParamsHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { - sp_std::fmt::LowerHex::fmt(&self.0, f) +impl core::fmt::LowerHex for ExecutorParamsHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + core::fmt::LowerHex::fmt(&self.0, f) } } @@ -159,21 +160,21 @@ impl sp_std::fmt::LowerHex for ExecutorParamsHash { #[derive(Clone, Copy, Encode, Decode, Hash, Eq, PartialEq, PartialOrd, Ord, TypeInfo)] pub struct ExecutorParamsPrepHash(Hash); -impl sp_std::fmt::Display for ExecutorParamsPrepHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Display for ExecutorParamsPrepHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { self.0.fmt(f) } } -impl sp_std::fmt::Debug for ExecutorParamsPrepHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Debug for ExecutorParamsPrepHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{:?}", self.0) } } -impl sp_std::fmt::LowerHex for ExecutorParamsPrepHash { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { - sp_std::fmt::LowerHex::fmt(&self.0, f) +impl core::fmt::LowerHex for ExecutorParamsPrepHash { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + core::fmt::LowerHex::fmt(&self.0, f) } } diff --git a/polkadot/primitives/src/v7/metrics.rs b/polkadot/primitives/src/v7/metrics.rs index 1a29471c5450a..1d66c9848a7c4 100644 --- a/polkadot/primitives/src/v7/metrics.rs +++ b/polkadot/primitives/src/v7/metrics.rs @@ -16,8 +16,8 @@ //! Runtime metric primitives. +use alloc::vec::Vec; use codec::{Decode, Encode}; -use sp_std::prelude::*; /// Runtime metric operations. #[derive(Encode, Decode)] @@ -42,7 +42,7 @@ pub struct RuntimeMetricUpdate { } fn vec_to_str<'a>(v: &'a Vec, default: &'static str) -> &'a str { - return sp_std::str::from_utf8(v).unwrap_or(default) + return alloc::str::from_utf8(v).unwrap_or(default) } impl RuntimeMetricLabels { @@ -99,7 +99,7 @@ pub trait AsStr { impl AsStr for RuntimeMetricLabel { fn as_str(&self) -> Option<&str> { - sp_std::str::from_utf8(&self.0).ok() + alloc::str::from_utf8(&self.0).ok() } } diff --git a/polkadot/primitives/src/v7/mod.rs b/polkadot/primitives/src/v7/mod.rs index 6b7985847a106..06b7046520835 100644 --- a/polkadot/primitives/src/v7/mod.rs +++ b/polkadot/primitives/src/v7/mod.rs @@ -16,15 +16,17 @@ //! `V7` Primitives. +use alloc::{ + vec, + vec::{IntoIter, Vec}, +}; use bitvec::{field::BitField, slice::BitSlice, vec::BitVec}; use codec::{Decode, Encode}; -use scale_info::TypeInfo; -use sp_std::{ +use core::{ marker::PhantomData, - prelude::*, slice::{Iter, IterMut}, - vec::IntoIter, }; +use scale_info::TypeInfo; use sp_application_crypto::KeyTypeId; use sp_arithmetic::traits::{BaseArithmetic, Saturating}; @@ -172,10 +174,10 @@ pub type ValidatorSignature = validator_app::Signature; /// A declarations of storage keys where an external observer can find some interesting data. pub mod well_known_keys { use super::{HrmpChannelId, Id, WellKnownKey}; + use alloc::vec::Vec; use codec::Encode as _; use hex_literal::hex; use sp_io::hashing::twox_64; - use sp_std::prelude::*; // A note on generating these magic values below: // @@ -617,13 +619,13 @@ impl CommittedCandidateReceipt { } impl PartialOrd for CommittedCandidateReceipt { - fn partial_cmp(&self, other: &Self) -> Option { + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for CommittedCandidateReceipt { - fn cmp(&self, other: &Self) -> sp_std::cmp::Ordering { + fn cmp(&self, other: &Self) -> core::cmp::Ordering { // TODO: compare signatures or something more sane // https://github.com/paritytech/polkadot/issues/222 self.descriptor() @@ -984,7 +986,7 @@ impl GroupRotationInfo { return GroupIndex(0) } - let cores = sp_std::cmp::min(cores, u32::MAX as usize); + let cores = core::cmp::min(cores, u32::MAX as usize); let blocks_since_start = self.now.saturating_sub(self.session_start_block); let rotations = blocks_since_start / self.group_rotation_frequency; @@ -1006,7 +1008,7 @@ impl GroupRotationInfo { return CoreIndex(0) } - let cores = sp_std::cmp::min(cores, u32::MAX as usize); + let cores = core::cmp::min(cores, u32::MAX as usize); let blocks_since_start = self.now.saturating_sub(self.session_start_block); let rotations = blocks_since_start / self.group_rotation_frequency; let rotations = rotations % cores as u32; @@ -1870,7 +1872,7 @@ pub fn effective_minimum_backing_votes( group_len: usize, configured_minimum_backing_votes: u32, ) -> usize { - sp_std::cmp::min(group_len, configured_minimum_backing_votes as usize) + core::cmp::min(group_len, configured_minimum_backing_votes as usize) } /// Information about validator sets of a session. @@ -1966,7 +1968,7 @@ impl PvfCheckStatement { pub struct WellKnownKey { /// The raw storage key. pub key: Vec, - _p: sp_std::marker::PhantomData, + _p: core::marker::PhantomData, } impl From> for WellKnownKey { diff --git a/polkadot/primitives/src/v7/signed.rs b/polkadot/primitives/src/v7/signed.rs index 62e4df2385038..f819b379a30ae 100644 --- a/polkadot/primitives/src/v7/signed.rs +++ b/polkadot/primitives/src/v7/signed.rs @@ -17,11 +17,11 @@ use codec::{Decode, Encode}; use scale_info::TypeInfo; +use alloc::vec::Vec; #[cfg(feature = "std")] use sp_application_crypto::AppCrypto; #[cfg(feature = "std")] use sp_keystore::{Error as KeystoreError, KeystorePtr}; -use sp_std::prelude::Vec; use sp_core::RuntimeDebug; use sp_runtime::traits::AppVerify; @@ -57,7 +57,7 @@ pub struct UncheckedSigned { /// The signature by the validator of the signed payload. signature: ValidatorSignature, /// This ensures the real payload is tracked at the typesystem level. - real_payload: sp_std::marker::PhantomData, + real_payload: core::marker::PhantomData, } impl, RealPayload: Encode> Signed { @@ -163,7 +163,7 @@ impl, RealPayload: Encode> Signed, RealPayload: Encode> Signed, RealPayload: Encode> UncheckedSigned, RealPayload: Encode> UncheckedSigned(sp_std::marker::PhantomData); + pub struct VersionUncheckedMigrateToV1(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV1 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { diff --git a/polkadot/runtime/common/src/assigned_slots/mod.rs b/polkadot/runtime/common/src/assigned_slots/mod.rs index d0a531b8b6ca5..dd39789e10cfd 100644 --- a/polkadot/runtime/common/src/assigned_slots/mod.rs +++ b/polkadot/runtime/common/src/assigned_slots/mod.rs @@ -30,6 +30,7 @@ use crate::{ slots::{self, Pallet as Slots, WeightInfo as SlotsWeightInfo}, traits::{LeaseError, Leaser, Registrar}, }; +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{pallet_prelude::*, traits::Currency}; use frame_system::pallet_prelude::*; @@ -41,7 +42,6 @@ use polkadot_runtime_parachains::{ }; use scale_info::TypeInfo; use sp_runtime::traits::{One, Saturating, Zero}; -use sp_std::prelude::*; const LOG_TARGET: &str = "runtime::assigned_slots"; diff --git a/polkadot/runtime/common/src/auctions.rs b/polkadot/runtime/common/src/auctions.rs index 19d82ae85d003..78f20d918bab5 100644 --- a/polkadot/runtime/common/src/auctions.rs +++ b/polkadot/runtime/common/src/auctions.rs @@ -22,7 +22,9 @@ use crate::{ slot_range::SlotRange, traits::{AuctionStatus, Auctioneer, LeaseError, Leaser, Registrar}, }; +use alloc::{vec, vec::Vec}; use codec::Decode; +use core::mem::swap; use frame_support::{ dispatch::DispatchResult, ensure, @@ -33,7 +35,6 @@ use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; use polkadot_primitives::Id as ParaId; use sp_runtime::traits::{CheckedSub, One, Saturating, Zero}; -use sp_std::{mem::swap, prelude::*}; type CurrencyOf = <::Leaser as Leaser>>::Currency; type BalanceOf = <<::Leaser as Leaser>>::Currency as Currency< diff --git a/polkadot/runtime/common/src/claims.rs b/polkadot/runtime/common/src/claims.rs index c12af215a04d7..162bf01c38432 100644 --- a/polkadot/runtime/common/src/claims.rs +++ b/polkadot/runtime/common/src/claims.rs @@ -16,7 +16,11 @@ //! Pallet to process claims from Ethereum addresses. +#[cfg(not(feature = "std"))] +use alloc::{format, string::String}; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; +use core::fmt::Debug; use frame_support::{ ensure, traits::{Currency, Get, IsSubType, VestingSchedule}, @@ -35,9 +39,6 @@ use sp_runtime::{ }, RuntimeDebug, }; -#[cfg(not(feature = "std"))] -use sp_std::alloc::{format, string::String}; -use sp_std::{fmt::Debug, prelude::*}; type CurrencyOf = <::VestingSchedule as VestingSchedule< ::AccountId, @@ -150,8 +151,8 @@ impl PartialEq for EcdsaSignature { } } -impl sp_std::fmt::Debug for EcdsaSignature { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Debug for EcdsaSignature { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "EcdsaSignature({:?})", &self.0[..]) } } @@ -596,12 +597,12 @@ where ::RuntimeCall: IsSubType>, { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "PrevalidateAttests") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -612,7 +613,7 @@ where { /// Create new `SignedExtension` to check runtime version. pub fn new() -> Self { - Self(sp_std::marker::PhantomData) + Self(core::marker::PhantomData) } } diff --git a/polkadot/runtime/common/src/crowdloan/migration.rs b/polkadot/runtime/common/src/crowdloan/migration.rs index 3afd6b3fbc94b..0ee3872a366ea 100644 --- a/polkadot/runtime/common/src/crowdloan/migration.rs +++ b/polkadot/runtime/common/src/crowdloan/migration.rs @@ -21,7 +21,7 @@ use frame_support::{ Twox64Concat, }; -pub struct MigrateToTrackInactiveV2(sp_std::marker::PhantomData); +pub struct MigrateToTrackInactiveV2(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToTrackInactiveV2 { fn on_runtime_upgrade() -> Weight { let on_chain_version = Pallet::::on_chain_storage_version(); diff --git a/polkadot/runtime/common/src/crowdloan/mod.rs b/polkadot/runtime/common/src/crowdloan/mod.rs index 61d406aa68126..8cf288197e3dd 100644 --- a/polkadot/runtime/common/src/crowdloan/mod.rs +++ b/polkadot/runtime/common/src/crowdloan/mod.rs @@ -55,6 +55,7 @@ use crate::{ slot_range::SlotRange, traits::{Auctioneer, Registrar}, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; use frame_support::{ ensure, @@ -77,7 +78,6 @@ use sp_runtime::{ }, MultiSignature, MultiSigner, RuntimeDebug, }; -use sp_std::vec::Vec; type CurrencyOf = <::Auctioneer as Auctioneer>>::Currency; type LeasePeriodOf = <::Auctioneer as Auctioneer>>::LeasePeriod; @@ -832,16 +832,16 @@ impl Pallet { impl crate::traits::OnSwap for Pallet { fn on_swap(one: ParaId, other: ParaId) { - Funds::::mutate(one, |x| Funds::::mutate(other, |y| sp_std::mem::swap(x, y))) + Funds::::mutate(one, |x| Funds::::mutate(other, |y| core::mem::swap(x, y))) } } #[cfg(any(feature = "runtime-benchmarks", test))] mod crypto { + use alloc::vec::Vec; use sp_core::ed25519; use sp_io::crypto::{ed25519_generate, ed25519_sign}; use sp_runtime::{MultiSignature, MultiSigner}; - use sp_std::vec::Vec; pub fn create_ed25519_pubkey(seed: Vec) -> MultiSigner { ed25519_generate(0.into(), Some(seed)).into() @@ -1968,7 +1968,6 @@ mod benchmarking { use polkadot_runtime_parachains::paras; use sp_core::crypto::UncheckedFrom; use sp_runtime::traits::{Bounded, CheckedSub}; - use sp_std::prelude::*; use frame_benchmarking::{account, benchmarks, whitelisted_caller}; diff --git a/polkadot/runtime/common/src/identity_migrator.rs b/polkadot/runtime/common/src/identity_migrator.rs index 7d02e24b53681..126c886280e6e 100644 --- a/polkadot/runtime/common/src/identity_migrator.rs +++ b/polkadot/runtime/common/src/identity_migrator.rs @@ -172,6 +172,7 @@ impl OnReapIdentity for () { #[benchmarks] mod benchmarks { use super::*; + use alloc::{boxed::Box, vec, vec::Vec}; use codec::Encode; use frame_support::traits::EnsureOrigin; use frame_system::RawOrigin; @@ -180,7 +181,6 @@ mod benchmarks { traits::{Bounded, Hash, StaticLookup}, Saturating, }; - use sp_std::{boxed::Box, vec::Vec, *}; const SEED: u32 = 0; diff --git a/polkadot/runtime/common/src/impls.rs b/polkadot/runtime/common/src/impls.rs index 709cc69cdbeab..9d61cd018731f 100644 --- a/polkadot/runtime/common/src/impls.rs +++ b/polkadot/runtime/common/src/impls.rs @@ -28,7 +28,7 @@ use sp_runtime::{traits::TryConvert, Perquintill, RuntimeDebug}; use xcm::VersionedLocation; /// Logic for the author to get a portion of fees. -pub struct ToAuthor(sp_std::marker::PhantomData); +pub struct ToAuthor(core::marker::PhantomData); impl OnUnbalanced>> for ToAuthor where R: pallet_balances::Config + pallet_authorship::Config, @@ -44,7 +44,7 @@ where } } -pub struct DealWithFees(sp_std::marker::PhantomData); +pub struct DealWithFees(core::marker::PhantomData); impl OnUnbalanced>> for DealWithFees where R: pallet_balances::Config + pallet_authorship::Config + pallet_treasury::Config, diff --git a/polkadot/runtime/common/src/integration_tests.rs b/polkadot/runtime/common/src/integration_tests.rs index 052fb0389db40..7a689a517eaa2 100644 --- a/polkadot/runtime/common/src/integration_tests.rs +++ b/polkadot/runtime/common/src/integration_tests.rs @@ -24,6 +24,7 @@ use crate::{ slots, traits::{AuctionStatus, Auctioneer, Leaser, Registrar as RegistrarT}, }; +use alloc::sync::Arc; use codec::Encode; use frame_support::{ assert_noop, assert_ok, derive_impl, parameter_types, @@ -50,7 +51,6 @@ use sp_runtime::{ transaction_validity::TransactionPriority, AccountId32, BuildStorage, MultiSignature, }; -use sp_std::sync::Arc; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlockU32; diff --git a/polkadot/runtime/common/src/lib.rs b/polkadot/runtime/common/src/lib.rs index 6e50384f68c9c..41e1cdbab8011 100644 --- a/polkadot/runtime/common/src/lib.rs +++ b/polkadot/runtime/common/src/lib.rs @@ -41,6 +41,8 @@ mod integration_tests; #[cfg(test)] mod mock; +extern crate alloc; + use frame_support::{ parameter_types, traits::{ConstU32, Currency, OneSessionHandler}, @@ -169,7 +171,7 @@ static_assertions::assert_eq_size!(polkadot_primitives::Balance, u128); /// A placeholder since there is currently no provided session key handler for parachain validator /// keys. -pub struct ParachainSessionKeyPlaceholder(sp_std::marker::PhantomData); +pub struct ParachainSessionKeyPlaceholder(core::marker::PhantomData); impl sp_runtime::BoundToRuntimeAppPublic for ParachainSessionKeyPlaceholder { type Public = ValidatorId; } @@ -198,7 +200,7 @@ impl OneSessionHandler /// A placeholder since there is currently no provided session key handler for parachain validator /// keys. -pub struct AssignmentSessionKeyPlaceholder(sp_std::marker::PhantomData); +pub struct AssignmentSessionKeyPlaceholder(core::marker::PhantomData); impl sp_runtime::BoundToRuntimeAppPublic for AssignmentSessionKeyPlaceholder { type Public = AssignmentId; } diff --git a/polkadot/runtime/common/src/mock.rs b/polkadot/runtime/common/src/mock.rs index 6534110cc2104..54170b07fa62c 100644 --- a/polkadot/runtime/common/src/mock.rs +++ b/polkadot/runtime/common/src/mock.rs @@ -37,7 +37,7 @@ thread_local! { static MANAGERS: RefCell>> = RefCell::new(HashMap::new()); } -pub struct TestRegistrar(sp_std::marker::PhantomData); +pub struct TestRegistrar(core::marker::PhantomData); impl Registrar for TestRegistrar { type AccountId = T::AccountId; diff --git a/polkadot/runtime/common/src/paras_registrar/migration.rs b/polkadot/runtime/common/src/paras_registrar/migration.rs index 18bb6bbfb559a..6b110d2ff5d5e 100644 --- a/polkadot/runtime/common/src/paras_registrar/migration.rs +++ b/polkadot/runtime/common/src/paras_registrar/migration.rs @@ -25,7 +25,7 @@ pub struct ParaInfoV1 { } pub struct VersionUncheckedMigrateToV1( - sp_std::marker::PhantomData<(T, UnlockParaIds)>, + core::marker::PhantomData<(T, UnlockParaIds)>, ); impl> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV1 diff --git a/polkadot/runtime/common/src/paras_registrar/mod.rs b/polkadot/runtime/common/src/paras_registrar/mod.rs index 606883b7119b4..07f02e9265612 100644 --- a/polkadot/runtime/common/src/paras_registrar/mod.rs +++ b/polkadot/runtime/common/src/paras_registrar/mod.rs @@ -19,6 +19,8 @@ pub mod migration; +use alloc::{vec, vec::Vec}; +use core::result; use frame_support::{ dispatch::DispatchResult, ensure, @@ -34,7 +36,6 @@ use polkadot_runtime_parachains::{ paras::{self, ParaGenesisArgs, UpgradeStrategy}, Origin, ParaLifecycle, }; -use sp_std::{prelude::*, result}; use crate::traits::{OnSwap, Registrar}; use codec::{Decode, Encode}; @@ -210,7 +211,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, pub next_free_para_id: ParaId, } @@ -717,6 +718,7 @@ mod tests { use crate::{ mock::conclude_pvf_checking, paras_registrar, traits::Registrar as RegistrarTrait, }; + use alloc::collections::btree_map::BTreeMap; use frame_support::{ assert_noop, assert_ok, derive_impl, parameter_types, traits::{OnFinalize, OnInitialize}, @@ -733,7 +735,6 @@ mod tests { transaction_validity::TransactionPriority, BuildStorage, Perbill, }; - use sp_std::collections::btree_map::BTreeMap; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlockU32; diff --git a/polkadot/runtime/common/src/paras_sudo_wrapper.rs b/polkadot/runtime/common/src/paras_sudo_wrapper.rs index 3ff8d4ac08e15..af93c70b4783f 100644 --- a/polkadot/runtime/common/src/paras_sudo_wrapper.rs +++ b/polkadot/runtime/common/src/paras_sudo_wrapper.rs @@ -16,6 +16,7 @@ //! A simple wrapper allowing `Sudo` to call into `paras` routines. +use alloc::boxed::Box; use codec::Encode; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; @@ -26,7 +27,6 @@ use polkadot_runtime_parachains::{ paras::{self, AssignCoretime, ParaGenesisArgs}, ParaLifecycle, }; -use sp_std::boxed::Box; #[frame_support::pallet] pub mod pallet { diff --git a/polkadot/runtime/common/src/purchase.rs b/polkadot/runtime/common/src/purchase.rs index eb480e4efe1f8..d650548b8ac39 100644 --- a/polkadot/runtime/common/src/purchase.rs +++ b/polkadot/runtime/common/src/purchase.rs @@ -16,6 +16,7 @@ //! Pallet to process purchase of DOTs. +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::{ pallet_prelude::*, @@ -29,7 +30,6 @@ use sp_runtime::{ traits::{CheckedAdd, Saturating, Verify, Zero}, AnySignature, DispatchError, DispatchResult, Permill, RuntimeDebug, }; -use sp_std::prelude::*; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; diff --git a/polkadot/runtime/common/src/slots/mod.rs b/polkadot/runtime/common/src/slots/mod.rs index 747b7b5ca634e..333f14c6608ac 100644 --- a/polkadot/runtime/common/src/slots/mod.rs +++ b/polkadot/runtime/common/src/slots/mod.rs @@ -25,6 +25,7 @@ pub mod migration; use crate::traits::{LeaseError, Leaser, Registrar}; +use alloc::{vec, vec::Vec}; use frame_support::{ pallet_prelude::*, traits::{Currency, ReservableCurrency}, @@ -34,7 +35,6 @@ use frame_system::pallet_prelude::*; pub use pallet::*; use polkadot_primitives::Id as ParaId; use sp_runtime::traits::{CheckedConversion, CheckedSub, Saturating, Zero}; -use sp_std::prelude::*; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -309,7 +309,7 @@ impl Pallet { // Useful when trying to clean up a parachain leases, as this would tell // you all the balances you need to unreserve. fn all_deposits_held(para: ParaId) -> Vec<(T::AccountId, BalanceOf)> { - let mut tracker = sp_std::collections::btree_map::BTreeMap::new(); + let mut tracker = alloc::collections::btree_map::BTreeMap::new(); Leases::::get(para).into_iter().for_each(|lease| match lease { Some((who, amount)) => match tracker.get(&who) { Some(prev_amount) => @@ -329,7 +329,7 @@ impl Pallet { impl crate::traits::OnSwap for Pallet { fn on_swap(one: ParaId, other: ParaId) { - Leases::::mutate(one, |x| Leases::::mutate(other, |y| sp_std::mem::swap(x, y))) + Leases::::mutate(one, |x| Leases::::mutate(other, |y| core::mem::swap(x, y))) } } diff --git a/polkadot/runtime/common/src/traits.rs b/polkadot/runtime/common/src/traits.rs index eadeac74fcdb6..6e49abcee98b2 100644 --- a/polkadot/runtime/common/src/traits.rs +++ b/polkadot/runtime/common/src/traits.rs @@ -16,12 +16,12 @@ //! Traits used across pallets for Polkadot. +use alloc::vec::*; use frame_support::{ dispatch::DispatchResult, traits::{Currency, ReservableCurrency}, }; use polkadot_primitives::{HeadData, Id as ParaId, ValidationCode}; -use sp_std::vec::*; /// Parachain registration API. pub trait Registrar { diff --git a/polkadot/runtime/common/src/try_runtime.rs b/polkadot/runtime/common/src/try_runtime.rs index 81aa34317bfd7..b22e170329206 100644 --- a/polkadot/runtime/common/src/try_runtime.rs +++ b/polkadot/runtime/common/src/try_runtime.rs @@ -16,13 +16,13 @@ //! Common try-runtime only tests for runtimes. +use alloc::{collections::btree_set::BTreeSet, vec::Vec}; use frame_support::{ dispatch::RawOrigin, traits::{Get, Hooks}, }; use pallet_fast_unstake::{Pallet as FastUnstake, *}; use pallet_staking::*; -use sp_std::{collections::btree_set::BTreeSet, prelude::*}; /// register all inactive nominators for fast-unstake, and progress until they have all been /// processed. diff --git a/polkadot/runtime/common/src/xcm_sender.rs b/polkadot/runtime/common/src/xcm_sender.rs index 5858a0ac3ca76..dace785a535b9 100644 --- a/polkadot/runtime/common/src/xcm_sender.rs +++ b/polkadot/runtime/common/src/xcm_sender.rs @@ -16,7 +16,9 @@ //! XCM sender for relay chain. +use alloc::vec::Vec; use codec::{Decode, Encode}; +use core::marker::PhantomData; use frame_support::traits::Get; use frame_system::pallet_prelude::BlockNumberFor; use polkadot_primitives::Id as ParaId; @@ -25,7 +27,6 @@ use polkadot_runtime_parachains::{ dmp, FeeTracker, }; use sp_runtime::FixedPointNumber; -use sp_std::{marker::PhantomData, prelude::*}; use xcm::prelude::*; use xcm_builder::InspectMessageQueues; use SendError::*; @@ -56,7 +57,7 @@ impl PriceForMessageDelivery for NoPriceForMessageDelivery { } /// Implementation of [`PriceForMessageDelivery`] which returns a fixed price. -pub struct ConstantPrice(sp_std::marker::PhantomData); +pub struct ConstantPrice(core::marker::PhantomData); impl> PriceForMessageDelivery for ConstantPrice { type Id = (); @@ -79,7 +80,7 @@ impl> PriceForMessageDelivery for ConstantPrice { /// - `B`: The base fee to pay for message delivery. /// - `M`: The fee to pay for each and every byte of the message after encoding it. /// - `F`: A fee factor multiplier. It can be understood as the exponent term in the formula. -pub struct ExponentialPrice(sp_std::marker::PhantomData<(A, B, M, F)>); +pub struct ExponentialPrice(core::marker::PhantomData<(A, B, M, F)>); impl, B: Get, M: Get, F: FeeTracker> PriceForMessageDelivery for ExponentialPrice { @@ -169,7 +170,7 @@ pub struct ToParachainDeliveryHelper< ParaId, ToParaIdHelper, >( - sp_std::marker::PhantomData<( + core::marker::PhantomData<( XcmConfig, ExistentialDeposit, PriceForDelivery, @@ -223,7 +224,7 @@ impl< } // overestimate delivery fee - let overestimated_xcm = vec![ClearOrigin; 128].into(); + let overestimated_xcm = alloc::vec![ClearOrigin; 128].into(); let overestimated_fees = PriceForDelivery::price_for_delivery(Parachain::get(), &overestimated_xcm); @@ -258,6 +259,7 @@ impl EnsureForParachain for () { mod tests { use super::*; use crate::integration_tests::new_test_ext; + use alloc::vec; use frame_support::{assert_ok, parameter_types}; use polkadot_runtime_parachains::FeeTracker; use sp_runtime::FixedU128; diff --git a/polkadot/runtime/metrics/Cargo.toml b/polkadot/runtime/metrics/Cargo.toml index 54c685effc116..3709e1eb697ea 100644 --- a/polkadot/runtime/metrics/Cargo.toml +++ b/polkadot/runtime/metrics/Cargo.toml @@ -10,7 +10,6 @@ description = "Runtime metric interface for the Polkadot node" workspace = true [dependencies] -sp-std = { workspace = true } sp-tracing = { workspace = true } codec = { workspace = true } polkadot-primitives = { workspace = true } @@ -25,7 +24,6 @@ std = [ "codec/std", "frame-benchmarking?/std", "polkadot-primitives/std", - "sp-std/std", "sp-tracing/std", ] runtime-metrics = ["frame-benchmarking", "sp-tracing/with-tracing"] diff --git a/polkadot/runtime/metrics/src/lib.rs b/polkadot/runtime/metrics/src/lib.rs index 6164d71f112a4..479ec7a69c3aa 100644 --- a/polkadot/runtime/metrics/src/lib.rs +++ b/polkadot/runtime/metrics/src/lib.rs @@ -22,6 +22,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(feature = "runtime-metrics")] mod with_runtime_metrics; #[cfg(feature = "runtime-metrics")] diff --git a/polkadot/runtime/metrics/src/with_runtime_metrics.rs b/polkadot/runtime/metrics/src/with_runtime_metrics.rs index 1339df9ff6879..979d5eda9afc6 100644 --- a/polkadot/runtime/metrics/src/with_runtime_metrics.rs +++ b/polkadot/runtime/metrics/src/with_runtime_metrics.rs @@ -22,14 +22,13 @@ const TRACING_TARGET: &'static str = "metrics"; +use alloc::vec::Vec; use codec::Encode; use polkadot_primitives::{ metric_definitions::{CounterDefinition, CounterVecDefinition, HistogramDefinition}, RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricUpdate, }; -use sp_std::prelude::*; - /// Holds a set of counters that have different values for their labels, /// like Prometheus `CounterVec`. pub struct CounterVec { diff --git a/polkadot/runtime/parachains/Cargo.toml b/polkadot/runtime/parachains/Cargo.toml index 82ba22a70f37b..7afdf49fe5516 100644 --- a/polkadot/runtime/parachains/Cargo.toml +++ b/polkadot/runtime/parachains/Cargo.toml @@ -21,7 +21,6 @@ bitflags = { workspace = true } sp-api = { workspace = true } sp-inherents = { workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-session = { workspace = true } @@ -110,7 +109,6 @@ std = [ "sp-runtime/std", "sp-session/std", "sp-staking/std", - "sp-std/std", "xcm-executor/std", "xcm/std", ] diff --git a/polkadot/runtime/parachains/src/assigner_coretime/mod.rs b/polkadot/runtime/parachains/src/assigner_coretime/mod.rs index e68ac2664b898..9ed007919b81b 100644 --- a/polkadot/runtime/parachains/src/assigner_coretime/mod.rs +++ b/polkadot/runtime/parachains/src/assigner_coretime/mod.rs @@ -34,14 +34,13 @@ use crate::{ ParaId, }; +use alloc::{vec, vec::Vec}; use frame_support::{defensive, pallet_prelude::*}; use frame_system::pallet_prelude::*; use pallet_broker::CoreAssignment; use polkadot_primitives::CoreIndex; use sp_runtime::traits::{One, Saturating}; -use sp_std::prelude::*; - pub use pallet::*; /// Fraction expressed as a nominator with an assumed denominator of 57,600. diff --git a/polkadot/runtime/parachains/src/assigner_coretime/tests.rs b/polkadot/runtime/parachains/src/assigner_coretime/tests.rs index bab09eda52c2d..9b0cbcb2d7d69 100644 --- a/polkadot/runtime/parachains/src/assigner_coretime/tests.rs +++ b/polkadot/runtime/parachains/src/assigner_coretime/tests.rs @@ -26,10 +26,10 @@ use crate::{ paras::{ParaGenesisArgs, ParaKind}, scheduler::common::Assignment, }; +use alloc::collections::btree_map::BTreeMap; use frame_support::{assert_noop, assert_ok, pallet_prelude::*, traits::Currency}; use pallet_broker::TaskId; use polkadot_primitives::{BlockNumber, Id as ParaId, SessionIndex, ValidationCode}; -use sp_std::collections::btree_map::BTreeMap; fn schedule_blank_para(id: ParaId, parakind: ParaKind) { let validation_code: ValidationCode = vec![1, 2, 3].into(); diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/benchmarking.rs b/polkadot/runtime/parachains/src/assigner_on_demand/benchmarking.rs index ba6951a146921..b0ebfe77a9665 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/benchmarking.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/benchmarking.rs @@ -25,6 +25,7 @@ use crate::{ shared::Pallet as ParasShared, }; +use alloc::vec; use frame_benchmarking::v2::*; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/migration.rs b/polkadot/runtime/parachains/src/assigner_on_demand/migration.rs index 314be11adbeb7..03f63d7333b65 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/migration.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/migration.rs @@ -23,7 +23,7 @@ use frame_support::{ mod v0 { use super::*; - use sp_std::collections::vec_deque::VecDeque; + use alloc::collections::vec_deque::VecDeque; #[derive(Encode, Decode, TypeInfo, Debug, PartialEq, Clone)] pub(super) struct EnqueuedOrder { @@ -50,7 +50,7 @@ mod v1 { use crate::assigner_on_demand::LOG_TARGET; /// Migration to V1 - pub struct UncheckedMigrateToV1(sp_std::marker::PhantomData); + pub struct UncheckedMigrateToV1(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for UncheckedMigrateToV1 { fn on_runtime_upgrade() -> Weight { let mut weight: Weight = Weight::zero(); @@ -88,7 +88,7 @@ mod v1 { } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { let n: u32 = v0::OnDemandQueue::::get().len() as u32; log::info!( @@ -100,7 +100,7 @@ mod v1 { } #[cfg(feature = "try-runtime")] - fn post_upgrade(state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + fn post_upgrade(state: alloc::vec::Vec) -> Result<(), sp_runtime::TryRuntimeError> { log::info!(target: LOG_TARGET, "Running post_upgrade()"); ensure!( diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/mod.rs b/polkadot/runtime/parachains/src/assigner_on_demand/mod.rs index 03f05842bca49..f045e957a6907 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/mod.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/mod.rs @@ -61,7 +61,6 @@ use sp_runtime::{ traits::{AccountIdConversion, One, SaturatedConversion}, FixedPointNumber, FixedPointOperand, FixedU128, Perbill, Saturating, }; -use sp_std::prelude::*; use types::{ BalanceOf, CoreAffinityCount, EnqueuedOrder, QueuePushDirection, QueueStatusType, SpotTrafficCalculationErr, diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs b/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs index a6074b305b4eb..0bad4346cfd9d 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs @@ -30,16 +30,14 @@ use crate::{ }, paras::{ParaGenesisArgs, ParaKind}, }; +use alloc::collections::btree_map::BTreeMap; +use core::cmp::{Ord, Ordering}; use frame_support::{assert_noop, assert_ok}; use pallet_balances::Error as BalancesError; use polkadot_primitives::{ BlockNumber, SessionIndex, ValidationCode, ON_DEMAND_MAX_QUEUE_MAX_SIZE, }; use sp_runtime::traits::BadOrigin; -use sp_std::{ - cmp::{Ord, Ordering}, - collections::btree_map::BTreeMap, -}; fn schedule_blank_para(id: ParaId, parakind: ParaKind) { let validation_code: ValidationCode = vec![1, 2, 3].into(); diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/types.rs b/polkadot/runtime/parachains/src/assigner_on_demand/types.rs index 51d586a77a178..96367b971fed5 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/types.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/types.rs @@ -18,16 +18,13 @@ use super::{alloc, pallet::Config}; use alloc::collections::BinaryHeap; +use core::cmp::{Ord, Ordering, PartialOrd}; use frame_support::{ pallet_prelude::{Decode, Encode, RuntimeDebug, TypeInfo}, traits::Currency, }; use polkadot_primitives::{CoreIndex, Id as ParaId, ON_DEMAND_MAX_QUEUE_MAX_SIZE}; use sp_runtime::FixedU128; -use sp_std::{ - cmp::{Ord, Ordering, PartialOrd}, - prelude::*, -}; /// Shorthand for the Balance type the runtime is using. pub type BalanceOf = diff --git a/polkadot/runtime/parachains/src/assigner_parachains/tests.rs b/polkadot/runtime/parachains/src/assigner_parachains/tests.rs index 14cb1a8978602..817e43a7138dd 100644 --- a/polkadot/runtime/parachains/src/assigner_parachains/tests.rs +++ b/polkadot/runtime/parachains/src/assigner_parachains/tests.rs @@ -23,9 +23,9 @@ use crate::{ }, paras::{ParaGenesisArgs, ParaKind}, }; +use alloc::collections::btree_map::BTreeMap; use frame_support::{assert_ok, pallet_prelude::*}; use polkadot_primitives::{BlockNumber, Id as ParaId, SessionIndex, ValidationCode}; -use sp_std::collections::btree_map::BTreeMap; fn schedule_blank_para(id: ParaId, parakind: ParaKind) { let validation_code: ValidationCode = vec![1, 2, 3].into(); diff --git a/polkadot/runtime/parachains/src/builder.rs b/polkadot/runtime/parachains/src/builder.rs index c046526ba372b..ec07cca2107e9 100644 --- a/polkadot/runtime/parachains/src/builder.rs +++ b/polkadot/runtime/parachains/src/builder.rs @@ -21,6 +21,11 @@ use crate::{ scheduler::{self, common::AssignmentProvider, CoreOccupied, ParasEntry}, session_info, shared, }; +use alloc::{ + collections::{btree_map::BTreeMap, btree_set::BTreeSet, vec_deque::VecDeque}, + vec, + vec::Vec, +}; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; @@ -39,11 +44,6 @@ use sp_runtime::{ traits::{Header as HeaderT, One, TrailingZeroInput, Zero}, RuntimeAppPublic, }; -use sp_std::{ - collections::{btree_map::BTreeMap, btree_set::BTreeSet, vec_deque::VecDeque}, - prelude::Vec, - vec, -}; fn mock_validation_code() -> ValidationCode { ValidationCode(vec![1, 2, 3]) @@ -112,7 +112,7 @@ pub(crate) struct BenchBuilder { fill_claimqueue: bool, /// Cores which should not be available when being populated with pending candidates. unavailable_cores: Vec, - _phantom: sp_std::marker::PhantomData, + _phantom: core::marker::PhantomData, } /// Paras inherent `enter` benchmark scenario. @@ -143,7 +143,7 @@ impl BenchBuilder { code_upgrade: None, fill_claimqueue: true, unavailable_cores: vec![], - _phantom: sp_std::marker::PhantomData::, + _phantom: core::marker::PhantomData::, } } diff --git a/polkadot/runtime/parachains/src/configuration.rs b/polkadot/runtime/parachains/src/configuration.rs index bffeab4a0d21b..d09962ef2b441 100644 --- a/polkadot/runtime/parachains/src/configuration.rs +++ b/polkadot/runtime/parachains/src/configuration.rs @@ -19,6 +19,7 @@ //! Configuration can change only at session boundaries and is buffered until then. use crate::{inclusion::MAX_UPWARD_MESSAGE_SIZE_BOUND, shared}; +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::{pallet_prelude::*, DefaultNoBound}; use frame_system::pallet_prelude::*; @@ -31,7 +32,6 @@ use polkadot_primitives::{ MAX_POV_SIZE, ON_DEMAND_MAX_QUEUE_MAX_SIZE, }; use sp_runtime::{traits::Zero, Perbill, Percent}; -use sp_std::prelude::*; #[cfg(test)] mod tests; @@ -345,7 +345,7 @@ pub enum InconsistentError { impl HostConfiguration where - BlockNumber: Zero + PartialOrd + sp_std::fmt::Debug + Clone + From, + BlockNumber: Zero + PartialOrd + core::fmt::Debug + Clone + From, { /// Checks that this instance is consistent with the requirements on each individual member. /// @@ -1469,7 +1469,7 @@ impl Pallet { /// The implementation of `Get<(u32, u32)>` which reads `ActiveConfig` and returns `P` percent of /// `hrmp_channel_max_message_size` / `hrmp_channel_max_capacity`. -pub struct ActiveConfigHrmpChannelSizeAndCapacityRatio(sp_std::marker::PhantomData<(T, P)>); +pub struct ActiveConfigHrmpChannelSizeAndCapacityRatio(core::marker::PhantomData<(T, P)>); impl> Get<(u32, u32)> for ActiveConfigHrmpChannelSizeAndCapacityRatio { diff --git a/polkadot/runtime/parachains/src/configuration/migration/v10.rs b/polkadot/runtime/parachains/src/configuration/migration/v10.rs index c53f58faaf03a..9375af88306fd 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v10.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v10.rs @@ -17,6 +17,7 @@ //! A module that is responsible for migration of storage. use crate::configuration::{Config, Pallet}; +use alloc::vec::Vec; use frame_support::{ pallet_prelude::*, traits::{Defensive, UncheckedOnRuntimeUpgrade}, @@ -28,7 +29,6 @@ use polkadot_primitives::{ LEGACY_MIN_BACKING_VOTES, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; use sp_runtime::Perbill; -use sp_std::vec::Vec; use super::v9::V9HostConfiguration; // All configuration of the runtime with respect to paras. @@ -164,7 +164,7 @@ mod v10 { >; } -pub struct VersionUncheckedMigrateToV10(sp_std::marker::PhantomData); +pub struct VersionUncheckedMigrateToV10(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV10 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { diff --git a/polkadot/runtime/parachains/src/configuration/migration/v11.rs b/polkadot/runtime/parachains/src/configuration/migration/v11.rs index 4d1bfc26196ca..4dce48fe52b0e 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v11.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v11.rs @@ -17,6 +17,7 @@ //! A module that is responsible for migration of storage. use crate::configuration::{self, Config, Pallet}; +use alloc::vec::Vec; use frame_support::{ migrations::VersionedMigration, pallet_prelude::*, @@ -28,7 +29,6 @@ use polkadot_primitives::{ ApprovalVotingParams, AsyncBackingParams, ExecutorParams, NodeFeatures, SessionIndex, LEGACY_MIN_BACKING_VOTES, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; -use sp_std::vec::Vec; use polkadot_core_primitives::Balance; use sp_arithmetic::Perbill; @@ -177,7 +177,7 @@ pub type MigrateToV11 = VersionedMigration< ::DbWeight, >; -pub struct UncheckedMigrateToV11(sp_std::marker::PhantomData); +pub struct UncheckedMigrateToV11(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for UncheckedMigrateToV11 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { diff --git a/polkadot/runtime/parachains/src/configuration/migration/v12.rs b/polkadot/runtime/parachains/src/configuration/migration/v12.rs index 126597ed84544..6b77655687f0d 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v12.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v12.rs @@ -17,6 +17,7 @@ //! A module that is responsible for migration of storage. use crate::configuration::{self, migration::v11::V11HostConfiguration, Config, Pallet}; +use alloc::vec::Vec; use frame_support::{ migrations::VersionedMigration, pallet_prelude::*, @@ -26,7 +27,6 @@ use frame_system::pallet_prelude::BlockNumberFor; use polkadot_primitives::vstaging::SchedulerParams; use sp_core::Get; use sp_staking::SessionIndex; -use sp_std::vec::Vec; type V12HostConfiguration = configuration::HostConfiguration; @@ -68,7 +68,7 @@ pub type MigrateToV12 = VersionedMigration< ::DbWeight, >; -pub struct UncheckedMigrateToV12(sp_std::marker::PhantomData); +pub struct UncheckedMigrateToV12(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for UncheckedMigrateToV12 { #[cfg(feature = "try-runtime")] diff --git a/polkadot/runtime/parachains/src/configuration/migration/v6.rs b/polkadot/runtime/parachains/src/configuration/migration/v6.rs index bec41d3ea0dc5..468bf78692a12 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v6.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v6.rs @@ -17,13 +17,11 @@ //! Contains the V6 storage definition of the host configuration. use crate::configuration::{Config, Pallet}; +use alloc::vec::Vec; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::BlockNumberFor; -use sp_std::vec::Vec; use polkadot_primitives::{AsyncBackingParams, Balance, ExecutorParams, SessionIndex}; -#[cfg(feature = "try-runtime")] -use sp_std::prelude::*; #[derive(codec::Encode, codec::Decode, Debug, Clone)] pub struct V6HostConfiguration { diff --git a/polkadot/runtime/parachains/src/configuration/migration/v7.rs b/polkadot/runtime/parachains/src/configuration/migration/v7.rs index 8fe4087cf9b17..9acd28d0f764e 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v7.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v7.rs @@ -17,6 +17,7 @@ //! A module that is responsible for migration of storage. use crate::configuration::{self, Config, Pallet}; +use alloc::vec::Vec; use frame_support::{ pallet_prelude::*, traits::{Defensive, StorageVersion}, @@ -24,7 +25,6 @@ use frame_support::{ }; use frame_system::pallet_prelude::BlockNumberFor; use polkadot_primitives::{AsyncBackingParams, Balance, ExecutorParams, SessionIndex}; -use sp_std::vec::Vec; use frame_support::traits::OnRuntimeUpgrade; @@ -154,7 +154,7 @@ mod v7 { >; } -pub struct MigrateToV7(sp_std::marker::PhantomData); +pub struct MigrateToV7(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV7 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { diff --git a/polkadot/runtime/parachains/src/configuration/migration/v8.rs b/polkadot/runtime/parachains/src/configuration/migration/v8.rs index 0aa7f550b102a..81ced74bebb97 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v8.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v8.rs @@ -17,6 +17,7 @@ //! A module that is responsible for migration of storage. use crate::configuration::{self, Config, Pallet}; +use alloc::vec::Vec; use frame_support::{ pallet_prelude::*, traits::{Defensive, StorageVersion}, @@ -27,7 +28,6 @@ use polkadot_primitives::{ AsyncBackingParams, Balance, ExecutorParams, SessionIndex, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; use sp_runtime::Perbill; -use sp_std::vec::Vec; use frame_support::traits::OnRuntimeUpgrade; @@ -161,7 +161,7 @@ mod v8 { >; } -pub struct MigrateToV8(sp_std::marker::PhantomData); +pub struct MigrateToV8(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV8 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { diff --git a/polkadot/runtime/parachains/src/configuration/migration/v9.rs b/polkadot/runtime/parachains/src/configuration/migration/v9.rs index 6afdd3cec29ef..dff5fdb17a697 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v9.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v9.rs @@ -17,6 +17,7 @@ //! A module that is responsible for migration of storage. use crate::configuration::{self, Config, Pallet}; +use alloc::vec::Vec; use frame_support::{ pallet_prelude::*, traits::{Defensive, StorageVersion}, @@ -28,7 +29,6 @@ use polkadot_primitives::{ ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; use sp_runtime::Perbill; -use sp_std::vec::Vec; use frame_support::traits::OnRuntimeUpgrade; @@ -164,7 +164,7 @@ mod v9 { >; } -pub struct MigrateToV9(sp_std::marker::PhantomData); +pub struct MigrateToV9(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV9 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { diff --git a/polkadot/runtime/parachains/src/coretime/migration.rs b/polkadot/runtime/parachains/src/coretime/migration.rs index 3f82472da8aa4..4e75088675590 100644 --- a/polkadot/runtime/parachains/src/coretime/migration.rs +++ b/polkadot/runtime/parachains/src/coretime/migration.rs @@ -26,10 +26,12 @@ mod v_coretime { coretime::{mk_coretime_call, Config, PartsOf57600, WeightInfo}, paras, }; + use alloc::{vec, vec::Vec}; #[cfg(feature = "try-runtime")] use codec::Decode; #[cfg(feature = "try-runtime")] use codec::Encode; + use core::{iter, result}; #[cfg(feature = "try-runtime")] use frame_support::ensure; use frame_support::{ @@ -43,9 +45,6 @@ mod v_coretime { use sp_arithmetic::traits::SaturatedConversion; use sp_core::Get; use sp_runtime::BoundedVec; - #[cfg(feature = "try-runtime")] - use sp_std::vec::Vec; - use sp_std::{iter, prelude::*, result}; use xcm::prelude::{send_xcm, Instruction, Junction, Location, SendError, WeightLimit, Xcm}; /// Return information about a legacy lease of a parachain. @@ -59,7 +58,7 @@ mod v_coretime { /// This assumes that the `Coretime` and the `AssignerCoretime` pallets are added at the same /// time to a runtime. pub struct MigrateToCoretime( - sp_std::marker::PhantomData<(T, SendXcm, LegacyLease)>, + core::marker::PhantomData<(T, SendXcm, LegacyLease)>, ); impl>> diff --git a/polkadot/runtime/parachains/src/coretime/mod.rs b/polkadot/runtime/parachains/src/coretime/mod.rs index fc8a3c7d9d24b..1c38b3989232b 100644 --- a/polkadot/runtime/parachains/src/coretime/mod.rs +++ b/polkadot/runtime/parachains/src/coretime/mod.rs @@ -18,6 +18,8 @@ //! //! +use alloc::{vec, vec::Vec}; +use core::result; use frame_support::{ pallet_prelude::*, traits::{defensive_prelude::*, Currency}, @@ -28,7 +30,6 @@ use pallet_broker::{CoreAssignment, CoreIndex as BrokerCoreIndex}; use polkadot_primitives::{Balance, BlockNumber, CoreIndex, Id as ParaId}; use sp_arithmetic::traits::SaturatedConversion; use sp_runtime::traits::TryConvert; -use sp_std::{prelude::*, result}; use xcm::{ prelude::{send_xcm, Instruction, Junction, Location, OriginKind, SendXcm, WeightLimit, Xcm}, v4::{ diff --git a/polkadot/runtime/parachains/src/disputes.rs b/polkadot/runtime/parachains/src/disputes.rs index 4a0f2390b45dc..f86573dadf562 100644 --- a/polkadot/runtime/parachains/src/disputes.rs +++ b/polkadot/runtime/parachains/src/disputes.rs @@ -19,8 +19,10 @@ use crate::{ configuration, initializer::SessionChangeNotification, metrics::METRICS, session_info, }; +use alloc::{collections::btree_set::BTreeSet, vec::Vec}; use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0}; use codec::{Decode, Encode}; +use core::cmp::Ordering; use frame_support::{ensure, weights::Weight}; use frame_system::pallet_prelude::*; use polkadot_primitives::{ @@ -36,7 +38,6 @@ use sp_runtime::{ traits::{AppVerify, One, Saturating, Zero}, DispatchError, RuntimeDebug, SaturatedConversion, }; -use sp_std::{cmp::Ordering, collections::btree_set::BTreeSet, prelude::*}; #[cfg(test)] #[allow(unused_imports)] diff --git a/polkadot/runtime/parachains/src/disputes/migration.rs b/polkadot/runtime/parachains/src/disputes/migration.rs index e12edffb51b38..dd32340c9f64f 100644 --- a/polkadot/runtime/parachains/src/disputes/migration.rs +++ b/polkadot/runtime/parachains/src/disputes/migration.rs @@ -21,16 +21,16 @@ use frame_support::traits::StorageVersion; pub mod v1 { use super::*; use crate::disputes::{Config, Pallet}; + use alloc::vec::Vec; use frame_support::{ pallet_prelude::*, storage_alias, traits::OnRuntimeUpgrade, weights::Weight, }; use polkadot_primitives::SessionIndex; - use sp_std::prelude::*; #[storage_alias] type SpamSlots = StorageMap, Twox64Concat, SessionIndex, Vec>; - pub struct MigrateToV1(sp_std::marker::PhantomData); + pub struct MigrateToV1(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { fn on_runtime_upgrade() -> Weight { let mut weight: Weight = Weight::zero(); diff --git a/polkadot/runtime/parachains/src/disputes/slashing.rs b/polkadot/runtime/parachains/src/disputes/slashing.rs index b50853ecc696c..4b76fb47e1f8d 100644 --- a/polkadot/runtime/parachains/src/disputes/slashing.rs +++ b/polkadot/runtime/parachains/src/disputes/slashing.rs @@ -50,6 +50,12 @@ use frame_support::{ }; use frame_system::pallet_prelude::BlockNumberFor; +use alloc::{ + boxed::Box, + collections::{btree_map::Entry, btree_set::BTreeSet}, + vec, + vec::Vec, +}; use polkadot_primitives::{ slashing::{DisputeProof, DisputesTimeSlot, PendingSlashes, SlashingOffenceKind}, CandidateHash, SessionIndex, ValidatorId, ValidatorIndex, @@ -65,10 +71,6 @@ use sp_runtime::{ }; use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::offence::{Kind, Offence, OffenceError, ReportOffence}; -use sp_std::{ - collections::{btree_map::Entry, btree_set::BTreeSet}, - prelude::*, -}; const LOG_TARGET: &str = "runtime::parachains::slashing"; @@ -158,7 +160,7 @@ impl SlashingOffence { /// This type implements `SlashingHandler`. pub struct SlashValidatorsForDisputes { - _phantom: sp_std::marker::PhantomData, + _phantom: core::marker::PhantomData, } impl Default for SlashValidatorsForDisputes { @@ -640,7 +642,7 @@ fn is_known_offence( /// When configured properly, should be instantiated with /// `T::KeyOwnerIdentification, Offences, ReportLongevity` parameters. pub struct SlashingReportHandler { - _phantom: sp_std::marker::PhantomData<(I, R, L)>, + _phantom: core::marker::PhantomData<(I, R, L)>, } impl Default for SlashingReportHandler { diff --git a/polkadot/runtime/parachains/src/dmp.rs b/polkadot/runtime/parachains/src/dmp.rs index c0e1635ba1692..54e112d1b8b44 100644 --- a/polkadot/runtime/parachains/src/dmp.rs +++ b/polkadot/runtime/parachains/src/dmp.rs @@ -46,6 +46,8 @@ use crate::{ configuration::{self, HostConfiguration}, initializer, FeeTracker, }; +use alloc::vec::Vec; +use core::fmt; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::BlockNumberFor; use polkadot_primitives::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage}; @@ -54,7 +56,6 @@ use sp_runtime::{ traits::{BlakeTwo256, Hash as HashT, SaturatedConversion}, FixedU128, Saturating, }; -use sp_std::{fmt, prelude::*}; use xcm::latest::SendError; pub use pallet::*; diff --git a/polkadot/runtime/parachains/src/hrmp.rs b/polkadot/runtime/parachains/src/hrmp.rs index e34e4a03e711c..8b01a755c3c7b 100644 --- a/polkadot/runtime/parachains/src/hrmp.rs +++ b/polkadot/runtime/parachains/src/hrmp.rs @@ -18,7 +18,13 @@ use crate::{ configuration::{self, HostConfiguration}, dmp, ensure_parachain, initializer, paras, }; +use alloc::{ + collections::{btree_map::BTreeMap, btree_set::BTreeSet}, + vec, + vec::Vec, +}; use codec::{Decode, Encode}; +use core::{fmt, mem}; use frame_support::{pallet_prelude::*, traits::ReservableCurrency, DefaultNoBound}; use frame_system::pallet_prelude::*; use polkadot_parachain_primitives::primitives::{HorizontalMessages, IsSystem}; @@ -31,11 +37,6 @@ use sp_runtime::{ traits::{AccountIdConversion, BlakeTwo256, Hash as HashT, UniqueSaturatedInto, Zero}, ArithmeticError, }; -use sp_std::{ - collections::{btree_map::BTreeMap, btree_set::BTreeSet}, - fmt, mem, - prelude::*, -}; pub use pallet::*; @@ -487,7 +488,7 @@ pub mod pallet { #[derive(DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - _config: sp_std::marker::PhantomData, + _config: core::marker::PhantomData, preopen_hrmp_channels: Vec<(ParaId, ParaId, u32, u32)>, } diff --git a/polkadot/runtime/parachains/src/inclusion/migration.rs b/polkadot/runtime/parachains/src/inclusion/migration.rs index a340d52643e05..36a810d341c65 100644 --- a/polkadot/runtime/parachains/src/inclusion/migration.rs +++ b/polkadot/runtime/parachains/src/inclusion/migration.rs @@ -73,9 +73,9 @@ mod v1 { CandidatePendingAvailability as V1CandidatePendingAvailability, Config, Pallet, PendingAvailability as V1PendingAvailability, }; + use alloc::{collections::vec_deque::VecDeque, vec::Vec}; use frame_support::{traits::UncheckedOnRuntimeUpgrade, weights::Weight}; use sp_core::Get; - use sp_std::{collections::vec_deque::VecDeque, vec::Vec}; #[cfg(feature = "try-runtime")] use codec::{Decode, Encode}; @@ -85,7 +85,7 @@ mod v1 { traits::{GetStorageVersion, StorageVersion}, }; - pub struct VersionUncheckedMigrateToV1(sp_std::marker::PhantomData); + pub struct VersionUncheckedMigrateToV1(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV1 { #[cfg(feature = "try-runtime")] diff --git a/polkadot/runtime/parachains/src/inclusion/mod.rs b/polkadot/runtime/parachains/src/inclusion/mod.rs index a86941a1a0b8e..281dc5d0c5f47 100644 --- a/polkadot/runtime/parachains/src/inclusion/mod.rs +++ b/polkadot/runtime/parachains/src/inclusion/mod.rs @@ -27,8 +27,15 @@ use crate::{ shared::{self, AllowedRelayParentsTracker}, util::make_persisted_validation_data_with_parent, }; +use alloc::{ + collections::{btree_map::BTreeMap, btree_set::BTreeSet, vec_deque::VecDeque}, + vec, + vec::Vec, +}; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use codec::{Decode, Encode}; +#[cfg(feature = "std")] +use core::fmt; use frame_support::{ defensive, pallet_prelude::*, @@ -46,12 +53,6 @@ use polkadot_primitives::{ }; use scale_info::TypeInfo; use sp_runtime::{traits::One, DispatchError, SaturatedConversion, Saturating}; -#[cfg(feature = "std")] -use sp_std::fmt; -use sp_std::{ - collections::{btree_map::BTreeMap, btree_set::BTreeSet, vec_deque::VecDeque}, - prelude::*, -}; pub use pallet::*; diff --git a/polkadot/runtime/parachains/src/initializer.rs b/polkadot/runtime/parachains/src/initializer.rs index fd0f1c3c06511..340f727097b58 100644 --- a/polkadot/runtime/parachains/src/initializer.rs +++ b/polkadot/runtime/parachains/src/initializer.rs @@ -25,6 +25,7 @@ use crate::{ disputes::{self, DisputesHandler as _, SlashingHandler as _}, dmp, hrmp, inclusion, paras, scheduler, session_info, shared, }; +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::{ traits::{OneSessionHandler, Randomness}, @@ -33,7 +34,6 @@ use frame_support::{ use frame_system::limits::BlockWeights; use polkadot_primitives::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId}; use scale_info::TypeInfo; -use sp_std::prelude::*; #[cfg(test)] mod tests; @@ -249,7 +249,7 @@ impl Pallet { // TODO: audit usage of randomness API // https://github.com/paritytech/polkadot/issues/2601 let (random_hash, _) = T::Randomness::random(&b"paras"[..]); - let len = sp_std::cmp::min(32, random_hash.as_ref().len()); + let len = core::cmp::min(32, random_hash.as_ref().len()); buf[..len].copy_from_slice(&random_hash.as_ref()[..len]); buf }; diff --git a/polkadot/runtime/parachains/src/lib.rs b/polkadot/runtime/parachains/src/lib.rs index 51110e89416c3..f2995d770e716 100644 --- a/polkadot/runtime/parachains/src/lib.rs +++ b/polkadot/runtime/parachains/src/lib.rs @@ -53,6 +53,8 @@ mod mock; #[cfg(test)] mod ump_tests; +extern crate alloc; + pub use origin::{ensure_parachain, Origin}; pub use paras::{ParaLifecycle, UpgradeStrategy}; use polkadot_primitives::{HeadData, Id as ParaId, ValidationCode}; diff --git a/polkadot/runtime/parachains/src/mock.rs b/polkadot/runtime/parachains/src/mock.rs index 9c23347ebb58b..45576668f6d62 100644 --- a/polkadot/runtime/parachains/src/mock.rs +++ b/polkadot/runtime/parachains/src/mock.rs @@ -51,11 +51,10 @@ use sp_runtime::{ transaction_validity::TransactionPriority, BuildStorage, FixedU128, Perbill, Permill, }; -use sp_std::{ +use std::{ cell::RefCell, - collections::{btree_map::BTreeMap, vec_deque::VecDeque}, + collections::{btree_map::BTreeMap, vec_deque::VecDeque, HashMap}, }; -use std::collections::HashMap; use xcm::{ prelude::XcmVersion, v4::{Assets, InteriorLocation, Location, SendError, SendResult, SendXcm, Xcm, XcmHash}, @@ -677,7 +676,7 @@ impl inclusion::RewardValidators for TestRewardValidators { /// Create a new set of test externalities. pub fn new_test_ext(state: MockGenesisConfig) -> TestExternalities { use sp_keystore::{testing::MemoryKeystore, KeystoreExt, KeystorePtr}; - use sp_std::sync::Arc; + use std::sync::Arc; sp_tracing::try_init_simple(); diff --git a/polkadot/runtime/parachains/src/origin.rs b/polkadot/runtime/parachains/src/origin.rs index 5202cba232d20..fd22929b08ff5 100644 --- a/polkadot/runtime/parachains/src/origin.rs +++ b/polkadot/runtime/parachains/src/origin.rs @@ -16,9 +16,9 @@ //! Declaration of the parachain specific origin and a pallet that hosts it. +use core::result; use polkadot_primitives::Id as ParaId; use sp_runtime::traits::BadOrigin; -use sp_std::result; pub use pallet::*; diff --git a/polkadot/runtime/parachains/src/paras/benchmarking.rs b/polkadot/runtime/parachains/src/paras/benchmarking.rs index 0f3318612a77c..630b86132ab88 100644 --- a/polkadot/runtime/parachains/src/paras/benchmarking.rs +++ b/polkadot/runtime/parachains/src/paras/benchmarking.rs @@ -16,6 +16,7 @@ use super::*; use crate::configuration::HostConfiguration; +use alloc::vec; use frame_benchmarking::benchmarks; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use polkadot_primitives::{ diff --git a/polkadot/runtime/parachains/src/paras/benchmarking/pvf_check.rs b/polkadot/runtime/parachains/src/paras/benchmarking/pvf_check.rs index 0bf5fe783a0e7..80443c7626e2b 100644 --- a/polkadot/runtime/parachains/src/paras/benchmarking/pvf_check.rs +++ b/polkadot/runtime/parachains/src/paras/benchmarking/pvf_check.rs @@ -17,6 +17,7 @@ //! This module focuses on the benchmarking of the `include_pvf_check_statement` dispatchable. use crate::{configuration, paras::*, shared::Pallet as ParasShared}; +use alloc::{vec, vec::Vec}; use frame_support::assert_ok; use frame_system::RawOrigin; use polkadot_primitives::{HeadData, Id as ParaId, ValidationCode, ValidatorId, ValidatorIndex}; diff --git a/polkadot/runtime/parachains/src/paras/mod.rs b/polkadot/runtime/parachains/src/paras/mod.rs index 8cffcbbbb024f..3f0b8659b1599 100644 --- a/polkadot/runtime/parachains/src/paras/mod.rs +++ b/polkadot/runtime/parachains/src/paras/mod.rs @@ -113,8 +113,10 @@ use crate::{ initializer::SessionChangeNotification, shared, }; +use alloc::{collections::btree_set::BTreeSet, vec::Vec}; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use codec::{Decode, Encode}; +use core::{cmp, mem}; use frame_support::{pallet_prelude::*, traits::EstimateNextSessionRotation, DefaultNoBound}; use frame_system::pallet_prelude::*; use polkadot_primitives::{ @@ -127,7 +129,6 @@ use sp_runtime::{ traits::{AppVerify, One, Saturating}, DispatchResult, SaturatedConversion, }; -use sp_std::{cmp, collections::btree_set::BTreeSet, mem, prelude::*}; use serde::{Deserialize, Serialize}; @@ -863,7 +864,7 @@ pub mod pallet { #[derive(DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, pub paras: Vec<(ParaId, ParaGenesisArgs)>, } diff --git a/polkadot/runtime/parachains/src/paras_inherent/benchmarking.rs b/polkadot/runtime/parachains/src/paras_inherent/benchmarking.rs index 4c8b093451ed5..c5284ba1dd1f8 100644 --- a/polkadot/runtime/parachains/src/paras_inherent/benchmarking.rs +++ b/polkadot/runtime/parachains/src/paras_inherent/benchmarking.rs @@ -16,9 +16,10 @@ use super::*; use crate::{inclusion, ParaId}; +use alloc::collections::btree_map::BTreeMap; +use core::cmp::min; use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; use frame_system::RawOrigin; -use sp_std::{cmp::min, collections::btree_map::BTreeMap}; use polkadot_primitives::v7::GroupIndex; diff --git a/polkadot/runtime/parachains/src/paras_inherent/misc.rs b/polkadot/runtime/parachains/src/paras_inherent/misc.rs index dac9e6e256d0e..2858c3f95de26 100644 --- a/polkadot/runtime/parachains/src/paras_inherent/misc.rs +++ b/polkadot/runtime/parachains/src/paras_inherent/misc.rs @@ -14,7 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use sp_std::{cmp::Ordering, vec::Vec}; +use alloc::vec::Vec; +use core::cmp::Ordering; /// A helper trait to allow calling retain while getting access /// to the index of the item in the `vec`. diff --git a/polkadot/runtime/parachains/src/paras_inherent/mod.rs b/polkadot/runtime/parachains/src/paras_inherent/mod.rs index 8b527c09490d6..fe4eef16f0227 100644 --- a/polkadot/runtime/parachains/src/paras_inherent/mod.rs +++ b/polkadot/runtime/parachains/src/paras_inherent/mod.rs @@ -32,6 +32,11 @@ use crate::{ shared::{self, AllowedRelayParentsTracker}, ParaId, }; +use alloc::{ + collections::{btree_map::BTreeMap, btree_set::BTreeSet}, + vec, + vec::Vec, +}; use bitvec::prelude::BitVec; use frame_support::{ defensive, @@ -53,11 +58,6 @@ use polkadot_primitives::{ use rand::{seq::SliceRandom, SeedableRng}; use scale_info::TypeInfo; use sp_runtime::traits::{Header as HeaderT, One}; -use sp_std::{ - collections::{btree_map::BTreeMap, btree_set::BTreeSet}, - prelude::*, - vec::Vec, -}; mod misc; mod weights; @@ -295,7 +295,7 @@ impl Pallet { fn process_inherent_data( data: ParachainsInherentData>, context: ProcessInherentDataContext, - ) -> sp_std::result::Result< + ) -> core::result::Result< (ParachainsInherentData>, PostDispatchInfo), DispatchErrorWithPostInfo, > { @@ -762,7 +762,7 @@ pub(crate) fn apply_weight_limit( let mut chained_candidates: Vec> = Vec::new(); let mut current_para_id = None; - for candidate in sp_std::mem::take(candidates).into_iter() { + for candidate in core::mem::take(candidates).into_iter() { let candidate_para_id = candidate.descriptor().para_id; if Some(candidate_para_id) == current_para_id { let chain = chained_candidates diff --git a/polkadot/runtime/parachains/src/paras_inherent/tests.rs b/polkadot/runtime/parachains/src/paras_inherent/tests.rs index abf1c1a56b24b..0d5653eb729d6 100644 --- a/polkadot/runtime/parachains/src/paras_inherent/tests.rs +++ b/polkadot/runtime/parachains/src/paras_inherent/tests.rs @@ -53,13 +53,13 @@ mod enter { }, session_info, }; + use alloc::collections::btree_map::BTreeMap; use assert_matches::assert_matches; use core::panic; use frame_support::assert_ok; use frame_system::limits; use polkadot_primitives::{vstaging::SchedulerParams, AvailabilityBitfield, UncheckedSigned}; use sp_runtime::Perbill; - use sp_std::collections::btree_map::BTreeMap; struct TestConfig { dispute_statements: BTreeMap, @@ -1744,8 +1744,8 @@ mod sanitizers { scheduler::{common::Assignment, ParasEntry}, util::{make_persisted_validation_data, make_persisted_validation_data_with_parent}, }; + use alloc::collections::vec_deque::VecDeque; use polkadot_primitives::ValidationCode; - use sp_std::collections::vec_deque::VecDeque; use super::*; diff --git a/polkadot/runtime/parachains/src/reward_points.rs b/polkadot/runtime/parachains/src/reward_points.rs index 5f45445b0ba2a..69ef2db756c21 100644 --- a/polkadot/runtime/parachains/src/reward_points.rs +++ b/polkadot/runtime/parachains/src/reward_points.rs @@ -22,9 +22,9 @@ //! for the time being, although we will build schemes to do so in the future. use crate::{session_info, shared}; +use alloc::collections::btree_set::BTreeSet; use frame_support::traits::{Defensive, ValidatorSet}; use polkadot_primitives::{SessionIndex, ValidatorIndex}; -use sp_std::collections::btree_set::BTreeSet; /// The amount of era points given by backing a candidate that is included. pub const BACKING_POINTS: u32 = 20; @@ -32,7 +32,7 @@ pub const BACKING_POINTS: u32 = 20; pub const DISPUTE_STATEMENT_POINTS: u32 = 20; /// Rewards validators for participating in parachains with era points in pallet-staking. -pub struct RewardValidatorsWithEraPoints(sp_std::marker::PhantomData); +pub struct RewardValidatorsWithEraPoints(core::marker::PhantomData); impl RewardValidatorsWithEraPoints where diff --git a/polkadot/runtime/parachains/src/runtime_api_impl/v10.rs b/polkadot/runtime/parachains/src/runtime_api_impl/v10.rs index 4417ec75abd67..6978902322113 100644 --- a/polkadot/runtime/parachains/src/runtime_api_impl/v10.rs +++ b/polkadot/runtime/parachains/src/runtime_api_impl/v10.rs @@ -22,6 +22,7 @@ use crate::{ scheduler::{self, CoreOccupied}, session_info, shared, }; +use alloc::{collections::btree_map::BTreeMap, vec, vec::Vec}; use frame_support::traits::{GetStorageVersion, StorageVersion}; use frame_system::pallet_prelude::*; use polkadot_primitives::{ @@ -37,7 +38,6 @@ use polkadot_primitives::{ ValidatorId, ValidatorIndex, ValidatorSignature, }; use sp_runtime::traits::One; -use sp_std::{collections::btree_map::BTreeMap, prelude::*}; /// Implementation for the `validators` function of the runtime API. pub fn validators() -> Vec { diff --git a/polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs b/polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs index f4e3db185fead..4aa381e33b1bc 100644 --- a/polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs +++ b/polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs @@ -17,12 +17,12 @@ //! Put implementations of functions from staging APIs here. use crate::{configuration, inclusion, initializer, scheduler}; -use polkadot_primitives::{CommittedCandidateReceipt, CoreIndex, Id as ParaId}; -use sp_runtime::traits::One; -use sp_std::{ +use alloc::{ collections::{btree_map::BTreeMap, vec_deque::VecDeque}, vec::Vec, }; +use polkadot_primitives::{CommittedCandidateReceipt, CoreIndex, Id as ParaId}; +use sp_runtime::traits::One; /// Returns the claimqueue from the scheduler pub fn claim_queue() -> BTreeMap> { diff --git a/polkadot/runtime/parachains/src/scheduler.rs b/polkadot/runtime/parachains/src/scheduler.rs index d7fe5c06863c8..445583d929aba 100644 --- a/polkadot/runtime/parachains/src/scheduler.rs +++ b/polkadot/runtime/parachains/src/scheduler.rs @@ -39,6 +39,13 @@ use core::iter::Peekable; use crate::{configuration, initializer::SessionChangeNotification, paras}; +use alloc::{ + collections::{ + btree_map::{self, BTreeMap}, + vec_deque::VecDeque, + }, + vec::Vec, +}; use frame_support::{pallet_prelude::*, traits::Defensive}; use frame_system::pallet_prelude::BlockNumberFor; pub use polkadot_core_primitives::v2::BlockNumber; @@ -46,13 +53,6 @@ use polkadot_primitives::{ CoreIndex, GroupIndex, GroupRotationInfo, Id as ParaId, ScheduledCore, ValidatorIndex, }; use sp_runtime::traits::One; -use sp_std::{ - collections::{ - btree_map::{self, BTreeMap}, - vec_deque::VecDeque, - }, - prelude::*, -}; pub mod common; @@ -314,10 +314,8 @@ impl Pallet { .into_iter() .filter(|(freed_index, _)| (freed_index.0 as usize) < c_len) .for_each(|(freed_index, freed_reason)| { - match sp_std::mem::replace( - &mut cores[freed_index.0 as usize], - CoreOccupied::Free, - ) { + match core::mem::replace(&mut cores[freed_index.0 as usize], CoreOccupied::Free) + { CoreOccupied::Free => {}, CoreOccupied::Paras(entry) => { match freed_reason { @@ -569,7 +567,7 @@ impl Pallet { fn push_occupied_cores_to_assignment_provider() { AvailabilityCores::::mutate(|cores| { for core in cores.iter_mut() { - match sp_std::mem::replace(core, CoreOccupied::Free) { + match core::mem::replace(core, CoreOccupied::Free) { CoreOccupied::Free => continue, CoreOccupied::Paras(entry) => { Self::maybe_push_assignment(entry); diff --git a/polkadot/runtime/parachains/src/scheduler/migration.rs b/polkadot/runtime/parachains/src/scheduler/migration.rs index 84d7d4b567102..125f105ef7066 100644 --- a/polkadot/runtime/parachains/src/scheduler/migration.rs +++ b/polkadot/runtime/parachains/src/scheduler/migration.rs @@ -17,6 +17,7 @@ //! A module that is responsible for migration of storage. use super::*; +use alloc::vec::Vec; use frame_support::{ migrations::VersionedMigration, pallet_prelude::ValueQuery, storage_alias, traits::UncheckedOnRuntimeUpgrade, weights::Weight, @@ -164,7 +165,7 @@ mod v1 { } /// Migration to V1 - pub struct UncheckedMigrateToV1(sp_std::marker::PhantomData); + pub struct UncheckedMigrateToV1(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for UncheckedMigrateToV1 { fn on_runtime_upgrade() -> Weight { let mut weight: Weight = Weight::zero(); @@ -301,7 +302,7 @@ mod v2 { } /// Migration to V2 - pub struct UncheckedMigrateToV2(sp_std::marker::PhantomData); + pub struct UncheckedMigrateToV2(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for UncheckedMigrateToV2 { fn on_runtime_upgrade() -> Weight { diff --git a/polkadot/runtime/parachains/src/scheduler/tests.rs b/polkadot/runtime/parachains/src/scheduler/tests.rs index 32811241e171c..f3866146e8112 100644 --- a/polkadot/runtime/parachains/src/scheduler/tests.rs +++ b/polkadot/runtime/parachains/src/scheduler/tests.rs @@ -16,12 +16,12 @@ use super::*; +use alloc::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use frame_support::assert_ok; use polkadot_primitives::{ vstaging::SchedulerParams, BlockNumber, SessionIndex, ValidationCode, ValidatorId, }; use sp_keyring::Sr25519Keyring; -use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use crate::{ configuration::HostConfiguration, diff --git a/polkadot/runtime/parachains/src/session_info.rs b/polkadot/runtime/parachains/src/session_info.rs index ff032f7e34d5e..ea05c1aacaa94 100644 --- a/polkadot/runtime/parachains/src/session_info.rs +++ b/polkadot/runtime/parachains/src/session_info.rs @@ -24,6 +24,7 @@ use crate::{ configuration, paras, scheduler, shared, util::{take_active_subset, take_active_subset_and_inactive}, }; +use alloc::vec::Vec; use frame_support::{ pallet_prelude::*, traits::{OneSessionHandler, ValidatorSet, ValidatorSetWithIdentification}, @@ -32,7 +33,6 @@ use frame_system::pallet_prelude::BlockNumberFor; use polkadot_primitives::{ AssignmentId, AuthorityDiscoveryId, ExecutorParams, SessionIndex, SessionInfo, }; -use sp_std::vec::Vec; pub use pallet::*; diff --git a/polkadot/runtime/parachains/src/shared.rs b/polkadot/runtime/parachains/src/shared.rs index 417de1fa3fb0d..154b7cfefc3ac 100644 --- a/polkadot/runtime/parachains/src/shared.rs +++ b/polkadot/runtime/parachains/src/shared.rs @@ -19,14 +19,14 @@ //! To avoid cyclic dependencies, it is important that this pallet is not //! dependent on any of the other pallets. +use alloc::{ + collections::{btree_map::BTreeMap, vec_deque::VecDeque}, + vec::Vec, +}; use frame_support::{pallet_prelude::*, traits::DisabledValidators}; use frame_system::pallet_prelude::BlockNumberFor; use polkadot_primitives::{SessionIndex, ValidatorId, ValidatorIndex}; use sp_runtime::traits::AtLeast32BitUnsigned; -use sp_std::{ - collections::{btree_map::BTreeMap, vec_deque::VecDeque}, - vec::Vec, -}; use rand::{seq::SliceRandom, SeedableRng}; use rand_chacha::ChaCha20Rng; diff --git a/polkadot/runtime/parachains/src/ump_tests.rs b/polkadot/runtime/parachains/src/ump_tests.rs index 4d6da8c9e3c1b..d914bf8b66612 100644 --- a/polkadot/runtime/parachains/src/ump_tests.rs +++ b/polkadot/runtime/parachains/src/ump_tests.rs @@ -34,7 +34,6 @@ use frame_support::{ use polkadot_primitives::{well_known_keys, Id as ParaId, UpwardMessage}; use sp_crypto_hashing::{blake2_256, twox_64}; use sp_runtime::traits::Bounded; -use sp_std::prelude::*; pub(super) struct GenesisConfigBuilder { max_upward_message_size: u32, diff --git a/polkadot/runtime/parachains/src/util.rs b/polkadot/runtime/parachains/src/util.rs index cb2deffd7f659..3588e494438d0 100644 --- a/polkadot/runtime/parachains/src/util.rs +++ b/polkadot/runtime/parachains/src/util.rs @@ -17,9 +17,9 @@ //! Utilities that don't belong to any particular module but may draw //! on all modules. +use alloc::{collections::btree_set::BTreeSet, vec::Vec}; use frame_system::pallet_prelude::BlockNumberFor; use polkadot_primitives::{HeadData, Id as ParaId, PersistedValidationData, ValidatorIndex}; -use sp_std::{collections::btree_set::BTreeSet, vec::Vec}; use crate::{configuration, hrmp, paras}; @@ -118,7 +118,7 @@ pub fn take_active_subset(active: &[ValidatorIndex], set: &[T]) -> Vec #[cfg(test)] mod tests { - use sp_std::vec::Vec; + use alloc::vec::Vec; use crate::util::{split_active_subset, take_active_subset}; use polkadot_primitives::ValidatorIndex; diff --git a/polkadot/runtime/rococo/Cargo.toml b/polkadot/runtime/rococo/Cargo.toml index c4fbd461a6318..f93a3ad65754c 100644 --- a/polkadot/runtime/rococo/Cargo.toml +++ b/polkadot/runtime/rococo/Cargo.toml @@ -32,7 +32,6 @@ sp-genesis-builder = { workspace = true } sp-inherents = { workspace = true } sp-offchain = { workspace = true } sp-arithmetic = { workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } sp-mmr-primitives = { workspace = true } sp-runtime = { workspace = true } @@ -209,7 +208,6 @@ std = [ "sp-runtime/std", "sp-session/std", "sp-staking/std", - "sp-std/std", "sp-storage/std", "sp-tracing/std", "sp-transaction-pool/std", diff --git a/polkadot/runtime/rococo/src/genesis_config_presets.rs b/polkadot/runtime/rococo/src/genesis_config_presets.rs index 1c70c94ce0484..67dcd6cd7a510 100644 --- a/polkadot/runtime/rococo/src/genesis_config_presets.rs +++ b/polkadot/runtime/rococo/src/genesis_config_presets.rs @@ -17,6 +17,9 @@ //! Genesis configs presets for the Rococo runtime use crate::{SessionKeys, BABE_GENESIS_EPOCH_CONFIG}; +#[cfg(not(feature = "std"))] +use alloc::format; +use alloc::vec::Vec; use polkadot_primitives::{ vstaging::SchedulerParams, AccountId, AccountPublic, AssignmentId, ValidatorId, }; @@ -27,9 +30,6 @@ use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; use sp_consensus_grandpa::AuthorityId as GrandpaId; use sp_core::{sr25519, Pair, Public}; use sp_runtime::traits::IdentifyAccount; -#[cfg(not(feature = "std"))] -use sp_std::alloc::format; -use sp_std::vec::Vec; /// Helper function to generate a crypto pair from seed fn get_from_seed(seed: &str) -> ::Public { @@ -530,7 +530,7 @@ fn wococo_local_testnet_genesis() -> serde_json::Value { } /// Provides the JSON representation of predefined genesis config for given `id`. -pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { +pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { let patch = match id.try_into() { Ok("local_testnet") => rococo_local_testnet_genesis(), Ok("development") => rococo_development_config_genesis(), diff --git a/polkadot/runtime/rococo/src/impls.rs b/polkadot/runtime/rococo/src/impls.rs index 7b5c7b1fb4aca..a4440a1c6e0b9 100644 --- a/polkadot/runtime/rococo/src/impls.rs +++ b/polkadot/runtime/rococo/src/impls.rs @@ -15,13 +15,14 @@ // along with Polkadot. If not, see . use crate::xcm_config; +use alloc::{boxed::Box, vec}; use codec::{Decode, Encode}; +use core::marker::PhantomData; use frame_support::pallet_prelude::DispatchResult; use frame_system::RawOrigin; use polkadot_primitives::Balance; use polkadot_runtime_common::identity_migrator::{OnReapIdentity, WeightInfo}; use rococo_runtime_constants::currency::*; -use sp_std::{marker::PhantomData, prelude::*}; use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm}; use xcm_executor::traits::TransactAsset; diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index ef629c7dad155..5adffbd7422f9 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -20,7 +20,15 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit. #![recursion_limit = "512"] +extern crate alloc; + +use alloc::{ + collections::{btree_map::BTreeMap, vec_deque::VecDeque}, + vec, + vec::Vec, +}; use codec::{Decode, Encode, MaxEncodedLen}; +use core::cmp::Ordering; use frame_support::{ dynamic_params::{dynamic_pallet_params, dynamic_params}, traits::FromContains, @@ -68,11 +76,6 @@ use sp_consensus_beefy::{ mmr::{BeefyDataProvider, MmrLeafVersion}, }; use sp_genesis_builder::PresetId; -use sp_std::{ - cmp::Ordering, - collections::{btree_map::BTreeMap, vec_deque::VecDeque}, - prelude::*, -}; use frame_support::{ construct_runtime, derive_impl, @@ -1845,7 +1848,7 @@ sp_api::impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -2389,7 +2392,7 @@ sp_api::impl_runtime_apis! { } fn set_up_complex_asset_transfer( - ) -> Option<(Assets, u32, Location, Box)> { + ) -> Option<(Assets, u32, Location, alloc::boxed::Box)> { // Relay supports only native token, either reserve transfer it to non-system parachains, // or teleport it to system parachain. Use the teleport case for benchmarking as it's // slightly heavier. diff --git a/polkadot/runtime/rococo/src/validator_manager.rs b/polkadot/runtime/rococo/src/validator_manager.rs index 0677ba7fbb2b2..ecfbff4fa0688 100644 --- a/polkadot/runtime/rococo/src/validator_manager.rs +++ b/polkadot/runtime/rococo/src/validator_manager.rs @@ -16,8 +16,8 @@ //! A pallet for managing validators on Rococo. +use alloc::vec::Vec; use sp_staking::SessionIndex; -use sp_std::vec::Vec; pub use pallet::*; diff --git a/polkadot/runtime/rococo/src/weights/pallet_session.rs b/polkadot/runtime/rococo/src/weights/pallet_session.rs index dbeca534add82..7f573d4e3952e 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_session.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_session.rs @@ -38,7 +38,7 @@ #![allow(unused_imports)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_session`. pub struct WeightInfo(PhantomData); diff --git a/polkadot/runtime/rococo/src/weights/xcm/mod.rs b/polkadot/runtime/rococo/src/weights/xcm/mod.rs index 12f3df897b1ee..bd2b0fbb8c061 100644 --- a/polkadot/runtime/rococo/src/weights/xcm/mod.rs +++ b/polkadot/runtime/rococo/src/weights/xcm/mod.rs @@ -18,8 +18,8 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::Runtime; +use alloc::vec::Vec; use frame_support::weights::Weight; -use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight; diff --git a/polkadot/runtime/test-runtime/Cargo.toml b/polkadot/runtime/test-runtime/Cargo.toml index a66fceedae341..ac379b69e3f2c 100644 --- a/polkadot/runtime/test-runtime/Cargo.toml +++ b/polkadot/runtime/test-runtime/Cargo.toml @@ -22,7 +22,6 @@ sp-consensus-beefy = { workspace = true } sp-api = { workspace = true } sp-inherents = { workspace = true } sp-offchain = { workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } sp-staking = { workspace = true } @@ -125,7 +124,6 @@ std = [ "sp-runtime/std", "sp-session/std", "sp-staking/std", - "sp-std/std", "sp-transaction-pool/std", "sp-version/std", "test-runtime-constants/std", diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 96392c026d5c9..a8a369a68e669 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -20,12 +20,15 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] -use codec::Encode; -use pallet_transaction_payment::FungibleAdapter; -use sp_std::{ +extern crate alloc; + +use alloc::{ collections::{btree_map::BTreeMap, vec_deque::VecDeque}, - prelude::*, + vec, + vec::Vec, }; +use codec::Encode; +use pallet_transaction_payment::FungibleAdapter; use polkadot_runtime_parachains::{ assigner_parachains as parachains_assigner_parachains, @@ -793,7 +796,7 @@ sp_api::impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> Vec { Runtime::metadata_versions() } } diff --git a/polkadot/runtime/test-runtime/src/xcm_config.rs b/polkadot/runtime/test-runtime/src/xcm_config.rs index b1d86ff9a85e9..b424b9a3ee55b 100644 --- a/polkadot/runtime/test-runtime/src/xcm_config.rs +++ b/polkadot/runtime/test-runtime/src/xcm_config.rs @@ -54,7 +54,7 @@ pub type LocalOriginToLocation = ( /// This implementation ensures that messages with non-reanchored assets return higher /// prices than messages with reanchored assets. /// Useful for `deposit_reserve_asset_works_for_any_xcm_sender` integration test. -pub struct TestDeliveryPrice(sp_std::marker::PhantomData<(A, F)>); +pub struct TestDeliveryPrice(core::marker::PhantomData<(A, F)>); impl, F: FeeTracker> PriceForMessageDelivery for TestDeliveryPrice { type Id = F::Id; diff --git a/polkadot/runtime/westend/Cargo.toml b/polkadot/runtime/westend/Cargo.toml index 5a7805c05161b..9e739f4c7fe6c 100644 --- a/polkadot/runtime/westend/Cargo.toml +++ b/polkadot/runtime/westend/Cargo.toml @@ -28,7 +28,6 @@ sp-offchain = { workspace = true } sp-api = { workspace = true } sp-application-crypto = { workspace = true } sp-arithmetic = { workspace = true } -sp-std = { workspace = true } sp-genesis-builder = { workspace = true } sp-io = { workspace = true } sp-mmr-primitives = { workspace = true } @@ -220,7 +219,6 @@ std = [ "sp-runtime/std", "sp-session/std", "sp-staking/std", - "sp-std/std", "sp-storage/std", "sp-tracing/std", "sp-transaction-pool/std", diff --git a/polkadot/runtime/westend/src/impls.rs b/polkadot/runtime/westend/src/impls.rs index d7ca677a7620e..11665953bd8e1 100644 --- a/polkadot/runtime/westend/src/impls.rs +++ b/polkadot/runtime/westend/src/impls.rs @@ -15,12 +15,13 @@ // along with Polkadot. If not, see . use crate::xcm_config; +use alloc::{boxed::Box, vec}; use codec::{Decode, Encode}; +use core::marker::PhantomData; use frame_support::pallet_prelude::DispatchResult; use frame_system::RawOrigin; use polkadot_primitives::Balance; use polkadot_runtime_common::identity_migrator::{OnReapIdentity, WeightInfo}; -use sp_std::{marker::PhantomData, prelude::*}; use westend_runtime_constants::currency::*; use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm}; use xcm_executor::traits::TransactAsset; diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 0d7a8a6a4ac22..f0b16e731d9e5 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -20,6 +20,13 @@ // `#[frame_support::runtime]!` does a lot of recursion and requires us to increase the limit. #![recursion_limit = "512"] +extern crate alloc; + +use alloc::{ + collections::{btree_map::BTreeMap, vec_deque::VecDeque}, + vec, + vec::Vec, +}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_election_provider_support::{bounds::ElectionBoundsBuilder, onchain, SequentialPhragmen}; use frame_support::{ @@ -95,10 +102,6 @@ use sp_runtime::{ ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill, }; use sp_staking::SessionIndex; -use sp_std::{ - collections::{btree_map::BTreeMap, vec_deque::VecDeque}, - prelude::*, -}; #[cfg(any(feature = "std", test))] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -1802,7 +1805,7 @@ sp_api::impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } @@ -2420,6 +2423,8 @@ sp_api::impl_runtime_apis! { use xcm_config::{AssetHub, TokenLocation}; + use alloc::boxed::Box; + parameter_types! { pub ExistentialDepositAsset: Option = Some(( TokenLocation::get(), diff --git a/polkadot/runtime/westend/src/weights/xcm/mod.rs b/polkadot/runtime/westend/src/weights/xcm/mod.rs index 09e883a9f7af5..cb5894ea51e3c 100644 --- a/polkadot/runtime/westend/src/weights/xcm/mod.rs +++ b/polkadot/runtime/westend/src/weights/xcm/mod.rs @@ -18,8 +18,8 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::Runtime; +use alloc::vec::Vec; use frame_support::weights::Weight; -use sp_std::prelude::*; use xcm::{ latest::{prelude::*, QueryResponseInfo}, DoubleEncoded, diff --git a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/mod.rs b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/mod.rs index e7d00ac71038b..23d6664bdafcb 100644 --- a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/mod.rs +++ b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/mod.rs @@ -16,7 +16,7 @@ //! # Runtime -use frame::{deps::frame_system, prelude::*, runtime::prelude::*, traits::IdentityLookup}; +use frame::{deps::frame_system, runtime::prelude::*, traits::IdentityLookup}; use xcm_executor::XcmExecutor; use xcm_simulator::mock_message_queue; diff --git a/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml b/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml index 1177d094c6c38..b07bdfdca3d19 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -18,7 +18,6 @@ scale-info = { features = ["derive"], workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } xcm-executor = { workspace = true } frame-benchmarking = { workspace = true } @@ -48,7 +47,6 @@ std = [ "scale-info/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm-builder/std", "xcm-executor/std", ] diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index d99da9184b5d8..6ce49074a6e2b 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -16,6 +16,7 @@ use super::*; use crate::{account_and_location, new_executor, AssetTransactorOf, EnsureDelivery, XcmCallOf}; +use alloc::{vec, vec::Vec}; use frame_benchmarking::{benchmarks_instance_pallet, BenchmarkError, BenchmarkResult}; use frame_support::{ pallet_prelude::Get, @@ -23,7 +24,6 @@ use frame_support::{ weights::Weight, }; use sp_runtime::traits::{Bounded, Zero}; -use sp_std::{prelude::*, vec}; use xcm::latest::{prelude::*, MAX_ITEMS_IN_ASSETS}; use xcm_executor::traits::{ConvertLocation, FeeReason, TransactAsset}; @@ -37,7 +37,7 @@ benchmarks_instance_pallet! { >::Balance as TryInto - >::Error: sp_std::fmt::Debug, + >::Error: core::fmt::Debug, } withdraw_asset { diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 760b21f93566e..40a7da58a687c 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -16,10 +16,10 @@ use super::*; use crate::{account_and_location, new_executor, EnsureDelivery, XcmCallOf}; +use alloc::{vec, vec::Vec}; use codec::Encode; use frame_benchmarking::{benchmarks, BenchmarkError}; use frame_support::{dispatch::GetDispatchInfo, traits::fungible::Inspect}; -use sp_std::{prelude::*, vec}; use xcm::{ latest::{prelude::*, MaxDispatchErrorLen, MaybeErrorCode, Weight, MAX_ITEMS_IN_ASSETS}, DoubleEncoded, diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs index a43f27bf47e72..4a12bb7f47c66 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -18,9 +18,11 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use codec::Encode; use frame_benchmarking::{account, BenchmarkError}; -use sp_std::prelude::*; use xcm::latest::prelude::*; use xcm_builder::EnsureDelivery; use xcm_executor::{traits::ConvertLocation, Config as XcmConfig}; diff --git a/polkadot/xcm/pallet-xcm/Cargo.toml b/polkadot/xcm/pallet-xcm/Cargo.toml index 0cce7a3449389..ed4b441d7c33c 100644 --- a/polkadot/xcm/pallet-xcm/Cargo.toml +++ b/polkadot/xcm/pallet-xcm/Cargo.toml @@ -21,7 +21,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } @@ -52,7 +51,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "xcm-builder/std", "xcm-executor/std", "xcm-runtime-apis/std", diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index da46a6a37c065..d09c81bf434e2 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -18,7 +18,6 @@ use super::*; use frame_benchmarking::{benchmarks, whitelisted_caller, BenchmarkError, BenchmarkResult}; use frame_support::{assert_ok, weights::Weight}; use frame_system::RawOrigin; -use sp_std::prelude::*; use xcm::latest::prelude::*; use xcm_builder::EnsureDelivery; use xcm_executor::traits::FeeReason; diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 668f07c52ce35..6451901279b16 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -27,7 +27,11 @@ mod tests; pub mod migration; +extern crate alloc; + +use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; +use core::{marker::PhantomData, result::Result}; use frame_support::{ dispatch::{ DispatchErrorWithPostInfo, GetDispatchInfo, PostDispatchInfo, WithPostDispatchInfo, @@ -49,7 +53,6 @@ use sp_runtime::{ }, Either, RuntimeDebug, }; -use sp_std::{boxed::Box, marker::PhantomData, prelude::*, result::Result, vec}; use xcm::{latest::QueryResponseInfo, prelude::*}; use xcm_builder::{ ExecuteController, ExecuteControllerWeightInfo, InspectMessageQueues, QueryController, @@ -792,7 +795,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, /// The default version to encode outgoing XCM messages with. pub safe_xcm_version: Option, } @@ -1438,8 +1441,8 @@ enum FeesHandling { Separate { local_xcm: Xcm<::RuntimeCall>, remote_xcm: Xcm<()> }, } -impl sp_std::fmt::Debug for FeesHandling { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Debug for FeesHandling { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::Batched { fees } => write!(f, "FeesHandling::Batched({:?})", fees), Self::Separate { local_xcm, remote_xcm } => write!( @@ -1840,8 +1843,8 @@ impl Pallet { FeesHandling::Separate { local_xcm: mut local_fees, remote_xcm: mut remote_fees } => { // fees are handled by separate XCM instructions, prepend fees instructions (for // remote XCM they have to be prepended instead of appended to pass barriers). - sp_std::mem::swap(local, &mut local_fees); - sp_std::mem::swap(remote, &mut remote_fees); + core::mem::swap(local, &mut local_fees); + core::mem::swap(remote, &mut remote_fees); // these are now swapped so fees actually go first local.inner_mut().append(&mut local_fees.into_inner()); remote.inner_mut().append(&mut remote_fees.into_inner()); diff --git a/polkadot/xcm/pallet-xcm/src/migration.rs b/polkadot/xcm/pallet-xcm/src/migration.rs index b157e6b5c3d5f..0aec97ab41051 100644 --- a/polkadot/xcm/pallet-xcm/src/migration.rs +++ b/polkadot/xcm/pallet-xcm/src/migration.rs @@ -34,7 +34,7 @@ pub mod v1 { /// enacted on-chain. /// /// Use experimental [`MigrateToV1`] instead. - pub struct VersionUncheckedMigrateToV1(sp_std::marker::PhantomData); + pub struct VersionUncheckedMigrateToV1(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV1 { fn on_runtime_upgrade() -> Weight { let mut weight = T::DbWeight::get().reads(1); @@ -81,7 +81,7 @@ pub mod v1 { /// `XCM_VERSION`. /// /// NOTE: This migration can be permanently added to the runtime migrations. -pub struct MigrateToLatestXcmVersion(sp_std::marker::PhantomData); +pub struct MigrateToLatestXcmVersion(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToLatestXcmVersion { fn on_runtime_upgrade() -> Weight { CurrentMigration::::put(VersionMigrationStage::default()); diff --git a/polkadot/xcm/pallet-xcm/src/mock.rs b/polkadot/xcm/pallet-xcm/src/mock.rs index 2be6f301f8562..3941d104b81c6 100644 --- a/polkadot/xcm/pallet-xcm/src/mock.rs +++ b/polkadot/xcm/pallet-xcm/src/mock.rs @@ -15,6 +15,7 @@ // along with Polkadot. If not, see . use codec::Encode; +pub use core::cell::RefCell; use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{ @@ -28,7 +29,6 @@ use polkadot_parachain_primitives::primitives::Id as ParaId; use polkadot_runtime_parachains::origin; use sp_core::H256; use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage}; -pub use sp_std::cell::RefCell; use xcm::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, diff --git a/polkadot/xcm/xcm-builder/Cargo.toml b/polkadot/xcm/xcm-builder/Cargo.toml index d43506aa651b4..7702e2f9be07d 100644 --- a/polkadot/xcm/xcm-builder/Cargo.toml +++ b/polkadot/xcm/xcm-builder/Cargo.toml @@ -15,7 +15,6 @@ codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } -sp-std = { workspace = true } sp-arithmetic = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } @@ -66,7 +65,6 @@ std = [ "sp-arithmetic/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-weights/std", "xcm-executor/std", "xcm/std", diff --git a/polkadot/xcm/xcm-builder/src/asset_conversion.rs b/polkadot/xcm/xcm-builder/src/asset_conversion.rs index 520ce87448ea4..16ae05c20795e 100644 --- a/polkadot/xcm/xcm-builder/src/asset_conversion.rs +++ b/polkadot/xcm/xcm-builder/src/asset_conversion.rs @@ -16,9 +16,9 @@ //! Adapters to work with [`frame_support::traits::fungibles`] through XCM. +use core::{marker::PhantomData, result}; use frame_support::traits::{Contains, Get}; use sp_runtime::traits::MaybeEquivalence; -use sp_std::{marker::PhantomData, prelude::*, result}; use xcm::latest::prelude::*; use xcm_executor::traits::{Error as MatchError, MatchesFungibles, MatchesNonFungibles}; diff --git a/polkadot/xcm/xcm-builder/src/barriers.rs b/polkadot/xcm/xcm-builder/src/barriers.rs index 11e9122f9a121..5d95005eb6630 100644 --- a/polkadot/xcm/xcm-builder/src/barriers.rs +++ b/polkadot/xcm/xcm-builder/src/barriers.rs @@ -17,12 +17,12 @@ //! Various implementations for `ShouldExecute`. use crate::{CreateMatcher, MatchXcm}; +use core::{cell::Cell, marker::PhantomData, ops::ControlFlow, result::Result}; use frame_support::{ ensure, traits::{Contains, Get, ProcessMessageError}, }; use polkadot_parachain_primitives::primitives::IsSystem; -use sp_std::{cell::Cell, marker::PhantomData, ops::ControlFlow, result::Result}; use xcm::prelude::*; use xcm_executor::traits::{CheckSuspension, OnResponse, Properties, ShouldExecute}; diff --git a/polkadot/xcm/xcm-builder/src/controller.rs b/polkadot/xcm/xcm-builder/src/controller.rs index 04b19eaa58700..d4ce2ca5b353c 100644 --- a/polkadot/xcm/xcm-builder/src/controller.rs +++ b/polkadot/xcm/xcm-builder/src/controller.rs @@ -18,11 +18,11 @@ //! Controller traits defined in this module are high-level traits that will rely on other traits //! from `xcm-executor` to perform their tasks. +use alloc::boxed::Box; use frame_support::{ dispatch::{DispatchErrorWithPostInfo, WithPostDispatchInfo}, pallet_prelude::DispatchError, }; -use sp_std::boxed::Box; use xcm::prelude::*; pub use xcm_executor::traits::QueryHandler; diff --git a/polkadot/xcm/xcm-builder/src/currency_adapter.rs b/polkadot/xcm/xcm-builder/src/currency_adapter.rs index 99a736d6ac1f9..355d6ad85388c 100644 --- a/polkadot/xcm/xcm-builder/src/currency_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/currency_adapter.rs @@ -19,9 +19,9 @@ #![allow(deprecated)] use super::MintLocation; +use core::{marker::PhantomData, result}; use frame_support::traits::{ExistenceRequirement::AllowDeath, Get, WithdrawReasons}; use sp_runtime::traits::CheckedSub; -use sp_std::{marker::PhantomData, result}; use xcm::latest::{Asset, Error as XcmError, Location, Result, XcmContext}; use xcm_executor::{ traits::{ConvertLocation, MatchesFungible, TransactAsset}, diff --git a/polkadot/xcm/xcm-builder/src/filter_asset_location.rs b/polkadot/xcm/xcm-builder/src/filter_asset_location.rs index d80c5d70deea8..16b7be7f3ba98 100644 --- a/polkadot/xcm/xcm-builder/src/filter_asset_location.rs +++ b/polkadot/xcm/xcm-builder/src/filter_asset_location.rs @@ -17,8 +17,9 @@ //! Various implementations of `ContainsPair` or //! `Contains<(Location, Vec)>`. +use alloc::vec::Vec; +use core::marker::PhantomData; use frame_support::traits::{Contains, ContainsPair, Get}; -use sp_std::{marker::PhantomData, vec::Vec}; use xcm::latest::{Asset, AssetFilter, AssetId, Location, WildAsset}; /// Accepts an asset iff it is a native asset. @@ -44,7 +45,7 @@ impl> ContainsPair for Case /// implementation of the given `Location` and if every asset from `assets` matches at least one of /// the `AssetFilter` instances provided by the `Get` implementation of `AssetFilters`. pub struct LocationWithAssetFilters( - sp_std::marker::PhantomData<(LocationFilter, AssetFilters)>, + core::marker::PhantomData<(LocationFilter, AssetFilters)>, ); impl, AssetFilters: Get>> Contains<(Location, Vec)> for LocationWithAssetFilters @@ -75,7 +76,7 @@ impl, AssetFilters: Get>> pub struct AllAssets; impl Get> for AllAssets { fn get() -> Vec { - sp_std::vec![AssetFilter::Wild(WildAsset::All)] + alloc::vec![AssetFilter::Wild(WildAsset::All)] } } @@ -96,11 +97,11 @@ mod tests { pub AssetYLocation: Location = Location::new(1, [GeneralIndex(2222)]); pub AssetZLocation: Location = Location::new(1, [GeneralIndex(3333)]); - pub OnlyAssetXOrAssetY: sp_std::vec::Vec = sp_std::vec![ + pub OnlyAssetXOrAssetY: alloc::vec::Vec = alloc::vec![ Wild(AllOf { fun: WildFungible, id: AssetId(AssetXLocation::get()) }), Wild(AllOf { fun: WildFungible, id: AssetId(AssetYLocation::get()) }), ]; - pub OnlyAssetZ: sp_std::vec::Vec = sp_std::vec![ + pub OnlyAssetZ: alloc::vec::Vec = alloc::vec![ Wild(AllOf { fun: WildFungible, id: AssetId(AssetZLocation::get()) }) ]; } diff --git a/polkadot/xcm/xcm-builder/src/fungible_adapter.rs b/polkadot/xcm/xcm-builder/src/fungible_adapter.rs index 45a0e2bdca286..25a705a39eb73 100644 --- a/polkadot/xcm/xcm-builder/src/fungible_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/fungible_adapter.rs @@ -17,6 +17,7 @@ //! Adapters to work with [`frame_support::traits::fungible`] through XCM. use super::MintLocation; +use core::{marker::PhantomData, result}; use frame_support::traits::{ tokens::{ fungible, @@ -27,7 +28,6 @@ use frame_support::traits::{ }, Get, }; -use sp_std::{marker::PhantomData, prelude::*, result}; use xcm::latest::prelude::*; use xcm_executor::{ traits::{ConvertLocation, Error as MatchError, MatchesFungible, TransactAsset}, diff --git a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs index 88bbf01d9e1f8..a259afc6e6825 100644 --- a/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/fungibles_adapter.rs @@ -16,6 +16,7 @@ //! Adapters to work with [`frame_support::traits::fungibles`] through XCM. +use core::{marker::PhantomData, result}; use frame_support::traits::{ tokens::{ fungibles, @@ -26,7 +27,6 @@ use frame_support::traits::{ }, Contains, Get, }; -use sp_std::{marker::PhantomData, prelude::*, result}; use xcm::latest::prelude::*; use xcm_executor::traits::{ConvertLocation, Error as MatchError, MatchesFungibles, TransactAsset}; @@ -101,7 +101,7 @@ impl AssetChecking for NoChecking { /// Implementation of `AssetChecking` which subjects a given set of assets `T` to having their /// teleportations recorded with a `MintLocation::Local`. -pub struct LocalMint(sp_std::marker::PhantomData); +pub struct LocalMint(core::marker::PhantomData); impl> AssetChecking for LocalMint { fn asset_checking(asset: &AssetId) -> Option { match T::contains(asset) { @@ -113,7 +113,7 @@ impl> AssetChecking for LocalMint { /// Implementation of `AssetChecking` which subjects a given set of assets `T` to having their /// teleportations recorded with a `MintLocation::NonLocal`. -pub struct NonLocalMint(sp_std::marker::PhantomData); +pub struct NonLocalMint(core::marker::PhantomData); impl> AssetChecking for NonLocalMint { fn asset_checking(asset: &AssetId) -> Option { match T::contains(asset) { @@ -126,7 +126,7 @@ impl> AssetChecking for NonLocalMint { /// Implementation of `AssetChecking` which subjects a given set of assets `L` to having their /// teleportations recorded with a `MintLocation::Local` and a second set of assets `R` to having /// their teleportations recorded with a `MintLocation::NonLocal`. -pub struct DualMint(sp_std::marker::PhantomData<(L, R)>); +pub struct DualMint(core::marker::PhantomData<(L, R)>); impl, R: Contains> AssetChecking for DualMint { diff --git a/polkadot/xcm/xcm-builder/src/lib.rs b/polkadot/xcm/xcm-builder/src/lib.rs index cc06c298a418d..c3495601cd875 100644 --- a/polkadot/xcm/xcm-builder/src/lib.rs +++ b/polkadot/xcm/xcm-builder/src/lib.rs @@ -20,6 +20,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(test)] mod tests; diff --git a/polkadot/xcm/xcm-builder/src/location_conversion.rs b/polkadot/xcm/xcm-builder/src/location_conversion.rs index f95258492381b..1d840e9c0dde4 100644 --- a/polkadot/xcm/xcm-builder/src/location_conversion.rs +++ b/polkadot/xcm/xcm-builder/src/location_conversion.rs @@ -15,11 +15,12 @@ // along with Polkadot. If not, see . use crate::universal_exports::ensure_is_remote; +use alloc::vec::Vec; use codec::{Compact, Decode, Encode}; +use core::marker::PhantomData; use frame_support::traits::Get; use sp_io::hashing::blake2_256; use sp_runtime::traits::{AccountIdConversion, TrailingZeroInput, TryConvert}; -use sp_std::{marker::PhantomData, prelude::*}; use xcm::latest::prelude::*; use xcm_executor::traits::ConvertLocation; @@ -460,7 +461,9 @@ impl #[cfg(test)] mod tests { use super::*; + use alloc::vec; use polkadot_primitives::AccountId; + pub type ForeignChainAliasAccount = HashedDescription; diff --git a/polkadot/xcm/xcm-builder/src/matches_location.rs b/polkadot/xcm/xcm-builder/src/matches_location.rs index b6c2807e6b29d..71c5ec1efd6f9 100644 --- a/polkadot/xcm/xcm-builder/src/matches_location.rs +++ b/polkadot/xcm/xcm-builder/src/matches_location.rs @@ -17,14 +17,14 @@ //! Various implementations and utilities for matching and filtering `Location` and //! `InteriorLocation` types. +use core::marker::PhantomData; use frame_support::traits::{Contains, Get}; use sp_runtime::traits::MaybeEquivalence; -use sp_std::marker::PhantomData; use xcm::latest::{InteriorLocation, Location, NetworkId}; /// An implementation of `Contains` that checks for `Location` or /// `InteriorLocation` if starts with the provided type `T`. -pub struct StartsWith(sp_std::marker::PhantomData<(T, L)>); +pub struct StartsWith(core::marker::PhantomData<(T, L)>); impl, L: TryInto + Clone> Contains for StartsWith { fn contains(location: &L) -> bool { let latest_location: Location = @@ -42,7 +42,7 @@ impl> Contains for StartsWith { /// An implementation of `Contains` that checks for `Location` or /// `InteriorLocation` if starts with expected `GlobalConsensus(NetworkId)` provided as type /// `T`. -pub struct StartsWithExplicitGlobalConsensus(sp_std::marker::PhantomData); +pub struct StartsWithExplicitGlobalConsensus(core::marker::PhantomData); impl> Contains for StartsWithExplicitGlobalConsensus { fn contains(location: &Location) -> bool { matches!(location.interior().global_consensus(), Ok(requested_network) if requested_network.eq(&T::get())) diff --git a/polkadot/xcm/xcm-builder/src/matches_token.rs b/polkadot/xcm/xcm-builder/src/matches_token.rs index e49fd18f88d80..095c50a5a25b0 100644 --- a/polkadot/xcm/xcm-builder/src/matches_token.rs +++ b/polkadot/xcm/xcm-builder/src/matches_token.rs @@ -16,8 +16,8 @@ //! Various implementations for the `MatchesFungible` trait. +use core::marker::PhantomData; use frame_support::traits::Get; -use sp_std::marker::PhantomData; use xcm::latest::{ Asset, AssetId, AssetInstance, Fungibility::{Fungible, NonFungible}, diff --git a/polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs b/polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs index b69002eafc5b9..8e6232ea64d27 100644 --- a/polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs @@ -17,11 +17,11 @@ //! Adapters to work with [`frame_support::traits::tokens::nonfungible`] through XCM. use crate::MintLocation; +use core::{marker::PhantomData, result}; use frame_support::{ ensure, traits::{tokens::nonfungible, Get}, }; -use sp_std::{marker::PhantomData, prelude::*, result}; use xcm::latest::prelude::*; use xcm_executor::traits::{ ConvertLocation, Error as MatchError, MatchesNonFungible, TransactAsset, diff --git a/polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs b/polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs index 3fce953848ebd..b111a05a4f1fc 100644 --- a/polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs @@ -17,11 +17,11 @@ //! Adapters to work with [`frame_support::traits::tokens::nonfungibles`] through XCM. use crate::{AssetChecking, MintLocation}; +use core::{marker::PhantomData, result}; use frame_support::{ ensure, traits::{tokens::nonfungibles, Get}, }; -use sp_std::{marker::PhantomData, prelude::*, result}; use xcm::latest::prelude::*; use xcm_executor::traits::{ ConvertLocation, Error as MatchError, MatchesNonFungibles, TransactAsset, diff --git a/polkadot/xcm/xcm-builder/src/origin_aliases.rs b/polkadot/xcm/xcm-builder/src/origin_aliases.rs index bbf810463a7c5..d568adc3127ce 100644 --- a/polkadot/xcm/xcm-builder/src/origin_aliases.rs +++ b/polkadot/xcm/xcm-builder/src/origin_aliases.rs @@ -16,8 +16,8 @@ //! Implementation for `ContainsPair`. +use core::marker::PhantomData; use frame_support::traits::{Contains, ContainsPair}; -use sp_std::marker::PhantomData; use xcm::latest::prelude::*; /// Alias a Foreign `AccountId32` with a local `AccountId32` if the foreign `AccountId32` matches diff --git a/polkadot/xcm/xcm-builder/src/origin_conversion.rs b/polkadot/xcm/xcm-builder/src/origin_conversion.rs index f64b5660f6674..6e73c0dae7b69 100644 --- a/polkadot/xcm/xcm-builder/src/origin_conversion.rs +++ b/polkadot/xcm/xcm-builder/src/origin_conversion.rs @@ -16,11 +16,11 @@ //! Various implementations for `ConvertOrigin`. +use core::marker::PhantomData; use frame_support::traits::{EnsureOrigin, Get, GetBacking, OriginTrait}; use frame_system::RawOrigin as SystemRawOrigin; use polkadot_parachain_primitives::primitives::IsSystem; use sp_runtime::traits::TryConvert; -use sp_std::marker::PhantomData; use xcm::latest::{BodyId, BodyPart, Junction, Junctions::*, Location, NetworkId, OriginKind}; use xcm_executor::traits::{ConvertLocation, ConvertOrigin}; diff --git a/polkadot/xcm/xcm-builder/src/pay.rs b/polkadot/xcm/xcm-builder/src/pay.rs index 35b624b041539..978c6870cdaf1 100644 --- a/polkadot/xcm/xcm-builder/src/pay.rs +++ b/polkadot/xcm/xcm-builder/src/pay.rs @@ -16,12 +16,13 @@ //! `PayOverXcm` struct for paying through XCM and getting the status back. +use alloc::vec; +use core::marker::PhantomData; use frame_support::traits::{ tokens::{Pay, PaymentStatus}, Get, }; use sp_runtime::traits::TryConvert; -use sp_std::{marker::PhantomData, vec}; use xcm::{opaque::lts::Weight, prelude::*}; use xcm_executor::traits::{QueryHandler, QueryResponseStatus}; @@ -199,7 +200,7 @@ pub struct LocatableAssetId { /// Adapter `struct` which implements a conversion from any `AssetKind` into a [`LocatableAssetId`] /// value using a fixed `Location` for the `location` field. -pub struct FixedLocation(sp_std::marker::PhantomData); +pub struct FixedLocation(core::marker::PhantomData); impl, AssetKind: Into> TryConvert for FixedLocation { diff --git a/polkadot/xcm/xcm-builder/src/process_xcm_message.rs b/polkadot/xcm/xcm-builder/src/process_xcm_message.rs index ef8c71fc24951..2e6f8c5fb5661 100644 --- a/polkadot/xcm/xcm-builder/src/process_xcm_message.rs +++ b/polkadot/xcm/xcm-builder/src/process_xcm_message.rs @@ -17,9 +17,9 @@ //! Implementation of `ProcessMessage` for an `ExecuteXcm` implementation. use codec::{Decode, FullCodec, MaxEncodedLen}; +use core::{fmt::Debug, marker::PhantomData}; use frame_support::traits::{ProcessMessage, ProcessMessageError}; use scale_info::TypeInfo; -use sp_std::{fmt::Debug, marker::PhantomData}; use sp_weights::{Weight, WeightMeter}; use xcm::prelude::*; @@ -118,6 +118,7 @@ impl< #[cfg(test)] mod tests { use super::*; + use alloc::vec; use codec::Encode; use frame_support::{ assert_err, assert_ok, diff --git a/polkadot/xcm/xcm-builder/src/routing.rs b/polkadot/xcm/xcm-builder/src/routing.rs index 543aef97c3409..03ef780ef0325 100644 --- a/polkadot/xcm/xcm-builder/src/routing.rs +++ b/polkadot/xcm/xcm-builder/src/routing.rs @@ -16,9 +16,10 @@ //! Various implementations for `SendXcm`. +use alloc::vec::Vec; use codec::Encode; +use core::{marker::PhantomData, result::Result}; use frame_system::unique; -use sp_std::{marker::PhantomData, result::Result, vec::Vec}; use xcm::prelude::*; use xcm_executor::{traits::FeeReason, FeesMode}; @@ -173,7 +174,7 @@ impl InspectMessageQueues for Tuple { /// `Inner::Ticket`. Therefore, this router aims to validate at least the passed `message`. /// /// NOTE: For use in mock runtimes which don't have the DMP/UMP/HRMP XCM validations. -pub struct EnsureDecodableXcm(sp_std::marker::PhantomData); +pub struct EnsureDecodableXcm(core::marker::PhantomData); impl SendXcm for EnsureDecodableXcm { type Ticket = Inner::Ticket; diff --git a/polkadot/xcm/xcm-builder/src/test_utils.rs b/polkadot/xcm/xcm-builder/src/test_utils.rs index 3131dece37570..37a49a1b3dc7e 100644 --- a/polkadot/xcm/xcm-builder/src/test_utils.rs +++ b/polkadot/xcm/xcm-builder/src/test_utils.rs @@ -16,11 +16,11 @@ // Shared test utilities and implementations for the XCM Builder. +use alloc::vec::Vec; use frame_support::{ parameter_types, traits::{Contains, CrateVersion, PalletInfoData, PalletsInfoAccess}, }; -use sp_std::vec::Vec; pub use xcm::latest::{prelude::*, Weight}; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ diff --git a/polkadot/xcm/xcm-builder/src/tests/mock.rs b/polkadot/xcm/xcm-builder/src/tests/mock.rs index f35c73bdb6857..ac43d217ff3ff 100644 --- a/polkadot/xcm/xcm-builder/src/tests/mock.rs +++ b/polkadot/xcm/xcm-builder/src/tests/mock.rs @@ -26,7 +26,12 @@ pub use crate::{ AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit, }; +pub use alloc::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; pub use codec::{Decode, Encode}; +pub use core::{ + cell::{Cell, RefCell}, + fmt::Debug, +}; use frame_support::traits::{ContainsPair, Everything}; pub use frame_support::{ dispatch::{DispatchInfo, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo}, @@ -34,11 +39,6 @@ pub use frame_support::{ sp_runtime::{traits::Dispatchable, DispatchError, DispatchErrorWithPostInfo}, traits::{Contains, Get, IsInVec}, }; -pub use sp_std::{ - cell::{Cell, RefCell}, - collections::{btree_map::BTreeMap, btree_set::BTreeSet}, - fmt::Debug, -}; pub use xcm::latest::{prelude::*, QueryId, Weight}; use xcm_executor::traits::{Properties, QueryHandler, QueryResponseStatus}; pub use xcm_executor::{ diff --git a/polkadot/xcm/xcm-builder/src/tests/mod.rs b/polkadot/xcm/xcm-builder/src/tests/mod.rs index 16ce3d2cf8ffe..379baaf5e3767 100644 --- a/polkadot/xcm/xcm-builder/src/tests/mod.rs +++ b/polkadot/xcm/xcm-builder/src/tests/mod.rs @@ -15,6 +15,7 @@ // along with Polkadot. If not, see . use super::{test_utils::*, *}; +use alloc::{vec, vec::Vec}; use frame_support::{ assert_err, traits::{ConstU32, ContainsPair, ProcessMessageError}, diff --git a/polkadot/xcm/xcm-builder/src/universal_exports.rs b/polkadot/xcm/xcm-builder/src/universal_exports.rs index 9820d535f7efd..8aa9602fcc297 100644 --- a/polkadot/xcm/xcm-builder/src/universal_exports.rs +++ b/polkadot/xcm/xcm-builder/src/universal_exports.rs @@ -17,9 +17,10 @@ //! Traits and utilities to help with origin mutation and bridging. use crate::InspectMessageQueues; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; +use core::{convert::TryInto, marker::PhantomData}; use frame_support::{ensure, traits::Get}; -use sp_std::{convert::TryInto, marker::PhantomData, prelude::*}; use xcm::prelude::*; use xcm_executor::traits::{validate_export, ExportXcm}; use SendError::*; @@ -149,7 +150,7 @@ impl NetworkExportTableItem { /// An adapter for the implementation of `ExporterFor`, which attempts to find the /// `(bridge_location, payment)` for the requested `network` and `remote_location` in the provided /// `T` table containing various exporters. -pub struct NetworkExportTable(sp_std::marker::PhantomData); +pub struct NetworkExportTable(core::marker::PhantomData); impl>> ExporterFor for NetworkExportTable { fn exporter_for( network: &NetworkId, @@ -649,7 +650,7 @@ mod tests { pub PaymentForNetworkAAndParachain2000: Asset = (Location::parent(), 150).into(); - pub BridgeTable: sp_std::vec::Vec = sp_std::vec![ + pub BridgeTable: alloc::vec::Vec = alloc::vec![ // NetworkA allows `Parachain(1000)` as remote location WITHOUT payment. NetworkExportTableItem::new( NetworkA::get(), diff --git a/polkadot/xcm/xcm-builder/src/weight.rs b/polkadot/xcm/xcm-builder/src/weight.rs index 1efa42ce95601..7861fdcc2e579 100644 --- a/polkadot/xcm/xcm-builder/src/weight.rs +++ b/polkadot/xcm/xcm-builder/src/weight.rs @@ -15,6 +15,7 @@ // along with Polkadot. If not, see . use codec::Decode; +use core::{marker::PhantomData, result::Result}; use frame_support::{ dispatch::GetDispatchInfo, traits::{ @@ -27,7 +28,6 @@ use frame_support::{ }, }; use sp_runtime::traits::{SaturatedConversion, Saturating, Zero}; -use sp_std::{marker::PhantomData, result::Result}; use xcm::latest::{prelude::*, GetWeight, Weight}; use xcm_executor::{ traits::{WeightBounds, WeightTrader}, diff --git a/polkadot/xcm/xcm-builder/tests/mock/mod.rs b/polkadot/xcm/xcm-builder/tests/mock/mod.rs index 582d596b78f10..0468b0a5410c4 100644 --- a/polkadot/xcm/xcm-builder/tests/mock/mod.rs +++ b/polkadot/xcm/xcm-builder/tests/mock/mod.rs @@ -15,6 +15,7 @@ // along with Polkadot. If not, see . use codec::Encode; +use core::cell::RefCell; use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{Everything, Nothing}, @@ -23,7 +24,6 @@ use frame_support::{ use frame_system::EnsureRoot; use primitive_types::H256; use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage}; -use sp_std::cell::RefCell; use polkadot_parachain_primitives::primitives::Id as ParaId; use polkadot_runtime_parachains::{configuration, origin, shared}; diff --git a/polkadot/xcm/xcm-executor/Cargo.toml b/polkadot/xcm/xcm-executor/Cargo.toml index 7d1fc48692f9a..cc966f91fe4db 100644 --- a/polkadot/xcm/xcm-executor/Cargo.toml +++ b/polkadot/xcm/xcm-executor/Cargo.toml @@ -15,7 +15,6 @@ environmental = { workspace = true } codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive", "serde"], workspace = true } xcm = { workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } sp-arithmetic = { workspace = true } sp-core = { workspace = true } @@ -42,7 +41,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-weights/std", "tracing/std", "xcm/std", diff --git a/polkadot/xcm/xcm-executor/src/assets.rs b/polkadot/xcm/xcm-executor/src/assets.rs index 4407752f70242..09e7535ebf81d 100644 --- a/polkadot/xcm/xcm-executor/src/assets.rs +++ b/polkadot/xcm/xcm-executor/src/assets.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use sp_runtime::{traits::Saturating, RuntimeDebug}; -use sp_std::{ +use alloc::{ collections::{btree_map::BTreeMap, btree_set::BTreeSet}, - mem, - prelude::*, + vec::Vec, }; +use core::mem; +use sp_runtime::{traits::Saturating, RuntimeDebug}; use xcm::latest::{ Asset, AssetFilter, AssetId, AssetInstance, Assets, Fungibility::{Fungible, NonFungible}, @@ -520,7 +520,9 @@ impl AssetsInHolding { #[cfg(test)] mod tests { use super::*; + use alloc::vec; use xcm::latest::prelude::*; + #[allow(non_snake_case)] /// Concrete fungible constructor fn CF(amount: u128) -> Asset { diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index aeeb24dcf8124..1daf5ae750cfb 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -16,7 +16,11 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; +use core::{fmt::Debug, marker::PhantomData}; use frame_support::{ dispatch::GetDispatchInfo, ensure, @@ -24,7 +28,6 @@ use frame_support::{ }; use sp_core::defer; use sp_io::hashing::blake2_128; -use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; use sp_weights::Weight; use xcm::latest::prelude::*; @@ -392,7 +395,7 @@ impl XcmExecutor { /// Remove the registered error handler and return it. Do not refund its weight. fn take_error_handler(&mut self) -> Xcm { let mut r = Xcm::(vec![]); - sp_std::mem::swap(&mut self.error_handler, &mut r); + core::mem::swap(&mut self.error_handler, &mut r); self.error_handler_weight = Weight::zero(); r } @@ -407,7 +410,7 @@ impl XcmExecutor { /// Remove the registered appendix and return it. fn take_appendix(&mut self) -> Xcm { let mut r = Xcm::(vec![]); - sp_std::mem::swap(&mut self.appendix, &mut r); + core::mem::swap(&mut self.appendix, &mut r); self.appendix_weight = Weight::zero(); r } diff --git a/polkadot/xcm/xcm-executor/src/traits/asset_lock.rs b/polkadot/xcm/xcm-executor/src/traits/asset_lock.rs index b6270c5294521..b4e9f32983fd5 100644 --- a/polkadot/xcm/xcm-executor/src/traits/asset_lock.rs +++ b/polkadot/xcm/xcm-executor/src/traits/asset_lock.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use sp_std::convert::Infallible; +use core::convert::Infallible; use xcm::prelude::*; #[derive(Debug)] diff --git a/polkadot/xcm/xcm-executor/src/traits/conversion.rs b/polkadot/xcm/xcm-executor/src/traits/conversion.rs index 1efe138b8c211..bc62ad6556697 100644 --- a/polkadot/xcm/xcm-executor/src/traits/conversion.rs +++ b/polkadot/xcm/xcm-executor/src/traits/conversion.rs @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use core::{marker::PhantomData, result::Result}; use frame_support::traits::{Contains, OriginTrait}; use sp_runtime::{traits::Dispatchable, DispatchErrorWithPostInfo}; -use sp_std::{marker::PhantomData, result::Result}; use xcm::latest::prelude::*; /// Means of converting a location into an account identifier. diff --git a/polkadot/xcm/xcm-executor/src/traits/on_response.rs b/polkadot/xcm/xcm-executor/src/traits/on_response.rs index 5d2412d613755..a4ed6014b4fc8 100644 --- a/polkadot/xcm/xcm-executor/src/traits/on_response.rs +++ b/polkadot/xcm/xcm-executor/src/traits/on_response.rs @@ -16,10 +16,9 @@ use crate::{Junctions::Here, Xcm}; use codec::{Decode, Encode}; -use core::result; +use core::{fmt::Debug, result}; use frame_support::{pallet_prelude::Get, parameter_types}; use sp_arithmetic::traits::Zero; -use sp_std::fmt::Debug; use xcm::latest::{ Error as XcmError, InteriorLocation, Location, QueryId, Response, Result as XcmResult, Weight, XcmContext, diff --git a/polkadot/xcm/xcm-executor/src/traits/should_execute.rs b/polkadot/xcm/xcm-executor/src/traits/should_execute.rs index 2e3acf5960ec1..ec9ef70cc817e 100644 --- a/polkadot/xcm/xcm-executor/src/traits/should_execute.rs +++ b/polkadot/xcm/xcm-executor/src/traits/should_execute.rs @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use core::result::Result; use frame_support::traits::ProcessMessageError; -use sp_std::result::Result; use xcm::latest::{Instruction, Location, Weight, XcmHash}; /// Properties of an XCM message and its imminent execution. diff --git a/polkadot/xcm/xcm-executor/src/traits/token_matching.rs b/polkadot/xcm/xcm-executor/src/traits/token_matching.rs index 45f3dc062a6d0..aa44aee4f9de3 100644 --- a/polkadot/xcm/xcm-executor/src/traits/token_matching.rs +++ b/polkadot/xcm/xcm-executor/src/traits/token_matching.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use sp_std::result; +use core::result; use xcm::latest::prelude::*; pub trait MatchesFungible { diff --git a/polkadot/xcm/xcm-executor/src/traits/transact_asset.rs b/polkadot/xcm/xcm-executor/src/traits/transact_asset.rs index eb85af0b80f30..c2331f805b4bd 100644 --- a/polkadot/xcm/xcm-executor/src/traits/transact_asset.rs +++ b/polkadot/xcm/xcm-executor/src/traits/transact_asset.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use crate::AssetsInHolding; -use sp_std::result::Result; +use core::result::Result; use xcm::latest::{Asset, Error as XcmError, Location, Result as XcmResult, XcmContext}; /// Facility for asset transacting. diff --git a/polkadot/xcm/xcm-executor/src/traits/weight.rs b/polkadot/xcm/xcm-executor/src/traits/weight.rs index 985dfcd0cf2d7..72de3e0f433b9 100644 --- a/polkadot/xcm/xcm-executor/src/traits/weight.rs +++ b/polkadot/xcm/xcm-executor/src/traits/weight.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use crate::AssetsInHolding; -use sp_std::result::Result; +use core::result::Result; use xcm::latest::{prelude::*, Weight}; /// Determine the weight of an XCM message. diff --git a/polkadot/xcm/xcm-runtime-apis/Cargo.toml b/polkadot/xcm/xcm-runtime-apis/Cargo.toml index 7d3f1a20b639a..748d5af68a1fd 100644 --- a/polkadot/xcm/xcm-runtime-apis/Cargo.toml +++ b/polkadot/xcm/xcm-runtime-apis/Cargo.toml @@ -16,7 +16,6 @@ scale-info = { features = ["derive", "serde"], workspace = true } frame-support = { workspace = true } sp-api = { workspace = true } -sp-std = { workspace = true } sp-weights = { workspace = true } xcm = { workspace = true } xcm-executor = { workspace = true } @@ -48,7 +47,6 @@ std = [ "scale-info/std", "sp-api/std", "sp-io/std", - "sp-std/std", "sp-weights/std", "xcm-builder/std", "xcm-executor/std", diff --git a/polkadot/xcm/xcm-runtime-apis/src/conversions.rs b/polkadot/xcm/xcm-runtime-apis/src/conversions.rs index d422664557e0e..e5eeac013fee6 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/conversions.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/conversions.rs @@ -44,7 +44,7 @@ pub enum Error { /// It is useful when you already have a `ConvertLocation` implementation and a default /// `Ss58Prefix`. pub struct LocationToAccountHelper( - sp_std::marker::PhantomData<(AccountId, Conversion)>, + core::marker::PhantomData<(AccountId, Conversion)>, ); impl> LocationToAccountHelper diff --git a/polkadot/xcm/xcm-runtime-apis/src/dry_run.rs b/polkadot/xcm/xcm-runtime-apis/src/dry_run.rs index 9828acab40230..2a1a0daf0d5d5 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/dry_run.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/dry_run.rs @@ -18,9 +18,9 @@ //! This API can be used to simulate XCMs and, for example, find the fees //! that need to be paid. +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::pallet_prelude::{DispatchResultWithPostInfo, TypeInfo}; -use sp_std::vec::Vec; use xcm::prelude::*; /// Effects of dry-running an extrinsic. diff --git a/polkadot/xcm/xcm-runtime-apis/src/fees.rs b/polkadot/xcm/xcm-runtime-apis/src/fees.rs index 572d4edf53386..3445d42ecab3b 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/fees.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/fees.rs @@ -16,9 +16,9 @@ //! Runtime API definition for getting XCM fees. +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::pallet_prelude::TypeInfo; -use sp_std::vec::Vec; use sp_weights::Weight; use xcm::{Version, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm}; diff --git a/polkadot/xcm/xcm-runtime-apis/src/lib.rs b/polkadot/xcm/xcm-runtime-apis/src/lib.rs index 7b3b86214b3a1..b106836c1132b 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/lib.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/lib.rs @@ -18,6 +18,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + /// Exposes runtime APIs for various XCM-related conversions. pub mod conversions; diff --git a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs index e723e25463565..c76b26fcd2a33 100644 --- a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs +++ b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs @@ -18,6 +18,7 @@ //! Implements both runtime APIs for fee estimation and getting the messages for transfers. use codec::Encode; +use core::{cell::RefCell, marker::PhantomData}; use frame_support::{ construct_runtime, derive_impl, parameter_types, sp_runtime, sp_runtime::{ @@ -32,7 +33,6 @@ use frame_support::{ }; use frame_system::{EnsureRoot, RawOrigin as SystemRawOrigin}; use pallet_xcm::TestWeightInfo; -use sp_std::{cell::RefCell, marker::PhantomData}; use xcm::{prelude::*, Version as XcmVersion}; use xcm_builder::{ AllowTopLevelPaidExecutionFrom, ConvertedConcreteId, EnsureXcmOrigin, FixedRateOfFungible, diff --git a/polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs b/polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs index 93c8302757cb0..bfb455aba3f93 100644 --- a/polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs +++ b/polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs @@ -31,7 +31,6 @@ use sp_runtime::{ traits::{Get, IdentityLookup}, AccountId32, }; -use sp_std::prelude::*; use xcm::latest::prelude::*; use xcm_builder::{EnsureXcmOrigin, SignedToAccountId32}; use xcm_executor::{traits::ConvertLocation, XcmExecutor}; @@ -101,7 +100,7 @@ impl EnsureOriginWithArg for ForeignCreators { fn try_origin( o: RuntimeOrigin, a: &Location, - ) -> sp_std::result::Result { + ) -> core::result::Result { let origin_location = pallet_xcm::EnsureXcm::::try_origin(o.clone())?; if !a.starts_with(&origin_location) { return Err(o); diff --git a/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs b/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs index 11435868d4682..616329a2f06b4 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -29,7 +29,6 @@ use sp_runtime::{ traits::{AccountIdLookup, BlakeTwo256, Hash, IdentifyAccount, Verify}, MultiAddress, MultiSignature, }; -use sp_std::prelude::*; use pallet_xcm::XcmPassthrough; use polkadot_core_primitives::BlockNumber as RelayBlockNumber; diff --git a/polkadot/xcm/xcm-simulator/src/lib.rs b/polkadot/xcm/xcm-simulator/src/lib.rs index a6747a4789edf..59df394406ea0 100644 --- a/polkadot/xcm/xcm-simulator/src/lib.rs +++ b/polkadot/xcm/xcm-simulator/src/lib.rs @@ -20,15 +20,18 @@ /// Used for sending messages. pub mod mock_message_queue; +extern crate alloc; + pub use codec::Encode; pub use paste; +pub use alloc::collections::vec_deque::VecDeque; +pub use core::{cell::RefCell, marker::PhantomData}; pub use frame_support::{ traits::{EnqueueMessage, Get, ProcessMessage, ProcessMessageError, ServiceQueues}, weights::{Weight, WeightMeter}, }; pub use sp_io::{hashing::blake2_256, TestExternalities}; -pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, marker::PhantomData}; pub use polkadot_core_primitives::BlockNumber as RelayBlockNumber; pub use polkadot_parachain_primitives::primitives::{ diff --git a/polkadot/xcm/xcm-simulator/src/mock_message_queue.rs b/polkadot/xcm/xcm-simulator/src/mock_message_queue.rs index 96b47999fe952..bf7b0e15967c0 100644 --- a/polkadot/xcm/xcm-simulator/src/mock_message_queue.rs +++ b/polkadot/xcm/xcm-simulator/src/mock_message_queue.rs @@ -24,7 +24,6 @@ use polkadot_parachain_primitives::primitives::{ use polkadot_primitives::BlockNumber as RelayBlockNumber; use sp_runtime::traits::{Get, Hash}; -use sp_std::prelude::*; use xcm::{latest::prelude::*, VersionedXcm}; pub use pallet::*; diff --git a/substrate/bin/node/runtime/src/assets_api.rs b/substrate/bin/node/runtime/src/assets_api.rs index 38ec56507113f..98187e7391f3e 100644 --- a/substrate/bin/node/runtime/src/assets_api.rs +++ b/substrate/bin/node/runtime/src/assets_api.rs @@ -20,8 +20,8 @@ use polkadot_sdk::*; +use alloc::vec::Vec; use codec::Codec; -use sp_std::vec::Vec; sp_api::decl_runtime_apis! { pub trait AssetsApi diff --git a/substrate/bin/node/runtime/src/impls.rs b/substrate/bin/node/runtime/src/impls.rs index dbe562857c99f..6c121fad624b2 100644 --- a/substrate/bin/node/runtime/src/impls.rs +++ b/substrate/bin/node/runtime/src/impls.rs @@ -17,8 +17,7 @@ //! Some configurable implementations as associated type for the substrate runtime. -use polkadot_sdk::*; - +use alloc::boxed::Box; use frame_support::{ pallet_prelude::*, traits::{ @@ -29,7 +28,7 @@ use frame_support::{ use pallet_alliance::{IdentityVerifier, ProposalIndex, ProposalProvider}; use pallet_asset_tx_payment::HandleCredit; use pallet_identity::legacy::IdentityField; -use sp_std::prelude::*; +use polkadot_sdk::*; use crate::{ AccountId, AllianceCollective, AllianceMotion, Assets, Authorship, Balances, Hash, diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index fc87fea57ba2e..2d1f52066f8f3 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -22,8 +22,11 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limits. #![recursion_limit = "1024"] +extern crate alloc; + use polkadot_sdk::*; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_election_provider_support::{ bounds::{ElectionBounds, ElectionBoundsBuilder}, @@ -100,7 +103,6 @@ use sp_runtime::{ ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Percent, Permill, Perquintill, RuntimeDebug, }; -use sp_std::prelude::*; #[cfg(any(feature = "std", test))] use sp_version::NativeVersion; use sp_version::RuntimeVersion; @@ -2660,7 +2662,7 @@ impl_runtime_apis! { Runtime::metadata_at_version(version) } - fn metadata_versions() -> sp_std::vec::Vec { + fn metadata_versions() -> alloc::vec::Vec { Runtime::metadata_versions() } } diff --git a/substrate/client/executor/runtime-test/Cargo.toml b/substrate/client/executor/runtime-test/Cargo.toml index 5f5e7eb46d623..d132f47ff877f 100644 --- a/substrate/client/executor/runtime-test/Cargo.toml +++ b/substrate/client/executor/runtime-test/Cargo.toml @@ -20,7 +20,6 @@ sp-core = { workspace = true } sp-io = { features = ["improved_panic_error_reporting"], workspace = true } sp-runtime = { workspace = true } sp-runtime-interface = { workspace = true } -sp-std = { workspace = true } [build-dependencies] substrate-wasm-builder = { optional = true, workspace = true, default-features = true } @@ -32,6 +31,5 @@ std = [ "sp-io/std", "sp-runtime-interface/std", "sp-runtime/std", - "sp-std/std", "substrate-wasm-builder", ] diff --git a/substrate/client/executor/runtime-test/src/lib.rs b/substrate/client/executor/runtime-test/src/lib.rs index 40683fbb664aa..08a5e39dff2cf 100644 --- a/substrate/client/executor/runtime-test/src/lib.rs +++ b/substrate/client/executor/runtime-test/src/lib.rs @@ -32,7 +32,10 @@ pub fn wasm_binary_unwrap() -> &'static [u8] { } #[cfg(not(feature = "std"))] -use sp_std::{vec, vec::Vec}; +extern crate alloc; + +#[cfg(not(feature = "std"))] +use alloc::{vec, vec::Vec}; #[cfg(not(feature = "std"))] use sp_core::{ed25519, sr25519}; @@ -332,7 +335,7 @@ sp_core::wasm_export_functions! { let test_message = b"Hello invalid heap memory"; let ptr = (heap_base + offset) as *mut u8; - let message_slice = unsafe { sp_std::slice::from_raw_parts_mut(ptr, test_message.len()) }; + let message_slice = unsafe { alloc::slice::from_raw_parts_mut(ptr, test_message.len()) }; assert_ne!(test_message, message_slice); message_slice.copy_from_slice(test_message); diff --git a/substrate/client/sysinfo/src/sysinfo.rs b/substrate/client/sysinfo/src/sysinfo.rs index 3fa583cf7aca1..37b35fcb91032 100644 --- a/substrate/client/sysinfo/src/sysinfo.rs +++ b/substrate/client/sysinfo/src/sysinfo.rs @@ -21,13 +21,13 @@ use crate::{ExecutionLimit, HwBench}; use sc_telemetry::SysInfo; use sp_core::{sr25519, Pair}; use sp_io::crypto::sr25519_verify; -use sp_std::{fmt, fmt::Formatter, prelude::*}; use derive_more::From; use rand::{seq::SliceRandom, Rng, RngCore}; use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; use std::{ - fmt::Display, + fmt, + fmt::{Display, Formatter}, fs::File, io::{Seek, SeekFrom, Write}, ops::{Deref, DerefMut}, diff --git a/substrate/frame/Cargo.toml b/substrate/frame/Cargo.toml index 594cb505cd60f..41ece6c9a27fe 100644 --- a/substrate/frame/Cargo.toml +++ b/substrate/frame/Cargo.toml @@ -27,7 +27,6 @@ scale-info = { features = [ # primitive deps, used for developing FRAME pallets. sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } sp-core = { workspace = true } sp-arithmetic = { workspace = true } @@ -104,7 +103,6 @@ std = [ "sp-offchain?/std", "sp-runtime/std", "sp-session?/std", - "sp-std/std", "sp-storage/std", "sp-transaction-pool?/std", "sp-version?/std", diff --git a/substrate/frame/alliance/Cargo.toml b/substrate/frame/alliance/Cargo.toml index 7ad9961d9b89c..451b86b35ddef 100644 --- a/substrate/frame/alliance/Cargo.toml +++ b/substrate/frame/alliance/Cargo.toml @@ -22,7 +22,6 @@ log = { workspace = true } codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-std = { workspace = true } sp-core = { workspace = true } sp-crypto-hashing = { optional = true, workspace = true } sp-io = { workspace = true } @@ -57,7 +56,6 @@ std = [ "sp-crypto-hashing?/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "array-bytes", diff --git a/substrate/frame/alliance/src/lib.rs b/substrate/frame/alliance/src/lib.rs index ed771c7226ea9..be65f49e6e4ea 100644 --- a/substrate/frame/alliance/src/lib.rs +++ b/substrate/frame/alliance/src/lib.rs @@ -94,6 +94,9 @@ pub mod migration; mod types; pub mod weights; +extern crate alloc; + +use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; @@ -101,7 +104,6 @@ use sp_runtime::{ traits::{Dispatchable, Saturating, StaticLookup, Zero}, DispatchError, RuntimeDebug, }; -use sp_std::prelude::*; use frame_support::{ dispatch::{DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo}, diff --git a/substrate/frame/alliance/src/types.rs b/substrate/frame/alliance/src/types.rs index 149030b52c674..75b949c19b325 100644 --- a/substrate/frame/alliance/src/types.rs +++ b/substrate/frame/alliance/src/types.rs @@ -15,11 +15,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{traits::ConstU32, BoundedVec}; use scale_info::TypeInfo; use sp_runtime::RuntimeDebug; -use sp_std::prelude::*; /// A Multihash instance that only supports the basic functionality and no hashing. #[derive( diff --git a/substrate/frame/asset-conversion/Cargo.toml b/substrate/frame/asset-conversion/Cargo.toml index 27d86bf6710b0..4e867ece1bd27 100644 --- a/substrate/frame/asset-conversion/Cargo.toml +++ b/substrate/frame/asset-conversion/Cargo.toml @@ -25,7 +25,6 @@ scale-info = { features = ["derive"], workspace = true } sp-api = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } sp-arithmetic = { workspace = true } @@ -51,7 +50,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/asset-conversion/ops/Cargo.toml b/substrate/frame/asset-conversion/ops/Cargo.toml index 0dc6cd5b1672a..97a676fde10d5 100644 --- a/substrate/frame/asset-conversion/ops/Cargo.toml +++ b/substrate/frame/asset-conversion/ops/Cargo.toml @@ -24,7 +24,6 @@ pallet-asset-conversion = { workspace = true } scale-info = { features = ["derive"], workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } sp-arithmetic = { workspace = true } @@ -50,7 +49,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/asset-conversion/ops/src/benchmarking.rs b/substrate/frame/asset-conversion/ops/src/benchmarking.rs index a7370f38bc4b0..384e17c9f0aac 100644 --- a/substrate/frame/asset-conversion/ops/src/benchmarking.rs +++ b/substrate/frame/asset-conversion/ops/src/benchmarking.rs @@ -28,7 +28,6 @@ use frame_system::RawOrigin as SystemOrigin; use pallet_asset_conversion::{BenchmarkHelper, Pallet as AssetConversion}; use sp_core::Get; use sp_runtime::traits::One; -use sp_std::prelude::*; /// Provides a pair of amounts expected to serve as sufficient initial liquidity for a pool. fn valid_liquidity_amount(ed1: T::Balance, ed2: T::Balance) -> (T::Balance, T::Balance) diff --git a/substrate/frame/asset-conversion/ops/src/lib.rs b/substrate/frame/asset-conversion/ops/src/lib.rs index a655a9cb44525..58c15b47a3eb3 100644 --- a/substrate/frame/asset-conversion/ops/src/lib.rs +++ b/substrate/frame/asset-conversion/ops/src/lib.rs @@ -42,6 +42,9 @@ pub mod weights; pub use pallet::*; pub use weights::WeightInfo; +extern crate alloc; + +use alloc::boxed::Box; use frame_support::traits::{ fungible::{Inspect as FungibleInspect, Mutate as FungibleMutate}, fungibles::{roles::ResetTeam, Inspect, Mutate, Refund}, @@ -50,7 +53,6 @@ use frame_support::traits::{ }; use pallet_asset_conversion::{PoolLocator, Pools}; use sp_runtime::traits::{TryConvert, Zero}; -use sp_std::boxed::Box; #[frame_support::pallet] pub mod pallet { diff --git a/substrate/frame/asset-conversion/ops/src/mock.rs b/substrate/frame/asset-conversion/ops/src/mock.rs index 91c18b2e79494..5c05faa6aa88d 100644 --- a/substrate/frame/asset-conversion/ops/src/mock.rs +++ b/substrate/frame/asset-conversion/ops/src/mock.rs @@ -17,7 +17,6 @@ //! Test environment for Asset Conversion Ops pallet. -use super::*; use crate as pallet_asset_conversion_ops; use core::default::Default; use frame_support::{ diff --git a/substrate/frame/asset-conversion/src/benchmarking.rs b/substrate/frame/asset-conversion/src/benchmarking.rs index c5f68476b1d0a..b003fe482881d 100644 --- a/substrate/frame/asset-conversion/src/benchmarking.rs +++ b/substrate/frame/asset-conversion/src/benchmarking.rs @@ -19,6 +19,8 @@ use super::*; use crate::Pallet as AssetConversion; +use alloc::vec; +use core::marker::PhantomData; use frame_benchmarking::{v2::*, whitelisted_caller}; use frame_support::{ assert_ok, @@ -29,7 +31,6 @@ use frame_support::{ }; use frame_system::RawOrigin as SystemOrigin; use sp_core::Get; -use sp_std::{marker::PhantomData, prelude::*}; /// Benchmark Helper pub trait BenchmarkHelper { diff --git a/substrate/frame/asset-conversion/src/lib.rs b/substrate/frame/asset-conversion/src/lib.rs index 62acb693efb1c..a9dc30375e5a8 100644 --- a/substrate/frame/asset-conversion/src/lib.rs +++ b/substrate/frame/asset-conversion/src/lib.rs @@ -70,6 +70,9 @@ pub use swap::*; pub use types::*; pub use weights::WeightInfo; +extern crate alloc; + +use alloc::{boxed::Box, collections::btree_set::BTreeSet, vec::Vec}; use codec::Codec; use frame_support::{ storage::{with_storage_layer, with_transaction}, @@ -93,7 +96,6 @@ use sp_runtime::{ }, DispatchError, Saturating, TokenError, TransactionOutcome, }; -use sp_std::{boxed::Box, collections::btree_set::BTreeSet, vec::Vec}; #[frame_support::pallet] pub mod pallet { diff --git a/substrate/frame/asset-rate/Cargo.toml b/substrate/frame/asset-rate/Cargo.toml index 96c87020684fb..4aeb6a39e8241 100644 --- a/substrate/frame/asset-rate/Cargo.toml +++ b/substrate/frame/asset-rate/Cargo.toml @@ -23,7 +23,6 @@ frame-benchmarking = { optional = true, workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-core = { optional = true, workspace = true } [dev-dependencies] @@ -43,7 +42,6 @@ std = [ "sp-core?/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/asset-rate/src/lib.rs b/substrate/frame/asset-rate/src/lib.rs index 69f8267a4f25f..cfb013a73f5e8 100644 --- a/substrate/frame/asset-rate/src/lib.rs +++ b/substrate/frame/asset-rate/src/lib.rs @@ -59,6 +59,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::boxed::Box; use frame_support::traits::{ fungible::Inspect, tokens::{ConversionFromAssetBalance, ConversionToAssetBalance}, @@ -67,7 +70,6 @@ use sp_runtime::{ traits::{CheckedDiv, Zero}, FixedPointNumber, FixedU128, }; -use sp_std::boxed::Box; pub use pallet::*; pub use weights::WeightInfo; diff --git a/substrate/frame/assets/Cargo.toml b/substrate/frame/assets/Cargo.toml index d0b5dc7778988..802b8b9f39d80 100644 --- a/substrate/frame/assets/Cargo.toml +++ b/substrate/frame/assets/Cargo.toml @@ -20,7 +20,6 @@ codec = { workspace = true } impl-trait-for-tuples = "0.2.2" log = { workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-std = { workspace = true } # Needed for various traits. In our case, `OnFinalize`. sp-runtime = { workspace = true } # Needed for type-safe access to storage DB. @@ -48,7 +47,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/assets/src/benchmarking.rs b/substrate/frame/assets/src/benchmarking.rs index 1b65bb953d77c..97cc04174a0c6 100644 --- a/substrate/frame/assets/src/benchmarking.rs +++ b/substrate/frame/assets/src/benchmarking.rs @@ -20,13 +20,13 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; +use alloc::vec; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError, }; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; use frame_system::RawOrigin as SystemOrigin; use sp_runtime::traits::Bounded; -use sp_std::prelude::*; use crate::Pallet as Assets; @@ -76,7 +76,7 @@ fn swap_is_sufficient, I: 'static>(s: &mut bool) { let asset_id = default_asset_id::(); Asset::::mutate(&asset_id.into(), |maybe_a| { if let Some(ref mut a) = maybe_a { - sp_std::mem::swap(s, &mut a.is_sufficient) + core::mem::swap(s, &mut a.is_sufficient) } }); } diff --git a/substrate/frame/assets/src/functions.rs b/substrate/frame/assets/src/functions.rs index 1e4a9522759c3..c218c4ddc952c 100644 --- a/substrate/frame/assets/src/functions.rs +++ b/substrate/frame/assets/src/functions.rs @@ -18,6 +18,7 @@ //! Functions for the Assets pallet. use super::*; +use alloc::vec; use frame_support::{defensive, traits::Get, BoundedVec}; #[must_use] @@ -35,20 +36,20 @@ impl, I: 'static> Pallet { /// Return the extra "sid-car" data for `id`/`who`, or `None` if the account doesn't exist. pub fn adjust_extra( id: T::AssetId, - who: impl sp_std::borrow::Borrow, + who: impl core::borrow::Borrow, ) -> Option> { ExtraMutator::maybe_new(id, who) } /// Get the asset `id` balance of `who`, or zero if the asset-account doesn't exist. - pub fn balance(id: T::AssetId, who: impl sp_std::borrow::Borrow) -> T::Balance { + pub fn balance(id: T::AssetId, who: impl core::borrow::Borrow) -> T::Balance { Self::maybe_balance(id, who).unwrap_or_default() } /// Get the asset `id` balance of `who` if the asset-account exists. pub fn maybe_balance( id: T::AssetId, - who: impl sp_std::borrow::Borrow, + who: impl core::borrow::Borrow, ) -> Option { Account::::get(id, who.borrow()).map(|a| a.balance) } diff --git a/substrate/frame/assets/src/impl_fungibles.rs b/substrate/frame/assets/src/impl_fungibles.rs index 30122f6d788ff..578fa08c4e63e 100644 --- a/substrate/frame/assets/src/impl_fungibles.rs +++ b/substrate/frame/assets/src/impl_fungibles.rs @@ -17,6 +17,7 @@ //! Implementations for fungibles trait. +use alloc::vec::Vec; use frame_support::{ defensive, traits::tokens::{ diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index 6dbce717a8e8d..b9b5b2388dfbe 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -167,13 +167,15 @@ mod impl_stored_map; mod types; pub use types::*; +extern crate alloc; + use scale_info::TypeInfo; use sp_runtime::{ traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, TokenError, }; -use sp_std::prelude::*; +use alloc::vec::Vec; use core::marker::PhantomData; use frame_support::{ dispatch::DispatchResult, diff --git a/substrate/frame/atomic-swap/Cargo.toml b/substrate/frame/atomic-swap/Cargo.toml index 7e2f5fc74ab22..0331006301296 100644 --- a/substrate/frame/atomic-swap/Cargo.toml +++ b/substrate/frame/atomic-swap/Cargo.toml @@ -23,7 +23,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -39,7 +38,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/atomic-swap/src/lib.rs b/substrate/frame/atomic-swap/src/lib.rs index dc0300dc1a5c9..c3010f5c9c03b 100644 --- a/substrate/frame/atomic-swap/src/lib.rs +++ b/substrate/frame/atomic-swap/src/lib.rs @@ -42,6 +42,9 @@ mod tests; +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode}; use core::{ marker::PhantomData, @@ -58,7 +61,6 @@ use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::RuntimeDebug; -use sp_std::vec::Vec; /// Pending atomic swap operation. #[derive(Clone, Eq, PartialEq, RuntimeDebugNoBound, Encode, Decode, TypeInfo, MaxEncodedLen)] diff --git a/substrate/frame/aura/Cargo.toml b/substrate/frame/aura/Cargo.toml index 97582e7d2e9db..f9d7459276387 100644 --- a/substrate/frame/aura/Cargo.toml +++ b/substrate/frame/aura/Cargo.toml @@ -25,7 +25,6 @@ pallet-timestamp = { workspace = true } sp-application-crypto = { workspace = true } sp-consensus-aura = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true } @@ -45,7 +44,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/aura/src/lib.rs b/substrate/frame/aura/src/lib.rs index 3ca1444aaae9b..f829578fb2851 100644 --- a/substrate/frame/aura/src/lib.rs +++ b/substrate/frame/aura/src/lib.rs @@ -38,6 +38,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ traits::{DisabledValidators, FindAuthor, Get, OnTimestampSet, OneSessionHandler}, @@ -50,7 +53,6 @@ use sp_runtime::{ traits::{IsMember, Member, SaturatedConversion, Saturating, Zero}, RuntimeAppPublic, }; -use sp_std::prelude::*; pub mod migrations; mod mock; @@ -66,7 +68,7 @@ const LOG_TARGET: &str = "runtime::aura"; /// /// This was the default behavior of the Aura pallet and may be used for /// backwards compatibility. -pub struct MinimumPeriodTimesTwo(sp_std::marker::PhantomData); +pub struct MinimumPeriodTimesTwo(core::marker::PhantomData); impl Get for MinimumPeriodTimesTwo { fn get() -> T::Moment { @@ -119,7 +121,7 @@ pub mod pallet { } #[pallet::pallet] - pub struct Pallet(sp_std::marker::PhantomData); + pub struct Pallet(core::marker::PhantomData); #[pallet::hooks] impl Hooks> for Pallet { @@ -362,7 +364,7 @@ impl FindAuthor for Pallet { /// We can not implement `FindAuthor` twice, because the compiler does not know if /// `u32 == T::AuthorityId` and thus, prevents us to implement the trait twice. #[doc(hidden)] -pub struct FindAccountFromAuthorIndex(sp_std::marker::PhantomData<(T, Inner)>); +pub struct FindAccountFromAuthorIndex(core::marker::PhantomData<(T, Inner)>); impl> FindAuthor for FindAccountFromAuthorIndex diff --git a/substrate/frame/authority-discovery/Cargo.toml b/substrate/frame/authority-discovery/Cargo.toml index 79057d94107be..9d55a7fd5dcb8 100644 --- a/substrate/frame/authority-discovery/Cargo.toml +++ b/substrate/frame/authority-discovery/Cargo.toml @@ -28,7 +28,6 @@ pallet-session = { features = [ sp-application-crypto = { workspace = true } sp-authority-discovery = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true, default-features = true } @@ -47,7 +46,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/authority-discovery/src/lib.rs b/substrate/frame/authority-discovery/src/lib.rs index 16f71960d693b..220b39292b575 100644 --- a/substrate/frame/authority-discovery/src/lib.rs +++ b/substrate/frame/authority-discovery/src/lib.rs @@ -23,12 +23,14 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use frame_support::{ traits::{Get, OneSessionHandler}, WeakBoundedVec, }; use sp_authority_discovery::AuthorityId; -use sp_std::prelude::*; pub use pallet::*; @@ -62,7 +64,7 @@ pub mod pallet { pub struct GenesisConfig { pub keys: Vec, #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -168,6 +170,7 @@ impl OneSessionHandler for Pallet { mod tests { use super::*; use crate as pallet_authority_discovery; + use alloc::vec; use frame_support::{derive_impl, parameter_types, traits::ConstU32}; use sp_application_crypto::Pair; use sp_authority_discovery::AuthorityPair; diff --git a/substrate/frame/authorship/Cargo.toml b/substrate/frame/authorship/Cargo.toml index 58292c0eba393..8ecacca93e0ab 100644 --- a/substrate/frame/authorship/Cargo.toml +++ b/substrate/frame/authorship/Cargo.toml @@ -24,7 +24,6 @@ scale-info = { features = ["derive"], workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true, default-features = true } @@ -40,7 +39,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/authorship/src/lib.rs b/substrate/frame/authorship/src/lib.rs index d8f1baab23c8b..a0cca806e7863 100644 --- a/substrate/frame/authorship/src/lib.rs +++ b/substrate/frame/authorship/src/lib.rs @@ -22,7 +22,6 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::traits::FindAuthor; -use sp_std::prelude::*; pub use pallet::*; diff --git a/substrate/frame/babe/Cargo.toml b/substrate/frame/babe/Cargo.toml index 68638798e796a..3dfda3b618be3 100644 --- a/substrate/frame/babe/Cargo.toml +++ b/substrate/frame/babe/Cargo.toml @@ -32,7 +32,6 @@ sp-io = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-session = { workspace = true } sp-staking = { features = ["serde"], workspace = true } -sp-std = { workspace = true } [dev-dependencies] frame-election-provider-support = { workspace = true, default-features = true } @@ -65,7 +64,6 @@ std = [ "sp-runtime/std", "sp-session/std", "sp-staking/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/babe/src/equivocation.rs b/substrate/frame/babe/src/equivocation.rs index ed1df640583b2..4be07bdae1f01 100644 --- a/substrate/frame/babe/src/equivocation.rs +++ b/substrate/frame/babe/src/equivocation.rs @@ -33,6 +33,7 @@ //! that the `ValidateUnsigned` for the BABE pallet is used in the runtime //! definition. +use alloc::{boxed::Box, vec, vec::Vec}; use frame_support::traits::{Get, KeyOwnerProofSystem}; use frame_system::pallet_prelude::HeaderFor; use log::{error, info}; @@ -50,7 +51,6 @@ use sp_staking::{ offence::{Kind, Offence, OffenceReportSystem, ReportOffence}, SessionIndex, }; -use sp_std::prelude::*; use crate::{Call, Config, Error, Pallet, LOG_TARGET}; @@ -104,7 +104,7 @@ impl Offence for EquivocationOffence { /// - On-chain validity checks and processing are mostly delegated to the user provided generic /// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits. /// - Offence reporter for unsigned transactions is fetched via the the authorship pallet. -pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); +pub struct EquivocationReportSystem(core::marker::PhantomData<(T, R, P, L)>); impl OffenceReportSystem, (EquivocationProof>, T::KeyOwnerProof)> diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index 9e16f1d095156..3e33d5627c47b 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -21,6 +21,9 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(unused_must_use, unsafe_code, unused_variables, unused_must_use)] +extern crate alloc; + +use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode}; use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, @@ -44,7 +47,6 @@ use sp_runtime::{ }; use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::{offence::OffenceReportSystem, SessionIndex}; -use sp_std::prelude::*; pub use sp_consensus_babe::AuthorityId; @@ -315,7 +317,7 @@ pub mod pallet { pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>, pub epoch_config: BabeEpochConfiguration, #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -687,7 +689,7 @@ impl Pallet { // Update the start blocks of the previous and new current epoch. EpochStart::::mutate(|(previous_epoch_start_block, current_epoch_start_block)| { - *previous_epoch_start_block = sp_std::mem::take(current_epoch_start_block); + *previous_epoch_start_block = core::mem::take(current_epoch_start_block); *current_epoch_start_block = >::block_number(); }); @@ -868,7 +870,7 @@ impl Pallet { /// randomness. Returns the new randomness. fn randomness_change_epoch(next_epoch_index: u64) -> BabeRandomness { let this_randomness = NextRandomness::::get(); - let segment_idx: u32 = SegmentIndex::::mutate(|s| sp_std::mem::replace(s, 0)); + let segment_idx: u32 = SegmentIndex::::mutate(|s| core::mem::replace(s, 0)); // overestimate to the segment being full. let rho_size = (segment_idx.saturating_add(1) * UNDER_CONSTRUCTION_SEGMENT_LENGTH) as usize; @@ -1055,7 +1057,7 @@ pub mod migrations { fn pallet_prefix() -> &'static str; } - struct __OldNextEpochConfig(sp_std::marker::PhantomData); + struct __OldNextEpochConfig(core::marker::PhantomData); impl frame_support::traits::StorageInstance for __OldNextEpochConfig { fn pallet_prefix() -> &'static str { T::pallet_prefix() diff --git a/substrate/frame/bags-list/Cargo.toml b/substrate/frame/bags-list/Cargo.toml index bf57bd2af53ce..549c4334b55db 100644 --- a/substrate/frame/bags-list/Cargo.toml +++ b/substrate/frame/bags-list/Cargo.toml @@ -25,7 +25,6 @@ scale-info = { features = [ # primitives sp-runtime = { workspace = true } -sp-std = { workspace = true } # FRAME frame-support = { workspace = true } @@ -66,7 +65,6 @@ std = [ "sp-core?/std", "sp-io?/std", "sp-runtime/std", - "sp-std/std", "sp-tracing?/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/bags-list/remote-tests/src/lib.rs b/substrate/frame/bags-list/remote-tests/src/lib.rs index 9f7c22d99dad1..1f0584fa07e5b 100644 --- a/substrate/frame/bags-list/remote-tests/src/lib.rs +++ b/substrate/frame/bags-list/remote-tests/src/lib.rs @@ -19,7 +19,6 @@ use frame_election_provider_support::ScoreProvider; use pallet_bags_list::Instance1; -use sp_std::prelude::*; /// A common log target to use. pub const LOG_TARGET: &str = "runtime::bags-list::remote-tests"; diff --git a/substrate/frame/bags-list/src/benchmarks.rs b/substrate/frame/bags-list/src/benchmarks.rs index 0c3955c0d7b79..55f4c24835ea6 100644 --- a/substrate/frame/bags-list/src/benchmarks.rs +++ b/substrate/frame/bags-list/src/benchmarks.rs @@ -19,6 +19,7 @@ use super::*; use crate::list::List; +use alloc::{vec, vec::Vec}; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, }; diff --git a/substrate/frame/bags-list/src/lib.rs b/substrate/frame/bags-list/src/lib.rs index 8e3d4cc1f012d..f6af1da5e7b78 100644 --- a/substrate/frame/bags-list/src/lib.rs +++ b/substrate/frame/bags-list/src/lib.rs @@ -122,11 +122,13 @@ #[doc = docify::embed!("src/tests.rs", examples_work)] pub mod example {} +extern crate alloc; + +use alloc::boxed::Box; use codec::FullCodec; use frame_election_provider_support::{ScoreProvider, SortedListProvider}; use frame_system::ensure_signed; use sp_runtime::traits::{AtLeast32BitUnsigned, Bounded, StaticLookup}; -use sp_std::prelude::*; #[cfg(any(test, feature = "try-runtime", feature = "fuzz"))] use sp_runtime::TryRuntimeError; @@ -238,7 +240,7 @@ pub mod pallet { + Eq + Ord + PartialOrd - + sp_std::fmt::Debug + + core::fmt::Debug + Copy + AtLeast32BitUnsigned + Bounded @@ -465,7 +467,7 @@ impl, I: 'static> SortedListProvider for Pallet let node = list::Node::::get(who).unwrap(); let current_bag_idx = thresholds .iter() - .chain(sp_std::iter::once(&T::Score::max_value())) + .chain(core::iter::once(&T::Score::max_value())) .position(|w| w == &node.bag_upper) .unwrap(); diff --git a/substrate/frame/bags-list/src/list/mod.rs b/substrate/frame/bags-list/src/list/mod.rs index e90530341a155..696b64d40e9b9 100644 --- a/substrate/frame/bags-list/src/list/mod.rs +++ b/substrate/frame/bags-list/src/list/mod.rs @@ -25,7 +25,12 @@ //! interface. use crate::Config; +use alloc::{ + boxed::Box, + collections::{btree_map::BTreeMap, btree_set::BTreeSet}, +}; use codec::{Decode, Encode, MaxEncodedLen}; +use core::{iter, marker::PhantomData}; use frame_election_provider_support::ScoreProvider; use frame_support::{ defensive, ensure, @@ -34,14 +39,15 @@ use frame_support::{ }; use scale_info::TypeInfo; use sp_runtime::traits::{Bounded, Zero}; -use sp_std::{ - boxed::Box, - collections::{btree_map::BTreeMap, btree_set::BTreeSet}, - iter, - marker::PhantomData, - prelude::*, -}; +#[cfg(any( + test, + feature = "try-runtime", + feature = "fuzz", + feature = "std", + feature = "runtime-benchmarks" +))] +use alloc::vec::Vec; #[cfg(any(test, feature = "try-runtime", feature = "fuzz"))] use sp_runtime::TryRuntimeError; @@ -274,7 +280,7 @@ impl, I: 'static> List { let start_node = Node::::get(start).ok_or(ListError::NodeNotFound)?; let start_node_upper = start_node.bag_upper; - let start_bag = sp_std::iter::successors(start_node.next(), |prev| prev.next()); + let start_bag = core::iter::successors(start_node.next(), |prev| prev.next()); let thresholds = T::BagThresholds::get(); let idx = thresholds.partition_point(|&threshold| start_node_upper > threshold); @@ -341,7 +347,7 @@ impl, I: 'static> List { if !Self::contains(id) { return Err(ListError::NodeNotFound) } - let _ = Self::remove_many(sp_std::iter::once(id)); + let _ = Self::remove_many(core::iter::once(id)); Ok(()) } @@ -591,7 +597,7 @@ impl, I: 'static> List { Box::new(iter) } else { // otherwise, insert it here. - Box::new(iter.chain(sp_std::iter::once(T::Score::max_value()))) + Box::new(iter.chain(core::iter::once(T::Score::max_value()))) }; iter.filter_map(|t| { @@ -673,7 +679,7 @@ impl, I: 'static> Bag { /// Iterate over the nodes in this bag. pub(crate) fn iter(&self) -> impl Iterator> { - sp_std::iter::successors(self.head(), |prev| prev.next()) + core::iter::successors(self.head(), |prev| prev.next()) } /// Insert a new id into this bag. @@ -804,7 +810,7 @@ impl, I: 'static> Bag { #[cfg(feature = "std")] #[allow(dead_code)] pub fn std_iter(&self) -> impl Iterator> { - sp_std::iter::successors(self.head(), |prev| prev.next()) + core::iter::successors(self.head(), |prev| prev.next()) } } diff --git a/substrate/frame/bags-list/src/migrations.rs b/substrate/frame/bags-list/src/migrations.rs index 7df63a6a44c54..bfc70fef370a5 100644 --- a/substrate/frame/bags-list/src/migrations.rs +++ b/substrate/frame/bags-list/src/migrations.rs @@ -28,10 +28,10 @@ use frame_support::ensure; use sp_runtime::TryRuntimeError; #[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; +use alloc::vec::Vec; /// A struct that does not migration, but only checks that the counter prefix exists and is correct. -pub struct CheckCounterPrefix, I: 'static>(sp_std::marker::PhantomData<(T, I)>); +pub struct CheckCounterPrefix, I: 'static>(core::marker::PhantomData<(T, I)>); impl, I: 'static> OnRuntimeUpgrade for CheckCounterPrefix { fn on_runtime_upgrade() -> frame_support::weights::Weight { frame_support::weights::Weight::zero() @@ -88,7 +88,7 @@ mod old { } /// A struct that migrates all bags lists to contain a score value. -pub struct AddScore, I: 'static = ()>(sp_std::marker::PhantomData<(T, I)>); +pub struct AddScore, I: 'static = ()>(core::marker::PhantomData<(T, I)>); impl, I: 'static> OnRuntimeUpgrade for AddScore { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { diff --git a/substrate/frame/balances/Cargo.toml b/substrate/frame/balances/Cargo.toml index 5fa8fa84bf59e..85734dce9e9b2 100644 --- a/substrate/frame/balances/Cargo.toml +++ b/substrate/frame/balances/Cargo.toml @@ -23,7 +23,6 @@ frame-benchmarking = { optional = true, workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } docify = { workspace = true } [dev-dependencies] @@ -46,7 +45,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] # Enable support for setting the existential deposit to zero. insecure_zero_ed = [] diff --git a/substrate/frame/balances/src/impl_currency.rs b/substrate/frame/balances/src/impl_currency.rs index d5fe9934e239e..454aead1773f2 100644 --- a/substrate/frame/balances/src/impl_currency.rs +++ b/substrate/frame/balances/src/impl_currency.rs @@ -39,8 +39,8 @@ pub use imbalances::{NegativeImbalance, PositiveImbalance}; // of the inner member. mod imbalances { use super::{result, Config, Imbalance, RuntimeDebug, Saturating, TryDrop, Zero}; + use core::mem; use frame_support::traits::SameOrOther; - use sp_std::mem; /// Opaque, move-only struct with private fields that serves as a token denoting that /// funds have been created without any equal and opposite accounting. diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index d01884293c090..0aaf618b303f4 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -150,7 +150,11 @@ mod tests; mod types; pub mod weights; +extern crate alloc; + +use alloc::vec::Vec; use codec::{Codec, MaxEncodedLen}; +use core::{cmp, fmt::Debug, mem, result}; use frame_support::{ ensure, pallet_prelude::DispatchResult, @@ -176,7 +180,6 @@ use sp_runtime::{ }, ArithmeticError, DispatchError, FixedPointOperand, Perbill, RuntimeDebug, TokenError, }; -use sp_std::{cmp, fmt::Debug, mem, prelude::*, result}; pub use types::{ AccountData, AdjustmentDirection, BalanceLock, DustCleaner, ExtraFlags, Reasons, ReserveData, }; @@ -525,7 +528,7 @@ pub mod pallet { .iter() .map(|(x, _)| x) .cloned() - .collect::>(); + .collect::>(); assert!( endowed_accounts.len() == self.balances.len(), @@ -856,13 +859,13 @@ pub mod pallet { } /// Get the free balance of an account. - pub fn free_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { + pub fn free_balance(who: impl core::borrow::Borrow) -> T::Balance { Self::account(who.borrow()).free } /// Get the balance of an account that can be used for transfers, reservations, or any other /// non-locking, non-transaction-fee activity. Will be at most `free_balance`. - pub fn usable_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { + pub fn usable_balance(who: impl core::borrow::Borrow) -> T::Balance { >::reducible_balance(who.borrow(), Expendable, Polite) } @@ -870,14 +873,12 @@ pub mod pallet { /// or any other kind of fees, though). Will be at most `free_balance`. /// /// This requires that the account stays alive. - pub fn usable_balance_for_fees( - who: impl sp_std::borrow::Borrow, - ) -> T::Balance { + pub fn usable_balance_for_fees(who: impl core::borrow::Borrow) -> T::Balance { >::reducible_balance(who.borrow(), Protect, Polite) } /// Get the reserved balance of an account. - pub fn reserved_balance(who: impl sp_std::borrow::Borrow) -> T::Balance { + pub fn reserved_balance(who: impl core::borrow::Borrow) -> T::Balance { Self::account(who.borrow()).reserved } diff --git a/substrate/frame/beefy-mmr/Cargo.toml b/substrate/frame/beefy-mmr/Cargo.toml index b46998a857426..11a7b281e87d9 100644 --- a/substrate/frame/beefy-mmr/Cargo.toml +++ b/substrate/frame/beefy-mmr/Cargo.toml @@ -27,7 +27,6 @@ sp-consensus-beefy = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-api = { workspace = true } sp-state-machine = { workspace = true } @@ -56,7 +55,6 @@ std = [ "sp-runtime/std", "sp-staking/std", "sp-state-machine/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/beefy-mmr/src/lib.rs b/substrate/frame/beefy-mmr/src/lib.rs index 18ebc9d8f38a7..ec341cad2084a 100644 --- a/substrate/frame/beefy-mmr/src/lib.rs +++ b/substrate/frame/beefy-mmr/src/lib.rs @@ -33,9 +33,11 @@ //! //! and thanks to versioning can be easily updated in the future. +extern crate alloc; + use sp_runtime::traits::{Convert, Header, Member}; -use sp_std::prelude::*; +use alloc::vec::Vec; use codec::Decode; use pallet_mmr::{primitives::AncestryProof, LeafDataProvider, ParentNumberAndHash}; use sp_consensus_beefy::{ @@ -56,7 +58,7 @@ mod mock; mod tests; /// A BEEFY consensus digest item with MMR root hash. -pub struct DepositBeefyDigest(sp_std::marker::PhantomData); +pub struct DepositBeefyDigest(core::marker::PhantomData); impl pallet_mmr::primitives::OnNewRoot for DepositBeefyDigest where diff --git a/substrate/frame/beefy/Cargo.toml b/substrate/frame/beefy/Cargo.toml index 8ce3a05985be7..089b817e226f3 100644 --- a/substrate/frame/beefy/Cargo.toml +++ b/substrate/frame/beefy/Cargo.toml @@ -24,7 +24,6 @@ sp-consensus-beefy = { features = ["serde"], workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-session = { workspace = true } sp-staking = { features = ["serde"], workspace = true } -sp-std = { workspace = true } [dev-dependencies] frame-election-provider-support = { workspace = true, default-features = true } @@ -61,7 +60,6 @@ std = [ "sp-session/std", "sp-staking/std", "sp-state-machine/std", - "sp-std/std", ] try-runtime = [ "frame-election-provider-support/try-runtime", diff --git a/substrate/frame/beefy/src/equivocation.rs b/substrate/frame/beefy/src/equivocation.rs index a1526e7811111..15345e6ae1997 100644 --- a/substrate/frame/beefy/src/equivocation.rs +++ b/substrate/frame/beefy/src/equivocation.rs @@ -34,6 +34,7 @@ //! that the `ValidateUnsigned` for the BEEFY pallet is used in the runtime //! definition. +use alloc::{vec, vec::Vec}; use codec::{self as codec, Decode, Encode}; use frame_support::traits::{Get, KeyOwnerProofSystem}; use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor}; @@ -54,7 +55,6 @@ use sp_staking::{ offence::{Kind, Offence, OffenceReportSystem, ReportOffence}, SessionIndex, }; -use sp_std::prelude::*; use super::{Call, Config, Error, Pallet, LOG_TARGET}; @@ -122,7 +122,7 @@ where /// - On-chain validity checks and processing are mostly delegated to the user provided generic /// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits. /// - Offence reporter for unsigned transactions is fetched via the authorship pallet. -pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); +pub struct EquivocationReportSystem(core::marker::PhantomData<(T, R, P, L)>); /// Equivocation evidence convenience alias. pub enum EquivocationEvidenceFor { diff --git a/substrate/frame/beefy/src/lib.rs b/substrate/frame/beefy/src/lib.rs index a49f5d28f455a..fd9a0027c6fc6 100644 --- a/substrate/frame/beefy/src/lib.rs +++ b/substrate/frame/beefy/src/lib.rs @@ -17,6 +17,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{boxed::Box, vec::Vec}; use codec::{Encode, MaxEncodedLen}; use frame_support::{ @@ -38,7 +41,6 @@ use sp_runtime::{ }; use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::{offence::OffenceReportSystem, SessionIndex}; -use sp_std::prelude::*; use sp_consensus_beefy::{ AncestryHelper, AuthorityIndex, BeefyAuthorityId, ConsensusLog, DoubleVotingProof, diff --git a/substrate/frame/benchmarking/Cargo.toml b/substrate/frame/benchmarking/Cargo.toml index a2c15951a5966..61bc706963bb6 100644 --- a/substrate/frame/benchmarking/Cargo.toml +++ b/substrate/frame/benchmarking/Cargo.toml @@ -31,7 +31,6 @@ sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } sp-runtime-interface = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } static_assertions = { workspace = true, default-features = true } @@ -58,7 +57,6 @@ std = [ "sp-keystore/std", "sp-runtime-interface/std", "sp-runtime/std", - "sp-std/std", "sp-storage/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/benchmarking/pov/Cargo.toml b/substrate/frame/benchmarking/pov/Cargo.toml index 4341f011fcbf9..6a449fb597d56 100644 --- a/substrate/frame/benchmarking/pov/Cargo.toml +++ b/substrate/frame/benchmarking/pov/Cargo.toml @@ -22,7 +22,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -34,7 +33,6 @@ std = [ "scale-info/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/benchmarking/pov/src/benchmarking.rs b/substrate/frame/benchmarking/pov/src/benchmarking.rs index 7e6aa8e6bf605..bf3d406d0b2b0 100644 --- a/substrate/frame/benchmarking/pov/src/benchmarking.rs +++ b/substrate/frame/benchmarking/pov/src/benchmarking.rs @@ -247,7 +247,7 @@ mod benchmarks { #[benchmark(pov_mode = Measured)] fn measured_storage_value_read_linear_size(l: Linear<0, { 1 << 22 }>) { - let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + let v: sp_runtime::BoundedVec = alloc::vec![0u8; l as usize].try_into().unwrap(); LargeValue::::put(&v); #[block] { @@ -257,7 +257,7 @@ mod benchmarks { #[benchmark(pov_mode = MaxEncodedLen)] fn mel_storage_value_read_linear_size(l: Linear<0, { 1 << 22 }>) { - let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + let v: sp_runtime::BoundedVec = alloc::vec![0u8; l as usize].try_into().unwrap(); LargeValue::::put(&v); #[block] { @@ -267,7 +267,7 @@ mod benchmarks { #[benchmark(pov_mode = Measured)] fn measured_storage_double_value_read_linear_size(l: Linear<0, { 1 << 22 }>) { - let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + let v: sp_runtime::BoundedVec = alloc::vec![0u8; l as usize].try_into().unwrap(); LargeValue::::put(&v); LargeValue2::::put(&v); #[block] @@ -279,7 +279,7 @@ mod benchmarks { #[benchmark(pov_mode = MaxEncodedLen)] fn mel_storage_double_value_read_linear_size(l: Linear<0, { 1 << 22 }>) { - let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + let v: sp_runtime::BoundedVec = alloc::vec![0u8; l as usize].try_into().unwrap(); LargeValue::::put(&v); LargeValue2::::put(&v); #[block] @@ -293,7 +293,7 @@ mod benchmarks { Pov::LargeValue2: Measured })] fn mel_mixed_storage_double_value_read_linear_size(l: Linear<0, { 1 << 22 }>) { - let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + let v: sp_runtime::BoundedVec = alloc::vec![0u8; l as usize].try_into().unwrap(); LargeValue::::put(&v); LargeValue2::::put(&v); #[block] @@ -307,7 +307,7 @@ mod benchmarks { Pov::LargeValue2: MaxEncodedLen })] fn measured_mixed_storage_double_value_read_linear_size(l: Linear<0, { 1 << 22 }>) { - let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + let v: sp_runtime::BoundedVec = alloc::vec![0u8; l as usize].try_into().unwrap(); LargeValue::::put(&v); LargeValue2::::put(&v); #[block] @@ -319,8 +319,8 @@ mod benchmarks { #[benchmark(pov_mode = Measured)] fn storage_map_unbounded_both_measured_read(i: Linear<0, 1000>) { - UnboundedMap::::insert(i, sp_std::vec![0; i as usize]); - UnboundedMap2::::insert(i, sp_std::vec![0; i as usize]); + UnboundedMap::::insert(i, alloc::vec![0; i as usize]); + UnboundedMap2::::insert(i, alloc::vec![0; i as usize]); #[block] { assert!(UnboundedMap::::get(i).is_some()); @@ -333,7 +333,7 @@ mod benchmarks { })] fn storage_map_partial_unbounded_read(i: Linear<0, 1000>) { Map1M::::insert(i, 0); - UnboundedMap::::insert(i, sp_std::vec![0; i as usize]); + UnboundedMap::::insert(i, alloc::vec![0; i as usize]); #[block] { assert!(Map1M::::get(i).is_some()); @@ -346,7 +346,7 @@ mod benchmarks { })] fn storage_map_partial_unbounded_ignored_read(i: Linear<0, 1000>) { Map1M::::insert(i, 0); - UnboundedMap::::insert(i, sp_std::vec![0; i as usize]); + UnboundedMap::::insert(i, alloc::vec![0; i as usize]); #[block] { assert!(Map1M::::get(i).is_some()); @@ -379,7 +379,7 @@ mod benchmarks { #[benchmark] fn storage_iteration() { for i in 0..65000 { - UnboundedMapTwox::::insert(i, sp_std::vec![0; 64]); + UnboundedMapTwox::::insert(i, alloc::vec![0; 64]); } #[block] { diff --git a/substrate/frame/benchmarking/pov/src/lib.rs b/substrate/frame/benchmarking/pov/src/lib.rs index eb02ccc983c09..4cdbaec2305c1 100644 --- a/substrate/frame/benchmarking/pov/src/lib.rs +++ b/substrate/frame/benchmarking/pov/src/lib.rs @@ -23,13 +23,15 @@ mod benchmarking; mod tests; mod weights; +extern crate alloc; + pub use pallet::*; #[frame_support::pallet] pub mod pallet { + use alloc::vec::Vec; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; - use sp_std::prelude::*; #[pallet::pallet] pub struct Pallet(_); diff --git a/substrate/frame/benchmarking/src/baseline.rs b/substrate/frame/benchmarking/src/baseline.rs index e76d5aed7b8d3..711d2123ca831 100644 --- a/substrate/frame/benchmarking/src/baseline.rs +++ b/substrate/frame/benchmarking/src/baseline.rs @@ -21,12 +21,12 @@ #![cfg(feature = "runtime-benchmarks")] use crate::benchmarks; +use alloc::{vec, vec::Vec}; use frame_system::Pallet as System; use sp_runtime::{ traits::{AppVerify, Hash}, RuntimeAppPublic, }; -use sp_std::{vec, vec::Vec}; mod crypto { use sp_application_crypto::{app_crypto, sr25519, KeyTypeId}; diff --git a/substrate/frame/benchmarking/src/lib.rs b/substrate/frame/benchmarking/src/lib.rs index d4ee0abbecce5..625da2a24bd0a 100644 --- a/substrate/frame/benchmarking/src/lib.rs +++ b/substrate/frame/benchmarking/src/lib.rs @@ -19,6 +19,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(feature = "std")] mod analysis; #[cfg(test)] @@ -35,6 +37,7 @@ pub mod v1; /// The exports are not stable and should not be relied on. #[doc(hidden)] pub mod __private { + pub use alloc::{boxed::Box, str, vec, vec::Vec}; pub use codec; pub use frame_support::{storage, traits}; pub use log; @@ -42,7 +45,6 @@ pub mod __private { pub use sp_core::defer; pub use sp_io::storage::root as storage_root; pub use sp_runtime::{traits::Zero, StateVersion}; - pub use sp_std::{self, boxed::Box, str, vec, vec::Vec}; pub use sp_storage::{well_known_keys, TrackedStorageKey}; } diff --git a/substrate/frame/benchmarking/src/tests.rs b/substrate/frame/benchmarking/src/tests.rs index bcca5fe7c2f2a..09011eadb03ae 100644 --- a/substrate/frame/benchmarking/src/tests.rs +++ b/substrate/frame/benchmarking/src/tests.rs @@ -25,7 +25,6 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -use sp_std::prelude::*; use std::cell::RefCell; #[frame_support::pallet(dev_mode)] @@ -130,7 +129,6 @@ mod benchmarks { use frame_support::{assert_err, assert_ok, ensure, traits::Get}; use frame_system::RawOrigin; use rusty_fork::rusty_fork_test; - use sp_std::prelude::*; // Additional used internally by the benchmark macro. use super::pallet_test::{Call, Config, Pallet}; diff --git a/substrate/frame/benchmarking/src/tests_instance.rs b/substrate/frame/benchmarking/src/tests_instance.rs index d6e1cf99ef73f..ecffbd1a018fa 100644 --- a/substrate/frame/benchmarking/src/tests_instance.rs +++ b/substrate/frame/benchmarking/src/tests_instance.rs @@ -25,7 +25,6 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -use sp_std::prelude::*; #[frame_support::pallet] mod pallet_test { @@ -131,7 +130,6 @@ mod benchmarks { use crate::account; use frame_support::ensure; use frame_system::RawOrigin; - use sp_std::prelude::*; // Additional used internally by the benchmark macro. use super::pallet_test::{Call, Config, Pallet}; diff --git a/substrate/frame/benchmarking/src/utils.rs b/substrate/frame/benchmarking/src/utils.rs index bfa25f63ef33e..ca362f7aa7efe 100644 --- a/substrate/frame/benchmarking/src/utils.rs +++ b/substrate/frame/benchmarking/src/utils.rs @@ -16,6 +16,7 @@ // limitations under the License. //! Interfaces, types and utils for benchmarking a FRAME runtime. +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::{dispatch::DispatchErrorWithPostInfo, pallet_prelude::*, traits::StorageInfo}; use scale_info::TypeInfo; @@ -23,7 +24,6 @@ use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_io::hashing::blake2_256; use sp_runtime::{traits::TrailingZeroInput, DispatchError}; -use sp_std::vec::Vec; use sp_storage::TrackedStorageKey; /// An alphabet of possible parameters to use for benchmarking. diff --git a/substrate/frame/benchmarking/src/v1.rs b/substrate/frame/benchmarking/src/v1.rs index 07778646237ed..d687f9fdfa104 100644 --- a/substrate/frame/benchmarking/src/v1.rs +++ b/substrate/frame/benchmarking/src/v1.rs @@ -1741,9 +1741,9 @@ pub fn show_benchmark_debug_info( * Components: {:?}\n\ * Verify: {:?}\n\ * Error message: {}", - sp_std::str::from_utf8(instance_string) + alloc::str::from_utf8(instance_string) .expect("it's all just strings ran through the wasm interface. qed"), - sp_std::str::from_utf8(benchmark) + alloc::str::from_utf8(benchmark) .expect("it's all just strings ran through the wasm interface. qed"), components, verify, diff --git a/substrate/frame/bounties/Cargo.toml b/substrate/frame/bounties/Cargo.toml index 4b242a1a577ce..cb9fa1f964b06 100644 --- a/substrate/frame/bounties/Cargo.toml +++ b/substrate/frame/bounties/Cargo.toml @@ -28,7 +28,6 @@ pallet-treasury = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -47,7 +46,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/bounties/src/benchmarking.rs b/substrate/frame/bounties/src/benchmarking.rs index f53d95d919d40..de93ba5c4ce7a 100644 --- a/substrate/frame/bounties/src/benchmarking.rs +++ b/substrate/frame/bounties/src/benchmarking.rs @@ -21,6 +21,7 @@ use super::*; +use alloc::{vec, vec::Vec}; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, }; diff --git a/substrate/frame/bounties/src/lib.rs b/substrate/frame/bounties/src/lib.rs index c04bec2d12aea..7b89a6e3e76f5 100644 --- a/substrate/frame/bounties/src/lib.rs +++ b/substrate/frame/bounties/src/lib.rs @@ -87,7 +87,9 @@ pub mod migrations; mod tests; pub mod weights; -use sp_std::prelude::*; +extern crate alloc; + +use alloc::vec::Vec; use frame_support::traits::{ Currency, ExistenceRequirement::AllowDeath, Get, Imbalance, OnUnbalanced, ReservableCurrency, diff --git a/substrate/frame/broker/Cargo.toml b/substrate/frame/broker/Cargo.toml index 77c4883e4a433..7593a4e8da14a 100644 --- a/substrate/frame/broker/Cargo.toml +++ b/substrate/frame/broker/Cargo.toml @@ -20,7 +20,6 @@ codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } bitvec = { workspace = true } sp-api = { workspace = true } -sp-std = { workspace = true } sp-arithmetic = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } @@ -49,7 +48,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/broker/src/benchmarking.rs b/substrate/frame/broker/src/benchmarking.rs index 3c9ea4cdba4e7..33df56c95f65d 100644 --- a/substrate/frame/broker/src/benchmarking.rs +++ b/substrate/frame/broker/src/benchmarking.rs @@ -20,6 +20,7 @@ use super::*; use crate::{CoreAssignment::Task, Pallet as Broker}; +use alloc::{vec, vec::Vec}; use frame_benchmarking::v2::*; use frame_support::{ storage::bounded_vec::BoundedVec, @@ -32,7 +33,6 @@ use frame_system::{Pallet as System, RawOrigin}; use sp_arithmetic::{traits::Zero, Perbill}; use sp_core::Get; use sp_runtime::{traits::BlockNumberProvider, Saturating}; -use sp_std::{vec, vec::Vec}; const SEED: u32 = 0; const MAX_CORE_COUNT: u16 = 1_000; diff --git a/substrate/frame/broker/src/coretime_interface.rs b/substrate/frame/broker/src/coretime_interface.rs index f92f8b22091ac..9c18e2c4ff0b3 100644 --- a/substrate/frame/broker/src/coretime_interface.rs +++ b/substrate/frame/broker/src/coretime_interface.rs @@ -17,13 +17,14 @@ #![deny(missing_docs)] +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; +use core::fmt::Debug; use frame_support::Parameter; use scale_info::TypeInfo; use sp_arithmetic::traits::AtLeast32BitUnsigned; use sp_core::RuntimeDebug; use sp_runtime::traits::BlockNumberProvider; -use sp_std::{fmt::Debug, vec::Vec}; use crate::Timeslice; diff --git a/substrate/frame/broker/src/lib.rs b/substrate/frame/broker/src/lib.rs index 4cb380bae91d8..45c33c1bfa615 100644 --- a/substrate/frame/broker/src/lib.rs +++ b/substrate/frame/broker/src/lib.rs @@ -47,12 +47,15 @@ pub use core_mask::*; pub use coretime_interface::*; pub use types::*; +extern crate alloc; + /// The log target for this pallet. const LOG_TARGET: &str = "runtime::broker"; #[frame_support::pallet] pub mod pallet { use super::*; + use alloc::vec::Vec; use frame_support::{ pallet_prelude::{DispatchResult, DispatchResultWithPostInfo, *}, traits::{ @@ -63,7 +66,6 @@ pub mod pallet { }; use frame_system::pallet_prelude::*; use sp_runtime::traits::{Convert, ConvertBack}; - use sp_std::vec::Vec; const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); @@ -496,7 +498,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] diff --git a/substrate/frame/broker/src/migration.rs b/substrate/frame/broker/src/migration.rs index 917f44a134cc1..c2a243d6f0e8e 100644 --- a/substrate/frame/broker/src/migration.rs +++ b/substrate/frame/broker/src/migration.rs @@ -23,9 +23,9 @@ use frame_support::traits::{Get, UncheckedOnRuntimeUpgrade}; use sp_runtime::Saturating; #[cfg(feature = "try-runtime")] -use frame_support::ensure; +use alloc::vec::Vec; #[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; +use frame_support::ensure; mod v1 { use super::*; diff --git a/substrate/frame/broker/src/mock.rs b/substrate/frame/broker/src/mock.rs index f29651abff7b8..6b1d2bbf7015d 100644 --- a/substrate/frame/broker/src/mock.rs +++ b/substrate/frame/broker/src/mock.rs @@ -18,6 +18,7 @@ #![cfg(test)] use crate::{test_fungibles::TestFungibles, *}; +use alloc::collections::btree_map::BTreeMap; use frame_support::{ assert_ok, derive_impl, ensure, ord_parameter_types, parameter_types, traits::{ @@ -34,7 +35,6 @@ use sp_runtime::{ traits::{BlockNumberProvider, Identity}, BuildStorage, Saturating, }; -use sp_std::collections::btree_map::BTreeMap; type Block = frame_system::mocking::MockBlock; diff --git a/substrate/frame/broker/src/nonfungible_impl.rs b/substrate/frame/broker/src/nonfungible_impl.rs index 80dcc175df539..e272ecbe0081b 100644 --- a/substrate/frame/broker/src/nonfungible_impl.rs +++ b/substrate/frame/broker/src/nonfungible_impl.rs @@ -16,11 +16,11 @@ // limitations under the License. use super::*; +use alloc::vec::Vec; use frame_support::{ pallet_prelude::{DispatchResult, *}, traits::nonfungible::{Inspect, Mutate, Transfer}, }; -use sp_std::vec::Vec; impl Inspect for Pallet { type ItemId = u128; diff --git a/substrate/frame/broker/src/test_fungibles.rs b/substrate/frame/broker/src/test_fungibles.rs index d18bff1495331..b0a06fc1a326d 100644 --- a/substrate/frame/broker/src/test_fungibles.rs +++ b/substrate/frame/broker/src/test_fungibles.rs @@ -15,6 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use alloc::collections::btree_map::BTreeMap; use codec::{Decode, Encode}; use frame_support::{ parameter_types, @@ -29,7 +30,6 @@ use scale_info::TypeInfo; use sp_arithmetic::traits::Zero; use sp_core::{Get, TypedGet}; use sp_runtime::{DispatchError, DispatchResult}; -use sp_std::collections::btree_map::BTreeMap; parameter_types! { static TestAssetOf: BTreeMap<(u32, Vec), Vec> = Default::default(); diff --git a/substrate/frame/broker/src/tick_impls.rs b/substrate/frame/broker/src/tick_impls.rs index 3292faa4eb7e3..71a1286d73915 100644 --- a/substrate/frame/broker/src/tick_impls.rs +++ b/substrate/frame/broker/src/tick_impls.rs @@ -16,10 +16,10 @@ // limitations under the License. use super::*; +use alloc::{vec, vec::Vec}; use frame_support::{pallet_prelude::*, traits::defensive_prelude::*, weights::WeightMeter}; use sp_arithmetic::traits::{One, SaturatedConversion, Saturating, Zero}; use sp_runtime::traits::ConvertBack; -use sp_std::{vec, vec::Vec}; use CompletionStatus::Complete; impl Pallet { diff --git a/substrate/frame/child-bounties/Cargo.toml b/substrate/frame/child-bounties/Cargo.toml index d0072e3a47613..9c979b41462c4 100644 --- a/substrate/frame/child-bounties/Cargo.toml +++ b/substrate/frame/child-bounties/Cargo.toml @@ -29,7 +29,6 @@ pallet-treasury = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -49,7 +48,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking", diff --git a/substrate/frame/child-bounties/src/benchmarking.rs b/substrate/frame/child-bounties/src/benchmarking.rs index 947cfcfaa96a2..b1f6370f33405 100644 --- a/substrate/frame/child-bounties/src/benchmarking.rs +++ b/substrate/frame/child-bounties/src/benchmarking.rs @@ -21,6 +21,8 @@ use super::*; +use alloc::{vec, vec::Vec}; + use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; diff --git a/substrate/frame/child-bounties/src/lib.rs b/substrate/frame/child-bounties/src/lib.rs index 04a1f9799cb86..911fd4c4c49f7 100644 --- a/substrate/frame/child-bounties/src/lib.rs +++ b/substrate/frame/child-bounties/src/lib.rs @@ -56,7 +56,9 @@ mod benchmarking; mod tests; pub mod weights; -use sp_std::prelude::*; +extern crate alloc; + +use alloc::vec::Vec; use frame_support::traits::{ Currency, diff --git a/substrate/frame/collective/Cargo.toml b/substrate/frame/collective/Cargo.toml index 6fc4bb7782987..7d9a4c41c8129 100644 --- a/substrate/frame/collective/Cargo.toml +++ b/substrate/frame/collective/Cargo.toml @@ -25,7 +25,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -39,7 +38,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/collective/src/lib.rs b/substrate/frame/collective/src/lib.rs index d0009d02f68c2..3544a8cddb45c 100644 --- a/substrate/frame/collective/src/lib.rs +++ b/substrate/frame/collective/src/lib.rs @@ -41,14 +41,17 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; +use core::{marker::PhantomData, result}; use scale_info::TypeInfo; use sp_io::storage; use sp_runtime::{ traits::{Dispatchable, Hash}, DispatchError, RuntimeDebug, }; -use sp_std::{marker::PhantomData, prelude::*, result}; use frame_support::{ dispatch::{ @@ -239,7 +242,7 @@ pub mod pallet { #[pallet::genesis_build] impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { - use sp_std::collections::btree_set::BTreeSet; + use alloc::collections::btree_set::BTreeSet; let members_set: BTreeSet<_> = self.members.iter().collect(); assert_eq!( members_set.len(), diff --git a/substrate/frame/contracts/mock-network/Cargo.toml b/substrate/frame/contracts/mock-network/Cargo.toml index 7df5d304c34af..85d98206ea57b 100644 --- a/substrate/frame/contracts/mock-network/Cargo.toml +++ b/substrate/frame/contracts/mock-network/Cargo.toml @@ -36,7 +36,6 @@ sp-core = { workspace = true } sp-io = { workspace = true } sp-keystore = { workspace = true, default-features = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-tracing = { workspace = true, default-features = true } xcm = { workspace = true } xcm-builder = { workspace = true, default-features = true } @@ -67,7 +66,6 @@ std = [ "sp-io/std", "sp-keystore/std", "sp-runtime/std", - "sp-std/std", "xcm-executor/std", "xcm/std", ] diff --git a/substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs b/substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs index bfdf6dd97eaf1..6e922c16c2982 100644 --- a/substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs +++ b/substrate/frame/contracts/mock-network/src/mocks/msg_queue.rs @@ -25,7 +25,6 @@ use polkadot_parachain_primitives::primitives::{ use polkadot_primitives::BlockNumber as RelayBlockNumber; use sp_runtime::traits::{Get, Hash}; -use sp_std::prelude::*; use xcm::{latest::prelude::*, VersionedXcm}; #[frame_support::pallet] diff --git a/substrate/frame/contracts/mock-network/src/parachain.rs b/substrate/frame/contracts/mock-network/src/parachain.rs index f35846ba32c31..3579b46ea6e9c 100644 --- a/substrate/frame/contracts/mock-network/src/parachain.rs +++ b/substrate/frame/contracts/mock-network/src/parachain.rs @@ -35,7 +35,6 @@ use pallet_xcm::XcmPassthrough; use sp_core::{ConstU32, ConstU64, H256}; use sp_runtime::traits::{Get, IdentityLookup, MaybeEquivalence}; -use sp_std::prelude::*; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, diff --git a/substrate/frame/contracts/proc-macro/src/lib.rs b/substrate/frame/contracts/proc-macro/src/lib.rs index f91f8660cd315..84ea7de00a2f1 100644 --- a/substrate/frame/contracts/proc-macro/src/lib.rs +++ b/substrate/frame/contracts/proc-macro/src/lib.rs @@ -649,7 +649,7 @@ fn expand_functions(def: &EnvDef, expand_mode: ExpandMode) -> TokenStream2 { quote! { let result = #body; if ::log::log_enabled!(target: "runtime::contracts::strace", ::log::Level::Trace) { - use sp_std::fmt::Write; + use core::fmt::Write; let mut w = sp_std::Writer::default(); let _ = core::write!(&mut w, #trace_fmt_str, #( #trace_fmt_args, )* result); let msg = core::str::from_utf8(&w.inner()).unwrap_or_default(); diff --git a/substrate/frame/contracts/src/benchmarking/call_builder.rs b/substrate/frame/contracts/src/benchmarking/call_builder.rs index 5d73d825fca9a..d87eaba734376 100644 --- a/substrate/frame/contracts/src/benchmarking/call_builder.rs +++ b/substrate/frame/contracts/src/benchmarking/call_builder.rs @@ -23,11 +23,11 @@ use crate::{ BalanceOf, Config, DebugBufferVec, Determinism, ExecReturnValue, GasMeter, Origin, Schedule, TypeInfo, WasmBlob, Weight, }; +use alloc::{vec, vec::Vec}; use codec::{Encode, HasCompact}; use core::fmt::Debug; use frame_benchmarking::benchmarking; use sp_core::Get; -use sp_std::prelude::*; type StackExt<'a, T> = Stack<'a, T, WasmBlob>; diff --git a/substrate/frame/contracts/src/benchmarking/code.rs b/substrate/frame/contracts/src/benchmarking/code.rs index 65bcf30683c05..1473022b55378 100644 --- a/substrate/frame/contracts/src/benchmarking/code.rs +++ b/substrate/frame/contracts/src/benchmarking/code.rs @@ -25,9 +25,9 @@ //! compiles it down into a `WasmModule` that can be used as a contract's code. use crate::Config; +use alloc::{borrow::ToOwned, vec, vec::Vec}; use frame_support::traits::Get; use sp_runtime::{traits::Hash, Saturating}; -use sp_std::{borrow::ToOwned, prelude::*}; use wasm_instrument::parity_wasm::{ builder, elements::{ @@ -338,7 +338,7 @@ pub mod body { .cycle() .take(instructions.len() * usize::try_from(repetitions).unwrap()) .cloned() - .chain(sp_std::iter::once(Instruction::End)) + .chain(core::iter::once(Instruction::End)) .collect(), ); FuncBody::new(locals.to_vec(), instructions) diff --git a/substrate/frame/contracts/src/benchmarking/mod.rs b/substrate/frame/contracts/src/benchmarking/mod.rs index 80c7e863d2994..612f929e8b196 100644 --- a/substrate/frame/contracts/src/benchmarking/mod.rs +++ b/substrate/frame/contracts/src/benchmarking/mod.rs @@ -34,6 +34,7 @@ use crate::{ wasm::BenchEnv, Pallet as Contracts, *, }; +use alloc::{vec, vec::Vec}; use codec::{Encode, MaxEncodedLen}; use frame_benchmarking::v2::*; use frame_support::{ @@ -46,7 +47,6 @@ use frame_system::RawOrigin; use pallet_balances; use pallet_contracts_uapi::{CallFlags, ReturnErrorCode}; use sp_runtime::traits::{Bounded, Hash}; -use sp_std::prelude::*; use wasm_instrument::parity_wasm::elements::{Instruction, Local, ValueType}; /// How many runs we do per API benchmark. @@ -186,7 +186,7 @@ fn caller_funding() -> BalanceOf { #[benchmarks( where - as codec::HasCompact>::Type: Clone + Eq + PartialEq + sp_std::fmt::Debug + scale_info::TypeInfo + codec::Encode, + as codec::HasCompact>::Type: Clone + Eq + PartialEq + core::fmt::Debug + scale_info::TypeInfo + codec::Encode, T: Config + pallet_balances::Config, BalanceOf: From< as Currency>::Balance>, as Currency>::Balance: From>, diff --git a/substrate/frame/contracts/src/chain_extension.rs b/substrate/frame/contracts/src/chain_extension.rs index f3a67fcb09a08..b9bb451fd734a 100644 --- a/substrate/frame/contracts/src/chain_extension.rs +++ b/substrate/frame/contracts/src/chain_extension.rs @@ -74,17 +74,18 @@ use crate::{ wasm::{Runtime, RuntimeCosts}, Error, }; +use alloc::vec::Vec; use codec::{Decode, MaxEncodedLen}; +use core::marker::PhantomData; use frame_support::weights::Weight; use sp_runtime::DispatchError; -use sp_std::{marker::PhantomData, vec::Vec}; pub use crate::{exec::Ext, gas::ChargedAmount, storage::meter::Diff, Config}; pub use frame_system::Config as SysConfig; pub use pallet_contracts_uapi::ReturnFlags; /// Result that returns a [`DispatchError`] on error. -pub type Result = sp_std::result::Result; +pub type Result = core::result::Result; /// A trait used to extend the set of contract callable functions. /// diff --git a/substrate/frame/contracts/src/exec.rs b/substrate/frame/contracts/src/exec.rs index 84a3f7dc2a140..0cc4844166f35 100644 --- a/substrate/frame/contracts/src/exec.rs +++ b/substrate/frame/contracts/src/exec.rs @@ -24,6 +24,8 @@ use crate::{ DebugBufferVec, Determinism, Error, Event, Nonce, Origin, Pallet as Contracts, Schedule, LOG_TARGET, }; +use alloc::vec::Vec; +use core::{fmt::Debug, marker::PhantomData, mem}; use frame_support::{ crypto::ecdsa::ECDSAExt, dispatch::{DispatchResult, DispatchResultWithPostInfo}, @@ -49,7 +51,6 @@ use sp_runtime::{ traits::{Convert, Dispatchable, Zero}, DispatchError, }; -use sp_std::{fmt::Debug, marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; pub type MomentOf = <::Time as Time>::Moment; @@ -1185,12 +1186,12 @@ where /// /// The iterator starts with the top frame and ends with the root frame. fn frames(&self) -> impl Iterator> { - sp_std::iter::once(&self.first_frame).chain(&self.frames).rev() + core::iter::once(&self.first_frame).chain(&self.frames).rev() } /// Same as `frames` but with a mutable reference as iterator item. fn frames_mut(&mut self) -> impl Iterator> { - sp_std::iter::once(&mut self.first_frame).chain(&mut self.frames).rev() + core::iter::once(&mut self.first_frame).chain(&mut self.frames).rev() } /// Returns whether the current contract is on the stack multiple times. diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index 33083c7ebe76a..ed00fdca62ff2 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -87,6 +87,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "1024")] +extern crate alloc; mod address; mod benchmarking; mod exec; @@ -115,6 +116,7 @@ use crate::{ wasm::{CodeInfo, WasmBlob}, }; use codec::{Codec, Decode, Encode, HasCompact, MaxEncodedLen}; +use core::fmt::Debug; use environmental::*; use frame_support::{ dispatch::{GetDispatchInfo, Pays, PostDispatchInfo, RawOrigin, WithPostDispatchInfo}, @@ -137,7 +139,6 @@ use sp_runtime::{ traits::{BadOrigin, Convert, Dispatchable, Saturating, StaticLookup, Zero}, DispatchError, RuntimeDebug, }; -use sp_std::{fmt::Debug, prelude::*}; pub use crate::{ address::{AddressGenerator, DefaultAddressGenerator}, diff --git a/substrate/frame/contracts/src/migration.rs b/substrate/frame/contracts/src/migration.rs index c633ba9c2d50d..29ac74d0d50a9 100644 --- a/substrate/frame/contracts/src/migration.rs +++ b/substrate/frame/contracts/src/migration.rs @@ -69,17 +69,16 @@ include!(concat!(env!("OUT_DIR"), "/migration_codegen.rs")); use crate::{weights::WeightInfo, Config, Error, MigrationInProgress, Pallet, Weight, LOG_TARGET}; use codec::{Codec, Decode}; +use core::marker::PhantomData; use frame_support::{ pallet_prelude::*, traits::{ConstU32, OnRuntimeUpgrade}, weights::WeightMeter, }; use sp_runtime::Saturating; -use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] -use sp_std::prelude::*; - +use alloc::vec::Vec; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -604,7 +603,7 @@ mod test { let mut meter = WeightMeter::with_limit(Weight::from_all(1)); let result = Migrations::steps(version, &cursor, &mut meter); - cursor = vec![1u8, 0].try_into().unwrap(); + cursor = alloc::vec![1u8, 0].try_into().unwrap(); assert_eq!(result, StepResult::InProgress { cursor: cursor.clone(), steps_done: 1 }); assert_eq!(meter.consumed(), Weight::from_all(1)); diff --git a/substrate/frame/contracts/src/migration/v09.rs b/substrate/frame/contracts/src/migration/v09.rs index 7e84191910d9f..6a67395174f5d 100644 --- a/substrate/frame/contracts/src/migration/v09.rs +++ b/substrate/frame/contracts/src/migration/v09.rs @@ -22,13 +22,13 @@ use crate::{ weights::WeightInfo, CodeHash, Config, Determinism, Pallet, Weight, LOG_TARGET, }; +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::{ pallet_prelude::*, storage_alias, weights::WeightMeter, DefaultNoBound, Identity, }; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; -use sp_std::prelude::*; mod v8 { use super::*; @@ -56,7 +56,7 @@ pub fn store_old_dummy_code(len: usize) { instruction_weights_version: 0, initial: 0, maximum: 0, - code: vec![42u8; len], + code: alloc::vec![42u8; len], }; let hash = T::Hashing::hash(&module.code); v8::CodeStorage::::insert(hash, module); diff --git a/substrate/frame/contracts/src/migration/v10.rs b/substrate/frame/contracts/src/migration/v10.rs index 61632a1fd1bad..23e7fd238bb7c 100644 --- a/substrate/frame/contracts/src/migration/v10.rs +++ b/substrate/frame/contracts/src/migration/v10.rs @@ -40,13 +40,15 @@ use frame_support::{ DefaultNoBound, }; use sp_core::hexdisplay::HexDisplay; -#[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; use sp_runtime::{ traits::{Hash, TrailingZeroInput, Zero}, Perbill, Saturating, }; -use sp_std::prelude::*; + +#[cfg(feature = "try-runtime")] +use alloc::vec::Vec; +#[cfg(feature = "try-runtime")] +use sp_runtime::TryRuntimeError; mod v9 { use super::*; diff --git a/substrate/frame/contracts/src/migration/v11.rs b/substrate/frame/contracts/src/migration/v11.rs index 9b4316162ca62..bd128e22869f4 100644 --- a/substrate/frame/contracts/src/migration/v11.rs +++ b/substrate/frame/contracts/src/migration/v11.rs @@ -23,11 +23,13 @@ use crate::{ weights::WeightInfo, Config, Pallet, TrieId, Weight, LOG_TARGET, }; +use alloc::vec::Vec; use codec::{Decode, Encode}; +use core::marker::PhantomData; use frame_support::{pallet_prelude::*, storage_alias, weights::WeightMeter, DefaultNoBound}; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; -use sp_std::{marker::PhantomData, prelude::*}; + mod v10 { use super::*; diff --git a/substrate/frame/contracts/src/migration/v12.rs b/substrate/frame/contracts/src/migration/v12.rs index aad51a9edcab2..3c33591e43514 100644 --- a/substrate/frame/contracts/src/migration/v12.rs +++ b/substrate/frame/contracts/src/migration/v12.rs @@ -23,6 +23,7 @@ use crate::{ weights::WeightInfo, AccountIdOf, BalanceOf, CodeHash, Config, Determinism, Pallet, Weight, LOG_TARGET, }; +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::{ pallet_prelude::*, storage_alias, traits::ReservableCurrency, weights::WeightMeter, @@ -33,7 +34,6 @@ use sp_core::hexdisplay::HexDisplay; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, FixedPointNumber, FixedU128, Saturating}; -use sp_std::prelude::*; mod v11 { use super::*; @@ -109,7 +109,7 @@ where { use sp_runtime::traits::Hash; - let code = vec![42u8; len]; + let code = alloc::vec![42u8; len]; let hash = T::Hashing::hash(&code); PristineCode::::insert(hash, code.clone()); diff --git a/substrate/frame/contracts/src/migration/v13.rs b/substrate/frame/contracts/src/migration/v13.rs index 6929bbce28e59..d1888b338dac7 100644 --- a/substrate/frame/contracts/src/migration/v13.rs +++ b/substrate/frame/contracts/src/migration/v13.rs @@ -26,7 +26,6 @@ use crate::{ use codec::{Decode, Encode}; use frame_support::{pallet_prelude::*, storage_alias, weights::WeightMeter, DefaultNoBound}; use sp_runtime::BoundedBTreeMap; -use sp_std::prelude::*; mod v12 { use super::*; diff --git a/substrate/frame/contracts/src/migration/v14.rs b/substrate/frame/contracts/src/migration/v14.rs index 017fd6d0c15b7..11336fe2e7d35 100644 --- a/substrate/frame/contracts/src/migration/v14.rs +++ b/substrate/frame/contracts/src/migration/v14.rs @@ -26,6 +26,8 @@ use crate::{ weights::WeightInfo, BalanceOf, CodeHash, Config, Determinism, HoldReason, Pallet, Weight, LOG_TARGET, }; +#[cfg(feature = "try-runtime")] +use alloc::collections::btree_map::BTreeMap; use codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] use environmental::Vec; @@ -42,8 +44,6 @@ use sp_core::hexdisplay::HexDisplay; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, Saturating}; -#[cfg(feature = "try-runtime")] -use sp_std::collections::btree_map::BTreeMap; mod v13 { use super::*; @@ -80,8 +80,8 @@ where T: Config, OldCurrency: ReservableCurrency<::AccountId> + 'static, { + use alloc::vec; use sp_runtime::traits::Hash; - use sp_std::vec; let len = T::MaxCodeLen::get(); let code = vec![42u8; len as usize]; diff --git a/substrate/frame/contracts/src/migration/v15.rs b/substrate/frame/contracts/src/migration/v15.rs index 3c700d1c0b021..11f07282d5614 100644 --- a/substrate/frame/contracts/src/migration/v15.rs +++ b/substrate/frame/contracts/src/migration/v15.rs @@ -28,6 +28,8 @@ use crate::{ AccountIdOf, BalanceOf, CodeHash, Config, HoldReason, Pallet, TrieId, Weight, LOG_TARGET, }; #[cfg(feature = "try-runtime")] +use alloc::vec::Vec; +#[cfg(feature = "try-runtime")] use frame_support::traits::fungible::InspectHold; use frame_support::{ pallet_prelude::*, @@ -44,8 +46,6 @@ use sp_core::hexdisplay::HexDisplay; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, Saturating}; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; mod v14 { use super::*; diff --git a/substrate/frame/contracts/src/migration/v16.rs b/substrate/frame/contracts/src/migration/v16.rs index 74fbc997718d6..3d5b2d2a85fcd 100644 --- a/substrate/frame/contracts/src/migration/v16.rs +++ b/substrate/frame/contracts/src/migration/v16.rs @@ -26,7 +26,6 @@ use crate::{ use codec::{Decode, Encode}; use frame_support::{pallet_prelude::*, storage_alias, DefaultNoBound}; use sp_runtime::{BoundedBTreeMap, Saturating}; -use sp_std::prelude::*; #[cfg(feature = "runtime-benchmarks")] pub fn store_old_contract_info( diff --git a/substrate/frame/contracts/src/primitives.rs b/substrate/frame/contracts/src/primitives.rs index ab73b28e8c49f..622a69f529fb5 100644 --- a/substrate/frame/contracts/src/primitives.rs +++ b/substrate/frame/contracts/src/primitives.rs @@ -17,6 +17,7 @@ //! A crate that hosts a common definitions that are relevant for the pallet-contracts. +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::weights::Weight; use pallet_contracts_uapi::ReturnFlags; @@ -25,7 +26,6 @@ use sp_runtime::{ traits::{Saturating, Zero}, DispatchError, RuntimeDebug, }; -use sp_std::prelude::*; /// Result type of a `bare_call` or `bare_instantiate` call as well as `ContractsApi::call` and /// `ContractsApi::instantiate`. diff --git a/substrate/frame/contracts/src/storage.rs b/substrate/frame/contracts/src/storage.rs index 1e9739a1599eb..23b5a2514eb14 100644 --- a/substrate/frame/contracts/src/storage.rs +++ b/substrate/frame/contracts/src/storage.rs @@ -25,7 +25,9 @@ use crate::{ BalanceOf, CodeHash, CodeInfo, Config, ContractInfoOf, DeletionQueue, DeletionQueueCounter, Error, TrieId, SENTINEL, }; +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; +use core::marker::PhantomData; use frame_support::{ storage::child::{self, ChildInfo}, weights::{Weight, WeightMeter}, @@ -38,7 +40,6 @@ use sp_runtime::{ traits::{Hash, Saturating, Zero}, BoundedBTreeMap, DispatchError, DispatchResult, RuntimeDebug, }; -use sp_std::{marker::PhantomData, prelude::*}; use self::meter::Diff; diff --git a/substrate/frame/contracts/src/storage/meter.rs b/substrate/frame/contracts/src/storage/meter.rs index 7c55ce5d3f0c4..951cb25994e1f 100644 --- a/substrate/frame/contracts/src/storage/meter.rs +++ b/substrate/frame/contracts/src/storage/meter.rs @@ -22,6 +22,8 @@ use crate::{ Inspect, Origin, Pallet, StorageDeposit as Deposit, System, LOG_TARGET, }; +use alloc::vec::Vec; +use core::{fmt::Debug, marker::PhantomData}; use frame_support::{ ensure, traits::{ @@ -37,7 +39,6 @@ use sp_runtime::{ traits::{Saturating, Zero}, DispatchError, FixedPointNumber, FixedU128, }; -use sp_std::{fmt::Debug, marker::PhantomData, vec::Vec}; /// Deposit that uses the native fungible's balance type. pub type DepositOf = Deposit>; diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index c20577a3f6458..3f608d90bea7e 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -458,7 +458,7 @@ parameter_types! { pub static InstantiateAccount: Option<::AccountId> = None; } -pub struct EnsureAccount(sp_std::marker::PhantomData<(T, A)>); +pub struct EnsureAccount(core::marker::PhantomData<(T, A)>); impl>>> EnsureOrigin<::RuntimeOrigin> for EnsureAccount where diff --git a/substrate/frame/contracts/src/wasm/mod.rs b/substrate/frame/contracts/src/wasm/mod.rs index 0d65d696758d0..2fef07f8b7a4c 100644 --- a/substrate/frame/contracts/src/wasm/mod.rs +++ b/substrate/frame/contracts/src/wasm/mod.rs @@ -48,6 +48,7 @@ use crate::{ AccountIdOf, BadOrigin, BalanceOf, CodeHash, CodeInfoOf, CodeVec, Config, Error, Event, HoldReason, Pallet, PristineCode, Schedule, Weight, LOG_TARGET, }; +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::DispatchResult, @@ -56,7 +57,6 @@ use frame_support::{ }; use sp_core::Get; use sp_runtime::{DispatchError, RuntimeDebug}; -use sp_std::prelude::*; use wasmi::{CompilationMode, InstancePre, Linker, Memory, MemoryType, StackLimits, Store}; const BYTES_PER_PAGE: usize = 64 * 1024; diff --git a/substrate/frame/contracts/src/wasm/prepare.rs b/substrate/frame/contracts/src/wasm/prepare.rs index 50eb6d625321a..93fe3080d22db 100644 --- a/substrate/frame/contracts/src/wasm/prepare.rs +++ b/substrate/frame/contracts/src/wasm/prepare.rs @@ -28,10 +28,10 @@ use crate::{ }, AccountIdOf, CodeVec, Config, Error, Schedule, LOG_TARGET, }; +#[cfg(any(test, feature = "runtime-benchmarks"))] +use alloc::vec::Vec; use codec::MaxEncodedLen; use sp_runtime::{traits::Hash, DispatchError}; -#[cfg(any(test, feature = "runtime-benchmarks"))] -use sp_std::prelude::Vec; use wasmi::{ core::ValType as WasmiValueType, CompilationMode, Config as WasmiConfig, Engine, ExternType, Module, StackLimits, @@ -56,7 +56,7 @@ pub enum LoadingMode { #[cfg(test)] pub mod tracker { - use sp_std::cell::RefCell; + use core::cell::RefCell; thread_local! { pub static LOADED_MODULE: RefCell> = RefCell::new(Vec::new()); } diff --git a/substrate/frame/contracts/src/wasm/runtime.rs b/substrate/frame/contracts/src/wasm/runtime.rs index 5f50dbf391a28..50b06de080cab 100644 --- a/substrate/frame/contracts/src/wasm/runtime.rs +++ b/substrate/frame/contracts/src/wasm/runtime.rs @@ -24,7 +24,9 @@ use crate::{ weights::WeightInfo, BalanceOf, CodeHash, Config, DebugBufferVec, Error, SENTINEL, }; +use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, DecodeLimit, Encode, MaxEncodedLen}; +use core::fmt; use frame_support::{ dispatch::DispatchInfo, ensure, pallet_prelude::DispatchResultWithPostInfo, parameter_types, traits::Get, weights::Weight, @@ -36,7 +38,6 @@ use sp_runtime::{ traits::{Bounded, Zero}, DispatchError, RuntimeDebug, }; -use sp_std::{fmt, prelude::*}; use wasmi::{core::HostError, errors::LinkerError, Linker, Memory, Store}; type CallOf = ::RuntimeCall; @@ -1900,7 +1901,7 @@ pub mod env { data_len: u32, ) -> Result<(), TrapReason> { let num_topic = topics_len - .checked_div(sp_std::mem::size_of::>() as u32) + .checked_div(core::mem::size_of::>() as u32) .ok_or("Zero sized topics are not allowed")?; ctx.charge_gas(RuntimeCosts::DepositEvent { num_topic, len: data_len })?; if data_len > ctx.ext.max_value_size() { diff --git a/substrate/frame/conviction-voting/Cargo.toml b/substrate/frame/conviction-voting/Cargo.toml index b96809b8aeb4d..6184b0ffd6e67 100644 --- a/substrate/frame/conviction-voting/Cargo.toml +++ b/substrate/frame/conviction-voting/Cargo.toml @@ -28,7 +28,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -49,7 +48,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/conviction-voting/src/benchmarking.rs b/substrate/frame/conviction-voting/src/benchmarking.rs index 8701ed7ebb074..546ad5385355e 100644 --- a/substrate/frame/conviction-voting/src/benchmarking.rs +++ b/substrate/frame/conviction-voting/src/benchmarking.rs @@ -19,6 +19,7 @@ use super::*; +use alloc::{collections::btree_map::BTreeMap, vec::Vec}; use assert_matches::assert_matches; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelist_account}; use frame_support::{ @@ -30,7 +31,6 @@ use frame_support::{ }, }; use sp_runtime::traits::Bounded; -use sp_std::collections::btree_map::BTreeMap; use crate::Pallet as ConvictionVoting; diff --git a/substrate/frame/conviction-voting/src/lib.rs b/substrate/frame/conviction-voting/src/lib.rs index 466fc70a619b6..be7f7f448070f 100644 --- a/substrate/frame/conviction-voting/src/lib.rs +++ b/substrate/frame/conviction-voting/src/lib.rs @@ -27,6 +27,8 @@ #![recursion_limit = "256"] #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + use frame_support::{ dispatch::DispatchResult, ensure, @@ -40,7 +42,6 @@ use sp_runtime::{ traits::{AtLeast32BitUnsigned, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, Perbill, }; -use sp_std::prelude::*; mod conviction; mod types; @@ -559,7 +560,7 @@ impl, I: 'static> Pallet { ensure!(balance <= T::Currency::total_balance(&who), Error::::InsufficientFunds); let votes = VotingFor::::try_mutate(&who, &class, |voting| -> Result { - let old = sp_std::mem::replace( + let old = core::mem::replace( voting, Voting::Delegating(Delegating { balance, @@ -596,7 +597,7 @@ impl, I: 'static> Pallet { fn try_undelegate(who: T::AccountId, class: ClassOf) -> Result { let votes = VotingFor::::try_mutate(&who, &class, |voting| -> Result { - match sp_std::mem::replace(voting, Voting::default()) { + match core::mem::replace(voting, Voting::default()) { Voting::Delegating(Delegating { balance, target, diff --git a/substrate/frame/conviction-voting/src/types.rs b/substrate/frame/conviction-voting/src/types.rs index 2c45b54485bd9..d6bbb678a14b3 100644 --- a/substrate/frame/conviction-voting/src/types.rs +++ b/substrate/frame/conviction-voting/src/types.rs @@ -18,6 +18,7 @@ //! Miscellaneous additional datatypes. use codec::{Codec, Decode, Encode, MaxEncodedLen}; +use core::{fmt::Debug, marker::PhantomData}; use frame_support::{ traits::VoteTally, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound, }; @@ -26,7 +27,6 @@ use sp_runtime::{ traits::{Saturating, Zero}, RuntimeDebug, }; -use sp_std::{fmt::Debug, marker::PhantomData}; use super::*; use crate::{AccountVote, Conviction, Vote}; diff --git a/substrate/frame/conviction-voting/src/vote.rs b/substrate/frame/conviction-voting/src/vote.rs index 5ae08f0de65f2..1c5b742ba12b1 100644 --- a/substrate/frame/conviction-voting/src/vote.rs +++ b/substrate/frame/conviction-voting/src/vote.rs @@ -25,7 +25,6 @@ use sp_runtime::{ traits::{Saturating, Zero}, RuntimeDebug, }; -use sp_std::prelude::*; /// A number of lock periods, plus a vote, one way or the other. #[derive(Copy, Clone, Eq, PartialEq, Default, RuntimeDebug, MaxEncodedLen)] diff --git a/substrate/frame/core-fellowship/Cargo.toml b/substrate/frame/core-fellowship/Cargo.toml index 44290402594a9..7ef6f9e11eb11 100644 --- a/substrate/frame/core-fellowship/Cargo.toml +++ b/substrate/frame/core-fellowship/Cargo.toml @@ -26,7 +26,6 @@ sp-arithmetic = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } pallet-ranked-collective = { optional = true, workspace = true } [features] @@ -44,7 +43,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/core-fellowship/src/benchmarking.rs b/substrate/frame/core-fellowship/src/benchmarking.rs index 34461e062b35c..adb8a4a091b8d 100644 --- a/substrate/frame/core-fellowship/src/benchmarking.rs +++ b/substrate/frame/core-fellowship/src/benchmarking.rs @@ -22,6 +22,7 @@ use super::*; use crate::Pallet as CoreFellowship; +use alloc::{boxed::Box, vec}; use frame_benchmarking::v2::*; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_arithmetic::traits::Bounded; diff --git a/substrate/frame/core-fellowship/src/lib.rs b/substrate/frame/core-fellowship/src/lib.rs index 5ed2562d6d019..c61447e36280a 100644 --- a/substrate/frame/core-fellowship/src/lib.rs +++ b/substrate/frame/core-fellowship/src/lib.rs @@ -57,11 +57,14 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::boxed::Box; use codec::{Decode, Encode, MaxEncodedLen}; +use core::{fmt::Debug, marker::PhantomData}; use scale_info::TypeInfo; use sp_arithmetic::traits::{Saturating, Zero}; use sp_runtime::RuntimeDebug; -use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; use frame_support::{ defensive, diff --git a/substrate/frame/core-fellowship/src/migration.rs b/substrate/frame/core-fellowship/src/migration.rs index b8b5540a4b475..b1e27d1e79363 100644 --- a/substrate/frame/core-fellowship/src/migration.rs +++ b/substrate/frame/core-fellowship/src/migration.rs @@ -24,6 +24,8 @@ use frame_support::{ BoundedVec, }; +#[cfg(feature = "try-runtime")] +use alloc::vec::Vec; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; diff --git a/substrate/frame/delegated-staking/Cargo.toml b/substrate/frame/delegated-staking/Cargo.toml index 0c1bcf0df0c5e..a7751e1d6c1ca 100644 --- a/substrate/frame/delegated-staking/Cargo.toml +++ b/substrate/frame/delegated-staking/Cargo.toml @@ -16,7 +16,6 @@ codec = { features = ["derive"], workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } sp-staking = { workspace = true } @@ -48,7 +47,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-election-provider-support/runtime-benchmarks", diff --git a/substrate/frame/delegated-staking/src/impls.rs b/substrate/frame/delegated-staking/src/impls.rs index 9f5649672d70e..f8df9dfe7b46c 100644 --- a/substrate/frame/delegated-staking/src/impls.rs +++ b/substrate/frame/delegated-staking/src/impls.rs @@ -139,7 +139,7 @@ impl OnStakingUpdate> for Pallet { fn on_slash( who: &T::AccountId, _slashed_active: BalanceOf, - _slashed_unlocking: &sp_std::collections::btree_map::BTreeMap>, + _slashed_unlocking: &alloc::collections::btree_map::BTreeMap>, slashed_total: BalanceOf, ) { >::mutate(who, |maybe_register| match maybe_register { diff --git a/substrate/frame/delegated-staking/src/lib.rs b/substrate/frame/delegated-staking/src/lib.rs index f16bb0d1dc08d..61809dcb54eea 100644 --- a/substrate/frame/delegated-staking/src/lib.rs +++ b/substrate/frame/delegated-staking/src/lib.rs @@ -132,10 +132,13 @@ mod mock; mod tests; mod types; +extern crate alloc; + pub use pallet::*; use types::*; +use core::convert::TryInto; use frame_support::{ pallet_prelude::*, traits::{ @@ -154,7 +157,6 @@ use sp_runtime::{ ArithmeticError, DispatchResult, Perbill, RuntimeDebug, Saturating, }; use sp_staking::{Agent, Delegator, EraIndex, StakingInterface, StakingUnchecked}; -use sp_std::{convert::TryInto, prelude::*}; pub type BalanceOf = <::Currency as FunInspect<::AccountId>>::Balance; @@ -779,7 +781,7 @@ impl Pallet { } #[cfg(any(test, feature = "try-runtime"))] -use sp_std::collections::btree_map::BTreeMap; +use alloc::collections::btree_map::BTreeMap; #[cfg(any(test, feature = "try-runtime"))] impl Pallet { diff --git a/substrate/frame/democracy/Cargo.toml b/substrate/frame/democracy/Cargo.toml index 6a44951e09c4b..ce5ffa57d5798 100644 --- a/substrate/frame/democracy/Cargo.toml +++ b/substrate/frame/democracy/Cargo.toml @@ -26,7 +26,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-core = { workspace = true } log = { workspace = true } @@ -51,7 +50,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/democracy/src/benchmarking.rs b/substrate/frame/democracy/src/benchmarking.rs index 799d614c37f4a..ee36e9212f52b 100644 --- a/substrate/frame/democracy/src/benchmarking.rs +++ b/substrate/frame/democracy/src/benchmarking.rs @@ -85,8 +85,8 @@ fn assert_has_event(generic_event: ::RuntimeEvent) { // note a new preimage. fn note_preimage() -> T::Hash { + use alloc::borrow::Cow; use core::sync::atomic::{AtomicU8, Ordering}; - use sp_std::borrow::Cow; // note a new preimage on every function invoke. static COUNTER: AtomicU8 = AtomicU8::new(0); let data = Cow::from(vec![COUNTER.fetch_add(1, Ordering::Relaxed)]); diff --git a/substrate/frame/democracy/src/lib.rs b/substrate/frame/democracy/src/lib.rs index e3b4696f8b2af..27bc36a756e4b 100644 --- a/substrate/frame/democracy/src/lib.rs +++ b/substrate/frame/democracy/src/lib.rs @@ -152,6 +152,9 @@ #![recursion_limit = "256"] #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; use frame_support::{ ensure, @@ -168,7 +171,6 @@ use sp_runtime::{ traits::{BadOrigin, Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, DispatchResult, }; -use sp_std::prelude::*; mod conviction; mod types; @@ -438,7 +440,7 @@ pub mod pallet { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - _config: sp_std::marker::PhantomData, + _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -1433,7 +1435,7 @@ impl Pallet { delegations: Default::default(), prior: Default::default(), }; - sp_std::mem::swap(&mut old, voting); + core::mem::swap(&mut old, voting); match old { Voting::Delegating { balance, target, conviction, delegations, mut prior, .. @@ -1474,7 +1476,7 @@ impl Pallet { fn try_undelegate(who: T::AccountId) -> Result { let votes = VotingOf::::try_mutate(&who, |voting| -> Result { let mut old = Voting::default(); - sp_std::mem::swap(&mut old, voting); + core::mem::swap(&mut old, voting); match old { Voting::Delegating { balance, target, conviction, delegations, mut prior } => { // remove any delegation votes to our current target. diff --git a/substrate/frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs b/substrate/frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs index 1cb50a157b12b..ca0e0f7a091aa 100644 --- a/substrate/frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs +++ b/substrate/frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs @@ -19,6 +19,7 @@ //! pallet. use crate::{PropIndex, Voting, DEMOCRACY_ID}; +use alloc::{collections::btree_map::BTreeMap, vec::Vec}; use core::iter::Sum; use frame_support::{ pallet_prelude::ValueQuery, @@ -29,7 +30,6 @@ use frame_support::{ }; use sp_core::Get; use sp_runtime::{traits::Zero, BoundedVec, Saturating}; -use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; const LOG_TARGET: &str = "runtime::democracy::migrations::unlock_and_unreserve_all_funds"; @@ -87,7 +87,7 @@ type VotingOf = StorageMap< /// The pallet should be made inoperable before this migration is run. /// /// (See also [`RemovePallet`][frame_support::migrations::RemovePallet]) -pub struct UnlockAndUnreserveAllFunds(sp_std::marker::PhantomData); +pub struct UnlockAndUnreserveAllFunds(core::marker::PhantomData); impl UnlockAndUnreserveAllFunds { /// Calculates and returns the total amounts reserved by each account by this pallet, and all @@ -170,8 +170,8 @@ where /// the actual total reserved amount for any accounts. #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + use alloc::collections::btree_set::BTreeSet; use codec::Encode; - use sp_std::collections::btree_set::BTreeSet; // Get staked and deposited balances as reported by this pallet. let (account_deposits, account_locks, _) = Self::get_account_deposits_and_locks(); diff --git a/substrate/frame/democracy/src/vote.rs b/substrate/frame/democracy/src/vote.rs index b3fe9aa28e1ac..779f7ecd570f0 100644 --- a/substrate/frame/democracy/src/vote.rs +++ b/substrate/frame/democracy/src/vote.rs @@ -25,7 +25,6 @@ use sp_runtime::{ traits::{Saturating, Zero}, BoundedVec, RuntimeDebug, }; -use sp_std::prelude::*; /// A number of lock periods, plus a vote, one way or the other. #[derive(Copy, Clone, Eq, PartialEq, Default, RuntimeDebug)] diff --git a/substrate/frame/election-provider-multi-phase/Cargo.toml b/substrate/frame/election-provider-multi-phase/Cargo.toml index 941d720f2c6ca..4d1f521d726e2 100644 --- a/substrate/frame/election-provider-multi-phase/Cargo.toml +++ b/substrate/frame/election-provider-multi-phase/Cargo.toml @@ -27,7 +27,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } -sp-std = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } sp-npos-elections = { workspace = true } @@ -68,7 +67,6 @@ std = [ "sp-io/std", "sp-npos-elections/std", "sp-runtime/std", - "sp-std/std", "sp-tracing/std", "strum/std", ] diff --git a/substrate/frame/election-provider-multi-phase/src/helpers.rs b/substrate/frame/election-provider-multi-phase/src/helpers.rs index a3f27fc18f077..8269b2cb73be2 100644 --- a/substrate/frame/election-provider-multi-phase/src/helpers.rs +++ b/substrate/frame/election-provider-multi-phase/src/helpers.rs @@ -21,7 +21,7 @@ use crate::{ unsigned::{MinerConfig, MinerVoterOf}, SolutionTargetIndexOf, SolutionVoterIndexOf, VoteWeight, }; -use sp_std::{collections::btree_map::BTreeMap, prelude::*}; +use alloc::{collections::btree_map::BTreeMap, vec::Vec}; #[macro_export] macro_rules! log { diff --git a/substrate/frame/election-provider-multi-phase/src/lib.rs b/substrate/frame/election-provider-multi-phase/src/lib.rs index 63b4c49cdfe47..9ce8b3890a624 100644 --- a/substrate/frame/election-provider-multi-phase/src/lib.rs +++ b/substrate/frame/election-provider-multi-phase/src/lib.rs @@ -229,6 +229,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{boxed::Box, vec::Vec}; use codec::{Decode, Encode}; use frame_election_provider_support::{ bounds::{CountBound, ElectionBounds, ElectionBoundsBuilder, SizeBound}, @@ -256,7 +259,6 @@ use sp_runtime::{ }, DispatchError, ModuleError, PerThing, Perbill, RuntimeDebug, SaturatedConversion, }; -use sp_std::prelude::*; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -837,7 +839,7 @@ pub mod pallet { } fn integrity_test() { - use sp_std::mem::size_of; + use core::mem::size_of; // The index type of both voters and targets need to be smaller than that of usize (very // unlikely to be the case, but anyhow).. assert!(size_of::>() <= size_of::()); @@ -1354,7 +1356,7 @@ pub mod pallet { /// This wrapper is created for handling the synchronization of [`Snapshot`], [`SnapshotMetadata`] /// and [`DesiredTargets`] storage items. -pub struct SnapshotWrapper(sp_std::marker::PhantomData); +pub struct SnapshotWrapper(core::marker::PhantomData); impl SnapshotWrapper { /// Kill all snapshot related storage items at the same time. diff --git a/substrate/frame/election-provider-multi-phase/src/migrations.rs b/substrate/frame/election-provider-multi-phase/src/migrations.rs index 156f1c02e27cd..73a2d878f150f 100644 --- a/substrate/frame/election-provider-multi-phase/src/migrations.rs +++ b/substrate/frame/election-provider-multi-phase/src/migrations.rs @@ -16,15 +16,15 @@ // limitations under the License. pub mod v1 { + use alloc::collections::btree_map::BTreeMap; use frame_support::{ storage::unhashed, traits::{Defensive, GetStorageVersion, OnRuntimeUpgrade}, BoundedVec, }; - use sp_std::collections::btree_map::BTreeMap; use crate::*; - pub struct MigrateToV1(sp_std::marker::PhantomData); + pub struct MigrateToV1(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { fn on_runtime_upgrade() -> Weight { let current = Pallet::::in_code_storage_version(); diff --git a/substrate/frame/election-provider-multi-phase/src/signed.rs b/substrate/frame/election-provider-multi-phase/src/signed.rs index ae830ed0382d8..fe07e477e1d5d 100644 --- a/substrate/frame/election-provider-multi-phase/src/signed.rs +++ b/substrate/frame/election-provider-multi-phase/src/signed.rs @@ -24,7 +24,12 @@ use crate::{ ReadySolution, SignedSubmissionIndices, SignedSubmissionNextIndex, SignedSubmissionsMap, SolutionOf, SolutionOrSnapshotSize, Weight, WeightInfo, }; +use alloc::{ + collections::{btree_map::BTreeMap, btree_set::BTreeSet}, + vec::Vec, +}; use codec::{Decode, Encode, HasCompact}; +use core::cmp::Ordering; use frame_election_provider_support::NposSolution; use frame_support::traits::{ defensive_prelude::*, Currency, Get, OnUnbalanced, ReservableCurrency, @@ -37,11 +42,6 @@ use sp_runtime::{ traits::{Convert, Saturating, Zero}, FixedPointNumber, FixedPointOperand, FixedU128, Percent, RuntimeDebug, }; -use sp_std::{ - cmp::Ordering, - collections::{btree_map::BTreeMap, btree_set::BTreeSet}, - vec::Vec, -}; /// A raw, unchecked signed submission. /// diff --git a/substrate/frame/election-provider-multi-phase/src/unsigned.rs b/substrate/frame/election-provider-multi-phase/src/unsigned.rs index 8b25815eca13e..728ab93023895 100644 --- a/substrate/frame/election-provider-multi-phase/src/unsigned.rs +++ b/substrate/frame/election-provider-multi-phase/src/unsigned.rs @@ -21,6 +21,7 @@ use crate::{ helpers, Call, Config, ElectionCompute, Error, FeasibilityError, Pallet, RawSolution, ReadySolution, RoundSnapshot, SolutionAccuracyOf, SolutionOf, SolutionOrSnapshotSize, Weight, }; +use alloc::{boxed::Box, vec::Vec}; use codec::Encode; use frame_election_provider_support::{NposSolution, NposSolver, PerThing128, VoteWeight}; use frame_support::{ @@ -39,7 +40,6 @@ use sp_runtime::{ offchain::storage::{MutateStorageError, StorageValueRef}, DispatchError, SaturatedConversion, }; -use sp_std::prelude::*; /// Storage key used to store the last block number at which offchain worker ran. pub(crate) const OFFCHAIN_LAST_BLOCK: &[u8] = b"parity/multi-phase-unsigned-election"; @@ -396,14 +396,14 @@ impl Pallet { /// Configurations for a miner that comes with this pallet. pub trait MinerConfig { /// The account id type. - type AccountId: Ord + Clone + codec::Codec + sp_std::fmt::Debug; + type AccountId: Ord + Clone + codec::Codec + core::fmt::Debug; /// The solution that the miner is mining. type Solution: codec::Codec + Default + PartialEq + Eq + Clone - + sp_std::fmt::Debug + + core::fmt::Debug + Ord + NposSolution + TypeInfo; @@ -428,7 +428,7 @@ pub trait MinerConfig { } /// A base miner, suitable to be used for both signed and unsigned submissions. -pub struct Miner(sp_std::marker::PhantomData); +pub struct Miner(core::marker::PhantomData); impl Miner { /// Same as [`Pallet::mine_solution`], but the input snapshot data must be given. pub fn mine_solution_with_snapshot( @@ -505,7 +505,7 @@ impl Miner { stake }) .unwrap_or_default(); - sp_std::cmp::Reverse(stake) + core::cmp::Reverse(stake) }, ); @@ -1016,6 +1016,7 @@ mod tests { Event, InvalidTransaction, Phase, QueuedSolution, TransactionSource, TransactionValidityError, }; + use alloc::vec; use codec::Decode; use frame_election_provider_support::IndexAssignment; use frame_support::{assert_noop, assert_ok, traits::OffchainWorker}; diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index bb1bdb3142056..5c64f2a0bc20f 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -38,7 +38,6 @@ use sp_staking::{ offence::{OffenceDetails, OnOffenceHandler}, EraIndex, SessionIndex, }; -use sp_std::prelude::*; use std::collections::BTreeMap; use codec::Decode; diff --git a/substrate/frame/election-provider-support/Cargo.toml b/substrate/frame/election-provider-support/Cargo.toml index 012392ffc59d9..80fea6c5ca972 100644 --- a/substrate/frame/election-provider-support/Cargo.toml +++ b/substrate/frame/election-provider-support/Cargo.toml @@ -23,7 +23,6 @@ frame-system = { workspace = true } sp-arithmetic = { workspace = true } sp-npos-elections = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-core = { workspace = true } [dev-dependencies] @@ -44,7 +43,6 @@ std = [ "sp-io/std", "sp-npos-elections/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-support/runtime-benchmarks", diff --git a/substrate/frame/election-provider-support/benchmarking/Cargo.toml b/substrate/frame/election-provider-support/benchmarking/Cargo.toml index ecf41ff9663bb..dcfcb9c35cda0 100644 --- a/substrate/frame/election-provider-support/benchmarking/Cargo.toml +++ b/substrate/frame/election-provider-support/benchmarking/Cargo.toml @@ -23,7 +23,6 @@ frame-election-provider-support = { workspace = true } frame-system = { workspace = true } sp-npos-elections = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -34,7 +33,6 @@ std = [ "frame-system/std", "sp-npos-elections/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/election-provider-support/benchmarking/src/inner.rs b/substrate/frame/election-provider-support/benchmarking/src/inner.rs index 4722680cfcc1c..8cca0d459eac3 100644 --- a/substrate/frame/election-provider-support/benchmarking/src/inner.rs +++ b/substrate/frame/election-provider-support/benchmarking/src/inner.rs @@ -18,10 +18,10 @@ //! Election provider support pallet benchmarking. //! This is separated into its own crate to avoid bloating the size of the runtime. +use alloc::vec::Vec; use codec::Decode; use frame_benchmarking::v1::benchmarks; use frame_election_provider_support::{NposSolver, PhragMMS, SequentialPhragmen}; -use sp_std::vec::Vec; pub struct Pallet(frame_system::Pallet); pub trait Config: frame_system::Config {} diff --git a/substrate/frame/election-provider-support/benchmarking/src/lib.rs b/substrate/frame/election-provider-support/benchmarking/src/lib.rs index 78b226e52af6c..d092483f93839 100644 --- a/substrate/frame/election-provider-support/benchmarking/src/lib.rs +++ b/substrate/frame/election-provider-support/benchmarking/src/lib.rs @@ -19,6 +19,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(feature = "runtime-benchmarks")] pub mod inner; diff --git a/substrate/frame/election-provider-support/solution-type/src/codec.rs b/substrate/frame/election-provider-support/solution-type/src/codec.rs index 17a256c228e28..16d5f17469b7e 100644 --- a/substrate/frame/election-provider-support/solution-type/src/codec.rs +++ b/substrate/frame/election-provider-support/solution-type/src/codec.rs @@ -51,14 +51,14 @@ fn decode_impl( quote! { let #name = < - _fepsp::sp_std::prelude::Vec<(_fepsp::codec::Compact<#voter_type>, _fepsp::codec::Compact<#target_type>)> + _fepsp::Vec<(_fepsp::codec::Compact<#voter_type>, _fepsp::codec::Compact<#target_type>)> as _fepsp::codec::Decode >::decode(value)?; let #name = #name .into_iter() .map(|(v, t)| (v.0, t.0)) - .collect::<_fepsp::sp_std::prelude::Vec<_>>(); + .collect::<_fepsp::Vec<_>>(); } }; @@ -73,7 +73,7 @@ fn decode_impl( quote! { let #name = < - _fepsp::sp_std::prelude::Vec<( + _fepsp::Vec<( _fepsp::codec::Compact<#voter_type>, [(_fepsp::codec::Compact<#target_type>, _fepsp::codec::Compact<#weight_type>); #c-1], _fepsp::codec::Compact<#target_type>, @@ -87,7 +87,7 @@ fn decode_impl( [ #inner_impl ], t_last.0, )) - .collect::<_fepsp::sp_std::prelude::Vec<_>>(); + .collect::<_fepsp::Vec<_>>(); } }) .collect::(); @@ -126,7 +126,7 @@ fn encode_impl(ident: &syn::Ident, count: usize) -> TokenStream2 { _fepsp::codec::Compact(v.clone()), _fepsp::codec::Compact(t.clone()), )) - .collect::<_fepsp::sp_std::prelude::Vec<_>>(); + .collect::<_fepsp::Vec<_>>(); #name.encode_to(&mut r); } }; @@ -153,7 +153,7 @@ fn encode_impl(ident: &syn::Ident, count: usize) -> TokenStream2 { [ #inners_solution_array ], _fepsp::codec::Compact(t_last.clone()), )) - .collect::<_fepsp::sp_std::prelude::Vec<_>>(); + .collect::<_fepsp::Vec<_>>(); #name.encode_to(&mut r); } }) @@ -161,7 +161,7 @@ fn encode_impl(ident: &syn::Ident, count: usize) -> TokenStream2 { quote!( impl _fepsp::codec::Encode for #ident { - fn encode(&self) -> _fepsp::sp_std::prelude::Vec { + fn encode(&self) -> _fepsp::Vec { let mut r = vec![]; #encode_impl_single #encode_impl_rest @@ -182,7 +182,7 @@ fn scale_info_impl( let name = format!("{}", vote_field(1)); quote! { .field(|f| - f.ty::<_fepsp::sp_std::prelude::Vec< + f.ty::<_fepsp::Vec< (_fepsp::codec::Compact<#voter_type>, _fepsp::codec::Compact<#target_type>) >>() .name(#name) @@ -194,7 +194,7 @@ fn scale_info_impl( let name = format!("{}", vote_field(2)); quote! { .field(|f| - f.ty::<_fepsp::sp_std::prelude::Vec<( + f.ty::<_fepsp::Vec<( _fepsp::codec::Compact<#voter_type>, (_fepsp::codec::Compact<#target_type>, _fepsp::codec::Compact<#weight_type>), _fepsp::codec::Compact<#target_type> @@ -209,7 +209,7 @@ fn scale_info_impl( let name = format!("{}", vote_field(c)); quote! { .field(|f| - f.ty::<_fepsp::sp_std::prelude::Vec<( + f.ty::<_fepsp::Vec<( _fepsp::codec::Compact<#voter_type>, [ (_fepsp::codec::Compact<#target_type>, _fepsp::codec::Compact<#weight_type>); diff --git a/substrate/frame/election-provider-support/solution-type/src/single_page.rs b/substrate/frame/election-provider-support/solution-type/src/single_page.rs index 161631ee83fa6..de59df162c8ad 100644 --- a/substrate/frame/election-provider-support/solution-type/src/single_page.rs +++ b/substrate/frame/election-provider-support/solution-type/src/single_page.rs @@ -40,7 +40,7 @@ pub(crate) fn generate(def: crate::SolutionDef) -> Result { let name = vote_field(1); // NOTE: we use the visibility of the struct for the fields as well.. could be made better. quote!( - #vis #name: _fepsp::sp_std::prelude::Vec<(#voter_type, #target_type)>, + #vis #name: _fepsp::Vec<(#voter_type, #target_type)>, ) }; @@ -49,7 +49,7 @@ pub(crate) fn generate(def: crate::SolutionDef) -> Result { let field_name = vote_field(c); let array_len = c - 1; quote!( - #vis #field_name: _fepsp::sp_std::prelude::Vec<( + #vis #field_name: _fepsp::Vec<( #voter_type, [(#target_type, #weight_type); #array_len], #target_type @@ -147,8 +147,8 @@ pub(crate) fn generate(def: crate::SolutionDef) -> Result { self, voter_at: impl Fn(Self::VoterIndex) -> Option, target_at: impl Fn(Self::TargetIndex) -> Option, - ) -> Result<_fepsp::sp_std::prelude::Vec<_feps::Assignment>, _feps::Error> { - let mut #assignment_name: _fepsp::sp_std::prelude::Vec<_feps::Assignment> = Default::default(); + ) -> Result<_fepsp::Vec<_feps::Assignment>, _feps::Error> { + let mut #assignment_name: _fepsp::Vec<_feps::Assignment> = Default::default(); #into_impl Ok(#assignment_name) } @@ -165,10 +165,10 @@ pub(crate) fn generate(def: crate::SolutionDef) -> Result { all_edges } - fn unique_targets(&self) -> _fepsp::sp_std::prelude::Vec { + fn unique_targets(&self) -> _fepsp::Vec { // NOTE: this implementation returns the targets sorted, but we don't use it yet per // se, nor is the API enforcing it. - use _fepsp::sp_std::collections::btree_set::BTreeSet; + use _fepsp::BTreeSet; let mut all_targets: BTreeSet = BTreeSet::new(); let mut maybe_insert_target = |t: Self::TargetIndex| { all_targets.insert(t); @@ -206,7 +206,7 @@ pub(crate) fn generate(def: crate::SolutionDef) -> Result { .saturating_add((s as usize).saturating_mul(max_element_size)) } } - impl<'a> _fepsp::sp_std::convert::TryFrom<&'a [__IndexAssignment]> for #ident { + impl<'a> core::convert::TryFrom<&'a [__IndexAssignment]> for #ident { type Error = _feps::Error; fn try_from(index_assignments: &'a [__IndexAssignment]) -> Result { let mut #struct_name = #ident::default(); @@ -361,7 +361,7 @@ pub(crate) fn into_impl( let target = target_at(*t_idx).or_invalid_index()?; Ok((target, *p)) }) - .collect::, _feps::Error>>()?; + .collect::, _feps::Error>>()?; if sum >= #per_thing::one() { return Err(_feps::Error::SolutionWeightOverflow); diff --git a/substrate/frame/election-provider-support/src/lib.rs b/substrate/frame/election-provider-support/src/lib.rs index 2e9ee3b8a48b5..394f58a384425 100644 --- a/substrate/frame/election-provider-support/src/lib.rs +++ b/substrate/frame/election-provider-support/src/lib.rs @@ -177,11 +177,14 @@ pub mod bounds; pub mod onchain; pub mod traits; +extern crate alloc; + +use alloc::{boxed::Box, vec::Vec}; +use core::fmt::Debug; use sp_runtime::{ traits::{Bounded, Saturating, Zero}, RuntimeDebug, }; -use sp_std::{fmt::Debug, prelude::*}; pub use bounds::DataProviderBounds; pub use codec::{Decode, Encode}; @@ -202,10 +205,10 @@ use sp_runtime::TryRuntimeError; // re-export for the solution macro, with the dependencies of the macro. #[doc(hidden)] pub mod private { + pub use alloc::{collections::btree_set::BTreeSet, vec::Vec}; pub use codec; pub use scale_info; pub use sp_arithmetic; - pub use sp_std; // Simple Extension trait to easily convert `None` from index closures to `Err`. // @@ -276,7 +279,7 @@ pub type IndexAssignmentOf = IndexAssignment< /// Types that are used by the data provider trait. pub mod data_provider { /// Alias for the result type of the election data provider. - pub type Result = sp_std::result::Result; + pub type Result = core::result::Result; } /// Something that can provide the data to an [`ElectionProvider`]. @@ -431,7 +434,7 @@ pub trait InstantElectionProvider: ElectionProviderBase { } /// An election provider that does nothing whatsoever. -pub struct NoElection(sp_std::marker::PhantomData); +pub struct NoElection(core::marker::PhantomData); impl ElectionProviderBase for NoElection<(AccountId, BlockNumber, DataProvider, MaxWinners)> @@ -486,7 +489,7 @@ where /// used on the implementing side of [`ElectionDataProvider`]. pub trait SortedListProvider { /// The list's error type. - type Error: sp_std::fmt::Debug; + type Error: core::fmt::Debug; /// The type used by the list to compare nodes for ordering. type Score: Bounded + Saturating + Zero; @@ -597,7 +600,7 @@ pub trait NposSolver { /// The accuracy of this solver. This will affect the accuracy of the output. type Accuracy: PerThing128; /// The error type of this implementation. - type Error: sp_std::fmt::Debug + sp_std::cmp::PartialEq; + type Error: core::fmt::Debug + core::cmp::PartialEq; /// Solve an NPoS solution with the given `voters`, `targets`, and select `to_elect` count /// of `targets`. @@ -617,7 +620,7 @@ pub trait NposSolver { /// A wrapper for [`sp_npos_elections::seq_phragmen`] that implements [`NposSolver`]. See the /// documentation of [`sp_npos_elections::seq_phragmen`] for more info. pub struct SequentialPhragmen( - sp_std::marker::PhantomData<(AccountId, Accuracy, Balancing)>, + core::marker::PhantomData<(AccountId, Accuracy, Balancing)>, ); impl>> @@ -642,7 +645,7 @@ impl( - sp_std::marker::PhantomData<(AccountId, Accuracy, Balancing)>, + core::marker::PhantomData<(AccountId, Accuracy, Balancing)>, ); impl>> diff --git a/substrate/frame/election-provider-support/src/onchain.rs b/substrate/frame/election-provider-support/src/onchain.rs index ee4f6992a085e..1063d5d35aee7 100644 --- a/substrate/frame/election-provider-support/src/onchain.rs +++ b/substrate/frame/election-provider-support/src/onchain.rs @@ -24,11 +24,12 @@ use crate::{ BoundedSupportsOf, Debug, ElectionDataProvider, ElectionProvider, ElectionProviderBase, InstantElectionProvider, NposSolver, WeightInfo, }; +use alloc::collections::btree_map::BTreeMap; +use core::marker::PhantomData; use frame_support::{dispatch::DispatchClass, traits::Get}; use sp_npos_elections::{ assignment_ratio_to_staked_normalized, to_supports, BoundedSupports, ElectionResult, VoteWeight, }; -use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData, prelude::*}; /// Errors of the on-chain election. #[derive(Eq, PartialEq, Debug)] diff --git a/substrate/frame/election-provider-support/src/traits.rs b/substrate/frame/election-provider-support/src/traits.rs index 43d183b338e29..84fd57992d343 100644 --- a/substrate/frame/election-provider-support/src/traits.rs +++ b/substrate/frame/election-provider-support/src/traits.rs @@ -18,11 +18,12 @@ //! Traits for the election operations. use crate::{Assignment, IdentifierT, IndexAssignmentOf, PerThing128, VoteWeight}; +use alloc::vec::Vec; use codec::Encode; +use core::fmt::Debug; use scale_info::TypeInfo; use sp_arithmetic::traits::{Bounded, UniqueSaturatedInto}; use sp_npos_elections::{ElectionScore, Error, EvaluateSupport}; -use sp_std::{fmt::Debug, prelude::*}; /// An opaque index-based, NPoS solution type. pub trait NposSolution diff --git a/substrate/frame/elections-phragmen/Cargo.toml b/substrate/frame/elections-phragmen/Cargo.toml index b53118b6b6fd2..6d1ecbd07350e 100644 --- a/substrate/frame/elections-phragmen/Cargo.toml +++ b/substrate/frame/elections-phragmen/Cargo.toml @@ -28,7 +28,6 @@ sp-core = { workspace = true } sp-io = { workspace = true } sp-npos-elections = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-staking = { workspace = true } [dev-dependencies] @@ -52,7 +51,6 @@ std = [ "sp-npos-elections/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", "sp-tracing/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index c6eca40c47182..565ead4059d5f 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -98,7 +98,11 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; +use core::cmp::Ordering; use frame_support::{ traits::{ defensive_prelude::*, ChangeMembers, Contains, ContainsLengthBound, Currency, Get, @@ -115,7 +119,6 @@ use sp_runtime::{ DispatchError, Perbill, RuntimeDebug, }; use sp_staking::currency_to_vote::CurrencyToVote; -use sp_std::{cmp::Ordering, prelude::*}; #[cfg(any(feature = "try-runtime", test))] use sp_runtime::TryRuntimeError; diff --git a/substrate/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs b/substrate/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs index 482766ee97f54..ed4569aa25ee6 100644 --- a/substrate/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs +++ b/substrate/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs @@ -18,6 +18,7 @@ //! A migration that unreserves all deposit and unlocks all stake held in the context of this //! pallet. +use alloc::{collections::btree_map::BTreeMap, vec::Vec}; use core::iter::Sum; use frame_support::{ pallet_prelude::ValueQuery, @@ -28,7 +29,6 @@ use frame_support::{ }; use sp_core::Get; use sp_runtime::traits::Zero; -use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; const LOG_TARGET: &str = "elections_phragmen::migrations::unlock_and_unreserve_all_funds"; @@ -93,7 +93,7 @@ type Voting = StorageMap< /// The pallet should be made inoperable before this migration is run. /// /// (See also [`RemovePallet`][frame_support::migrations::RemovePallet]) -pub struct UnlockAndUnreserveAllFunds(sp_std::marker::PhantomData); +pub struct UnlockAndUnreserveAllFunds(core::marker::PhantomData); impl UnlockAndUnreserveAllFunds { /// Calculates and returns the total amounts deposited and staked by each account in the context @@ -187,8 +187,8 @@ where /// reported as staked by the pallet and the amount actually locked in `Balances`. #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + use alloc::collections::btree_set::BTreeSet; use codec::Encode; - use sp_std::collections::btree_set::BTreeSet; // Get staked and deposited balances as reported by this pallet. let (account_deposited_sums, account_staked_sums, _) = diff --git a/substrate/frame/elections-phragmen/src/migrations/v3.rs b/substrate/frame/elections-phragmen/src/migrations/v3.rs index b0092d6c07bb6..82f82f23e712f 100644 --- a/substrate/frame/elections-phragmen/src/migrations/v3.rs +++ b/substrate/frame/elections-phragmen/src/migrations/v3.rs @@ -19,12 +19,12 @@ use super::super::LOG_TARGET; use crate::{Config, Pallet}; +use alloc::vec::Vec; use codec::{Decode, Encode, FullCodec}; use frame_support::{ pallet_prelude::ValueQuery, traits::StorageVersion, weights::Weight, Twox64Concat, }; use sp_runtime::RuntimeDebug; -use sp_std::prelude::*; #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq)] struct SeatHolder { diff --git a/substrate/frame/elections-phragmen/src/migrations/v5.rs b/substrate/frame/elections-phragmen/src/migrations/v5.rs index 6e360aa8b8c15..150a4c4fa6c2c 100644 --- a/substrate/frame/elections-phragmen/src/migrations/v5.rs +++ b/substrate/frame/elections-phragmen/src/migrations/v5.rs @@ -16,6 +16,7 @@ // limitations under the License. use super::super::*; +use alloc::{boxed::Box, vec::Vec}; /// Migrate the locks and vote stake on accounts (as specified with param `to_migrate`) that have /// more than their free balance locked. diff --git a/substrate/frame/examples/basic/Cargo.toml b/substrate/frame/examples/basic/Cargo.toml index b34d9efc15b7f..af547c7eeb21e 100644 --- a/substrate/frame/examples/basic/Cargo.toml +++ b/substrate/frame/examples/basic/Cargo.toml @@ -26,7 +26,6 @@ frame-system = { workspace = true } pallet-balances = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true } @@ -44,7 +43,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/examples/basic/src/lib.rs b/substrate/frame/examples/basic/src/lib.rs index 12cadc969fd74..fea04cb447a07 100644 --- a/substrate/frame/examples/basic/src/lib.rs +++ b/substrate/frame/examples/basic/src/lib.rs @@ -53,6 +53,9 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode}; use core::marker::PhantomData; use frame_support::{ @@ -69,7 +72,6 @@ use sp_runtime::{ InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction, }, }; -use sp_std::vec::Vec; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; diff --git a/substrate/frame/examples/basic/src/tests.rs b/substrate/frame/examples/basic/src/tests.rs index 505cd6f906de2..d7095eb3c944f 100644 --- a/substrate/frame/examples/basic/src/tests.rs +++ b/substrate/frame/examples/basic/src/tests.rs @@ -92,7 +92,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { example: pallet_example_basic::GenesisConfig { dummy: 42, // we configure the map with (key, value) pairs. - bar: vec![(1, 2), (2, 3)], + bar: alloc::vec![(1, 2), (2, 3)], foo: 24, }, } diff --git a/substrate/frame/examples/default-config/Cargo.toml b/substrate/frame/examples/default-config/Cargo.toml index 8a0d14edbdbf3..81509c782a3fa 100644 --- a/substrate/frame/examples/default-config/Cargo.toml +++ b/substrate/frame/examples/default-config/Cargo.toml @@ -25,7 +25,6 @@ frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -37,7 +36,6 @@ std = [ "scale-info/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/examples/default-config/src/lib.rs b/substrate/frame/examples/default-config/src/lib.rs index 5b66c78e06283..ccdcd4968598d 100644 --- a/substrate/frame/examples/default-config/src/lib.rs +++ b/substrate/frame/examples/default-config/src/lib.rs @@ -32,6 +32,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[frame_support::pallet] pub mod pallet { use frame_support::pallet_prelude::*; @@ -189,7 +191,7 @@ pub mod tests { } parameter_types! { - pub const SomeCall: RuntimeCall = RuntimeCall::System(frame_system::Call::::remark { remark: vec![] }); + pub const SomeCall: RuntimeCall = RuntimeCall::System(frame_system::Call::::remark { remark: alloc::vec![] }); } #[derive_impl(TestDefaultConfig as pallet::DefaultConfig)] diff --git a/substrate/frame/examples/dev-mode/Cargo.toml b/substrate/frame/examples/dev-mode/Cargo.toml index 1dd033d7e071e..c3dd7f26f21d4 100644 --- a/substrate/frame/examples/dev-mode/Cargo.toml +++ b/substrate/frame/examples/dev-mode/Cargo.toml @@ -24,7 +24,6 @@ frame-system = { workspace = true } pallet-balances = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true } @@ -41,7 +40,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/examples/dev-mode/src/lib.rs b/substrate/frame/examples/dev-mode/src/lib.rs index 15f1a4b5d6199..eb94c024280c7 100644 --- a/substrate/frame/examples/dev-mode/src/lib.rs +++ b/substrate/frame/examples/dev-mode/src/lib.rs @@ -28,9 +28,11 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{vec, vec::Vec}; use frame_support::dispatch::DispatchResult; use frame_system::ensure_signed; -use sp_std::{vec, vec::Vec}; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; diff --git a/substrate/frame/examples/kitchensink/Cargo.toml b/substrate/frame/examples/kitchensink/Cargo.toml index b3869dff94142..f1f9fdb492d9c 100644 --- a/substrate/frame/examples/kitchensink/Cargo.toml +++ b/substrate/frame/examples/kitchensink/Cargo.toml @@ -25,7 +25,6 @@ frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } frame-benchmarking = { optional = true, workspace = true } @@ -47,7 +46,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/examples/kitchensink/src/lib.rs b/substrate/frame/examples/kitchensink/src/lib.rs index b7425b0c0846a..442318565426e 100644 --- a/substrate/frame/examples/kitchensink/src/lib.rs +++ b/substrate/frame/examples/kitchensink/src/lib.rs @@ -42,6 +42,8 @@ use sp_runtime::TryRuntimeError; pub mod weights; pub use weights::*; +extern crate alloc; + #[frame_support::pallet] pub mod pallet { use super::*; diff --git a/substrate/frame/examples/offchain-worker/Cargo.toml b/substrate/frame/examples/offchain-worker/Cargo.toml index f8ccd1f04e475..179a658de312d 100644 --- a/substrate/frame/examples/offchain-worker/Cargo.toml +++ b/substrate/frame/examples/offchain-worker/Cargo.toml @@ -27,7 +27,6 @@ sp-core = { workspace = true } sp-io = { workspace = true } sp-keystore = { optional = true, workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -42,7 +41,6 @@ std = [ "sp-io/std", "sp-keystore/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/examples/offchain-worker/src/lib.rs b/substrate/frame/examples/offchain-worker/src/lib.rs index 0a90e896188eb..add014f6b34a9 100644 --- a/substrate/frame/examples/offchain-worker/src/lib.rs +++ b/substrate/frame/examples/offchain-worker/src/lib.rs @@ -45,6 +45,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::traits::Get; use frame_system::{ @@ -67,7 +70,6 @@ use sp_runtime::{ transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction}, RuntimeDebug, }; -use sp_std::vec::Vec; #[cfg(test)] mod tests; @@ -606,7 +608,7 @@ impl Pallet { let body = response.body().collect::>(); // Create a str slice from the body. - let body_str = sp_std::str::from_utf8(&body).map_err(|_| { + let body_str = alloc::str::from_utf8(&body).map_err(|_| { log::warn!("No UTF8 body"); http::Error::Unknown })?; diff --git a/substrate/frame/examples/offchain-worker/src/tests.rs b/substrate/frame/examples/offchain-worker/src/tests.rs index e2c57a8c1e1ab..b665cbbb62aed 100644 --- a/substrate/frame/examples/offchain-worker/src/tests.rs +++ b/substrate/frame/examples/offchain-worker/src/tests.rs @@ -375,7 +375,7 @@ fn price_oracle_response(state: &mut testing::OffchainState) { #[test] fn parse_price_works() { - let test_data = vec![ + let test_data = alloc::vec![ ("{\"USD\":6536.92}", Some(653692)), ("{\"USD\":65.92}", Some(6592)), ("{\"USD\":6536.924565}", Some(653692)), diff --git a/substrate/frame/examples/single-block-migrations/Cargo.toml b/substrate/frame/examples/single-block-migrations/Cargo.toml index a6cf020ce535d..2d524f2caa269 100644 --- a/substrate/frame/examples/single-block-migrations/Cargo.toml +++ b/substrate/frame/examples/single-block-migrations/Cargo.toml @@ -22,7 +22,6 @@ frame-executive = { workspace = true } frame-system = { workspace = true } frame-try-runtime = { optional = true, workspace = true } pallet-balances = { workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } @@ -42,7 +41,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-version/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/examples/single-block-migrations/src/lib.rs b/substrate/frame/examples/single-block-migrations/src/lib.rs index 411537aa8c65f..07c7199b93223 100644 --- a/substrate/frame/examples/single-block-migrations/src/lib.rs +++ b/substrate/frame/examples/single-block-migrations/src/lib.rs @@ -156,6 +156,9 @@ pub use pallet::*; pub mod migrations; #[doc(hidden)] mod mock; + +extern crate alloc; + use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::traits::StorageVersion; use sp_runtime::RuntimeDebug; diff --git a/substrate/frame/examples/single-block-migrations/src/migrations/v1.rs b/substrate/frame/examples/single-block-migrations/src/migrations/v1.rs index 7b543d72c9840..55cf7cef9a7a8 100644 --- a/substrate/frame/examples/single-block-migrations/src/migrations/v1.rs +++ b/substrate/frame/examples/single-block-migrations/src/migrations/v1.rs @@ -21,7 +21,7 @@ use frame_support::{ }; #[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; +use alloc::vec::Vec; /// Collection of storage item formats from the previous storage version. /// @@ -41,7 +41,7 @@ mod v0 { /// /// In this migration, update the on-chain storage for the pallet to reflect the new storage /// layout. -pub struct InnerMigrateV0ToV1(sp_std::marker::PhantomData); +pub struct InnerMigrateV0ToV1(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for InnerMigrateV0ToV1 { /// Return the existing [`crate::Value`] so we can check that it was correctly set in diff --git a/substrate/frame/examples/split/Cargo.toml b/substrate/frame/examples/split/Cargo.toml index d8a8c6869ab5f..9542902bae64b 100644 --- a/substrate/frame/examples/split/Cargo.toml +++ b/substrate/frame/examples/split/Cargo.toml @@ -25,7 +25,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } -sp-std = { workspace = true } frame-benchmarking = { optional = true, workspace = true } @@ -43,7 +42,6 @@ std = [ "scale-info/std", "sp-core/std", "sp-io/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/examples/tasks/Cargo.toml b/substrate/frame/examples/tasks/Cargo.toml index 1ca62fd89943e..00695ceddf197 100644 --- a/substrate/frame/examples/tasks/Cargo.toml +++ b/substrate/frame/examples/tasks/Cargo.toml @@ -24,7 +24,6 @@ frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-core = { workspace = true } frame-benchmarking = { optional = true, workspace = true } @@ -41,7 +40,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/executive/Cargo.toml b/substrate/frame/executive/Cargo.toml index 0f9741eec180d..78d9ea6fa4992 100644 --- a/substrate/frame/executive/Cargo.toml +++ b/substrate/frame/executive/Cargo.toml @@ -28,7 +28,6 @@ frame-try-runtime = { optional = true, workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-tracing = { workspace = true } [dev-dependencies] @@ -57,7 +56,6 @@ std = [ "sp-inherents/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-tracing/std", "sp-version/std", ] diff --git a/substrate/frame/executive/src/lib.rs b/substrate/frame/executive/src/lib.rs index 3028eaf318e08..1e7bac64e18fd 100644 --- a/substrate/frame/executive/src/lib.rs +++ b/substrate/frame/executive/src/lib.rs @@ -151,7 +151,10 @@ pub mod block_flowchart {} #[cfg(test)] mod tests; +extern crate alloc; + use codec::{Codec, Encode}; +use core::marker::PhantomData; use frame_support::{ defensive_assert, dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, PostDispatchInfo}, @@ -174,7 +177,6 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, ExtrinsicInclusionMode, }; -use sp_std::{marker::PhantomData, prelude::*}; #[cfg(feature = "try-runtime")] use ::{ @@ -467,7 +469,7 @@ where /// Logs the result of trying to decode the entire state. fn log_decode_result( - res: Result>, + res: Result>, ) -> Result<(), TryRuntimeError> { match res { Ok(bytes) => { diff --git a/substrate/frame/fast-unstake/Cargo.toml b/substrate/frame/fast-unstake/Cargo.toml index 59676ad399519..2b188bad1dfa7 100644 --- a/substrate/frame/fast-unstake/Cargo.toml +++ b/substrate/frame/fast-unstake/Cargo.toml @@ -24,7 +24,6 @@ frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-staking = { workspace = true } frame-election-provider-support = { workspace = true } @@ -58,7 +57,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", "sp-tracing/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/fast-unstake/src/benchmarking.rs b/substrate/frame/fast-unstake/src/benchmarking.rs index 4828dcb9b42cb..d01ff715ca4fc 100644 --- a/substrate/frame/fast-unstake/src/benchmarking.rs +++ b/substrate/frame/fast-unstake/src/benchmarking.rs @@ -20,6 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use crate::{types::*, Pallet as FastUnstake, *}; +use alloc::{vec, vec::Vec}; use frame_benchmarking::v1::{benchmarks, whitelist_account, BenchmarkError}; use frame_support::{ assert_ok, @@ -28,7 +29,6 @@ use frame_support::{ use frame_system::RawOrigin; use sp_runtime::traits::Zero; use sp_staking::{EraIndex, StakingInterface}; -use sp_std::prelude::*; const USER_SEED: u32 = 0; diff --git a/substrate/frame/fast-unstake/src/lib.rs b/substrate/frame/fast-unstake/src/lib.rs index f31c9c640260b..41920907bd57b 100644 --- a/substrate/frame/fast-unstake/src/lib.rs +++ b/substrate/frame/fast-unstake/src/lib.rs @@ -112,6 +112,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + pub use pallet::*; #[cfg(test)] @@ -150,6 +152,7 @@ macro_rules! log { pub mod pallet { use super::*; use crate::types::*; + use alloc::vec::Vec; use frame_support::{ pallet_prelude::*, traits::{Defensive, ReservableCurrency, StorageVersion}, @@ -157,7 +160,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; use sp_runtime::{traits::Zero, DispatchResult}; use sp_staking::{EraIndex, StakingInterface}; - use sp_std::{prelude::*, vec::Vec}; pub use weights::WeightInfo; #[cfg(feature = "try-runtime")] diff --git a/substrate/frame/fast-unstake/src/migrations.rs b/substrate/frame/fast-unstake/src/migrations.rs index 97ad86bfff42b..1a873534ac819 100644 --- a/substrate/frame/fast-unstake/src/migrations.rs +++ b/substrate/frame/fast-unstake/src/migrations.rs @@ -17,20 +17,20 @@ pub mod v1 { use crate::{types::BalanceOf, *}; + use alloc::vec::Vec; use frame_support::{ storage::unhashed, traits::{Defensive, Get, GetStorageVersion, OnRuntimeUpgrade}, weights::Weight, }; use sp_staking::EraIndex; - use sp_std::prelude::*; #[cfg(feature = "try-runtime")] use frame_support::ensure; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; - pub struct MigrateToV1(sp_std::marker::PhantomData); + pub struct MigrateToV1(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { fn on_runtime_upgrade() -> Weight { let current = Pallet::::in_code_storage_version(); diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index 7ce7fee141078..757052e230a18 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -26,7 +26,6 @@ use frame_support::{ use sp_runtime::{traits::IdentityLookup, BuildStorage}; use pallet_staking::{Exposure, IndividualExposure, StakerStatus}; -use sp_std::prelude::*; pub type AccountId = u128; pub type BlockNumber = u64; diff --git a/substrate/frame/fast-unstake/src/types.rs b/substrate/frame/fast-unstake/src/types.rs index 3fb5720861fa8..2a2319ef61296 100644 --- a/substrate/frame/fast-unstake/src/types.rs +++ b/substrate/frame/fast-unstake/src/types.rs @@ -24,7 +24,6 @@ use frame_support::{ }; use scale_info::TypeInfo; use sp_staking::{EraIndex, StakingInterface}; -use sp_std::prelude::*; /// Maximum number of eras that we might check for a single staker. /// @@ -32,7 +31,7 @@ use sp_std::prelude::*; #[derive(scale_info::TypeInfo, codec::Encode, codec::Decode, codec::MaxEncodedLen)] #[codec(mel_bound(T: Config))] #[scale_info(skip_type_params(T))] -pub struct MaxChecking(sp_std::marker::PhantomData); +pub struct MaxChecking(core::marker::PhantomData); impl frame_support::traits::Get for MaxChecking { fn get() -> u32 { T::Staking::bonding_duration() + 1 diff --git a/substrate/frame/glutton/Cargo.toml b/substrate/frame/glutton/Cargo.toml index 58faecde62939..5a73e8caef8ea 100644 --- a/substrate/frame/glutton/Cargo.toml +++ b/substrate/frame/glutton/Cargo.toml @@ -26,7 +26,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-inherents = { workspace = true } [dev-dependencies] @@ -47,7 +46,6 @@ std = [ "sp-inherents/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/glutton/src/lib.rs b/substrate/frame/glutton/src/lib.rs index 5427173b486ba..c8d2981ebfef1 100644 --- a/substrate/frame/glutton/src/lib.rs +++ b/substrate/frame/glutton/src/lib.rs @@ -35,12 +35,14 @@ mod mock; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use blake2::{Blake2b512, Digest}; use frame_support::{pallet_prelude::*, weights::WeightMeter, DefaultNoBound}; use frame_system::pallet_prelude::*; use sp_io::hashing::twox_256; use sp_runtime::{traits::Zero, FixedPointNumber, FixedU64}; -use sp_std::{vec, vec::Vec}; pub use pallet::*; pub use weights::WeightInfo; @@ -162,7 +164,7 @@ pub mod pallet { pub block_length: FixedU64, #[serde(skip)] /// The required configuration field. - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] diff --git a/substrate/frame/grandpa/Cargo.toml b/substrate/frame/grandpa/Cargo.toml index e08af3a5e91b3..e24f9a51db842 100644 --- a/substrate/frame/grandpa/Cargo.toml +++ b/substrate/frame/grandpa/Cargo.toml @@ -31,7 +31,6 @@ sp-io = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-session = { workspace = true } sp-staking = { features = ["serde"], workspace = true } -sp-std = { workspace = true } [dev-dependencies] finality-grandpa = { features = ["derive-codec"], workspace = true, default-features = true } @@ -67,7 +66,6 @@ std = [ "sp-runtime/std", "sp-session/std", "sp-staking/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/grandpa/src/equivocation.rs b/substrate/frame/grandpa/src/equivocation.rs index 16727f79a58d5..b213c1ceb7219 100644 --- a/substrate/frame/grandpa/src/equivocation.rs +++ b/substrate/frame/grandpa/src/equivocation.rs @@ -35,6 +35,7 @@ //! that the `ValidateUnsigned` for the GRANDPA pallet is used in the runtime //! definition. +use alloc::{boxed::Box, vec, vec::Vec}; use codec::{self as codec, Decode, Encode}; use frame_support::traits::{Get, KeyOwnerProofSystem}; use frame_system::pallet_prelude::BlockNumberFor; @@ -52,7 +53,6 @@ use sp_staking::{ offence::{Kind, Offence, OffenceReportSystem, ReportOffence}, SessionIndex, }; -use sp_std::prelude::*; use super::{Call, Config, Error, Pallet, LOG_TARGET}; @@ -114,7 +114,7 @@ impl Offence for EquivocationOffence { /// - On-chain validity checks and processing are mostly delegated to the user provided generic /// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits. /// - Offence reporter for unsigned transactions is fetched via the the authorship pallet. -pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); +pub struct EquivocationReportSystem(core::marker::PhantomData<(T, R, P, L)>); impl OffenceReportSystem< diff --git a/substrate/frame/grandpa/src/lib.rs b/substrate/frame/grandpa/src/lib.rs index 90bcd8721dfa1..4f69aeaef5236 100644 --- a/substrate/frame/grandpa/src/lib.rs +++ b/substrate/frame/grandpa/src/lib.rs @@ -28,11 +28,14 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + // Re-export since this is necessary for `impl_apis` in runtime. pub use sp_consensus_grandpa::{ self as fg_primitives, AuthorityId, AuthorityList, AuthorityWeight, }; +use alloc::{boxed::Box, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, @@ -50,7 +53,6 @@ use sp_consensus_grandpa::{ use sp_runtime::{generic::DigestItem, traits::Zero, DispatchResult}; use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::{offence::OffenceReportSystem, SessionIndex}; -use sp_std::prelude::*; mod default_weights; mod equivocation; @@ -351,7 +353,7 @@ pub mod pallet { pub struct GenesisConfig { pub authorities: AuthorityList, #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] diff --git a/substrate/frame/grandpa/src/migrations/v5.rs b/substrate/frame/grandpa/src/migrations/v5.rs index a0865a3f2bf9a..f1af0af42dd0a 100644 --- a/substrate/frame/grandpa/src/migrations/v5.rs +++ b/substrate/frame/grandpa/src/migrations/v5.rs @@ -16,7 +16,9 @@ // limitations under the License. use crate::{BoundedAuthorityList, Pallet}; +use alloc::vec::Vec; use codec::Decode; +use core::marker::PhantomData; use frame_support::{ migrations::VersionedMigration, storage, @@ -24,7 +26,6 @@ use frame_support::{ weights::Weight, }; use sp_consensus_grandpa::AuthorityList; -use sp_std::{marker::PhantomData, vec::Vec}; const GRANDPA_AUTHORITIES_KEY: &[u8] = b":grandpa_authorities"; diff --git a/substrate/frame/identity/Cargo.toml b/substrate/frame/identity/Cargo.toml index d0b796cd75d35..6794fbfbbf42b 100644 --- a/substrate/frame/identity/Cargo.toml +++ b/substrate/frame/identity/Cargo.toml @@ -25,7 +25,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -48,7 +47,6 @@ std = [ "sp-io/std", "sp-keystore/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/identity/src/benchmarking.rs b/substrate/frame/identity/src/benchmarking.rs index 957549b19f859..ab04000c2281b 100644 --- a/substrate/frame/identity/src/benchmarking.rs +++ b/substrate/frame/identity/src/benchmarking.rs @@ -22,6 +22,7 @@ use super::*; use crate::Pallet as Identity; +use alloc::{vec, vec::Vec}; use frame_benchmarking::{account, v2::*, whitelisted_caller, BenchmarkError}; use frame_support::{ assert_ok, ensure, diff --git a/substrate/frame/identity/src/legacy.rs b/substrate/frame/identity/src/legacy.rs index 60e812c2238b2..c2107e9290385 100644 --- a/substrate/frame/identity/src/legacy.rs +++ b/substrate/frame/identity/src/legacy.rs @@ -15,6 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#[cfg(feature = "runtime-benchmarks")] +use alloc::vec; use codec::{Decode, Encode, MaxEncodedLen}; #[cfg(feature = "runtime-benchmarks")] use enumflags2::BitFlag; @@ -22,7 +24,6 @@ use enumflags2::{bitflags, BitFlags}; use frame_support::{traits::Get, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound}; use scale_info::{build::Variants, Path, Type, TypeInfo}; use sp_runtime::{BoundedVec, RuntimeDebug}; -use sp_std::prelude::*; use crate::types::{Data, IdentityInformationProvider}; diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 50d6de32ac61e..776a08f5e9e8a 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -101,7 +101,10 @@ mod tests; mod types; pub mod weights; +extern crate alloc; + use crate::types::{AuthorityPropertiesOf, Suffix, Username}; +use alloc::{boxed::Box, vec::Vec}; use codec::Encode; use frame_support::{ ensure, @@ -113,7 +116,6 @@ pub use pallet::*; use sp_runtime::traits::{ AppendZerosInput, Hash, IdentifyAccount, Saturating, StaticLookup, Verify, Zero, }; -use sp_std::prelude::*; pub use types::{ Data, IdentityInformationProvider, Judgement, RegistrarIndex, RegistrarInfo, Registration, }; diff --git a/substrate/frame/identity/src/types.rs b/substrate/frame/identity/src/types.rs index 10f0db8c25d8f..45401d53e9e90 100644 --- a/substrate/frame/identity/src/types.rs +++ b/substrate/frame/identity/src/types.rs @@ -16,7 +16,9 @@ // limitations under the License. use super::*; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; +use core::{fmt::Debug, iter::once, ops::Add}; use frame_support::{ traits::{ConstU32, Get}, BoundedVec, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound, @@ -29,7 +31,6 @@ use sp_runtime::{ traits::{Member, Zero}, RuntimeDebug, }; -use sp_std::{fmt::Debug, iter::once, ops::Add, prelude::*}; /// An identifier for a single name registrar/identity verification service. pub type RegistrarIndex = u32; @@ -65,7 +66,7 @@ impl Data { } impl Decode for Data { - fn decode(input: &mut I) -> sp_std::result::Result { + fn decode(input: &mut I) -> core::result::Result { let b = input.read_byte()?; Ok(match b { 0 => Data::None, @@ -295,7 +296,7 @@ impl< IdentityInfo: IdentityInformationProvider, > Decode for Registration { - fn decode(input: &mut I) -> sp_std::result::Result { + fn decode(input: &mut I) -> core::result::Result { let (judgements, deposit, info) = Decode::decode(&mut AppendZerosInput::new(input))?; Ok(Self { judgements, deposit, info }) } diff --git a/substrate/frame/im-online/Cargo.toml b/substrate/frame/im-online/Cargo.toml index 85cbcb3941b17..2cb03b57d6ca8 100644 --- a/substrate/frame/im-online/Cargo.toml +++ b/substrate/frame/im-online/Cargo.toml @@ -28,7 +28,6 @@ sp-core = { features = ["serde"], workspace = true } sp-io = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-staking = { features = ["serde"], workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-session = { workspace = true, default-features = true } @@ -49,7 +48,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/im-online/src/lib.rs b/substrate/frame/im-online/src/lib.rs index f91a473e53d53..ee2a8451d6fb7 100644 --- a/substrate/frame/im-online/src/lib.rs +++ b/substrate/frame/im-online/src/lib.rs @@ -82,6 +82,9 @@ mod mock; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ pallet_prelude::*, @@ -107,7 +110,6 @@ use sp_staking::{ offence::{Kind, Offence, ReportOffence}, SessionIndex, }; -use sp_std::prelude::*; pub use weights::WeightInfo; pub mod sr25519 { @@ -196,8 +198,8 @@ enum OffchainErr { SubmitTransaction, } -impl sp_std::fmt::Debug for OffchainErr { - fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { +impl core::fmt::Debug for OffchainErr { + fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { match *self { OffchainErr::TooEarly => write!(fmt, "Too early to send heartbeat."), OffchainErr::WaitingForInclusion(ref block) => { diff --git a/substrate/frame/im-online/src/migration.rs b/substrate/frame/im-online/src/migration.rs index 754a2e672e6cf..6d3a5cda69735 100644 --- a/substrate/frame/im-online/src/migration.rs +++ b/substrate/frame/im-online/src/migration.rs @@ -18,6 +18,7 @@ //! Storage migrations for the im-online pallet. use super::*; +use alloc::vec::Vec; use frame_support::{storage_alias, traits::OnRuntimeUpgrade}; #[cfg(feature = "try-runtime")] diff --git a/substrate/frame/indices/Cargo.toml b/substrate/frame/indices/Cargo.toml index 20c3863ff99b0..ea17048153126 100644 --- a/substrate/frame/indices/Cargo.toml +++ b/substrate/frame/indices/Cargo.toml @@ -25,7 +25,6 @@ sp-core = { workspace = true } sp-io = { workspace = true } sp-keyring = { optional = true, workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -44,7 +43,6 @@ std = [ "sp-keyring", "sp-keyring?/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/indices/src/lib.rs b/substrate/frame/indices/src/lib.rs index ff12d092cfb8d..740d69365df3e 100644 --- a/substrate/frame/indices/src/lib.rs +++ b/substrate/frame/indices/src/lib.rs @@ -25,13 +25,15 @@ mod mock; mod tests; pub mod weights; +extern crate alloc; + +use alloc::vec::Vec; use codec::Codec; use frame_support::traits::{BalanceStatus::Reserved, Currency, ReservableCurrency}; use sp_runtime::{ traits::{AtLeast32Bit, LookupError, Saturating, StaticLookup, Zero}, MultiAddress, }; -use sp_std::prelude::*; pub use weights::WeightInfo; type BalanceOf = diff --git a/substrate/frame/insecure-randomness-collective-flip/Cargo.toml b/substrate/frame/insecure-randomness-collective-flip/Cargo.toml index 0da0d5373953b..977b9fdb6f606 100644 --- a/substrate/frame/insecure-randomness-collective-flip/Cargo.toml +++ b/substrate/frame/insecure-randomness-collective-flip/Cargo.toml @@ -22,7 +22,6 @@ scale-info = { features = ["derive"], workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true, default-features = true } @@ -39,7 +38,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/lottery/Cargo.toml b/substrate/frame/lottery/Cargo.toml index 34d1728e42ed0..0a33e54a825de 100644 --- a/substrate/frame/lottery/Cargo.toml +++ b/substrate/frame/lottery/Cargo.toml @@ -23,7 +23,6 @@ frame-benchmarking = { optional = true, workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] frame-support-test = { workspace = true } @@ -44,7 +43,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/lottery/src/benchmarking.rs b/substrate/frame/lottery/src/benchmarking.rs index 123b425b976f3..046bc0acbb644 100644 --- a/substrate/frame/lottery/src/benchmarking.rs +++ b/substrate/frame/lottery/src/benchmarking.rs @@ -22,6 +22,7 @@ use super::*; use crate::Pallet as Lottery; +use alloc::{boxed::Box, vec}; use frame_benchmarking::{ v1::{account, whitelisted_caller, BenchmarkError}, v2::*, diff --git a/substrate/frame/lottery/src/lib.rs b/substrate/frame/lottery/src/lib.rs index 54a8edd38606d..0071b258fc45c 100644 --- a/substrate/frame/lottery/src/lib.rs +++ b/substrate/frame/lottery/src/lib.rs @@ -54,6 +54,9 @@ mod mock; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{boxed::Box, vec::Vec}; use codec::{Decode, Encode}; use frame_support::{ dispatch::{DispatchResult, GetDispatchInfo}, @@ -68,7 +71,6 @@ use sp_runtime::{ traits::{AccountIdConversion, Dispatchable, Saturating, Zero}, ArithmeticError, DispatchError, RuntimeDebug, }; -use sp_std::prelude::*; pub use weights::WeightInfo; type BalanceOf = diff --git a/substrate/frame/membership/Cargo.toml b/substrate/frame/membership/Cargo.toml index 35b0eeaa71419..0fc5ce02809e1 100644 --- a/substrate/frame/membership/Cargo.toml +++ b/substrate/frame/membership/Cargo.toml @@ -25,7 +25,6 @@ frame-system = { workspace = true } sp-core = { features = ["serde"], workspace = true } sp-io = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -39,7 +38,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index d5dad68e811b0..e38a6ba5d931b 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -23,12 +23,14 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use frame_support::{ traits::{ChangeMembers, Contains, ContainsLengthBound, Get, InitializeMembers, SortedMembers}, BoundedVec, }; use sp_runtime::traits::{StaticLookup, UniqueSaturatedInto}; -use sp_std::prelude::*; pub mod migrations; pub mod weights; @@ -113,7 +115,7 @@ pub mod pallet { #[pallet::genesis_build] impl, I: 'static> BuildGenesisConfig for GenesisConfig { fn build(&self) { - use sp_std::collections::btree_set::BTreeSet; + use alloc::collections::btree_set::BTreeSet; let members_set: BTreeSet<_> = self.members.iter().collect(); assert_eq!( members_set.len(), diff --git a/substrate/frame/merkle-mountain-range/Cargo.toml b/substrate/frame/merkle-mountain-range/Cargo.toml index 27ba77e5a62a9..b8a9b6065c6cd 100644 --- a/substrate/frame/merkle-mountain-range/Cargo.toml +++ b/substrate/frame/merkle-mountain-range/Cargo.toml @@ -25,7 +25,6 @@ sp-core = { workspace = true } sp-io = { workspace = true } sp-mmr-primitives = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] array-bytes = { workspace = true, default-features = true } @@ -45,7 +44,6 @@ std = [ "sp-io/std", "sp-mmr-primitives/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/merkle-mountain-range/src/lib.rs b/substrate/frame/merkle-mountain-range/src/lib.rs index 47a325db605d8..cacb33b504347 100644 --- a/substrate/frame/merkle-mountain-range/src/lib.rs +++ b/substrate/frame/merkle-mountain-range/src/lib.rs @@ -56,6 +56,9 @@ //! NOTE This pallet is experimental and not proven to work in production. #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use frame_support::weights::Weight; use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor}; use log; @@ -64,7 +67,6 @@ use sp_runtime::{ traits::{self, One, Saturating}, SaturatedConversion, }; -use sp_std::prelude::*; pub use pallet::*; pub use sp_mmr_primitives::{ @@ -89,7 +91,7 @@ mod tests; /// is not available (since the block is not finished yet), /// we use the `parent_hash` here along with parent block number. pub struct ParentNumberAndHash { - _phantom: sp_std::marker::PhantomData, + _phantom: core::marker::PhantomData, } impl LeafDataProvider for ParentNumberAndHash { @@ -110,7 +112,7 @@ pub trait BlockHashProvider { /// Default implementation of BlockHashProvider using frame_system. pub struct DefaultBlockHashProvider { - _phantom: sp_std::marker::PhantomData, + _phantom: core::marker::PhantomData, } impl BlockHashProvider, T::Hash> @@ -302,7 +304,7 @@ impl, I: 'static> Pallet { fn node_temp_offchain_key( pos: NodeIndex, parent_hash: ::Hash, - ) -> sp_std::prelude::Vec { + ) -> Vec { NodesUtils::node_temp_offchain_key::>(&T::INDEXING_PREFIX, pos, parent_hash) } @@ -311,7 +313,7 @@ impl, I: 'static> Pallet { /// Used for nodes added by now finalized blocks. /// Never read keys using `node_canon_offchain_key` unless you sure that /// there's no `node_offchain_key` key in the storage. - fn node_canon_offchain_key(pos: NodeIndex) -> sp_std::prelude::Vec { + fn node_canon_offchain_key(pos: NodeIndex) -> Vec { NodesUtils::node_canon_offchain_key(&T::INDEXING_PREFIX, pos) } diff --git a/substrate/frame/merkle-mountain-range/src/mmr/mmr.rs b/substrate/frame/merkle-mountain-range/src/mmr/mmr.rs index 8a99f4d87deb0..2b46357c50723 100644 --- a/substrate/frame/merkle-mountain-range/src/mmr/mmr.rs +++ b/substrate/frame/merkle-mountain-range/src/mmr/mmr.rs @@ -23,8 +23,8 @@ use crate::{ primitives::{self, Error, NodeIndex}, Config, HashOf, HashingOf, }; +use alloc::vec::Vec; use sp_mmr_primitives::{mmr_lib, mmr_lib::MMRStoreReadOps, utils::NodesUtils, LeafIndex}; -use sp_std::prelude::*; /// Stateless verification of the proof for a batch of leaves. /// Note, the leaves should be sorted such that corresponding leaves and leaf indices have the diff --git a/substrate/frame/merkle-mountain-range/src/mmr/storage.rs b/substrate/frame/merkle-mountain-range/src/mmr/storage.rs index e27440be35c45..a390898014846 100644 --- a/substrate/frame/merkle-mountain-range/src/mmr/storage.rs +++ b/substrate/frame/merkle-mountain-range/src/mmr/storage.rs @@ -17,14 +17,13 @@ //! An MMR storage implementation. +use alloc::{vec, vec::Vec}; use codec::Encode; +use core::iter::Peekable; use log::{debug, trace}; use sp_core::offchain::StorageKind; use sp_io::offchain_index; use sp_mmr_primitives::{mmr_lib, mmr_lib::helper, utils::NodesUtils}; -use sp_std::iter::Peekable; -#[cfg(not(feature = "std"))] -use sp_std::prelude::*; use crate::{ mmr::{Node, NodeOf}, @@ -52,7 +51,7 @@ pub struct OffchainStorage; /// /// There are two different implementations depending on the use case. /// See docs for [RuntimeStorage] and [OffchainStorage]. -pub struct Storage(sp_std::marker::PhantomData<(StorageType, T, I, L)>); +pub struct Storage(core::marker::PhantomData<(StorageType, T, I, L)>); impl Default for Storage { fn default() -> Self { diff --git a/substrate/frame/message-queue/Cargo.toml b/substrate/frame/message-queue/Cargo.toml index 5ced1a4e08ff9..0c3bbb2c883c5 100644 --- a/substrate/frame/message-queue/Cargo.toml +++ b/substrate/frame/message-queue/Cargo.toml @@ -21,7 +21,6 @@ environmental = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-arithmetic = { workspace = true } sp-weights = { workspace = true } @@ -49,7 +48,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-tracing/std", "sp-weights/std", ] diff --git a/substrate/frame/message-queue/src/benchmarking.rs b/substrate/frame/message-queue/src/benchmarking.rs index 7e99bc0585845..8f0712acc5f51 100644 --- a/substrate/frame/message-queue/src/benchmarking.rs +++ b/substrate/frame/message-queue/src/benchmarking.rs @@ -26,7 +26,6 @@ use frame_benchmarking::v2::*; use frame_support::traits::Get; use frame_system::RawOrigin; use sp_io::hashing::blake2_256; -use sp_std::prelude::*; #[benchmarks( where diff --git a/substrate/frame/message-queue/src/lib.rs b/substrate/frame/message-queue/src/lib.rs index ef3420d21be52..2dbffef7e5a24 100644 --- a/substrate/frame/message-queue/src/lib.rs +++ b/substrate/frame/message-queue/src/lib.rs @@ -203,7 +203,11 @@ pub mod mock_helpers; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{vec, vec::Vec}; use codec::{Codec, Decode, Encode, MaxEncodedLen}; +use core::{fmt::Debug, ops::Deref}; use frame_support::{ defensive, pallet_prelude::*, @@ -223,7 +227,6 @@ use sp_runtime::{ traits::{One, Zero}, SaturatedConversion, Saturating, }; -use sp_std::{fmt::Debug, ops::Deref, prelude::*, vec}; use sp_weights::WeightMeter; pub use weights::WeightInfo; @@ -307,7 +310,7 @@ impl< return Err(()) } - let mut heap = sp_std::mem::take(&mut self.heap).into_inner(); + let mut heap = core::mem::take(&mut self.heap).into_inner(); header.using_encoded(|h| heap.extend_from_slice(h)); heap.extend_from_slice(message.deref()); self.heap = BoundedVec::defensive_truncate_from(heap); @@ -1509,7 +1512,7 @@ pub(crate) fn with_service_mutex R, R>(f: F) -> Result { } /// Provides a [`sp_core::Get`] to access the `MEL` of a [`codec::MaxEncodedLen`] type. -pub struct MaxEncodedLenOf(sp_std::marker::PhantomData); +pub struct MaxEncodedLenOf(core::marker::PhantomData); impl Get for MaxEncodedLenOf { fn get() -> u32 { T::max_encoded_len() as u32 @@ -1518,7 +1521,7 @@ impl Get for MaxEncodedLenOf { /// Calculates the maximum message length and exposed it through the [`codec::MaxEncodedLen`] trait. pub struct MaxMessageLen( - sp_std::marker::PhantomData<(Origin, Size, HeapSize)>, + core::marker::PhantomData<(Origin, Size, HeapSize)>, ); impl, HeapSize: Get> Get for MaxMessageLen @@ -1544,7 +1547,7 @@ pub type BookStateOf = BookState>; /// Converts a [`sp_core::Get`] with returns a type that can be cast into an `u32` into a `Get` /// which returns an `u32`. -pub struct IntoU32(sp_std::marker::PhantomData<(T, O)>); +pub struct IntoU32(core::marker::PhantomData<(T, O)>); impl, O: Into> Get for IntoU32 { fn get() -> u32 { T::get().into() diff --git a/substrate/frame/message-queue/src/mock.rs b/substrate/frame/message-queue/src/mock.rs index 66a242d5a18ff..26533cc7c330c 100644 --- a/substrate/frame/message-queue/src/mock.rs +++ b/substrate/frame/message-queue/src/mock.rs @@ -23,9 +23,9 @@ pub use super::mock_helpers::*; use super::*; use crate as pallet_message_queue; +use alloc::collections::btree_map::BTreeMap; use frame_support::{derive_impl, parameter_types}; use sp_runtime::BuildStorage; -use sp_std::collections::btree_map::BTreeMap; type Block = frame_system::mocking::MockBlock; diff --git a/substrate/frame/message-queue/src/mock_helpers.rs b/substrate/frame/message-queue/src/mock_helpers.rs index 28395e27cdd2a..873add776e209 100644 --- a/substrate/frame/message-queue/src/mock_helpers.rs +++ b/substrate/frame/message-queue/src/mock_helpers.rs @@ -22,6 +22,7 @@ //! Cannot be put into mock.rs since benchmarks require no-std and mock.rs is std. use crate::*; +use alloc::vec::Vec; use frame_support::traits::Defensive; /// Converts `Self` into a `Weight` by using `Self` for all components. diff --git a/substrate/frame/migrations/Cargo.toml b/substrate/frame/migrations/Cargo.toml index 5a946d3aa0581..5fbed74a44007 100644 --- a/substrate/frame/migrations/Cargo.toml +++ b/substrate/frame/migrations/Cargo.toml @@ -21,7 +21,6 @@ frame-benchmarking = { optional = true, workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-core = { workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } [dev-dependencies] @@ -46,7 +45,6 @@ std = [ "scale-info/std", "sp-core/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/migrations/src/lib.rs b/substrate/frame/migrations/src/lib.rs index 649bc314a12b5..68041a57eaa2e 100644 --- a/substrate/frame/migrations/src/lib.rs +++ b/substrate/frame/migrations/src/lib.rs @@ -69,22 +69,22 @@ //! either be [`MigrationCursor::Active`] or [`MigrationCursor::Stuck`]. In the active case it //! points to the currently active migration and stores its inner cursor. The inner cursor can then //! be used by the migration to store its inner state and advance. Each time when the migration -//! returns `Some(cursor)`, it signals the pallet that it is not done yet. +//! returns `Some(cursor)`, it signals the pallet that it is not done yet. //! The cursor is reset on each runtime upgrade. This ensures that it starts to execute at the //! first migration in the vector. The pallets cursor is only ever incremented or set to `Stuck` //! once it encounters an error (Goal 4). Once in the stuck state, the pallet will stay stuck until -//! it is fixed through manual governance intervention. +//! it is fixed through manual governance intervention. //! As soon as the cursor of the pallet becomes `Some(_)`; [`MultiStepMigrator::ongoing`] returns //! `true` (Goal 2). This can be used by upstream code to possibly pause transactions. //! In `on_initialize` the pallet will load the current migration and check whether it was already //! executed in the past by checking for membership of its ID in the [`Historic`] set. Historic //! migrations are skipped without causing an error. Each successfully executed migration is added -//! to this set (Goal 5). +//! to this set (Goal 5). //! This proceeds until no more migrations remain. At that point, the event `UpgradeCompleted` is -//! emitted (Goal 1). +//! emitted (Goal 1). //! The execution of each migration happens by calling [`SteppedMigration::transactional_step`]. //! This function wraps the inner `step` function into a transactional layer to allow rollback in -//! the error case (Goal 6). +//! the error case (Goal 6). //! Weight limits must be checked by the migration itself. The pallet provides a [`WeightMeter`] for //! that purpose. The pallet may return [`SteppedMigrationError::InsufficientWeight`] at any point. //! In that scenario, one of two things will happen: if that migration was exclusively executed @@ -145,9 +145,12 @@ pub mod mock_helpers; mod tests; pub mod weights; +extern crate alloc; + pub use pallet::*; pub use weights::WeightInfo; +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use core::ops::ControlFlow; use frame_support::{ @@ -159,7 +162,6 @@ use frame_support::{ }; use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System}; use sp_runtime::Saturating; -use sp_std::vec::Vec; /// Points to the next migration to execute. #[derive(Debug, Clone, Eq, PartialEq, Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] diff --git a/substrate/frame/migrations/src/mock_helpers.rs b/substrate/frame/migrations/src/mock_helpers.rs index d230417d12e6c..9d3b4d1193f21 100644 --- a/substrate/frame/migrations/src/mock_helpers.rs +++ b/substrate/frame/migrations/src/mock_helpers.rs @@ -19,6 +19,7 @@ #![allow(missing_docs)] +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; use frame_support::{ migrations::*, @@ -26,7 +27,6 @@ use frame_support::{ }; use sp_core::ConstU32; use sp_runtime::BoundedVec; -use sp_std::{vec, vec::Vec}; /// Opaque identifier of a migration. pub type MockedIdentifier = BoundedVec>; diff --git a/substrate/frame/mixnet/Cargo.toml b/substrate/frame/mixnet/Cargo.toml index f3bea3d291475..a9980ac268bcb 100644 --- a/substrate/frame/mixnet/Cargo.toml +++ b/substrate/frame/mixnet/Cargo.toml @@ -28,7 +28,6 @@ sp-arithmetic = { workspace = true } sp-io = { workspace = true } sp-mixnet = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -45,7 +44,6 @@ std = [ "sp-io/std", "sp-mixnet/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/mixnet/src/lib.rs b/substrate/frame/mixnet/src/lib.rs index c7a5b624157b8..c0505a4f01057 100644 --- a/substrate/frame/mixnet/src/lib.rs +++ b/substrate/frame/mixnet/src/lib.rs @@ -21,7 +21,11 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; +use core::cmp::Ordering; use frame_support::{ traits::{EstimateNextSessionRotation, Get, OneSessionHandler}, BoundedVec, @@ -41,7 +45,6 @@ use sp_mixnet::types::{ SessionPhase, SessionStatus, KX_PUBLIC_SIZE, }; use sp_runtime::RuntimeDebug; -use sp_std::{cmp::Ordering, vec::Vec}; const LOG_TARGET: &str = "runtime::mixnet"; diff --git a/substrate/frame/multisig/Cargo.toml b/substrate/frame/multisig/Cargo.toml index 329b2e8824e24..c1571c6c0300a 100644 --- a/substrate/frame/multisig/Cargo.toml +++ b/substrate/frame/multisig/Cargo.toml @@ -23,7 +23,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } # third party log = { workspace = true } @@ -43,7 +42,6 @@ std = [ "scale-info/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/multisig/src/lib.rs b/substrate/frame/multisig/src/lib.rs index a83b78e316f50..51c36773bdad3 100644 --- a/substrate/frame/multisig/src/lib.rs +++ b/substrate/frame/multisig/src/lib.rs @@ -48,6 +48,9 @@ pub mod migrations; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::{ @@ -66,7 +69,6 @@ use sp_runtime::{ traits::{Dispatchable, TrailingZeroInput, Zero}, DispatchError, RuntimeDebug, }; -use sp_std::prelude::*; pub use weights::WeightInfo; pub use pallet::*; diff --git a/substrate/frame/nft-fractionalization/Cargo.toml b/substrate/frame/nft-fractionalization/Cargo.toml index f0613581257e9..ca2e70cbe6cef 100644 --- a/substrate/frame/nft-fractionalization/Cargo.toml +++ b/substrate/frame/nft-fractionalization/Cargo.toml @@ -25,7 +25,6 @@ frame-system = { workspace = true } pallet-assets = { workspace = true } pallet-nfts = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -48,7 +47,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/nft-fractionalization/src/benchmarking.rs b/substrate/frame/nft-fractionalization/src/benchmarking.rs index 0b54acdab49ea..811b5fe1b3177 100644 --- a/substrate/frame/nft-fractionalization/src/benchmarking.rs +++ b/substrate/frame/nft-fractionalization/src/benchmarking.rs @@ -32,7 +32,6 @@ use frame_support::{ use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin as SystemOrigin}; use pallet_nfts::{CollectionConfig, CollectionSettings, ItemConfig, MintSettings}; use sp_runtime::traits::StaticLookup; -use sp_std::prelude::*; use crate::Pallet as NftFractionalization; diff --git a/substrate/frame/nft-fractionalization/src/lib.rs b/substrate/frame/nft-fractionalization/src/lib.rs index cb269f464c48a..5fa990ecebe66 100644 --- a/substrate/frame/nft-fractionalization/src/lib.rs +++ b/substrate/frame/nft-fractionalization/src/lib.rs @@ -56,6 +56,7 @@ pub use weights::WeightInfo; #[frame_support::pallet] pub mod pallet { use super::*; + use core::fmt::Display; use frame_support::{ dispatch::DispatchResult, ensure, @@ -83,7 +84,6 @@ pub mod pallet { use frame_system::pallet_prelude::*; use scale_info::prelude::{format, string::String}; use sp_runtime::traits::{One, Zero}; - use sp_std::{fmt::Display, prelude::*}; #[pallet::pallet] pub struct Pallet(_); diff --git a/substrate/frame/nfts/Cargo.toml b/substrate/frame/nfts/Cargo.toml index a1eef3226ecf7..e3ffd971a2bb6 100644 --- a/substrate/frame/nfts/Cargo.toml +++ b/substrate/frame/nfts/Cargo.toml @@ -26,7 +26,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -47,7 +46,6 @@ std = [ "sp-io/std", "sp-keystore/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/nfts/runtime-api/Cargo.toml b/substrate/frame/nfts/runtime-api/Cargo.toml index 731f5f5ae7767..4125aa1aab00b 100644 --- a/substrate/frame/nfts/runtime-api/Cargo.toml +++ b/substrate/frame/nfts/runtime-api/Cargo.toml @@ -19,8 +19,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { features = ["derive"], workspace = true } pallet-nfts = { workspace = true } sp-api = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] -std = ["codec/std", "pallet-nfts/std", "sp-api/std", "sp-std/std"] +std = ["codec/std", "pallet-nfts/std", "sp-api/std"] diff --git a/substrate/frame/nfts/runtime-api/src/lib.rs b/substrate/frame/nfts/runtime-api/src/lib.rs index 816088f1b716a..87faa7909851e 100644 --- a/substrate/frame/nfts/runtime-api/src/lib.rs +++ b/substrate/frame/nfts/runtime-api/src/lib.rs @@ -19,8 +19,10 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode}; -use sp_std::vec::Vec; sp_api::decl_runtime_apis! { pub trait NftsApi diff --git a/substrate/frame/nfts/src/benchmarking.rs b/substrate/frame/nfts/src/benchmarking.rs index 80860bc5a53c4..bc81096b459dc 100644 --- a/substrate/frame/nfts/src/benchmarking.rs +++ b/substrate/frame/nfts/src/benchmarking.rs @@ -31,7 +31,6 @@ use frame_support::{ }; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin as SystemOrigin}; use sp_runtime::traits::{Bounded, One}; -use sp_std::prelude::*; use crate::Pallet as Nfts; diff --git a/substrate/frame/nfts/src/common_functions.rs b/substrate/frame/nfts/src/common_functions.rs index 1ad523d664c7c..2c4778c1444f7 100644 --- a/substrate/frame/nfts/src/common_functions.rs +++ b/substrate/frame/nfts/src/common_functions.rs @@ -18,6 +18,7 @@ //! Various pieces of common functionality. use crate::*; +use alloc::vec::Vec; use frame_support::pallet_prelude::*; impl, I: 'static> Pallet { diff --git a/substrate/frame/nfts/src/features/metadata.rs b/substrate/frame/nfts/src/features/metadata.rs index 85edd294d50b7..260061603e9cc 100644 --- a/substrate/frame/nfts/src/features/metadata.rs +++ b/substrate/frame/nfts/src/features/metadata.rs @@ -18,6 +18,7 @@ //! This module contains helper methods to configure the metadata of collections and items. use crate::*; +use alloc::vec::Vec; use frame_support::pallet_prelude::*; impl, I: 'static> Pallet { diff --git a/substrate/frame/nfts/src/features/roles.rs b/substrate/frame/nfts/src/features/roles.rs index f6d2785fd9cb4..aa6394f70bfd4 100644 --- a/substrate/frame/nfts/src/features/roles.rs +++ b/substrate/frame/nfts/src/features/roles.rs @@ -18,8 +18,8 @@ //! This module contains helper methods to configure account roles for existing collections. use crate::*; +use alloc::{collections::btree_map::BTreeMap, vec::Vec}; use frame_support::pallet_prelude::*; -use sp_std::collections::btree_map::BTreeMap; impl, I: 'static> Pallet { /// Set the team roles for a specific collection. diff --git a/substrate/frame/nfts/src/impl_nonfungibles.rs b/substrate/frame/nfts/src/impl_nonfungibles.rs index ee7f42cfc689c..c90655aadbfc6 100644 --- a/substrate/frame/nfts/src/impl_nonfungibles.rs +++ b/substrate/frame/nfts/src/impl_nonfungibles.rs @@ -25,7 +25,6 @@ use frame_support::{ BoundedSlice, }; use sp_runtime::{DispatchError, DispatchResult}; -use sp_std::prelude::*; impl, I: 'static> Inspect<::AccountId> for Pallet { type ItemId = T::ItemId; diff --git a/substrate/frame/nfts/src/lib.rs b/substrate/frame/nfts/src/lib.rs index 0406cac6e2c98..4e5493a3c7551 100644 --- a/substrate/frame/nfts/src/lib.rs +++ b/substrate/frame/nfts/src/lib.rs @@ -48,6 +48,9 @@ mod types; pub mod macros; pub mod weights; +extern crate alloc; + +use alloc::{boxed::Box, vec, vec::Vec}; use codec::{Decode, Encode}; use frame_support::traits::{ tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, Incrementable, @@ -58,7 +61,6 @@ use sp_runtime::{ traits::{IdentifyAccount, Saturating, StaticLookup, Verify, Zero}, RuntimeDebug, }; -use sp_std::prelude::*; pub use pallet::*; pub use types::*; diff --git a/substrate/frame/nfts/src/tests.rs b/substrate/frame/nfts/src/tests.rs index 4d23aca64ceb1..e1b598ca4261c 100644 --- a/substrate/frame/nfts/src/tests.rs +++ b/substrate/frame/nfts/src/tests.rs @@ -32,7 +32,6 @@ use sp_runtime::{ traits::{Dispatchable, IdentifyAccount}, MultiSignature, MultiSigner, }; -use sp_std::prelude::*; type AccountIdOf = ::AccountId; diff --git a/substrate/frame/nfts/src/types.rs b/substrate/frame/nfts/src/types.rs index 5a9f6ae2f0e21..1687a03520afe 100644 --- a/substrate/frame/nfts/src/types.rs +++ b/substrate/frame/nfts/src/types.rs @@ -19,6 +19,7 @@ use super::*; use crate::macros::*; +use alloc::{vec, vec::Vec}; use codec::EncodeLike; use enumflags2::{bitflags, BitFlags}; use frame_support::{ diff --git a/substrate/frame/nis/Cargo.toml b/substrate/frame/nis/Cargo.toml index 418c906e2b66c..fb6c25789b26d 100644 --- a/substrate/frame/nis/Cargo.toml +++ b/substrate/frame/nis/Cargo.toml @@ -24,7 +24,6 @@ frame-system = { workspace = true } sp-arithmetic = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -43,7 +42,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/nis/src/benchmarking.rs b/substrate/frame/nis/src/benchmarking.rs index f6a83b78d5181..2c7ad651f9903 100644 --- a/substrate/frame/nis/src/benchmarking.rs +++ b/substrate/frame/nis/src/benchmarking.rs @@ -30,7 +30,6 @@ use sp_runtime::{ traits::{Bounded, One, Zero}, DispatchError, PerThing, }; -use sp_std::prelude::*; use crate::Pallet as Nis; diff --git a/substrate/frame/nis/src/lib.rs b/substrate/frame/nis/src/lib.rs index d815ea6ac115c..016daa4cb78be 100644 --- a/substrate/frame/nis/src/lib.rs +++ b/substrate/frame/nis/src/lib.rs @@ -76,6 +76,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + use frame_support::traits::{ fungible::{self, Inspect as FunInspect, Mutate as FunMutate}, tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, @@ -95,7 +97,7 @@ mod mock; mod tests; pub mod weights; -pub struct WithMaximumOf(sp_std::marker::PhantomData); +pub struct WithMaximumOf(core::marker::PhantomData); impl Convert for WithMaximumOf where A::Type: Clone + Unsigned + From, @@ -116,7 +118,7 @@ where } } -pub struct NoCounterpart(sp_std::marker::PhantomData); +pub struct NoCounterpart(core::marker::PhantomData); impl FunInspect for NoCounterpart { type Balance = u32; fn total_issuance() -> u32 { @@ -171,6 +173,7 @@ impl BenchmarkSetup for () { pub mod pallet { use super::{FunInspect, FunMutate}; pub use crate::weights::WeightInfo; + use alloc::{vec, vec::Vec}; use frame_support::{ pallet_prelude::*, traits::{ @@ -193,7 +196,6 @@ pub mod pallet { traits::{AccountIdConversion, Bounded, Convert, ConvertBack, Saturating, Zero}, Rounding, TokenError, }; - use sp_std::prelude::*; type BalanceOf = <::Currency as FunInspect<::AccountId>>::Balance; @@ -372,7 +374,7 @@ pub mod pallet { pub receipts_on_hold: Balance, } - pub struct OnEmptyQueueTotals(sp_std::marker::PhantomData); + pub struct OnEmptyQueueTotals(core::marker::PhantomData); impl Get> for OnEmptyQueueTotals { fn get() -> QueueTotalsTypeOf { BoundedVec::truncate_from(vec![ @@ -573,7 +575,7 @@ pub mod pallet { // queue is let mut bid = Bid { amount, who: who.clone() }; let net = if queue_full { - sp_std::mem::swap(&mut q[0], &mut bid); + core::mem::swap(&mut q[0], &mut bid); let _ = T::Currency::release( &HoldReason::NftReceipt.into(), &bid.who, diff --git a/substrate/frame/node-authorization/Cargo.toml b/substrate/frame/node-authorization/Cargo.toml index d16e9bc6ead6c..b56a76ce641aa 100644 --- a/substrate/frame/node-authorization/Cargo.toml +++ b/substrate/frame/node-authorization/Cargo.toml @@ -23,7 +23,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -36,7 +35,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/node-authorization/src/lib.rs b/substrate/frame/node-authorization/src/lib.rs index a7967536079f9..7682b54ea0f24 100644 --- a/substrate/frame/node-authorization/src/lib.rs +++ b/substrate/frame/node-authorization/src/lib.rs @@ -44,10 +44,12 @@ mod tests; pub mod weights; +extern crate alloc; + +use alloc::{collections::btree_set::BTreeSet, vec::Vec}; pub use pallet::*; use sp_core::OpaquePeerId as PeerId; use sp_runtime::traits::StaticLookup; -use sp_std::{collections::btree_set::BTreeSet, prelude::*}; pub use weights::WeightInfo; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; diff --git a/substrate/frame/nomination-pools/Cargo.toml b/substrate/frame/nomination-pools/Cargo.toml index 535d5252435f3..bfcc92edb7e2e 100644 --- a/substrate/frame/nomination-pools/Cargo.toml +++ b/substrate/frame/nomination-pools/Cargo.toml @@ -27,7 +27,6 @@ scale-info = { features = [ frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-staking = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } @@ -55,7 +54,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", "sp-tracing?/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/nomination-pools/benchmarking/Cargo.toml b/substrate/frame/nomination-pools/benchmarking/Cargo.toml index 1516f0154b88f..e73a208926ee5 100644 --- a/substrate/frame/nomination-pools/benchmarking/Cargo.toml +++ b/substrate/frame/nomination-pools/benchmarking/Cargo.toml @@ -34,7 +34,6 @@ pallet-nomination-pools = { workspace = true } sp-runtime = { workspace = true } sp-runtime-interface = { workspace = true } sp-staking = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true } @@ -64,7 +63,6 @@ std = [ "sp-runtime-interface/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/nomination-pools/benchmarking/src/inner.rs b/substrate/frame/nomination-pools/benchmarking/src/inner.rs index b8c978945e9ee..2a45594251112 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/inner.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/inner.rs @@ -17,6 +17,7 @@ //! Benchmarks for the nomination pools coupled with the staking and bags list pallets. +use alloc::{vec, vec::Vec}; use frame_benchmarking::v1::{account, whitelist_account}; use frame_election_provider_support::SortedListProvider; use frame_support::{ @@ -41,7 +42,6 @@ use sp_runtime::{ Perbill, }; use sp_staking::EraIndex; -use sp_std::{vec, vec::Vec}; // `frame_benchmarking::benchmarks!` macro needs this use pallet_nomination_pools::Call; diff --git a/substrate/frame/nomination-pools/benchmarking/src/lib.rs b/substrate/frame/nomination-pools/benchmarking/src/lib.rs index 910cdf2e3dff6..feb73be716818 100644 --- a/substrate/frame/nomination-pools/benchmarking/src/lib.rs +++ b/substrate/frame/nomination-pools/benchmarking/src/lib.rs @@ -20,6 +20,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] +extern crate alloc; + #[cfg(feature = "runtime-benchmarks")] pub mod inner; diff --git a/substrate/frame/nomination-pools/runtime-api/Cargo.toml b/substrate/frame/nomination-pools/runtime-api/Cargo.toml index 2b217e021455f..2f91e550bc053 100644 --- a/substrate/frame/nomination-pools/runtime-api/Cargo.toml +++ b/substrate/frame/nomination-pools/runtime-api/Cargo.toml @@ -18,9 +18,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { features = ["derive"], workspace = true } sp-api = { workspace = true } -sp-std = { workspace = true } pallet-nomination-pools = { workspace = true } [features] default = ["std"] -std = ["codec/std", "pallet-nomination-pools/std", "sp-api/std", "sp-std/std"] +std = ["codec/std", "pallet-nomination-pools/std", "sp-api/std"] diff --git a/substrate/frame/nomination-pools/src/adapter.rs b/substrate/frame/nomination-pools/src/adapter.rs index 4809fbc0e9da0..4d571855e4fe8 100644 --- a/substrate/frame/nomination-pools/src/adapter.rs +++ b/substrate/frame/nomination-pools/src/adapter.rs @@ -83,7 +83,7 @@ impl Member { /// [`DelegateStake`] for more detail. pub trait StakeStrategy { type Balance: frame_support::traits::tokens::Balance; - type AccountId: Clone + sp_std::fmt::Debug; + type AccountId: Clone + core::fmt::Debug; type CoreStaking: StakingInterface; /// The type of staking strategy of the current adapter. diff --git a/substrate/frame/nomination-pools/src/lib.rs b/substrate/frame/nomination-pools/src/lib.rs index 641f2b1457727..472f0affcc735 100644 --- a/substrate/frame/nomination-pools/src/lib.rs +++ b/substrate/frame/nomination-pools/src/lib.rs @@ -351,8 +351,12 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + use adapter::{Member, Pool, StakeStrategy}; +use alloc::{collections::btree_map::BTreeMap, vec::Vec}; use codec::Codec; +use core::{fmt::Debug, ops::Div}; use frame_support::{ defensive, defensive_assert, ensure, pallet_prelude::{MaxEncodedLen, *}, @@ -375,7 +379,6 @@ use sp_runtime::{ FixedPointNumber, Perbill, }; use sp_staking::{EraIndex, StakingInterface}; -use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, ops::Div, vec::Vec}; #[cfg(any(feature = "try-runtime", feature = "fuzzing", test, debug_assertions))] use sp_runtime::TryRuntimeError; @@ -949,14 +952,14 @@ pub struct BondedPool { inner: BondedPoolInner, } -impl sp_std::ops::Deref for BondedPool { +impl core::ops::Deref for BondedPool { type Target = BondedPoolInner; fn deref(&self) -> &Self::Target { &self.inner } } -impl sp_std::ops::DerefMut for BondedPool { +impl core::ops::DerefMut for BondedPool { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner } diff --git a/substrate/frame/nomination-pools/src/migration.rs b/substrate/frame/nomination-pools/src/migration.rs index a9222ea53d75f..d8697364a76c5 100644 --- a/substrate/frame/nomination-pools/src/migration.rs +++ b/substrate/frame/nomination-pools/src/migration.rs @@ -17,8 +17,8 @@ use super::*; use crate::log; +use alloc::{collections::btree_map::BTreeMap, vec::Vec}; use frame_support::traits::{OnRuntimeUpgrade, UncheckedOnRuntimeUpgrade}; -use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -60,7 +60,7 @@ pub mod unversioned { use super::*; /// Checks and updates `TotalValueLocked` if out of sync. - pub struct TotalValueLockedSync(sp_std::marker::PhantomData); + pub struct TotalValueLockedSync(core::marker::PhantomData); impl OnRuntimeUpgrade for TotalValueLockedSync { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { @@ -125,7 +125,7 @@ pub mod unversioned { /// /// If there are pools that fail to migrate or did not fit in the bounds, the remaining pools /// can be migrated via the permission-less extrinsic [`Call::migrate_pool_to_delegate_stake`]. - pub struct DelegationStakeMigration(sp_std::marker::PhantomData<(T, MaxPools)>); + pub struct DelegationStakeMigration(core::marker::PhantomData<(T, MaxPools)>); impl> OnRuntimeUpgrade for DelegationStakeMigration { fn on_runtime_upgrade() -> Weight { @@ -262,7 +262,7 @@ pub mod v8 { } } - pub struct VersionUncheckedMigrateV7ToV8(sp_std::marker::PhantomData); + pub struct VersionUncheckedMigrateV7ToV8(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV7ToV8 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { @@ -341,7 +341,7 @@ pub(crate) mod v7 { pub type BondedPools = CountedStorageMap, Twox64Concat, PoolId, V7BondedPoolInner>; - pub struct VersionUncheckedMigrateV6ToV7(sp_std::marker::PhantomData); + pub struct VersionUncheckedMigrateV6ToV7(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV6ToV7 { fn on_runtime_upgrade() -> Weight { let migrated = BondedPools::::count(); @@ -402,7 +402,7 @@ mod v6 { /// This migration would restrict reward account of pools to go below ED by doing a named /// freeze on all the existing pools. - pub struct MigrateToV6(sp_std::marker::PhantomData); + pub struct MigrateToV6(core::marker::PhantomData); impl MigrateToV6 { fn freeze_ed(pool_id: PoolId) -> Result<(), ()> { @@ -470,7 +470,7 @@ pub mod v5 { /// This migration adds `total_commission_pending` and `total_commission_claimed` field to every /// `RewardPool`, if any. - pub struct MigrateToV5(sp_std::marker::PhantomData); + pub struct MigrateToV5(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV5 { fn on_runtime_upgrade() -> Weight { let in_code = Pallet::::in_code_storage_version(); @@ -625,7 +625,7 @@ pub mod v4 { #[deprecated( note = "To avoid mangled storage please use `MigrateV3ToV5` instead. See: github.com/paritytech/substrate/pull/13715" )] - pub struct MigrateToV4(sp_std::marker::PhantomData<(T, U)>); + pub struct MigrateToV4(core::marker::PhantomData<(T, U)>); #[allow(deprecated)] impl> OnRuntimeUpgrade for MigrateToV4 { fn on_runtime_upgrade() -> Weight { @@ -707,7 +707,7 @@ pub mod v3 { use super::*; /// This migration removes stale bonded-pool metadata, if any. - pub struct MigrateToV3(sp_std::marker::PhantomData); + pub struct MigrateToV3(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV3 { fn on_runtime_upgrade() -> Weight { let current = Pallet::::in_code_storage_version(); @@ -845,7 +845,7 @@ pub mod v2 { /// Migrate the pool reward scheme to the new version, as per /// . - pub struct MigrateToV2(sp_std::marker::PhantomData); + pub struct MigrateToV2(core::marker::PhantomData); impl MigrateToV2 { fn run(current: StorageVersion) -> Weight { let mut reward_pools_translated = 0u64; @@ -1104,7 +1104,7 @@ pub mod v1 { /// Trivial migration which makes the roles of each pool optional. /// /// Note: The depositor is not optional since they can never change. - pub struct MigrateToV1(sp_std::marker::PhantomData); + pub struct MigrateToV1(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { fn on_runtime_upgrade() -> Weight { let current = Pallet::::in_code_storage_version(); diff --git a/substrate/frame/offences/Cargo.toml b/substrate/frame/offences/Cargo.toml index 51eb3e4f43817..9cf5e911a9d3a 100644 --- a/substrate/frame/offences/Cargo.toml +++ b/substrate/frame/offences/Cargo.toml @@ -25,7 +25,6 @@ frame-system = { workspace = true } pallet-balances = { workspace = true } sp-runtime = { workspace = true } sp-staking = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true, default-features = true } @@ -45,7 +44,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-support/runtime-benchmarks", diff --git a/substrate/frame/offences/benchmarking/Cargo.toml b/substrate/frame/offences/benchmarking/Cargo.toml index 037812b3ed114..eb97eb3d4132a 100644 --- a/substrate/frame/offences/benchmarking/Cargo.toml +++ b/substrate/frame/offences/benchmarking/Cargo.toml @@ -31,7 +31,6 @@ pallet-session = { workspace = true } pallet-staking = { workspace = true } sp-runtime = { workspace = true } sp-staking = { workspace = true } -sp-std = { workspace = true } log = { workspace = true } [dev-dependencies] @@ -62,7 +61,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/offences/benchmarking/src/inner.rs b/substrate/frame/offences/benchmarking/src/inner.rs index 9aa88f7a0d6d0..b16e5be653d1e 100644 --- a/substrate/frame/offences/benchmarking/src/inner.rs +++ b/substrate/frame/offences/benchmarking/src/inner.rs @@ -17,7 +17,7 @@ //! Offences pallet benchmarking. -use sp_std::{prelude::*, vec}; +use alloc::{vec, vec::Vec}; use frame_benchmarking::v1::{account, benchmarks}; use frame_support::traits::{Currency, Get}; diff --git a/substrate/frame/offences/benchmarking/src/lib.rs b/substrate/frame/offences/benchmarking/src/lib.rs index b08955a133297..f696546d1f0a0 100644 --- a/substrate/frame/offences/benchmarking/src/lib.rs +++ b/substrate/frame/offences/benchmarking/src/lib.rs @@ -19,6 +19,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(feature = "runtime-benchmarks")] pub mod inner; diff --git a/substrate/frame/offences/src/lib.rs b/substrate/frame/offences/src/lib.rs index a328b2fee4e2e..ffea32a1f4703 100644 --- a/substrate/frame/offences/src/lib.rs +++ b/substrate/frame/offences/src/lib.rs @@ -26,16 +26,17 @@ pub mod migration; mod mock; mod tests; -use core::marker::PhantomData; +extern crate alloc; +use alloc::vec::Vec; use codec::Encode; +use core::marker::PhantomData; use frame_support::weights::Weight; use sp_runtime::{traits::Hash, Perbill}; use sp_staking::{ offence::{Kind, Offence, OffenceDetails, OffenceError, OnOffenceHandler, ReportOffence}, SessionIndex, }; -use sp_std::prelude::*; pub use pallet::*; diff --git a/substrate/frame/offences/src/migration.rs b/substrate/frame/offences/src/migration.rs index 199f47491369b..abf8acd94875d 100644 --- a/substrate/frame/offences/src/migration.rs +++ b/substrate/frame/offences/src/migration.rs @@ -16,6 +16,7 @@ // limitations under the License. use super::{Config, Kind, OffenceDetails, Pallet, Perbill, SessionIndex, LOG_TARGET}; +use alloc::vec::Vec; use frame_support::{ pallet_prelude::ValueQuery, storage_alias, @@ -24,7 +25,6 @@ use frame_support::{ Twox64Concat, }; use sp_staking::offence::OnOffenceHandler; -use sp_std::vec::Vec; #[cfg(feature = "try-runtime")] use frame_support::ensure; @@ -49,7 +49,7 @@ pub mod v1 { use super::*; - pub struct MigrateToV1(sp_std::marker::PhantomData); + pub struct MigrateToV1(core::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { diff --git a/substrate/frame/paged-list/Cargo.toml b/substrate/frame/paged-list/Cargo.toml index f5a3a2e5bae19..597bdd37f57fb 100644 --- a/substrate/frame/paged-list/Cargo.toml +++ b/substrate/frame/paged-list/Cargo.toml @@ -24,7 +24,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-metadata-ir = { optional = true, workspace = true } @@ -42,7 +41,6 @@ std = [ "sp-io/std", "sp-metadata-ir/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/paged-list/src/lib.rs b/substrate/frame/paged-list/src/lib.rs index ddeed174f34bb..ed68dac63beb6 100644 --- a/substrate/frame/paged-list/src/lib.rs +++ b/substrate/frame/paged-list/src/lib.rs @@ -58,7 +58,7 @@ //! //! ## Low Level / Implementation Details //! -//! Implementation details are documented in [`paged_list::StoragePagedList`]. +//! Implementation details are documented in [`paged_list::StoragePagedList`]. //! All storage entries are prefixed with a unique prefix that is generated by [`ListPrefix`]. #![cfg_attr(not(feature = "std"), no_std)] @@ -69,6 +69,8 @@ pub mod mock; mod paged_list; mod tests; +extern crate alloc; + use codec::FullCodec; use frame_support::{ pallet_prelude::StorageList, diff --git a/substrate/frame/paged-list/src/paged_list.rs b/substrate/frame/paged-list/src/paged_list.rs index eecc728cd62a1..bbd889e252180 100644 --- a/substrate/frame/paged-list/src/paged_list.rs +++ b/substrate/frame/paged-list/src/paged_list.rs @@ -23,6 +23,7 @@ #![deny(missing_docs)] #![deny(unsafe_code)] +use alloc::vec::Vec; use codec::{Decode, Encode, EncodeLike, FullCodec}; use core::marker::PhantomData; use frame_support::{ @@ -32,7 +33,6 @@ use frame_support::{ CloneNoBound, DebugNoBound, DefaultNoBound, EqNoBound, PartialEqNoBound, }; use sp_runtime::traits::Saturating; -use sp_std::prelude::*; pub type PageIndex = u32; pub type ValueIndex = u32; @@ -177,7 +177,7 @@ pub struct Page { /// The index of the page. index: PageIndex, /// The remaining values of the page, to be drained by [`Page::next`]. - values: sp_std::iter::Skip>, + values: core::iter::Skip>, } impl Page { @@ -188,7 +188,7 @@ impl Page { ) -> Option { let key = page_key::(index); let values = sp_io::storage::get(&key) - .and_then(|raw| sp_std::vec::Vec::::decode(&mut &raw[..]).ok())?; + .and_then(|raw| alloc::vec::Vec::::decode(&mut &raw[..]).ok())?; if values.is_empty() { // Don't create empty pages. return None diff --git a/substrate/frame/parameters/Cargo.toml b/substrate/frame/parameters/Cargo.toml index b993347d24637..a97ba1172a503 100644 --- a/substrate/frame/parameters/Cargo.toml +++ b/substrate/frame/parameters/Cargo.toml @@ -18,7 +18,6 @@ frame-support = { features = ["experimental"], workspace = true } frame-system = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } frame-benchmarking = { optional = true, workspace = true } [dev-dependencies] @@ -38,7 +37,6 @@ std = [ "serde", "sp-core/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/preimage/Cargo.toml b/substrate/frame/preimage/Cargo.toml index ee572b189b231..425c4e81aa7b3 100644 --- a/substrate/frame/preimage/Cargo.toml +++ b/substrate/frame/preimage/Cargo.toml @@ -20,7 +20,6 @@ frame-system = { workspace = true } sp-core = { optional = true, workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } log = { workspace = true } [dev-dependencies] @@ -48,7 +47,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/preimage/src/benchmarking.rs b/substrate/frame/preimage/src/benchmarking.rs index f2b76a7999d6c..2d3bec16b8183 100644 --- a/substrate/frame/preimage/src/benchmarking.rs +++ b/substrate/frame/preimage/src/benchmarking.rs @@ -18,11 +18,11 @@ //! Preimage pallet benchmarking. use super::*; +use alloc::vec; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; use frame_support::assert_ok; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; -use sp_std::{prelude::*, vec}; use crate::Pallet as Preimage; diff --git a/substrate/frame/preimage/src/lib.rs b/substrate/frame/preimage/src/lib.rs index dd323a12b8f84..30056fc6d9a49 100644 --- a/substrate/frame/preimage/src/lib.rs +++ b/substrate/frame/preimage/src/lib.rs @@ -37,11 +37,13 @@ mod mock; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{borrow::Cow, vec::Vec}; use sp_runtime::{ traits::{BadOrigin, Hash, Saturating}, Perbill, }; -use sp_std::{borrow::Cow, prelude::*}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ diff --git a/substrate/frame/preimage/src/migration.rs b/substrate/frame/preimage/src/migration.rs index a86109f892a4f..e38483ee68c62 100644 --- a/substrate/frame/preimage/src/migration.rs +++ b/substrate/frame/preimage/src/migration.rs @@ -18,11 +18,11 @@ //! Storage migrations for the preimage pallet. use super::*; +use alloc::collections::btree_map::BTreeMap; use frame_support::{ storage_alias, traits::{ConstU32, OnRuntimeUpgrade}, }; -use sp_std::collections::btree_map::BTreeMap; #[cfg(feature = "try-runtime")] use frame_support::ensure; @@ -79,7 +79,7 @@ pub mod v1 { /// /// Note: This needs to be run with the same hashing algorithm as before /// since it is not re-hashing the preimages. - pub struct Migration(sp_std::marker::PhantomData); + pub struct Migration(core::marker::PhantomData); impl OnRuntimeUpgrade for Migration { #[cfg(feature = "try-runtime")] diff --git a/substrate/frame/proxy/Cargo.toml b/substrate/frame/proxy/Cargo.toml index 6b4251e1bcc57..af2427da380a9 100644 --- a/substrate/frame/proxy/Cargo.toml +++ b/substrate/frame/proxy/Cargo.toml @@ -23,7 +23,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -43,7 +42,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/proxy/src/benchmarking.rs b/substrate/frame/proxy/src/benchmarking.rs index e0d14163d21b2..4081af49c2435 100644 --- a/substrate/frame/proxy/src/benchmarking.rs +++ b/substrate/frame/proxy/src/benchmarking.rs @@ -21,6 +21,7 @@ use super::*; use crate::Pallet as Proxy; +use alloc::{boxed::Box, vec}; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::traits::Bounded; diff --git a/substrate/frame/proxy/src/lib.rs b/substrate/frame/proxy/src/lib.rs index 2b3fac5f59e4b..d681088165c8f 100644 --- a/substrate/frame/proxy/src/lib.rs +++ b/substrate/frame/proxy/src/lib.rs @@ -33,6 +33,9 @@ mod benchmarking; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{boxed::Box, vec}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::GetDispatchInfo, @@ -47,7 +50,6 @@ use sp_runtime::{ traits::{Dispatchable, Hash, Saturating, StaticLookup, TrailingZeroInput, Zero}, DispatchError, DispatchResult, RuntimeDebug, }; -use sp_std::prelude::*; pub use weights::WeightInfo; type CallHashOf = <::CallHasher as Hash>::Output; diff --git a/substrate/frame/proxy/src/tests.rs b/substrate/frame/proxy/src/tests.rs index 3ed61fbedaaa9..3edb96026a82b 100644 --- a/substrate/frame/proxy/src/tests.rs +++ b/substrate/frame/proxy/src/tests.rs @@ -22,6 +22,7 @@ use super::*; use crate as proxy; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; use frame_support::{ assert_noop, assert_ok, derive_impl, diff --git a/substrate/frame/ranked-collective/Cargo.toml b/substrate/frame/ranked-collective/Cargo.toml index be48d5cad4048..dd9b466e0f919 100644 --- a/substrate/frame/ranked-collective/Cargo.toml +++ b/substrate/frame/ranked-collective/Cargo.toml @@ -26,7 +26,6 @@ sp-arithmetic = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } impl-trait-for-tuples = { workspace = true } [features] @@ -42,7 +41,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/ranked-collective/src/benchmarking.rs b/substrate/frame/ranked-collective/src/benchmarking.rs index 462f55a238d2a..dc7f4aaca7735 100644 --- a/substrate/frame/ranked-collective/src/benchmarking.rs +++ b/substrate/frame/ranked-collective/src/benchmarking.rs @@ -20,6 +20,7 @@ use super::*; #[allow(unused_imports)] use crate::Pallet as RankedCollective; +use alloc::vec::Vec; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, diff --git a/substrate/frame/ranked-collective/src/lib.rs b/substrate/frame/ranked-collective/src/lib.rs index 53d5f0c6662d7..e34cf3d8df711 100644 --- a/substrate/frame/ranked-collective/src/lib.rs +++ b/substrate/frame/ranked-collective/src/lib.rs @@ -40,7 +40,10 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + use codec::{Decode, Encode, MaxEncodedLen}; +use core::marker::PhantomData; use scale_info::TypeInfo; use sp_arithmetic::traits::Saturating; use sp_runtime::{ @@ -48,7 +51,6 @@ use sp_runtime::{ ArithmeticError::Overflow, DispatchError, Perbill, RuntimeDebug, }; -use sp_std::{marker::PhantomData, prelude::*}; use frame_support::{ dispatch::{DispatchResultWithPostInfo, PostDispatchInfo}, diff --git a/substrate/frame/recovery/Cargo.toml b/substrate/frame/recovery/Cargo.toml index 3b3a382fe6dcf..42493b435105c 100644 --- a/substrate/frame/recovery/Cargo.toml +++ b/substrate/frame/recovery/Cargo.toml @@ -23,7 +23,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -49,7 +48,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/recovery/src/benchmarking.rs b/substrate/frame/recovery/src/benchmarking.rs index 72f77336212dd..b7639742a6202 100644 --- a/substrate/frame/recovery/src/benchmarking.rs +++ b/substrate/frame/recovery/src/benchmarking.rs @@ -20,6 +20,7 @@ use super::*; use crate::Pallet; +use alloc::{boxed::Box, vec, vec::Vec}; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::traits::{Currency, Get}; use frame_system::RawOrigin; diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index 5673147c8e005..69be4df971bc4 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -150,13 +150,15 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{boxed::Box, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_runtime::{ traits::{CheckedAdd, CheckedMul, Dispatchable, SaturatedConversion, StaticLookup}, RuntimeDebug, }; -use sp_std::prelude::*; use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, diff --git a/substrate/frame/referenda/Cargo.toml b/substrate/frame/referenda/Cargo.toml index eb30fef7894b4..578486714d636 100644 --- a/substrate/frame/referenda/Cargo.toml +++ b/substrate/frame/referenda/Cargo.toml @@ -28,7 +28,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } log = { workspace = true } [dev-dependencies] @@ -55,7 +54,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "assert_matches", diff --git a/substrate/frame/referenda/src/benchmarking.rs b/substrate/frame/referenda/src/benchmarking.rs index 47d43cc0600c0..67ac82787d31d 100644 --- a/substrate/frame/referenda/src/benchmarking.rs +++ b/substrate/frame/referenda/src/benchmarking.rs @@ -19,6 +19,7 @@ use super::*; use crate::Pallet as Referenda; +use alloc::{vec, vec::Vec}; use assert_matches::assert_matches; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, BenchmarkError, @@ -632,7 +633,7 @@ benchmarks_instance_pallet! { } set_some_metadata { - use sp_std::borrow::Cow; + use alloc::borrow::Cow; let origin = T::SubmitOrigin::try_successful_origin(&RawOrigin::Root.into()) .expect("SubmitOrigin has no successful origin required for the benchmark"); let index = create_referendum::(origin.clone()); @@ -643,7 +644,7 @@ benchmarks_instance_pallet! { } clear_metadata { - use sp_std::borrow::Cow; + use alloc::borrow::Cow; let origin = T::SubmitOrigin::try_successful_origin(&RawOrigin::Root.into()) .expect("SubmitOrigin has no successful origin required for the benchmark"); let index = create_referendum::(origin.clone()); diff --git a/substrate/frame/referenda/src/lib.rs b/substrate/frame/referenda/src/lib.rs index 0cdf450d3b6c9..e72dd7f11cbb2 100644 --- a/substrate/frame/referenda/src/lib.rs +++ b/substrate/frame/referenda/src/lib.rs @@ -64,7 +64,11 @@ #![recursion_limit = "256"] #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::boxed::Box; use codec::{Codec, Encode}; +use core::fmt::Debug; use frame_support::{ dispatch::DispatchResult, ensure, @@ -84,7 +88,6 @@ use sp_runtime::{ traits::{AtLeast32BitUnsigned, Bounded, Dispatchable, One, Saturating, Zero}, DispatchError, Perbill, }; -use sp_std::{fmt::Debug, prelude::*}; mod branch; pub mod migration; @@ -102,6 +105,7 @@ pub use self::{ }, weights::WeightInfo, }; +pub use alloc::vec::Vec; #[cfg(test)] mod mock; @@ -112,7 +116,6 @@ mod tests; pub mod benchmarking; pub use frame_support::traits::Get; -pub use sp_std::vec::Vec; #[macro_export] macro_rules! impl_tracksinfo_get { diff --git a/substrate/frame/referenda/src/types.rs b/substrate/frame/referenda/src/types.rs index b3c583322cce3..1039b288b2aec 100644 --- a/substrate/frame/referenda/src/types.rs +++ b/substrate/frame/referenda/src/types.rs @@ -515,7 +515,7 @@ impl Curve { #[cfg(feature = "std")] impl Debug for Curve { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::LinearDecreasing { length, floor, ceil } => { write!( diff --git a/substrate/frame/remark/Cargo.toml b/substrate/frame/remark/Cargo.toml index 44cf5ebc3b492..efc9917428c04 100644 --- a/substrate/frame/remark/Cargo.toml +++ b/substrate/frame/remark/Cargo.toml @@ -25,7 +25,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-core = { workspace = true } @@ -48,7 +47,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/remark/src/benchmarking.rs b/substrate/frame/remark/src/benchmarking.rs index 831946834963f..15b72b4748dd4 100644 --- a/substrate/frame/remark/src/benchmarking.rs +++ b/substrate/frame/remark/src/benchmarking.rs @@ -20,9 +20,9 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; +use alloc::vec; use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_system::{EventRecord, Pallet as System, RawOrigin}; -use sp_std::*; #[cfg(test)] use crate::Pallet as Remark; diff --git a/substrate/frame/remark/src/lib.rs b/substrate/frame/remark/src/lib.rs index 8ca3cd395afb5..eae8e0b83f5d2 100644 --- a/substrate/frame/remark/src/lib.rs +++ b/substrate/frame/remark/src/lib.rs @@ -28,7 +28,9 @@ mod mock; #[cfg(test)] mod tests; -use sp_std::prelude::*; +extern crate alloc; + +use alloc::vec::Vec; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index 3c758b91d52fe..ab43b723e8a9b 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -18,6 +18,7 @@ use super::*; use crate as root_offences; +use alloc::collections::btree_map::BTreeMap; use frame_election_provider_support::{ bounds::{ElectionBounds, ElectionBoundsBuilder}, onchain, SequentialPhragmen, @@ -29,7 +30,6 @@ use frame_support::{ use pallet_staking::StakerStatus; use sp_runtime::{curve::PiecewiseLinear, testing::UintAuthorityId, traits::Zero, BuildStorage}; use sp_staking::{EraIndex, SessionIndex}; -use sp_std::collections::btree_map::BTreeMap; type Block = frame_system::mocking::MockBlock; type AccountId = u64; diff --git a/substrate/frame/root-testing/Cargo.toml b/substrate/frame/root-testing/Cargo.toml index 38d91c8104b90..96d8613626225 100644 --- a/substrate/frame/root-testing/Cargo.toml +++ b/substrate/frame/root-testing/Cargo.toml @@ -23,7 +23,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] try-runtime = [ @@ -40,5 +39,4 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] diff --git a/substrate/frame/safe-mode/Cargo.toml b/substrate/frame/safe-mode/Cargo.toml index 749c4bcdc7000..b704818f1adf0 100644 --- a/substrate/frame/safe-mode/Cargo.toml +++ b/substrate/frame/safe-mode/Cargo.toml @@ -23,7 +23,6 @@ frame-system = { workspace = true } scale-info = { features = ["derive"], workspace = true } sp-arithmetic = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } pallet-balances = { optional = true, workspace = true } pallet-utility = { optional = true, workspace = true } pallet-proxy = { optional = true, workspace = true } @@ -51,7 +50,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/salary/Cargo.toml b/substrate/frame/salary/Cargo.toml index c9b72da2e649f..9121f59ff4626 100644 --- a/substrate/frame/salary/Cargo.toml +++ b/substrate/frame/salary/Cargo.toml @@ -26,7 +26,6 @@ sp-arithmetic = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } pallet-ranked-collective = { optional = true, workspace = true } [features] @@ -44,7 +43,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/sassafras/Cargo.toml b/substrate/frame/sassafras/Cargo.toml index ecd03c47db689..0eefca57849aa 100644 --- a/substrate/frame/sassafras/Cargo.toml +++ b/substrate/frame/sassafras/Cargo.toml @@ -26,7 +26,6 @@ log = { workspace = true } sp-consensus-sassafras = { features = ["serde"], workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] array-bytes = { workspace = true, default-features = true } @@ -45,7 +44,6 @@ std = [ "sp-consensus-sassafras/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/sassafras/src/lib.rs b/substrate/frame/sassafras/src/lib.rs index d521ed9dd91b8..285758afbe6db 100644 --- a/substrate/frame/sassafras/src/lib.rs +++ b/substrate/frame/sassafras/src/lib.rs @@ -47,10 +47,13 @@ #![warn(unused_must_use, unsafe_code, unused_variables, unused_imports, missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + use codec::{Decode, Encode, MaxEncodedLen}; use log::{debug, error, trace, warn}; use scale_info::TypeInfo; +use alloc::vec::Vec; use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, traits::{Defensive, Get}, @@ -72,7 +75,6 @@ use sp_runtime::{ traits::{One, Zero}, BoundToRuntimeAppPublic, }; -use sp_std::prelude::Vec; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; @@ -288,7 +290,7 @@ pub mod pallet { pub epoch_config: EpochConfiguration, /// Phantom config #[serde(skip)] - pub _phantom: sp_std::marker::PhantomData, + pub _phantom: core::marker::PhantomData, } #[pallet::genesis_build] diff --git a/substrate/frame/scheduler/Cargo.toml b/substrate/frame/scheduler/Cargo.toml index 0a6b646fc8c3c..29aaaec9aa408 100644 --- a/substrate/frame/scheduler/Cargo.toml +++ b/substrate/frame/scheduler/Cargo.toml @@ -21,7 +21,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-weights = { workspace = true } docify = { workspace = true } @@ -51,7 +50,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-weights/std", ] try-runtime = [ diff --git a/substrate/frame/scheduler/src/benchmarking.rs b/substrate/frame/scheduler/src/benchmarking.rs index 884f78000384c..d0a14fc73d64f 100644 --- a/substrate/frame/scheduler/src/benchmarking.rs +++ b/substrate/frame/scheduler/src/benchmarking.rs @@ -18,6 +18,7 @@ //! Scheduler pallet benchmarking. use super::*; +use alloc::vec; use frame_benchmarking::v1::{account, benchmarks, BenchmarkError}; use frame_support::{ ensure, @@ -25,7 +26,6 @@ use frame_support::{ weights::WeightMeter, }; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; -use sp_std::{prelude::*, vec}; use crate::Pallet as Scheduler; use frame_system::{Call as SystemCall, EventRecord}; diff --git a/substrate/frame/scheduler/src/lib.rs b/substrate/frame/scheduler/src/lib.rs index d19a1e0001dd3..3eecf6d6f9e88 100644 --- a/substrate/frame/scheduler/src/lib.rs +++ b/substrate/frame/scheduler/src/lib.rs @@ -85,7 +85,11 @@ mod mock; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{boxed::Box, vec::Vec}; use codec::{Decode, Encode, MaxEncodedLen}; +use core::{borrow::Borrow, cmp::Ordering, marker::PhantomData}; use frame_support::{ dispatch::{DispatchResult, GetDispatchInfo, Parameter, RawOrigin}, ensure, @@ -106,7 +110,6 @@ use sp_runtime::{ traits::{BadOrigin, Dispatchable, One, Saturating, Zero}, BoundedVec, DispatchError, RuntimeDebug, }; -use sp_std::{borrow::Borrow, cmp::Ordering, marker::PhantomData, prelude::*}; pub use pallet::*; pub use weights::WeightInfo; diff --git a/substrate/frame/scheduler/src/migration.rs b/substrate/frame/scheduler/src/migration.rs index c2e956035a767..a304689a120cc 100644 --- a/substrate/frame/scheduler/src/migration.rs +++ b/substrate/frame/scheduler/src/migration.rs @@ -305,8 +305,8 @@ pub mod v4 { mod test { use super::*; use crate::mock::*; + use alloc::borrow::Cow; use frame_support::Hashable; - use sp_std::borrow::Cow; use substrate_test_utils::assert_eq_uvec; #[test] diff --git a/substrate/frame/scored-pool/Cargo.toml b/substrate/frame/scored-pool/Cargo.toml index 69ecd527eb7c9..132799ead62a7 100644 --- a/substrate/frame/scored-pool/Cargo.toml +++ b/substrate/frame/scored-pool/Cargo.toml @@ -22,7 +22,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -39,7 +38,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/scored-pool/src/lib.rs b/substrate/frame/scored-pool/src/lib.rs index 2bf70cbc574c8..c4464bbbfac04 100644 --- a/substrate/frame/scored-pool/src/lib.rs +++ b/substrate/frame/scored-pool/src/lib.rs @@ -98,7 +98,11 @@ mod mock; #[cfg(test)] mod tests; +extern crate alloc; + +use alloc::vec::Vec; use codec::{FullCodec, MaxEncodedLen}; +use core::{cmp::Reverse, fmt::Debug}; use frame_support::{ ensure, traits::{ChangeMembers, Currency, Get, InitializeMembers, ReservableCurrency}, @@ -106,7 +110,6 @@ use frame_support::{ }; pub use pallet::*; use sp_runtime::traits::{AtLeast32Bit, StaticLookup, Zero}; -use sp_std::{fmt::Debug, prelude::*}; type BalanceOf = <>::Currency as Currency<::AccountId>>::Balance; diff --git a/substrate/frame/session/Cargo.toml b/substrate/frame/session/Cargo.toml index c7b499548bdb4..09bb93d8c1d09 100644 --- a/substrate/frame/session/Cargo.toml +++ b/substrate/frame/session/Cargo.toml @@ -28,7 +28,6 @@ sp-io = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-session = { workspace = true } sp-staking = { features = ["serde"], workspace = true } -sp-std = { workspace = true } sp-trie = { optional = true, workspace = true } sp-state-machine = { workspace = true } @@ -48,7 +47,6 @@ std = [ "sp-session/std", "sp-staking/std", "sp-state-machine/std", - "sp-std/std", "sp-trie/std", ] try-runtime = [ diff --git a/substrate/frame/session/benchmarking/Cargo.toml b/substrate/frame/session/benchmarking/Cargo.toml index ba7f7acfd9919..9ca3549f681dc 100644 --- a/substrate/frame/session/benchmarking/Cargo.toml +++ b/substrate/frame/session/benchmarking/Cargo.toml @@ -25,7 +25,6 @@ pallet-session = { workspace = true } pallet-staking = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] codec = { features = ["derive"], workspace = true, default-features = true } @@ -53,7 +52,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-session/std", - "sp-std/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/session/benchmarking/src/inner.rs b/substrate/frame/session/benchmarking/src/inner.rs index d86c5d9ad278e..f08e10f078690 100644 --- a/substrate/frame/session/benchmarking/src/inner.rs +++ b/substrate/frame/session/benchmarking/src/inner.rs @@ -18,8 +18,8 @@ //! Benchmarks for the Session Pallet. // This is separated into its own crate due to cyclic dependency issues. +use alloc::{vec, vec::Vec}; use sp_runtime::traits::{One, StaticLookup, TrailingZeroInput}; -use sp_std::{prelude::*, vec}; use codec::Decode; use frame_benchmarking::v1::benchmarks; diff --git a/substrate/frame/session/benchmarking/src/lib.rs b/substrate/frame/session/benchmarking/src/lib.rs index b08955a133297..f696546d1f0a0 100644 --- a/substrate/frame/session/benchmarking/src/lib.rs +++ b/substrate/frame/session/benchmarking/src/lib.rs @@ -19,6 +19,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(feature = "runtime-benchmarks")] pub mod inner; diff --git a/substrate/frame/session/src/historical/mod.rs b/substrate/frame/session/src/historical/mod.rs index 618497e3d54db..fac580b49b3ab 100644 --- a/substrate/frame/session/src/historical/mod.rs +++ b/substrate/frame/session/src/historical/mod.rs @@ -30,14 +30,15 @@ pub mod offchain; pub mod onchain; mod shared; +use alloc::vec::Vec; use codec::{Decode, Encode}; +use core::fmt::Debug; use sp_runtime::{ traits::{Convert, OpaqueKeys}, KeyTypeId, }; use sp_session::{MembershipProof, ValidatorCount}; use sp_staking::SessionIndex; -use sp_std::{fmt::Debug, prelude::*}; use sp_trie::{ trie_types::{TrieDBBuilder, TrieDBMutBuilderV0}, LayoutV0, MemoryDB, Recorder, StorageProof, Trie, TrieMut, TrieRecorder, @@ -103,7 +104,7 @@ impl Pallet { None => return, // nothing to prune. }; - let up_to = sp_std::cmp::min(up_to, end); + let up_to = core::cmp::min(up_to, end); if up_to < start { return // out of bounds. harmless. @@ -168,7 +169,7 @@ pub trait SessionManager: /// An `SessionManager` implementation that wraps an inner `I` and also /// sets the historical trie root of the ending session. -pub struct NoteHistoricalRoot(sp_std::marker::PhantomData<(T, I)>); +pub struct NoteHistoricalRoot(core::marker::PhantomData<(T, I)>); impl> NoteHistoricalRoot { fn do_new_session(new_index: SessionIndex, is_genesis: bool) -> Option> { @@ -374,6 +375,7 @@ pub(crate) mod tests { use crate::mock::{ force_new_session, set_next_validators, NextValidators, Session, System, Test, }; + use alloc::vec; use sp_runtime::{key_types::DUMMY, testing::UintAuthorityId, BuildStorage}; use sp_state_machine::BasicExternalities; diff --git a/substrate/frame/session/src/historical/offchain.rs b/substrate/frame/session/src/historical/offchain.rs index 95f4d762949ee..685a0be8e191e 100644 --- a/substrate/frame/session/src/historical/offchain.rs +++ b/substrate/frame/session/src/historical/offchain.rs @@ -23,12 +23,12 @@ //! required data to the offchain validator set. This is used in conjunction with [`ProvingTrie`] //! and the off-chain indexing API. +use alloc::vec::Vec; use sp_runtime::{ offchain::storage::{MutateStorageError, StorageRetrievalError, StorageValueRef}, KeyTypeId, }; use sp_session::MembershipProof; -use sp_std::prelude::*; use super::{shared, Config, IdentificationTuple, ProvingTrie}; use crate::{Pallet as SessionModule, SessionIndex}; @@ -60,9 +60,9 @@ impl ValidatorSet { /// Implement conversion into iterator for usage /// with [ProvingTrie](super::ProvingTrie::generate_for). -impl sp_std::iter::IntoIterator for ValidatorSet { +impl core::iter::IntoIterator for ValidatorSet { type Item = (T::ValidatorId, T::FullIdentification); - type IntoIter = sp_std::vec::IntoIter; + type IntoIter = alloc::vec::IntoIter; fn into_iter(self) -> Self::IntoIter { self.validator_set.into_iter() } diff --git a/substrate/frame/session/src/historical/onchain.rs b/substrate/frame/session/src/historical/onchain.rs index 97a7f02bd096e..a9eb18474b86a 100644 --- a/substrate/frame/session/src/historical/onchain.rs +++ b/substrate/frame/session/src/historical/onchain.rs @@ -17,9 +17,9 @@ //! On-chain logic to store a validator-set for deferred validation using an off-chain worker. +use alloc::vec::Vec; use codec::Encode; use sp_runtime::traits::Convert; -use sp_std::prelude::*; use super::{shared, Config as HistoricalConfig}; use crate::{Config as SessionConfig, Pallet as SessionModule, SessionIndex}; diff --git a/substrate/frame/session/src/historical/shared.rs b/substrate/frame/session/src/historical/shared.rs index 297385dfb426e..06b25ec99a4cb 100644 --- a/substrate/frame/session/src/historical/shared.rs +++ b/substrate/frame/session/src/historical/shared.rs @@ -18,9 +18,9 @@ //! Shared logic between on-chain and off-chain components used for slashing using an off-chain //! worker. +use alloc::{borrow::ToOwned, vec::Vec}; use codec::Encode; use sp_staking::SessionIndex; -use sp_std::prelude::*; pub(super) const PREFIX: &[u8] = b"session_historical"; pub(super) const LAST_PRUNE: &[u8] = b"session_historical_last_prune"; diff --git a/substrate/frame/session/src/lib.rs b/substrate/frame/session/src/lib.rs index 9506e98adf7d7..45f70dfa2582d 100644 --- a/substrate/frame/session/src/lib.rs +++ b/substrate/frame/session/src/lib.rs @@ -115,7 +115,14 @@ mod mock; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{boxed::Box, vec::Vec}; use codec::{Decode, MaxEncodedLen}; +use core::{ + marker::PhantomData, + ops::{Rem, Sub}, +}; use frame_support::{ dispatch::DispatchResult, ensure, @@ -132,11 +139,6 @@ use sp_runtime::{ ConsensusEngineId, DispatchError, KeyTypeId, Permill, RuntimeAppPublic, }; use sp_staking::SessionIndex; -use sp_std::{ - marker::PhantomData, - ops::{Rem, Sub}, - prelude::*, -}; pub use pallet::*; pub use weights::WeightInfo; @@ -917,7 +919,7 @@ impl frame_support::traits::DisabledValidators for Pallet { /// Wraps the author-scraping logic for consensus engines that can recover /// the canonical index of an author. This then transforms it into the /// registering account-ID of that session key index. -pub struct FindAccountFromAuthorIndex(sp_std::marker::PhantomData<(T, Inner)>); +pub struct FindAccountFromAuthorIndex(core::marker::PhantomData<(T, Inner)>); impl> FindAuthor for FindAccountFromAuthorIndex diff --git a/substrate/frame/society/Cargo.toml b/substrate/frame/society/Cargo.toml index 6582d47f19431..b6fa70c42efc0 100644 --- a/substrate/frame/society/Cargo.toml +++ b/substrate/frame/society/Cargo.toml @@ -21,7 +21,6 @@ rand_chacha = { workspace = true } scale-info = { features = ["derive"], workspace = true } codec = { features = ["derive"], workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } sp-arithmetic = { workspace = true } sp-runtime = { workspace = true } @@ -52,7 +51,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking", diff --git a/substrate/frame/society/src/benchmarking.rs b/substrate/frame/society/src/benchmarking.rs index 20af6e35ada52..8c3d2bf32ce73 100644 --- a/substrate/frame/society/src/benchmarking.rs +++ b/substrate/frame/society/src/benchmarking.rs @@ -24,6 +24,7 @@ use super::*; use frame_benchmarking::{account, benchmarks_instance_pallet, whitelisted_caller}; use frame_system::RawOrigin; +use alloc::vec; use sp_runtime::traits::Bounded; use crate::Pallet as Society; diff --git a/substrate/frame/society/src/lib.rs b/substrate/frame/society/src/lib.rs index 5bce245f73f17..b4c5c88af3d6e 100644 --- a/substrate/frame/society/src/lib.rs +++ b/substrate/frame/society/src/lib.rs @@ -257,6 +257,9 @@ pub mod weights; pub mod migrations; +extern crate alloc; + +use alloc::vec::Vec; use frame_support::{ impl_ensure_origin_with_arg_ignoring_arg, pallet_prelude::*, @@ -282,7 +285,6 @@ use sp_runtime::{ ArithmeticError::Overflow, Percent, RuntimeDebug, }; -use sp_std::prelude::*; pub use weights::WeightInfo; @@ -1362,7 +1364,7 @@ pub mod pallet { } /// Simple ensure origin struct to filter for the founder account. -pub struct EnsureFounder(sp_std::marker::PhantomData); +pub struct EnsureFounder(core::marker::PhantomData); impl EnsureOrigin<::RuntimeOrigin> for EnsureFounder { type Success = T::AccountId; fn try_origin(o: T::RuntimeOrigin) -> Result { diff --git a/substrate/frame/society/src/migrations.rs b/substrate/frame/society/src/migrations.rs index 7ded1f84f5823..396ed787c784c 100644 --- a/substrate/frame/society/src/migrations.rs +++ b/substrate/frame/society/src/migrations.rs @@ -18,6 +18,7 @@ //! # Migrations for Society Pallet use super::*; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; use frame_support::traits::{Defensive, DefensiveOption, Instance, UncheckedOnRuntimeUpgrade}; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index e09d8fc4fa1d4..3836e71cb00f2 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -132,10 +132,6 @@ pub mod prelude { #[doc(no_inline)] pub use frame_system::pallet_prelude::*; - /// All of the std alternative types. - #[doc(no_inline)] - pub use sp_std::prelude::*; - /// All FRAME-relevant derive macros. #[doc(no_inline)] pub use super::derive::*; @@ -164,7 +160,6 @@ pub mod testing_prelude { pub use frame_system::{self, mocking::*}; pub use sp_io::TestExternalities as TestState; - pub use sp_std::if_std; } /// All of the types and tools needed to build FRAME-based runtimes. @@ -347,13 +342,13 @@ pub mod primitives { /// This is already part of the [`prelude`]. pub mod derive { pub use codec::{Decode, Encode}; + pub use core::fmt::Debug; pub use frame_support::{ CloneNoBound, DebugNoBound, DefaultNoBound, EqNoBound, OrdNoBound, PartialEqNoBound, PartialOrdNoBound, RuntimeDebugNoBound, }; pub use scale_info::TypeInfo; pub use sp_runtime::RuntimeDebug; - pub use sp_std::fmt::Debug; } /// Access to all of the dependencies of this crate. In case the re-exports are not enough, this @@ -373,7 +368,6 @@ pub mod deps { pub use sp_core; pub use sp_io; pub use sp_runtime; - pub use sp_std; pub use codec; pub use scale_info; diff --git a/substrate/frame/staking/Cargo.toml b/substrate/frame/staking/Cargo.toml index afae4652a4ef2..57eeec543634d 100644 --- a/substrate/frame/staking/Cargo.toml +++ b/substrate/frame/staking/Cargo.toml @@ -24,7 +24,6 @@ scale-info = { features = ["derive", "serde"], workspace = true } sp-io = { workspace = true } sp-runtime = { features = ["serde"], workspace = true } sp-staking = { features = ["serde"], workspace = true } -sp-std = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } pallet-session = { features = [ @@ -74,7 +73,6 @@ std = [ "sp-npos-elections/std", "sp-runtime/std", "sp-staking/std", - "sp-std/std", "sp-tracing/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index 3ed33ffea4223..1f8580d7a3e67 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -33,7 +33,6 @@ use sp_runtime::{ Perbill, Percent, Saturating, }; use sp_staking::{currency_to_vote::CurrencyToVote, SessionIndex}; -use sp_std::prelude::*; pub use frame_benchmarking::v1::{ account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, @@ -169,7 +168,7 @@ impl ListScenario { // burn the entire issuance. let i = T::Currency::burn(T::Currency::total_issuance()); - sp_std::mem::forget(i); + core::mem::forget(i); // create accounts with the origin weight diff --git a/substrate/frame/staking/src/ledger.rs b/substrate/frame/staking/src/ledger.rs index 294918376d82c..dc4b4fc326b81 100644 --- a/substrate/frame/staking/src/ledger.rs +++ b/substrate/frame/staking/src/ledger.rs @@ -36,7 +36,6 @@ use frame_support::{ traits::{Defensive, LockableCurrency}, }; use sp_staking::{StakingAccount, StakingInterface}; -use sp_std::prelude::*; use crate::{ BalanceOf, Bonded, Config, Error, Ledger, Pallet, Payee, RewardDestination, StakingLedger, diff --git a/substrate/frame/staking/src/lib.rs b/substrate/frame/staking/src/lib.rs index 053ecdef2b00b..9e59cbd3d0cb8 100644 --- a/substrate/frame/staking/src/lib.rs +++ b/substrate/frame/staking/src/lib.rs @@ -304,6 +304,9 @@ pub mod weights; mod pallet; +extern crate alloc; + +use alloc::{collections::btree_map::BTreeMap, vec, vec::Vec}; use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; use frame_support::{ defensive, defensive_assert, @@ -325,7 +328,6 @@ use sp_staking::{ StakingAccount, }; pub use sp_staking::{Exposure, IndividualExposure, StakerStatus}; -use sp_std::{collections::btree_map::BTreeMap, prelude::*}; pub use weights::WeightInfo; pub use pallet::{pallet::*, UseNominatorsAndValidatorsMap, UseValidatorsMap}; @@ -674,7 +676,7 @@ impl StakingLedger { // slightly under-slashed, by at most `MaxUnlockingChunks * ED`, which is not a big // deal. slash_from_target = - sp_std::mem::replace(target, Zero::zero()).saturating_add(slash_from_target) + core::mem::replace(target, Zero::zero()).saturating_add(slash_from_target) } self.total = self.total.saturating_sub(slash_from_target); @@ -916,7 +918,7 @@ impl EraPayout for () { /// Adaptor to turn a `PiecewiseLinear` curve definition into an `EraPayout` impl, used for /// backwards compatibility. -pub struct ConvertCurve(sp_std::marker::PhantomData); +pub struct ConvertCurve(core::marker::PhantomData); impl EraPayout for ConvertCurve where Balance: AtLeast32BitUnsigned + Clone + Copy, @@ -974,7 +976,7 @@ impl Default for Forcing { /// A `Convert` implementation that finds the stash of the given controller account, /// if any. -pub struct StashOf(sp_std::marker::PhantomData); +pub struct StashOf(core::marker::PhantomData); impl Convert> for StashOf { fn convert(controller: T::AccountId) -> Option { @@ -987,7 +989,7 @@ impl Convert> for StashOf { /// /// Active exposure is the exposure of the validator set currently validating, i.e. in /// `active_era`. It can differ from the latest planned exposure in `current_era`. -pub struct ExposureOf(sp_std::marker::PhantomData); +pub struct ExposureOf(core::marker::PhantomData); impl Convert>>> for ExposureOf @@ -1000,7 +1002,7 @@ impl Convert /// Filter historical offences out and only allow those from the bonding period. pub struct FilterHistoricalOffences { - _inner: sp_std::marker::PhantomData<(T, R)>, + _inner: core::marker::PhantomData<(T, R)>, } impl ReportOffence @@ -1033,7 +1035,7 @@ where /// Wrapper struct for Era related information. It is not a pure encapsulation as these storage /// items can be accessed directly but nevertheless, its recommended to use `EraInfo` where we /// can and add more functions to it as needed. -pub struct EraInfo(sp_std::marker::PhantomData); +pub struct EraInfo(core::marker::PhantomData); impl EraInfo { /// Returns true if validator has one or more page of era rewards not claimed yet. // Also looks at legacy storage that can be cleaned up after #433. diff --git a/substrate/frame/staking/src/migrations.rs b/substrate/frame/staking/src/migrations.rs index b2ddf77004f95..5c9cf86132131 100644 --- a/substrate/frame/staking/src/migrations.rs +++ b/substrate/frame/staking/src/migrations.rs @@ -67,7 +67,7 @@ pub mod v15 { // The disabling strategy used by staking pallet type DefaultDisablingStrategy = UpToLimitDisablingStrategy; - pub struct VersionUncheckedMigrateV14ToV15(sp_std::marker::PhantomData); + pub struct VersionUncheckedMigrateV14ToV15(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV14ToV15 { fn on_runtime_upgrade() -> Weight { let mut migrated = v14::OffendingValidators::::take() @@ -382,14 +382,14 @@ pub mod v10 { pub mod v9 { use super::*; #[cfg(feature = "try-runtime")] - use codec::{Decode, Encode}; + use alloc::vec::Vec; #[cfg(feature = "try-runtime")] - use sp_std::vec::Vec; + use codec::{Decode, Encode}; /// Migration implementation that injects all validators into sorted list. /// /// This is only useful for chains that started their `VoterList` just based on nominators. - pub struct InjectValidatorsIntoVoterList(sp_std::marker::PhantomData); + pub struct InjectValidatorsIntoVoterList(core::marker::PhantomData); impl OnRuntimeUpgrade for InjectValidatorsIntoVoterList { fn on_runtime_upgrade() -> Weight { if StorageVersion::::get() == ObsoleteReleases::V8_0_0 { diff --git a/substrate/frame/staking/src/pallet/impls.rs b/substrate/frame/staking/src/pallet/impls.rs index 90374451a3a52..b19a127d13c43 100644 --- a/substrate/frame/staking/src/pallet/impls.rs +++ b/substrate/frame/staking/src/pallet/impls.rs @@ -48,7 +48,6 @@ use sp_staking::{ StakingAccount::{self, Controller, Stash}, StakingInterface, }; -use sp_std::prelude::*; use crate::{ election_size_tracker::StaticTracker, log, slashing, weights::WeightInfo, ActiveEraInfo, @@ -56,6 +55,7 @@ use crate::{ LedgerIntegrityState, MaxNominationsOf, MaxWinnersOf, Nominations, NominationsQuota, PositiveImbalanceOf, RewardDestination, SessionInterface, StakingLedger, ValidatorPrefs, }; +use alloc::{boxed::Box, vec, vec::Vec}; use super::pallet::*; @@ -1584,14 +1584,14 @@ impl ScoreProvider for Pallet { let imbalance = T::Currency::burn(T::Currency::total_issuance()); // kinda ugly, but gets the job done. The fact that this works here is a HUGE exception. // Don't try this pattern in other places. - sp_std::mem::forget(imbalance); + core::mem::forget(imbalance); } } /// A simple sorted list implementation that does not require any additional pallets. Note, this /// does not provide validators in sorted order. If you desire nominators in a sorted order take /// a look at [`pallet-bags-list`]. -pub struct UseValidatorsMap(sp_std::marker::PhantomData); +pub struct UseValidatorsMap(core::marker::PhantomData); impl SortedListProvider for UseValidatorsMap { type Score = BalanceOf; type Error = (); @@ -1657,7 +1657,7 @@ impl SortedListProvider for UseValidatorsMap { /// A simple voter list implementation that does not require any additional pallets. Note, this /// does not provided nominators in sorted ordered. If you desire nominators in a sorted order take /// a look at [`pallet-bags-list]. -pub struct UseNominatorsAndValidatorsMap(sp_std::marker::PhantomData); +pub struct UseNominatorsAndValidatorsMap(core::marker::PhantomData); impl SortedListProvider for UseNominatorsAndValidatorsMap { type Error = (); type Score = VoteWeight; @@ -1995,7 +1995,7 @@ impl Pallet { /// is resolved, turn warns into check /// failures. fn check_bonded_consistency() -> Result<(), TryRuntimeError> { - use sp_std::collections::btree_set::BTreeSet; + use alloc::collections::btree_set::BTreeSet; let mut count_controller_double = 0; let mut count_double = 0; @@ -2159,8 +2159,8 @@ impl Pallet { /// = exposure.own + exposure.own). /// * Paged exposures metadata (`ErasStakersOverview`) matches the paged exposures state. fn check_paged_exposures() -> Result<(), TryRuntimeError> { + use alloc::collections::btree_map::BTreeMap; use sp_staking::PagedExposureMetadata; - use sp_std::collections::btree_map::BTreeMap; // Sanity check for the paged exposure of the active era. let mut exposures: BTreeMap>> = diff --git a/substrate/frame/staking/src/pallet/mod.rs b/substrate/frame/staking/src/pallet/mod.rs index a76e47edf3803..79f9d298ada78 100644 --- a/substrate/frame/staking/src/pallet/mod.rs +++ b/substrate/frame/staking/src/pallet/mod.rs @@ -17,6 +17,7 @@ //! Staking FRAME Pallet. +use alloc::vec::Vec; use codec::Codec; use frame_election_provider_support::{ ElectionProvider, ElectionProviderBase, SortedListProvider, VoteWeight, @@ -41,7 +42,6 @@ use sp_staking::{ StakingAccount::{self, Controller, Stash}, StakingInterface, }; -use sp_std::prelude::*; mod impls; @@ -101,7 +101,7 @@ pub mod pallet { + codec::FullCodec + Copy + MaybeSerializeDeserialize - + sp_std::fmt::Debug + + core::fmt::Debug + Default + From + TypeInfo diff --git a/substrate/frame/staking/src/slashing.rs b/substrate/frame/staking/src/slashing.rs index 1fe608cd3358b..9bc8197c50b3e 100644 --- a/substrate/frame/staking/src/slashing.rs +++ b/substrate/frame/staking/src/slashing.rs @@ -54,6 +54,7 @@ use crate::{ NominatorSlashInEra, Pallet, Perbill, SessionInterface, SpanSlash, UnappliedSlash, ValidatorSlashInEra, }; +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ ensure, @@ -65,7 +66,6 @@ use sp_runtime::{ DispatchResult, RuntimeDebug, }; use sp_staking::{EraIndex, StakingInterface}; -use sp_std::vec::Vec; /// The proportion of the slashing reward to be paid out on the first slashing detection. /// This is f_1 in the paper. @@ -148,7 +148,7 @@ impl SlashingSpans { SlashingSpan { index, start, length: Some(length) } }); - sp_std::iter::once(last).chain(prior) + core::iter::once(last).chain(prior) } /// Yields the era index where the most recent non-zero slash occurred. @@ -182,7 +182,7 @@ impl SlashingSpans { }; // readjust the ongoing span, if it started before the beginning of the window. - self.last_start = sp_std::cmp::max(self.last_start, window_start); + self.last_start = core::cmp::max(self.last_start, window_start); pruned } } @@ -408,7 +408,7 @@ struct InspectingSpans<'a, T: Config + 'a> { paid_out: &'a mut BalanceOf, slash_of: &'a mut BalanceOf, reward_proportion: Perbill, - _marker: sp_std::marker::PhantomData, + _marker: core::marker::PhantomData, } // fetches the slashing spans record for a stash account, initializing it if necessary. @@ -433,7 +433,7 @@ fn fetch_spans<'a, T: Config + 'a>( slash_of, paid_out, reward_proportion, - _marker: sp_std::marker::PhantomData, + _marker: core::marker::PhantomData, } } @@ -451,7 +451,7 @@ impl<'a, T: 'a + Config> InspectingSpans<'a, T> { // although `amount` may be zero, as it is only a difference. fn add_slash(&mut self, amount: BalanceOf, slash_era: EraIndex) { *self.slash_of += amount; - self.spans.last_nonzero_slash = sp_std::cmp::max(self.spans.last_nonzero_slash, slash_era); + self.spans.last_nonzero_slash = core::cmp::max(self.spans.last_nonzero_slash, slash_era); } // find the span index of the given era, if covered. diff --git a/substrate/frame/staking/src/testing_utils.rs b/substrate/frame/staking/src/testing_utils.rs index d4938ea43ebe2..65aaa5f09de4e 100644 --- a/substrate/frame/staking/src/testing_utils.rs +++ b/substrate/frame/staking/src/testing_utils.rs @@ -30,7 +30,6 @@ use sp_io::hashing::blake2_256; use frame_election_provider_support::SortedListProvider; use frame_support::{pallet_prelude::*, traits::Currency}; use sp_runtime::{traits::StaticLookup, Perbill}; -use sp_std::prelude::*; const SEED: u32 = 0; diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 825b03b8ecaac..c35e5e8a06c6f 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -41,7 +41,6 @@ use sp_staking::{ offence::{OffenceDetails, OnOffenceHandler}, SessionIndex, }; -use sp_std::prelude::*; use substrate_test_utils::assert_eq_uvec; #[test] diff --git a/substrate/frame/state-trie-migration/Cargo.toml b/substrate/frame/state-trie-migration/Cargo.toml index 8bb4079715e2a..db8d10dabfdef 100644 --- a/substrate/frame/state-trie-migration/Cargo.toml +++ b/substrate/frame/state-trie-migration/Cargo.toml @@ -28,7 +28,6 @@ remote-externalities = { optional = true, workspace = true, default-features = t sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } substrate-state-trie-migration-rpc = { optional = true, workspace = true, default-features = true } [dev-dependencies] @@ -50,7 +49,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-tracing/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/state-trie-migration/src/lib.rs b/substrate/frame/state-trie-migration/src/lib.rs index 22ad640d3bd23..3fe5abb810313 100644 --- a/substrate/frame/state-trie-migration/src/lib.rs +++ b/substrate/frame/state-trie-migration/src/lib.rs @@ -55,6 +55,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + pub use pallet::*; pub mod weights; @@ -75,6 +77,8 @@ pub mod pallet { pub use crate::weights::WeightInfo; + use alloc::{vec, vec::Vec}; + use core::ops::Deref; use frame_support::{ dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, ensure, @@ -93,7 +97,6 @@ pub mod pallet { self, traits::{Saturating, Zero}, }; - use sp_std::{ops::Deref, prelude::*}; pub(crate) type BalanceOf = <::Currency as Inspect<::AccountId>>::Balance; @@ -169,11 +172,11 @@ pub mod pallet { pub(crate) child_items: u32, #[codec(skip)] - pub(crate) _ph: sp_std::marker::PhantomData, + pub(crate) _ph: core::marker::PhantomData, } - impl> sp_std::fmt::Debug for Progress { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { + impl> core::fmt::Debug for Progress { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Progress::ToStart => f.write_str("To start"), Progress::LastKey(key) => write!(f, "Last: {:?}", HexDisplay::from(key.deref())), @@ -182,8 +185,8 @@ pub mod pallet { } } - impl sp_std::fmt::Debug for MigrationTask { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { + impl core::fmt::Debug for MigrationTask { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("MigrationTask") .field("top", &self.progress_top) .field("child", &self.progress_child) @@ -953,8 +956,8 @@ pub mod pallet { #[cfg(feature = "runtime-benchmarks")] mod benchmarks { use super::{pallet::Pallet as StateTrieMigration, *}; + use alloc::vec; use frame_support::traits::fungible::{Inspect, Mutate}; - use sp_std::prelude::*; // The size of the key seemingly makes no difference in the read/write time, so we make it // constant. @@ -1080,7 +1083,7 @@ mod benchmarks { process_top_key { let v in 1 .. (4 * 1024 * 1024); - let value = sp_std::vec![1u8; v as usize]; + let value = alloc::vec![1u8; v as usize]; sp_io::storage::set(KEY, &value); }: { let data = sp_io::storage::get(KEY).unwrap(); @@ -1101,6 +1104,7 @@ mod benchmarks { mod mock { use super::*; use crate as pallet_state_trie_migration; + use alloc::{vec, vec::Vec}; use frame_support::{derive_impl, parameter_types, traits::Hooks, weights::Weight}; use frame_system::{EnsureRoot, EnsureSigned}; use sp_core::{ diff --git a/substrate/frame/statement/Cargo.toml b/substrate/frame/statement/Cargo.toml index 233b7255fc5db..000e5033d8f19 100644 --- a/substrate/frame/statement/Cargo.toml +++ b/substrate/frame/statement/Cargo.toml @@ -22,7 +22,6 @@ frame-system = { workspace = true } sp-statement-store = { workspace = true } sp-api = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } sp-core = { workspace = true } log = { workspace = true } @@ -44,7 +43,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-statement-store/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/statement/src/lib.rs b/substrate/frame/statement/src/lib.rs index c68dac2d29722..6a7f577ab0869 100644 --- a/substrate/frame/statement/src/lib.rs +++ b/substrate/frame/statement/src/lib.rs @@ -92,7 +92,7 @@ pub mod pallet { } #[pallet::pallet] - pub struct Pallet(sp_std::marker::PhantomData); + pub struct Pallet(core::marker::PhantomData); #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] diff --git a/substrate/frame/sudo/Cargo.toml b/substrate/frame/sudo/Cargo.toml index 5d5d09d692342..1a94753728b24 100644 --- a/substrate/frame/sudo/Cargo.toml +++ b/substrate/frame/sudo/Cargo.toml @@ -23,7 +23,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } docify = { workspace = true } @@ -41,7 +40,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/sudo/src/benchmarking.rs b/substrate/frame/sudo/src/benchmarking.rs index e64233fe7480a..dee7d09c9d0c6 100644 --- a/substrate/frame/sudo/src/benchmarking.rs +++ b/substrate/frame/sudo/src/benchmarking.rs @@ -19,6 +19,7 @@ use super::*; use crate::Pallet; +use alloc::{boxed::Box, vec}; use frame_benchmarking::v2::*; use frame_system::RawOrigin; diff --git a/substrate/frame/sudo/src/extension.rs b/substrate/frame/sudo/src/extension.rs index e90286e5a7c6b..fb7eaf7894806 100644 --- a/substrate/frame/sudo/src/extension.rs +++ b/substrate/frame/sudo/src/extension.rs @@ -17,6 +17,7 @@ use crate::{Config, Key}; use codec::{Decode, Encode}; +use core::{fmt, marker::PhantomData}; use frame_support::{dispatch::DispatchInfo, ensure}; use scale_info::TypeInfo; use sp_runtime::{ @@ -26,7 +27,6 @@ use sp_runtime::{ UnknownTransaction, ValidTransaction, }, }; -use sp_std::{fmt, marker::PhantomData}; /// Ensure that signed transactions are only valid if they are signed by sudo account. /// diff --git a/substrate/frame/sudo/src/lib.rs b/substrate/frame/sudo/src/lib.rs index 63b68e694307e..07296e90b6485 100644 --- a/substrate/frame/sudo/src/lib.rs +++ b/substrate/frame/sudo/src/lib.rs @@ -121,8 +121,11 @@ #![deny(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::boxed::Box; + use sp_runtime::{traits::StaticLookup, DispatchResult}; -use sp_std::prelude::*; use frame_support::{dispatch::GetDispatchInfo, traits::UnfilteredDispatchable}; diff --git a/substrate/frame/support/procedural/src/construct_runtime/expand/inherent.rs b/substrate/frame/support/procedural/src/construct_runtime/expand/inherent.rs index da483fa6cf0b6..c5fe8440d21be 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/expand/inherent.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/expand/inherent.rs @@ -58,17 +58,17 @@ pub fn expand_outer_inherent( trait InherentDataExt { fn create_extrinsics(&self) -> - #scrate::__private::sp_std::vec::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic>; + #scrate::__private::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic>; fn check_extrinsics(&self, block: &#block) -> #scrate::inherent::CheckInherentsResult; } impl InherentDataExt for #scrate::inherent::InherentData { fn create_extrinsics(&self) -> - #scrate::__private::sp_std::vec::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic> + #scrate::__private::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic> { use #scrate::inherent::ProvideInherent; - let mut inherents = #scrate::__private::sp_std::vec::Vec::new(); + let mut inherents = #scrate::__private::Vec::new(); #( #pallet_attrs diff --git a/substrate/frame/support/procedural/src/construct_runtime/expand/metadata.rs b/substrate/frame/support/procedural/src/construct_runtime/expand/metadata.rs index 0e76f9a92469a..daef1b171617f 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/expand/metadata.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/expand/metadata.rs @@ -111,7 +111,7 @@ pub fn expand_runtime_metadata( >(); #scrate::__private::metadata_ir::MetadataIR { - pallets: #scrate::__private::sp_std::vec![ #(#pallets),* ], + pallets: #scrate::__private::vec![ #(#pallets),* ], extrinsic: #scrate::__private::metadata_ir::ExtrinsicMetadataIR { ty, version: <#extrinsic as #scrate::sp_runtime::traits::ExtrinsicMetadata>::VERSION, @@ -156,7 +156,7 @@ pub fn expand_runtime_metadata( }) } - pub fn metadata_versions() -> #scrate::__private::sp_std::vec::Vec { + pub fn metadata_versions() -> #scrate::__private::Vec { #scrate::__private::metadata_ir::supported_versions() } } diff --git a/substrate/frame/support/procedural/src/construct_runtime/expand/origin.rs b/substrate/frame/support/procedural/src/construct_runtime/expand/origin.rs index 83049919d01c3..4a14853c04eec 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/expand/origin.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/expand/origin.rs @@ -105,25 +105,25 @@ pub fn expand_outer_origin( #[derive(Clone)] pub struct RuntimeOrigin { pub caller: OriginCaller, - filter: #scrate::__private::sp_std::rc::Rc::RuntimeCall) -> bool>>, + filter: #scrate::__private::Rc<#scrate::__private::Box::RuntimeCall) -> bool>>, } #[cfg(not(feature = "std"))] - impl #scrate::__private::sp_std::fmt::Debug for RuntimeOrigin { + impl core::fmt::Debug for RuntimeOrigin { fn fmt( &self, - fmt: &mut #scrate::__private::sp_std::fmt::Formatter, - ) -> #scrate::__private::sp_std::result::Result<(), #scrate::__private::sp_std::fmt::Error> { + fmt: &mut core::fmt::Formatter, + ) -> core::result::Result<(), core::fmt::Error> { fmt.write_str("") } } #[cfg(feature = "std")] - impl #scrate::__private::sp_std::fmt::Debug for RuntimeOrigin { + impl core::fmt::Debug for RuntimeOrigin { fn fmt( &self, - fmt: &mut #scrate::__private::sp_std::fmt::Formatter, - ) -> #scrate::__private::sp_std::result::Result<(), #scrate::__private::sp_std::fmt::Error> { + fmt: &mut core::fmt::Formatter, + ) -> core::result::Result<(), core::fmt::Error> { fmt.debug_struct("Origin") .field("caller", &self.caller) .field("filter", &"[function ptr]") @@ -139,7 +139,7 @@ pub fn expand_outer_origin( fn add_filter(&mut self, filter: impl Fn(&Self::Call) -> bool + 'static) { let f = self.filter.clone(); - self.filter = #scrate::__private::sp_std::rc::Rc::new(Box::new(move |call| { + self.filter = #scrate::__private::Rc::new(#scrate::__private::Box::new(move |call| { f(call) && filter(call) })); } @@ -150,7 +150,7 @@ pub fn expand_outer_origin( as #scrate::traits::Contains<<#runtime as #system_path::Config>::RuntimeCall> >::contains; - self.filter = #scrate::__private::sp_std::rc::Rc::new(Box::new(filter)); + self.filter = #scrate::__private::Rc::new(#scrate::__private::Box::new(filter)); } fn set_caller_from(&mut self, other: impl Into) { @@ -252,7 +252,7 @@ pub fn expand_outer_origin( impl TryFrom for #system_path::Origin<#runtime> { type Error = OriginCaller; fn try_from(x: OriginCaller) - -> #scrate::__private::sp_std::result::Result<#system_path::Origin<#runtime>, OriginCaller> + -> core::result::Result<#system_path::Origin<#runtime>, OriginCaller> { if let OriginCaller::system(l) = x { Ok(l) @@ -275,7 +275,7 @@ pub fn expand_outer_origin( fn from(x: OriginCaller) -> Self { let mut o = RuntimeOrigin { caller: x, - filter: #scrate::__private::sp_std::rc::Rc::new(Box::new(|_| true)), + filter: #scrate::__private::Rc::new(#scrate::__private::Box::new(|_| true)), }; #scrate::traits::OriginTrait::reset_filter(&mut o); @@ -284,7 +284,7 @@ pub fn expand_outer_origin( } } - impl From for #scrate::__private::sp_std::result::Result<#system_path::Origin<#runtime>, RuntimeOrigin> { + impl From for core::result::Result<#system_path::Origin<#runtime>, RuntimeOrigin> { /// NOTE: converting to pallet origin loses the origin filter information. fn from(val: RuntimeOrigin) -> Self { if let OriginCaller::system(l) = val.caller { @@ -349,7 +349,7 @@ fn expand_origin_caller_variant( } fn expand_origin_pallet_conversions( - scrate: &TokenStream, + _scrate: &TokenStream, runtime: &Ident, pallet: &Pallet, instance: Option<&Ident>, @@ -394,7 +394,7 @@ fn expand_origin_pallet_conversions( } #attr - impl From for #scrate::__private::sp_std::result::Result<#pallet_origin, RuntimeOrigin> { + impl From for core::result::Result<#pallet_origin, RuntimeOrigin> { /// NOTE: converting to pallet origin loses the origin filter information. fn from(val: RuntimeOrigin) -> Self { if let OriginCaller::#variant_name(l) = val.caller { @@ -410,7 +410,7 @@ fn expand_origin_pallet_conversions( type Error = OriginCaller; fn try_from( x: OriginCaller, - ) -> #scrate::__private::sp_std::result::Result<#pallet_origin, OriginCaller> { + ) -> core::result::Result<#pallet_origin, OriginCaller> { if let OriginCaller::#variant_name(l) = x { Ok(l) } else { @@ -424,7 +424,7 @@ fn expand_origin_pallet_conversions( type Error = (); fn try_from( x: &'a OriginCaller, - ) -> #scrate::__private::sp_std::result::Result<&'a #pallet_origin, ()> { + ) -> core::result::Result<&'a #pallet_origin, ()> { if let OriginCaller::#variant_name(l) = x { Ok(&l) } else { @@ -438,7 +438,7 @@ fn expand_origin_pallet_conversions( type Error = (); fn try_from( x: &'a RuntimeOrigin, - ) -> #scrate::__private::sp_std::result::Result<&'a #pallet_origin, ()> { + ) -> core::result::Result<&'a #pallet_origin, ()> { if let OriginCaller::#variant_name(l) = &x.caller { Ok(&l) } else { diff --git a/substrate/frame/support/procedural/src/construct_runtime/mod.rs b/substrate/frame/support/procedural/src/construct_runtime/mod.rs index 1505d158895f0..17042c2487803 100644 --- a/substrate/frame/support/procedural/src/construct_runtime/mod.rs +++ b/substrate/frame/support/procedural/src/construct_runtime/mod.rs @@ -470,7 +470,7 @@ fn construct_runtime_final_expansion( #[doc(hidden)] trait InternalConstructRuntime { #[inline(always)] - fn runtime_metadata(&self) -> #scrate::__private::sp_std::vec::Vec<#scrate::__private::metadata_ir::RuntimeApiMetadataIR> { + fn runtime_metadata(&self) -> #scrate::__private::Vec<#scrate::__private::metadata_ir::RuntimeApiMetadataIR> { Default::default() } } @@ -669,10 +669,10 @@ pub(crate) fn decl_pallet_runtime_setup( impl #scrate::traits::PalletInfo for PalletInfo { fn index() -> Option { - let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); + let type_id = core::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { + if type_id == core::any::TypeId::of::<#names>() { return Some(#indices) } )* @@ -681,10 +681,10 @@ pub(crate) fn decl_pallet_runtime_setup( } fn name() -> Option<&'static str> { - let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); + let type_id = core::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { + if type_id == core::any::TypeId::of::<#names>() { return Some(#name_strings) } )* @@ -693,10 +693,10 @@ pub(crate) fn decl_pallet_runtime_setup( } fn name_hash() -> Option<[u8; 16]> { - let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); + let type_id = core::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { + if type_id == core::any::TypeId::of::<#names>() { return Some(#name_hashes) } )* @@ -705,10 +705,10 @@ pub(crate) fn decl_pallet_runtime_setup( } fn module_name() -> Option<&'static str> { - let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); + let type_id = core::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { + if type_id == core::any::TypeId::of::<#names>() { return Some(#module_names) } )* @@ -717,10 +717,10 @@ pub(crate) fn decl_pallet_runtime_setup( } fn crate_version() -> Option<#scrate::traits::CrateVersion> { - let type_id = #scrate::__private::sp_std::any::TypeId::of::

(); + let type_id = core::any::TypeId::of::

(); #( #pallet_attrs - if type_id == #scrate::__private::sp_std::any::TypeId::of::<#names>() { + if type_id == core::any::TypeId::of::<#names>() { return Some( <#pallet_structs as #scrate::traits::PalletInfoAccess>::crate_version() ) diff --git a/substrate/frame/support/procedural/src/pallet/expand/constants.rs b/substrate/frame/support/procedural/src/pallet/expand/constants.rs index d7fbb5a718973..a36df790bd298 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/constants.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/constants.rs @@ -88,7 +88,7 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream { name: #ident_str, ty: #frame_support::__private::scale_info::meta_type::<#const_type>(), value: { #default_byte_impl }, - docs: #frame_support::__private::sp_std::vec![ #( #doc ),* ], + docs: #frame_support::__private::vec![ #( #doc ),* ], } }) }); @@ -98,9 +98,9 @@ pub fn expand_constants(def: &mut Def) -> proc_macro2::TokenStream { #[doc(hidden)] pub fn pallet_constants_metadata() - -> #frame_support::__private::sp_std::vec::Vec<#frame_support::__private::metadata_ir::PalletConstantMetadataIR> + -> #frame_support::__private::Vec<#frame_support::__private::metadata_ir::PalletConstantMetadataIR> { - #frame_support::__private::sp_std::vec![ #( #consts ),* ] + #frame_support::__private::vec![ #( #consts ),* ] } } ) diff --git a/substrate/frame/support/procedural/src/pallet/expand/documentation.rs b/substrate/frame/support/procedural/src/pallet/expand/documentation.rs index ec19f889a9f20..e2c72ee921c46 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/documentation.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/documentation.rs @@ -163,9 +163,9 @@ pub fn expand_documentation(def: &mut Def) -> proc_macro2::TokenStream { #[doc(hidden)] pub fn pallet_documentation_metadata() - -> #frame_support::__private::sp_std::vec::Vec<&'static str> + -> #frame_support::__private::Vec<&'static str> { - #frame_support::__private::sp_std::vec![ #( #docs ),* ] + #frame_support::__private::vec![ #( #docs ),* ] } } ) diff --git a/substrate/frame/support/procedural/src/pallet/expand/error.rs b/substrate/frame/support/procedural/src/pallet/expand/error.rs index b921d66ff9e73..05478ee390841 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/error.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/error.rs @@ -66,7 +66,7 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream { #[doc(hidden)] #[codec(skip)] __Ignore( - #frame_support::__private::sp_std::marker::PhantomData<(#type_use_gen)>, + core::marker::PhantomData<(#type_use_gen)>, #frame_support::Never, ) ); @@ -124,11 +124,11 @@ pub fn expand_error(def: &mut Def) -> proc_macro2::TokenStream { } quote::quote_spanned!(error.attr_span => - impl<#type_impl_gen> #frame_support::__private::sp_std::fmt::Debug for #error_ident<#type_use_gen> + impl<#type_impl_gen> core::fmt::Debug for #error_ident<#type_use_gen> #config_where_clause { - fn fmt(&self, f: &mut #frame_support::__private::sp_std::fmt::Formatter<'_>) - -> #frame_support::__private::sp_std::fmt::Result + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) + -> core::fmt::Result { f.write_str(self.as_str()) } diff --git a/substrate/frame/support/procedural/src/pallet/expand/hooks.rs b/substrate/frame/support/procedural/src/pallet/expand/hooks.rs index 3623b595268d0..d7b1ca14f574b 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/hooks.rs @@ -255,7 +255,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<#frame_support::__private::sp_std::vec::Vec, #frame_support::sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result<#frame_support::__private::Vec, #frame_support::sp_runtime::TryRuntimeError> { < Self as @@ -264,7 +264,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { } #[cfg(feature = "try-runtime")] - fn post_upgrade(state: #frame_support::__private::sp_std::vec::Vec) -> Result<(), #frame_support::sp_runtime::TryRuntimeError> { + fn post_upgrade(state: #frame_support::__private::Vec) -> Result<(), #frame_support::sp_runtime::TryRuntimeError> { #post_storage_version_check < diff --git a/substrate/frame/support/procedural/src/pallet/expand/pallet_struct.rs b/substrate/frame/support/procedural/src/pallet/expand/pallet_struct.rs index 7cdf6bde9de87..7ebc4bb2e9dc2 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/pallet_struct.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/pallet_struct.rs @@ -54,7 +54,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream { if let Some(field) = pallet_item.fields.iter_mut().next() { if field.ty == syn::parse_quote!(_) { field.ty = syn::parse_quote!( - #frame_support::__private::sp_std::marker::PhantomData<(#type_use_gen)> + core::marker::PhantomData<(#type_use_gen)> ); } } @@ -139,10 +139,10 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream { #storages_where_clauses { fn storage_info() - -> #frame_support::__private::sp_std::vec::Vec<#frame_support::traits::StorageInfo> + -> #frame_support::__private::Vec<#frame_support::traits::StorageInfo> { #[allow(unused_mut)] - let mut res = #frame_support::__private::sp_std::vec![]; + let mut res = #frame_support::__private::vec![]; #( #(#storage_cfg_attrs)* @@ -179,8 +179,8 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream { let whitelisted_storage_keys_impl = quote::quote![ use #frame_support::traits::{StorageInfoTrait, TrackedStorageKey, WhitelistedStorageKeys}; impl<#type_impl_gen> WhitelistedStorageKeys for #pallet_ident<#type_use_gen> #storages_where_clauses { - fn whitelisted_storage_keys() -> #frame_support::__private::sp_std::vec::Vec { - use #frame_support::__private::sp_std::vec; + fn whitelisted_storage_keys() -> #frame_support::__private::Vec { + use #frame_support::__private::vec; vec![#( TrackedStorageKey::new(#whitelisted_storage_idents::<#type_use_gen>::hashed_key().to_vec()) ),*] @@ -272,7 +272,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream { #config_where_clause { fn count() -> usize { 1 } - fn infos() -> #frame_support::__private::sp_std::vec::Vec<#frame_support::traits::PalletInfoData> { + fn infos() -> #frame_support::__private::Vec<#frame_support::traits::PalletInfoData> { use #frame_support::traits::PalletInfoAccess; let item = #frame_support::traits::PalletInfoData { index: Self::index(), @@ -280,7 +280,7 @@ pub fn expand_pallet_struct(def: &mut Def) -> proc_macro2::TokenStream { module_name: Self::module_name(), crate_version: Self::crate_version(), }; - #frame_support::__private::sp_std::vec![item] + #frame_support::__private::vec![item] } } diff --git a/substrate/frame/support/procedural/src/pallet/expand/storage.rs b/substrate/frame/support/procedural/src/pallet/expand/storage.rs index 3cc8a843e3b16..267b0f2dd3ba4 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/storage.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/storage.rs @@ -423,7 +423,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { #(#cfg_attrs)* { <#full_ident as #frame_support::storage::StorageEntryMetadataBuilder>::build_metadata( - #frame_support::__private::sp_std::vec![ + #frame_support::__private::vec![ #( #docs, )* ], &mut entries, @@ -853,7 +853,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { impl<#type_impl_gen> #frame_support::traits::TryDecodeEntireStorage for #pallet_ident<#type_use_gen> #completed_where_clause { - fn try_decode_entire_state() -> Result> { + fn try_decode_entire_state() -> Result> { let pallet_name = <::PalletInfo as #frame_support::traits::PalletInfo> ::name::<#pallet_ident<#type_use_gen>>() .expect("Every active pallet has a name in the runtime; qed"); @@ -861,7 +861,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { #frame_support::__private::log::debug!(target: "runtime::try-decode-state", "trying to decode pallet: {pallet_name}"); // NOTE: for now, we have to exclude storage items that are feature gated. - let mut errors = #frame_support::__private::sp_std::vec::Vec::new(); + let mut errors = #frame_support::__private::Vec::new(); let mut decoded = 0usize; #( @@ -902,7 +902,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream { .expect("No name found for the pallet in the runtime! This usually means that the pallet wasn't added to `construct_runtime!`."), entries: { #[allow(unused_mut)] - let mut entries = #frame_support::__private::sp_std::vec![]; + let mut entries = #frame_support::__private::vec![]; #( #entries_builder )* entries }, diff --git a/substrate/frame/support/procedural/src/pallet/expand/tasks.rs b/substrate/frame/support/procedural/src/pallet/expand/tasks.rs index 6697e5c822a31..7201c352d92cd 100644 --- a/substrate/frame/support/procedural/src/pallet/expand/tasks.rs +++ b/substrate/frame/support/procedural/src/pallet/expand/tasks.rs @@ -159,7 +159,6 @@ impl ToTokens for TasksDef { let task_fn_names = self.tasks.iter().map(|task| &task.item.sig.ident); let task_arg_names = self.tasks.iter().map(|task| &task.arg_names).collect::>(); - let sp_std = quote!(#scrate::__private::sp_std); let impl_generics = &self.item_impl.generics; tokens.extend(quote! { impl #impl_generics #enum_use @@ -169,13 +168,13 @@ impl ToTokens for TasksDef { impl #impl_generics #scrate::traits::Task for #enum_use { - type Enumeration = #sp_std::vec::IntoIter<#enum_use>; + type Enumeration = #scrate::__private::IntoIter<#enum_use>; fn iter() -> Self::Enumeration { - let mut all_tasks = #sp_std::vec![]; + let mut all_tasks = #scrate::__private::vec![]; #(all_tasks .extend(#task_iters.map(|(#(#task_arg_names),*)| #enum_ident::#task_fn_idents { #(#task_arg_names: #task_arg_names.clone()),* }) - .collect::<#sp_std::vec::Vec<_>>()); + .collect::<#scrate::__private::Vec<_>>()); )* all_tasks.into_iter() } diff --git a/substrate/frame/support/procedural/src/pallet/parse/tests/tasks.rs b/substrate/frame/support/procedural/src/pallet/parse/tests/tasks.rs index 9f14362840473..7df91ae777d7f 100644 --- a/substrate/frame/support/procedural/src/pallet/parse/tests/tasks.rs +++ b/substrate/frame/support/procedural/src/pallet/parse/tests/tasks.rs @@ -124,10 +124,10 @@ fn test_parse_pallet_manual_tasks_impl_without_manual_tasks_enum() { where T: TypeInfo, { - type Enumeration = sp_std::vec::IntoIter>; + type Enumeration = alloc::vec::IntoIter>; fn iter() -> Self::Enumeration { - sp_std::vec![Task::increment, Task::decrement].into_iter() + alloc::vec![Task::increment, Task::decrement].into_iter() } } diff --git a/substrate/frame/support/procedural/src/runtime/expand/mod.rs b/substrate/frame/support/procedural/src/runtime/expand/mod.rs index 3cdfb06cb6eaa..f34ab1cef5436 100644 --- a/substrate/frame/support/procedural/src/runtime/expand/mod.rs +++ b/substrate/frame/support/procedural/src/runtime/expand/mod.rs @@ -280,7 +280,7 @@ fn construct_runtime_final_expansion( #[doc(hidden)] trait InternalConstructRuntime { #[inline(always)] - fn runtime_metadata(&self) -> #scrate::__private::sp_std::vec::Vec<#scrate::__private::metadata_ir::RuntimeApiMetadataIR> { + fn runtime_metadata(&self) -> #scrate::__private::Vec<#scrate::__private::metadata_ir::RuntimeApiMetadataIR> { Default::default() } } diff --git a/substrate/frame/support/src/dispatch.rs b/substrate/frame/support/src/dispatch.rs index 4a313551aca63..351ba3a15efcc 100644 --- a/substrate/frame/support/src/dispatch.rs +++ b/substrate/frame/support/src/dispatch.rs @@ -20,6 +20,7 @@ use crate::traits::UnfilteredDispatchable; use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; +use core::fmt; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; @@ -28,7 +29,6 @@ use sp_runtime::{ traits::SignedExtension, DispatchError, RuntimeDebug, }; -use sp_std::fmt; use sp_weights::Weight; /// The return type of a `Dispatchable` in frame. When returned explicitly from @@ -220,14 +220,14 @@ pub trait OneOrMany { } impl OneOrMany for DispatchClass { - type Iter = sp_std::iter::Once; + type Iter = core::iter::Once; fn into_iter(self) -> Self::Iter { - sp_std::iter::once(self) + core::iter::once(self) } } impl<'a> OneOrMany for &'a [DispatchClass] { - type Iter = sp_std::iter::Cloned>; + type Iter = core::iter::Cloned>; fn into_iter(self) -> Self::Iter { self.iter().cloned() } diff --git a/substrate/frame/support/src/dispatch_context.rs b/substrate/frame/support/src/dispatch_context.rs index 254302c8f14d2..b34c6bdada3d4 100644 --- a/substrate/frame/support/src/dispatch_context.rs +++ b/substrate/frame/support/src/dispatch_context.rs @@ -81,11 +81,11 @@ //! In your pallet you will only have to use [`with_context`], because as described above //! [`run_in_context`] will be handled by FRAME for you. -use sp_std::{ - any::{Any, TypeId}, +use alloc::{ boxed::Box, collections::btree_map::{BTreeMap, Entry}, }; +use core::any::{Any, TypeId}; environmental::environmental!(DISPATCH_CONTEXT: BTreeMap>); @@ -158,7 +158,7 @@ pub fn with_context(callback: impl FnOnce(&mut Value) -> R) -> if value.is_none() { log::error!( "Failed to downcast value for type {} in dispatch context!", - sp_std::any::type_name::(), + core::any::type_name::(), ); } diff --git a/substrate/frame/support/src/genesis_builder_helper.rs b/substrate/frame/support/src/genesis_builder_helper.rs index 7389c5a787d76..662ea2cb1862d 100644 --- a/substrate/frame/support/src/genesis_builder_helper.rs +++ b/substrate/frame/support/src/genesis_builder_helper.rs @@ -41,7 +41,7 @@ pub fn build_state(json: Vec) -> BuildResult { /// to [`sp_genesis_builder::GenesisBuilder::get_preset`]. pub fn get_preset( name: &Option, - preset_for_name: impl FnOnce(&sp_genesis_builder::PresetId) -> Option>, + preset_for_name: impl FnOnce(&sp_genesis_builder::PresetId) -> Option>, ) -> Option> where GC: BuildGenesisConfig + Default, diff --git a/substrate/frame/support/src/hash.rs b/substrate/frame/support/src/hash.rs index 9c48f4b187ad3..a09890560c644 100644 --- a/substrate/frame/support/src/hash.rs +++ b/substrate/frame/support/src/hash.rs @@ -17,10 +17,10 @@ //! Hash utilities. +use alloc::vec::Vec; use codec::{Codec, MaxEncodedLen}; use sp_io::hashing::{blake2_128, blake2_256, twox_128, twox_256, twox_64}; use sp_metadata_ir as metadata_ir; -use sp_std::prelude::Vec; // This trait must be kept coherent with frame-support-procedural HasherKind usage pub trait Hashable: Sized { diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs index 94f4b9dd4bdcc..3ad8c5fabaa2c 100644 --- a/substrate/frame/support/src/lib.rs +++ b/substrate/frame/support/src/lib.rs @@ -33,11 +33,20 @@ #[doc(hidden)] extern crate self as frame_support; +#[doc(hidden)] +extern crate alloc; + /// Private exports that are being used by macros. /// /// The exports are not stable and should not be relied on. #[doc(hidden)] pub mod __private { + pub use alloc::{ + boxed::Box, + rc::Rc, + vec, + vec::{IntoIter, Vec}, + }; pub use codec; pub use frame_metadata as metadata; pub use log; @@ -261,7 +270,7 @@ macro_rules! parameter_types { ) => ( $( #[ $attr ] )* $vis struct $name $( - < $($ty_params),* >( $($crate::__private::sp_std::marker::PhantomData<$ty_params>),* ) + < $($ty_params),* >( $(core::marker::PhantomData<$ty_params>),* ) )?; $crate::parameter_types!(IMPL_CONST $name , $type , $value $( $(, $ty_params)* )?); $crate::parameter_types!( $( $rest )* ); @@ -273,7 +282,7 @@ macro_rules! parameter_types { ) => ( $( #[ $attr ] )* $vis struct $name $( - < $($ty_params),* >( $($crate::__private::sp_std::marker::PhantomData<$ty_params>),* ) + < $($ty_params),* >( $(core::marker::PhantomData<$ty_params>),* ) )?; $crate::parameter_types!(IMPL $name, $type, $value $( $(, $ty_params)* )?); $crate::parameter_types!( $( $rest )* ); @@ -285,7 +294,7 @@ macro_rules! parameter_types { ) => ( $( #[ $attr ] )* $vis struct $name $( - < $($ty_params),* >( $($crate::__private::sp_std::marker::PhantomData<$ty_params>),* ) + < $($ty_params),* >( $(core::marker::PhantomData<$ty_params>),* ) )?; $crate::parameter_types!(IMPL_STORAGE $name, $type, $value $( $(, $ty_params)* )?); $crate::parameter_types!( $( $rest )* ); @@ -468,7 +477,7 @@ macro_rules! ord_parameter_types { (IMPL $name:ident , $type:ty , $value:expr) => { impl $crate::traits::SortedMembers<$type> for $name { fn contains(t: &$type) -> bool { &$value == t } - fn sorted_members() -> $crate::__private::sp_std::prelude::Vec<$type> { vec![$value] } + fn sorted_members() -> $crate::__private::Vec<$type> { vec![$value] } fn count() -> usize { 1 } #[cfg(feature = "runtime-benchmarks")] fn add(_: &$type) {} @@ -499,7 +508,7 @@ macro_rules! runtime_print { } /// Print out the debuggable type. -pub fn debug(data: &impl sp_std::fmt::Debug) { +pub fn debug(data: &impl core::fmt::Debug) { runtime_print!("{:?}", data); } @@ -926,6 +935,7 @@ pub mod pallet_prelude { pub use codec::{Decode, Encode, MaxEncodedLen}; pub use frame_support::pallet_macros::*; + pub use core::marker::PhantomData; /// The optional attribute `#[inject_runtime_type]` can be attached to `RuntimeCall`, /// `RuntimeEvent`, `RuntimeOrigin` or `PalletInfo` in an impl statement that has /// `#[register_default_impl]` attached to indicate that this item is generated by @@ -954,7 +964,6 @@ pub mod pallet_prelude { }, DispatchError, RuntimeDebug, MAX_MODULE_ERROR_ENCODED_SIZE, }; - pub use sp_std::marker::PhantomData; pub use sp_weights::Weight; } @@ -1285,7 +1294,7 @@ pub mod pallet_macros { /// # use frame_support::pallet_prelude::*; /// # use frame_support::inherent::IsFatalError; /// # use sp_timestamp::InherentError; - /// # use sp_std::result; + /// # use core::result; /// # /// // Example inherent identifier /// pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0"; @@ -1911,7 +1920,7 @@ pub mod pallet_macros { /// Field types in enum variants must also implement [`frame_support::PalletError`], /// otherwise the pallet will fail to compile. Rust primitive types have already /// implemented the [`frame_support::PalletError`] trait along with some commonly used - /// stdlib types such as [`Option`] and [`sp_std::marker::PhantomData`], and hence + /// stdlib types such as [`Option`] and [`core::marker::PhantomData`], and hence /// in most use cases, a manual implementation is not necessary and is discouraged. /// /// The generic `T` must not bound anything and a `where` clause is not allowed. That said, diff --git a/substrate/frame/support/src/migrations.rs b/substrate/frame/support/src/migrations.rs index fa018d743653f..7f74614695640 100644 --- a/substrate/frame/support/src/migrations.rs +++ b/substrate/frame/support/src/migrations.rs @@ -24,13 +24,14 @@ use crate::{ }, weights::{RuntimeDbWeight, Weight, WeightMeter}, }; +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; +use core::marker::PhantomData; use impl_trait_for_tuples::impl_for_tuples; use sp_arithmetic::traits::Bounded; use sp_core::Get; use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult}; use sp_runtime::traits::Zero; -use sp_std::{marker::PhantomData, vec::Vec}; /// Handles storage migration pallet versioning. /// @@ -71,7 +72,7 @@ use sp_std::{marker::PhantomData, vec::Vec}; /// /// - https://internals.rust-lang.org/t/lang-team-minutes-private-in-public-rules/4504/40 /// mod version_unchecked { /// use super::*; -/// pub struct VersionUncheckedMigrateV5ToV6(sp_std::marker::PhantomData); +/// pub struct VersionUncheckedMigrateV5ToV6(core::marker::PhantomData); /// impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV5ToV6 { /// // `UncheckedOnRuntimeUpgrade` implementation... /// } @@ -102,7 +103,7 @@ pub struct VersionedMigration), + MigrationExecuted(alloc::vec::Vec), /// This migration is a noop, do not run post_upgrade checks. Noop, } @@ -125,7 +126,7 @@ impl< /// [`VersionedPostUpgradeData`] before passing them to post_upgrade, so it knows whether the /// migration ran or not. #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { let on_chain_version = Pallet::on_chain_storage_version(); if on_chain_version == FROM { Ok(VersionedPostUpgradeData::MigrationExecuted(Inner::pre_upgrade()?).encode()) @@ -175,7 +176,7 @@ impl< /// the migration ran, and [`VersionedPostUpgradeData::Noop`] otherwise. #[cfg(feature = "try-runtime")] fn post_upgrade( - versioned_post_upgrade_data_bytes: sp_std::vec::Vec, + versioned_post_upgrade_data_bytes: alloc::vec::Vec, ) -> Result<(), sp_runtime::TryRuntimeError> { use codec::DecodeAll; match ::decode_all(&mut &versioned_post_upgrade_data_bytes[..]) @@ -339,7 +340,7 @@ impl, DbWeight: Get> frame_support::traits } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { use crate::storage::unhashed::contains_prefixed_key; let hashed_prefix = twox_128(P::get().as_bytes()); @@ -350,11 +351,11 @@ impl, DbWeight: Get> frame_support::traits P::get() ), }; - Ok(sp_std::vec::Vec::new()) + Ok(alloc::vec::Vec::new()) } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: sp_std::vec::Vec) -> Result<(), sp_runtime::TryRuntimeError> { + fn post_upgrade(_state: alloc::vec::Vec) -> Result<(), sp_runtime::TryRuntimeError> { use crate::storage::unhashed::contains_prefixed_key; let hashed_prefix = twox_128(P::get().as_bytes()); @@ -450,7 +451,7 @@ impl, S: Get<&'static str>, DbWeight: Get> } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { use crate::storage::unhashed::contains_prefixed_key; let hashed_prefix = storage_prefix(P::get().as_bytes(), S::get().as_bytes()); @@ -466,7 +467,7 @@ impl, S: Get<&'static str>, DbWeight: Get> } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: sp_std::vec::Vec) -> Result<(), sp_runtime::TryRuntimeError> { + fn post_upgrade(_state: alloc::vec::Vec) -> Result<(), sp_runtime::TryRuntimeError> { use crate::storage::unhashed::contains_prefixed_key; let hashed_prefix = storage_prefix(P::get().as_bytes(), S::get().as_bytes()); diff --git a/substrate/frame/support/src/storage/bounded_btree_map.rs b/substrate/frame/support/src/storage/bounded_btree_map.rs index 91196be9e802c..d3560dd5f0d4d 100644 --- a/substrate/frame/support/src/storage/bounded_btree_map.rs +++ b/substrate/frame/support/src/storage/bounded_btree_map.rs @@ -26,9 +26,9 @@ impl StorageDecodeLength for BoundedBTreeMap {} pub mod test { use super::*; use crate::Twox128; + use alloc::collections::btree_map::BTreeMap; use frame_support::traits::{ConstU32, Get}; use sp_io::TestExternalities; - use sp_std::collections::btree_map::BTreeMap; #[crate::storage_alias] type Foo = StorageValue>>; diff --git a/substrate/frame/support/src/storage/bounded_btree_set.rs b/substrate/frame/support/src/storage/bounded_btree_set.rs index cf801eb47874f..70ab2304cab01 100644 --- a/substrate/frame/support/src/storage/bounded_btree_set.rs +++ b/substrate/frame/support/src/storage/bounded_btree_set.rs @@ -26,9 +26,9 @@ impl StorageDecodeNonDedupLength for BoundedBTreeSet {} pub mod test { use super::*; use crate::Twox128; + use alloc::collections::btree_set::BTreeSet; use frame_support::traits::{ConstU32, Get}; use sp_io::TestExternalities; - use sp_std::collections::btree_set::BTreeSet; #[crate::storage_alias] type Foo = StorageValue>>; diff --git a/substrate/frame/support/src/storage/child.rs b/substrate/frame/support/src/storage/child.rs index 76e6f4ee4023e..5ebba26936585 100644 --- a/substrate/frame/support/src/storage/child.rs +++ b/substrate/frame/support/src/storage/child.rs @@ -21,10 +21,10 @@ // NOTE: could replace unhashed by having only one kind of storage (top trie being the child info // of null length parent storage key). +use alloc::vec::Vec; use codec::{Codec, Decode, Encode}; pub use sp_core::storage::{ChildInfo, ChildType, StateVersion}; pub use sp_io::{KillStorageResult, MultiRemovalResults}; -use sp_std::prelude::*; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. pub fn get(child_info: &ChildInfo, key: &[u8]) -> Option { diff --git a/substrate/frame/support/src/storage/generator/double_map.rs b/substrate/frame/support/src/storage/generator/double_map.rs index a4c1f58203e3c..b68f3fa495ff9 100644 --- a/substrate/frame/support/src/storage/generator/double_map.rs +++ b/substrate/frame/support/src/storage/generator/double_map.rs @@ -20,8 +20,8 @@ use crate::{ storage::{self, storage_prefix, unhashed, KeyPrefixIterator, PrefixIterator, StorageAppend}, Never, }; +use alloc::vec::Vec; use codec::{Decode, Encode, EncodeLike, FullCodec, FullEncode}; -use sp_std::prelude::*; /// Generator for `StorageDoubleMap` used by `decl_storage`. /// @@ -516,6 +516,7 @@ mod test_iterators { unhashed, }, }; + use alloc::vec; use codec::Encode; #[test] diff --git a/substrate/frame/support/src/storage/generator/map.rs b/substrate/frame/support/src/storage/generator/map.rs index 257aa7e7bcf9a..b41f9c7171670 100644 --- a/substrate/frame/support/src/storage/generator/map.rs +++ b/substrate/frame/support/src/storage/generator/map.rs @@ -20,9 +20,8 @@ use crate::{ storage::{self, storage_prefix, unhashed, KeyPrefixIterator, PrefixIterator, StorageAppend}, Never, }; +use alloc::vec::Vec; use codec::{Decode, Encode, EncodeLike, FullCodec, FullEncode}; -#[cfg(not(feature = "std"))] -use sp_std::prelude::*; /// Generator for `StorageMap` used by `decl_storage`. /// @@ -80,7 +79,7 @@ pub struct StorageMapIterator { prefix: Vec, previous_key: Vec, drain: bool, - _phantom: ::sp_std::marker::PhantomData<(K, V, Hasher)>, + _phantom: ::core::marker::PhantomData<(K, V, Hasher)>, } impl Iterator @@ -370,6 +369,7 @@ mod test_iterators { unhashed, }, }; + use alloc::vec; use codec::Encode; #[test] diff --git a/substrate/frame/support/src/storage/generator/mod.rs b/substrate/frame/support/src/storage/generator/mod.rs index dd6d622852db1..b0b1bda24bb74 100644 --- a/substrate/frame/support/src/storage/generator/mod.rs +++ b/substrate/frame/support/src/storage/generator/mod.rs @@ -36,6 +36,7 @@ pub use value::StorageValue; #[cfg(test)] mod tests { + use alloc::vec::Vec; use codec::Encode; use sp_io::TestExternalities; use sp_runtime::{generic, traits::BlakeTwo256, BuildStorage}; diff --git a/substrate/frame/support/src/storage/generator/nmap.rs b/substrate/frame/support/src/storage/generator/nmap.rs index 4b49ad3eb38d4..0466583a27955 100755 --- a/substrate/frame/support/src/storage/generator/nmap.rs +++ b/substrate/frame/support/src/storage/generator/nmap.rs @@ -40,9 +40,8 @@ use crate::{ }, Never, }; +use alloc::vec::Vec; use codec::{Decode, Encode, EncodeLike, FullCodec}; -#[cfg(not(feature = "std"))] -use sp_std::prelude::*; /// Generator for `StorageNMap` used by `decl_storage` and storage types. /// @@ -464,6 +463,7 @@ mod test_iterators { unhashed, }, }; + use alloc::vec; use codec::Encode; #[test] diff --git a/substrate/frame/support/src/storage/hashed.rs b/substrate/frame/support/src/storage/hashed.rs index 6633adce8ff65..d823eb9887994 100644 --- a/substrate/frame/support/src/storage/hashed.rs +++ b/substrate/frame/support/src/storage/hashed.rs @@ -18,8 +18,8 @@ //! Operation on runtime storage using hashed keys. use super::unhashed; +use alloc::vec::Vec; use codec::{Decode, Encode}; -use sp_std::prelude::*; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. pub fn get(hash: &HashFn, key: &[u8]) -> Option diff --git a/substrate/frame/support/src/storage/migration.rs b/substrate/frame/support/src/storage/migration.rs index 252625cf4f7d0..1dd690c3ed67b 100644 --- a/substrate/frame/support/src/storage/migration.rs +++ b/substrate/frame/support/src/storage/migration.rs @@ -22,8 +22,8 @@ use crate::{ storage::{storage_prefix, unhashed}, StorageHasher, Twox128, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; -use sp_std::prelude::*; use super::PrefixIterator; @@ -32,7 +32,7 @@ pub struct StorageIterator { prefix: Vec, previous_key: Vec, drain: bool, - _phantom: ::sp_std::marker::PhantomData, + _phantom: ::core::marker::PhantomData, } impl StorageIterator { @@ -95,7 +95,7 @@ pub struct StorageKeyIterator { prefix: Vec, previous_key: Vec, drain: bool, - _phantom: ::sp_std::marker::PhantomData<(K, T, H)>, + _phantom: ::core::marker::PhantomData<(K, T, H)>, } impl StorageKeyIterator { diff --git a/substrate/frame/support/src/storage/mod.rs b/substrate/frame/support/src/storage/mod.rs index f7d7447482d06..7fb991d377923 100644 --- a/substrate/frame/support/src/storage/mod.rs +++ b/substrate/frame/support/src/storage/mod.rs @@ -24,10 +24,11 @@ use crate::{ ReversibleKeyGenerator, TupleToEncodedIter, }, }; +use alloc::{collections::btree_set::BTreeSet, vec::Vec}; use codec::{Decode, Encode, EncodeLike, FullCodec, FullEncode}; +use core::marker::PhantomData; use sp_core::storage::ChildInfo; use sp_runtime::generic::{Digest, DigestItem}; -use sp_std::{collections::btree_set::BTreeSet, marker::PhantomData, prelude::*}; pub use self::{ stream_iter::StorageStreamIter, diff --git a/substrate/frame/support/src/storage/storage_noop_guard.rs b/substrate/frame/support/src/storage/storage_noop_guard.rs index c4d40fa99a35c..23201e58db5b7 100644 --- a/substrate/frame/support/src/storage/storage_noop_guard.rs +++ b/substrate/frame/support/src/storage/storage_noop_guard.rs @@ -38,7 +38,7 @@ /// ``` #[must_use] pub struct StorageNoopGuard<'a> { - storage_root: sp_std::vec::Vec, + storage_root: alloc::vec::Vec, error_message: &'a str, } @@ -71,7 +71,8 @@ impl<'a> StorageNoopGuard<'a> { impl<'a> Drop for StorageNoopGuard<'a> { fn drop(&mut self) { // No need to double panic, eg. inside a test assertion failure. - if sp_std::thread::panicking() { + #[cfg(feature = "std")] + if std::thread::panicking() { return } assert_eq!( @@ -85,9 +86,10 @@ impl<'a> Drop for StorageNoopGuard<'a> { #[cfg(test)] mod tests { - use super::*; use sp_io::TestExternalities; + use super::*; + #[test] #[should_panic(expected = "`StorageNoopGuard` detected an attempted storage change.")] fn storage_noop_guard_panics_on_changed() { @@ -112,7 +114,7 @@ mod tests { TestExternalities::default().execute_with(|| { let guard = StorageNoopGuard::default(); frame_support::storage::unhashed::put(b"key", b"value"); - sp_std::mem::drop(guard); + std::mem::drop(guard); frame_support::storage::unhashed::kill(b"key"); }); } @@ -122,7 +124,7 @@ mod tests { TestExternalities::default().execute_with(|| { let guard = StorageNoopGuard::default(); frame_support::storage::unhashed::put(b"key", b"value"); - sp_std::mem::forget(guard); + std::mem::forget(guard); }); } diff --git a/substrate/frame/support/src/storage/stream_iter.rs b/substrate/frame/support/src/storage/stream_iter.rs index 529b2f387c71c..0d1e5582f841b 100644 --- a/substrate/frame/support/src/storage/stream_iter.rs +++ b/substrate/frame/support/src/storage/stream_iter.rs @@ -16,8 +16,8 @@ // limitations under the License. use crate::{BoundedBTreeMap, BoundedBTreeSet, BoundedVec, WeakBoundedVec}; +use alloc::vec::Vec; use codec::Decode; -use sp_std::vec::Vec; /// Provides the sealed trait `StreamIter`. mod private { @@ -26,7 +26,7 @@ mod private { /// Used as marker trait for types that support stream iteration. pub trait StreamIter { /// The actual iterator implementation. - type Iterator: sp_std::iter::Iterator; + type Iterator: core::iter::Iterator; /// Create the stream iterator for the value found at `key`. fn stream_iter(key: Vec) -> Self::Iterator; @@ -40,7 +40,7 @@ mod private { } } - impl StreamIter for sp_std::collections::btree_set::BTreeSet { + impl StreamIter for alloc::collections::btree_set::BTreeSet { type Iterator = ScaleContainerStreamIter; fn stream_iter(key: Vec) -> Self::Iterator { @@ -49,7 +49,7 @@ mod private { } impl StreamIter - for sp_std::collections::btree_map::BTreeMap + for alloc::collections::btree_map::BTreeMap { type Iterator = ScaleContainerStreamIter<(K, V)>; @@ -116,14 +116,14 @@ impl(len) ++ data`. -/// This type provides an [`Iterator`](sp_std::iter::Iterator) implementation that decodes +/// This type provides an [`Iterator`](core::iter::Iterator) implementation that decodes /// one item after another with each call to [`next`](Self::next). The bytes representing /// the container are also not read at once into memory and instead being read in chunks. As long /// as individual items are smaller than these chunks the memory usage of this iterator should /// be constant. On decoding errors [`next`](Self::next) will return `None` to signal that the /// iterator is finished. pub struct ScaleContainerStreamIter { - marker: sp_std::marker::PhantomData, + marker: core::marker::PhantomData, input: StorageInput, length: u32, read: u32, @@ -156,7 +156,7 @@ impl ScaleContainerStreamIter { 0 }; - Self { marker: sp_std::marker::PhantomData, input, length, read: 0 } + Self { marker: core::marker::PhantomData, input, length, read: 0 } } /// Creates a new instance of the stream iterator. @@ -168,11 +168,11 @@ impl ScaleContainerStreamIter { let mut input = StorageInput::new(key); let length = if input.exists() { codec::Compact::::decode(&mut input)?.0 } else { 0 }; - Ok(Self { marker: sp_std::marker::PhantomData, input, length, read: 0 }) + Ok(Self { marker: core::marker::PhantomData, input, length, read: 0 }) } } -impl sp_std::iter::Iterator for ScaleContainerStreamIter { +impl core::iter::Iterator for ScaleContainerStreamIter { type Item = T; fn next(&mut self) -> Option { @@ -235,7 +235,7 @@ impl StorageInput { /// /// - `key`: The storage key of the storage item that this input will read. fn new(key: Vec) -> Self { - let mut buffer = sp_std::vec![0; STORAGE_INPUT_BUFFER_CAPACITY]; + let mut buffer = alloc::vec![0; STORAGE_INPUT_BUFFER_CAPACITY]; unsafe { buffer.set_len(buffer.capacity()); } @@ -270,7 +270,7 @@ impl StorageInput { sp_io::storage::read(&self.key, &mut self.buffer[present_bytes..], self.offset) { let bytes_read = - sp_std::cmp::min(length_minus_offset as usize, self.buffer.len() - present_bytes); + core::cmp::min(length_minus_offset as usize, self.buffer.len() - present_bytes); let buffer_len = present_bytes + bytes_read; unsafe { self.buffer.set_len(buffer_len); diff --git a/substrate/frame/support/src/storage/types/counted_map.rs b/substrate/frame/support/src/storage/types/counted_map.rs index 0444e269928ab..9adcb33ae0743 100644 --- a/substrate/frame/support/src/storage/types/counted_map.rs +++ b/substrate/frame/support/src/storage/types/counted_map.rs @@ -29,11 +29,11 @@ use crate::{ traits::{Get, GetDefault, StorageInfo, StorageInfoTrait, StorageInstance}, Never, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen, Ref}; use sp_io::MultiRemovalResults; use sp_metadata_ir::StorageEntryMetadataIR; use sp_runtime::traits::Saturating; -use sp_std::prelude::*; /// A wrapper around a [`StorageMap`] and a [`StorageValue`] (with the value being `u32`) to keep /// track of how many items are in a map, without needing to iterate all the values. diff --git a/substrate/frame/support/src/storage/types/counted_nmap.rs b/substrate/frame/support/src/storage/types/counted_nmap.rs index 51cde93f28c01..13c1b10be39c4 100644 --- a/substrate/frame/support/src/storage/types/counted_nmap.rs +++ b/substrate/frame/support/src/storage/types/counted_nmap.rs @@ -28,10 +28,10 @@ use crate::{ traits::{Get, GetDefault, StorageInfo, StorageInstance}, Never, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen, Ref}; use sp_metadata_ir::StorageEntryMetadataIR; use sp_runtime::traits::Saturating; -use sp_std::prelude::*; /// A wrapper around a [`StorageNMap`] and a [`StorageValue`] (with the value being `u32`) to keep /// track of how many items are in a map, without needing to iterate all the values. @@ -683,6 +683,7 @@ mod test { hash::{StorageHasher as _, *}, storage::types::{Key as NMapKey, ValueQuery}, }; + use alloc::boxed::Box; use sp_io::{hashing::twox_128, TestExternalities}; use sp_metadata_ir::{StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR}; diff --git a/substrate/frame/support/src/storage/types/double_map.rs b/substrate/frame/support/src/storage/types/double_map.rs index 2a7af7a984633..3d227feb902f3 100644 --- a/substrate/frame/support/src/storage/types/double_map.rs +++ b/substrate/frame/support/src/storage/types/double_map.rs @@ -26,11 +26,11 @@ use crate::{ traits::{Get, GetDefault, StorageInfo, StorageInstance}, StorageHasher, Twox128, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; use frame_support::storage::StorageDecodeNonDedupLength; use sp_arithmetic::traits::SaturatedConversion; use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; -use sp_std::prelude::*; /// A type representing a *double map* in storage. This structure associates a pair of keys with a /// value of a specified type stored on-chain. diff --git a/substrate/frame/support/src/storage/types/key.rs b/substrate/frame/support/src/storage/types/key.rs index 90cf09dd1d341..b9b497b61d949 100755 --- a/substrate/frame/support/src/storage/types/key.rs +++ b/substrate/frame/support/src/storage/types/key.rs @@ -18,10 +18,10 @@ //! Storage key type. use crate::hash::{ReversibleStorageHasher, StorageHasher}; +use alloc::{boxed::Box, vec::Vec}; use codec::{Encode, EncodeLike, FullCodec, MaxEncodedLen}; use paste::paste; use scale_info::StaticTypeInfo; -use sp_std::prelude::*; /// A type used exclusively by storage maps as their key type. /// @@ -203,19 +203,19 @@ impl<'a, T: EncodeLike + EncodeLikeTuple, U: Encode> EncodeLikeTuple /// Trait to indicate that a tuple can be converted into an iterator of a vector of encoded bytes. pub trait TupleToEncodedIter { - fn to_encoded_iter(&self) -> sp_std::vec::IntoIter>; + fn to_encoded_iter(&self) -> alloc::vec::IntoIter>; } #[impl_trait_for_tuples::impl_for_tuples(1, 18)] #[tuple_types_custom_trait_bound(Encode)] impl TupleToEncodedIter for Tuple { - fn to_encoded_iter(&self) -> sp_std::vec::IntoIter> { + fn to_encoded_iter(&self) -> alloc::vec::IntoIter> { [for_tuples!( #(self.Tuple.encode()),* )].to_vec().into_iter() } } impl TupleToEncodedIter for &T { - fn to_encoded_iter(&self) -> sp_std::vec::IntoIter> { + fn to_encoded_iter(&self) -> alloc::vec::IntoIter> { (*self).to_encoded_iter() } } @@ -223,7 +223,7 @@ impl TupleToEncodedIter for &T { impl<'a, T: EncodeLike + TupleToEncodedIter, U: Encode> TupleToEncodedIter for codec::Ref<'a, T, U> { - fn to_encoded_iter(&self) -> sp_std::vec::IntoIter> { + fn to_encoded_iter(&self) -> alloc::vec::IntoIter> { use core::ops::Deref as _; self.deref().to_encoded_iter() } diff --git a/substrate/frame/support/src/storage/types/map.rs b/substrate/frame/support/src/storage/types/map.rs index b79a6ae9b8482..b70026eea50e1 100644 --- a/substrate/frame/support/src/storage/types/map.rs +++ b/substrate/frame/support/src/storage/types/map.rs @@ -26,11 +26,11 @@ use crate::{ traits::{Get, GetDefault, StorageInfo, StorageInstance}, StorageHasher, Twox128, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; use frame_support::storage::StorageDecodeNonDedupLength; use sp_arithmetic::traits::SaturatedConversion; use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; -use sp_std::prelude::*; /// A type representing a *map* in storage. A *storage map* is a mapping of keys to values of a /// given type stored on-chain. diff --git a/substrate/frame/support/src/storage/types/mod.rs b/substrate/frame/support/src/storage/types/mod.rs index 631410f425d17..b063e11621d61 100644 --- a/substrate/frame/support/src/storage/types/mod.rs +++ b/substrate/frame/support/src/storage/types/mod.rs @@ -18,9 +18,9 @@ //! Storage types to build abstraction on storage, they implements storage traits such as //! StorageMap and others. +use alloc::vec::Vec; use codec::FullCodec; use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryModifierIR}; -use sp_std::prelude::*; mod counted_map; mod counted_nmap; @@ -93,7 +93,7 @@ where } /// Implements [`QueryKindTrait`] with `Query` type being `Result`. -pub struct ResultQuery(sp_std::marker::PhantomData); +pub struct ResultQuery(core::marker::PhantomData); impl QueryKindTrait for ResultQuery where Value: FullCodec + 'static, diff --git a/substrate/frame/support/src/storage/types/nmap.rs b/substrate/frame/support/src/storage/types/nmap.rs index 253f02a14f079..c3dfd5b3e48c9 100755 --- a/substrate/frame/support/src/storage/types/nmap.rs +++ b/substrate/frame/support/src/storage/types/nmap.rs @@ -28,10 +28,10 @@ use crate::{ }, traits::{Get, GetDefault, StorageInfo, StorageInstance}, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; use sp_runtime::SaturatedConversion; -use sp_std::prelude::*; /// A type representing an *NMap* in storage. This structure associates an arbitrary number of keys /// with a value of a specified type stored on-chain. @@ -655,6 +655,7 @@ mod test { hash::{StorageHasher as _, *}, storage::types::{Key as NMapKey, ValueQuery}, }; + use alloc::boxed::Box; use sp_io::{hashing::twox_128, TestExternalities}; use sp_metadata_ir::{StorageEntryModifierIR, StorageHasherIR}; diff --git a/substrate/frame/support/src/storage/types/value.rs b/substrate/frame/support/src/storage/types/value.rs index a2d93a6a165ff..9cc985b36d8c6 100644 --- a/substrate/frame/support/src/storage/types/value.rs +++ b/substrate/frame/support/src/storage/types/value.rs @@ -25,11 +25,11 @@ use crate::{ }, traits::{Get, GetDefault, StorageInfo, StorageInstance}, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; use frame_support::storage::StorageDecodeNonDedupLength; use sp_arithmetic::traits::SaturatedConversion; use sp_metadata_ir::{StorageEntryMetadataIR, StorageEntryTypeIR}; -use sp_std::prelude::*; /// A type representing a *value* in storage. A *storage value* is a single value of a given type /// stored on-chain. diff --git a/substrate/frame/support/src/storage/unhashed.rs b/substrate/frame/support/src/storage/unhashed.rs index 776c7d0f3c3a8..7f9bc93d7d818 100644 --- a/substrate/frame/support/src/storage/unhashed.rs +++ b/substrate/frame/support/src/storage/unhashed.rs @@ -17,8 +17,8 @@ //! Operation on unhashed runtime storage. +use alloc::vec::Vec; use codec::{Decode, Encode}; -use sp_std::prelude::*; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. pub fn get(key: &[u8]) -> Option { diff --git a/substrate/frame/support/src/traits/dynamic_params.rs b/substrate/frame/support/src/traits/dynamic_params.rs index 32dae6799eaf7..3ef298fc5a5a0 100644 --- a/substrate/frame/support/src/traits/dynamic_params.rs +++ b/substrate/frame/support/src/traits/dynamic_params.rs @@ -85,7 +85,7 @@ impl AggregatedKeyValue for () { /// /// This concretization is useful when configuring pallets, since a pallet will require a parameter /// store for its own KV type and not the aggregated runtime-wide KV type. -pub struct ParameterStoreAdapter(sp_std::marker::PhantomData<(PS, KV)>); +pub struct ParameterStoreAdapter(core::marker::PhantomData<(PS, KV)>); impl ParameterStore for ParameterStoreAdapter where diff --git a/substrate/frame/support/src/traits/filter.rs b/substrate/frame/support/src/traits/filter.rs index 44f9f136cfc2a..ff62449847d25 100644 --- a/substrate/frame/support/src/traits/filter.rs +++ b/substrate/frame/support/src/traits/filter.rs @@ -18,7 +18,7 @@ //! Traits and associated utilities for dealing with abstract constraint filters. pub use super::members::Contains; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Trait to add a constraint onto the filter. pub trait FilterStack: Contains { @@ -103,7 +103,7 @@ macro_rules! impl_filter_stack { mod $module { #[allow(unused_imports)] use super::*; - use $crate::__private::sp_std::{boxed::Box, cell::RefCell, mem::{swap, take}, vec::Vec}; + use std::{boxed::Box, cell::RefCell, mem::{swap, take}, vec::Vec}; use $crate::traits::filter::{Contains, FilterStack}; thread_local! { diff --git a/substrate/frame/support/src/traits/hooks.rs b/substrate/frame/support/src/traits/hooks.rs index 1a687cade79f5..012a74d0ae92f 100644 --- a/substrate/frame/support/src/traits/hooks.rs +++ b/substrate/frame/support/src/traits/hooks.rs @@ -24,9 +24,10 @@ use crate::weights::Weight; use impl_trait_for_tuples::impl_for_tuples; use sp_runtime::traits::AtLeast32BitUnsigned; -use sp_std::prelude::*; use sp_weights::WeightMeter; +#[cfg(feature = "try-runtime")] +use alloc::vec::Vec; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -707,7 +708,7 @@ mod tests { #[test] fn on_idle_round_robin_works() { - static mut ON_IDLE_INVOCATION_ORDER: sp_std::vec::Vec<&str> = sp_std::vec::Vec::new(); + static mut ON_IDLE_INVOCATION_ORDER: alloc::vec::Vec<&str> = alloc::vec::Vec::new(); struct Test1; struct Test2; diff --git a/substrate/frame/support/src/traits/members.rs b/substrate/frame/support/src/traits/members.rs index 53de84ab22455..89b6b6cdfad95 100644 --- a/substrate/frame/support/src/traits/members.rs +++ b/substrate/frame/support/src/traits/members.rs @@ -17,10 +17,11 @@ //! Traits for dealing with the idea of membership. +use alloc::vec::Vec; +use core::marker::PhantomData; use impl_trait_for_tuples::impl_for_tuples; use sp_arithmetic::traits::AtLeast16BitUnsigned; use sp_runtime::DispatchResult; -use sp_std::{marker::PhantomData, prelude::*}; /// A trait for querying whether a type can be said to "contain" a value. pub trait Contains { diff --git a/substrate/frame/support/src/traits/messages.rs b/substrate/frame/support/src/traits/messages.rs index 3f8d80f5c6baf..d28716237119e 100644 --- a/substrate/frame/support/src/traits/messages.rs +++ b/substrate/frame/support/src/traits/messages.rs @@ -19,10 +19,10 @@ use super::storage::Footprint; use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; +use core::{fmt::Debug, marker::PhantomData}; use scale_info::TypeInfo; use sp_core::{ConstU32, Get, TypedGet}; use sp_runtime::{traits::Convert, BoundedSlice, RuntimeDebug}; -use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; use sp_weights::{Weight, WeightMeter}; /// Errors that can happen when attempting to process a message with diff --git a/substrate/frame/support/src/traits/metadata.rs b/substrate/frame/support/src/traits/metadata.rs index 8bda4186bc967..1e46470a3911f 100644 --- a/substrate/frame/support/src/traits/metadata.rs +++ b/substrate/frame/support/src/traits/metadata.rs @@ -17,10 +17,11 @@ //! Traits for managing information attached to pallets and their constituents. +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; +use core::ops::Add; use impl_trait_for_tuples::impl_for_tuples; use sp_runtime::RuntimeDebug; -use sp_std::{ops::Add, prelude::*}; /// Provides information about the pallet itself and its setup in the runtime. /// @@ -146,16 +147,16 @@ impl CrateVersion { } } -impl sp_std::cmp::Ord for CrateVersion { - fn cmp(&self, other: &Self) -> sp_std::cmp::Ordering { +impl Ord for CrateVersion { + fn cmp(&self, other: &Self) -> core::cmp::Ordering { self.major .cmp(&other.major) .then_with(|| self.minor.cmp(&other.minor).then_with(|| self.patch.cmp(&other.patch))) } } -impl sp_std::cmp::PartialOrd for CrateVersion { - fn partial_cmp(&self, other: &Self) -> Option { +impl PartialOrd for CrateVersion { + fn partial_cmp(&self, other: &Self) -> Option { Some(::cmp(self, other)) } } @@ -248,7 +249,7 @@ impl PartialEq for StorageVersion { } impl PartialOrd for StorageVersion { - fn partial_cmp(&self, other: &u16) -> Option { + fn partial_cmp(&self, other: &u16) -> Option { Some(self.0.cmp(other)) } } diff --git a/substrate/frame/support/src/traits/misc.rs b/substrate/frame/support/src/traits/misc.rs index bc7407a7be624..7c8c22d1ae5a3 100644 --- a/substrate/frame/support/src/traits/misc.rs +++ b/substrate/frame/support/src/traits/misc.rs @@ -18,19 +18,20 @@ //! Smaller traits used in FRAME which don't need their own file. use crate::dispatch::{DispatchResult, Parameter}; +use alloc::{vec, vec::Vec}; use codec::{CompactLen, Decode, DecodeLimit, Encode, EncodeLike, Input, MaxEncodedLen}; use impl_trait_for_tuples::impl_for_tuples; use scale_info::{build::Fields, meta_type, Path, Type, TypeInfo, TypeParameter}; use sp_arithmetic::traits::{CheckedAdd, CheckedMul, CheckedSub, One, Saturating}; use sp_core::bounded::bounded_vec::TruncateFrom; +use core::cmp::Ordering; #[doc(hidden)] pub use sp_runtime::traits::{ ConstBool, ConstI128, ConstI16, ConstI32, ConstI64, ConstI8, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Get, GetDefault, TryCollect, TypedGet, }; use sp_runtime::{traits::Block as BlockT, DispatchError}; -use sp_std::{cmp::Ordering, prelude::*}; #[doc(hidden)] pub const DEFENSIVE_OP_PUBLIC_ERROR: &str = "a defensive failure has been triggered; please report the block number at https://github.com/paritytech/substrate/issues"; @@ -48,7 +49,7 @@ impl VariantCount for () { } /// Adapter for `Get` to access `VARIANT_COUNT` from `trait pub trait VariantCount {`. -pub struct VariantCountOf(sp_std::marker::PhantomData); +pub struct VariantCountOf(core::marker::PhantomData); impl Get for VariantCountOf { fn get() -> u32 { T::VARIANT_COUNT @@ -190,10 +191,10 @@ pub trait DefensiveOption { /// Defensively transform this option to a result, mapping `None` to the return value of an /// error closure. - fn defensive_ok_or_else E>(self, err: F) -> Result; + fn defensive_ok_or_else E>(self, err: F) -> Result; /// Defensively transform this option to a result, mapping `None` to a default value. - fn defensive_ok_or(self, err: E) -> Result; + fn defensive_ok_or(self, err: E) -> Result; /// Exactly the same as `map`, but it prints the appropriate warnings if the value being mapped /// is `None`. @@ -252,7 +253,7 @@ impl Defensive for Option { } } -impl Defensive for Result { +impl Defensive for Result { fn defensive_unwrap_or(self, or: T) -> T { match self { Ok(inner) => inner, @@ -307,7 +308,7 @@ impl Defensive for Result { } } -impl DefensiveResult for Result { +impl DefensiveResult for Result { fn defensive_map_err F>(self, o: O) -> Result { self.map_err(|e| { defensive!(e); @@ -357,7 +358,7 @@ impl DefensiveOption for Option { ) } - fn defensive_ok_or_else E>(self, err: F) -> Result { + fn defensive_ok_or_else E>(self, err: F) -> Result { self.ok_or_else(|| { let err_value = err(); defensive!(err_value); @@ -365,7 +366,7 @@ impl DefensiveOption for Option { }) } - fn defensive_ok_or(self, err: E) -> Result { + fn defensive_ok_or(self, err: E) -> Result { self.ok_or_else(|| { defensive!(err); err @@ -416,11 +417,11 @@ impl DefensiveSatura } fn defensive_saturating_accrue(&mut self, other: Self) { // Use `replace` here since `take` would require `T: Default`. - *self = sp_std::mem::replace(self, One::one()).defensive_saturating_add(other); + *self = core::mem::replace(self, One::one()).defensive_saturating_add(other); } fn defensive_saturating_reduce(&mut self, other: Self) { // Use `replace` here since `take` would require `T: Default`. - *self = sp_std::mem::replace(self, One::one()).defensive_saturating_sub(other); + *self = core::mem::replace(self, One::one()).defensive_saturating_sub(other); } fn defensive_saturating_inc(&mut self) { self.defensive_saturating_accrue(One::one()); @@ -510,7 +511,7 @@ pub trait DefensiveMin { impl DefensiveMin for T where - T: sp_std::cmp::PartialOrd, + T: PartialOrd, { fn defensive_min(self, other: T) -> Self { if self <= other { @@ -574,7 +575,7 @@ pub trait DefensiveMax { impl DefensiveMax for T where - T: sp_std::cmp::PartialOrd, + T: PartialOrd, { fn defensive_max(self, other: T) -> Self { if self >= other { @@ -1050,7 +1051,7 @@ impl TypeInfo for WrapperOpaque { #[derive(Debug, Eq, PartialEq, Default, Clone)] pub struct WrapperKeepOpaque { data: Vec, - _phantom: sp_std::marker::PhantomData, + _phantom: core::marker::PhantomData, } impl WrapperKeepOpaque { @@ -1073,7 +1074,7 @@ impl WrapperKeepOpaque { /// Create from the given encoded `data`. pub fn from_encoded(data: Vec) -> Self { - Self { data, _phantom: sp_std::marker::PhantomData } + Self { data, _phantom: core::marker::PhantomData } } } @@ -1100,7 +1101,7 @@ impl Encode for WrapperKeepOpaque { impl Decode for WrapperKeepOpaque { fn decode(input: &mut I) -> Result { - Ok(Self { data: Vec::::decode(input)?, _phantom: sp_std::marker::PhantomData }) + Ok(Self { data: Vec::::decode(input)?, _phantom: core::marker::PhantomData }) } fn skip(input: &mut I) -> Result<(), codec::Error> { @@ -1212,8 +1213,8 @@ pub trait AccountTouch { #[cfg(test)] mod test { use super::*; + use core::marker::PhantomData; use sp_core::bounded::{BoundedSlice, BoundedVec}; - use sp_std::marker::PhantomData; #[test] fn defensive_assert_works() { diff --git a/substrate/frame/support/src/traits/preimages.rs b/substrate/frame/support/src/traits/preimages.rs index 647af029c16dc..80020d8d00809 100644 --- a/substrate/frame/support/src/traits/preimages.rs +++ b/substrate/frame/support/src/traits/preimages.rs @@ -17,6 +17,7 @@ //! Stuff for dealing with hashed preimages. +use alloc::borrow::Cow; use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; use scale_info::TypeInfo; use sp_core::RuntimeDebug; @@ -24,7 +25,6 @@ use sp_runtime::{ traits::{ConstU32, Hash}, DispatchError, }; -use sp_std::borrow::Cow; pub type BoundedInline = crate::BoundedVec>; @@ -37,7 +37,7 @@ pub enum Bounded { /// A hash with no preimage length. We do not support creation of this except /// for transitioning from legacy state. In the future we will make this a pure /// `Dummy` item storing only the final `dummy` field. - Legacy { hash: H::Output, dummy: sp_std::marker::PhantomData }, + Legacy { hash: H::Output, dummy: core::marker::PhantomData }, /// A an bounded `Call`. Its encoding must be at most 128 bytes. Inline(BoundedInline), /// A hash of the call together with an upper limit for its size.` @@ -61,7 +61,7 @@ impl Bounded { { use Bounded::*; match self { - Legacy { hash, .. } => Legacy { hash, dummy: sp_std::marker::PhantomData }, + Legacy { hash, .. } => Legacy { hash, dummy: core::marker::PhantomData }, Inline(x) => Inline(x), Lookup { hash, len } => Lookup { hash, len }, } @@ -123,7 +123,7 @@ impl Bounded { /// Constructs a `Legacy` bounded item. #[deprecated = "This API is only for transitioning to Scheduler v3 API"] pub fn from_legacy_hash(hash: impl Into) -> Self { - Self::Legacy { hash: hash.into(), dummy: sp_std::marker::PhantomData } + Self::Legacy { hash: hash.into(), dummy: core::marker::PhantomData } } } diff --git a/substrate/frame/support/src/traits/schedule.rs b/substrate/frame/support/src/traits/schedule.rs index f41c73fe69a88..a302e28d4ce24 100644 --- a/substrate/frame/support/src/traits/schedule.rs +++ b/substrate/frame/support/src/traits/schedule.rs @@ -19,10 +19,11 @@ #[allow(deprecated)] use super::PreimageProvider; +use alloc::vec::Vec; use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; +use core::{fmt::Debug, result::Result}; use scale_info::TypeInfo; use sp_runtime::{traits::Saturating, DispatchError, RuntimeDebug}; -use sp_std::{fmt::Debug, prelude::*, result::Result}; /// Information relating to the period of a scheduled task. First item is the length of the /// period and the second is the number of times it should be executed in total before the task @@ -182,7 +183,7 @@ pub mod v1 { /// A type that can be used as a scheduler. pub trait Named { /// An address which can be used for removing a scheduled task. - type Address: Codec + Clone + Eq + EncodeLike + sp_std::fmt::Debug + MaxEncodedLen; + type Address: Codec + Clone + Eq + EncodeLike + core::fmt::Debug + MaxEncodedLen; /// Schedule a dispatch to happen at the beginning of some block in the future. /// @@ -353,7 +354,7 @@ pub mod v2 { /// A type that can be used as a scheduler. pub trait Named { /// An address which can be used for removing a scheduled task. - type Address: Codec + Clone + Eq + EncodeLike + sp_std::fmt::Debug + MaxEncodedLen; + type Address: Codec + Clone + Eq + EncodeLike + core::fmt::Debug + MaxEncodedLen; /// A means of expressing a call by the hash of its encoded data. type Hash; @@ -448,7 +449,7 @@ pub mod v3 { /// A type that can be used as a scheduler. pub trait Named { /// An address which can be used for removing a scheduled task. - type Address: Codec + MaxEncodedLen + Clone + Eq + EncodeLike + sp_std::fmt::Debug; + type Address: Codec + MaxEncodedLen + Clone + Eq + EncodeLike + core::fmt::Debug; /// The hasher used in the runtime. type Hasher: sp_runtime::traits::Hash; diff --git a/substrate/frame/support/src/traits/storage.rs b/substrate/frame/support/src/traits/storage.rs index 875ff56bea19e..22fb28e4c0e79 100644 --- a/substrate/frame/support/src/traits/storage.rs +++ b/substrate/frame/support/src/traits/storage.rs @@ -17,6 +17,7 @@ //! Traits for encoding data related to pallet's storage items. +use alloc::{collections::btree_set::BTreeSet, vec, vec::Vec}; use codec::{Encode, FullCodec, MaxEncodedLen}; use core::marker::PhantomData; use impl_trait_for_tuples::impl_for_tuples; @@ -27,7 +28,6 @@ use sp_runtime::{ traits::{Convert, Member, Saturating}, DispatchError, RuntimeDebug, }; -use sp_std::{collections::btree_set::BTreeSet, prelude::*}; /// An instance of a pallet in the storage. /// diff --git a/substrate/frame/support/src/traits/tasks.rs b/substrate/frame/support/src/traits/tasks.rs index 42b837e55970d..0b5d0c082509d 100644 --- a/substrate/frame/support/src/traits/tasks.rs +++ b/substrate/frame/support/src/traits/tasks.rs @@ -18,20 +18,22 @@ //! Contains the [`Task`] trait, which defines a general-purpose way for defining and executing //! service work, and supporting types. +use alloc::{vec, vec::IntoIter}; use codec::FullCodec; +use core::{fmt::Debug, iter::Iterator}; use scale_info::TypeInfo; use sp_runtime::DispatchError; -use sp_std::{fmt::Debug, iter::Iterator, vec, vec::IntoIter}; use sp_weights::Weight; /// Contain's re-exports of all the supporting types for the [`Task`] trait. Used in the macro /// expansion of `RuntimeTask`. #[doc(hidden)] pub mod __private { + pub use alloc::{vec, vec::IntoIter}; pub use codec::FullCodec; + pub use core::{fmt::Debug, iter::Iterator}; pub use scale_info::TypeInfo; pub use sp_runtime::DispatchError; - pub use sp_std::{fmt::Debug, iter::Iterator, vec, vec::IntoIter}; pub use sp_weights::Weight; } diff --git a/substrate/frame/support/src/traits/tokens/currency/reservable.rs b/substrate/frame/support/src/traits/tokens/currency/reservable.rs index ff8b0c6eea838..60ea9a71805fc 100644 --- a/substrate/frame/support/src/traits/tokens/currency/reservable.rs +++ b/substrate/frame/support/src/traits/tokens/currency/reservable.rs @@ -242,7 +242,7 @@ pub trait NamedReservableCurrency: ReservableCurrency { /// /// All "anonymous" operations are then implemented as their named counterparts with the given `Id`. pub struct WithName( - sp_std::marker::PhantomData<(NamedReservable, Id, AccountId)>, + core::marker::PhantomData<(NamedReservable, Id, AccountId)>, ); impl< NamedReservable: NamedReservableCurrency, diff --git a/substrate/frame/support/src/traits/tokens/fungible/imbalance.rs b/substrate/frame/support/src/traits/tokens/fungible/imbalance.rs index 020dffe28c85b..41907b2aa009d 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/imbalance.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/imbalance.rs @@ -26,9 +26,9 @@ use crate::traits::{ misc::{SameOrOther, TryDrop}, tokens::{AssetId, Balance}, }; +use core::marker::PhantomData; use frame_support_procedural::{EqNoBound, PartialEqNoBound, RuntimeDebugNoBound}; use sp_runtime::traits::Zero; -use sp_std::marker::PhantomData; /// Handler for when an imbalance gets dropped. This could handle either a credit (negative) or /// debt (positive) imbalance. @@ -93,7 +93,7 @@ impl, OppositeOnDrop: HandleImbalance /// Forget the imbalance without invoking the on-drop handler. pub(crate) fn forget(imbalance: Self) { - sp_std::mem::forget(imbalance); + core::mem::forget(imbalance); } } @@ -108,7 +108,7 @@ impl, OppositeOnDrop: HandleImbalance fn drop_zero(self) -> Result<(), Self> { if self.amount.is_zero() { - sp_std::mem::forget(self); + core::mem::forget(self); Ok(()) } else { Err(self) @@ -118,7 +118,7 @@ impl, OppositeOnDrop: HandleImbalance fn split(self, amount: B) -> (Self, Self) { let first = self.amount.min(amount); let second = self.amount - first; - sp_std::mem::forget(self); + core::mem::forget(self); (Imbalance::new(first), Imbalance::new(second)) } @@ -130,19 +130,19 @@ impl, OppositeOnDrop: HandleImbalance fn merge(mut self, other: Self) -> Self { self.amount = self.amount.saturating_add(other.amount); - sp_std::mem::forget(other); + core::mem::forget(other); self } fn subsume(&mut self, other: Self) { self.amount = self.amount.saturating_add(other.amount); - sp_std::mem::forget(other); + core::mem::forget(other); } fn offset( self, other: Imbalance, ) -> SameOrOther> { let (a, b) = (self.amount, other.amount); - sp_std::mem::forget((self, other)); + core::mem::forget((self, other)); if a == b { SameOrOther::None diff --git a/substrate/frame/support/src/traits/tokens/fungible/item_of.rs b/substrate/frame/support/src/traits/tokens/fungible/item_of.rs index 2aa53d622dbff..c9f366911a8b6 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/item_of.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/item_of.rs @@ -39,7 +39,7 @@ pub struct ItemOf< F: fungibles::Inspect, A: Get<>::AssetId>, AccountId, ->(sp_std::marker::PhantomData<(F, A, AccountId)>); +>(core::marker::PhantomData<(F, A, AccountId)>); impl< F: fungibles::Inspect, @@ -361,7 +361,7 @@ impl< } pub struct ConvertImbalanceDropHandler( - sp_std::marker::PhantomData<(AccountId, Balance, AssetIdType, AssetId, Handler)>, + core::marker::PhantomData<(AccountId, Balance, AssetIdType, AssetId, Handler)>, ); impl< diff --git a/substrate/frame/support/src/traits/tokens/fungible/mod.rs b/substrate/frame/support/src/traits/tokens/fungible/mod.rs index a113cb01c982d..f40e494b930d5 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/mod.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/mod.rs @@ -65,7 +65,7 @@ //! "stack". This means that if an account has 3 freezes for 100 units, the account can spend its //! funds for any reason down to 100 units, at which point the freezes will start to come into //! play. -//! +//! //! It's important to note that the frozen balance can exceed the total balance of the account. //! This is useful, eg, in cases where you want to prevent a user from transferring any fund. In //! such a case, setting the frozen balance to `Balance::MAX` would serve that purpose @@ -161,9 +161,9 @@ mod regular; mod union_of; use codec::{Decode, Encode, MaxEncodedLen}; +use core::marker::PhantomData; use frame_support_procedural::{CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound}; use scale_info::TypeInfo; -use sp_std::marker::PhantomData; use super::{ Fortitude::{Force, Polite}, diff --git a/substrate/frame/support/src/traits/tokens/fungible/regular.rs b/substrate/frame/support/src/traits/tokens/fungible/regular.rs index c46614be4734c..54a04444649d2 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/regular.rs @@ -36,9 +36,9 @@ use crate::{ SameOrOther, TryDrop, }, }; +use core::marker::PhantomData; use sp_arithmetic::traits::{CheckedAdd, CheckedSub, One}; use sp_runtime::{traits::Saturating, ArithmeticError, DispatchError, TokenError}; -use sp_std::marker::PhantomData; use super::{Credit, Debt, HandleImbalanceDrop, Imbalance}; diff --git a/substrate/frame/support/src/traits/tokens/fungible/union_of.rs b/substrate/frame/support/src/traits/tokens/fungible/union_of.rs index 63791b0522370..3adbbdda31431 100644 --- a/substrate/frame/support/src/traits/tokens/fungible/union_of.rs +++ b/substrate/frame/support/src/traits/tokens/fungible/union_of.rs @@ -21,6 +21,7 @@ //! See the [`crate::traits::fungible`] doc for more information about fungible traits. use codec::{Decode, Encode, MaxEncodedLen}; +use core::cmp::Ordering; use frame_support::traits::{ fungible::imbalance, tokens::{ @@ -36,7 +37,6 @@ use sp_runtime::{ Either::{Left, Right}, RuntimeDebug, }; -use sp_std::cmp::Ordering; /// The `NativeOrWithId` enum classifies an asset as either `Native` to the current chain or as an /// asset with a specific ID. @@ -101,7 +101,7 @@ impl Convert, Either<(), AssetId>> for Nat /// - `AssetKind` is a superset type encompassing asset kinds from `Left` and `Right` sets. /// - `AccountId` is an account identifier type. pub struct UnionOf( - sp_std::marker::PhantomData<(Left, Right, Criterion, AssetKind, AccountId)>, + core::marker::PhantomData<(Left, Right, Criterion, AssetKind, AccountId)>, ); impl< @@ -664,7 +664,7 @@ pub struct ConvertImbalanceDropHandler< Balance, AssetId, AccountId, ->(sp_std::marker::PhantomData<(Left, Right, Criterion, AssetKind, Balance, AssetId, AccountId)>); +>(core::marker::PhantomData<(Left, Right, Criterion, AssetKind, Balance, AssetId, AccountId)>); impl< Left: fungible::HandleImbalanceDrop, diff --git a/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs b/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs index bb0d83721a481..c3b213cc8fc86 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs @@ -26,9 +26,9 @@ use crate::traits::{ misc::{SameOrOther, TryDrop}, tokens::{imbalance::Imbalance as ImbalanceT, AssetId, Balance}, }; +use core::marker::PhantomData; use frame_support_procedural::{EqNoBound, PartialEqNoBound, RuntimeDebugNoBound}; use sp_runtime::traits::Zero; -use sp_std::marker::PhantomData; /// Handler for when an imbalance gets dropped. This could handle either a credit (negative) or /// debt (positive) imbalance. @@ -98,12 +98,12 @@ impl< /// Forget the imbalance without invoking the on-drop handler. pub(crate) fn forget(imbalance: Self) { - sp_std::mem::forget(imbalance); + core::mem::forget(imbalance); } pub fn drop_zero(self) -> Result<(), Self> { if self.amount.is_zero() { - sp_std::mem::forget(self); + core::mem::forget(self); Ok(()) } else { Err(self) @@ -114,7 +114,7 @@ impl< let first = self.amount.min(amount); let second = self.amount - first; let asset = self.asset.clone(); - sp_std::mem::forget(self); + core::mem::forget(self); (Imbalance::new(asset.clone(), first), Imbalance::new(asset, second)) } @@ -129,7 +129,7 @@ impl< pub fn merge(mut self, other: Self) -> Result { if self.asset == other.asset { self.amount = self.amount.saturating_add(other.amount); - sp_std::mem::forget(other); + core::mem::forget(other); Ok(self) } else { Err((self, other)) @@ -138,7 +138,7 @@ impl< pub fn subsume(&mut self, other: Self) -> Result<(), Self> { if self.asset == other.asset { self.amount = self.amount.saturating_add(other.amount); - sp_std::mem::forget(other); + core::mem::forget(other); Ok(()) } else { Err(other) @@ -154,7 +154,7 @@ impl< if self.asset == other.asset { let (a, b) = (self.amount, other.amount); let asset = self.asset.clone(); - sp_std::mem::forget((self, other)); + core::mem::forget((self, other)); if a == b { Ok(SameOrOther::None) diff --git a/substrate/frame/support/src/traits/tokens/fungibles/metadata.rs b/substrate/frame/support/src/traits/tokens/fungibles/metadata.rs index ab722426dadf6..27f663e575095 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/metadata.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/metadata.rs @@ -20,7 +20,7 @@ //! See the [`crate::traits::fungibles`] doc for more information about fungibles traits. use crate::dispatch::DispatchResult; -use sp_std::vec::Vec; +use alloc::vec::Vec; pub trait Inspect: super::Inspect { // Get name for an AssetId. diff --git a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs index 946c4756cff60..3985da7856d75 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/regular.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/regular.rs @@ -19,7 +19,7 @@ //! //! See the [`crate::traits::fungibles`] doc for more information about fungibles traits. -use sp_std::marker::PhantomData; +use core::marker::PhantomData; use crate::{ ensure, diff --git a/substrate/frame/support/src/traits/tokens/fungibles/union_of.rs b/substrate/frame/support/src/traits/tokens/fungibles/union_of.rs index f4259a78f0a25..77047150e00ce 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/union_of.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/union_of.rs @@ -41,7 +41,7 @@ use sp_runtime::{ /// - `AssetKind` is a superset type encompassing asset kinds from `Left` and `Right` sets. /// - `AccountId` is an account identifier type. pub struct UnionOf( - sp_std::marker::PhantomData<(Left, Right, Criterion, AssetKind, AccountId)>, + core::marker::PhantomData<(Left, Right, Criterion, AssetKind, AccountId)>, ); impl< @@ -622,7 +622,7 @@ pub struct ConvertImbalanceDropHandler< Balance, AccountId, >( - sp_std::marker::PhantomData<( + core::marker::PhantomData<( Left, Right, LeftAssetId, diff --git a/substrate/frame/support/src/traits/tokens/imbalance/on_unbalanced.rs b/substrate/frame/support/src/traits/tokens/imbalance/on_unbalanced.rs index ecb8de8841f91..4bf9af3fbb186 100644 --- a/substrate/frame/support/src/traits/tokens/imbalance/on_unbalanced.rs +++ b/substrate/frame/support/src/traits/tokens/imbalance/on_unbalanced.rs @@ -17,9 +17,9 @@ //! Trait for handling imbalances. +use core::marker::PhantomData; use frame_support::traits::{fungible, fungibles, misc::TryDrop}; use sp_core::TypedGet; -use sp_std::marker::PhantomData; /// Handler for when some currency "account" decreased in balance for /// some reason. diff --git a/substrate/frame/support/src/traits/tokens/imbalance/signed_imbalance.rs b/substrate/frame/support/src/traits/tokens/imbalance/signed_imbalance.rs index 03e821b161b69..eec892cc31154 100644 --- a/substrate/frame/support/src/traits/tokens/imbalance/signed_imbalance.rs +++ b/substrate/frame/support/src/traits/tokens/imbalance/signed_imbalance.rs @@ -20,8 +20,8 @@ use super::super::imbalance::Imbalance; use crate::traits::misc::SameOrOther; use codec::FullCodec; +use core::fmt::Debug; use sp_runtime::traits::{AtLeast32BitUnsigned, MaybeSerializeDeserialize}; -use sp_std::fmt::Debug; /// Either a positive or a negative imbalance. pub enum SignedImbalance> { diff --git a/substrate/frame/support/src/traits/tokens/imbalance/split_two_ways.rs b/substrate/frame/support/src/traits/tokens/imbalance/split_two_ways.rs index 59a582389ba61..d79ae562ec676 100644 --- a/substrate/frame/support/src/traits/tokens/imbalance/split_two_ways.rs +++ b/substrate/frame/support/src/traits/tokens/imbalance/split_two_ways.rs @@ -18,8 +18,8 @@ //! Means for splitting an imbalance into two and handling them differently. use super::super::imbalance::{Imbalance, OnUnbalanced}; +use core::{marker::PhantomData, ops::Div}; use sp_runtime::traits::Saturating; -use sp_std::{marker::PhantomData, ops::Div}; /// Split an unbalanced amount two ways between a common divisor. pub struct SplitTwoWays( diff --git a/substrate/frame/support/src/traits/tokens/misc.rs b/substrate/frame/support/src/traits/tokens/misc.rs index e1ff1e058ae7a..9fa1df862097f 100644 --- a/substrate/frame/support/src/traits/tokens/misc.rs +++ b/substrate/frame/support/src/traits/tokens/misc.rs @@ -19,13 +19,13 @@ use crate::{traits::Contains, TypeInfo}; use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; +use core::fmt::Debug; use sp_arithmetic::traits::{AtLeast32BitUnsigned, Zero}; use sp_core::RuntimeDebug; use sp_runtime::{ traits::{Convert, MaybeSerializeDeserialize}, ArithmeticError, DispatchError, TokenError, }; -use sp_std::fmt::Debug; /// The origin of funds to be used for a deposit operation. #[derive(Copy, Clone, RuntimeDebug, Eq, PartialEq)] @@ -351,7 +351,7 @@ pub trait GetSalary { } /// Adapter for a rank-to-salary `Convert` implementation into a `GetSalary` implementation. -pub struct ConvertRank(sp_std::marker::PhantomData); +pub struct ConvertRank(core::marker::PhantomData); impl> GetSalary for ConvertRank { fn get_salary(rank: R, _: &A) -> B { C::convert(rank) diff --git a/substrate/frame/support/src/traits/tokens/nonfungible.rs b/substrate/frame/support/src/traits/tokens/nonfungible.rs index e3fc84f1d57b2..249f84b227593 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungible.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungible.rs @@ -26,9 +26,9 @@ use super::nonfungibles; use crate::{dispatch::DispatchResult, traits::Get}; +use alloc::vec::Vec; use codec::{Decode, Encode}; use sp_runtime::TokenError; -use sp_std::prelude::*; /// Trait for providing an interface to a read-only NFT-like set of items. pub trait Inspect { @@ -125,7 +125,7 @@ pub struct ItemOf< F: nonfungibles::Inspect, A: Get<>::CollectionId>, AccountId, ->(sp_std::marker::PhantomData<(F, A, AccountId)>); +>(core::marker::PhantomData<(F, A, AccountId)>); impl< F: nonfungibles::Inspect, diff --git a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs index 05f76e2859d2e..5775162e34ed0 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungible_v2.rs @@ -29,9 +29,9 @@ use crate::{ dispatch::{DispatchResult, Parameter}, traits::Get, }; +use alloc::vec::Vec; use codec::{Decode, Encode}; use sp_runtime::TokenError; -use sp_std::prelude::*; /// Trait for providing an interface to a read-only NFT-like item. pub trait Inspect { @@ -207,7 +207,7 @@ pub struct ItemOf< F: nonfungibles::Inspect, A: Get<>::CollectionId>, AccountId, ->(sp_std::marker::PhantomData<(F, A, AccountId)>); +>(core::marker::PhantomData<(F, A, AccountId)>); impl< F: nonfungibles::Inspect, diff --git a/substrate/frame/support/src/traits/tokens/nonfungibles.rs b/substrate/frame/support/src/traits/tokens/nonfungibles.rs index 615e79c29c85f..22358cf806fb1 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungibles.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungibles.rs @@ -28,9 +28,9 @@ //! `nonfungible` traits by using the `nonfungible::ItemOf` type adapter. use crate::dispatch::DispatchResult; +use alloc::vec::Vec; use codec::{Decode, Encode}; use sp_runtime::{DispatchError, TokenError}; -use sp_std::prelude::*; /// Trait for providing an interface to many read-only NFT-like sets of items. pub trait Inspect { diff --git a/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs b/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs index c0209b6d5123d..edf1c2b8023df 100644 --- a/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs +++ b/substrate/frame/support/src/traits/tokens/nonfungibles_v2.rs @@ -28,9 +28,9 @@ //! `nonfungible` traits by using the `nonfungible::ItemOf` type adapter. use crate::dispatch::{DispatchResult, Parameter}; +use alloc::vec::Vec; use codec::{Decode, Encode}; use sp_runtime::{DispatchError, TokenError}; -use sp_std::prelude::*; /// Trait for providing an interface to many read-only NFT-like sets of items. pub trait Inspect { diff --git a/substrate/frame/support/src/traits/tokens/pay.rs b/substrate/frame/support/src/traits/tokens/pay.rs index 62d7a056a3f1b..5a7ed4d6aa130 100644 --- a/substrate/frame/support/src/traits/tokens/pay.rs +++ b/substrate/frame/support/src/traits/tokens/pay.rs @@ -18,10 +18,10 @@ //! The Pay trait and associated types. use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; +use core::fmt::Debug; use scale_info::TypeInfo; use sp_core::{RuntimeDebug, TypedGet}; use sp_runtime::DispatchError; -use sp_std::fmt::Debug; use super::{fungible, fungibles, Balance, Preservation::Expendable}; diff --git a/substrate/frame/support/src/traits/try_runtime/decode_entire_state.rs b/substrate/frame/support/src/traits/try_runtime/decode_entire_state.rs index d5dc93fcf28fe..8dbeecd8e860e 100644 --- a/substrate/frame/support/src/traits/try_runtime/decode_entire_state.rs +++ b/substrate/frame/support/src/traits/try_runtime/decode_entire_state.rs @@ -26,10 +26,10 @@ use crate::{ traits::{PartialStorageInfoTrait, StorageInfo}, StorageHasher, }; +use alloc::{vec, vec::Vec}; use codec::{Decode, DecodeAll, FullCodec}; use impl_trait_for_tuples::impl_for_tuples; use sp_core::Get; -use sp_std::prelude::*; /// Decode the entire data under the given storage type. /// @@ -82,8 +82,8 @@ impl core::fmt::Display for TryDecodeEntireStorageError { write!( f, "`{}::{}` key `{}` is undecodable", - &sp_std::str::from_utf8(&self.info.pallet_name).unwrap_or(""), - &sp_std::str::from_utf8(&self.info.storage_name).unwrap_or(""), + &alloc::str::from_utf8(&self.info.pallet_name).unwrap_or(""), + &alloc::str::from_utf8(&self.info.storage_name).unwrap_or(""), array_bytes::bytes2hex("0x", &self.key) ) } diff --git a/substrate/frame/support/src/traits/try_runtime/mod.rs b/substrate/frame/support/src/traits/try_runtime/mod.rs index c1bf1feb19e54..09c33c0144067 100644 --- a/substrate/frame/support/src/traits/try_runtime/mod.rs +++ b/substrate/frame/support/src/traits/try_runtime/mod.rs @@ -22,10 +22,10 @@ pub use decode_entire_state::{TryDecodeEntireStorage, TryDecodeEntireStorageErro use super::StorageInstance; +use alloc::vec::Vec; use impl_trait_for_tuples::impl_for_tuples; use sp_arithmetic::traits::AtLeast32BitUnsigned; use sp_runtime::TryRuntimeError; -use sp_std::prelude::*; /// Which state tests to execute. #[derive(codec::Encode, codec::Decode, Clone, scale_info::TypeInfo)] @@ -55,15 +55,15 @@ impl Default for Select { } } -impl sp_std::fmt::Debug for Select { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Debug for Select { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Select::RoundRobin(x) => write!(f, "RoundRobin({})", x), Select::Only(x) => write!( f, "Only({:?})", x.iter() - .map(|x| sp_std::str::from_utf8(x).unwrap_or("")) + .map(|x| alloc::str::from_utf8(x).unwrap_or("")) .collect::>(), ), Select::All => write!(f, "All"), @@ -73,7 +73,7 @@ impl sp_std::fmt::Debug for Select { } #[cfg(feature = "std")] -impl sp_std::str::FromStr for Select { +impl std::str::FromStr for Select { type Err = &'static str; fn from_str(s: &str) -> Result { match s { @@ -153,9 +153,7 @@ pub trait TryState { #[cfg_attr(all(not(feature = "tuples-96"), not(feature = "tuples-128")), impl_for_tuples(64))] #[cfg_attr(all(feature = "tuples-96", not(feature = "tuples-128")), impl_for_tuples(96))] #[cfg_attr(all(feature = "tuples-128"), impl_for_tuples(128))] -impl TryState - for Tuple -{ +impl TryState for Tuple { for_tuples!( where #( Tuple: crate::traits::PalletInfoAccess )* ); fn try_state(n: BlockNumber, targets: Select) -> Result<(), TryRuntimeError> { match targets { @@ -221,7 +219,7 @@ impl TryState { /// Initializes a new tally. @@ -74,7 +74,7 @@ impl PollStatus { } } -pub struct ClassCountOf(sp_std::marker::PhantomData<(P, T)>); +pub struct ClassCountOf(core::marker::PhantomData<(P, T)>); impl> sp_runtime::traits::Get for ClassCountOf { fn get() -> u32 { P::classes().len() as u32 diff --git a/substrate/frame/support/test/Cargo.toml b/substrate/frame/support/test/Cargo.toml index 697e14ae1d388..82ac1d2c7475b 100644 --- a/substrate/frame/support/test/Cargo.toml +++ b/substrate/frame/support/test/Cargo.toml @@ -28,7 +28,6 @@ frame-support = { features = ["experimental"], workspace = true } frame-benchmarking = { workspace = true } sp-runtime = { workspace = true } sp-core = { workspace = true } -sp-std = { workspace = true } sp-version = { workspace = true } sp-metadata-ir = { workspace = true } trybuild = { features = ["diff"], workspace = true } @@ -57,7 +56,6 @@ std = [ "sp-metadata-ir/std", "sp-runtime/std", "sp-state-machine/std", - "sp-std/std", "sp-version/std", "test-pallet/std", ] diff --git a/substrate/frame/support/test/src/lib.rs b/substrate/frame/support/test/src/lib.rs index a8a723375033a..b080740b0a4b1 100644 --- a/substrate/frame/support/test/src/lib.rs +++ b/substrate/frame/support/test/src/lib.rs @@ -127,7 +127,7 @@ pub mod pallet_prelude { /// Provides an implementation of [`frame_support::traits::Randomness`] that should only be used in /// tests! -pub struct TestRandomness(sp_std::marker::PhantomData); +pub struct TestRandomness(core::marker::PhantomData); impl frame_support::traits::Randomness> for TestRandomness diff --git a/substrate/frame/support/test/tests/issue2219.rs b/substrate/frame/support/test/tests/issue2219.rs index 20c2773406ff1..7a2138d056a09 100644 --- a/substrate/frame/support/test/tests/issue2219.rs +++ b/substrate/frame/support/test/tests/issue2219.rs @@ -139,7 +139,7 @@ mod module { pub enable_storage_role: bool, pub request_life_time: u64, #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] diff --git a/substrate/frame/support/test/tests/origin.rs b/substrate/frame/support/test/tests/origin.rs index 4f14bda184c86..e6dd0cfc0e315 100644 --- a/substrate/frame/support/test/tests/origin.rs +++ b/substrate/frame/support/test/tests/origin.rs @@ -65,7 +65,7 @@ mod nested { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -135,7 +135,7 @@ pub mod module { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] diff --git a/substrate/frame/support/test/tests/pallet.rs b/substrate/frame/support/test/tests/pallet.rs index c441d4c371af0..6f8af949cc313 100644 --- a/substrate/frame/support/test/tests/pallet.rs +++ b/substrate/frame/support/test/tests/pallet.rs @@ -446,7 +446,7 @@ pub mod pallet { T::AccountId: From + SomeAssociation1 + From, { #[serde(skip)] - _config: sp_std::marker::PhantomData, + _config: core::marker::PhantomData, _myfield: u32, } diff --git a/substrate/frame/support/test/tests/pallet_instance.rs b/substrate/frame/support/test/tests/pallet_instance.rs index dfe4caa476d3b..09a49617044da 100644 --- a/substrate/frame/support/test/tests/pallet_instance.rs +++ b/substrate/frame/support/test/tests/pallet_instance.rs @@ -15,6 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use core::any::TypeId; use frame_support::{ derive_impl, dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays}, @@ -33,7 +34,6 @@ use sp_io::{ TestExternalities, }; use sp_runtime::{DispatchError, ModuleError}; -use sp_std::any::TypeId; #[frame_support::pallet(dev_mode)] pub mod pallet { @@ -194,7 +194,7 @@ pub mod pallet { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { #[serde(skip)] - _config: sp_std::marker::PhantomData<(T, I)>, + _config: core::marker::PhantomData<(T, I)>, _myfield: u32, } diff --git a/substrate/frame/support/test/tests/runtime.rs b/substrate/frame/support/test/tests/runtime.rs index 1f4d9110a24fc..06c2b5b7071c1 100644 --- a/substrate/frame/support/test/tests/runtime.rs +++ b/substrate/frame/support/test/tests/runtime.rs @@ -169,7 +169,7 @@ mod nested { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -251,7 +251,7 @@ pub mod module3 { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -871,7 +871,7 @@ fn test_metadata() { PalletMetadata { name: "Module3", storage: Some(PalletStorageMetadata { - prefix: "Module3", + prefix: "Module3", entries: vec![ StorageEntryMetadata { name: "Storage", diff --git a/substrate/frame/support/test/tests/runtime_legacy_ordering.rs b/substrate/frame/support/test/tests/runtime_legacy_ordering.rs index 6330a138e2f2a..4233db21e2031 100644 --- a/substrate/frame/support/test/tests/runtime_legacy_ordering.rs +++ b/substrate/frame/support/test/tests/runtime_legacy_ordering.rs @@ -169,7 +169,7 @@ mod nested { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -251,7 +251,7 @@ pub mod module3 { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -808,7 +808,7 @@ fn test_metadata() { PalletMetadata { name: "Module3", storage: Some(PalletStorageMetadata { - prefix: "Module3", + prefix: "Module3", entries: vec![ StorageEntryMetadata { name: "Storage", diff --git a/substrate/frame/support/test/tests/versioned_migration.rs b/substrate/frame/support/test/tests/versioned_migration.rs index c83dd6b71de9b..58c9e4ce93b58 100644 --- a/substrate/frame/support/test/tests/versioned_migration.rs +++ b/substrate/frame/support/test/tests/versioned_migration.rs @@ -51,7 +51,7 @@ mod dummy_pallet { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { #[serde(skip)] - _config: sp_std::marker::PhantomData, + _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -90,7 +90,7 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities { /// A dummy migration for testing the `VersionedMigration` trait. /// Sets SomeStorage to S. -struct SomeUnversionedMigration(sp_std::marker::PhantomData); +struct SomeUnversionedMigration(core::marker::PhantomData); parameter_types! { const UpgradeReads: u64 = 4; diff --git a/substrate/frame/system/benchmarking/Cargo.toml b/substrate/frame/system/benchmarking/Cargo.toml index 47a6721b93f58..dec68d20b6995 100644 --- a/substrate/frame/system/benchmarking/Cargo.toml +++ b/substrate/frame/system/benchmarking/Cargo.toml @@ -23,7 +23,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] sp-io = { workspace = true, default-features = true } @@ -42,7 +41,6 @@ std = [ "sp-externalities/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-version/std", ] diff --git a/substrate/frame/system/benchmarking/src/inner.rs b/substrate/frame/system/benchmarking/src/inner.rs index c1631b0a2e334..0fb592f3dbba7 100644 --- a/substrate/frame/system/benchmarking/src/inner.rs +++ b/substrate/frame/system/benchmarking/src/inner.rs @@ -17,13 +17,13 @@ //! Frame System benchmarks. +use alloc::{vec, vec::Vec}; use codec::Encode; use frame_benchmarking::v2::*; use frame_support::{dispatch::DispatchClass, storage, traits::Get}; use frame_system::{Call, Pallet as System, RawOrigin}; use sp_core::storage::well_known_keys; use sp_runtime::traits::Hash; -use sp_std::{prelude::*, vec}; pub struct Pallet(System); pub trait Config: frame_system::Config { diff --git a/substrate/frame/system/benchmarking/src/lib.rs b/substrate/frame/system/benchmarking/src/lib.rs index e55038aeb9551..f66d20ac8aed9 100644 --- a/substrate/frame/system/benchmarking/src/lib.rs +++ b/substrate/frame/system/benchmarking/src/lib.rs @@ -19,6 +19,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(feature = "runtime-benchmarks")] pub mod inner; diff --git a/substrate/frame/system/src/extensions/check_genesis.rs b/substrate/frame/system/src/extensions/check_genesis.rs index 76a711a823e7d..000ec56da64f3 100644 --- a/substrate/frame/system/src/extensions/check_genesis.rs +++ b/substrate/frame/system/src/extensions/check_genesis.rs @@ -31,16 +31,16 @@ use sp_runtime::{ /// the extension does not affect any other fields of `TransactionValidity` directly. #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] #[scale_info(skip_type_params(T))] -pub struct CheckGenesis(sp_std::marker::PhantomData); +pub struct CheckGenesis(core::marker::PhantomData); -impl sp_std::fmt::Debug for CheckGenesis { +impl core::fmt::Debug for CheckGenesis { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "CheckGenesis") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -48,7 +48,7 @@ impl sp_std::fmt::Debug for CheckGenesis { impl CheckGenesis { /// Creates new `SignedExtension` to check genesis hash. pub fn new() -> Self { - Self(sp_std::marker::PhantomData) + Self(core::marker::PhantomData) } } diff --git a/substrate/frame/system/src/extensions/check_mortality.rs b/substrate/frame/system/src/extensions/check_mortality.rs index 31fdbba5950e2..6666c4812fbc3 100644 --- a/substrate/frame/system/src/extensions/check_mortality.rs +++ b/substrate/frame/system/src/extensions/check_mortality.rs @@ -36,23 +36,23 @@ use sp_runtime::{ /// The extension affects `longevity` of the transaction according to the [`Era`] definition. #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] #[scale_info(skip_type_params(T))] -pub struct CheckMortality(pub Era, sp_std::marker::PhantomData); +pub struct CheckMortality(pub Era, core::marker::PhantomData); impl CheckMortality { /// utility constructor. Used only in client/factory code. pub fn from(era: Era) -> Self { - Self(era, sp_std::marker::PhantomData) + Self(era, core::marker::PhantomData) } } -impl sp_std::fmt::Debug for CheckMortality { +impl core::fmt::Debug for CheckMortality { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "CheckMortality({:?})", self.0) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } diff --git a/substrate/frame/system/src/extensions/check_non_zero_sender.rs b/substrate/frame/system/src/extensions/check_non_zero_sender.rs index 92eed60fc66b5..06dc2bf177ac9 100644 --- a/substrate/frame/system/src/extensions/check_non_zero_sender.rs +++ b/substrate/frame/system/src/extensions/check_non_zero_sender.rs @@ -17,6 +17,7 @@ use crate::Config; use codec::{Decode, Encode}; +use core::marker::PhantomData; use frame_support::{dispatch::DispatchInfo, DefaultNoBound}; use scale_info::TypeInfo; use sp_runtime::{ @@ -25,21 +26,20 @@ use sp_runtime::{ InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction, }, }; -use sp_std::{marker::PhantomData, prelude::*}; /// Check to ensure that the sender is not the zero address. #[derive(Encode, Decode, DefaultNoBound, Clone, Eq, PartialEq, TypeInfo)] #[scale_info(skip_type_params(T))] pub struct CheckNonZeroSender(PhantomData); -impl sp_std::fmt::Debug for CheckNonZeroSender { +impl core::fmt::Debug for CheckNonZeroSender { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "CheckNonZeroSender") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -47,7 +47,7 @@ impl sp_std::fmt::Debug for CheckNonZeroSender { impl CheckNonZeroSender { /// Create new `SignedExtension` to check runtime version. pub fn new() -> Self { - Self(sp_std::marker::PhantomData) + Self(core::marker::PhantomData) } } @@ -61,7 +61,7 @@ where type Pre = (); const IDENTIFIER: &'static str = "CheckNonZeroSender"; - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } diff --git a/substrate/frame/system/src/extensions/check_nonce.rs b/substrate/frame/system/src/extensions/check_nonce.rs index 894ab72eb593b..3535870d1b595 100644 --- a/substrate/frame/system/src/extensions/check_nonce.rs +++ b/substrate/frame/system/src/extensions/check_nonce.rs @@ -16,6 +16,7 @@ // limitations under the License. use crate::Config; +use alloc::vec; use codec::{Decode, Encode}; use frame_support::dispatch::DispatchInfo; use scale_info::TypeInfo; @@ -26,7 +27,6 @@ use sp_runtime::{ ValidTransaction, }, }; -use sp_std::vec; /// Nonce check and increment to give replay protection for transactions. /// @@ -46,14 +46,14 @@ impl CheckNonce { } } -impl sp_std::fmt::Debug for CheckNonce { +impl core::fmt::Debug for CheckNonce { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "CheckNonce({})", self.0) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -68,7 +68,7 @@ where type Pre = (); const IDENTIFIER: &'static str = "CheckNonce"; - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } diff --git a/substrate/frame/system/src/extensions/check_spec_version.rs b/substrate/frame/system/src/extensions/check_spec_version.rs index 24d5ef9cafb17..ee7e6f2efd001 100644 --- a/substrate/frame/system/src/extensions/check_spec_version.rs +++ b/substrate/frame/system/src/extensions/check_spec_version.rs @@ -31,16 +31,16 @@ use sp_runtime::{ /// is not affected in any other way. #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] #[scale_info(skip_type_params(T))] -pub struct CheckSpecVersion(sp_std::marker::PhantomData); +pub struct CheckSpecVersion(core::marker::PhantomData); -impl sp_std::fmt::Debug for CheckSpecVersion { +impl core::fmt::Debug for CheckSpecVersion { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "CheckSpecVersion") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -48,7 +48,7 @@ impl sp_std::fmt::Debug for CheckSpecVersion { impl CheckSpecVersion { /// Create new `SignedExtension` to check runtime version. pub fn new() -> Self { - Self(sp_std::marker::PhantomData) + Self(core::marker::PhantomData) } } diff --git a/substrate/frame/system/src/extensions/check_tx_version.rs b/substrate/frame/system/src/extensions/check_tx_version.rs index 3f9d6a1903fe1..15983c2cd088b 100644 --- a/substrate/frame/system/src/extensions/check_tx_version.rs +++ b/substrate/frame/system/src/extensions/check_tx_version.rs @@ -31,16 +31,16 @@ use sp_runtime::{ /// is not affected in any other way. #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] #[scale_info(skip_type_params(T))] -pub struct CheckTxVersion(sp_std::marker::PhantomData); +pub struct CheckTxVersion(core::marker::PhantomData); -impl sp_std::fmt::Debug for CheckTxVersion { +impl core::fmt::Debug for CheckTxVersion { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "CheckTxVersion") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -48,7 +48,7 @@ impl sp_std::fmt::Debug for CheckTxVersion { impl CheckTxVersion { /// Create new `SignedExtension` to check transaction version. pub fn new() -> Self { - Self(sp_std::marker::PhantomData) + Self(core::marker::PhantomData) } } diff --git a/substrate/frame/system/src/extensions/check_weight.rs b/substrate/frame/system/src/extensions/check_weight.rs index d4705f200efdd..22da2a5b98725 100644 --- a/substrate/frame/system/src/extensions/check_weight.rs +++ b/substrate/frame/system/src/extensions/check_weight.rs @@ -37,7 +37,7 @@ use sp_weights::Weight; /// transaction is valid. #[derive(Encode, Decode, Clone, Eq, PartialEq, Default, TypeInfo)] #[scale_info(skip_type_params(T))] -pub struct CheckWeight(sp_std::marker::PhantomData); +pub struct CheckWeight(core::marker::PhantomData); impl CheckWeight where @@ -211,7 +211,7 @@ where type Pre = (); const IDENTIFIER: &'static str = "CheckWeight"; - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } @@ -281,14 +281,14 @@ where } } -impl sp_std::fmt::Debug for CheckWeight { +impl core::fmt::Debug for CheckWeight { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "CheckWeight") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -300,8 +300,8 @@ mod tests { mock::{new_test_ext, System, Test, CALL}, AllExtrinsicsLen, BlockWeight, DispatchClass, }; + use core::marker::PhantomData; use frame_support::{assert_err, assert_ok, dispatch::Pays, weights::Weight}; - use sp_std::marker::PhantomData; fn block_weights() -> crate::limits::BlockWeights { ::BlockWeights::get() diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 84d00a1e917ec..0c6ff2cb8ddba 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -97,6 +97,10 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{boxed::Box, vec, vec::Vec}; +use core::{fmt::Debug, marker::PhantomData}; use pallet_prelude::{BlockNumberFor, HeaderFor}; #[cfg(feature = "std")] use serde::Serialize; @@ -118,7 +122,6 @@ use sp_runtime::{ }; #[cfg(any(feature = "std", test))] use sp_std::map; -use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; use sp_version::RuntimeVersion; use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; @@ -269,7 +272,7 @@ pub mod pallet { /// /// NOTE: Avoids overriding `BlockHashCount` when using `mocking::{MockBlock, MockBlockU32, /// MockBlockU128}`. - pub struct TestBlockHashCount>(sp_std::marker::PhantomData); + pub struct TestBlockHashCount>(core::marker::PhantomData); impl, C: Get> Get for TestBlockHashCount { fn get() -> I { C::get().into() @@ -511,7 +514,7 @@ pub mod pallet { + Default + Copy + CheckEqual - + sp_std::hash::Hash + + core::hash::Hash + AsRef<[u8]> + AsMut<[u8]> + MaxEncodedLen; @@ -1011,7 +1014,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } #[pallet::genesis_build] @@ -1153,7 +1156,7 @@ impl From for LastRuntimeUpgradeInfo { } /// Ensure the origin is Root. -pub struct EnsureRoot(sp_std::marker::PhantomData); +pub struct EnsureRoot(core::marker::PhantomData); impl, O>> + From>, AccountId> EnsureOrigin for EnsureRoot { @@ -1179,7 +1182,7 @@ impl_ensure_origin_with_arg_ignoring_arg! { /// Ensure the origin is Root and return the provided `Success` value. pub struct EnsureRootWithSuccess( - sp_std::marker::PhantomData<(AccountId, Success)>, + core::marker::PhantomData<(AccountId, Success)>, ); impl< O: Into, O>> + From>, @@ -1209,7 +1212,7 @@ impl_ensure_origin_with_arg_ignoring_arg! { /// Ensure the origin is provided `Ensure` origin and return the provided `Success` value. pub struct EnsureWithSuccess( - sp_std::marker::PhantomData<(Ensure, AccountId, Success)>, + core::marker::PhantomData<(Ensure, AccountId, Success)>, ); impl< @@ -1232,7 +1235,7 @@ impl< } /// Ensure the origin is any `Signed` origin. -pub struct EnsureSigned(sp_std::marker::PhantomData); +pub struct EnsureSigned(core::marker::PhantomData); impl, O>> + From>, AccountId: Decode> EnsureOrigin for EnsureSigned { @@ -1259,7 +1262,7 @@ impl_ensure_origin_with_arg_ignoring_arg! { } /// Ensure the origin is `Signed` origin from the given `AccountId`. -pub struct EnsureSignedBy(sp_std::marker::PhantomData<(Who, AccountId)>); +pub struct EnsureSignedBy(core::marker::PhantomData<(Who, AccountId)>); impl< O: Into, O>> + From>, Who: SortedMembers, @@ -1291,7 +1294,7 @@ impl_ensure_origin_with_arg_ignoring_arg! { } /// Ensure the origin is `None`. i.e. unsigned transaction. -pub struct EnsureNone(sp_std::marker::PhantomData); +pub struct EnsureNone(core::marker::PhantomData); impl, O>> + From>, AccountId> EnsureOrigin for EnsureNone { @@ -1316,7 +1319,7 @@ impl_ensure_origin_with_arg_ignoring_arg! { } /// Always fail. -pub struct EnsureNever(sp_std::marker::PhantomData); +pub struct EnsureNever(core::marker::PhantomData); impl EnsureOrigin for EnsureNever { type Success = Success; fn try_origin(o: O) -> Result { @@ -1906,7 +1909,7 @@ impl Pallet { /// Should only be called if you know what you are doing and outside of the runtime block /// execution else it can have a large impact on the PoV size of a block. pub fn read_events_no_consensus( - ) -> impl sp_std::iter::Iterator>> { + ) -> impl Iterator>> { Events::::stream_iter() } diff --git a/substrate/frame/system/src/migrations/mod.rs b/substrate/frame/system/src/migrations/mod.rs index 945bbc5395525..7c69843d73f10 100644 --- a/substrate/frame/system/src/migrations/mod.rs +++ b/substrate/frame/system/src/migrations/mod.rs @@ -24,7 +24,6 @@ use frame_support::{ pallet_prelude::ValueQuery, traits::PalletInfoAccess, weights::Weight, Blake2_128Concat, }; use sp_runtime::RuntimeDebug; -use sp_std::prelude::*; /// Type used to encode the number of references an account has. type RefCount = u32; diff --git a/substrate/frame/system/src/offchain.rs b/substrate/frame/system/src/offchain.rs index a64b326196403..1f72ea2d37452 100644 --- a/substrate/frame/system/src/offchain.rs +++ b/substrate/frame/system/src/offchain.rs @@ -56,13 +56,13 @@ #![warn(missing_docs)] +use alloc::{boxed::Box, collections::btree_set::BTreeSet, vec::Vec}; use codec::Encode; use sp_runtime::{ app_crypto::RuntimeAppPublic, traits::{Extrinsic as ExtrinsicT, IdentifyAccount, One}, RuntimeDebug, }; -use sp_std::{collections::btree_set::BTreeSet, prelude::*}; /// Marker struct used to flag using all supported keys to sign a payload. pub struct ForAll {} @@ -76,7 +76,7 @@ pub struct ForAny {} /// utility function can be used. However, this struct is used by `Signer` /// to submit a signed transactions providing the signature along with the call. pub struct SubmitTransaction, OverarchingCall> { - _phantom: sp_std::marker::PhantomData<(T, OverarchingCall)>, + _phantom: core::marker::PhantomData<(T, OverarchingCall)>, } impl SubmitTransaction @@ -115,7 +115,7 @@ where #[derive(RuntimeDebug)] pub struct Signer, X = ForAny> { accounts: Option>, - _phantom: sp_std::marker::PhantomData<(X, C)>, + _phantom: core::marker::PhantomData<(X, C)>, } impl, X> Default for Signer { diff --git a/substrate/frame/timestamp/Cargo.toml b/substrate/frame/timestamp/Cargo.toml index 2da6e2d5a95d2..25aecea7b79ea 100644 --- a/substrate/frame/timestamp/Cargo.toml +++ b/substrate/frame/timestamp/Cargo.toml @@ -26,7 +26,6 @@ frame-system = { workspace = true } sp-inherents = { workspace = true } sp-io = { optional = true, workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-storage = { workspace = true } sp-timestamp = { workspace = true } @@ -49,7 +48,6 @@ std = [ "sp-inherents/std", "sp-io?/std", "sp-runtime/std", - "sp-std/std", "sp-storage/std", "sp-timestamp/std", ] diff --git a/substrate/frame/timestamp/src/lib.rs b/substrate/frame/timestamp/src/lib.rs index 6a22ab1cd5ef8..ca495c5e24efb 100644 --- a/substrate/frame/timestamp/src/lib.rs +++ b/substrate/frame/timestamp/src/lib.rs @@ -133,9 +133,9 @@ mod mock; mod tests; pub mod weights; +use core::{cmp, result}; use frame_support::traits::{OnTimestampSet, Time, UnixTime}; use sp_runtime::traits::{AtLeast32Bit, SaturatedConversion, Scale, Zero}; -use sp_std::{cmp, result}; use sp_timestamp::{InherentError, InherentType, INHERENT_IDENTIFIER}; pub use weights::WeightInfo; @@ -367,14 +367,12 @@ impl UnixTime for Pallet { // now is duration since unix epoch in millisecond as documented in // `sp_timestamp::InherentDataProvider`. let now = Now::::get(); - sp_std::if_std! { - if now == T::Moment::zero() { - log::error!( - target: "runtime::timestamp", - "`pallet_timestamp::UnixTime::now` is called at genesis, invalid value returned: 0", - ); - } - } + + log::error!( + target: "runtime::timestamp", + "`pallet_timestamp::UnixTime::now` is called at genesis, invalid value returned: 0", + ); + core::time::Duration::from_millis(now.saturated_into::()) } } diff --git a/substrate/frame/tips/Cargo.toml b/substrate/frame/tips/Cargo.toml index abebaa19aedae..bec2ce0a47b8b 100644 --- a/substrate/frame/tips/Cargo.toml +++ b/substrate/frame/tips/Cargo.toml @@ -27,7 +27,6 @@ pallet-treasury = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -48,7 +47,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-storage/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/tips/src/lib.rs b/substrate/frame/tips/src/lib.rs index a75aed89d0b44..67bcdfa0685e5 100644 --- a/substrate/frame/tips/src/lib.rs +++ b/substrate/frame/tips/src/lib.rs @@ -60,12 +60,14 @@ mod tests; pub mod migrations; pub mod weights; +extern crate alloc; + use sp_runtime::{ traits::{AccountIdConversion, BadOrigin, Hash, StaticLookup, TrailingZeroInput, Zero}, Percent, RuntimeDebug, }; -use sp_std::prelude::*; +use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; use frame_support::{ ensure, diff --git a/substrate/frame/tips/src/migrations/unreserve_deposits.rs b/substrate/frame/tips/src/migrations/unreserve_deposits.rs index 16cb1a80e812b..afc424309bf4d 100644 --- a/substrate/frame/tips/src/migrations/unreserve_deposits.rs +++ b/substrate/frame/tips/src/migrations/unreserve_deposits.rs @@ -18,6 +18,7 @@ //! A migration that unreserves all deposit and unlocks all stake held in the context of this //! pallet. +use alloc::collections::btree_map::BTreeMap; use core::iter::Sum; use frame_support::{ pallet_prelude::OptionQuery, @@ -27,7 +28,6 @@ use frame_support::{ Parameter, Twox64Concat, }; use sp_runtime::{traits::Zero, Saturating}; -use sp_std::collections::btree_map::BTreeMap; #[cfg(feature = "try-runtime")] const LOG_TARGET: &str = "runtime::tips::migrations::unreserve_deposits"; @@ -85,7 +85,7 @@ type Tips, I: 'static> = StorageMap< /// The pallet should be made inoperable before or immediately after this migration is run. /// /// (See also the `RemovePallet` migration in `frame/support/src/migrations.rs`) -pub struct UnreserveDeposits, I: 'static>(sp_std::marker::PhantomData<(T, I)>); +pub struct UnreserveDeposits, I: 'static>(core::marker::PhantomData<(T, I)>); impl, I: 'static> UnreserveDeposits { /// Calculates and returns the total amount reserved by each account by this pallet from open @@ -133,7 +133,7 @@ where /// Fails with a `TryRuntimeError` if somehow the amount reserved by this pallet is greater than /// the actual total reserved amount for any accounts. #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { use codec::Encode; use frame_support::ensure; @@ -189,7 +189,7 @@ where /// Verifies that the account reserved balances were reduced by the actual expected amounts. #[cfg(feature = "try-runtime")] fn post_upgrade( - account_reserved_before_bytes: sp_std::vec::Vec, + account_reserved_before_bytes: alloc::vec::Vec, ) -> Result<(), sp_runtime::TryRuntimeError> { use codec::Decode; diff --git a/substrate/frame/transaction-payment/Cargo.toml b/substrate/frame/transaction-payment/Cargo.toml index 3e890a8f7b69f..c405ea1e94390 100644 --- a/substrate/frame/transaction-payment/Cargo.toml +++ b/substrate/frame/transaction-payment/Cargo.toml @@ -26,7 +26,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] serde_json = { workspace = true, default-features = true } @@ -44,7 +43,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = [ "frame-support/try-runtime", diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml b/substrate/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml index 02ce212deb6a7..b87d780b96721 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml @@ -18,7 +18,6 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # Substrate dependencies sp-runtime = { workspace = true } -sp-std = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } pallet-asset-conversion = { workspace = true } @@ -47,7 +46,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-storage/std", ] try-runtime = [ diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs index ed0ed56e6e074..538d88bfacfaa 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs @@ -42,7 +42,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use sp_std::prelude::*; +extern crate alloc; use codec::{Decode, Encode}; use frame_support::{ @@ -214,13 +214,13 @@ where } } -impl sp_std::fmt::Debug for ChargeAssetTxPayment { +impl core::fmt::Debug for ChargeAssetTxPayment { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "ChargeAssetTxPayment<{:?}, {:?}>", self.tip, self.asset_id.encode()) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -252,7 +252,7 @@ where Option>, ); - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs index f2f2c57bb376d..0ef3fb1111439 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs @@ -17,6 +17,8 @@ use super::*; use crate::Config; +use alloc::vec; +use core::marker::PhantomData; use frame_support::{ ensure, traits::{fungible::Inspect, tokens::Balance}, @@ -28,7 +30,6 @@ use sp_runtime::{ transaction_validity::InvalidTransaction, Saturating, }; -use sp_std::marker::PhantomData; /// Handle withdrawing, refunding and depositing of transaction fees. pub trait OnChargeAssetTransaction { diff --git a/substrate/frame/transaction-payment/asset-tx-payment/Cargo.toml b/substrate/frame/transaction-payment/asset-tx-payment/Cargo.toml index 1b92ecf53c026..ec8fb38dda390 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/Cargo.toml +++ b/substrate/frame/transaction-payment/asset-tx-payment/Cargo.toml @@ -20,7 +20,6 @@ targets = ["x86_64-unknown-linux-gnu"] sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } @@ -57,7 +56,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-storage/std", ] runtime-benchmarks = [ diff --git a/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs b/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs index 753fae747a37e..97f1116993fc1 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -35,8 +35,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -use sp_std::prelude::*; - use codec::{Decode, Encode}; use frame_support::{ dispatch::{DispatchInfo, DispatchResult, PostDispatchInfo}, @@ -198,13 +196,13 @@ where } } -impl sp_std::fmt::Debug for ChargeAssetTxPayment { +impl core::fmt::Debug for ChargeAssetTxPayment { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "ChargeAssetTxPayment<{:?}, {:?}>", self.tip, self.asset_id.encode()) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -232,7 +230,7 @@ where Option>, ); - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } diff --git a/substrate/frame/transaction-payment/asset-tx-payment/src/payment.rs b/substrate/frame/transaction-payment/asset-tx-payment/src/payment.rs index 717114ab6bd03..2486474bad45b 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/src/payment.rs +++ b/substrate/frame/transaction-payment/asset-tx-payment/src/payment.rs @@ -18,6 +18,7 @@ use super::*; use crate::Config; use codec::FullCodec; +use core::{fmt::Debug, marker::PhantomData}; use frame_support::{ traits::{ fungibles::{Balanced, Credit, Inspect}, @@ -33,7 +34,6 @@ use sp_runtime::{ traits::{DispatchInfoOf, MaybeSerializeDeserialize, One, PostDispatchInfoOf}, transaction_validity::InvalidTransaction, }; -use sp_std::{fmt::Debug, marker::PhantomData}; /// Handle withdrawing, refunding and depositing of transaction fees. pub trait OnChargeAssetTransaction { diff --git a/substrate/frame/transaction-payment/skip-feeless-payment/Cargo.toml b/substrate/frame/transaction-payment/skip-feeless-payment/Cargo.toml index 7265979cedc0c..b5bc7719def60 100644 --- a/substrate/frame/transaction-payment/skip-feeless-payment/Cargo.toml +++ b/substrate/frame/transaction-payment/skip-feeless-payment/Cargo.toml @@ -16,7 +16,6 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # Substrate dependencies sp-runtime = { workspace = true } -sp-std = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } @@ -33,7 +32,6 @@ std = [ "frame-system/std", "scale-info/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-support/runtime-benchmarks", diff --git a/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs b/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs index 682fb32035616..3ab38743bafdd 100644 --- a/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/skip-feeless-payment/src/lib.rs @@ -77,7 +77,7 @@ pub mod pallet { /// A [`SignedExtension`] that skips the wrapped extension if the dispatchable is feeless. #[derive(Encode, Decode, Clone, Eq, PartialEq)] -pub struct SkipCheckIfFeeless(pub S, sp_std::marker::PhantomData); +pub struct SkipCheckIfFeeless(pub S, core::marker::PhantomData); // Make this extension "invisible" from the outside (ie metadata type information) impl TypeInfo for SkipCheckIfFeeless { @@ -87,20 +87,20 @@ impl TypeInfo for SkipCheckIfFeeless { } } -impl sp_std::fmt::Debug for SkipCheckIfFeeless { +impl core::fmt::Debug for SkipCheckIfFeeless { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "SkipCheckIfFeeless<{:?}>", self.0.encode()) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } impl From for SkipCheckIfFeeless { fn from(s: S) -> Self { - Self(s, sp_std::marker::PhantomData) + Self(s, core::marker::PhantomData) } } diff --git a/substrate/frame/transaction-payment/skip-feeless-payment/src/mock.rs b/substrate/frame/transaction-payment/skip-feeless-payment/src/mock.rs index 4ddeae11fcab4..d6d600f24e77c 100644 --- a/substrate/frame/transaction-payment/skip-feeless-payment/src/mock.rs +++ b/substrate/frame/transaction-payment/skip-feeless-payment/src/mock.rs @@ -45,7 +45,7 @@ impl SignedExtension for DummyExtension { type AdditionalSigned = (); type Pre = (); const IDENTIFIER: &'static str = "DummyExtension"; - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } diff --git a/substrate/frame/transaction-payment/src/lib.rs b/substrate/frame/transaction-payment/src/lib.rs index 0e440ee4e9ff5..69fad6e0e3248 100644 --- a/substrate/frame/transaction-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/src/lib.rs @@ -69,7 +69,6 @@ use sp_runtime::{ }, FixedPointNumber, FixedU128, Perbill, Perquintill, RuntimeDebug, }; -use sp_std::prelude::*; pub use types::{FeeDetails, InclusionFee, RuntimeDispatchInfo}; #[cfg(test)] @@ -137,7 +136,7 @@ type BalanceOf = <::OnChargeTransaction as OnChargeTransaction -pub struct TargetedFeeAdjustment(sp_std::marker::PhantomData<(T, S, V, M, X)>); +pub struct TargetedFeeAdjustment(core::marker::PhantomData<(T, S, V, M, X)>); /// Something that can convert the current multiplier to the next one. pub trait MultiplierUpdate: Convert { @@ -264,7 +263,7 @@ where } /// A struct to make the fee multiplier a constant -pub struct ConstFeeMultiplier>(sp_std::marker::PhantomData); +pub struct ConstFeeMultiplier>(core::marker::PhantomData); impl> MultiplierUpdate for ConstFeeMultiplier { fn min() -> Multiplier { @@ -406,7 +405,7 @@ pub mod pallet { pub struct GenesisConfig { pub multiplier: Multiplier, #[serde(skip)] - pub _config: sp_std::marker::PhantomData, + pub _config: core::marker::PhantomData, } impl Default for GenesisConfig { @@ -806,13 +805,13 @@ where } } -impl sp_std::fmt::Debug for ChargeTransactionPayment { +impl core::fmt::Debug for ChargeTransactionPayment { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "ChargeTransactionPayment<{:?}>", self.0) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -834,7 +833,7 @@ where // imbalance resulting from withdrawing the fee <::OnChargeTransaction as OnChargeTransaction>::LiquidityInfo, ); - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } diff --git a/substrate/frame/transaction-payment/src/types.rs b/substrate/frame/transaction-payment/src/types.rs index 25cecc58a63ab..67c7311d0cab5 100644 --- a/substrate/frame/transaction-payment/src/types.rs +++ b/substrate/frame/transaction-payment/src/types.rs @@ -24,7 +24,6 @@ use serde::{Deserialize, Serialize}; use scale_info::TypeInfo; use sp_runtime::traits::{AtLeast32BitUnsigned, Zero}; -use sp_std::prelude::*; use frame_support::dispatch::DispatchClass; diff --git a/substrate/frame/transaction-storage/Cargo.toml b/substrate/frame/transaction-storage/Cargo.toml index 3bb97e0cd0156..e57ee1e729c4d 100644 --- a/substrate/frame/transaction-storage/Cargo.toml +++ b/substrate/frame/transaction-storage/Cargo.toml @@ -27,7 +27,6 @@ pallet-balances = { workspace = true } sp-inherents = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-transaction-storage-proof = { workspace = true } log = { workspace = true } @@ -58,7 +57,6 @@ std = [ "sp-inherents/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", "sp-transaction-storage-proof/std", ] try-runtime = [ diff --git a/substrate/frame/transaction-storage/src/benchmarking.rs b/substrate/frame/transaction-storage/src/benchmarking.rs index 8d485d9f3cac2..f360e9847a1e1 100644 --- a/substrate/frame/transaction-storage/src/benchmarking.rs +++ b/substrate/frame/transaction-storage/src/benchmarking.rs @@ -20,11 +20,11 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; +use alloc::{vec, vec::Vec}; use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_support::traits::{Get, OnFinalize, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; use sp_runtime::traits::{Bounded, CheckedDiv, One, Zero}; -use sp_std::*; use sp_transaction_storage_proof::TransactionStorageProof; use crate::Pallet as TransactionStorage; diff --git a/substrate/frame/transaction-storage/src/lib.rs b/substrate/frame/transaction-storage/src/lib.rs index 6e58ee3e585ab..68f24526300d8 100644 --- a/substrate/frame/transaction-storage/src/lib.rs +++ b/substrate/frame/transaction-storage/src/lib.rs @@ -28,7 +28,11 @@ mod mock; #[cfg(test)] mod tests; +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; +use core::result; use frame_support::{ dispatch::GetDispatchInfo, traits::{ @@ -38,7 +42,6 @@ use frame_support::{ }, }; use sp_runtime::traits::{BlakeTwo256, Dispatchable, Hash, One, Saturating, Zero}; -use sp_std::{prelude::*, result}; use sp_transaction_storage_proof::{ encode_index, random_chunk, InherentError, TransactionStorageProof, CHUNK_SIZE, INHERENT_IDENTIFIER, diff --git a/substrate/frame/treasury/Cargo.toml b/substrate/frame/treasury/Cargo.toml index 33e74b0a4aa28..2727ab809320c 100644 --- a/substrate/frame/treasury/Cargo.toml +++ b/substrate/frame/treasury/Cargo.toml @@ -29,7 +29,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } pallet-balances = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } sp-core = { optional = true, workspace = true } [dev-dependencies] @@ -51,7 +50,6 @@ std = [ "sp-core?/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "dep:sp-core", diff --git a/substrate/frame/treasury/src/lib.rs b/substrate/frame/treasury/src/lib.rs index b437e5ef137e3..3954489a2d156 100644 --- a/substrate/frame/treasury/src/lib.rs +++ b/substrate/frame/treasury/src/lib.rs @@ -81,14 +81,16 @@ use core::marker::PhantomData; #[cfg(feature = "runtime-benchmarks")] pub use benchmarking::ArgumentsFactory; +extern crate alloc; + use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +use alloc::{boxed::Box, collections::btree_map::BTreeMap}; use sp_runtime::{ traits::{AccountIdConversion, CheckedAdd, Saturating, StaticLookup, Zero}, Permill, RuntimeDebug, }; -use sp_std::{collections::btree_map::BTreeMap, prelude::*}; use frame_support::{ dispatch::{DispatchResult, DispatchResultWithPostInfo}, @@ -326,7 +328,7 @@ pub mod pallet { #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig, I: 'static = ()> { #[serde(skip)] - _config: sp_std::marker::PhantomData<(T, I)>, + _config: core::marker::PhantomData<(T, I)>, } #[pallet::genesis_build] diff --git a/substrate/frame/try-runtime/Cargo.toml b/substrate/frame/try-runtime/Cargo.toml index 16e815975b544..228d96095ac92 100644 --- a/substrate/frame/try-runtime/Cargo.toml +++ b/substrate/frame/try-runtime/Cargo.toml @@ -19,7 +19,6 @@ codec = { features = ["derive"], workspace = true } frame-support = { workspace = true } sp-api = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [features] default = ["std"] @@ -28,6 +27,5 @@ std = [ "frame-support/std", "sp-api/std", "sp-runtime/std", - "sp-std/std", ] try-runtime = ["frame-support/try-runtime", "sp-runtime/try-runtime"] diff --git a/substrate/frame/tx-pause/Cargo.toml b/substrate/frame/tx-pause/Cargo.toml index fbb71513c6ae7..861a85881f2dd 100644 --- a/substrate/frame/tx-pause/Cargo.toml +++ b/substrate/frame/tx-pause/Cargo.toml @@ -22,7 +22,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } scale-info = { features = ["derive"], workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } pallet-balances = { optional = true, workspace = true } pallet-utility = { optional = true, workspace = true } pallet-proxy = { optional = true, workspace = true } @@ -48,7 +47,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/tx-pause/src/benchmarking.rs b/substrate/frame/tx-pause/src/benchmarking.rs index 126c0837949d5..95ae250eff7b5 100644 --- a/substrate/frame/tx-pause/src/benchmarking.rs +++ b/substrate/frame/tx-pause/src/benchmarking.rs @@ -18,6 +18,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::{Pallet as TxPause, *}; +use alloc::vec; use frame_benchmarking::v2::*; #[benchmarks] diff --git a/substrate/frame/tx-pause/src/lib.rs b/substrate/frame/tx-pause/src/lib.rs index 5904b5ed31628..68f7a0312554d 100644 --- a/substrate/frame/tx-pause/src/lib.rs +++ b/substrate/frame/tx-pause/src/lib.rs @@ -79,6 +79,9 @@ pub mod mock; mod tests; pub mod weights; +extern crate alloc; + +use alloc::vec::Vec; use frame_support::{ dispatch::GetDispatchInfo, pallet_prelude::*, @@ -87,7 +90,6 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; use sp_runtime::{traits::Dispatchable, DispatchResult}; -use sp_std::prelude::*; pub use pallet::*; pub use weights::*; diff --git a/substrate/frame/uniques/Cargo.toml b/substrate/frame/uniques/Cargo.toml index d41d322bb63f1..2b1794aa60fe7 100644 --- a/substrate/frame/uniques/Cargo.toml +++ b/substrate/frame/uniques/Cargo.toml @@ -23,7 +23,6 @@ frame-benchmarking = { optional = true, workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -44,7 +43,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/uniques/src/benchmarking.rs b/substrate/frame/uniques/src/benchmarking.rs index 80d02f1362189..a8a83010c51ff 100644 --- a/substrate/frame/uniques/src/benchmarking.rs +++ b/substrate/frame/uniques/src/benchmarking.rs @@ -20,6 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; +use alloc::{vec, vec::Vec}; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError, }; @@ -29,7 +30,6 @@ use frame_support::{ }; use frame_system::RawOrigin as SystemOrigin; use sp_runtime::traits::Bounded; -use sp_std::prelude::*; use crate::Pallet as Uniques; diff --git a/substrate/frame/uniques/src/impl_nonfungibles.rs b/substrate/frame/uniques/src/impl_nonfungibles.rs index 0ae055a98d8c8..8e4af723f8033 100644 --- a/substrate/frame/uniques/src/impl_nonfungibles.rs +++ b/substrate/frame/uniques/src/impl_nonfungibles.rs @@ -18,13 +18,13 @@ //! Implementations for `nonfungibles` traits. use super::*; +use alloc::vec::Vec; use frame_support::{ storage::KeyPrefixIterator, traits::{tokens::nonfungibles::*, Get}, BoundedSlice, }; use sp_runtime::{DispatchError, DispatchResult}; -use sp_std::prelude::*; impl, I: 'static> Inspect<::AccountId> for Pallet { type ItemId = T::ItemId; diff --git a/substrate/frame/uniques/src/lib.rs b/substrate/frame/uniques/src/lib.rs index 2291d19de2bfb..dc27c33562340 100644 --- a/substrate/frame/uniques/src/lib.rs +++ b/substrate/frame/uniques/src/lib.rs @@ -42,6 +42,9 @@ mod types; pub mod migration; pub mod weights; +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::traits::{ tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, ReservableCurrency, @@ -51,7 +54,6 @@ use sp_runtime::{ traits::{Saturating, StaticLookup, Zero}, ArithmeticError, RuntimeDebug, }; -use sp_std::prelude::*; pub use pallet::*; pub use types::*; diff --git a/substrate/frame/uniques/src/tests.rs b/substrate/frame/uniques/src/tests.rs index 5dfe43c96888d..a8428c420b3e5 100644 --- a/substrate/frame/uniques/src/tests.rs +++ b/substrate/frame/uniques/src/tests.rs @@ -21,7 +21,6 @@ use crate::{mock::*, Event, *}; use frame_support::{assert_noop, assert_ok, traits::Currency}; use pallet_balances::Error as BalancesError; use sp_runtime::traits::Dispatchable; -use sp_std::prelude::*; fn items() -> Vec<(u64, u32, u32)> { let mut r: Vec<_> = Account::::iter().map(|x| x.0).collect(); diff --git a/substrate/frame/utility/Cargo.toml b/substrate/frame/utility/Cargo.toml index 0ccdac6be6236..f08232de9cd6d 100644 --- a/substrate/frame/utility/Cargo.toml +++ b/substrate/frame/utility/Cargo.toml @@ -24,7 +24,6 @@ frame-system = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -48,7 +47,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/utility/src/benchmarking.rs b/substrate/frame/utility/src/benchmarking.rs index 78911fd310e85..467055ecd800d 100644 --- a/substrate/frame/utility/src/benchmarking.rs +++ b/substrate/frame/utility/src/benchmarking.rs @@ -20,6 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; +use alloc::{vec, vec::Vec}; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_system::RawOrigin; diff --git a/substrate/frame/utility/src/lib.rs b/substrate/frame/utility/src/lib.rs index 7f963e3637d6f..3ce5b4ff86496 100644 --- a/substrate/frame/utility/src/lib.rs +++ b/substrate/frame/utility/src/lib.rs @@ -56,6 +56,9 @@ mod benchmarking; mod tests; pub mod weights; +extern crate alloc; + +use alloc::{boxed::Box, vec::Vec}; use codec::{Decode, Encode}; use frame_support::{ dispatch::{extract_actual_weight, GetDispatchInfo, PostDispatchInfo}, @@ -64,7 +67,6 @@ use frame_support::{ use sp_core::TypeId; use sp_io::hashing::blake2_256; use sp_runtime::traits::{BadOrigin, Dispatchable, TrailingZeroInput}; -use sp_std::prelude::*; pub use weights::WeightInfo; pub use pallet::*; @@ -131,7 +133,7 @@ pub mod pallet { /// The limit on the number of batched calls. fn batched_calls_limit() -> u32 { let allocator_limit = sp_core::MAX_POSSIBLE_ALLOCATION; - let call_size = ((sp_std::mem::size_of::<::RuntimeCall>() as u32 + + let call_size = ((core::mem::size_of::<::RuntimeCall>() as u32 + CALL_ALIGN - 1) / CALL_ALIGN) * CALL_ALIGN; // The margin to take into account vec doubling capacity. @@ -146,7 +148,7 @@ pub mod pallet { fn integrity_test() { // If you hit this error, you need to try to `Box` big dispatchable parameters. assert!( - sp_std::mem::size_of::<::RuntimeCall>() as u32 <= CALL_ALIGN, + core::mem::size_of::<::RuntimeCall>() as u32 <= CALL_ALIGN, "Call enum size should be smaller than {} bytes.", CALL_ALIGN, ); diff --git a/substrate/frame/vesting/Cargo.toml b/substrate/frame/vesting/Cargo.toml index 3aca5683465cd..64c26174cfdfd 100644 --- a/substrate/frame/vesting/Cargo.toml +++ b/substrate/frame/vesting/Cargo.toml @@ -25,7 +25,6 @@ frame-benchmarking = { optional = true, workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -45,7 +44,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/substrate/frame/vesting/src/lib.rs b/substrate/frame/vesting/src/lib.rs index 3868f1a8592e9..bfc10efeed796 100644 --- a/substrate/frame/vesting/src/lib.rs +++ b/substrate/frame/vesting/src/lib.rs @@ -56,7 +56,11 @@ mod vesting_info; pub mod migrations; pub mod weights; +extern crate alloc; + +use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; +use core::{fmt::Debug, marker::PhantomData}; use frame_support::{ dispatch::DispatchResult, ensure, @@ -76,7 +80,6 @@ use sp_runtime::{ }, DispatchError, RuntimeDebug, }; -use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; pub use pallet::*; pub use vesting_info::*; diff --git a/substrate/frame/vesting/src/migrations.rs b/substrate/frame/vesting/src/migrations.rs index 6fe82312b637d..33fa5d0df882c 100644 --- a/substrate/frame/vesting/src/migrations.rs +++ b/substrate/frame/vesting/src/migrations.rs @@ -18,6 +18,7 @@ //! Storage migrations for the vesting pallet. use super::*; +use alloc::vec; // Migration from single schedule to multiple schedules. pub mod v1 { diff --git a/substrate/frame/whitelist/Cargo.toml b/substrate/frame/whitelist/Cargo.toml index 922f9124d913a..c48a15f216318 100644 --- a/substrate/frame/whitelist/Cargo.toml +++ b/substrate/frame/whitelist/Cargo.toml @@ -22,7 +22,6 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-api = { workspace = true } sp-runtime = { workspace = true } -sp-std = { workspace = true } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -44,7 +43,6 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime/std", - "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking", diff --git a/substrate/frame/whitelist/src/benchmarking.rs b/substrate/frame/whitelist/src/benchmarking.rs index 7fb5632fc0024..cbe6ee4becd0a 100644 --- a/substrate/frame/whitelist/src/benchmarking.rs +++ b/substrate/frame/whitelist/src/benchmarking.rs @@ -73,7 +73,7 @@ mod benchmarks { ) -> Result<(), BenchmarkError> { let origin = T::DispatchWhitelistedOrigin::try_successful_origin() .map_err(|_| BenchmarkError::Weightless)?; - let remark = sp_std::vec![1u8; n as usize]; + let remark = alloc::vec![1u8; n as usize]; let call: ::RuntimeCall = frame_system::Call::remark { remark }.into(); let call_weight = call.get_dispatch_info().weight; let encoded_call = call.encode(); @@ -97,7 +97,7 @@ mod benchmarks { fn dispatch_whitelisted_call_with_preimage(n: Linear<1, 10_000>) -> Result<(), BenchmarkError> { let origin = T::DispatchWhitelistedOrigin::try_successful_origin() .map_err(|_| BenchmarkError::Weightless)?; - let remark = sp_std::vec![1u8; n as usize]; + let remark = alloc::vec![1u8; n as usize]; let call: ::RuntimeCall = frame_system::Call::remark { remark }.into(); let call_hash = T::Hashing::hash_of(&call); diff --git a/substrate/frame/whitelist/src/lib.rs b/substrate/frame/whitelist/src/lib.rs index 44551abd10715..de16c2c2da883 100644 --- a/substrate/frame/whitelist/src/lib.rs +++ b/substrate/frame/whitelist/src/lib.rs @@ -40,6 +40,9 @@ mod tests; pub mod weights; pub use weights::WeightInfo; +extern crate alloc; + +use alloc::boxed::Box; use codec::{DecodeLimit, Encode, FullCodec}; use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, @@ -49,7 +52,6 @@ use frame_support::{ }; use scale_info::TypeInfo; use sp_runtime::traits::{Dispatchable, Hash}; -use sp_std::prelude::*; pub use pallet::*; diff --git a/substrate/primitives/api/Cargo.toml b/substrate/primitives/api/Cargo.toml index f8cbad8e31f02..d6c64a0ada28b 100644 --- a/substrate/primitives/api/Cargo.toml +++ b/substrate/primitives/api/Cargo.toml @@ -19,7 +19,6 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { workspace = true } sp-api-proc-macro = { workspace = true } sp-core = { workspace = true } -sp-std = { workspace = true } sp-runtime = { workspace = true } sp-runtime-interface = { workspace = true } sp-externalities = { optional = true, workspace = true } @@ -53,7 +52,6 @@ std = [ "sp-runtime-interface/std", "sp-runtime/std", "sp-state-machine/std", - "sp-std/std", "sp-test-primitives/std", "sp-trie/std", "sp-version/std", diff --git a/substrate/primitives/api/src/lib.rs b/substrate/primitives/api/src/lib.rs index cd8da8ba2374e..d254bf20601fe 100644 --- a/substrate/primitives/api/src/lib.rs +++ b/substrate/primitives/api/src/lib.rs @@ -70,6 +70,8 @@ // Make doc tests happy extern crate self as sp_api; +extern crate alloc; + /// Private exports used by the macros. /// /// This is seen as internal API and can change at any point. @@ -90,7 +92,9 @@ pub mod __private { pub use std_imports::*; pub use crate::*; + pub use alloc::vec; pub use codec::{self, Decode, DecodeLimit, Encode}; + pub use core::{mem, slice}; pub use scale_info; pub use sp_core::offchain; #[cfg(not(feature = "std"))] @@ -103,7 +107,6 @@ pub mod __private { transaction_validity::TransactionValidity, ExtrinsicInclusionMode, RuntimeString, TransactionOutcome, }; - pub use sp_std::{mem, slice, vec}; pub use sp_version::{create_apis_vec, ApiId, ApisVec, RuntimeVersion}; #[cfg(all(any(target_arch = "riscv32", target_arch = "riscv64"), substrate_runtime))] @@ -833,7 +836,7 @@ decl_runtime_apis! { /// Returns the supported metadata versions. /// /// This can be used to call `metadata_at_version`. - fn metadata_versions() -> sp_std::vec::Vec; + fn metadata_versions() -> alloc::vec::Vec; } } diff --git a/substrate/primitives/application-crypto/Cargo.toml b/substrate/primitives/application-crypto/Cargo.toml index fbf9def20fce7..c0508d377f8b4 100644 --- a/substrate/primitives/application-crypto/Cargo.toml +++ b/substrate/primitives/application-crypto/Cargo.toml @@ -22,7 +22,6 @@ sp-core = { workspace = true } codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } serde = { optional = true, features = ["alloc", "derive"], workspace = true } -sp-std = { workspace = true } sp-io = { workspace = true } [features] @@ -34,7 +33,6 @@ std = [ "serde/std", "sp-core/std", "sp-io/std", - "sp-std/std", ] # Serde support without relying on std features. diff --git a/substrate/primitives/application-crypto/src/bandersnatch.rs b/substrate/primitives/application-crypto/src/bandersnatch.rs index fc7383815d702..0e21e5d3bce31 100644 --- a/substrate/primitives/application-crypto/src/bandersnatch.rs +++ b/substrate/primitives/application-crypto/src/bandersnatch.rs @@ -18,8 +18,8 @@ //! Bandersnatch VRF application crypto types. use crate::{KeyTypeId, RuntimePublic}; +use alloc::vec::Vec; pub use sp_core::bandersnatch::*; -use sp_std::vec::Vec; mod app { crate::app_crypto!(super, sp_core::testing::BANDERSNATCH); diff --git a/substrate/primitives/application-crypto/src/bls377.rs b/substrate/primitives/application-crypto/src/bls377.rs index 3bd01de139c94..9d346ea618343 100644 --- a/substrate/primitives/application-crypto/src/bls377.rs +++ b/substrate/primitives/application-crypto/src/bls377.rs @@ -18,8 +18,8 @@ //! BLS12-377 crypto applications. use crate::{KeyTypeId, RuntimePublic}; +use alloc::vec::Vec; pub use sp_core::bls::bls377::*; -use sp_std::vec::Vec; mod app { crate::app_crypto!(super, sp_core::testing::BLS377); diff --git a/substrate/primitives/application-crypto/src/ecdsa.rs b/substrate/primitives/application-crypto/src/ecdsa.rs index 439b51dc60450..94d5288584ccb 100644 --- a/substrate/primitives/application-crypto/src/ecdsa.rs +++ b/substrate/primitives/application-crypto/src/ecdsa.rs @@ -19,7 +19,7 @@ use crate::{KeyTypeId, RuntimePublic}; -use sp_std::vec::Vec; +use alloc::vec::Vec; pub use sp_core::ecdsa::*; diff --git a/substrate/primitives/application-crypto/src/ecdsa_bls377.rs b/substrate/primitives/application-crypto/src/ecdsa_bls377.rs index 8dee73095fb2e..443d214d67729 100644 --- a/substrate/primitives/application-crypto/src/ecdsa_bls377.rs +++ b/substrate/primitives/application-crypto/src/ecdsa_bls377.rs @@ -18,7 +18,7 @@ //! ECDSA and BLS12-377 paired crypto applications. use crate::{KeyTypeId, RuntimePublic}; -use sp_std::vec::Vec; +use alloc::vec::Vec; pub use sp_core::paired_crypto::ecdsa_bls377::*; diff --git a/substrate/primitives/application-crypto/src/ed25519.rs b/substrate/primitives/application-crypto/src/ed25519.rs index addefe7daf643..6769de4e47c34 100644 --- a/substrate/primitives/application-crypto/src/ed25519.rs +++ b/substrate/primitives/application-crypto/src/ed25519.rs @@ -19,7 +19,7 @@ use crate::{KeyTypeId, RuntimePublic}; -use sp_std::vec::Vec; +use alloc::vec::Vec; pub use sp_core::ed25519::*; diff --git a/substrate/primitives/application-crypto/src/lib.rs b/substrate/primitives/application-crypto/src/lib.rs index 2355f1ba527d5..37949d7c41ded 100644 --- a/substrate/primitives/application-crypto/src/lib.rs +++ b/substrate/primitives/application-crypto/src/lib.rs @@ -20,6 +20,8 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + pub use sp_core::crypto::{key_types, CryptoTypeId, DeriveJunction, KeyTypeId, Ss58Codec}; #[doc(hidden)] pub use sp_core::crypto::{DeriveError, Pair, SecretStringError}; @@ -30,15 +32,17 @@ pub use sp_core::{ RuntimeDebug, }; +#[doc(hidden)] +pub use alloc::vec::Vec; #[doc(hidden)] pub use codec; #[doc(hidden)] +pub use core::ops::Deref; +#[doc(hidden)] pub use scale_info; #[doc(hidden)] #[cfg(feature = "serde")] pub use serde; -#[doc(hidden)] -pub use sp_std::{ops::Deref, vec::Vec}; #[cfg(feature = "bandersnatch-experimental")] pub mod bandersnatch; @@ -357,7 +361,7 @@ macro_rules! app_crypto_public_common { #[doc(hidden)] pub mod module_format_string_prelude { #[cfg(all(not(feature = "std"), feature = "serde"))] - pub use sp_std::alloc::{format, string::String}; + pub use alloc::{format, string::String}; #[cfg(feature = "std")] pub use std::{format, string::String}; } diff --git a/substrate/primitives/application-crypto/src/sr25519.rs b/substrate/primitives/application-crypto/src/sr25519.rs index d411cc253c0d8..ba6f0e3ae6b37 100644 --- a/substrate/primitives/application-crypto/src/sr25519.rs +++ b/substrate/primitives/application-crypto/src/sr25519.rs @@ -19,7 +19,7 @@ use crate::{KeyTypeId, RuntimePublic}; -use sp_std::vec::Vec; +use alloc::vec::Vec; pub use sp_core::sr25519::*; diff --git a/substrate/primitives/application-crypto/src/traits.rs b/substrate/primitives/application-crypto/src/traits.rs index 0b59abf272dc7..1789d9b96fd82 100644 --- a/substrate/primitives/application-crypto/src/traits.rs +++ b/substrate/primitives/application-crypto/src/traits.rs @@ -18,8 +18,9 @@ use codec::Codec; use scale_info::TypeInfo; +use alloc::vec::Vec; +use core::fmt::Debug; use sp_core::crypto::{CryptoType, CryptoTypeId, IsWrappedBy, KeyTypeId, Pair, Public}; -use sp_std::{fmt::Debug, vec::Vec}; /// Application-specific cryptographic object. /// @@ -47,8 +48,8 @@ pub trait AppCrypto: 'static + Sized + CryptoType { } /// Type which implements Hash in std, not when no-std (std variant). -pub trait MaybeHash: sp_std::hash::Hash {} -impl MaybeHash for T {} +pub trait MaybeHash: core::hash::Hash {} +impl MaybeHash for T {} /// Application-specific key pair. pub trait AppPair: diff --git a/substrate/primitives/arithmetic/Cargo.toml b/substrate/primitives/arithmetic/Cargo.toml index a0d80fc9b5049..4a9d5ba234bab 100644 --- a/substrate/primitives/arithmetic/Cargo.toml +++ b/substrate/primitives/arithmetic/Cargo.toml @@ -26,7 +26,6 @@ num-traits = { workspace = true } scale-info = { features = ["derive"], workspace = true } serde = { features = ["alloc", "derive"], optional = true, workspace = true } static_assertions = { workspace = true, default-features = true } -sp-std = { workspace = true } docify = { workspace = true } [dev-dependencies] @@ -43,7 +42,6 @@ std = [ "scale-info/std", "serde/std", "sp-crypto-hashing/std", - "sp-std/std", ] # Serde support without relying on std features. serde = ["dep:serde", "scale-info/serde"] diff --git a/substrate/primitives/core/src/address_uri.rs b/substrate/primitives/core/src/address_uri.rs index d44f3c0c87c40..bbe31b7553bd2 100644 --- a/substrate/primitives/core/src/address_uri.rs +++ b/substrate/primitives/core/src/address_uri.rs @@ -18,8 +18,8 @@ //! Little util for parsing an address URI. Replaces regular expressions. #[cfg(not(feature = "std"))] -use sp_std::{ - alloc::string::{String, ToString}, +use alloc::{ + string::{String, ToString}, vec::Vec, }; @@ -97,10 +97,10 @@ impl InvalidCharacterInfo { } } -impl sp_std::fmt::Display for InvalidCharacterInfo { - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { +impl core::fmt::Display for InvalidCharacterInfo { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { let (s, pos) = escape_string(&self.0, self.1); - write!(f, "{s}\n{i}^", i = sp_std::iter::repeat(" ").take(pos).collect::()) + write!(f, "{s}\n{i}^", i = core::iter::repeat(" ").take(pos).collect::()) } } diff --git a/substrate/primitives/core/src/bandersnatch.rs b/substrate/primitives/core/src/bandersnatch.rs index 71ee2da538348..25bf4657030fb 100644 --- a/substrate/primitives/core/src/bandersnatch.rs +++ b/substrate/primitives/core/src/bandersnatch.rs @@ -31,7 +31,7 @@ use bandersnatch_vrfs::{CanonicalSerialize, SecretKey}; use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_std::{vec, vec::Vec}; +use alloc::{vec, vec::Vec}; /// Identifier used to match public keys against bandersnatch-vrf keys. pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"band"); diff --git a/substrate/primitives/core/src/bls.rs b/substrate/primitives/core/src/bls.rs index bb04babb3f180..a86f67844da2a 100644 --- a/substrate/primitives/core/src/bls.rs +++ b/substrate/primitives/core/src/bls.rs @@ -28,7 +28,7 @@ use crate::crypto::{ SignatureBytes, UncheckedFrom, }; -use sp_std::vec::Vec; +use alloc::vec::Vec; use w3f_bls::{ DoublePublicKey, DoublePublicKeyScheme, DoubleSignature, EngineBLS, Keypair, Message, diff --git a/substrate/primitives/core/src/crypto.rs b/substrate/primitives/core/src/crypto.rs index b13899fff5176..fd7fe77672040 100644 --- a/substrate/primitives/core/src/crypto.rs +++ b/substrate/primitives/core/src/crypto.rs @@ -18,8 +18,14 @@ //! Cryptographic utilities. use crate::{ed25519, sr25519}; +#[cfg(all(not(feature = "std"), feature = "serde"))] +use alloc::{format, string::String, vec}; +use alloc::{str, vec::Vec}; use bip39::{Language, Mnemonic}; use codec::{Decode, Encode, MaxEncodedLen}; +use core::hash::Hash; +#[doc(hidden)] +pub use core::ops::Deref; #[cfg(feature = "std")] use itertools::Itertools; #[cfg(feature = "std")] @@ -27,14 +33,6 @@ use rand::{rngs::OsRng, RngCore}; use scale_info::TypeInfo; pub use secrecy::{ExposeSecret, SecretString}; use sp_runtime_interface::pass_by::PassByInner; -#[doc(hidden)] -pub use sp_std::ops::Deref; -#[cfg(all(not(feature = "std"), feature = "serde"))] -use sp_std::{ - alloc::{format, string::String}, - vec, -}; -use sp_std::{hash::Hash, str, vec::Vec}; pub use ss58_registry::{from_known_address_format, Ss58AddressFormat, Ss58AddressFormatRegistry}; /// Trait to zeroize a memory buffer. pub use zeroize::Zeroize; @@ -245,8 +243,8 @@ pub enum PublicError { } #[cfg(feature = "std")] -impl sp_std::fmt::Debug for PublicError { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { +impl core::fmt::Debug for PublicError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { // Just use the `Display` implementation write!(f, "{}", self) } @@ -587,8 +585,8 @@ impl std::fmt::Display for AccountId32 { } } -impl sp_std::fmt::Debug for AccountId32 { - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { +impl core::fmt::Debug for AccountId32 { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { #[cfg(feature = "serde")] { let s = self.to_ss58check(); @@ -624,7 +622,7 @@ impl<'de> serde::Deserialize<'de> for AccountId32 { } #[cfg(feature = "std")] -impl sp_std::str::FromStr for AccountId32 { +impl std::str::FromStr for AccountId32 { type Err = &'static str; fn from_str(s: &str) -> Result { @@ -786,7 +784,7 @@ pub struct SecretUri { pub junctions: Vec, } -impl sp_std::str::FromStr for SecretUri { +impl alloc::str::FromStr for SecretUri { type Err = SecretStringError; fn from_str(s: &str) -> Result { @@ -925,7 +923,7 @@ pub trait Pair: CryptoType + Sized { s: &str, password_override: Option<&str>, ) -> Result<(Self, Option), SecretStringError> { - use sp_std::str::FromStr; + use alloc::str::FromStr; let SecretUri { junctions, phrase, password } = SecretUri::from_str(s)?; let password = password_override.or_else(|| password.as_ref().map(|p| p.expose_secret().as_str())); diff --git a/substrate/primitives/core/src/crypto_bytes.rs b/substrate/primitives/core/src/crypto_bytes.rs index ee5f3482f743a..e5130e6d50079 100644 --- a/substrate/primitives/core/src/crypto_bytes.rs +++ b/substrate/primitives/core/src/crypto_bytes.rs @@ -34,7 +34,7 @@ use crate::crypto::Ss58Codec; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; #[cfg(all(not(feature = "std"), feature = "serde"))] -use sp_std::alloc::{format, string::String}; +use alloc::{format, string::String}; pub use public_bytes::*; pub use signature_bytes::*; @@ -256,7 +256,7 @@ mod public_bytes { impl Public for PublicBytes where Self: CryptoType {} - impl sp_std::fmt::Debug for PublicBytes + impl core::fmt::Debug for PublicBytes where Self: CryptoType, { @@ -267,7 +267,7 @@ mod public_bytes { } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } @@ -362,17 +362,17 @@ mod signature_bytes { } } - impl sp_std::fmt::Debug for SignatureBytes + impl core::fmt::Debug for SignatureBytes where Self: CryptoType, { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "{}", crate::hexdisplay::HexDisplay::from(&&self.0[..])) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } diff --git a/substrate/primitives/core/src/ecdsa.rs b/substrate/primitives/core/src/ecdsa.rs index 9cba8cc3d352a..d11811ff2af65 100644 --- a/substrate/primitives/core/src/ecdsa.rs +++ b/substrate/primitives/core/src/ecdsa.rs @@ -22,6 +22,8 @@ use crate::crypto::{ SecretStringError, SignatureBytes, }; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; #[cfg(not(feature = "std"))] use k256::ecdsa::{SigningKey as SecretKey, VerifyingKey}; #[cfg(feature = "std")] @@ -29,8 +31,6 @@ use secp256k1::{ ecdsa::{RecoverableSignature, RecoveryId}, Message, PublicKey, SecretKey, SECP256K1, }; -#[cfg(not(feature = "std"))] -use sp_std::vec::Vec; /// An identifier used to match public keys against ecdsa keys pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"ecds"); diff --git a/substrate/primitives/core/src/ed25519.rs b/substrate/primitives/core/src/ed25519.rs index 269b6bfcd8dce..401f9a39d5673 100644 --- a/substrate/primitives/core/src/ed25519.rs +++ b/substrate/primitives/core/src/ed25519.rs @@ -24,7 +24,7 @@ use crate::crypto::{ use ed25519_zebra::{SigningKey, VerificationKey}; -use sp_std::vec::Vec; +use alloc::vec::Vec; /// An identifier used to match public keys against ed25519 keys pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"ed25"); diff --git a/substrate/primitives/core/src/hexdisplay.rs b/substrate/primitives/core/src/hexdisplay.rs index 72bb24a186e54..1902b8cca958a 100644 --- a/substrate/primitives/core/src/hexdisplay.rs +++ b/substrate/primitives/core/src/hexdisplay.rs @@ -27,8 +27,8 @@ impl<'a> HexDisplay<'a> { } } -impl<'a> sp_std::fmt::Display for HexDisplay<'a> { - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> Result<(), sp_std::fmt::Error> { +impl<'a> core::fmt::Display for HexDisplay<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { if self.0.len() < 1027 { for byte in self.0 { f.write_fmt(format_args!("{:02x}", byte))?; @@ -46,8 +46,8 @@ impl<'a> sp_std::fmt::Display for HexDisplay<'a> { } } -impl<'a> sp_std::fmt::Debug for HexDisplay<'a> { - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> Result<(), sp_std::fmt::Error> { +impl<'a> core::fmt::Debug for HexDisplay<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { for byte in self.0 { f.write_fmt(format_args!("{:02x}", byte))?; } @@ -73,7 +73,7 @@ impl AsBytesRef for [u8] { } } -impl AsBytesRef for sp_std::vec::Vec { +impl AsBytesRef for alloc::vec::Vec { fn as_bytes_ref(&self) -> &[u8] { self } diff --git a/substrate/primitives/core/src/lib.rs b/substrate/primitives/core/src/lib.rs index 78ec92e4be98d..46503921453de 100644 --- a/substrate/primitives/core/src/lib.rs +++ b/substrate/primitives/core/src/lib.rs @@ -31,15 +31,18 @@ macro_rules! map { ); } +extern crate alloc; + +use alloc::vec::Vec; #[doc(hidden)] pub use codec::{Decode, Encode, MaxEncodedLen}; +use core::ops::Deref; use scale_info::TypeInfo; #[cfg(feature = "serde")] pub use serde; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use sp_runtime_interface::pass_by::{PassByEnum, PassByInner}; -use sp_std::{ops::Deref, prelude::*}; pub use sp_debug_derive::RuntimeDebug; @@ -137,7 +140,7 @@ impl codec::WrapperTypeDecode for Bytes { } #[cfg(feature = "std")] -impl sp_std::str::FromStr for Bytes { +impl alloc::str::FromStr for Bytes { type Err = bytes::FromHexError; fn from_str(s: &str) -> Result { @@ -156,7 +159,7 @@ impl OpaqueMetadata { } } -impl sp_std::ops::Deref for OpaqueMetadata { +impl Deref for OpaqueMetadata { type Target = Vec; fn deref(&self) -> &Self::Target { @@ -313,7 +316,7 @@ pub fn to_substrate_wasm_fn_return_value(value: &impl Encode) -> u64 { // Leak the output vector to avoid it being freed. // This is fine in a WASM context since the heap // will be discarded after the call. - sp_std::mem::forget(encoded); + core::mem::forget(encoded); res } @@ -456,7 +459,7 @@ macro_rules! generate_feature_enabled_macro { /// // Will add the code depending on the feature being enabled or not. #[doc = concat!(stringify!($macro_name), "!( println!(\"Hello\") )")] /// ``` - // https://github.com/rust-lang/rust/pull/52234 + // https://github.com/rust-lang/rust/pull/52234 pub use [<_ $macro_name>] as $macro_name; } }; diff --git a/substrate/primitives/core/src/offchain/mod.rs b/substrate/primitives/core/src/offchain/mod.rs index cef495dfaacdc..9be86e85d5878 100644 --- a/substrate/primitives/core/src/offchain/mod.rs +++ b/substrate/primitives/core/src/offchain/mod.rs @@ -18,10 +18,10 @@ //! Offchain workers types use crate::{OpaquePeerId, RuntimeDebug}; +use alloc::{boxed::Box, vec::Vec}; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime_interface::pass_by::{PassByCodec, PassByEnum, PassByInner}; -use sp_std::prelude::{Box, Vec}; pub use crate::crypto::KeyTypeId; diff --git a/substrate/primitives/core/src/paired_crypto.rs b/substrate/primitives/core/src/paired_crypto.rs index 260e86b6ff9c4..57bc5b006197b 100644 --- a/substrate/primitives/core/src/paired_crypto.rs +++ b/substrate/primitives/core/src/paired_crypto.rs @@ -24,7 +24,7 @@ use crate::crypto::{ PublicBytes, SecretStringError, Signature as SignatureT, SignatureBytes, UncheckedFrom, }; -use sp_std::vec::Vec; +use alloc::vec::Vec; /// ECDSA and BLS12-377 paired crypto scheme #[cfg(feature = "bls-experimental")] diff --git a/substrate/primitives/core/src/sr25519.rs b/substrate/primitives/core/src/sr25519.rs index 54b9a98db3d2c..48780f2ccff93 100644 --- a/substrate/primitives/core/src/sr25519.rs +++ b/substrate/primitives/core/src/sr25519.rs @@ -25,25 +25,25 @@ use crate::crypto::Ss58Codec; use crate::crypto::{ CryptoBytes, DeriveError, DeriveJunction, Pair as TraitPair, SecretStringError, }; +use alloc::vec::Vec; #[cfg(feature = "full_crypto")] use schnorrkel::signing_context; use schnorrkel::{ derive::{ChainCode, Derivation, CHAIN_CODE_LENGTH}, ExpansionMode, Keypair, MiniSecretKey, PublicKey, SecretKey, }; -use sp_std::vec::Vec; use crate::crypto::{CryptoType, CryptoTypeId, Derive, Public as TraitPublic, SignatureBytes}; use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +#[cfg(all(not(feature = "std"), feature = "serde"))] +use alloc::{format, string::String}; use schnorrkel::keys::{MINI_SECRET_KEY_LENGTH, SECRET_KEY_LENGTH}; #[cfg(feature = "serde")] use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; #[cfg(feature = "std")] use sp_runtime_interface::pass_by::PassByInner; -#[cfg(all(not(feature = "std"), feature = "serde"))] -use sp_std::alloc::{format, string::String}; // signing context const SIGNING_CTX: &[u8] = b"substrate"; @@ -100,15 +100,15 @@ impl std::fmt::Display for Public { } } -impl sp_std::fmt::Debug for Public { +impl core::fmt::Debug for Public { #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { let s = self.to_ss58check(); write!(f, "{} ({}...)", crate::hexdisplay::HexDisplay::from(self.inner()), &s[0..8]) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } diff --git a/substrate/primitives/io/Cargo.toml b/substrate/primitives/io/Cargo.toml index 6b58ea70b8e5e..923efc3b87646 100644 --- a/substrate/primitives/io/Cargo.toml +++ b/substrate/primitives/io/Cargo.toml @@ -25,7 +25,6 @@ codec = { features = [ sp-core = { workspace = true } sp-crypto-hashing = { workspace = true } sp-keystore = { optional = true, workspace = true } -sp-std = { workspace = true } libsecp256k1 = { optional = true, workspace = true, default-features = true } sp-state-machine = { optional = true, workspace = true } sp-runtime-interface = { workspace = true } @@ -67,7 +66,6 @@ std = [ "sp-keystore/std", "sp-runtime-interface/std", "sp-state-machine/std", - "sp-std/std", "sp-tracing/std", "sp-trie/std", "tracing-core/std", diff --git a/substrate/primitives/io/src/lib.rs b/substrate/primitives/io/src/lib.rs index 67e822ba7e248..b39a06ed2115a 100644 --- a/substrate/primitives/io/src/lib.rs +++ b/substrate/primitives/io/src/lib.rs @@ -77,7 +77,9 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(enable_alloc_error_handler, feature(alloc_error_handler))] -use sp_std::vec::Vec; +extern crate alloc; + +use alloc::vec::Vec; #[cfg(feature = "std")] use tracing; @@ -1771,7 +1773,7 @@ pub fn unreachable() -> ! { #[panic_handler] #[no_mangle] pub fn panic(info: &core::panic::PanicInfo) -> ! { - let message = sp_std::alloc::format!("{}", info); + let message = alloc::format!("{}", info); #[cfg(feature = "improved_panic_error_reporting")] { panic_handler::abort_on_panic(&message); diff --git a/substrate/primitives/runtime-interface/proc-macro/src/pass_by/enum_.rs b/substrate/primitives/runtime-interface/proc-macro/src/pass_by/enum_.rs index 0d05dd9aa51e2..d0eb382cdc566 100644 --- a/substrate/primitives/runtime-interface/proc-macro/src/pass_by/enum_.rs +++ b/substrate/primitives/runtime-interface/proc-macro/src/pass_by/enum_.rs @@ -54,7 +54,7 @@ pub fn derive_impl(input: DeriveInput) -> Result { impl TryFrom for #ident { type Error = (); - fn try_from(inner: u8) -> #crate_::sp_std::result::Result { + fn try_from(inner: u8) -> core::result::Result { match inner { #( #try_from_variants, )* _ => Err(()), diff --git a/substrate/primitives/runtime-interface/src/impls.rs b/substrate/primitives/runtime-interface/src/impls.rs index 3530b62662a53..daf5725e7f511 100644 --- a/substrate/primitives/runtime-interface/src/impls.rs +++ b/substrate/primitives/runtime-interface/src/impls.rs @@ -35,10 +35,12 @@ use sp_wasm_interface::{FunctionContext, Result}; use codec::{Decode, Encode}; -use sp_std::{any::TypeId, mem, vec::Vec}; +use core::{any::TypeId, mem}; + +use alloc::vec::Vec; #[cfg(feature = "std")] -use sp_std::borrow::Cow; +use alloc::borrow::Cow; // Make sure that our assumptions for storing a pointer + its size in `u64` is valid. #[cfg(all(not(feature = "std"), not(feature = "disable_target_static_assertions")))] @@ -337,7 +339,7 @@ impl IntoPreallocatedFFIValue for [u8; N] { } } -impl PassBy for sp_std::result::Result { +impl PassBy for core::result::Result { type PassBy = Codec; } diff --git a/substrate/primitives/runtime-interface/src/lib.rs b/substrate/primitives/runtime-interface/src/lib.rs index f6ef27789b36f..d6dcb69958af4 100644 --- a/substrate/primitives/runtime-interface/src/lib.rs +++ b/substrate/primitives/runtime-interface/src/lib.rs @@ -111,6 +111,8 @@ extern crate self as sp_runtime_interface; +extern crate alloc; + #[doc(hidden)] #[cfg(feature = "std")] pub use sp_wasm_interface; diff --git a/substrate/primitives/runtime-interface/src/pass_by.rs b/substrate/primitives/runtime-interface/src/pass_by.rs index 103e9c1622054..dce0b8e4bddb7 100644 --- a/substrate/primitives/runtime-interface/src/pass_by.rs +++ b/substrate/primitives/runtime-interface/src/pass_by.rs @@ -33,10 +33,10 @@ use crate::wasm::*; #[cfg(feature = "std")] use sp_wasm_interface::{FunctionContext, Pointer, Result}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; #[cfg(not(feature = "std"))] -use sp_std::vec::Vec; +use alloc::vec::Vec; /// Derive macro for implementing [`PassBy`] with the [`Codec`] strategy. /// diff --git a/substrate/primitives/runtime-interface/test-wasm/Cargo.toml b/substrate/primitives/runtime-interface/test-wasm/Cargo.toml index 759ab99ceacc1..77e77c707d9e6 100644 --- a/substrate/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/substrate/primitives/runtime-interface/test-wasm/Cargo.toml @@ -20,7 +20,6 @@ bytes = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime-interface = { workspace = true } -sp-std = { workspace = true } [build-dependencies] substrate-wasm-builder = { optional = true, workspace = true, default-features = true } @@ -32,6 +31,5 @@ std = [ "sp-core/std", "sp-io/std", "sp-runtime-interface/std", - "sp-std/std", "substrate-wasm-builder", ] diff --git a/substrate/primitives/runtime-interface/test-wasm/src/lib.rs b/substrate/primitives/runtime-interface/test-wasm/src/lib.rs index 2b3fc728f6ff4..545f1ff4a115e 100644 --- a/substrate/primitives/runtime-interface/test-wasm/src/lib.rs +++ b/substrate/primitives/runtime-interface/test-wasm/src/lib.rs @@ -19,11 +19,14 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + use sp_runtime_interface::runtime_interface; #[cfg(not(feature = "std"))] -use sp_std::{mem, prelude::*}; +use core::mem; +use alloc::{vec, vec::Vec}; use sp_core::{sr25519::Public, wasm_export_functions}; // Include the WASM binary @@ -229,7 +232,7 @@ wasm_export_functions! { fn test_invalid_utf8_data_should_return_an_error() { let data = vec![0, 159, 146, 150]; // I'm an evil hacker, trying to hack! - let data_str = unsafe { sp_std::str::from_utf8_unchecked(&data) }; + let data_str = unsafe { alloc::str::from_utf8_unchecked(&data) }; test_api::invalid_utf8_data(data_str); } diff --git a/substrate/primitives/runtime/src/generic/block.rs b/substrate/primitives/runtime/src/generic/block.rs index 05146e880cb16..8ed79c7c8dcf7 100644 --- a/substrate/primitives/runtime/src/generic/block.rs +++ b/substrate/primitives/runtime/src/generic/block.rs @@ -31,8 +31,8 @@ use crate::{ }, Justifications, }; +use alloc::vec::Vec; use sp_core::RuntimeDebug; -use sp_std::prelude::*; /// Something to identify a block. #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] diff --git a/substrate/primitives/runtime/src/generic/digest.rs b/substrate/primitives/runtime/src/generic/digest.rs index d7db0f91a4821..c639576a28670 100644 --- a/substrate/primitives/runtime/src/generic/digest.rs +++ b/substrate/primitives/runtime/src/generic/digest.rs @@ -17,12 +17,11 @@ //! Generic implementation of a digest. +#[cfg(all(not(feature = "std"), feature = "serde"))] +use alloc::format; +use alloc::vec::Vec; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -#[cfg(all(not(feature = "std"), feature = "serde"))] -use sp_std::alloc::format; - -use sp_std::prelude::*; use crate::{ codec::{Decode, Encode, Error, Input}, diff --git a/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs b/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs index df1f5645f0482..499b7c5f5836d 100644 --- a/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs +++ b/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs @@ -26,12 +26,13 @@ use crate::{ transaction_validity::{InvalidTransaction, TransactionValidityError}, OpaqueExtrinsic, }; +#[cfg(all(not(feature = "std"), feature = "serde"))] +use alloc::format; +use alloc::{vec, vec::Vec}; use codec::{Compact, Decode, Encode, EncodeLike, Error, Input}; +use core::fmt; use scale_info::{build::Fields, meta_type, Path, StaticTypeInfo, Type, TypeInfo, TypeParameter}; use sp_io::hashing::blake2_256; -#[cfg(all(not(feature = "std"), feature = "serde"))] -use sp_std::alloc::format; -use sp_std::{fmt, prelude::*}; /// Current version of the [`UncheckedExtrinsic`] encoded format. /// @@ -316,7 +317,7 @@ where Extra: SignedExtension, { fn encode(&self) -> Vec { - let mut tmp = Vec::with_capacity(sp_std::mem::size_of::()); + let mut tmp = Vec::with_capacity(core::mem::size_of::()); // 1 byte version id. match self.signature.as_ref() { @@ -437,7 +438,7 @@ mod tests { type AdditionalSigned = (); type Pre = (); - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } diff --git a/substrate/primitives/runtime/src/lib.rs b/substrate/primitives/runtime/src/lib.rs index 046909b9a38d7..d313d23395a0f 100644 --- a/substrate/primitives/runtime/src/lib.rs +++ b/substrate/primitives/runtime/src/lib.rs @@ -45,6 +45,11 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] +#[doc(hidden)] +extern crate alloc; + +#[doc(hidden)] +pub use alloc::vec::Vec; #[doc(hidden)] pub use codec; #[doc(hidden)] @@ -73,12 +78,12 @@ use sp_core::{ hash::{H256, H512}, sr25519, }; -use sp_std::prelude::*; +#[cfg(all(not(feature = "std"), feature = "serde"))] +use alloc::format; +use alloc::vec; use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; -#[cfg(all(not(feature = "std"), feature = "serde"))] -use sp_std::alloc::format; pub mod curve; pub mod generic; @@ -191,7 +196,7 @@ impl Justifications { impl IntoIterator for Justifications { type Item = Justification; - type IntoIter = sp_std::vec::IntoIter; + type IntoIter = alloc::vec::IntoIter; fn into_iter(self) -> Self::IntoIter { self.0.into_iter() @@ -508,11 +513,11 @@ impl From for DispatchOutcome { /// This is the legacy return type of `Dispatchable`. It is still exposed for compatibility reasons. /// The new return type is `DispatchResultWithInfo`. FRAME runtimes should use /// `frame_support::dispatch::DispatchResult`. -pub type DispatchResult = sp_std::result::Result<(), DispatchError>; +pub type DispatchResult = core::result::Result<(), DispatchError>; /// Return type of a `Dispatchable` which contains the `DispatchResult` and additional information /// about the `Dispatchable` that is only known post dispatch. -pub type DispatchResultWithInfo = sp_std::result::Result>; +pub type DispatchResultWithInfo = core::result::Result>; /// Reason why a pallet call failed. #[derive(Eq, Clone, Copy, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] @@ -911,14 +916,14 @@ impl OpaqueExtrinsic { } } -impl sp_std::fmt::Debug for OpaqueExtrinsic { +impl core::fmt::Debug for OpaqueExtrinsic { #[cfg(feature = "std")] - fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { write!(fmt, "{}", sp_core::hexdisplay::HexDisplay::from(&self.0)) } #[cfg(not(feature = "std"))] - fn fmt(&self, _fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn fmt(&self, _fmt: &mut core::fmt::Formatter) -> core::fmt::Result { Ok(()) } } diff --git a/substrate/primitives/runtime/src/multiaddress.rs b/substrate/primitives/runtime/src/multiaddress.rs index c435606312e43..4382405a8ebc6 100644 --- a/substrate/primitives/runtime/src/multiaddress.rs +++ b/substrate/primitives/runtime/src/multiaddress.rs @@ -17,8 +17,8 @@ //! MultiAddress type is a wrapper for multiple downstream account formats. +use alloc::vec::Vec; use codec::{Decode, Encode}; -use sp_std::vec::Vec; /// A multi-format address wrapper for on-chain accounts. #[derive(Encode, Decode, PartialEq, Eq, Clone, crate::RuntimeDebug, scale_info::TypeInfo)] diff --git a/substrate/primitives/runtime/src/offchain/http.rs b/substrate/primitives/runtime/src/offchain/http.rs index bacc0073825bb..7989916454025 100644 --- a/substrate/primitives/runtime/src/offchain/http.rs +++ b/substrate/primitives/runtime/src/offchain/http.rs @@ -48,15 +48,13 @@ //! assert_eq!(body.error(), &None); //! ``` +use alloc::{str, vec, vec::Vec}; use sp_core::{ offchain::{ HttpError, HttpRequestId as RequestId, HttpRequestStatus as RequestStatus, Timestamp, }, RuntimeDebug, }; -#[cfg(not(feature = "std"))] -use sp_std::prelude::vec; -use sp_std::{prelude::Vec, str}; /// Request method (HTTP verb) #[derive(Clone, PartialEq, Eq, RuntimeDebug)] diff --git a/substrate/primitives/runtime/src/runtime_logger.rs b/substrate/primitives/runtime/src/runtime_logger.rs index 6f1e738eb0e7a..79984b1356725 100644 --- a/substrate/primitives/runtime/src/runtime_logger.rs +++ b/substrate/primitives/runtime/src/runtime_logger.rs @@ -53,7 +53,7 @@ impl log::Log for RuntimeLogger { } fn log(&self, record: &log::Record) { - use sp_std::fmt::Write; + use core::fmt::Write; let mut w = sp_std::Writer::default(); let _ = ::core::write!(&mut w, "{}", record.args()); diff --git a/substrate/primitives/runtime/src/runtime_string.rs b/substrate/primitives/runtime/src/runtime_string.rs index 607ae59db632f..71aacf07a762e 100644 --- a/substrate/primitives/runtime/src/runtime_string.rs +++ b/substrate/primitives/runtime/src/runtime_string.rs @@ -15,9 +15,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +use alloc::vec::Vec; use codec::{Decode, Encode}; use sp_core::RuntimeDebug; -use sp_std::vec::Vec; /// A string that wraps a `&'static str` in the runtime and `String`/`Vec` on decode. #[derive(Eq, RuntimeDebug, Clone)] @@ -50,7 +50,7 @@ macro_rules! format_runtime_string { } #[cfg(not(feature = "std"))] { - sp_runtime::RuntimeString::Owned(sp_std::alloc::format!($($args)*).as_bytes().to_vec()) + sp_runtime::RuntimeString::Owned(alloc::format!($($args)*).as_bytes().to_vec()) } }}; } diff --git a/substrate/primitives/runtime/src/traits.rs b/substrate/primitives/runtime/src/traits.rs index d023aa045dbe0..25ef15eaf56ef 100644 --- a/substrate/primitives/runtime/src/traits.rs +++ b/substrate/primitives/runtime/src/traits.rs @@ -26,7 +26,10 @@ use crate::{ }, DispatchResult, }; +use alloc::vec::Vec; use codec::{Codec, Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; +#[doc(hidden)] +pub use core::{fmt::Debug, marker::PhantomData}; use impl_trait_for_tuples::impl_for_tuples; #[cfg(feature = "serde")] use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -44,9 +47,6 @@ pub use sp_core::{ parameter_types, ConstBool, ConstI128, ConstI16, ConstI32, ConstI64, ConstI8, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8, Get, GetDefault, TryCollect, TypedGet, }; -#[doc(hidden)] -pub use sp_std::marker::PhantomData; -use sp_std::{self, fmt::Debug, prelude::*}; #[cfg(feature = "std")] use std::fmt::Display; #[cfg(feature = "std")] @@ -322,7 +322,7 @@ impl TryMorph for Identity { } /// Implementation of `Morph` which converts between types using `Into`. -pub struct MorphInto(sp_std::marker::PhantomData); +pub struct MorphInto(core::marker::PhantomData); impl> Morph for MorphInto { type Outcome = T; fn morph(a: A) -> T { @@ -331,7 +331,7 @@ impl> Morph for MorphInto { } /// Implementation of `TryMorph` which attempts to convert between types using `TryInto`. -pub struct TryMorphInto(sp_std::marker::PhantomData); +pub struct TryMorphInto(core::marker::PhantomData); impl> TryMorph for TryMorphInto { type Outcome = T; fn try_morph(a: A) -> Result { @@ -692,7 +692,7 @@ impl MaybeEquivalence for Tuple { /// Adapter which turns a [Get] implementation into a [Convert] implementation which always returns /// in the same value no matter the input. -pub struct ConvertToValue(sp_std::marker::PhantomData); +pub struct ConvertToValue(core::marker::PhantomData); impl> Convert for ConvertToValue { fn convert(_: X) -> Y { T::get() @@ -934,17 +934,17 @@ impl Clear for T { pub trait SimpleBitOps: Sized + Clear - + sp_std::ops::BitOr - + sp_std::ops::BitXor - + sp_std::ops::BitAnd + + core::ops::BitOr + + core::ops::BitXor + + core::ops::BitAnd { } impl< T: Sized + Clear - + sp_std::ops::BitOr - + sp_std::ops::BitXor - + sp_std::ops::BitAnd, + + core::ops::BitOr + + core::ops::BitXor + + core::ops::BitAnd, > SimpleBitOps for T { } @@ -988,7 +988,7 @@ pub trait HashOutput: + MaybeDisplay + MaybeFromStr + Debug - + sp_std::hash::Hash + + core::hash::Hash + AsRef<[u8]> + AsMut<[u8]> + Copy @@ -1008,7 +1008,7 @@ impl HashOutput for T where + MaybeDisplay + MaybeFromStr + Debug - + sp_std::hash::Hash + + core::hash::Hash + AsRef<[u8]> + AsMut<[u8]> + Copy @@ -1131,7 +1131,7 @@ sp_core::impl_maybe_marker!( trait MaybeFromStr: FromStr; /// A type that implements Hash when in std environment. - trait MaybeHash: sp_std::hash::Hash; + trait MaybeHash: core::hash::Hash; ); sp_core::impl_maybe_marker_std_or_serde!( @@ -1158,7 +1158,7 @@ pub trait BlockNumber: + MaybeSerializeDeserialize + MaybeFromStr + Debug - + sp_std::hash::Hash + + core::hash::Hash + Copy + MaybeDisplay + AtLeast32BitUnsigned @@ -1176,7 +1176,7 @@ impl< + MaybeSerializeDeserialize + MaybeFromStr + Debug - + sp_std::hash::Hash + + core::hash::Hash + Copy + MaybeDisplay + AtLeast32BitUnsigned @@ -1599,7 +1599,7 @@ pub trait SignedExtension: /// This method provides a default implementation that returns a vec containing a single /// [`SignedExtensionMetadata`]. fn metadata() -> Vec { - sp_std::vec![SignedExtensionMetadata { + alloc::vec![SignedExtensionMetadata { identifier: Self::IDENTIFIER, ty: scale_info::meta_type::(), additional_signed: scale_info::meta_type::() @@ -1702,7 +1702,7 @@ impl SignedExtension for () { type Call = (); type Pre = (); const IDENTIFIER: &'static str = "UnitSignedExtension"; - fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { + fn additional_signed(&self) -> core::result::Result<(), TransactionValidityError> { Ok(()) } fn pre_dispatch( @@ -2035,7 +2035,7 @@ macro_rules! impl_opaque_keys_inner { /// The generated key pairs are stored in the keystore. /// /// Returns the concatenated SCALE encoded public keys. - pub fn generate(seed: Option<$crate::sp_std::vec::Vec>) -> $crate::sp_std::vec::Vec { + pub fn generate(seed: Option<$crate::Vec>) -> $crate::Vec { let keys = Self{ $( $field: < @@ -2051,7 +2051,7 @@ macro_rules! impl_opaque_keys_inner { /// Converts `Self` into a `Vec` of `(raw public key, KeyTypeId)`. pub fn into_raw_public_keys( self, - ) -> $crate::sp_std::vec::Vec<($crate::sp_std::vec::Vec, $crate::KeyTypeId)> { + ) -> $crate::Vec<($crate::Vec, $crate::KeyTypeId)> { let mut keys = Vec::new(); $( keys.push(( @@ -2073,7 +2073,7 @@ macro_rules! impl_opaque_keys_inner { /// Returns `None` when the decoding failed, otherwise `Some(_)`. pub fn decode_into_raw_public_keys( encoded: &[u8], - ) -> Option<$crate::sp_std::vec::Vec<($crate::sp_std::vec::Vec, $crate::KeyTypeId)>> { + ) -> Option<$crate::Vec<($crate::Vec, $crate::KeyTypeId)>> { ::decode(&mut &encoded[..]) .ok() .map(|s| s.into_raw_public_keys()) diff --git a/substrate/primitives/runtime/src/transaction_validity.rs b/substrate/primitives/runtime/src/transaction_validity.rs index 836948493823c..ffff94e17461e 100644 --- a/substrate/primitives/runtime/src/transaction_validity.rs +++ b/substrate/primitives/runtime/src/transaction_validity.rs @@ -21,8 +21,8 @@ use crate::{ codec::{Decode, Encode}, RuntimeDebug, }; +use alloc::{vec, vec::Vec}; use scale_info::TypeInfo; -use sp_std::prelude::*; /// Priority for a transaction. Additive. Higher is better. pub type TransactionPriority = u64; diff --git a/substrate/primitives/version/src/lib.rs b/substrate/primitives/version/src/lib.rs index 789c507742f77..55dea364eef4d 100644 --- a/substrate/primitives/version/src/lib.rs +++ b/substrate/primitives/version/src/lib.rs @@ -33,6 +33,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; #[cfg(feature = "std")] @@ -40,6 +42,8 @@ use std::collections::HashSet; #[cfg(feature = "std")] use std::fmt; +#[doc(hidden)] +pub use alloc::borrow::Cow; use codec::{Decode, Encode, Input}; use scale_info::TypeInfo; use sp_runtime::RuntimeString; @@ -139,13 +143,13 @@ pub use sp_version_proc_macro::runtime_version; pub type ApiId = [u8; 8]; /// A vector of pairs of `ApiId` and a `u32` for version. -pub type ApisVec = sp_std::borrow::Cow<'static, [(ApiId, u32)]>; +pub type ApisVec = alloc::borrow::Cow<'static, [(ApiId, u32)]>; /// Create a vector of Api declarations. #[macro_export] macro_rules! create_apis_vec { ( $y:expr ) => { - $crate::sp_std::borrow::Cow::Borrowed(&$y) + $crate::Cow::Borrowed(&$y) }; } @@ -409,9 +413,9 @@ impl GetNativeVersion for std::sync::Arc { #[cfg(feature = "serde")] mod apis_serialize { use super::*; + use alloc::vec::Vec; use impl_serde::serialize as bytes; use serde::{de, ser::SerializeTuple, Serializer}; - use sp_std::vec::Vec; #[derive(Serialize)] struct ApiId<'a>(#[serde(serialize_with = "serialize_bytesref")] &'a super::ApiId, &'a u32); @@ -446,7 +450,7 @@ mod apis_serialize { impl<'de> de::Visitor<'de> for Visitor { type Value = ApisVec; - fn expecting(&self, formatter: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result { formatter.write_str("a sequence of api id and version tuples") } diff --git a/substrate/test-utils/runtime/src/lib.rs b/substrate/test-utils/runtime/src/lib.rs index a13441302e4df..d1a3eaa2daa92 100644 --- a/substrate/test-utils/runtime/src/lib.rs +++ b/substrate/test-utils/runtime/src/lib.rs @@ -27,7 +27,6 @@ pub mod extrinsic; pub mod genesismap; pub mod substrate_test_pallet; -use alloc::boxed::Box; #[cfg(not(feature = "std"))] use alloc::{vec, vec::Vec}; use codec::{Decode, Encode}; diff --git a/templates/minimal/runtime/src/lib.rs b/templates/minimal/runtime/src/lib.rs index 8c7867f4cc8cd..08ad537ecdd14 100644 --- a/templates/minimal/runtime/src/lib.rs +++ b/templates/minimal/runtime/src/lib.rs @@ -23,6 +23,9 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +extern crate alloc; + +use alloc::{vec, vec::Vec}; use frame::{ deps::frame_support::{ genesis_builder_helper::{build_state, get_preset}, diff --git a/templates/parachain/runtime/src/lib.rs b/templates/parachain/runtime/src/lib.rs index 012ad1d097bfa..f53871bb18502 100644 --- a/templates/parachain/runtime/src/lib.rs +++ b/templates/parachain/runtime/src/lib.rs @@ -13,7 +13,7 @@ mod configs; mod weights; extern crate alloc; -use alloc::{boxed::Box, vec::Vec}; +use alloc::vec::Vec; use smallvec::smallvec; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, diff --git a/templates/solochain/runtime/src/lib.rs b/templates/solochain/runtime/src/lib.rs index 936ecd1bd388f..9de95ac956951 100644 --- a/templates/solochain/runtime/src/lib.rs +++ b/templates/solochain/runtime/src/lib.rs @@ -4,7 +4,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); extern crate alloc; -use alloc::{boxed::Box, vec, vec::Vec}; +use alloc::{vec, vec::Vec}; use pallet_grandpa::AuthorityId as GrandpaId; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; From c05b0b970942c2bc298f61be62cc2e2b5d46af19 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 15 Jul 2024 23:10:03 +0200 Subject: [PATCH 03/13] Updated substrate-relay version for tests (#5017) ## Testing Both Bridges zombienet tests passed, e.g.: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6698640 https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6698641 https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6700072 https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6700073 --- docker/dockerfiles/bridges_zombienet_tests_injected.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/dockerfiles/bridges_zombienet_tests_injected.Dockerfile b/docker/dockerfiles/bridges_zombienet_tests_injected.Dockerfile index 634b9f1882917..60698de1d6add 100644 --- a/docker/dockerfiles/bridges_zombienet_tests_injected.Dockerfile +++ b/docker/dockerfiles/bridges_zombienet_tests_injected.Dockerfile @@ -1,7 +1,7 @@ # this image is built on top of existing Zombienet image ARG ZOMBIENET_IMAGE # this image uses substrate-relay image built elsewhere -ARG SUBSTRATE_RELAY_IMAGE=docker.io/paritytech/substrate-relay:v1.6.5 +ARG SUBSTRATE_RELAY_IMAGE=docker.io/paritytech/substrate-relay:v1.6.6 # metadata ARG VCS_REF From 926c1b6adcaa767f4887b5774ef1fdde75156dd9 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 16 Jul 2024 00:57:08 +0200 Subject: [PATCH 04/13] rpc: add back rpc logger (#4952) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Kƶcher --- substrate/client/rpc-servers/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/substrate/client/rpc-servers/src/lib.rs b/substrate/client/rpc-servers/src/lib.rs index 619498b333365..0bae16b113dff 100644 --- a/substrate/client/rpc-servers/src/lib.rs +++ b/substrate/client/rpc-servers/src/lib.rs @@ -224,8 +224,9 @@ where ), }; - let rpc_middleware = - RpcServiceBuilder::new().option_layer(middleware_layer.clone()); + let rpc_middleware = RpcServiceBuilder::new() + .rpc_logger(1024) + .option_layer(middleware_layer.clone()); let mut svc = service_builder.set_rpc_middleware(rpc_middleware).build(methods, stop_handle); From 8d392711f59d60104d0dafba4609d8985a2216e9 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:23:26 +0300 Subject: [PATCH 05/13] net/litep2p: Propagate ValuePut events to the network backend (#5018) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `DhtEvent::ValuePut` was not propagated back to the higher levels. This PR ensures we'll send the ValuePut event similarly to `DhtEvent::ValuePutFailed` ### Next Steps - [ ] A bit more testing Thanks @alexggh for catching this šŸ™ cc @paritytech/networking Signed-off-by: Alexandru Vasile --- substrate/client/network/src/litep2p/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/substrate/client/network/src/litep2p/mod.rs b/substrate/client/network/src/litep2p/mod.rs index 824f62082cac7..34ca5b716101f 100644 --- a/substrate/client/network/src/litep2p/mod.rs +++ b/substrate/client/network/src/litep2p/mod.rs @@ -851,6 +851,10 @@ impl NetworkBackend for Litep2pNetworkBac "`PUT_VALUE` for {key:?} ({query_id:?}) succeeded", ); + self.event_streams.send(Event::Dht( + DhtEvent::ValuePut(libp2p::kad::RecordKey::new(&key)) + )); + if let Some(ref metrics) = self.metrics { metrics .kademlia_query_duration From d8d36a091c9f6387a448aaed0067406c9a2c6416 Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Tue, 16 Jul 2024 10:49:11 +0200 Subject: [PATCH 06/13] command-action: added scoped permissions to the github tokens (#5016) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will ensure that malicious code can not access other parts of the project. Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Bastian Kƶcher --- .github/workflows/command-bench-all.yml | 3 +++ .github/workflows/command-bench-overhead.yml | 3 +++ .github/workflows/command-bench.yml | 3 +++ .github/workflows/command-fmt.yml | 3 +++ .github/workflows/command-sync.yml | 3 +++ .github/workflows/command-update-ui.yml | 3 +++ 6 files changed, 18 insertions(+) diff --git a/.github/workflows/command-bench-all.yml b/.github/workflows/command-bench-all.yml index 6aa4f6f7ff003..4128f86fb7c82 100644 --- a/.github/workflows/command-bench-all.yml +++ b/.github/workflows/command-bench-all.yml @@ -66,6 +66,9 @@ jobs: runs-on: arc-runners-polkadot-sdk-weights container: image: ${{ needs.set-image.outputs.IMAGE }} + permissions: + contents: write + pull-requests: write steps: - name: Download repo uses: actions/checkout@v4 diff --git a/.github/workflows/command-bench-overhead.yml b/.github/workflows/command-bench-overhead.yml index 16cbcefcf2697..fec8d37bb9ef8 100644 --- a/.github/workflows/command-bench-overhead.yml +++ b/.github/workflows/command-bench-overhead.yml @@ -45,6 +45,9 @@ jobs: runs-on: arc-runners-polkadot-sdk-benchmark container: image: ${{ needs.set-image.outputs.IMAGE }} + permissions: + contents: write + pull-requests: write steps: - name: Download repo uses: actions/checkout@v4 diff --git a/.github/workflows/command-bench.yml b/.github/workflows/command-bench.yml index b23b06d1b3c04..ac879f443755c 100644 --- a/.github/workflows/command-bench.yml +++ b/.github/workflows/command-bench.yml @@ -91,6 +91,9 @@ jobs: runs-on: arc-runners-polkadot-sdk-benchmark container: image: ${{ needs.set-image.outputs.IMAGE }} + permissions: + contents: write + pull-requests: write steps: - name: Download repo uses: actions/checkout@v4 diff --git a/.github/workflows/command-fmt.yml b/.github/workflows/command-fmt.yml index c949d0768d7a7..586b8c77f2745 100644 --- a/.github/workflows/command-fmt.yml +++ b/.github/workflows/command-fmt.yml @@ -23,6 +23,9 @@ jobs: timeout-minutes: 20 container: image: ${{ needs.set-image.outputs.IMAGE }} + permissions: + contents: write + pull-requests: write steps: - name: Download repo uses: actions/checkout@v4 diff --git a/.github/workflows/command-sync.yml b/.github/workflows/command-sync.yml index fa5bb9eaf9125..c610f4066a873 100644 --- a/.github/workflows/command-sync.yml +++ b/.github/workflows/command-sync.yml @@ -38,6 +38,9 @@ jobs: runs-on: arc-runners-polkadot-sdk-warpsync container: image: ${{ needs.set-image.outputs.IMAGE }} + permissions: + contents: write + pull-requests: write steps: - name: Download repo uses: actions/checkout@v4 diff --git a/.github/workflows/command-update-ui.yml b/.github/workflows/command-update-ui.yml index b6b0420e78689..860177adc8790 100644 --- a/.github/workflows/command-update-ui.yml +++ b/.github/workflows/command-update-ui.yml @@ -26,6 +26,9 @@ jobs: timeout-minutes: 90 container: image: ${{ needs.set-image.outputs.IMAGE }} + permissions: + contents: write + pull-requests: write steps: - name: Download repo uses: actions/checkout@v4 From 0b3d7607d2f78e9b62d92ccf487f0984f921043e Mon Sep 17 00:00:00 2001 From: Parth Mittal <76661350+mittal-parth@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:23:37 +0530 Subject: [PATCH 07/13] Remove `pallet-getter` usage from pallet-session (#4972) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per #3326, removes usage of the `pallet::getter` macro from the `session` pallet. The syntax `StorageItem::::get()` should be used instead. Also, adds public functions for compatibility. NOTE: The `./historical` directory has not been modified. cc @muraca polkadot address: 5GsLutpKjbzsbTphebs9Uy4YK6gTN47MAaz6njPktidjR5cp --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Bastian Kƶcher --- prdoc/pr_4972.prdoc | 14 ++++ substrate/frame/session/README.md | 2 +- .../frame/session/benchmarking/src/inner.rs | 2 +- substrate/frame/session/src/lib.rs | 74 +++++++++++-------- substrate/frame/session/src/tests.rs | 44 +++++------ 5 files changed, 83 insertions(+), 53 deletions(-) create mode 100644 prdoc/pr_4972.prdoc diff --git a/prdoc/pr_4972.prdoc b/prdoc/pr_4972.prdoc new file mode 100644 index 0000000000000..dd9f1b531aad1 --- /dev/null +++ b/prdoc/pr_4972.prdoc @@ -0,0 +1,14 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "Remove `pallet::getter` usage from pallet-session" + +doc: + - audience: Runtime Dev + description: | + This PR removes the `pallet::getter`s from `pallet-session`. + The syntax `StorageItem::::get()` should be used instead. + +crates: + - name: pallet-session + bump: minor diff --git a/substrate/frame/session/README.md b/substrate/frame/session/README.md index fa7c9b3f98348..5a063bffee0b1 100644 --- a/substrate/frame/session/README.md +++ b/substrate/frame/session/README.md @@ -70,7 +70,7 @@ set. use pallet_session as session; fn validators() -> Vec<::ValidatorId> { - >::validators() + pallet_session::Validators::::get() } ``` diff --git a/substrate/frame/session/benchmarking/src/inner.rs b/substrate/frame/session/benchmarking/src/inner.rs index f08e10f078690..9ba47b34ed7a3 100644 --- a/substrate/frame/session/benchmarking/src/inner.rs +++ b/substrate/frame/session/benchmarking/src/inner.rs @@ -152,7 +152,7 @@ fn check_membership_proof_setup( Pallet::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::one()); // skip sessions until the new validator set is enacted - while Session::::validators().len() < n as usize { + while Validators::::get().len() < n as usize { Session::::rotate_session(); } diff --git a/substrate/frame/session/src/lib.rs b/substrate/frame/session/src/lib.rs index 45f70dfa2582d..e1a2a31911feb 100644 --- a/substrate/frame/session/src/lib.rs +++ b/substrate/frame/session/src/lib.rs @@ -95,7 +95,7 @@ //! use pallet_session as session; //! //! fn validators() -> Vec<::ValidatorId> { -//! >::validators() +//! pallet_session::Validators::::get() //! } //! # fn main(){} //! ``` @@ -447,7 +447,7 @@ pub mod pallet { }); for (account, val, keys) in self.keys.iter().cloned() { - >::inner_set_keys(&val, keys) + Pallet::::inner_set_keys(&val, keys) .expect("genesis config must not contain duplicates; qed"); if frame_system::Pallet::::inc_consumers_without_limit(&account).is_err() { // This will leak a provider reference, however it only happens once (at @@ -479,7 +479,7 @@ pub mod pallet { T::SessionHandler::on_genesis_session::(&queued_keys); Validators::::put(initial_validators_0); - >::put(queued_keys); + QueuedKeys::::put(queued_keys); T::SessionManager::start_session(0); } @@ -487,12 +487,10 @@ pub mod pallet { /// The current set of validators. #[pallet::storage] - #[pallet::getter(fn validators)] pub type Validators = StorageValue<_, Vec, ValueQuery>; /// Current index of the session. #[pallet::storage] - #[pallet::getter(fn current_index)] pub type CurrentIndex = StorageValue<_, SessionIndex, ValueQuery>; /// True if the underlying economic identities or weighting behind the validators @@ -503,7 +501,6 @@ pub mod pallet { /// The queued keys for the next session. When the next session begins, these keys /// will be used to determine the validator's session keys. #[pallet::storage] - #[pallet::getter(fn queued_keys)] pub type QueuedKeys = StorageValue<_, Vec<(T::ValidatorId, T::Keys)>, ValueQuery>; /// Indices of disabled validators. @@ -512,7 +509,6 @@ pub mod pallet { /// disabled using binary search. It gets cleared when `on_session_ending` returns /// a new set of identities. #[pallet::storage] - #[pallet::getter(fn disabled_validators)] pub type DisabledValidators = StorageValue<_, Vec, ValueQuery>; /// The next session keys for a validator. @@ -609,33 +605,53 @@ pub mod pallet { } impl Pallet { + /// Public function to access the current set of validators. + pub fn validators() -> Vec { + Validators::::get() + } + + /// Public function to access the current session index. + pub fn current_index() -> SessionIndex { + CurrentIndex::::get() + } + + /// Public function to access the queued keys. + pub fn queued_keys() -> Vec<(T::ValidatorId, T::Keys)> { + QueuedKeys::::get() + } + + /// Public function to access the disabled validators. + pub fn disabled_validators() -> Vec { + DisabledValidators::::get() + } + /// Move on to next session. Register new validator set and session keys. Changes to the /// validator set have a session of delay to take effect. This allows for equivocation /// punishment after a fork. pub fn rotate_session() { - let session_index = >::get(); + let session_index = CurrentIndex::::get(); log::trace!(target: "runtime::session", "rotating session {:?}", session_index); - let changed = >::get(); + let changed = QueuedChanged::::get(); // Inform the session handlers that a session is going to end. T::SessionHandler::on_before_session_ending(); T::SessionManager::end_session(session_index); // Get queued session keys and validators. - let session_keys = >::get(); + let session_keys = QueuedKeys::::get(); let validators = session_keys.iter().map(|(validator, _)| validator.clone()).collect::>(); Validators::::put(&validators); if changed { // reset disabled validators if active set was changed - >::take(); + DisabledValidators::::take(); } // Increment session index. let session_index = session_index + 1; - >::put(session_index); + CurrentIndex::::put(session_index); T::SessionManager::start_session(session_index); @@ -683,8 +699,8 @@ impl Pallet { (queued_amalgamated, changed) }; - >::put(queued_amalgamated.clone()); - >::put(next_changed); + QueuedKeys::::put(queued_amalgamated.clone()); + QueuedChanged::::put(next_changed); // Record that this happened. Self::deposit_event(Event::NewSession { session_index }); @@ -699,7 +715,7 @@ impl Pallet { return false } - >::mutate(|disabled| { + DisabledValidators::::mutate(|disabled| { if let Err(index) = disabled.binary_search(&i) { disabled.insert(index, i); T::SessionHandler::on_disabled(i); @@ -716,7 +732,7 @@ impl Pallet { /// Returns `false` either if the validator could not be found or it was already /// disabled. pub fn disable(c: &T::ValidatorId) -> bool { - Self::validators() + Validators::::get() .iter() .position(|i| i == c) .map(|i| Self::disable_index(i as u32)) @@ -747,7 +763,7 @@ impl Pallet { let new_ids = T::Keys::key_ids(); // Translate NextKeys, and key ownership relations at the same time. - >::translate::(|val, old_keys| { + NextKeys::::translate::(|val, old_keys| { // Clear all key ownership relations. Typically the overlap should // stay the same, but no guarantees by the upgrade function. for i in old_ids.iter() { @@ -764,7 +780,7 @@ impl Pallet { Some(new_keys) }); - let _ = >::translate::, _>(|k| { + let _ = QueuedKeys::::translate::, _>(|k| { k.map(|k| { k.into_iter() .map(|(val, old_keys)| (val.clone(), upgrade(val, old_keys))) @@ -850,28 +866,28 @@ impl Pallet { } fn load_keys(v: &T::ValidatorId) -> Option { - >::get(v) + NextKeys::::get(v) } fn take_keys(v: &T::ValidatorId) -> Option { - >::take(v) + NextKeys::::take(v) } fn put_keys(v: &T::ValidatorId, keys: &T::Keys) { - >::insert(v, keys); + NextKeys::::insert(v, keys); } /// Query the owner of a session key by returning the owner's validator ID. pub fn key_owner(id: KeyTypeId, key_data: &[u8]) -> Option { - >::get((id, key_data)) + KeyOwner::::get((id, key_data)) } fn put_key_owner(id: KeyTypeId, key_data: &[u8], v: &T::ValidatorId) { - >::insert((id, key_data), v) + KeyOwner::::insert((id, key_data), v) } fn clear_key_owner(id: KeyTypeId, key_data: &[u8]) { - >::remove((id, key_data)); + KeyOwner::::remove((id, key_data)); } } @@ -886,11 +902,11 @@ impl ValidatorSet for Pallet { type ValidatorIdOf = T::ValidatorIdOf; fn session_index() -> sp_staking::SessionIndex { - Pallet::::current_index() + CurrentIndex::::get() } fn validators() -> Vec { - Pallet::::validators() + Validators::::get() } } @@ -908,11 +924,11 @@ impl EstimateNextNewSession> for Pallet { impl frame_support::traits::DisabledValidators for Pallet { fn is_disabled(index: u32) -> bool { - >::disabled_validators().binary_search(&index).is_ok() + DisabledValidators::::get().binary_search(&index).is_ok() } fn disabled_validators() -> Vec { - >::disabled_validators() + DisabledValidators::::get() } } @@ -930,7 +946,7 @@ impl> FindAuthor { let i = Inner::find_author(digests)?; - let validators = >::validators(); + let validators = Validators::::get(); validators.get(i as usize).cloned() } } diff --git a/substrate/frame/session/src/tests.rs b/substrate/frame/session/src/tests.rs index 69337e016ea8a..f392c2ab7663c 100644 --- a/substrate/frame/session/src/tests.rs +++ b/substrate/frame/session/src/tests.rs @@ -44,7 +44,7 @@ fn initialize_block(block: u64) { fn simple_setup_should_work() { new_test_ext().execute_with(|| { assert_eq!(authorities(), vec![UintAuthorityId(1), UintAuthorityId(2), UintAuthorityId(3)]); - assert_eq!(Session::validators(), vec![1, 2, 3]); + assert_eq!(Validators::::get(), vec![1, 2, 3]); }); } @@ -60,7 +60,7 @@ fn put_get_keys() { fn keys_cleared_on_kill() { let mut ext = new_test_ext(); ext.execute_with(|| { - assert_eq!(Session::validators(), vec![1, 2, 3]); + assert_eq!(Validators::::get(), vec![1, 2, 3]); assert_eq!(Session::load_keys(&1), Some(UintAuthorityId(1).into())); let id = DUMMY; @@ -79,7 +79,7 @@ fn keys_cleared_on_kill() { fn purge_keys_works_for_stash_id() { let mut ext = new_test_ext(); ext.execute_with(|| { - assert_eq!(Session::validators(), vec![1, 2, 3]); + assert_eq!(Validators::::get(), vec![1, 2, 3]); TestValidatorIdOf::set(vec![(10, 1), (20, 2), (3, 3)].into_iter().collect()); assert_eq!(Session::load_keys(&1), Some(UintAuthorityId(1).into())); assert_eq!(Session::load_keys(&2), Some(UintAuthorityId(2).into())); @@ -108,10 +108,10 @@ fn authorities_should_track_validators() { force_new_session(); initialize_block(1); assert_eq!( - Session::queued_keys(), + QueuedKeys::::get(), vec![(1, UintAuthorityId(1).into()), (2, UintAuthorityId(2).into()),] ); - assert_eq!(Session::validators(), vec![1, 2, 3]); + assert_eq!(Validators::::get(), vec![1, 2, 3]); assert_eq!(authorities(), vec![UintAuthorityId(1), UintAuthorityId(2), UintAuthorityId(3)]); assert!(before_session_end_called()); reset_before_session_end_called(); @@ -119,10 +119,10 @@ fn authorities_should_track_validators() { force_new_session(); initialize_block(2); assert_eq!( - Session::queued_keys(), + QueuedKeys::::get(), vec![(1, UintAuthorityId(1).into()), (2, UintAuthorityId(2).into()),] ); - assert_eq!(Session::validators(), vec![1, 2]); + assert_eq!(Validators::::get(), vec![1, 2]); assert_eq!(authorities(), vec![UintAuthorityId(1), UintAuthorityId(2)]); assert!(before_session_end_called()); reset_before_session_end_called(); @@ -132,28 +132,28 @@ fn authorities_should_track_validators() { force_new_session(); initialize_block(3); assert_eq!( - Session::queued_keys(), + QueuedKeys::::get(), vec![ (1, UintAuthorityId(1).into()), (2, UintAuthorityId(2).into()), (4, UintAuthorityId(4).into()), ] ); - assert_eq!(Session::validators(), vec![1, 2]); + assert_eq!(Validators::::get(), vec![1, 2]); assert_eq!(authorities(), vec![UintAuthorityId(1), UintAuthorityId(2)]); assert!(before_session_end_called()); force_new_session(); initialize_block(4); assert_eq!( - Session::queued_keys(), + QueuedKeys::::get(), vec![ (1, UintAuthorityId(1).into()), (2, UintAuthorityId(2).into()), (4, UintAuthorityId(4).into()), ] ); - assert_eq!(Session::validators(), vec![1, 2, 4]); + assert_eq!(Validators::::get(), vec![1, 2, 4]); assert_eq!(authorities(), vec![UintAuthorityId(1), UintAuthorityId(2), UintAuthorityId(4)]); }); } @@ -164,20 +164,20 @@ fn should_work_with_early_exit() { set_session_length(10); initialize_block(1); - assert_eq!(Session::current_index(), 0); + assert_eq!(CurrentIndex::::get(), 0); initialize_block(2); - assert_eq!(Session::current_index(), 0); + assert_eq!(CurrentIndex::::get(), 0); force_new_session(); initialize_block(3); - assert_eq!(Session::current_index(), 1); + assert_eq!(CurrentIndex::::get(), 1); initialize_block(9); - assert_eq!(Session::current_index(), 1); + assert_eq!(CurrentIndex::::get(), 1); initialize_block(10); - assert_eq!(Session::current_index(), 2); + assert_eq!(CurrentIndex::::get(), 2); }); } @@ -402,7 +402,7 @@ fn upgrade_keys() { // Set `QueuedKeys`. { - let storage_key = >::hashed_key(); + let storage_key = super::QueuedKeys::::hashed_key(); assert!(storage::unhashed::exists(&storage_key)); storage::unhashed::put(&storage_key, &val_keys); } @@ -410,7 +410,7 @@ fn upgrade_keys() { // Set `NextKeys`. { for &(i, ref keys) in val_keys.iter() { - let storage_key = >::hashed_key_for(i); + let storage_key = super::NextKeys::::hashed_key_for(i); assert!(storage::unhashed::exists(&storage_key)); storage::unhashed::put(&storage_key, keys); } @@ -446,12 +446,12 @@ fn upgrade_keys() { // Check queued keys. assert_eq!( - Session::queued_keys(), + QueuedKeys::::get(), vec![(1, mock_keys_for(1)), (2, mock_keys_for(2)), (3, mock_keys_for(3)),], ); for i in 1u64..4 { - assert_eq!(>::get(&i), Some(mock_keys_for(i))); + assert_eq!(super::NextKeys::::get(&i), Some(mock_keys_for(i))); } }) } @@ -466,8 +466,8 @@ fn test_migration_v1() { use frame_support::traits::{PalletInfoAccess, StorageVersion}; new_test_ext().execute_with(|| { - assert!(>::iter_values().count() > 0); - assert!(>::exists()); + assert!(HistoricalSessions::::iter_values().count() > 0); + assert!(StoredRange::::exists()); let old_pallet = "Session"; let new_pallet = ::name(); From cde2eb42a6b4ed5e930e59ec4dc03b5fa5059bd5 Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghe <49718502+alexggh@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:51:09 +0300 Subject: [PATCH 08/13] [1 / 5] Optimize logic for gossiping assignments (#4848) This is part of the work to further optimize the approval subsystems, if you want to understand the full context start with reading https://github.com/paritytech/polkadot-sdk/pull/4849#issue-2364261568, however that's not necessary, as this change is self-contained and nodes would benefit from it regardless of subsequent changes landing or not. While testing with 1000 validators I found out that the logic for determining the validators an assignment should be gossiped to is taking a lot of time, because it always iterated through all the peers, to determine which are X and Y neighbours and to which we should randomly gossip(4 samples). This could be actually optimised, so we don't have to iterate through all peers for each new assignment, by fetching the list of X and Y peer ids from the topology first and then stopping the loop once we took the 4 random samples. With this improvements we reduce the total CPU time spent in approval-distribution with 15% on networks with 500 validators and 20% on networks with 1000 validators. ## Test coverage: `propagates_assignments_along_unshared_dimension` and `propagates_locally_generated_assignment_to_both_dimensions` cover already logic and they passed, confirm that there is no breaking change. Additionally, the approval voting benchmark measure the traffic sent to other peers, so I confirmed that for various network size there is no difference in the size of the traffic sent to other peers. --------- Signed-off-by: Alexandru Gheorghe --- .../network/approval-distribution/src/lib.rs | 30 +++++++++++++------ .../approval-distribution/src/tests.rs | 12 +++++--- .../network/protocol/src/grid_topology.rs | 22 ++++++++++++++ prdoc/pr_4848.prdoc | 14 +++++++++ 4 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 prdoc/pr_4848.prdoc diff --git a/polkadot/node/network/approval-distribution/src/lib.rs b/polkadot/node/network/approval-distribution/src/lib.rs index 369d82b45b094..d48fb08a311c7 100644 --- a/polkadot/node/network/approval-distribution/src/lib.rs +++ b/polkadot/node/network/approval-distribution/src/lib.rs @@ -1431,6 +1431,21 @@ impl State { let required_routing = topology.map_or(RequiredRouting::PendingTopology, |t| { t.local_grid_neighbors().required_routing_by_index(validator_index, local) }); + // Peers that we will send the assignment to. + let mut peers = HashSet::new(); + + let peers_to_route_to = topology + .as_ref() + .map(|t| t.peers_to_route(required_routing)) + .unwrap_or_default(); + + for peer in peers_to_route_to { + if !entry.known_by.contains_key(&peer) { + continue + } + + peers.insert(peer); + } // All the peers that know the relay chain block. let peers_to_filter = entry.known_by(); @@ -1456,20 +1471,13 @@ impl State { let n_peers_total = self.peer_views.len(); let source_peer = source.peer_id(); - // Peers that we will send the assignment to. - let mut peers = Vec::new(); - // Filter destination peers for peer in peers_to_filter.into_iter() { if Some(peer) == source_peer { continue } - if let Some(true) = topology - .as_ref() - .map(|t| t.local_grid_neighbors().route_to_peer(required_routing, &peer)) - { - peers.push(peer); + if peers.contains(&peer) { continue } @@ -1485,7 +1493,11 @@ impl State { if route_random { approval_entry.routing_info_mut().mark_randomly_sent(peer); - peers.push(peer); + peers.insert(peer); + } + + if approval_entry.routing_info().random_routing.is_complete() { + break } } diff --git a/polkadot/node/network/approval-distribution/src/tests.rs b/polkadot/node/network/approval-distribution/src/tests.rs index 5ad034464767e..2d08807f97b60 100644 --- a/polkadot/node/network/approval-distribution/src/tests.rs +++ b/polkadot/node/network/approval-distribution/src/tests.rs @@ -2404,7 +2404,7 @@ fn propagates_locally_generated_assignment_to_both_dimensions() { let assignments = vec![(cert.clone(), candidate_index)]; let approvals = vec![approval.clone()]; - let assignment_sent_peers = assert_matches!( + let mut assignment_sent_peers = assert_matches!( overseer_recv(overseer).await, AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage( sent_peers, @@ -2428,12 +2428,14 @@ fn propagates_locally_generated_assignment_to_both_dimensions() { assert_matches!( overseer_recv(overseer).await, AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage( - sent_peers, + mut sent_peers, Versioned::V1(protocol_v1::ValidationProtocol::ApprovalDistribution( protocol_v1::ApprovalDistributionMessage::Approvals(sent_approvals) )) )) => { // Random sampling is reused from the assignment. + sent_peers.sort(); + assignment_sent_peers.sort(); assert_eq!(sent_peers, assignment_sent_peers); assert_eq!(sent_approvals, approvals); } @@ -2678,7 +2680,7 @@ fn propagates_to_required_after_connect() { let assignments = vec![(cert.clone(), candidate_index)]; let approvals = vec![approval.clone()]; - let assignment_sent_peers = assert_matches!( + let mut assignment_sent_peers = assert_matches!( overseer_recv(overseer).await, AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage( sent_peers, @@ -2702,12 +2704,14 @@ fn propagates_to_required_after_connect() { assert_matches!( overseer_recv(overseer).await, AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage( - sent_peers, + mut sent_peers, Versioned::V1(protocol_v1::ValidationProtocol::ApprovalDistribution( protocol_v1::ApprovalDistributionMessage::Approvals(sent_approvals) )) )) => { // Random sampling is reused from the assignment. + sent_peers.sort(); + assignment_sent_peers.sort(); assert_eq!(sent_peers, assignment_sent_peers); assert_eq!(sent_approvals, approvals); } diff --git a/polkadot/node/network/protocol/src/grid_topology.rs b/polkadot/node/network/protocol/src/grid_topology.rs index a14d24610722b..4dd7d29fc25cd 100644 --- a/polkadot/node/network/protocol/src/grid_topology.rs +++ b/polkadot/node/network/protocol/src/grid_topology.rs @@ -313,6 +313,23 @@ impl SessionGridTopologyEntry { self.topology.is_validator(peer) } + /// Returns the list of peers to route based on the required routing. + pub fn peers_to_route(&self, required_routing: RequiredRouting) -> Vec { + match required_routing { + RequiredRouting::All => self.topology.peer_ids.iter().copied().collect(), + RequiredRouting::GridX => self.local_neighbors.peers_x.iter().copied().collect(), + RequiredRouting::GridY => self.local_neighbors.peers_y.iter().copied().collect(), + RequiredRouting::GridXY => self + .local_neighbors + .peers_x + .iter() + .chain(self.local_neighbors.peers_y.iter()) + .copied() + .collect(), + RequiredRouting::None | RequiredRouting::PendingTopology => Vec::new(), + } + } + /// Updates the known peer ids for the passed authorities ids. pub fn update_authority_ids( &mut self, @@ -524,6 +541,11 @@ impl RandomRouting { pub fn inc_sent(&mut self) { self.sent += 1 } + + /// Returns `true` if we already took all the necessary samples. + pub fn is_complete(&self) -> bool { + self.sent >= self.target + } } /// Routing mode diff --git a/prdoc/pr_4848.prdoc b/prdoc/pr_4848.prdoc new file mode 100644 index 0000000000000..cbc0c8322d772 --- /dev/null +++ b/prdoc/pr_4848.prdoc @@ -0,0 +1,14 @@ +title: Optimize logic for gossiping assignments + +doc: + - audience: Node Dev + description: | + Optimize the logic for gossiping assignments by obtaining the list of peer ids + from the topology instead of iterating through all connected validators, this + gives us a 15% to 20% reduction in cpu usage. + +crates: +- name: polkadot-approval-distribution + bump: minor +- name: polkadot-node-network-protocol + bump: minor \ No newline at end of file From eac2a22a4801e1539a97a7fd5bf5fd3916a4339b Mon Sep 17 00:00:00 2001 From: Sebastian Miasojed Date: Tue, 16 Jul 2024 13:15:53 +0200 Subject: [PATCH 09/13] [pallet_contracts] Add support for transient storage in contracts host functions (#4566) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce transient storage, which behaves identically to regular storage but is kept only in memory and discarded after every transaction. This functionality is similar to the `TSTORE` and `TLOAD` operations used in Ethereum. The following new host functions have been introduced: `get_transient_storage` `set_transient_storage` `take_transient_storage` `clear_transient_storage` `contains_transient_storage` Note: These functions are declared as `unstable` and thus are not activated. --------- Co-authored-by: command-bot <> Co-authored-by: PG Herveou Co-authored-by: Alexander TheiƟen --- .../contracts-rococo/src/contracts.rs | 1 + prdoc/pr_4566.prdoc | 23 + substrate/bin/node/runtime/src/lib.rs | 1 + .../create_transient_storage_and_call.rs | 56 ++ .../contracts/set_transient_storage.rs | 42 + .../fixtures/contracts/transient_storage.rs | 58 ++ .../src/benchmarking/call_builder.rs | 46 +- .../frame/contracts/src/benchmarking/mod.rs | 291 ++++++ substrate/frame/contracts/src/exec.rs | 319 ++++++ substrate/frame/contracts/src/lib.rs | 24 +- substrate/frame/contracts/src/storage.rs | 2 +- substrate/frame/contracts/src/tests.rs | 64 ++ .../frame/contracts/src/transient_storage.rs | 698 +++++++++++++ substrate/frame/contracts/src/wasm/mod.rs | 353 +++++++ substrate/frame/contracts/src/wasm/runtime.rs | 226 ++++- substrate/frame/contracts/src/weights.rs | 950 +++++++++++------- substrate/frame/contracts/uapi/src/host.rs | 84 +- .../frame/contracts/uapi/src/host/riscv32.rs | 20 + .../frame/contracts/uapi/src/host/wasm32.rs | 81 ++ 19 files changed, 2943 insertions(+), 396 deletions(-) create mode 100644 prdoc/pr_4566.prdoc create mode 100644 substrate/frame/contracts/fixtures/contracts/create_transient_storage_and_call.rs create mode 100644 substrate/frame/contracts/fixtures/contracts/set_transient_storage.rs create mode 100644 substrate/frame/contracts/fixtures/contracts/transient_storage.rs create mode 100644 substrate/frame/contracts/src/transient_storage.rs diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/contracts.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/contracts.rs index fcd786711bbe9..e8cc9d02fb0e4 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/contracts.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/contracts.rs @@ -65,6 +65,7 @@ impl Config for Runtime { type AddressGenerator = DefaultAddressGenerator; type MaxCodeLen = ConstU32<{ 123 * 1024 }>; type MaxStorageKeyLen = ConstU32<128>; + type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>; type UnsafeUnstableInterface = ConstBool; type UploadOrigin = EnsureSigned; type InstantiateOrigin = EnsureSigned; diff --git a/prdoc/pr_4566.prdoc b/prdoc/pr_4566.prdoc new file mode 100644 index 0000000000000..ea2979bb363aa --- /dev/null +++ b/prdoc/pr_4566.prdoc @@ -0,0 +1,23 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "[pallet_contracts] Add support for transient storage in contracts host functions" + +doc: + - audience: Runtime User + description: | + This PR implements transient storage, which behaves identically to regular storage + but is kept only in memory and discarded after every transaction. + This functionality is similar to the `TSTORE` and `TLOAD` operations used in Ethereum. + The following new host functions have been introduced: `get_transient_storage`, + `set_transient_storage`, `take_transient_storage`, `clear_transient_storage` and + `contains_transient_storage`. + These functions are declared as unstable and thus are not activated. + +crates: + - name: pallet-contracts + bump: major + - name: pallet-contracts-uapi + bump: major + - name: contracts-rococo-runtime + bump: minor diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 2d1f52066f8f3..a1896325ee936 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -1373,6 +1373,7 @@ impl pallet_contracts::Config for Runtime { type UploadOrigin = EnsureSigned; type InstantiateOrigin = EnsureSigned; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; + type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>; type RuntimeHoldReason = RuntimeHoldReason; #[cfg(not(feature = "runtime-benchmarks"))] type Migrations = (); diff --git a/substrate/frame/contracts/fixtures/contracts/create_transient_storage_and_call.rs b/substrate/frame/contracts/fixtures/contracts/create_transient_storage_and_call.rs new file mode 100644 index 0000000000000..6bafee5557715 --- /dev/null +++ b/substrate/frame/contracts/fixtures/contracts/create_transient_storage_and_call.rs @@ -0,0 +1,56 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! This calls another contract as passed as its account id. It also creates some transient storage. +#![no_std] +#![no_main] + +use common::input; +use uapi::{HostFn, HostFnImpl as api}; + +#[no_mangle] +#[polkavm_derive::polkavm_export] +pub extern "C" fn deploy() {} + +#[no_mangle] +#[polkavm_derive::polkavm_export] +pub extern "C" fn call() { + input!( + buffer, + len: u32, + input: [u8; 4], + callee: [u8; 32], + ); + + let data = [0u8; 16 * 1024]; + let value = &data[..len as usize]; + #[allow(deprecated)] + api::set_transient_storage(buffer, value); + + // Call the callee + api::call_v2( + uapi::CallFlags::empty(), + callee, + 0u64, // How much ref_time weight to devote for the execution. 0 = all. + 0u64, // How much proof_size weight to devote for the execution. 0 = all. + None, + &0u64.to_le_bytes(), // Value transferred to the contract. + input, + None, + ) + .unwrap(); +} diff --git a/substrate/frame/contracts/fixtures/contracts/set_transient_storage.rs b/substrate/frame/contracts/fixtures/contracts/set_transient_storage.rs new file mode 100644 index 0000000000000..e4fde08314ce8 --- /dev/null +++ b/substrate/frame/contracts/fixtures/contracts/set_transient_storage.rs @@ -0,0 +1,42 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#![no_std] +#![no_main] + +use common::input; +use uapi::{HostFn, HostFnImpl as api}; + +#[no_mangle] +#[polkavm_derive::polkavm_export] +pub extern "C" fn deploy() {} + +#[no_mangle] +#[polkavm_derive::polkavm_export] +pub extern "C" fn call() { + input!(len: u32, ); + + let buffer = [0u8; 16 * 1024]; + let data = &buffer[..len as usize]; + + // Place a garbage value in the transient storage, with the size specified by the call input. + let mut key = [0u8; 32]; + key[0] = 1; + + #[allow(deprecated)] + api::set_transient_storage(&key, data); +} diff --git a/substrate/frame/contracts/fixtures/contracts/transient_storage.rs b/substrate/frame/contracts/fixtures/contracts/transient_storage.rs new file mode 100644 index 0000000000000..c797e17887bc8 --- /dev/null +++ b/substrate/frame/contracts/fixtures/contracts/transient_storage.rs @@ -0,0 +1,58 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! This contract tests the transient storage APIs. +#![no_std] +#![no_main] + +use common::unwrap_output; +use uapi::{HostFn, HostFnImpl as api}; + +#[no_mangle] +#[polkavm_derive::polkavm_export] +pub extern "C" fn deploy() {} + +#[no_mangle] +#[polkavm_derive::polkavm_export] +pub extern "C" fn call() { + const KEY: [u8; 32] = [1u8; 32]; + const VALUE_1: [u8; 4] = [1u8; 4]; + const VALUE_2: [u8; 4] = [2u8; 4]; + const VALUE_3: [u8; 4] = [3u8; 4]; + + #[allow(deprecated)] + { + let existing = api::set_transient_storage(&KEY, &VALUE_1); + assert_eq!(existing, None); + assert_eq!(api::contains_transient_storage(&KEY), Some(VALUE_1.len() as _)); + unwrap_output!(val, [0u8; 4], api::get_transient_storage, &KEY); + assert_eq!(**val, VALUE_1); + + let existing = api::set_transient_storage(&KEY, &VALUE_2); + assert_eq!(existing, Some(VALUE_1.len() as _)); + unwrap_output!(val, [0u8; 4], api::get_transient_storage, &KEY); + assert_eq!(**val, VALUE_2); + + api::clear_transient_storage(&KEY); + assert_eq!(api::contains_transient_storage(&KEY), None); + + let existing = api::set_transient_storage(&KEY, &VALUE_3); + assert_eq!(existing, None); + unwrap_output!(val, [0u8; 32], api::take_transient_storage, &KEY); + assert_eq!(**val, VALUE_3); + } +} diff --git a/substrate/frame/contracts/src/benchmarking/call_builder.rs b/substrate/frame/contracts/src/benchmarking/call_builder.rs index d87eaba734376..5833639d7ce25 100644 --- a/substrate/frame/contracts/src/benchmarking/call_builder.rs +++ b/substrate/frame/contracts/src/benchmarking/call_builder.rs @@ -17,11 +17,12 @@ use crate::{ benchmarking::{Contract, WasmModule}, - exec::Stack, + exec::{Ext, Key, Stack}, storage::meter::Meter, + transient_storage::MeterEntry, wasm::Runtime, - BalanceOf, Config, DebugBufferVec, Determinism, ExecReturnValue, GasMeter, Origin, Schedule, - TypeInfo, WasmBlob, Weight, + BalanceOf, Config, DebugBufferVec, Determinism, Error, ExecReturnValue, GasMeter, Origin, + Schedule, TypeInfo, WasmBlob, Weight, }; use alloc::{vec, vec::Vec}; use codec::{Encode, HasCompact}; @@ -56,6 +57,7 @@ pub struct CallSetup { debug_message: Option>, determinism: Determinism, data: Vec, + transient_storage_size: u32, } impl Default for CallSetup @@ -103,6 +105,7 @@ where debug_message: None, determinism: Determinism::Enforced, data: vec![], + transient_storage_size: 0, } } @@ -126,6 +129,11 @@ where self.data = value; } + /// Set the transient storage size. + pub fn set_transient_storage_size(&mut self, size: u32) { + self.transient_storage_size = size; + } + /// Set the debug message. pub fn enable_debug_message(&mut self) { self.debug_message = Some(Default::default()); @@ -148,7 +156,7 @@ where /// Build the call stack. pub fn ext(&mut self) -> (StackExt<'_, T>, WasmBlob) { - StackExt::bench_new_call( + let mut ext = StackExt::bench_new_call( self.dest.clone(), self.origin.clone(), &mut self.gas_meter, @@ -157,7 +165,11 @@ where self.value, self.debug_message.as_mut(), self.determinism, - ) + ); + if self.transient_storage_size > 0 { + Self::with_transient_storage(&mut ext.0, self.transient_storage_size).unwrap(); + } + ext } /// Prepare a call to the module. @@ -169,6 +181,30 @@ where let (func, store) = module.bench_prepare_call(ext, input); PreparedCall { func, store } } + + /// Add transient_storage + fn with_transient_storage(ext: &mut StackExt, size: u32) -> Result<(), &'static str> { + let &MeterEntry { amount, limit } = ext.transient_storage().meter().current(); + ext.transient_storage().meter().current_mut().limit = size; + for i in 1u32.. { + let mut key_data = i.to_le_bytes().to_vec(); + while key_data.last() == Some(&0) { + key_data.pop(); + } + let key = Key::::try_from_var(key_data).unwrap(); + if let Err(e) = ext.set_transient_storage(&key, Some(Vec::new()), false) { + // Restore previous settings. + ext.transient_storage().meter().current_mut().limit = limit; + ext.transient_storage().meter().current_mut().amount = amount; + if e == Error::::OutOfTransientStorage.into() { + break; + } else { + return Err("Initialization of the transient storage failed"); + } + } + } + Ok(()) + } } #[macro_export] diff --git a/substrate/frame/contracts/src/benchmarking/mod.rs b/substrate/frame/contracts/src/benchmarking/mod.rs index 612f929e8b196..620e6544b08f9 100644 --- a/substrate/frame/contracts/src/benchmarking/mod.rs +++ b/substrate/frame/contracts/src/benchmarking/mod.rs @@ -31,6 +31,7 @@ use crate::{ migration::{ codegen::LATEST_MIGRATION_VERSION, v09, v10, v11, v12, v13, v14, v15, v16, MigrationStep, }, + storage::WriteOutcome, wasm::BenchEnv, Pallet as Contracts, *, }; @@ -1162,6 +1163,296 @@ mod benchmarks { Ok(()) } + // We use both full and empty benchmarks here instead of benchmarking transient_storage + // (BTreeMap) directly. This approach is necessary because benchmarking this BTreeMap is very + // slow. Additionally, we use linear regression for our benchmarks, and the BTreeMap's log(n) + // complexity can introduce approximation errors. + #[benchmark(pov_mode = Ignored)] + fn set_transient_storage_empty() -> Result<(), BenchmarkError> { + let max_value_len = T::Schedule::get().limits.payload_len; + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + let value = Some(vec![42u8; max_value_len as _]); + let mut setup = CallSetup::::default(); + let (mut ext, _) = setup.ext(); + let mut runtime = crate::wasm::Runtime::new(&mut ext, vec![]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + let result; + #[block] + { + result = runtime.ext().set_transient_storage(&key, value, false); + } + + assert_eq!(result, Ok(WriteOutcome::New)); + assert_eq!(runtime.ext().get_transient_storage(&key), Some(vec![42u8; max_value_len as _])); + Ok(()) + } + + #[benchmark(pov_mode = Ignored)] + fn set_transient_storage_full() -> Result<(), BenchmarkError> { + let max_value_len = T::Schedule::get().limits.payload_len; + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + let value = Some(vec![42u8; max_value_len as _]); + let mut setup = CallSetup::::default(); + setup.set_transient_storage_size(T::MaxTransientStorageSize::get()); + let (mut ext, _) = setup.ext(); + let mut runtime = crate::wasm::Runtime::new(&mut ext, vec![]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + let result; + #[block] + { + result = runtime.ext().set_transient_storage(&key, value, false); + } + + assert_eq!(result, Ok(WriteOutcome::New)); + assert_eq!(runtime.ext().get_transient_storage(&key), Some(vec![42u8; max_value_len as _])); + Ok(()) + } + + #[benchmark(pov_mode = Ignored)] + fn get_transient_storage_empty() -> Result<(), BenchmarkError> { + let max_value_len = T::Schedule::get().limits.payload_len; + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + + let mut setup = CallSetup::::default(); + let (mut ext, _) = setup.ext(); + let mut runtime = crate::wasm::Runtime::new(&mut ext, vec![]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + runtime + .ext() + .set_transient_storage(&key, Some(vec![42u8; max_value_len as _]), false) + .map_err(|_| "Failed to write to transient storage during setup.")?; + let result; + #[block] + { + result = runtime.ext().get_transient_storage(&key); + } + + assert_eq!(result, Some(vec![42u8; max_value_len as _])); + Ok(()) + } + + #[benchmark(pov_mode = Ignored)] + fn get_transient_storage_full() -> Result<(), BenchmarkError> { + let max_value_len = T::Schedule::get().limits.payload_len; + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + + let mut setup = CallSetup::::default(); + setup.set_transient_storage_size(T::MaxTransientStorageSize::get()); + let (mut ext, _) = setup.ext(); + let mut runtime = crate::wasm::Runtime::new(&mut ext, vec![]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + runtime + .ext() + .set_transient_storage(&key, Some(vec![42u8; max_value_len as _]), false) + .map_err(|_| "Failed to write to transient storage during setup.")?; + let result; + #[block] + { + result = runtime.ext().get_transient_storage(&key); + } + + assert_eq!(result, Some(vec![42u8; max_value_len as _])); + Ok(()) + } + + // The weight of journal rollbacks should be taken into account when setting storage. + #[benchmark(pov_mode = Ignored)] + fn rollback_transient_storage() -> Result<(), BenchmarkError> { + let max_value_len = T::Schedule::get().limits.payload_len; + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + + let mut setup = CallSetup::::default(); + setup.set_transient_storage_size(T::MaxTransientStorageSize::get()); + let (mut ext, _) = setup.ext(); + let mut runtime = crate::wasm::Runtime::new(&mut ext, vec![]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + runtime.ext().transient_storage().start_transaction(); + runtime + .ext() + .set_transient_storage(&key, Some(vec![42u8; max_value_len as _]), false) + .map_err(|_| "Failed to write to transient storage during setup.")?; + #[block] + { + runtime.ext().transient_storage().rollback_transaction(); + } + + assert_eq!(runtime.ext().get_transient_storage(&key), None); + Ok(()) + } + + // n: new byte size + // o: old byte size + #[benchmark(pov_mode = Measured)] + fn seal_set_transient_storage( + n: Linear<0, { T::Schedule::get().limits.payload_len }>, + o: Linear<0, { T::Schedule::get().limits.payload_len }>, + ) -> Result<(), BenchmarkError> { + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + let value = vec![1u8; n as usize]; + build_runtime!(runtime, memory: [ key.to_vec(), value.clone(), ]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + runtime + .ext() + .set_transient_storage(&key, Some(vec![42u8; o as usize]), false) + .map_err(|_| "Failed to write to transient storage during setup.")?; + + let result; + #[block] + { + result = BenchEnv::seal0_set_transient_storage( + &mut runtime, + &mut memory, + 0, // key_ptr + max_key_len, // key_len + max_key_len, // value_ptr + n, // value_len + ); + } + + assert_ok!(result); + assert_eq!(runtime.ext().get_transient_storage(&key).unwrap(), value); + Ok(()) + } + + #[benchmark(pov_mode = Measured)] + fn seal_clear_transient_storage( + n: Linear<0, { T::Schedule::get().limits.payload_len }>, + ) -> Result<(), BenchmarkError> { + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + build_runtime!(runtime, memory: [ key.to_vec(), ]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + runtime + .ext() + .set_transient_storage(&key, Some(vec![42u8; n as usize]), false) + .map_err(|_| "Failed to write to transient storage during setup.")?; + + let result; + #[block] + { + result = + BenchEnv::seal0_clear_transient_storage(&mut runtime, &mut memory, 0, max_key_len); + } + + assert_ok!(result); + assert!(runtime.ext().get_transient_storage(&key).is_none()); + Ok(()) + } + + #[benchmark(pov_mode = Measured)] + fn seal_get_transient_storage( + n: Linear<0, { T::Schedule::get().limits.payload_len }>, + ) -> Result<(), BenchmarkError> { + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + build_runtime!(runtime, memory: [ key.to_vec(), n.to_le_bytes(), vec![0u8; n as _], ]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + runtime + .ext() + .set_transient_storage(&key, Some(vec![42u8; n as usize]), false) + .map_err(|_| "Failed to write to transient storage during setup.")?; + + let out_ptr = max_key_len + 4; + let result; + #[block] + { + result = BenchEnv::seal0_get_transient_storage( + &mut runtime, + &mut memory, + 0, // key_ptr + max_key_len, // key_len + out_ptr, // out_ptr + max_key_len, // out_len_ptr + ); + } + + assert_ok!(result); + assert_eq!( + &runtime.ext().get_transient_storage(&key).unwrap(), + &memory[out_ptr as usize..] + ); + Ok(()) + } + + #[benchmark(pov_mode = Measured)] + fn seal_contains_transient_storage( + n: Linear<0, { T::Schedule::get().limits.payload_len }>, + ) -> Result<(), BenchmarkError> { + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + build_runtime!(runtime, memory: [ key.to_vec(), ]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + runtime + .ext() + .set_transient_storage(&key, Some(vec![42u8; n as usize]), false) + .map_err(|_| "Failed to write to transient storage during setup.")?; + + let result; + #[block] + { + result = BenchEnv::seal0_contains_transient_storage( + &mut runtime, + &mut memory, + 0, + max_key_len, + ); + } + + assert_eq!(result.unwrap(), n); + Ok(()) + } + + #[benchmark(pov_mode = Measured)] + fn seal_take_transient_storage( + n: Linear<0, { T::Schedule::get().limits.payload_len }>, + ) -> Result<(), BenchmarkError> { + let n = T::Schedule::get().limits.payload_len; + let max_key_len = T::MaxStorageKeyLen::get(); + let key = Key::::try_from_var(vec![0u8; max_key_len as usize]) + .map_err(|_| "Key has wrong length")?; + build_runtime!(runtime, memory: [ key.to_vec(), n.to_le_bytes(), vec![0u8; n as _], ]); + runtime.ext().transient_storage().meter().current_mut().limit = u32::MAX; + let value = vec![42u8; n as usize]; + runtime + .ext() + .set_transient_storage(&key, Some(value.clone()), false) + .map_err(|_| "Failed to write to transient storage during setup.")?; + + let out_ptr = max_key_len + 4; + let result; + #[block] + { + result = BenchEnv::seal0_take_transient_storage( + &mut runtime, + &mut memory, + 0, // key_ptr + max_key_len, // key_len + out_ptr, // out_ptr + max_key_len, // out_len_ptr + ); + } + + assert_ok!(result); + assert!(&runtime.ext().get_transient_storage(&key).is_none()); + assert_eq!(&value, &memory[out_ptr as usize..]); + Ok(()) + } + // We transfer to unique accounts. #[benchmark(pov_mode = Measured)] fn seal_transfer() { diff --git a/substrate/frame/contracts/src/exec.rs b/substrate/frame/contracts/src/exec.rs index 0cc4844166f35..31e0bf50b73e7 100644 --- a/substrate/frame/contracts/src/exec.rs +++ b/substrate/frame/contracts/src/exec.rs @@ -20,6 +20,7 @@ use crate::{ gas::GasMeter, primitives::{ExecReturnValue, StorageDeposit}, storage::{self, meter::Diff, WriteOutcome}, + transient_storage::TransientStorage, BalanceOf, CodeHash, CodeInfo, CodeInfoOf, Config, ContractInfo, ContractInfoOf, DebugBufferVec, Determinism, Error, Event, Nonce, Origin, Pallet as Contracts, Schedule, LOG_TARGET, @@ -210,6 +211,27 @@ pub trait Ext: sealing::Sealed { take_old: bool, ) -> Result; + /// Returns the transient storage entry of the executing account for the given `key`. + /// + /// Returns `None` if the `key` wasn't previously set by `set_transient_storage` or + /// was deleted. + fn get_transient_storage(&self, key: &Key) -> Option>; + + /// Returns `Some(len)` (in bytes) if a transient storage item exists at `key`. + /// + /// Returns `None` if the `key` wasn't previously set by `set_transient_storage` or + /// was deleted. + fn get_transient_storage_size(&self, key: &Key) -> Option; + + /// Sets the transient storage entry for the given key to the specified value. If `value` is + /// `None` then the storage entry is deleted. + fn set_transient_storage( + &mut self, + key: &Key, + value: Option>, + take_old: bool, + ) -> Result; + /// Returns the caller. fn caller(&self) -> Origin; @@ -308,6 +330,12 @@ pub trait Ext: sealing::Sealed { #[cfg(any(test, feature = "runtime-benchmarks"))] fn contract_info(&mut self) -> &mut ContractInfo; + /// Get a mutable reference to the transient storage. + /// Useful in benchmarks when it is sometimes necessary to modify and inspect the transient + /// storage directly. + #[cfg(feature = "runtime-benchmarks")] + fn transient_storage(&mut self) -> &mut TransientStorage; + /// Sets new code hash for existing contract. fn set_code_hash(&mut self, hash: CodeHash) -> DispatchResult; @@ -474,6 +502,8 @@ pub struct Stack<'a, T: Config, E> { debug_message: Option<&'a mut DebugBufferVec>, /// The determinism requirement of this call stack. determinism: Determinism, + /// Transient storage used to store data, which is kept for the duration of a transaction. + transient_storage: TransientStorage, /// No executable is held by the struct but influences its behaviour. _phantom: PhantomData, } @@ -797,6 +827,7 @@ where frames: Default::default(), debug_message, determinism, + transient_storage: TransientStorage::new(T::MaxTransientStorageSize::get()), _phantom: Default::default(), }; @@ -927,6 +958,9 @@ where let entry_point = frame.entry_point; let delegated_code_hash = if frame.delegate_caller.is_some() { Some(*executable.code_hash()) } else { None }; + + self.transient_storage.start_transaction(); + let do_transaction = || { // We need to charge the storage deposit before the initial transfer so that // it can create the account in case the initial transfer is < ed. @@ -1047,6 +1081,12 @@ where Err(error) => (false, Err(error.into())), }; + if success { + self.transient_storage.commit_transaction(); + } else { + self.transient_storage.rollback_transaction(); + } + self.pop_frame(success); output } @@ -1375,6 +1415,24 @@ where ) } + fn get_transient_storage(&self, key: &Key) -> Option> { + self.transient_storage.read(self.address(), key) + } + + fn get_transient_storage_size(&self, key: &Key) -> Option { + self.transient_storage.read(self.address(), key).map(|value| value.len() as _) + } + + fn set_transient_storage( + &mut self, + key: &Key, + value: Option>, + take_old: bool, + ) -> Result { + let account_id = self.address().clone(); + self.transient_storage.write(&account_id, key, value, take_old) + } + fn address(&self) -> &T::AccountId { &self.top_frame().account_id } @@ -1519,6 +1577,11 @@ where self.top_frame_mut().contract_info() } + #[cfg(feature = "runtime-benchmarks")] + fn transient_storage(&mut self) -> &mut TransientStorage { + &mut self.transient_storage + } + fn set_code_hash(&mut self, hash: CodeHash) -> DispatchResult { let frame = top_frame_mut!(self); if !E::from_storage(hash, &mut frame.nested_gas)?.is_deterministic() { @@ -3827,6 +3890,262 @@ mod tests { }); } + #[test] + fn set_transient_storage_works() { + let code_hash = MockLoader::insert(Call, |ctx, _| { + // Write + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([1; 32]), Some(vec![1, 2, 3]), false), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([2; 32]), Some(vec![4, 5, 6]), true), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([3; 32]), None, false), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([4; 32]), None, true), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([5; 32]), Some(vec![]), false), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([6; 32]), Some(vec![]), true), + Ok(WriteOutcome::New) + ); + + // Overwrite + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([1; 32]), Some(vec![42]), false), + Ok(WriteOutcome::Overwritten(3)) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([2; 32]), Some(vec![48]), true), + Ok(WriteOutcome::Taken(vec![4, 5, 6])) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([3; 32]), None, false), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([4; 32]), None, true), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([5; 32]), Some(vec![]), false), + Ok(WriteOutcome::Overwritten(0)) + ); + assert_eq!( + ctx.ext.set_transient_storage(&Key::Fix([6; 32]), Some(vec![]), true), + Ok(WriteOutcome::Taken(vec![])) + ); + + exec_success() + }); + + ExtBuilder::default().build().execute_with(|| { + let schedule = ::Schedule::get(); + place_contract(&BOB, code_hash); + let contract_origin = Origin::from_account_id(ALICE); + let mut storage_meter = storage::meter::Meter::new(&contract_origin, None, 0).unwrap(); + assert_ok!(MockStack::run_call( + contract_origin, + BOB, + &mut GasMeter::::new(GAS_LIMIT), + &mut storage_meter, + &schedule, + 0, + vec![], + None, + Determinism::Enforced + )); + }); + } + + #[test] + fn get_transient_storage_works() { + // Call stack: BOB -> CHARLIE(success) -> BOB' (success) + let storage_key_1 = &Key::Fix([1; 32]); + let storage_key_2 = &Key::Fix([2; 32]); + let storage_key_3 = &Key::Fix([3; 32]); + let code_bob = MockLoader::insert(Call, |ctx, _| { + if ctx.input_data[0] == 0 { + assert_eq!( + ctx.ext.set_transient_storage(storage_key_1, Some(vec![1, 2]), false), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.call( + Weight::zero(), + BalanceOf::::zero(), + CHARLIE, + 0, + vec![], + true, + false, + ), + exec_success() + ); + assert_eq!(ctx.ext.get_transient_storage(storage_key_1), Some(vec![3])); + assert_eq!(ctx.ext.get_transient_storage(storage_key_2), Some(vec![])); + assert_eq!(ctx.ext.get_transient_storage(storage_key_3), None); + } else { + assert_eq!( + ctx.ext.set_transient_storage(storage_key_1, Some(vec![3]), true), + Ok(WriteOutcome::Taken(vec![1, 2])) + ); + assert_eq!( + ctx.ext.set_transient_storage(storage_key_2, Some(vec![]), false), + Ok(WriteOutcome::New) + ); + } + exec_success() + }); + let code_charlie = MockLoader::insert(Call, |ctx, _| { + assert!(ctx + .ext + .call(Weight::zero(), BalanceOf::::zero(), BOB, 0, vec![99], true, false) + .is_ok()); + // CHARLIE can not read BOB`s storage. + assert_eq!(ctx.ext.get_transient_storage(storage_key_1), None); + exec_success() + }); + + // This one tests passing the input data into a contract via call. + ExtBuilder::default().build().execute_with(|| { + let schedule = ::Schedule::get(); + place_contract(&BOB, code_bob); + place_contract(&CHARLIE, code_charlie); + let contract_origin = Origin::from_account_id(ALICE); + let mut storage_meter = + storage::meter::Meter::new(&contract_origin, Some(0), 0).unwrap(); + + let result = MockStack::run_call( + contract_origin, + BOB, + &mut GasMeter::::new(GAS_LIMIT), + &mut storage_meter, + &schedule, + 0, + vec![0], + None, + Determinism::Enforced, + ); + assert_matches!(result, Ok(_)); + }); + } + + #[test] + fn get_transient_storage_size_works() { + let storage_key_1 = &Key::Fix([1; 32]); + let storage_key_2 = &Key::Fix([2; 32]); + let storage_key_3 = &Key::Fix([3; 32]); + let code_hash = MockLoader::insert(Call, |ctx, _| { + assert_eq!( + ctx.ext.set_transient_storage(storage_key_1, Some(vec![1, 2, 3]), false), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.set_transient_storage(storage_key_2, Some(vec![]), false), + Ok(WriteOutcome::New) + ); + assert_eq!(ctx.ext.get_transient_storage_size(storage_key_1), Some(3)); + assert_eq!(ctx.ext.get_transient_storage_size(storage_key_2), Some(0)); + assert_eq!(ctx.ext.get_transient_storage_size(storage_key_3), None); + + exec_success() + }); + + ExtBuilder::default().build().execute_with(|| { + let schedule = ::Schedule::get(); + place_contract(&BOB, code_hash); + let contract_origin = Origin::from_account_id(ALICE); + let mut storage_meter = + storage::meter::Meter::new(&contract_origin, Some(0), 0).unwrap(); + assert_ok!(MockStack::run_call( + contract_origin, + BOB, + &mut GasMeter::::new(GAS_LIMIT), + &mut storage_meter, + &schedule, + 0, + vec![], + None, + Determinism::Enforced + )); + }); + } + + #[test] + fn rollback_transient_storage_works() { + // Call stack: BOB -> CHARLIE (trap) -> BOB' (success) + let storage_key = &Key::Fix([1; 32]); + let code_bob = MockLoader::insert(Call, |ctx, _| { + if ctx.input_data[0] == 0 { + assert_eq!( + ctx.ext.set_transient_storage(storage_key, Some(vec![1, 2]), false), + Ok(WriteOutcome::New) + ); + assert_eq!( + ctx.ext.call( + Weight::zero(), + BalanceOf::::zero(), + CHARLIE, + 0, + vec![], + true, + false + ), + exec_trapped() + ); + assert_eq!(ctx.ext.get_transient_storage(storage_key), Some(vec![1, 2])); + } else { + let overwritten_length = ctx.ext.get_transient_storage_size(storage_key).unwrap(); + assert_eq!( + ctx.ext.set_transient_storage(storage_key, Some(vec![3]), false), + Ok(WriteOutcome::Overwritten(overwritten_length)) + ); + assert_eq!(ctx.ext.get_transient_storage(storage_key), Some(vec![3])); + } + exec_success() + }); + let code_charlie = MockLoader::insert(Call, |ctx, _| { + assert!(ctx + .ext + .call(Weight::zero(), BalanceOf::::zero(), BOB, 0, vec![99], true, false) + .is_ok()); + exec_trapped() + }); + + // This one tests passing the input data into a contract via call. + ExtBuilder::default().build().execute_with(|| { + let schedule = ::Schedule::get(); + place_contract(&BOB, code_bob); + place_contract(&CHARLIE, code_charlie); + let contract_origin = Origin::from_account_id(ALICE); + let mut storage_meter = + storage::meter::Meter::new(&contract_origin, Some(0), 0).unwrap(); + + let result = MockStack::run_call( + contract_origin, + BOB, + &mut GasMeter::::new(GAS_LIMIT), + &mut storage_meter, + &schedule, + 0, + vec![0], + None, + Determinism::Enforced, + ); + assert_matches!(result, Ok(_)); + }); + } + #[test] fn ecdsa_to_eth_address_returns_proper_value() { let bob_ch = MockLoader::insert(Call, |ctx, _| { diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index ed00fdca62ff2..093adc07ab48b 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -97,6 +97,7 @@ pub use primitives::*; mod schedule; mod storage; +mod transient_storage; mod wasm; pub mod chain_extension; @@ -388,6 +389,11 @@ pub mod pallet { #[pallet::constant] type MaxStorageKeyLen: Get; + /// The maximum size of the transient storage in bytes. + /// This includes keys, values, and previous entries used for storage rollback. + #[pallet::constant] + type MaxTransientStorageSize: Get; + /// The maximum number of delegate_dependencies that a contract can lock with /// [`chain_extension::Ext::lock_delegate_dependency`]. #[pallet::constant] @@ -554,6 +560,7 @@ pub mod pallet { type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; type MaxDelegateDependencies = MaxDelegateDependencies; type MaxStorageKeyLen = ConstU32<128>; + type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>; type Migrations = (); type Time = Self; type Randomness = Self; @@ -605,7 +612,11 @@ pub mod pallet { // Max call depth is CallStack::size() + 1 let max_call_depth = u32::try_from(T::CallStack::size().saturating_add(1)) .expect("CallStack size is too big"); - + // Transient storage uses a BTreeMap, which has overhead compared to the raw size of + // key-value data. To ensure safety, a margin of 2x the raw key-value size is used. + let max_transient_storage_size = T::MaxTransientStorageSize::get() + .checked_mul(2) + .expect("MaxTransientStorageSize is too large"); // Check that given configured `MaxCodeLen`, runtime heap memory limit can't be broken. // // In worst case, the decoded Wasm contract code would be `x16` times larger than the @@ -615,7 +626,7 @@ pub mod pallet { // Next, the pallet keeps the Wasm blob for each // contract, hence we add up `MaxCodeLen` to the safety margin. // - // Finally, the inefficiencies of the freeing-bump allocator + // The inefficiencies of the freeing-bump allocator // being used in the client for the runtime memory allocations, could lead to possible // memory allocations for contract code grow up to `x4` times in some extreme cases, // which gives us total multiplier of `17*4` for `MaxCodeLen`. @@ -624,17 +635,20 @@ pub mod pallet { // memory should be available. Note that maximum allowed heap memory and stack size per // each contract (stack frame) should also be counted. // + // The pallet holds transient storage with a size up to `max_transient_storage_size`. + // // Finally, we allow 50% of the runtime memory to be utilized by the contracts call // stack, keeping the rest for other facilities, such as PoV, etc. // // This gives us the following formula: // - // `(MaxCodeLen * 17 * 4 + MAX_STACK_SIZE + max_heap_size) * max_call_depth < - // max_runtime_mem/2` + // `(MaxCodeLen * 17 * 4 + MAX_STACK_SIZE + max_heap_size) * max_call_depth + + // max_transient_storage_size < max_runtime_mem/2` // // Hence the upper limit for the `MaxCodeLen` can be defined as follows: let code_len_limit = max_runtime_mem .saturating_div(2) + .saturating_sub(max_transient_storage_size) .saturating_div(max_call_depth) .saturating_sub(max_heap_size) .saturating_sub(MAX_STACK_SIZE) @@ -1235,6 +1249,8 @@ pub mod pallet { DelegateDependencyAlreadyExists, /// Can not add a delegate dependency to the code hash of the contract itself. CannotAddSelfAsDelegateDependency, + /// Can not add more data to transient storage. + OutOfTransientStorage, } /// A reason for the pallet contracts placing a hold on funds. diff --git a/substrate/frame/contracts/src/storage.rs b/substrate/frame/contracts/src/storage.rs index 23b5a2514eb14..65e7129cdf845 100644 --- a/substrate/frame/contracts/src/storage.rs +++ b/substrate/frame/contracts/src/storage.rs @@ -335,7 +335,7 @@ impl ContractInfo { } /// Information about what happened to the pre-existing value when calling [`ContractInfo::write`]. -#[cfg_attr(test, derive(Debug, PartialEq))] +#[cfg_attr(any(test, feature = "runtime-benchmarks"), derive(Debug, PartialEq))] pub enum WriteOutcome { /// No value existed at the specified key. New, diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index 3f608d90bea7e..cc2a69b5c4196 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -411,6 +411,7 @@ parameter_types! { pub static DepositPerByte: BalanceOf = 1; pub const DepositPerItem: BalanceOf = 2; pub static MaxDelegateDependencies: u32 = 32; + pub static MaxTransientStorageSize: u32 = 4 * 1024; pub static CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0); // We need this one set high enough for running benchmarks. @@ -504,6 +505,7 @@ impl Config for Test { type Migrations = crate::migration::codegen::BenchMigrations; type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; type MaxDelegateDependencies = MaxDelegateDependencies; + type MaxTransientStorageSize = MaxTransientStorageSize; type Debug = TestDebug; } @@ -962,6 +964,68 @@ fn storage_max_value_limit() { }); } +#[test] +fn transient_storage_work() { + let (code, _code_hash) = compile_module::("transient_storage").unwrap(); + + ExtBuilder::default().build().execute_with(|| { + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = Contracts::min_balance(); + let addr = builder::bare_instantiate(Code::Upload(code)) + .value(min_balance * 100) + .build_and_unwrap_account_id(); + + builder::bare_call(addr).build_and_unwrap_result(); + }); +} + +#[test] +fn transient_storage_limit_in_call() { + let (wasm_caller, _code_hash_caller) = + compile_module::("create_transient_storage_and_call").unwrap(); + let (wasm_callee, _code_hash_callee) = compile_module::("set_transient_storage").unwrap(); + ExtBuilder::default().build().execute_with(|| { + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = Contracts::min_balance(); + + // Create both contracts: Constructors do nothing. + let addr_caller = builder::bare_instantiate(Code::Upload(wasm_caller)) + .value(min_balance * 100) + .build_and_unwrap_account_id(); + let addr_callee = builder::bare_instantiate(Code::Upload(wasm_callee)) + .value(min_balance * 100) + .build_and_unwrap_account_id(); + + let storage_value_size = 1000; + MaxTransientStorageSize::set(4 * 1024); + // Call contracts with storage values within the limit. + // Caller and Callee contracts each set a transient storage value of size 1000. + assert_ok!(builder::call(addr_caller.clone()) + .data((storage_value_size, storage_value_size, &addr_callee).encode()) + .build(),); + + MaxTransientStorageSize::set(512); + // Call a contract with a storage value that is too large. + // Limit exceeded in the caller contract. + assert_err_ignore_postinfo!( + builder::call(addr_caller.clone()) + .data((storage_value_size, storage_value_size, &addr_callee).encode()) + .build(), + >::OutOfTransientStorage, + ); + + MaxTransientStorageSize::set(1536); + // Call a contract with a storage value that is too large. + // Limit exceeded in the callee contract. + assert_err_ignore_postinfo!( + builder::call(addr_caller) + .data((storage_value_size, storage_value_size, &addr_callee).encode()) + .build(), + >::ContractTrapped + ); + }); +} + #[test] fn deploy_and_call_other_contract() { let (caller_wasm, _caller_code_hash) = compile_module::("caller_contract").unwrap(); diff --git a/substrate/frame/contracts/src/transient_storage.rs b/substrate/frame/contracts/src/transient_storage.rs new file mode 100644 index 0000000000000..c795a966385a9 --- /dev/null +++ b/substrate/frame/contracts/src/transient_storage.rs @@ -0,0 +1,698 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! This module contains routines for accessing and altering a contract transient storage. + +use crate::{ + exec::{AccountIdOf, Key}, + storage::WriteOutcome, + Config, Error, +}; +use codec::Encode; +use core::marker::PhantomData; +use frame_support::DefaultNoBound; +use sp_runtime::{DispatchError, DispatchResult, Saturating}; +use sp_std::{collections::btree_map::BTreeMap, mem, vec::Vec}; + +/// Meter entry tracks transaction allocations. +#[derive(Default, Debug)] +pub struct MeterEntry { + /// Allocations made in the current transaction. + pub amount: u32, + /// Allocations limit in the current transaction. + pub limit: u32, +} + +impl MeterEntry { + /// Create a new entry. + fn new(limit: u32) -> Self { + Self { limit, amount: Default::default() } + } + + /// Check if the allocated amount exceeds the limit. + fn exceeds_limit(&self, amount: u32) -> bool { + self.amount.saturating_add(amount) > self.limit + } + + /// Absorb the allocation amount of the nested entry into the current entry. + fn absorb(&mut self, rhs: Self) { + self.amount.saturating_accrue(rhs.amount) + } +} + +// The storage meter enforces a limit for each transaction, +// which is calculated as free_storage * (1 - 1/16) for each subsequent frame. +#[derive(DefaultNoBound)] +pub struct StorageMeter { + nested_meters: Vec, + root_meter: MeterEntry, + _phantom: PhantomData, +} + +impl StorageMeter { + const STORAGE_FRACTION_DENOMINATOR: u32 = 16; + /// Create a new storage allocation meter. + fn new(memory_limit: u32) -> Self { + Self { root_meter: MeterEntry::new(memory_limit), ..Default::default() } + } + + /// Charge the allocated amount of transaction storage from the meter. + fn charge(&mut self, amount: u32) -> DispatchResult { + let meter = self.current_mut(); + if meter.exceeds_limit(amount) { + return Err(Error::::OutOfTransientStorage.into()); + } + meter.amount.saturating_accrue(amount); + Ok(()) + } + + /// Revert a transaction meter. + fn revert(&mut self) { + self.nested_meters.pop().expect( + "A call to revert a meter must be preceded by a corresponding call to start a meter; + the code within this crate makes sure that this is always the case; qed", + ); + } + + /// Start a transaction meter. + fn start(&mut self) { + let meter = self.current(); + let mut transaction_limit = meter.limit.saturating_sub(meter.amount); + if !self.nested_meters.is_empty() { + // Allow use of (1 - 1/STORAGE_FRACTION_DENOMINATOR) of free storage for subsequent + // calls. + transaction_limit.saturating_reduce( + transaction_limit.saturating_div(Self::STORAGE_FRACTION_DENOMINATOR), + ); + } + + self.nested_meters.push(MeterEntry::new(transaction_limit)); + } + + /// Commit a transaction meter. + fn commit(&mut self) { + let transaction_meter = self.nested_meters.pop().expect( + "A call to commit a meter must be preceded by a corresponding call to start a meter; + the code within this crate makes sure that this is always the case; qed", + ); + self.current_mut().absorb(transaction_meter) + } + + /// The total allocated amount of memory. + #[cfg(test)] + fn total_amount(&self) -> u32 { + self.nested_meters + .iter() + .fold(self.root_meter.amount, |acc, e| acc.saturating_add(e.amount)) + } + + /// A mutable reference to the current meter entry. + pub fn current_mut(&mut self) -> &mut MeterEntry { + self.nested_meters.last_mut().unwrap_or(&mut self.root_meter) + } + + /// A reference to the current meter entry. + pub fn current(&self) -> &MeterEntry { + self.nested_meters.last().unwrap_or(&self.root_meter) + } +} + +/// An entry representing a journal change. +struct JournalEntry { + key: Vec, + prev_value: Option>, +} + +impl JournalEntry { + /// Create a new change. + fn new(key: Vec, prev_value: Option>) -> Self { + Self { key, prev_value } + } + + /// Revert the change. + fn revert(self, storage: &mut Storage) { + storage.write(&self.key, self.prev_value); + } +} + +/// A journal containing transient storage modifications. +struct Journal(Vec); + +impl Journal { + /// Create a new journal. + fn new() -> Self { + Self(Default::default()) + } + + /// Add a change to the journal. + fn push(&mut self, entry: JournalEntry) { + self.0.push(entry); + } + + /// Length of the journal. + fn len(&self) -> usize { + self.0.len() + } + + /// Roll back all journal changes until the chackpoint + fn rollback(&mut self, storage: &mut Storage, checkpoint: usize) { + self.0.drain(checkpoint..).rev().for_each(|entry| entry.revert(storage)); + } +} + +/// Storage for maintaining the current transaction state. +#[derive(Default)] +struct Storage(BTreeMap, Vec>); + +impl Storage { + /// Read the storage entry. + fn read(&self, key: &Vec) -> Option> { + self.0.get(key).cloned() + } + + /// Write the storage entry. + fn write(&mut self, key: &Vec, value: Option>) -> Option> { + if let Some(value) = value { + // Insert storage entry. + self.0.insert(key.clone(), value) + } else { + // Remove storage entry. + self.0.remove(key) + } + } +} + +/// Transient storage behaves almost identically to regular storage but is discarded after each +/// transaction. It consists of a `BTreeMap` for the current state, a journal of all changes, and a +/// list of checkpoints. On entry to the `start_transaction` function, a marker (checkpoint) is +/// added to the list. New values are written to the current state, and the previous value is +/// recorded in the journal (`write`). When the `commit_transaction` function is called, the marker +/// to the journal index (checkpoint) of when that call was entered is discarded. +/// On `rollback_transaction`, all entries are reverted up to the last checkpoint. +pub struct TransientStorage { + // The storage and journal size is limited by the storage meter. + storage: Storage, + journal: Journal, + // The size of the StorageMeter is limited by the stack depth. + meter: StorageMeter, + // The size of the checkpoints is limited by the stack depth. + checkpoints: Vec, +} + +impl TransientStorage { + /// Create new transient storage with the supplied memory limit. + pub fn new(memory_limit: u32) -> Self { + TransientStorage { + storage: Default::default(), + journal: Journal::new(), + checkpoints: Default::default(), + meter: StorageMeter::new(memory_limit), + } + } + + /// Read the storage value. If the entry does not exist, `None` is returned. + pub fn read(&self, account: &AccountIdOf, key: &Key) -> Option> { + self.storage.read(&Self::storage_key(&account.encode(), &key.hash())) + } + + /// Write a value to storage. + /// + /// If the `value` is `None`, then the entry is removed. If `take` is true, + /// a [`WriteOutcome::Taken`] is returned instead of a [`WriteOutcome::Overwritten`]. + /// If the entry did not exist, [`WriteOutcome::New`] is returned. + pub fn write( + &mut self, + account: &AccountIdOf, + key: &Key, + value: Option>, + take: bool, + ) -> Result { + let key = Self::storage_key(&account.encode(), &key.hash()); + let prev_value = self.storage.read(&key); + // Skip if the same value is being set. + if prev_value != value { + // Calculate the allocation size. + if let Some(value) = &value { + // Charge the key, value and journal entry. + // If a new value is written, a new journal entry is created. The previous value is + // moved to the journal along with its key, and the new value is written to + // storage. + let key_len = key.capacity(); + let mut amount = value + .capacity() + .saturating_add(key_len) + .saturating_add(mem::size_of::()); + if prev_value.is_none() { + // Charge a new storage entry. + // If there was no previous value, a new entry is added to storage (BTreeMap) + // containing a Vec for the key and a Vec for the value. The value was already + // included in the amount. + amount.saturating_accrue(key_len.saturating_add(mem::size_of::>())); + } + self.meter.charge(amount as _)?; + } + self.storage.write(&key, value); + // Update the journal. + self.journal.push(JournalEntry::new(key, prev_value.clone())); + } + + Ok(match (take, prev_value) { + (_, None) => WriteOutcome::New, + (false, Some(prev_value)) => WriteOutcome::Overwritten(prev_value.len() as _), + (true, Some(prev_value)) => WriteOutcome::Taken(prev_value), + }) + } + + /// Start a new nested transaction. + /// + /// This allows to either commit or roll back all changes that are made after this call. + /// For every transaction there must be a matching call to either `rollback_transaction` + /// or `commit_transaction`. + pub fn start_transaction(&mut self) { + self.meter.start(); + self.checkpoints.push(self.journal.len()); + } + + /// Rollback the last transaction started by `start_transaction`. + /// + /// Any changes made during that transaction are discarded. + /// + /// # Panics + /// + /// Will panic if there is no open transaction. + pub fn rollback_transaction(&mut self) { + let checkpoint = self + .checkpoints + .pop() + .expect( + "A call to rollback_transaction must be preceded by a corresponding call to start_transaction; + the code within this crate makes sure that this is always the case; qed" + ); + self.meter.revert(); + self.journal.rollback(&mut self.storage, checkpoint); + } + + /// Commit the last transaction started by `start_transaction`. + /// + /// Any changes made during that transaction are committed. + /// + /// # Panics + /// + /// Will panic if there is no open transaction. + pub fn commit_transaction(&mut self) { + self.checkpoints + .pop() + .expect( + "A call to commit_transaction must be preceded by a corresponding call to start_transaction; + the code within this crate makes sure that this is always the case; qed" + ); + self.meter.commit(); + } + + /// The storage allocation meter used for transaction metering. + #[cfg(any(test, feature = "runtime-benchmarks"))] + pub fn meter(&mut self) -> &mut StorageMeter { + return &mut self.meter + } + + fn storage_key(account: &[u8], key: &[u8]) -> Vec { + let mut storage_key = Vec::with_capacity(account.len() + key.len()); + storage_key.extend_from_slice(&account); + storage_key.extend_from_slice(&key); + storage_key + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + tests::{Test, ALICE, BOB, CHARLIE}, + Error, + }; + use core::u32::MAX; + + // Calculate the allocation size for the given entry. + fn allocation_size( + account: &AccountIdOf, + key: &Key, + value: Option>, + ) -> u32 { + let mut storage: TransientStorage = TransientStorage::::new(MAX); + storage + .write(account, key, value, false) + .expect("Could not write to transient storage."); + storage.meter().current().amount + } + + #[test] + fn read_write_works() { + let mut storage: TransientStorage = TransientStorage::::new(2048); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1]), false), + Ok(WriteOutcome::New) + ); + assert_eq!( + storage.write(&ALICE, &Key::Fix([2; 32]), Some(vec![2]), true), + Ok(WriteOutcome::New) + ); + assert_eq!( + storage.write(&BOB, &Key::Fix([3; 32]), Some(vec![3]), false), + Ok(WriteOutcome::New) + ); + assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), Some(vec![1])); + assert_eq!(storage.read(&ALICE, &Key::Fix([2; 32])), Some(vec![2])); + assert_eq!(storage.read(&BOB, &Key::Fix([3; 32])), Some(vec![3])); + // Overwrite values. + assert_eq!( + storage.write(&ALICE, &Key::Fix([2; 32]), Some(vec![4, 5]), false), + Ok(WriteOutcome::Overwritten(1)) + ); + assert_eq!( + storage.write(&BOB, &Key::Fix([3; 32]), Some(vec![6, 7]), true), + Ok(WriteOutcome::Taken(vec![3])) + ); + assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), Some(vec![1])); + assert_eq!(storage.read(&ALICE, &Key::Fix([2; 32])), Some(vec![4, 5])); + assert_eq!(storage.read(&BOB, &Key::Fix([3; 32])), Some(vec![6, 7])); + + // Check for an empty value. + assert_eq!( + storage.write(&BOB, &Key::Fix([3; 32]), Some(vec![]), true), + Ok(WriteOutcome::Taken(vec![6, 7])) + ); + assert_eq!(storage.read(&BOB, &Key::Fix([3; 32])), Some(vec![])); + + assert_eq!( + storage.write(&BOB, &Key::Fix([3; 32]), None, true), + Ok(WriteOutcome::Taken(vec![])) + ); + assert_eq!(storage.read(&BOB, &Key::Fix([3; 32])), None); + } + + #[test] + fn read_write_with_var_sized_keys_works() { + let mut storage = TransientStorage::::new(2048); + assert_eq!( + storage.write( + &ALICE, + &Key::::try_from_var([1; 64].to_vec()).unwrap(), + Some(vec![1]), + false + ), + Ok(WriteOutcome::New) + ); + assert_eq!( + storage.write( + &BOB, + &Key::::try_from_var([2; 64].to_vec()).unwrap(), + Some(vec![2, 3]), + false + ), + Ok(WriteOutcome::New) + ); + assert_eq!( + storage.read(&ALICE, &Key::::try_from_var([1; 64].to_vec()).unwrap()), + Some(vec![1]) + ); + assert_eq!( + storage.read(&BOB, &Key::::try_from_var([2; 64].to_vec()).unwrap()), + Some(vec![2, 3]) + ); + // Overwrite values. + assert_eq!( + storage.write( + &ALICE, + &Key::::try_from_var([1; 64].to_vec()).unwrap(), + Some(vec![4, 5]), + false + ), + Ok(WriteOutcome::Overwritten(1)) + ); + assert_eq!( + storage.read(&ALICE, &Key::::try_from_var([1; 64].to_vec()).unwrap()), + Some(vec![4, 5]) + ); + } + + #[test] + fn rollback_transaction_works() { + let mut storage = TransientStorage::::new(1024); + + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1]), false), + Ok(WriteOutcome::New) + ); + storage.rollback_transaction(); + assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), None) + } + + #[test] + fn commit_transaction_works() { + let mut storage = TransientStorage::::new(1024); + + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1]), false), + Ok(WriteOutcome::New) + ); + storage.commit_transaction(); + assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), Some(vec![1])) + } + + #[test] + fn overwrite_and_commmit_transaction_works() { + let mut storage = TransientStorage::::new(1024); + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1]), false), + Ok(WriteOutcome::New) + ); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1, 2]), false), + Ok(WriteOutcome::Overwritten(1)) + ); + storage.commit_transaction(); + assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), Some(vec![1, 2])) + } + + #[test] + fn rollback_in_nested_transaction_works() { + let mut storage = TransientStorage::::new(1024); + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1]), false), + Ok(WriteOutcome::New) + ); + storage.start_transaction(); + assert_eq!( + storage.write(&BOB, &Key::Fix([1; 32]), Some(vec![1]), false), + Ok(WriteOutcome::New) + ); + storage.rollback_transaction(); + storage.commit_transaction(); + assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), Some(vec![1])); + assert_eq!(storage.read(&BOB, &Key::Fix([1; 32])), None) + } + + #[test] + fn commit_in_nested_transaction_works() { + let mut storage = TransientStorage::::new(1024); + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1]), false), + Ok(WriteOutcome::New) + ); + storage.start_transaction(); + assert_eq!( + storage.write(&BOB, &Key::Fix([1; 32]), Some(vec![2]), false), + Ok(WriteOutcome::New) + ); + storage.start_transaction(); + assert_eq!( + storage.write(&CHARLIE, &Key::Fix([1; 32]), Some(vec![3]), false), + Ok(WriteOutcome::New) + ); + storage.commit_transaction(); + storage.commit_transaction(); + storage.commit_transaction(); + assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), Some(vec![1])); + assert_eq!(storage.read(&BOB, &Key::Fix([1; 32])), Some(vec![2])); + assert_eq!(storage.read(&CHARLIE, &Key::Fix([1; 32])), Some(vec![3])); + } + + #[test] + fn rollback_all_transactions_works() { + let mut storage = TransientStorage::::new(1024); + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1]), false), + Ok(WriteOutcome::New) + ); + storage.start_transaction(); + assert_eq!( + storage.write(&BOB, &Key::Fix([1; 32]), Some(vec![2]), false), + Ok(WriteOutcome::New) + ); + storage.start_transaction(); + assert_eq!( + storage.write(&CHARLIE, &Key::Fix([1; 32]), Some(vec![3]), false), + Ok(WriteOutcome::New) + ); + storage.commit_transaction(); + storage.commit_transaction(); + storage.rollback_transaction(); + assert_eq!(storage.read(&ALICE, &Key::Fix([1; 32])), None); + assert_eq!(storage.read(&BOB, &Key::Fix([1; 32])), None); + assert_eq!(storage.read(&CHARLIE, &Key::Fix([1; 32])), None); + } + + #[test] + fn metering_transactions_works() { + let size = allocation_size(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096])); + let mut storage = TransientStorage::::new(size * 2); + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + let limit = storage.meter().current().limit; + storage.commit_transaction(); + + storage.start_transaction(); + assert_eq!(storage.meter().current().limit, limit - size); + assert_eq!(storage.meter().current().limit - storage.meter().current().amount, size); + assert_eq!( + storage.write(&ALICE, &Key::Fix([2; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + assert_eq!(storage.meter().current().amount, size); + storage.commit_transaction(); + assert_eq!(storage.meter().total_amount(), size * 2); + } + + #[test] + fn metering_nested_transactions_works() { + let size = allocation_size(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096])); + let mut storage = TransientStorage::::new(size * 3); + + storage.start_transaction(); + let limit = storage.meter().current().limit; + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + storage.start_transaction(); + assert_eq!(storage.meter().total_amount(), size); + assert!(storage.meter().current().limit < limit - size); + assert_eq!( + storage.write(&ALICE, &Key::Fix([2; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + storage.commit_transaction(); + assert_eq!(storage.meter().current().limit, limit); + assert_eq!(storage.meter().total_amount(), storage.meter().current().amount); + storage.commit_transaction(); + } + + #[test] + fn metering_transaction_fails() { + let size = allocation_size(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096])); + let mut storage = TransientStorage::::new(size - 1); + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096]), false), + Err(Error::::OutOfTransientStorage.into()) + ); + assert_eq!(storage.meter.current().amount, 0); + storage.commit_transaction(); + assert_eq!(storage.meter.total_amount(), 0); + } + + #[test] + fn metering_nested_transactions_fails() { + let size = allocation_size(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096])); + let mut storage = TransientStorage::::new(size * 2); + + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([2; 32]), Some(vec![1u8; 4096]), false), + Err(Error::::OutOfTransientStorage.into()) + ); + storage.commit_transaction(); + storage.commit_transaction(); + assert_eq!(storage.meter.total_amount(), size); + } + + #[test] + fn metering_nested_transaction_with_rollback_works() { + let size = allocation_size(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096])); + let mut storage = TransientStorage::::new(size * 2); + + storage.start_transaction(); + let limit = storage.meter.current().limit; + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([2; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + storage.rollback_transaction(); + + assert_eq!(storage.meter.total_amount(), 0); + assert_eq!(storage.meter.current().limit, limit); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + let amount = storage.meter().current().amount; + assert_eq!(storage.meter().total_amount(), amount); + storage.commit_transaction(); + } + + #[test] + fn metering_with_rollback_works() { + let size = allocation_size(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096])); + let mut storage = TransientStorage::::new(size * 5); + + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([1; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + let amount = storage.meter.total_amount(); + storage.start_transaction(); + assert_eq!( + storage.write(&ALICE, &Key::Fix([2; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + storage.start_transaction(); + assert_eq!( + storage.write(&BOB, &Key::Fix([1; 32]), Some(vec![1u8; 4096]), false), + Ok(WriteOutcome::New) + ); + storage.commit_transaction(); + storage.rollback_transaction(); + assert_eq!(storage.meter.total_amount(), amount); + storage.commit_transaction(); + } +} diff --git a/substrate/frame/contracts/src/wasm/mod.rs b/substrate/frame/contracts/src/wasm/mod.rs index 2fef07f8b7a4c..f4ee76459c4ea 100644 --- a/substrate/frame/contracts/src/wasm/mod.rs +++ b/substrate/frame/contracts/src/wasm/mod.rs @@ -506,6 +506,7 @@ mod tests { primitives::ExecReturnValue, storage::WriteOutcome, tests::{RuntimeCall, Test, ALICE, BOB}, + transient_storage::TransientStorage, BalanceOf, CodeHash, Error, Origin, Pallet as Contracts, }; use assert_matches::assert_matches; @@ -563,6 +564,7 @@ mod tests { pub struct MockExt { storage: HashMap, Vec>, + transient_storage: TransientStorage, instantiates: Vec, terminations: Vec, calls: Vec, @@ -591,6 +593,7 @@ mod tests { Self { code_hashes: Default::default(), storage: Default::default(), + transient_storage: TransientStorage::new(1024 * 1024), instantiates: Default::default(), terminations: Default::default(), calls: Default::default(), @@ -691,6 +694,21 @@ mod tests { } Ok(result) } + fn get_transient_storage(&self, key: &Key) -> Option> { + self.transient_storage.read(self.address(), key) + } + fn get_transient_storage_size(&self, key: &Key) -> Option { + self.transient_storage.read(self.address(), key).map(|value| value.len() as _) + } + fn set_transient_storage( + &mut self, + key: &Key, + value: Option>, + take_old: bool, + ) -> Result { + let account_id = self.address().clone(); + self.transient_storage.write(&account_id, key, value, take_old) + } fn caller(&self) -> Origin { self.caller.clone() } @@ -784,6 +802,10 @@ mod tests { fn contract_info(&mut self) -> &mut crate::ContractInfo { unimplemented!() } + #[cfg(feature = "runtime-benchmarks")] + fn transient_storage(&mut self) -> &mut TransientStorage { + unimplemented!() + } fn ecdsa_to_eth_address(&self, _pk: &[u8; 33]) -> Result<[u8; 20], ()> { Ok([2u8; 20]) } @@ -3046,6 +3068,337 @@ mod tests { assert_eq!(&result.data[4..], &[0u8; 0]); } + #[test] + fn set_transient_storage_works() { + const CODE: &str = r#" +(module + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) + (import "seal0" "set_transient_storage" (func $set_transient_storage (param i32 i32 i32 i32) (result i32))) + (import "env" "memory" (memory 1 1)) + + ;; [0, 4) size of input buffer + ;; 4k in little endian + (data (i32.const 0) "\00\10") + + ;; [4, 4100) input buffer + + (func (export "call") + ;; Receive (key ++ value_to_write) + (call $seal_input + (i32.const 4) ;; Pointer to the input buffer + (i32.const 0) ;; Size of the input buffer + ) + ;; Store the passed value to the passed key and store result to memory + (i32.store (i32.const 168) + (call $set_transient_storage + (i32.const 8) ;; key_ptr + (i32.load (i32.const 4)) ;; key_len + (i32.add ;; value_ptr = 8 + key_len + (i32.const 8) + (i32.load (i32.const 4))) + (i32.sub ;; value_len (input_size - (key_len + key_len_len)) + (i32.load (i32.const 0)) + (i32.add + (i32.load (i32.const 4)) + (i32.const 4) + ) + ) + ) + ) + (call $seal_return + (i32.const 0) ;; flags + (i32.const 168) ;; ptr to returned value + (i32.const 4) ;; length of returned value + ) + ) + + (func (export "deploy")) +) +"#; + + let mut ext = MockExt::default(); + + // value did not exist before -> sentinel returned + let input = (32, [1u8; 32], [42u8, 48]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!(u32::from_le_bytes(result.data.try_into().unwrap()), crate::SENTINEL); + assert_eq!( + ext.get_transient_storage(&Key::::try_from_var([1u8; 32].to_vec()).unwrap()), + Some(vec![42, 48]) + ); + + // value do exist -> length of old value returned + let input = (32, [1u8; 32], [0u8; 0]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!(u32::from_le_bytes(result.data.try_into().unwrap()), 2); + assert_eq!( + ext.get_transient_storage(&Key::::try_from_var([1u8; 32].to_vec()).unwrap()), + Some(vec![]) + ); + + // value do exist -> length of old value returned (test for zero sized val) + let input = (32, [1u8; 32], [99u8]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!(u32::from_le_bytes(result.data.try_into().unwrap()), 0); + assert_eq!( + ext.get_transient_storage(&Key::::try_from_var([1u8; 32].to_vec()).unwrap()), + Some(vec![99]) + ); + } + + #[test] + fn get_transient_storage_works() { + const CODE: &str = r#" +(module + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) + (import "seal0" "get_transient_storage" (func $get_transient_storage (param i32 i32 i32 i32) (result i32))) + (import "env" "memory" (memory 1 1)) + + ;; [0, 4) size of input buffer (160 bytes as we copy the key+len here) + (data (i32.const 0) "\A0") + + ;; [4, 8) size of output buffer + ;; 4k in little endian + (data (i32.const 4) "\00\10") + + ;; [8, 168) input buffer + ;; [168, 4264) output buffer + + (func (export "call") + ;; Receive (key ++ value_to_write) + (call $seal_input + (i32.const 8) ;; Pointer to the input buffer + (i32.const 0) ;; Size of the input buffer + ) + ;; Load a storage value and result of this call into the output buffer + (i32.store (i32.const 168) + (call $get_transient_storage + (i32.const 12) ;; key_ptr + (i32.load (i32.const 8)) ;; key_len + (i32.const 172) ;; Pointer to the output buffer + (i32.const 4) ;; Pointer to the size of the buffer + ) + ) + (call $seal_return + (i32.const 0) ;; flags + (i32.const 168) ;; output buffer ptr + (i32.add ;; length: output size + 4 (retval) + (i32.load (i32.const 4)) + (i32.const 4) + ) + ) + ) + + (func (export "deploy")) +) +"#; + + let mut ext = MockExt::default(); + + assert_ok!(ext.set_transient_storage( + &Key::::try_from_var([1u8; 64].to_vec()).unwrap(), + Some(vec![42u8]), + false + )); + assert_ok!(ext.set_transient_storage( + &Key::::try_from_var([2u8; 19].to_vec()).unwrap(), + Some(vec![]), + false + )); + + // value does not exist + let input = (63, [1u8; 64]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!( + u32::from_le_bytes(result.data[0..4].try_into().unwrap()), + ReturnErrorCode::KeyNotFound as u32 + ); + + // value exists + let input = (64, [1u8; 64]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!( + u32::from_le_bytes(result.data[0..4].try_into().unwrap()), + ReturnErrorCode::Success as u32 + ); + assert_eq!(&result.data[4..], &[42u8]); + + // value exists (test for 0 sized) + let input = (19, [2u8; 19]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!( + u32::from_le_bytes(result.data[0..4].try_into().unwrap()), + ReturnErrorCode::Success as u32 + ); + assert_eq!(&result.data[4..], &([] as [u8; 0])); + } + + #[test] + fn clear_transient_storage_works() { + const CODE: &str = r#" +(module + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) + (import "seal0" "clear_transient_storage" (func $clear_transient_storage (param i32 i32) (result i32))) + (import "env" "memory" (memory 1 1)) + + ;; size of input buffer + ;; [0, 4) size of input buffer (128+32 = 160 bytes = 0xA0) + (data (i32.const 0) "\A0") + + ;; [4, 164) input buffer + + (func (export "call") + ;; Receive key + (call $seal_input + (i32.const 4) ;; Where we take input and store it + (i32.const 0) ;; Where we take and store the length of thedata + ) + ;; Call seal_clear_storage and save what it returns at 0 + (i32.store (i32.const 0) + (call $clear_transient_storage + (i32.const 8) ;; key_ptr + (i32.load (i32.const 4)) ;; key_len + ) + ) + (call $seal_return + (i32.const 0) ;; flags + (i32.const 0) ;; returned value + (i32.const 4) ;; length of returned value + ) + ) + + (func (export "deploy")) +) +"#; + + let mut ext = MockExt::default(); + + assert_ok!(ext.set_transient_storage( + &Key::::try_from_var([1u8; 64].to_vec()).unwrap(), + Some(vec![42u8]), + false + )); + + // value did not exist + let input = (32, [3u8; 32]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + // sentinel returned + assert_eq!(u32::from_le_bytes(result.data.try_into().unwrap()), crate::SENTINEL); + + // value did exist + let input = (64, [1u8; 64]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + // length returned + assert_eq!(u32::from_le_bytes(result.data.try_into().unwrap()), 1); + // value cleared + assert_eq!( + ext.get_transient_storage(&Key::::try_from_var([1u8; 64].to_vec()).unwrap()), + None + ); + } + + #[test] + fn take_transient_storage_works() { + const CODE: &str = r#" +(module + (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "take_transient_storage" (func $take_transient_storage (param i32 i32 i32 i32) (result i32))) + (import "env" "memory" (memory 1 1)) + + ;; [0, 4) size of input buffer (160 bytes as we copy the key+len here) + (data (i32.const 0) "\A0") + + ;; [4, 8) size of output buffer + ;; 4k in little endian + (data (i32.const 4) "\00\10") + + ;; [8, 168) input buffer + ;; [168, 4264) output buffer + + (func (export "call") + ;; Receive key + (call $seal_input + (i32.const 8) ;; Pointer to the input buffer + (i32.const 0) ;; Size of the length buffer + ) + + ;; Load a storage value and result of this call into the output buffer + (i32.store (i32.const 168) + (call $take_transient_storage + (i32.const 12) ;; key_ptr + (i32.load (i32.const 8)) ;; key_len + (i32.const 172) ;; Pointer to the output buffer + (i32.const 4) ;; Pointer to the size of the buffer + ) + ) + + ;; Return the contents of the buffer + (call $seal_return + (i32.const 0) ;; flags + (i32.const 168) ;; output buffer ptr + (i32.add ;; length: storage size + 4 (retval) + (i32.load (i32.const 4)) + (i32.const 4) + ) + ) + ) + + (func (export "deploy")) +) +"#; + + let mut ext = MockExt::default(); + + assert_ok!(ext.set_transient_storage( + &Key::::try_from_var([1u8; 64].to_vec()).unwrap(), + Some(vec![42u8]), + false + )); + assert_ok!(ext.set_transient_storage( + &Key::::try_from_var([2u8; 19].to_vec()).unwrap(), + Some(vec![]), + false + )); + + // value does not exist -> error returned + let input = (63, [1u8; 64]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!( + u32::from_le_bytes(result.data[0..4].try_into().unwrap()), + ReturnErrorCode::KeyNotFound as u32 + ); + + // value did exist -> value returned + let input = (64, [1u8; 64]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!( + u32::from_le_bytes(result.data[0..4].try_into().unwrap()), + ReturnErrorCode::Success as u32 + ); + assert_eq!( + ext.get_transient_storage(&Key::::try_from_var([1u8; 64].to_vec()).unwrap()), + None + ); + assert_eq!(&result.data[4..], &[42u8]); + + // value did exist -> length returned (test for 0 sized) + let input = (19, [2u8; 19]).encode(); + let result = execute(CODE, input, &mut ext).unwrap(); + assert_eq!( + u32::from_le_bytes(result.data[0..4].try_into().unwrap()), + ReturnErrorCode::Success as u32 + ); + assert_eq!( + ext.get_transient_storage(&Key::::try_from_var([2u8; 19].to_vec()).unwrap()), + None + ); + assert_eq!(&result.data[4..], &[0u8; 0]); + } + #[test] fn is_contract_works() { const CODE_IS_CONTRACT: &str = r#" diff --git a/substrate/frame/contracts/src/wasm/runtime.rs b/substrate/frame/contracts/src/wasm/runtime.rs index 50b06de080cab..982d28540ec1e 100644 --- a/substrate/frame/contracts/src/wasm/runtime.rs +++ b/substrate/frame/contracts/src/wasm/runtime.rs @@ -199,6 +199,16 @@ pub enum RuntimeCosts { GetStorage(u32), /// Weight of calling `seal_take_storage` for the given size. TakeStorage(u32), + /// Weight of calling `seal_set_transient_storage` for the given storage item sizes. + SetTransientStorage { old_bytes: u32, new_bytes: u32 }, + /// Weight of calling `seal_clear_transient_storage` per cleared byte. + ClearTransientStorage(u32), + /// Weight of calling `seal_contains_transient_storage` per byte of the checked item. + ContainsTransientStorage(u32), + /// Weight of calling `seal_get_transient_storage` with the specified size in storage. + GetTransientStorage(u32), + /// Weight of calling `seal_take_transient_storage` for the given size. + TakeTransientStorage(u32), /// Weight of calling `seal_transfer`. Transfer, /// Base weight of calling `seal_call`. @@ -245,6 +255,34 @@ pub enum RuntimeCosts { UnlockDelegateDependency, } +// For the function that modifies the storage, the benchmarks are done with one item in the +// transient_storage (BTreeMap). To consider the worst-case scenario, the weight of the overhead of +// writing to a full BTreeMap should be included. On top of that, the rollback weight is added, +// which is the worst scenario. +macro_rules! cost_write { + // cost_write!(name, a, b, c) -> T::WeightInfo::name(a, b, c).saturating_add(T::WeightInfo::rollback_transient_storage()) + // .saturating_add(T::WeightInfo::set_transient_storage_full().saturating_sub(T::WeightInfo::set_transient_storage_empty()) + ($name:ident $(, $arg:expr )*) => { + (T::WeightInfo::$name($( $arg ),*).saturating_add(T::WeightInfo::rollback_transient_storage()).saturating_add(cost_write!(@cost_storage))) + }; + + (@cost_storage) => { + T::WeightInfo::set_transient_storage_full().saturating_sub(T::WeightInfo::set_transient_storage_empty()) + }; +} + +macro_rules! cost_read { + // cost_read!(name, a, b, c) -> T::WeightInfo::name(a, b, c).saturating_add(T::WeightInfo::get_transient_storage_full() + // .saturating_sub(T::WeightInfo::get_transient_storage_empty()) + ($name:ident $(, $arg:expr )*) => { + (T::WeightInfo::$name($( $arg ),*).saturating_add(cost_read!(@cost_storage))) + }; + + (@cost_storage) => { + T::WeightInfo::get_transient_storage_full().saturating_sub(T::WeightInfo::get_transient_storage_empty()) + }; +} + macro_rules! cost_args { // cost_args!(name, a, b, c) -> T::WeightInfo::name(a, b, c).saturating_sub(T::WeightInfo::name(0, 0, 0)) ($name:ident, $( $arg: expr ),+) => { @@ -296,6 +334,12 @@ impl Token for RuntimeCosts { ContainsStorage(len) => T::WeightInfo::seal_contains_storage(len), GetStorage(len) => T::WeightInfo::seal_get_storage(len), TakeStorage(len) => T::WeightInfo::seal_take_storage(len), + SetTransientStorage { new_bytes, old_bytes } => + cost_write!(seal_set_transient_storage, new_bytes, old_bytes), + ClearTransientStorage(len) => cost_write!(seal_clear_transient_storage, len), + ContainsTransientStorage(len) => cost_read!(seal_contains_transient_storage, len), + GetTransientStorage(len) => cost_read!(seal_get_transient_storage, len), + TakeTransientStorage(len) => cost_write!(seal_take_transient_storage, len), Transfer => T::WeightInfo::seal_transfer(), CallBase => T::WeightInfo::seal_call(0, 0), DelegateCallBase => T::WeightInfo::seal_delegate_call(), @@ -792,10 +836,129 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { let key = self.decode_key(memory, key_type, key_ptr)?; let outcome = self.ext.get_storage_size(&key); - self.adjust_gas(charged, RuntimeCosts::ClearStorage(outcome.unwrap_or(0))); + self.adjust_gas(charged, RuntimeCosts::ContainsStorage(outcome.unwrap_or(0))); Ok(outcome.unwrap_or(SENTINEL)) } + fn set_transient_storage( + &mut self, + memory: &[u8], + key_type: KeyType, + key_ptr: u32, + value_ptr: u32, + value_len: u32, + ) -> Result { + let max_size = self.ext.max_value_size(); + let charged = self.charge_gas(RuntimeCosts::SetTransientStorage { + new_bytes: value_len, + old_bytes: max_size, + })?; + if value_len > max_size { + return Err(Error::::ValueTooLarge.into()) + } + let key = self.decode_key(memory, key_type, key_ptr)?; + let value = Some(self.read_sandbox_memory(memory, value_ptr, value_len)?); + let write_outcome = self.ext.set_transient_storage(&key, value, false)?; + self.adjust_gas( + charged, + RuntimeCosts::SetTransientStorage { + new_bytes: value_len, + old_bytes: write_outcome.old_len(), + }, + ); + Ok(write_outcome.old_len_with_sentinel()) + } + + fn clear_transient_storage( + &mut self, + memory: &[u8], + key_type: KeyType, + key_ptr: u32, + ) -> Result { + let charged = + self.charge_gas(RuntimeCosts::ClearTransientStorage(self.ext.max_value_size()))?; + let key = self.decode_key(memory, key_type, key_ptr)?; + let outcome = self.ext.set_transient_storage(&key, None, false)?; + + self.adjust_gas(charged, RuntimeCosts::ClearTransientStorage(outcome.old_len())); + Ok(outcome.old_len_with_sentinel()) + } + + fn get_transient_storage( + &mut self, + memory: &mut [u8], + key_type: KeyType, + key_ptr: u32, + out_ptr: u32, + out_len_ptr: u32, + ) -> Result { + let charged = + self.charge_gas(RuntimeCosts::GetTransientStorage(self.ext.max_value_size()))?; + let key = self.decode_key(memory, key_type, key_ptr)?; + let outcome = self.ext.get_transient_storage(&key); + + if let Some(value) = outcome { + self.adjust_gas(charged, RuntimeCosts::GetTransientStorage(value.len() as u32)); + self.write_sandbox_output( + memory, + out_ptr, + out_len_ptr, + &value, + false, + already_charged, + )?; + Ok(ReturnErrorCode::Success) + } else { + self.adjust_gas(charged, RuntimeCosts::GetTransientStorage(0)); + Ok(ReturnErrorCode::KeyNotFound) + } + } + + fn contains_transient_storage( + &mut self, + memory: &[u8], + key_type: KeyType, + key_ptr: u32, + ) -> Result { + let charged = + self.charge_gas(RuntimeCosts::ContainsTransientStorage(self.ext.max_value_size()))?; + let key = self.decode_key(memory, key_type, key_ptr)?; + let outcome = self.ext.get_transient_storage_size(&key); + + self.adjust_gas(charged, RuntimeCosts::ContainsTransientStorage(outcome.unwrap_or(0))); + Ok(outcome.unwrap_or(SENTINEL)) + } + + fn take_transient_storage( + &mut self, + memory: &mut [u8], + key_type: KeyType, + key_ptr: u32, + out_ptr: u32, + out_len_ptr: u32, + ) -> Result { + let charged = + self.charge_gas(RuntimeCosts::TakeTransientStorage(self.ext.max_value_size()))?; + let key = self.decode_key(memory, key_type, key_ptr)?; + if let crate::storage::WriteOutcome::Taken(value) = + self.ext.set_transient_storage(&key, None, true)? + { + self.adjust_gas(charged, RuntimeCosts::TakeTransientStorage(value.len() as u32)); + self.write_sandbox_output( + memory, + out_ptr, + out_len_ptr, + &value, + false, + already_charged, + )?; + Ok(ReturnErrorCode::Success) + } else { + self.adjust_gas(charged, RuntimeCosts::TakeTransientStorage(0)); + Ok(ReturnErrorCode::KeyNotFound) + } + } + fn call( &mut self, memory: &mut [u8], @@ -1099,6 +1262,67 @@ pub mod env { } } + /// Set the value at the given key in the contract transient storage. + #[unstable] + fn set_transient_storage( + ctx: _, + memory: _, + key_ptr: u32, + key_len: u32, + value_ptr: u32, + value_len: u32, + ) -> Result { + ctx.set_transient_storage(memory, KeyType::Var(key_len), key_ptr, value_ptr, value_len) + } + + /// Clear the value at the given key in the contract storage. + #[unstable] + fn clear_transient_storage( + ctx: _, + memory: _, + key_ptr: u32, + key_len: u32, + ) -> Result { + ctx.clear_transient_storage(memory, KeyType::Var(key_len), key_ptr) + } + + /// Retrieve the value under the given key from transient storage. + #[unstable] + fn get_transient_storage( + ctx: _, + memory: _, + key_ptr: u32, + key_len: u32, + out_ptr: u32, + out_len_ptr: u32, + ) -> Result { + ctx.get_transient_storage(memory, KeyType::Var(key_len), key_ptr, out_ptr, out_len_ptr) + } + + /// Checks whether there is a value stored under the given key in transient storage. + #[unstable] + fn contains_transient_storage( + ctx: _, + memory: _, + key_ptr: u32, + key_len: u32, + ) -> Result { + ctx.contains_transient_storage(memory, KeyType::Var(key_len), key_ptr) + } + + /// Retrieve and remove the value under the given key from transient storage. + #[unstable] + fn take_transient_storage( + ctx: _, + memory: _, + key_ptr: u32, + key_len: u32, + out_ptr: u32, + out_len_ptr: u32, + ) -> Result { + ctx.take_transient_storage(memory, KeyType::Var(key_len), key_ptr, out_ptr, out_len_ptr) + } + /// Transfer some value to another account. /// See [`pallet_contracts_uapi::HostFn::transfer`]. #[prefixed_alias] diff --git a/substrate/frame/contracts/src/weights.rs b/substrate/frame/contracts/src/weights.rs index 0404a9d3d8e50..dc10a8aee773c 100644 --- a/substrate/frame/contracts/src/weights.rs +++ b/substrate/frame/contracts/src/weights.rs @@ -18,9 +18,9 @@ //! Autogenerated weights for `pallet_contracts` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-06-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-1pho9goo-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `runner-yaoqqom-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: @@ -98,6 +98,16 @@ pub trait WeightInfo { fn seal_get_storage(n: u32, ) -> Weight; fn seal_contains_storage(n: u32, ) -> Weight; fn seal_take_storage(n: u32, ) -> Weight; + fn set_transient_storage_empty() -> Weight; + fn set_transient_storage_full() -> Weight; + fn get_transient_storage_empty() -> Weight; + fn get_transient_storage_full() -> Weight; + fn rollback_transient_storage() -> Weight; + fn seal_set_transient_storage(n: u32, o: u32, ) -> Weight; + fn seal_clear_transient_storage(n: u32, ) -> Weight; + fn seal_get_transient_storage(n: u32, ) -> Weight; + fn seal_contains_transient_storage(n: u32, ) -> Weight; + fn seal_take_transient_storage(n: u32, ) -> Weight; fn seal_transfer() -> Weight; fn seal_call(t: u32, i: u32, ) -> Weight; fn seal_delegate_call() -> Weight; @@ -127,8 +137,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 1_896_000 picoseconds. - Weight::from_parts(1_990_000, 1627) + // Minimum execution time: 1_921_000 picoseconds. + Weight::from_parts(2_003_000, 1627) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -138,10 +148,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `452 + k * (69 Ā±0)` // Estimated: `442 + k * (70 Ā±0)` - // Minimum execution time: 11_142_000 picoseconds. - Weight::from_parts(11_578_000, 442) - // Standard Error: 1_557 - .saturating_add(Weight::from_parts(1_165_198, 0).saturating_mul(k.into())) + // Minimum execution time: 11_364_000 picoseconds. + Weight::from_parts(11_463_000, 442) + // Standard Error: 2_141 + .saturating_add(Weight::from_parts(1_149_944, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -155,10 +165,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `211 + c * (1 Ā±0)` // Estimated: `6149 + c * (1 Ā±0)` - // Minimum execution time: 7_649_000 picoseconds. - Weight::from_parts(4_827_445, 6149) + // Minimum execution time: 7_565_000 picoseconds. + Weight::from_parts(5_041_009, 6149) // Standard Error: 5 - .saturating_add(Weight::from_parts(1_630, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(1_640, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -171,8 +181,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `510` // Estimated: `6450` - // Minimum execution time: 16_096_000 picoseconds. - Weight::from_parts(16_937_000, 6450) + // Minimum execution time: 15_894_000 picoseconds. + Weight::from_parts(16_618_000, 6450) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -185,10 +195,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `171 + k * (1 Ā±0)` // Estimated: `3635 + k * (1 Ā±0)` - // Minimum execution time: 3_131_000 picoseconds. - Weight::from_parts(3_209_000, 3635) - // Standard Error: 481 - .saturating_add(Weight::from_parts(1_087_506, 0).saturating_mul(k.into())) + // Minimum execution time: 3_077_000 picoseconds. + Weight::from_parts(3_144_000, 3635) + // Standard Error: 650 + .saturating_add(Weight::from_parts(1_095_835, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -207,10 +217,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `325 + c * (1 Ā±0)` // Estimated: `6263 + c * (1 Ā±0)` - // Minimum execution time: 15_289_000 picoseconds. - Weight::from_parts(16_157_168, 6263) + // Minimum execution time: 14_960_000 picoseconds. + Weight::from_parts(15_778_951, 6263) // Standard Error: 1 - .saturating_add(Weight::from_parts(395, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(443, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -221,8 +231,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `440` // Estimated: `6380` - // Minimum execution time: 12_312_000 picoseconds. - Weight::from_parts(12_650_000, 6380) + // Minimum execution time: 11_849_000 picoseconds. + Weight::from_parts(12_273_000, 6380) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -236,8 +246,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `352` // Estimated: `6292` - // Minimum execution time: 47_239_000 picoseconds. - Weight::from_parts(48_617_000, 6292) + // Minimum execution time: 47_862_000 picoseconds. + Weight::from_parts(48_879_000, 6292) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -249,8 +259,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `594` // Estimated: `6534` - // Minimum execution time: 52_084_000 picoseconds. - Weight::from_parts(53_838_000, 6534) + // Minimum execution time: 50_754_000 picoseconds. + Weight::from_parts(52_720_000, 6534) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -260,8 +270,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `409` // Estimated: `6349` - // Minimum execution time: 11_785_000 picoseconds. - Weight::from_parts(12_284_000, 6349) + // Minimum execution time: 11_459_000 picoseconds. + Weight::from_parts(11_921_000, 6349) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -271,8 +281,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 2_136_000 picoseconds. - Weight::from_parts(2_233_000, 1627) + // Minimum execution time: 2_135_000 picoseconds. + Weight::from_parts(2_247_000, 1627) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -284,8 +294,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `166` // Estimated: `3631` - // Minimum execution time: 10_957_000 picoseconds. - Weight::from_parts(11_314_000, 3631) + // Minimum execution time: 10_645_000 picoseconds. + Weight::from_parts(11_107_000, 3631) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -295,8 +305,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 4_354_000 picoseconds. - Weight::from_parts(4_613_000, 3607) + // Minimum execution time: 4_353_000 picoseconds. + Weight::from_parts(4_628_000, 3607) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -307,8 +317,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `167` // Estimated: `3632` - // Minimum execution time: 5_541_000 picoseconds. - Weight::from_parts(5_790_000, 3632) + // Minimum execution time: 5_432_000 picoseconds. + Weight::from_parts(5_624_000, 3632) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -319,8 +329,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 5_502_000 picoseconds. - Weight::from_parts(5_701_000, 3607) + // Minimum execution time: 5_371_000 picoseconds. + Weight::from_parts(5_794_000, 3607) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -339,12 +349,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `801 + c * (1 Ā±0)` - // Estimated: `4264 + c * (1 Ā±0)` - // Minimum execution time: 247_884_000 picoseconds. - Weight::from_parts(265_795_781, 4264) + // Measured: `800 + c * (1 Ā±0)` + // Estimated: `4266 + c * (1 Ā±0)` + // Minimum execution time: 247_157_000 picoseconds. + Weight::from_parts(269_252_698, 4266) // Standard Error: 4 - .saturating_add(Weight::from_parts(724, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(729, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -372,14 +382,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `323` // Estimated: `6262` - // Minimum execution time: 4_500_184_000 picoseconds. - Weight::from_parts(160_729_258, 6262) - // Standard Error: 143 - .saturating_add(Weight::from_parts(52_809, 0).saturating_mul(c.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(2_173, 0).saturating_mul(i.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(2_165, 0).saturating_mul(s.into())) + // Minimum execution time: 4_575_784_000 picoseconds. + Weight::from_parts(207_379_459, 6262) + // Standard Error: 124 + .saturating_add(Weight::from_parts(52_392, 0).saturating_mul(c.into())) + // Standard Error: 15 + .saturating_add(Weight::from_parts(2_257, 0).saturating_mul(i.into())) + // Standard Error: 15 + .saturating_add(Weight::from_parts(2_263, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -404,13 +414,13 @@ impl WeightInfo for SubstrateWeight { fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `560` - // Estimated: `4029` - // Minimum execution time: 2_219_163_000 picoseconds. - Weight::from_parts(2_236_918_000, 4029) - // Standard Error: 32 - .saturating_add(Weight::from_parts(937, 0).saturating_mul(i.into())) - // Standard Error: 32 - .saturating_add(Weight::from_parts(938, 0).saturating_mul(s.into())) + // Estimated: `4017` + // Minimum execution time: 2_306_770_000 picoseconds. + Weight::from_parts(2_462_908_000, 4017) + // Standard Error: 33 + .saturating_add(Weight::from_parts(898, 0).saturating_mul(i.into())) + // Standard Error: 33 + .saturating_add(Weight::from_parts(859, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -430,8 +440,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `826` // Estimated: `4291` - // Minimum execution time: 164_801_000 picoseconds. - Weight::from_parts(167_250_000, 4291) + // Minimum execution time: 165_499_000 picoseconds. + Weight::from_parts(169_903_000, 4291) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -448,10 +458,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 225_207_000 picoseconds. - Weight::from_parts(263_665_658, 3607) - // Standard Error: 47 - .saturating_add(Weight::from_parts(50_732, 0).saturating_mul(c.into())) + // Minimum execution time: 227_590_000 picoseconds. + Weight::from_parts(260_045_588, 3607) + // Standard Error: 52 + .saturating_add(Weight::from_parts(51_305, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -468,10 +478,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 230_718_000 picoseconds. - Weight::from_parts(258_359_271, 3607) - // Standard Error: 47 - .saturating_add(Weight::from_parts(51_014, 0).saturating_mul(c.into())) + // Minimum execution time: 239_634_000 picoseconds. + Weight::from_parts(262_040_831, 3607) + // Standard Error: 103 + .saturating_add(Weight::from_parts(51_590, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -487,8 +497,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `315` // Estimated: `3780` - // Minimum execution time: 39_668_000 picoseconds. - Weight::from_parts(41_031_000, 3780) + // Minimum execution time: 39_152_000 picoseconds. + Weight::from_parts(39_970_000, 3780) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -502,8 +512,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `552` // Estimated: `6492` - // Minimum execution time: 25_890_000 picoseconds. - Weight::from_parts(26_603_000, 6492) + // Minimum execution time: 25_143_000 picoseconds. + Weight::from_parts(26_103_000, 6492) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -512,17 +522,17 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_269_000 picoseconds. - Weight::from_parts(9_227_069, 0) - // Standard Error: 74 - .saturating_add(Weight::from_parts(51_396, 0).saturating_mul(r.into())) + // Minimum execution time: 8_406_000 picoseconds. + Weight::from_parts(9_056_753, 0) + // Standard Error: 98 + .saturating_add(Weight::from_parts(53_110, 0).saturating_mul(r.into())) } fn seal_caller() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 602_000 picoseconds. - Weight::from_parts(664_000, 0) + // Minimum execution time: 659_000 picoseconds. + Weight::from_parts(705_000, 0) } /// Storage: `Contracts::ContractInfoOf` (r:1 w:0) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) @@ -530,8 +540,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `354` // Estimated: `3819` - // Minimum execution time: 6_131_000 picoseconds. - Weight::from_parts(6_468_000, 3819) + // Minimum execution time: 6_165_000 picoseconds. + Weight::from_parts(6_340_000, 3819) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `Contracts::ContractInfoOf` (r:1 w:0) @@ -540,79 +550,79 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `447` // Estimated: `3912` - // Minimum execution time: 7_557_000 picoseconds. - Weight::from_parts(7_704_000, 3912) + // Minimum execution time: 7_398_000 picoseconds. + Weight::from_parts(7_661_000, 3912) .saturating_add(T::DbWeight::get().reads(1_u64)) } fn seal_own_code_hash() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 783_000 picoseconds. - Weight::from_parts(848_000, 0) + // Minimum execution time: 723_000 picoseconds. + Weight::from_parts(793_000, 0) } fn seal_caller_is_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 397_000 picoseconds. - Weight::from_parts(435_000, 0) + // Minimum execution time: 398_000 picoseconds. + Weight::from_parts(428_000, 0) } fn seal_caller_is_root() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 351_000 picoseconds. - Weight::from_parts(372_000, 0) + // Minimum execution time: 329_000 picoseconds. + Weight::from_parts(364_000, 0) } fn seal_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 608_000 picoseconds. - Weight::from_parts(645_000, 0) + // Minimum execution time: 592_000 picoseconds. + Weight::from_parts(624_000, 0) } fn seal_gas_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 661_000 picoseconds. - Weight::from_parts(729_000, 0) + // Minimum execution time: 665_000 picoseconds. + Weight::from_parts(714_000, 0) } fn seal_balance() -> Weight { // Proof Size summary in bytes: // Measured: `140` // Estimated: `0` - // Minimum execution time: 4_545_000 picoseconds. - Weight::from_parts(4_663_000, 0) + // Minimum execution time: 4_486_000 picoseconds. + Weight::from_parts(4_668_000, 0) } fn seal_value_transferred() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 614_000 picoseconds. - Weight::from_parts(641_000, 0) + // Minimum execution time: 548_000 picoseconds. + Weight::from_parts(590_000, 0) } fn seal_minimum_balance() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 583_000 picoseconds. - Weight::from_parts(618_000, 0) + // Minimum execution time: 536_000 picoseconds. + Weight::from_parts(578_000, 0) } fn seal_block_number() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 583_000 picoseconds. - Weight::from_parts(617_000, 0) + // Minimum execution time: 552_000 picoseconds. + Weight::from_parts(599_000, 0) } fn seal_now() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 607_000 picoseconds. - Weight::from_parts(638_000, 0) + // Minimum execution time: 556_000 picoseconds. + Weight::from_parts(600_000, 0) } /// Storage: `TransactionPayment::NextFeeMultiplier` (r:1 w:0) /// Proof: `TransactionPayment::NextFeeMultiplier` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `Measured`) @@ -620,8 +630,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `67` // Estimated: `1552` - // Minimum execution time: 4_172_000 picoseconds. - Weight::from_parts(4_408_000, 1552) + // Minimum execution time: 4_084_000 picoseconds. + Weight::from_parts(4_321_000, 1552) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// The range of component `n` is `[0, 1048572]`. @@ -629,20 +639,20 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 475_000 picoseconds. - Weight::from_parts(515_000, 0) + // Minimum execution time: 468_000 picoseconds. + Weight::from_parts(492_000, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(298, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(310, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048572]`. fn seal_return(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 289_000 picoseconds. - Weight::from_parts(357_000, 0) - // Standard Error: 10 - .saturating_add(Weight::from_parts(405, 0).saturating_mul(n.into())) + // Minimum execution time: 377_000 picoseconds. + Weight::from_parts(396_000, 0) + // Standard Error: 9 + .saturating_add(Weight::from_parts(431, 0).saturating_mul(n.into())) } /// Storage: `Contracts::DeletionQueueCounter` (r:1 w:1) /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) @@ -655,10 +665,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `319 + n * (78 Ā±0)` // Estimated: `3784 + n * (2553 Ā±0)` - // Minimum execution time: 13_316_000 picoseconds. - Weight::from_parts(15_855_821, 3784) - // Standard Error: 7_274 - .saturating_add(Weight::from_parts(3_447_246, 0).saturating_mul(n.into())) + // Minimum execution time: 13_028_000 picoseconds. + Weight::from_parts(15_330_917, 3784) + // Standard Error: 8_260 + .saturating_add(Weight::from_parts(3_594_893, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -671,8 +681,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 3_468_000 picoseconds. - Weight::from_parts(3_608_000, 1561) + // Minimum execution time: 3_367_000 picoseconds. + Weight::from_parts(3_555_000, 1561) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `System::EventTopics` (r:4 w:4) @@ -683,12 +693,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `990 + t * (2475 Ā±0)` - // Minimum execution time: 3_777_000 picoseconds. - Weight::from_parts(4_028_191, 990) - // Standard Error: 5_907 - .saturating_add(Weight::from_parts(2_183_733, 0).saturating_mul(t.into())) + // Minimum execution time: 3_779_000 picoseconds. + Weight::from_parts(4_003_836, 990) + // Standard Error: 5_409 + .saturating_add(Weight::from_parts(2_082_176, 0).saturating_mul(t.into())) // Standard Error: 1 - .saturating_add(Weight::from_parts(18, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(14, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 2475).saturating_mul(t.into())) @@ -698,10 +708,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 400_000 picoseconds. - Weight::from_parts(423_000, 0) + // Minimum execution time: 409_000 picoseconds. + Weight::from_parts(447_000, 0) // Standard Error: 10 - .saturating_add(Weight::from_parts(1_209, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_219, 0).saturating_mul(i.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -711,12 +721,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `250 + o * (1 Ā±0)` // Estimated: `249 + o * (1 Ā±0)` - // Minimum execution time: 9_033_000 picoseconds. - Weight::from_parts(8_797_934, 249) + // Minimum execution time: 9_176_000 picoseconds. + Weight::from_parts(9_121_191, 249) // Standard Error: 1 - .saturating_add(Weight::from_parts(257, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(292, 0).saturating_mul(n.into())) // Standard Error: 1 - .saturating_add(Weight::from_parts(51, 0).saturating_mul(o.into())) + .saturating_add(Weight::from_parts(31, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(o.into())) @@ -728,10 +738,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + n * (1 Ā±0)` // Estimated: `248 + n * (1 Ā±0)` - // Minimum execution time: 7_167_000 picoseconds. - Weight::from_parts(8_012_194, 248) + // Minimum execution time: 7_294_000 picoseconds. + Weight::from_parts(7_963_151, 248) // Standard Error: 1 - .saturating_add(Weight::from_parts(90, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(92, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -743,10 +753,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + n * (1 Ā±0)` // Estimated: `248 + n * (1 Ā±0)` - // Minimum execution time: 6_868_000 picoseconds. - Weight::from_parts(7_801_811, 248) + // Minimum execution time: 6_978_000 picoseconds. + Weight::from_parts(7_741_355, 248) // Standard Error: 1 - .saturating_add(Weight::from_parts(605, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(654, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -757,10 +767,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + n * (1 Ā±0)` // Estimated: `248 + n * (1 Ā±0)` - // Minimum execution time: 6_322_000 picoseconds. - Weight::from_parts(7_103_552, 248) + // Minimum execution time: 6_286_000 picoseconds. + Weight::from_parts(7_026_923, 248) // Standard Error: 1 - .saturating_add(Weight::from_parts(79, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(86, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -771,20 +781,106 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `248 + n * (1 Ā±0)` // Estimated: `248 + n * (1 Ā±0)` - // Minimum execution time: 7_702_000 picoseconds. - Weight::from_parts(8_746_305, 248) - // Standard Error: 2 - .saturating_add(Weight::from_parts(604, 0).saturating_mul(n.into())) + // Minimum execution time: 7_597_000 picoseconds. + Weight::from_parts(8_706_785, 248) + // Standard Error: 1 + .saturating_add(Weight::from_parts(653, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } + fn set_transient_storage_empty() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_497_000 picoseconds. + Weight::from_parts(1_564_000, 0) + } + fn set_transient_storage_full() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_670_000 picoseconds. + Weight::from_parts(2_807_000, 0) + } + fn get_transient_storage_empty() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_836_000 picoseconds. + Weight::from_parts(3_878_000, 0) + } + fn get_transient_storage_full() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_537_000 picoseconds. + Weight::from_parts(4_665_000, 0) + } + fn rollback_transient_storage() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_592_000 picoseconds. + Weight::from_parts(1_742_000, 0) + } + /// The range of component `n` is `[0, 16384]`. + /// The range of component `o` is `[0, 16384]`. + fn seal_set_transient_storage(n: u32, o: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_101_000 picoseconds. + Weight::from_parts(2_481_218, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(242, 0).saturating_mul(n.into())) + // Standard Error: 0 + .saturating_add(Weight::from_parts(300, 0).saturating_mul(o.into())) + } + /// The range of component `n` is `[0, 16384]`. + fn seal_clear_transient_storage(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_059_000 picoseconds. + Weight::from_parts(2_426_609, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(307, 0).saturating_mul(n.into())) + } + /// The range of component `n` is `[0, 16384]`. + fn seal_get_transient_storage(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_918_000 picoseconds. + Weight::from_parts(2_114_837, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(302, 0).saturating_mul(n.into())) + } + /// The range of component `n` is `[0, 16384]`. + fn seal_contains_transient_storage(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_759_000 picoseconds. + Weight::from_parts(1_959_995, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(147, 0).saturating_mul(n.into())) + } + /// The range of component `n` is `[0, 16384]`. + fn seal_take_transient_storage(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_759_000 picoseconds. + Weight::from_parts(9_952_099, 0) + } fn seal_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `140` // Estimated: `0` - // Minimum execution time: 8_851_000 picoseconds. - Weight::from_parts(9_083_000, 0) + // Minimum execution time: 8_700_000 picoseconds. + Weight::from_parts(8_903_000, 0) } /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) @@ -800,12 +896,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `620 + t * (280 Ā±0)` // Estimated: `4085 + t * (2182 Ā±0)` - // Minimum execution time: 121_148_000 picoseconds. - Weight::from_parts(119_605_377, 4085) - // Standard Error: 208_337 - .saturating_add(Weight::from_parts(43_153_338, 0).saturating_mul(t.into())) + // Minimum execution time: 123_399_000 picoseconds. + Weight::from_parts(120_909_821, 4085) + // Standard Error: 166_830 + .saturating_add(Weight::from_parts(43_853_642, 0).saturating_mul(t.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(5, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(6, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -820,8 +916,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `430` // Estimated: `3895` - // Minimum execution time: 108_159_000 picoseconds. - Weight::from_parts(110_027_000, 3895) + // Minimum execution time: 112_350_000 picoseconds. + Weight::from_parts(116_003_000, 3895) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) @@ -839,13 +935,13 @@ impl WeightInfo for SubstrateWeight { fn seal_instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `676` - // Estimated: `4127` - // Minimum execution time: 1_861_874_000 picoseconds. - Weight::from_parts(1_872_926_000, 4127) - // Standard Error: 23 - .saturating_add(Weight::from_parts(557, 0).saturating_mul(i.into())) - // Standard Error: 23 - .saturating_add(Weight::from_parts(920, 0).saturating_mul(s.into())) + // Estimated: `4132` + // Minimum execution time: 1_972_276_000 picoseconds. + Weight::from_parts(1_977_872_000, 4132) + // Standard Error: 24 + .saturating_add(Weight::from_parts(623, 0).saturating_mul(i.into())) + // Standard Error: 24 + .saturating_add(Weight::from_parts(917, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -854,64 +950,64 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 878_000 picoseconds. - Weight::from_parts(10_993_950, 0) + // Minimum execution time: 899_000 picoseconds. + Weight::from_parts(10_963_972, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_325, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_355, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_261_000 picoseconds. - Weight::from_parts(9_759_497, 0) + // Minimum execution time: 1_396_000 picoseconds. + Weight::from_parts(9_404_986, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(3_594, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_627, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 726_000 picoseconds. - Weight::from_parts(9_795_728, 0) + // Minimum execution time: 834_000 picoseconds. + Weight::from_parts(9_749_716, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_455, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_500, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 739_000 picoseconds. - Weight::from_parts(9_701_202, 0) + // Minimum execution time: 756_000 picoseconds. + Weight::from_parts(8_995_036, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_459, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_495, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 125697]`. fn seal_sr25519_verify(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 43_309_000 picoseconds. - Weight::from_parts(41_405_949, 0) + // Minimum execution time: 45_800_000 picoseconds. + Weight::from_parts(44_676_829, 0) // Standard Error: 8 - .saturating_add(Weight::from_parts(5_336, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(5_315, 0).saturating_mul(n.into())) } fn seal_ecdsa_recover() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 47_880_000 picoseconds. - Weight::from_parts(49_025_000, 0) + // Minimum execution time: 47_415_000 picoseconds. + Weight::from_parts(48_743_000, 0) } fn seal_ecdsa_to_eth_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_462_000 picoseconds. - Weight::from_parts(13_631_000, 0) + // Minimum execution time: 13_437_000 picoseconds. + Weight::from_parts(13_588_000, 0) } /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) @@ -921,8 +1017,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `430` // Estimated: `3895` - // Minimum execution time: 17_978_000 picoseconds. - Weight::from_parts(18_578_000, 3895) + // Minimum execution time: 17_775_000 picoseconds. + Weight::from_parts(18_332_000, 3895) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -932,8 +1028,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `355` // Estimated: `3820` - // Minimum execution time: 8_384_000 picoseconds. - Weight::from_parts(8_687_000, 3820) + // Minimum execution time: 8_326_000 picoseconds. + Weight::from_parts(8_656_000, 3820) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -943,8 +1039,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `355` // Estimated: `3558` - // Minimum execution time: 7_547_000 picoseconds. - Weight::from_parts(7_935_000, 3558) + // Minimum execution time: 7_276_000 picoseconds. + Weight::from_parts(7_630_000, 3558) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -952,15 +1048,15 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 331_000 picoseconds. - Weight::from_parts(363_000, 0) + // Minimum execution time: 330_000 picoseconds. + Weight::from_parts(373_000, 0) } fn seal_account_reentrance_count() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 349_000 picoseconds. - Weight::from_parts(365_000, 0) + // Minimum execution time: 381_000 picoseconds. + Weight::from_parts(418_000, 0) } /// Storage: `Contracts::Nonce` (r:1 w:0) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) @@ -968,8 +1064,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `219` // Estimated: `1704` - // Minimum execution time: 2_814_000 picoseconds. - Weight::from_parts(3_038_000, 1704) + // Minimum execution time: 2_711_000 picoseconds. + Weight::from_parts(2_941_000, 1704) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// The range of component `r` is `[0, 5000]`. @@ -977,10 +1073,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 693_000 picoseconds. - Weight::from_parts(665_431, 0) - // Standard Error: 12 - .saturating_add(Weight::from_parts(7_030, 0).saturating_mul(r.into())) + // Minimum execution time: 720_000 picoseconds. + Weight::from_parts(389_111, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(7_278, 0).saturating_mul(r.into())) } } @@ -992,8 +1088,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 1_896_000 picoseconds. - Weight::from_parts(1_990_000, 1627) + // Minimum execution time: 1_921_000 picoseconds. + Weight::from_parts(2_003_000, 1627) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Skipped::Metadata` (r:0 w:0) @@ -1003,10 +1099,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `452 + k * (69 Ā±0)` // Estimated: `442 + k * (70 Ā±0)` - // Minimum execution time: 11_142_000 picoseconds. - Weight::from_parts(11_578_000, 442) - // Standard Error: 1_557 - .saturating_add(Weight::from_parts(1_165_198, 0).saturating_mul(k.into())) + // Minimum execution time: 11_364_000 picoseconds. + Weight::from_parts(11_463_000, 442) + // Standard Error: 2_141 + .saturating_add(Weight::from_parts(1_149_944, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1020,10 +1116,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `211 + c * (1 Ā±0)` // Estimated: `6149 + c * (1 Ā±0)` - // Minimum execution time: 7_649_000 picoseconds. - Weight::from_parts(4_827_445, 6149) + // Minimum execution time: 7_565_000 picoseconds. + Weight::from_parts(5_041_009, 6149) // Standard Error: 5 - .saturating_add(Weight::from_parts(1_630, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(1_640, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -1036,8 +1132,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `510` // Estimated: `6450` - // Minimum execution time: 16_096_000 picoseconds. - Weight::from_parts(16_937_000, 6450) + // Minimum execution time: 15_894_000 picoseconds. + Weight::from_parts(16_618_000, 6450) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1050,10 +1146,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `171 + k * (1 Ā±0)` // Estimated: `3635 + k * (1 Ā±0)` - // Minimum execution time: 3_131_000 picoseconds. - Weight::from_parts(3_209_000, 3635) - // Standard Error: 481 - .saturating_add(Weight::from_parts(1_087_506, 0).saturating_mul(k.into())) + // Minimum execution time: 3_077_000 picoseconds. + Weight::from_parts(3_144_000, 3635) + // Standard Error: 650 + .saturating_add(Weight::from_parts(1_095_835, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -1072,10 +1168,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `325 + c * (1 Ā±0)` // Estimated: `6263 + c * (1 Ā±0)` - // Minimum execution time: 15_289_000 picoseconds. - Weight::from_parts(16_157_168, 6263) + // Minimum execution time: 14_960_000 picoseconds. + Weight::from_parts(15_778_951, 6263) // Standard Error: 1 - .saturating_add(Weight::from_parts(395, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(443, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -1086,8 +1182,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `440` // Estimated: `6380` - // Minimum execution time: 12_312_000 picoseconds. - Weight::from_parts(12_650_000, 6380) + // Minimum execution time: 11_849_000 picoseconds. + Weight::from_parts(12_273_000, 6380) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1101,8 +1197,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `352` // Estimated: `6292` - // Minimum execution time: 47_239_000 picoseconds. - Weight::from_parts(48_617_000, 6292) + // Minimum execution time: 47_862_000 picoseconds. + Weight::from_parts(48_879_000, 6292) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1114,8 +1210,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `594` // Estimated: `6534` - // Minimum execution time: 52_084_000 picoseconds. - Weight::from_parts(53_838_000, 6534) + // Minimum execution time: 50_754_000 picoseconds. + Weight::from_parts(52_720_000, 6534) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1125,8 +1221,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `409` // Estimated: `6349` - // Minimum execution time: 11_785_000 picoseconds. - Weight::from_parts(12_284_000, 6349) + // Minimum execution time: 11_459_000 picoseconds. + Weight::from_parts(11_921_000, 6349) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1136,8 +1232,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 2_136_000 picoseconds. - Weight::from_parts(2_233_000, 1627) + // Minimum execution time: 2_135_000 picoseconds. + Weight::from_parts(2_247_000, 1627) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1149,8 +1245,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `166` // Estimated: `3631` - // Minimum execution time: 10_957_000 picoseconds. - Weight::from_parts(11_314_000, 3631) + // Minimum execution time: 10_645_000 picoseconds. + Weight::from_parts(11_107_000, 3631) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1160,8 +1256,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 4_354_000 picoseconds. - Weight::from_parts(4_613_000, 3607) + // Minimum execution time: 4_353_000 picoseconds. + Weight::from_parts(4_628_000, 3607) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -1172,8 +1268,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `167` // Estimated: `3632` - // Minimum execution time: 5_541_000 picoseconds. - Weight::from_parts(5_790_000, 3632) + // Minimum execution time: 5_432_000 picoseconds. + Weight::from_parts(5_624_000, 3632) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) @@ -1184,8 +1280,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 5_502_000 picoseconds. - Weight::from_parts(5_701_000, 3607) + // Minimum execution time: 5_371_000 picoseconds. + Weight::from_parts(5_794_000, 3607) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1204,12 +1300,12 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `801 + c * (1 Ā±0)` - // Estimated: `4264 + c * (1 Ā±0)` - // Minimum execution time: 247_884_000 picoseconds. - Weight::from_parts(265_795_781, 4264) + // Measured: `800 + c * (1 Ā±0)` + // Estimated: `4266 + c * (1 Ā±0)` + // Minimum execution time: 247_157_000 picoseconds. + Weight::from_parts(269_252_698, 4266) // Standard Error: 4 - .saturating_add(Weight::from_parts(724, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(729, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) @@ -1237,14 +1333,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `323` // Estimated: `6262` - // Minimum execution time: 4_500_184_000 picoseconds. - Weight::from_parts(160_729_258, 6262) - // Standard Error: 143 - .saturating_add(Weight::from_parts(52_809, 0).saturating_mul(c.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(2_173, 0).saturating_mul(i.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(2_165, 0).saturating_mul(s.into())) + // Minimum execution time: 4_575_784_000 picoseconds. + Weight::from_parts(207_379_459, 6262) + // Standard Error: 124 + .saturating_add(Weight::from_parts(52_392, 0).saturating_mul(c.into())) + // Standard Error: 15 + .saturating_add(Weight::from_parts(2_257, 0).saturating_mul(i.into())) + // Standard Error: 15 + .saturating_add(Weight::from_parts(2_263, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -1269,13 +1365,13 @@ impl WeightInfo for () { fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `560` - // Estimated: `4029` - // Minimum execution time: 2_219_163_000 picoseconds. - Weight::from_parts(2_236_918_000, 4029) - // Standard Error: 32 - .saturating_add(Weight::from_parts(937, 0).saturating_mul(i.into())) - // Standard Error: 32 - .saturating_add(Weight::from_parts(938, 0).saturating_mul(s.into())) + // Estimated: `4017` + // Minimum execution time: 2_306_770_000 picoseconds. + Weight::from_parts(2_462_908_000, 4017) + // Standard Error: 33 + .saturating_add(Weight::from_parts(898, 0).saturating_mul(i.into())) + // Standard Error: 33 + .saturating_add(Weight::from_parts(859, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -1295,8 +1391,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `826` // Estimated: `4291` - // Minimum execution time: 164_801_000 picoseconds. - Weight::from_parts(167_250_000, 4291) + // Minimum execution time: 165_499_000 picoseconds. + Weight::from_parts(169_903_000, 4291) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1313,10 +1409,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 225_207_000 picoseconds. - Weight::from_parts(263_665_658, 3607) - // Standard Error: 47 - .saturating_add(Weight::from_parts(50_732, 0).saturating_mul(c.into())) + // Minimum execution time: 227_590_000 picoseconds. + Weight::from_parts(260_045_588, 3607) + // Standard Error: 52 + .saturating_add(Weight::from_parts(51_305, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1333,10 +1429,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 230_718_000 picoseconds. - Weight::from_parts(258_359_271, 3607) - // Standard Error: 47 - .saturating_add(Weight::from_parts(51_014, 0).saturating_mul(c.into())) + // Minimum execution time: 239_634_000 picoseconds. + Weight::from_parts(262_040_831, 3607) + // Standard Error: 103 + .saturating_add(Weight::from_parts(51_590, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1352,8 +1448,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `315` // Estimated: `3780` - // Minimum execution time: 39_668_000 picoseconds. - Weight::from_parts(41_031_000, 3780) + // Minimum execution time: 39_152_000 picoseconds. + Weight::from_parts(39_970_000, 3780) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1367,8 +1463,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `552` // Estimated: `6492` - // Minimum execution time: 25_890_000 picoseconds. - Weight::from_parts(26_603_000, 6492) + // Minimum execution time: 25_143_000 picoseconds. + Weight::from_parts(26_103_000, 6492) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1377,17 +1473,17 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_269_000 picoseconds. - Weight::from_parts(9_227_069, 0) - // Standard Error: 74 - .saturating_add(Weight::from_parts(51_396, 0).saturating_mul(r.into())) + // Minimum execution time: 8_406_000 picoseconds. + Weight::from_parts(9_056_753, 0) + // Standard Error: 98 + .saturating_add(Weight::from_parts(53_110, 0).saturating_mul(r.into())) } fn seal_caller() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 602_000 picoseconds. - Weight::from_parts(664_000, 0) + // Minimum execution time: 659_000 picoseconds. + Weight::from_parts(705_000, 0) } /// Storage: `Contracts::ContractInfoOf` (r:1 w:0) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) @@ -1395,8 +1491,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `354` // Estimated: `3819` - // Minimum execution time: 6_131_000 picoseconds. - Weight::from_parts(6_468_000, 3819) + // Minimum execution time: 6_165_000 picoseconds. + Weight::from_parts(6_340_000, 3819) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `Contracts::ContractInfoOf` (r:1 w:0) @@ -1405,79 +1501,79 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `447` // Estimated: `3912` - // Minimum execution time: 7_557_000 picoseconds. - Weight::from_parts(7_704_000, 3912) + // Minimum execution time: 7_398_000 picoseconds. + Weight::from_parts(7_661_000, 3912) .saturating_add(RocksDbWeight::get().reads(1_u64)) } fn seal_own_code_hash() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 783_000 picoseconds. - Weight::from_parts(848_000, 0) + // Minimum execution time: 723_000 picoseconds. + Weight::from_parts(793_000, 0) } fn seal_caller_is_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 397_000 picoseconds. - Weight::from_parts(435_000, 0) + // Minimum execution time: 398_000 picoseconds. + Weight::from_parts(428_000, 0) } fn seal_caller_is_root() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 351_000 picoseconds. - Weight::from_parts(372_000, 0) + // Minimum execution time: 329_000 picoseconds. + Weight::from_parts(364_000, 0) } fn seal_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 608_000 picoseconds. - Weight::from_parts(645_000, 0) + // Minimum execution time: 592_000 picoseconds. + Weight::from_parts(624_000, 0) } fn seal_gas_left() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 661_000 picoseconds. - Weight::from_parts(729_000, 0) + // Minimum execution time: 665_000 picoseconds. + Weight::from_parts(714_000, 0) } fn seal_balance() -> Weight { // Proof Size summary in bytes: // Measured: `140` // Estimated: `0` - // Minimum execution time: 4_545_000 picoseconds. - Weight::from_parts(4_663_000, 0) + // Minimum execution time: 4_486_000 picoseconds. + Weight::from_parts(4_668_000, 0) } fn seal_value_transferred() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 614_000 picoseconds. - Weight::from_parts(641_000, 0) + // Minimum execution time: 548_000 picoseconds. + Weight::from_parts(590_000, 0) } fn seal_minimum_balance() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 583_000 picoseconds. - Weight::from_parts(618_000, 0) + // Minimum execution time: 536_000 picoseconds. + Weight::from_parts(578_000, 0) } fn seal_block_number() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 583_000 picoseconds. - Weight::from_parts(617_000, 0) + // Minimum execution time: 552_000 picoseconds. + Weight::from_parts(599_000, 0) } fn seal_now() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 607_000 picoseconds. - Weight::from_parts(638_000, 0) + // Minimum execution time: 556_000 picoseconds. + Weight::from_parts(600_000, 0) } /// Storage: `TransactionPayment::NextFeeMultiplier` (r:1 w:0) /// Proof: `TransactionPayment::NextFeeMultiplier` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `Measured`) @@ -1485,8 +1581,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `67` // Estimated: `1552` - // Minimum execution time: 4_172_000 picoseconds. - Weight::from_parts(4_408_000, 1552) + // Minimum execution time: 4_084_000 picoseconds. + Weight::from_parts(4_321_000, 1552) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// The range of component `n` is `[0, 1048572]`. @@ -1494,20 +1590,20 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 475_000 picoseconds. - Weight::from_parts(515_000, 0) + // Minimum execution time: 468_000 picoseconds. + Weight::from_parts(492_000, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(298, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(310, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048572]`. fn seal_return(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 289_000 picoseconds. - Weight::from_parts(357_000, 0) - // Standard Error: 10 - .saturating_add(Weight::from_parts(405, 0).saturating_mul(n.into())) + // Minimum execution time: 377_000 picoseconds. + Weight::from_parts(396_000, 0) + // Standard Error: 9 + .saturating_add(Weight::from_parts(431, 0).saturating_mul(n.into())) } /// Storage: `Contracts::DeletionQueueCounter` (r:1 w:1) /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) @@ -1520,10 +1616,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `319 + n * (78 Ā±0)` // Estimated: `3784 + n * (2553 Ā±0)` - // Minimum execution time: 13_316_000 picoseconds. - Weight::from_parts(15_855_821, 3784) - // Standard Error: 7_274 - .saturating_add(Weight::from_parts(3_447_246, 0).saturating_mul(n.into())) + // Minimum execution time: 13_028_000 picoseconds. + Weight::from_parts(15_330_917, 3784) + // Standard Error: 8_260 + .saturating_add(Weight::from_parts(3_594_893, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -1536,8 +1632,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 3_468_000 picoseconds. - Weight::from_parts(3_608_000, 1561) + // Minimum execution time: 3_367_000 picoseconds. + Weight::from_parts(3_555_000, 1561) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: `System::EventTopics` (r:4 w:4) @@ -1548,12 +1644,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `990 + t * (2475 Ā±0)` - // Minimum execution time: 3_777_000 picoseconds. - Weight::from_parts(4_028_191, 990) - // Standard Error: 5_907 - .saturating_add(Weight::from_parts(2_183_733, 0).saturating_mul(t.into())) + // Minimum execution time: 3_779_000 picoseconds. + Weight::from_parts(4_003_836, 990) + // Standard Error: 5_409 + .saturating_add(Weight::from_parts(2_082_176, 0).saturating_mul(t.into())) // Standard Error: 1 - .saturating_add(Weight::from_parts(18, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(14, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 2475).saturating_mul(t.into())) @@ -1563,10 +1659,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 400_000 picoseconds. - Weight::from_parts(423_000, 0) + // Minimum execution time: 409_000 picoseconds. + Weight::from_parts(447_000, 0) // Standard Error: 10 - .saturating_add(Weight::from_parts(1_209, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_219, 0).saturating_mul(i.into())) } /// Storage: `Skipped::Metadata` (r:0 w:0) /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -1576,12 +1672,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `250 + o * (1 Ā±0)` // Estimated: `249 + o * (1 Ā±0)` - // Minimum execution time: 9_033_000 picoseconds. - Weight::from_parts(8_797_934, 249) + // Minimum execution time: 9_176_000 picoseconds. + Weight::from_parts(9_121_191, 249) // Standard Error: 1 - .saturating_add(Weight::from_parts(257, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(292, 0).saturating_mul(n.into())) // Standard Error: 1 - .saturating_add(Weight::from_parts(51, 0).saturating_mul(o.into())) + .saturating_add(Weight::from_parts(31, 0).saturating_mul(o.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(o.into())) @@ -1593,10 +1689,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + n * (1 Ā±0)` // Estimated: `248 + n * (1 Ā±0)` - // Minimum execution time: 7_167_000 picoseconds. - Weight::from_parts(8_012_194, 248) + // Minimum execution time: 7_294_000 picoseconds. + Weight::from_parts(7_963_151, 248) // Standard Error: 1 - .saturating_add(Weight::from_parts(90, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(92, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1608,10 +1704,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + n * (1 Ā±0)` // Estimated: `248 + n * (1 Ā±0)` - // Minimum execution time: 6_868_000 picoseconds. - Weight::from_parts(7_801_811, 248) + // Minimum execution time: 6_978_000 picoseconds. + Weight::from_parts(7_741_355, 248) // Standard Error: 1 - .saturating_add(Weight::from_parts(605, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(654, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -1622,10 +1718,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + n * (1 Ā±0)` // Estimated: `248 + n * (1 Ā±0)` - // Minimum execution time: 6_322_000 picoseconds. - Weight::from_parts(7_103_552, 248) + // Minimum execution time: 6_286_000 picoseconds. + Weight::from_parts(7_026_923, 248) // Standard Error: 1 - .saturating_add(Weight::from_parts(79, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(86, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } @@ -1636,20 +1732,106 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `248 + n * (1 Ā±0)` // Estimated: `248 + n * (1 Ā±0)` - // Minimum execution time: 7_702_000 picoseconds. - Weight::from_parts(8_746_305, 248) - // Standard Error: 2 - .saturating_add(Weight::from_parts(604, 0).saturating_mul(n.into())) + // Minimum execution time: 7_597_000 picoseconds. + Weight::from_parts(8_706_785, 248) + // Standard Error: 1 + .saturating_add(Weight::from_parts(653, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } + fn set_transient_storage_empty() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_497_000 picoseconds. + Weight::from_parts(1_564_000, 0) + } + fn set_transient_storage_full() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_670_000 picoseconds. + Weight::from_parts(2_807_000, 0) + } + fn get_transient_storage_empty() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_836_000 picoseconds. + Weight::from_parts(3_878_000, 0) + } + fn get_transient_storage_full() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_537_000 picoseconds. + Weight::from_parts(4_665_000, 0) + } + fn rollback_transient_storage() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_592_000 picoseconds. + Weight::from_parts(1_742_000, 0) + } + /// The range of component `n` is `[0, 16384]`. + /// The range of component `o` is `[0, 16384]`. + fn seal_set_transient_storage(n: u32, o: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_101_000 picoseconds. + Weight::from_parts(2_481_218, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(242, 0).saturating_mul(n.into())) + // Standard Error: 0 + .saturating_add(Weight::from_parts(300, 0).saturating_mul(o.into())) + } + /// The range of component `n` is `[0, 16384]`. + fn seal_clear_transient_storage(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_059_000 picoseconds. + Weight::from_parts(2_426_609, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(307, 0).saturating_mul(n.into())) + } + /// The range of component `n` is `[0, 16384]`. + fn seal_get_transient_storage(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_918_000 picoseconds. + Weight::from_parts(2_114_837, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(302, 0).saturating_mul(n.into())) + } + /// The range of component `n` is `[0, 16384]`. + fn seal_contains_transient_storage(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_759_000 picoseconds. + Weight::from_parts(1_959_995, 0) + // Standard Error: 0 + .saturating_add(Weight::from_parts(147, 0).saturating_mul(n.into())) + } + /// The range of component `n` is `[0, 16384]`. + fn seal_take_transient_storage(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_759_000 picoseconds. + Weight::from_parts(9_952_099, 0) + } fn seal_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `140` // Estimated: `0` - // Minimum execution time: 8_851_000 picoseconds. - Weight::from_parts(9_083_000, 0) + // Minimum execution time: 8_700_000 picoseconds. + Weight::from_parts(8_903_000, 0) } /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(1795), added: 4270, mode: `Measured`) @@ -1665,12 +1847,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `620 + t * (280 Ā±0)` // Estimated: `4085 + t * (2182 Ā±0)` - // Minimum execution time: 121_148_000 picoseconds. - Weight::from_parts(119_605_377, 4085) - // Standard Error: 208_337 - .saturating_add(Weight::from_parts(43_153_338, 0).saturating_mul(t.into())) + // Minimum execution time: 123_399_000 picoseconds. + Weight::from_parts(120_909_821, 4085) + // Standard Error: 166_830 + .saturating_add(Weight::from_parts(43_853_642, 0).saturating_mul(t.into())) // Standard Error: 0 - .saturating_add(Weight::from_parts(5, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(6, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -1685,8 +1867,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `430` // Estimated: `3895` - // Minimum execution time: 108_159_000 picoseconds. - Weight::from_parts(110_027_000, 3895) + // Minimum execution time: 112_350_000 picoseconds. + Weight::from_parts(116_003_000, 3895) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) @@ -1704,13 +1886,13 @@ impl WeightInfo for () { fn seal_instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `676` - // Estimated: `4127` - // Minimum execution time: 1_861_874_000 picoseconds. - Weight::from_parts(1_872_926_000, 4127) - // Standard Error: 23 - .saturating_add(Weight::from_parts(557, 0).saturating_mul(i.into())) - // Standard Error: 23 - .saturating_add(Weight::from_parts(920, 0).saturating_mul(s.into())) + // Estimated: `4132` + // Minimum execution time: 1_972_276_000 picoseconds. + Weight::from_parts(1_977_872_000, 4132) + // Standard Error: 24 + .saturating_add(Weight::from_parts(623, 0).saturating_mul(i.into())) + // Standard Error: 24 + .saturating_add(Weight::from_parts(917, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1719,64 +1901,64 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 878_000 picoseconds. - Weight::from_parts(10_993_950, 0) + // Minimum execution time: 899_000 picoseconds. + Weight::from_parts(10_963_972, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_325, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_355, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_261_000 picoseconds. - Weight::from_parts(9_759_497, 0) + // Minimum execution time: 1_396_000 picoseconds. + Weight::from_parts(9_404_986, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(3_594, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_627, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 726_000 picoseconds. - Weight::from_parts(9_795_728, 0) + // Minimum execution time: 834_000 picoseconds. + Weight::from_parts(9_749_716, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_455, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_500, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 739_000 picoseconds. - Weight::from_parts(9_701_202, 0) + // Minimum execution time: 756_000 picoseconds. + Weight::from_parts(8_995_036, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_459, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_495, 0).saturating_mul(n.into())) } /// The range of component `n` is `[0, 125697]`. fn seal_sr25519_verify(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 43_309_000 picoseconds. - Weight::from_parts(41_405_949, 0) + // Minimum execution time: 45_800_000 picoseconds. + Weight::from_parts(44_676_829, 0) // Standard Error: 8 - .saturating_add(Weight::from_parts(5_336, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(5_315, 0).saturating_mul(n.into())) } fn seal_ecdsa_recover() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 47_880_000 picoseconds. - Weight::from_parts(49_025_000, 0) + // Minimum execution time: 47_415_000 picoseconds. + Weight::from_parts(48_743_000, 0) } fn seal_ecdsa_to_eth_address() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_462_000 picoseconds. - Weight::from_parts(13_631_000, 0) + // Minimum execution time: 13_437_000 picoseconds. + Weight::from_parts(13_588_000, 0) } /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) @@ -1786,8 +1968,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `430` // Estimated: `3895` - // Minimum execution time: 17_978_000 picoseconds. - Weight::from_parts(18_578_000, 3895) + // Minimum execution time: 17_775_000 picoseconds. + Weight::from_parts(18_332_000, 3895) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1797,8 +1979,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `355` // Estimated: `3820` - // Minimum execution time: 8_384_000 picoseconds. - Weight::from_parts(8_687_000, 3820) + // Minimum execution time: 8_326_000 picoseconds. + Weight::from_parts(8_656_000, 3820) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1808,8 +1990,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `355` // Estimated: `3558` - // Minimum execution time: 7_547_000 picoseconds. - Weight::from_parts(7_935_000, 3558) + // Minimum execution time: 7_276_000 picoseconds. + Weight::from_parts(7_630_000, 3558) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1817,15 +1999,15 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 331_000 picoseconds. - Weight::from_parts(363_000, 0) + // Minimum execution time: 330_000 picoseconds. + Weight::from_parts(373_000, 0) } fn seal_account_reentrance_count() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 349_000 picoseconds. - Weight::from_parts(365_000, 0) + // Minimum execution time: 381_000 picoseconds. + Weight::from_parts(418_000, 0) } /// Storage: `Contracts::Nonce` (r:1 w:0) /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) @@ -1833,8 +2015,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `219` // Estimated: `1704` - // Minimum execution time: 2_814_000 picoseconds. - Weight::from_parts(3_038_000, 1704) + // Minimum execution time: 2_711_000 picoseconds. + Weight::from_parts(2_941_000, 1704) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// The range of component `r` is `[0, 5000]`. @@ -1842,9 +2024,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 693_000 picoseconds. - Weight::from_parts(665_431, 0) - // Standard Error: 12 - .saturating_add(Weight::from_parts(7_030, 0).saturating_mul(r.into())) + // Minimum execution time: 720_000 picoseconds. + Weight::from_parts(389_111, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(7_278, 0).saturating_mul(r.into())) } } diff --git a/substrate/frame/contracts/uapi/src/host.rs b/substrate/frame/contracts/uapi/src/host.rs index 92065eda5d635..51f0cd7eb2dc0 100644 --- a/substrate/frame/contracts/uapi/src/host.rs +++ b/substrate/frame/contracts/uapi/src/host.rs @@ -67,7 +67,7 @@ fn ptr_or_sentinel(data: &Option<&[u8]>) -> *const u8 { pub enum HostFnImpl {} /// Defines all the host apis implemented by both wasm and RISC-V vms. -pub trait HostFn { +pub trait HostFn: private::Sealed { /// Returns the number of times specified contract exists on the call stack. Delegated calls are /// not counted as separate calls. /// @@ -292,6 +292,20 @@ pub trait HostFn { /// Returns the size of the pre-existing value at the specified key if any. fn clear_storage_v1(key: &[u8]) -> Option; + /// Clear the value at the given key in the contract transient storage. + /// + /// # Parameters + /// + /// - `key`: The storage key. + /// + /// # Return + /// + /// Returns the size of the pre-existing value at the specified key if any. + #[deprecated( + note = "Unstable function. Behaviour can change without further notice. Use only for testing." + )] + fn clear_transient_storage(key: &[u8]) -> Option; + /// Retrieve the code hash for a specified contract address. /// /// # Parameters @@ -324,6 +338,21 @@ pub trait HostFn { /// Returns the size of the pre-existing value at the specified key if any. fn contains_storage_v1(key: &[u8]) -> Option; + /// Checks whether there is a value stored under the given key in transient storage. + /// + /// The key length must not exceed the maximum defined by the contracts module parameter. + /// + /// # Parameters + /// - `key`: The storage key. + /// + /// # Return + /// + /// Returns the size of the pre-existing value at the specified key if any. + #[deprecated( + note = "Unstable function. Behaviour can change without further notice. Use only for testing." + )] + fn contains_transient_storage(key: &[u8]) -> Option; + /// Emit a custom debug message. /// /// No newlines are added to the supplied message. @@ -453,6 +482,22 @@ pub trait HostFn { /// [KeyNotFound][`crate::ReturnErrorCode::KeyNotFound] fn get_storage_v1(key: &[u8], output: &mut &mut [u8]) -> Result; + /// Retrieve the value under the given key from transient storage. + /// + /// The key length must not exceed the maximum defined by the contracts module parameter. + /// + /// # Parameters + /// - `key`: The storage key. + /// - `output`: A reference to the output data buffer to write the storage entry. + /// + /// # Errors + /// + /// [KeyNotFound][`crate::ReturnErrorCode::KeyNotFound] + #[deprecated( + note = "Unstable function. Behaviour can change without further notice. Use only for testing." + )] + fn get_transient_storage(key: &[u8], output: &mut &mut [u8]) -> Result; + hash_fn!(sha2_256, 32); hash_fn!(keccak_256, 32); hash_fn!(blake2_256, 32); @@ -673,6 +718,24 @@ pub trait HostFn { /// Returns the size of the pre-existing value at the specified key if any. fn set_storage_v2(key: &[u8], value: &[u8]) -> Option; + /// Set the value at the given key in the contract transient storage. + /// + /// The key and value lengths must not exceed the maximums defined by the contracts module + /// parameters. + /// + /// # Parameters + /// + /// - `key`: The storage key. + /// - `encoded_value`: The storage value. + /// + /// # Return + /// + /// Returns the size of the pre-existing value at the specified key if any. + #[deprecated( + note = "Unstable function. Behaviour can change without further notice. Use only for testing." + )] + fn set_transient_storage(key: &[u8], value: &[u8]) -> Option; + /// Verify a sr25519 signature /// /// # Parameters @@ -696,6 +759,20 @@ pub trait HostFn { /// [KeyNotFound][`crate::ReturnErrorCode::KeyNotFound] fn take_storage(key: &[u8], output: &mut &mut [u8]) -> Result; + /// Retrieve and remove the value under the given key from transient storage. + /// + /// # Parameters + /// - `key`: The storage key. + /// - `output`: A reference to the output data buffer to write the storage entry. + /// + /// # Errors + /// + /// [KeyNotFound][`crate::ReturnErrorCode::KeyNotFound] + #[deprecated( + note = "Unstable function. Behaviour can change without further notice. Use only for testing." + )] + fn take_transient_storage(key: &[u8], output: &mut &mut [u8]) -> Result; + /// Transfer some amount of funds into the specified account. /// /// # Parameters @@ -804,3 +881,8 @@ pub trait HostFn { )] fn xcm_send(dest: &[u8], msg: &[u8], output: &mut [u8; 32]) -> Result; } + +mod private { + pub trait Sealed {} + impl Sealed for super::HostFnImpl {} +} diff --git a/substrate/frame/contracts/uapi/src/host/riscv32.rs b/substrate/frame/contracts/uapi/src/host/riscv32.rs index 561ab28747df9..3555202332121 100644 --- a/substrate/frame/contracts/uapi/src/host/riscv32.rs +++ b/substrate/frame/contracts/uapi/src/host/riscv32.rs @@ -172,6 +172,10 @@ impl HostFn for HostFnImpl { todo!() } + fn set_transient_storage(key: &[u8], encoded_value: &[u8]) -> Option { + todo!() + } + fn clear_storage(key: &[u8]) { todo!() } @@ -180,13 +184,25 @@ impl HostFn for HostFnImpl { todo!() } + fn clear_transient_storage(key: &[u8]) -> Option { + todo!() + } + impl_get_storage!(get_storage, sys::get_storage); impl_get_storage!(get_storage_v1, sys::v1::get_storage); + fn get_transient_storage(key: &[u8], output: &mut &mut [u8]) -> Result { + todo!() + } + fn take_storage(key: &[u8], output: &mut &mut [u8]) -> Result { todo!() } + fn take_transient_storage(key: &[u8], output: &mut &mut [u8]) -> Result { + todo!() + } + fn contains_storage(key: &[u8]) -> Option { todo!() } @@ -195,6 +211,10 @@ impl HostFn for HostFnImpl { todo!() } + fn contains_transient_storage(key: &[u8]) -> Option { + todo!() + } + fn terminate(beneficiary: &[u8]) -> ! { todo!() } diff --git a/substrate/frame/contracts/uapi/src/host/wasm32.rs b/substrate/frame/contracts/uapi/src/host/wasm32.rs index cb5435bfc014d..55600bc3201f0 100644 --- a/substrate/frame/contracts/uapi/src/host/wasm32.rs +++ b/substrate/frame/contracts/uapi/src/host/wasm32.rs @@ -61,6 +61,8 @@ mod sys { pub fn clear_storage(key_ptr: *const u8); + pub fn clear_transient_storage(key_ptr: *const u8, key_len: u32) -> ReturnCode; + pub fn code_hash( account_id_ptr: *const u8, output_ptr: *mut u8, @@ -69,6 +71,8 @@ mod sys { pub fn contains_storage(key_ptr: *const u8) -> ReturnCode; + pub fn contains_transient_storage(key_ptr: *const u8, key_len: u32) -> ReturnCode; + pub fn debug_message(str_ptr: *const u8, str_len: u32) -> ReturnCode; pub fn delegate_call( @@ -103,6 +107,13 @@ mod sys { out_len_ptr: *mut u32, ) -> ReturnCode; + pub fn get_transient_storage( + key_ptr: *const u8, + key_len: u32, + out_ptr: *mut u8, + out_len_ptr: *mut u32, + ) -> ReturnCode; + pub fn hash_blake2_128(input_ptr: *const u8, input_len: u32, output_ptr: *mut u8); pub fn hash_blake2_256(input_ptr: *const u8, input_len: u32, output_ptr: *mut u8); @@ -133,6 +144,13 @@ mod sys { pub fn set_storage(key_ptr: *const u8, value_ptr: *const u8, value_len: u32); + pub fn set_transient_storage( + key_ptr: *const u8, + key_len: u32, + value_ptr: *const u8, + value_len: u32, + ) -> ReturnCode; + pub fn sr25519_verify( signature_ptr: *const u8, public_key_ptr: *const u8, @@ -147,6 +165,13 @@ mod sys { out_len_ptr: *mut u32, ) -> ReturnCode; + pub fn take_transient_storage( + key_ptr: *const u8, + key_len: u32, + out_ptr: *mut u8, + out_len_ptr: *mut u32, + ) -> ReturnCode; + pub fn terminate(beneficiary_ptr: *const u8) -> !; pub fn transfer( @@ -598,6 +623,18 @@ impl HostFn for HostFnImpl { ret_code.into() } + fn set_transient_storage(key: &[u8], encoded_value: &[u8]) -> Option { + let ret_code = unsafe { + sys::set_transient_storage( + key.as_ptr(), + key.len() as u32, + encoded_value.as_ptr(), + encoded_value.len() as u32, + ) + }; + ret_code.into() + } + fn clear_storage(key: &[u8]) { unsafe { sys::clear_storage(key.as_ptr()) }; } @@ -607,6 +644,11 @@ impl HostFn for HostFnImpl { ret_code.into() } + fn clear_transient_storage(key: &[u8]) -> Option { + let ret_code = unsafe { sys::clear_transient_storage(key.as_ptr(), key.len() as u32) }; + ret_code.into() + } + #[inline(always)] fn get_storage(key: &[u8], output: &mut &mut [u8]) -> Result { let mut output_len = output.len() as u32; @@ -633,6 +675,23 @@ impl HostFn for HostFnImpl { ret_code.into() } + #[inline(always)] + fn get_transient_storage(key: &[u8], output: &mut &mut [u8]) -> Result { + let mut output_len = output.len() as u32; + let ret_code = { + unsafe { + sys::get_transient_storage( + key.as_ptr(), + key.len() as u32, + output.as_mut_ptr(), + &mut output_len, + ) + } + }; + extract_from_slice(output, output_len as usize); + ret_code.into() + } + #[inline(always)] fn take_storage(key: &[u8], output: &mut &mut [u8]) -> Result { let mut output_len = output.len() as u32; @@ -650,6 +709,23 @@ impl HostFn for HostFnImpl { ret_code.into() } + #[inline(always)] + fn take_transient_storage(key: &[u8], output: &mut &mut [u8]) -> Result { + let mut output_len = output.len() as u32; + let ret_code = { + unsafe { + sys::take_transient_storage( + key.as_ptr(), + key.len() as u32, + output.as_mut_ptr(), + &mut output_len, + ) + } + }; + extract_from_slice(output, output_len as usize); + ret_code.into() + } + fn debug_message(str: &[u8]) -> Result { let ret_code = unsafe { sys::debug_message(str.as_ptr(), str.len() as u32) }; ret_code.into() @@ -665,6 +741,11 @@ impl HostFn for HostFnImpl { ret_code.into() } + fn contains_transient_storage(key: &[u8]) -> Option { + let ret_code = unsafe { sys::contains_transient_storage(key.as_ptr(), key.len() as u32) }; + ret_code.into() + } + fn terminate(beneficiary: &[u8]) -> ! { unsafe { sys::terminate(beneficiary.as_ptr()) } } From 79a3d6c294430a52f00563f8a5e59984680b889f Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Tue, 16 Jul 2024 13:31:51 +0200 Subject: [PATCH 10/13] Adjust base value for statement-distribution regression tests (#5028) A baseline for the statement-distribution regression test was set only in the beginning and now we see that the actual values a bit lower. image [Source](https://paritytech.github.io/polkadot-sdk/bench/statement-distribution-regression-bench) --- .../benches/statement-distribution-regression-bench.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/node/network/statement-distribution/benches/statement-distribution-regression-bench.rs b/polkadot/node/network/statement-distribution/benches/statement-distribution-regression-bench.rs index 9cbe385e3f42e..4e7206e0a366d 100644 --- a/polkadot/node/network/statement-distribution/benches/statement-distribution-regression-bench.rs +++ b/polkadot/node/network/statement-distribution/benches/statement-distribution-regression-bench.rs @@ -63,7 +63,7 @@ fn main() -> Result<(), String> { ("Received from peers", 106.4000, 0.001), ("Sent to peers", 127.9100, 0.001), ])); - messages.extend(average_usage.check_cpu_usage(&[("statement-distribution", 0.0390, 0.1)])); + messages.extend(average_usage.check_cpu_usage(&[("statement-distribution", 0.0374, 0.1)])); if messages.is_empty() { Ok(()) From 66baa2fb307fe72cb9ddc7c3be16ba57fcb2670a Mon Sep 17 00:00:00 2001 From: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:48:42 +0200 Subject: [PATCH 11/13] [ci] Update forklift in CI image (#5032) cc https://github.com/paritytech/ci_cd/issues/939 --- .github/env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/env b/.github/env index 162ce8af7c0dd..2e4d5b48100df 100644 --- a/.github/env +++ b/.github/env @@ -1 +1 @@ -IMAGE="docker.io/paritytech/ci-unified:bullseye-1.77.0-2024-04-10-v20240408" \ No newline at end of file +IMAGE="docker.io/paritytech/ci-unified:bullseye-1.77.0-2024-04-10-v202407161507" From 975e04bbb59b643362f918e8521f0cde5c27fbc8 Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Tue, 16 Jul 2024 19:56:25 +0200 Subject: [PATCH 12/13] Send PeerViewChange with high priority (#4755) Closes https://github.com/paritytech/polkadot-sdk/issues/577 ### Changed - `orchestra` updated to 0.4.0 - `PeerViewChange` sent with high priority and should be processed first in a queue. - To count them in tests added tracker to TestSender and TestOverseer. It acts more like a smoke test though. ### Testing on Versi The changes were tested on Versi with two objectives: 1. Make sure the node functionality does not change. 2. See how the changes affect performance. Test setup: - 2.5 hours for each case - 100 validators - 50 parachains - validatorsPerCore = 2 - neededApprovals = 100 - nDelayTranches = 89 - relayVrfModuloSamples = 50 During the test period, all nodes ran without any crashes, which satisfies the first objective. To estimate the change in performance we used ToF charts. The graphs show that there are no spikes in the top as before. This proves that our hypothesis is correct. ### Normalized charts with ToF ![image](https://github.com/user-attachments/assets/0d49d0db-8302-4a8c-a557-501856805ff5) [Before](https://grafana.teleport.parity.io/goto/ZoR53ClSg?orgId=1) ![image](https://github.com/user-attachments/assets/9cc73784-7e45-49d9-8212-152373c05880) [After](https://grafana.teleport.parity.io/goto/6ux5qC_IR?orgId=1) ### Conclusion The prioritization of subsystem messages reduces the ToF of the networking subsystem, which helps faster propagation of gossip messages. --- Cargo.lock | 24 ++++++-- Cargo.toml | 2 +- polkadot/node/malus/src/interceptor.rs | 13 +++- .../src/tests/state.rs | 2 +- polkadot/node/network/bridge/src/rx/mod.rs | 32 ++++++++-- polkadot/node/network/bridge/src/rx/tests.rs | 17 ++++++ polkadot/node/overseer/src/lib.rs | 17 +++--- .../node/subsystem-test-helpers/src/lib.rs | 61 +++++++++++++++++-- prdoc/pr_4755.prdoc | 24 ++++++++ 9 files changed, 165 insertions(+), 27 deletions(-) create mode 100644 prdoc/pr_4755.prdoc diff --git a/Cargo.lock b/Cargo.lock index 9972285780f35..3866a74b3f215 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5376,12 +5376,14 @@ dependencies = [ [[package]] name = "expander" -version = "2.0.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" +checksum = "e2c470c71d91ecbd179935b24170459e926382eaaa86b590b78814e180d8a8e2" dependencies = [ "blake2 0.10.6", + "file-guard", "fs-err", + "prettyplease 0.2.12", "proc-macro2 1.0.82", "quote 1.0.35", "syn 2.0.61", @@ -5514,6 +5516,16 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" +[[package]] +name = "file-guard" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21ef72acf95ec3d7dbf61275be556299490a245f017cf084bd23b4f68cf9407c" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "file-per-thread-logger" version = "0.1.6" @@ -9554,9 +9566,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "orchestra" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92829eef0328a3d1cd22a02c0e51deb92a5362df3e7d21a4e9bdc38934694e66" +checksum = "41f6bbacc8c189a3f2e45e0fd0436e5d97f194db888e721bdbc3973e7dbed4c2" dependencies = [ "async-trait", "dyn-clonable", @@ -9571,9 +9583,9 @@ dependencies = [ [[package]] name = "orchestra-proc-macro" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1344346d5af32c95bbddea91b18a88cc83eac394192d20ef2fc4c40a74332355" +checksum = "f7b1d40dd8f367db3c65bec8d3dd47d4a604ee8874480738f93191bddab4e0e0" dependencies = [ "expander", "indexmap 2.2.3", diff --git a/Cargo.toml b/Cargo.toml index 5c2677fffeb22..0999d63040130 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -855,7 +855,7 @@ num-rational = { version = "0.4.1" } num-traits = { version = "0.2.17", default-features = false } num_cpus = { version = "1.13.1" } once_cell = { version = "1.19.0" } -orchestra = { version = "0.3.5", default-features = false } +orchestra = { version = "0.4.0", default-features = false } pallet-alliance = { path = "substrate/frame/alliance", default-features = false } pallet-asset-conversion = { path = "substrate/frame/asset-conversion", default-features = false } pallet-asset-conversion-ops = { path = "substrate/frame/asset-conversion/ops", default-features = false } diff --git a/polkadot/node/malus/src/interceptor.rs b/polkadot/node/malus/src/interceptor.rs index b44ffc8956b52..2181118646d56 100644 --- a/polkadot/node/malus/src/interceptor.rs +++ b/polkadot/node/malus/src/interceptor.rs @@ -90,6 +90,10 @@ where >::Error: std::fmt::Debug, { async fn send_message(&mut self, msg: OutgoingMessage) { + self.send_message_with_priority::(msg).await; + } + + async fn send_message_with_priority(&mut self, msg: OutgoingMessage) { let msg = < <>::Message as overseer::AssociateOutgoing >::OutgoingMessages as From>::from(msg); @@ -103,7 +107,14 @@ where } } - fn try_send_message(&mut self, msg: OutgoingMessage) -> Result<(), TrySendError> { + fn try_send_message( + &mut self, + msg: OutgoingMessage, + ) -> Result<(), polkadot_node_subsystem_util::metered::TrySendError> { + self.try_send_message_with_priority::(msg) + } + + fn try_send_message_with_priority(&mut self, msg: OutgoingMessage) -> Result<(), TrySendError> { let msg = < <>::Message as overseer::AssociateOutgoing >::OutgoingMessages as From>::from(msg); diff --git a/polkadot/node/network/availability-distribution/src/tests/state.rs b/polkadot/node/network/availability-distribution/src/tests/state.rs index befbff0a2f27e..97e616f79fb75 100644 --- a/polkadot/node/network/availability-distribution/src/tests/state.rs +++ b/polkadot/node/network/availability-distribution/src/tests/state.rs @@ -216,7 +216,7 @@ impl TestState { // Test will fail if this does not happen until timeout. let mut remaining_stores = self.valid_chunks.len(); - let TestSubsystemContextHandle { tx, mut rx } = harness.virtual_overseer; + let TestSubsystemContextHandle { tx, mut rx, .. } = harness.virtual_overseer; // Spawning necessary as incoming queue can only hold a single item, we don't want to dead // lock ;-) diff --git a/polkadot/node/network/bridge/src/rx/mod.rs b/polkadot/node/network/bridge/src/rx/mod.rs index 84e935366d0cb..56965ce6ba404 100644 --- a/polkadot/node/network/bridge/src/rx/mod.rs +++ b/polkadot/node/network/bridge/src/rx/mod.rs @@ -1135,13 +1135,33 @@ async fn dispatch_validation_events_to_all( I: IntoIterator>, I::IntoIter: Send, { + macro_rules! send_message { + ($event:expr, $message:ident) => { + if let Ok(event) = $event.focus() { + let has_high_priority = matches!( + event, + // NetworkBridgeEvent::OurViewChange(..) must also be here, + // but it is sent via an unbounded channel. + // See https://github.com/paritytech/polkadot-sdk/issues/824 + NetworkBridgeEvent::PeerConnected(..) | + NetworkBridgeEvent::PeerDisconnected(..) | + NetworkBridgeEvent::PeerViewChange(..) + ); + let message = $message::from(event); + if has_high_priority { + sender.send_message_with_priority::(message).await; + } else { + sender.send_message(message).await; + } + } + }; + } + for event in events { - sender - .send_messages(event.focus().map(StatementDistributionMessage::from)) - .await; - sender.send_messages(event.focus().map(BitfieldDistributionMessage::from)).await; - sender.send_messages(event.focus().map(ApprovalDistributionMessage::from)).await; - sender.send_messages(event.focus().map(GossipSupportMessage::from)).await; + send_message!(event, StatementDistributionMessage); + send_message!(event, BitfieldDistributionMessage); + send_message!(event, ApprovalDistributionMessage); + send_message!(event, GossipSupportMessage); } } diff --git a/polkadot/node/network/bridge/src/rx/tests.rs b/polkadot/node/network/bridge/src/rx/tests.rs index 6182bf3d883b5..392ff7391a1c1 100644 --- a/polkadot/node/network/bridge/src/rx/tests.rs +++ b/polkadot/node/network/bridge/src/rx/tests.rs @@ -880,6 +880,8 @@ fn peer_view_updates_sent_via_overseer() { &mut virtual_overseer, ) .await; + + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 8); } network_handle @@ -895,6 +897,7 @@ fn peer_view_updates_sent_via_overseer() { &mut virtual_overseer, ) .await; + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 12); virtual_overseer }); } @@ -930,6 +933,8 @@ fn peer_messages_sent_via_overseer() { &mut virtual_overseer, ) .await; + + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 8); } let approval_distribution_message = @@ -970,6 +975,7 @@ fn peer_messages_sent_via_overseer() { &mut virtual_overseer, ) .await; + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 12); virtual_overseer }); } @@ -1008,6 +1014,8 @@ fn peer_disconnect_from_just_one_peerset() { &mut virtual_overseer, ) .await; + + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 8); } { @@ -1036,6 +1044,7 @@ fn peer_disconnect_from_just_one_peerset() { &mut virtual_overseer, ) .await; + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 12); // to show that we're still connected on the collation protocol, send a view update. @@ -1094,6 +1103,8 @@ fn relays_collation_protocol_messages() { &mut virtual_overseer, ) .await; + + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 8); } { @@ -1201,6 +1212,8 @@ fn different_views_on_different_peer_sets() { &mut virtual_overseer, ) .await; + + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 8); } { @@ -1247,6 +1260,8 @@ fn different_views_on_different_peer_sets() { ) .await; + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 12); + assert_sends_collation_event_to_all( NetworkBridgeEvent::PeerViewChange(peer, view_b.clone()), &mut virtual_overseer, @@ -1481,6 +1496,8 @@ fn network_protocol_versioning_subsystem_msg() { &mut virtual_overseer, ) .await; + + assert_eq!(virtual_overseer.message_counter.with_high_priority(), 8); } let approval_distribution_message = diff --git a/polkadot/node/overseer/src/lib.rs b/polkadot/node/overseer/src/lib.rs index 24985a99913d8..4e13d5eda76f6 100644 --- a/polkadot/node/overseer/src/lib.rs +++ b/polkadot/node/overseer/src/lib.rs @@ -105,10 +105,11 @@ pub use polkadot_node_metrics::{ pub use orchestra as gen; pub use orchestra::{ - contextbounds, orchestra, subsystem, FromOrchestra, MapSubsystem, MessagePacket, - OrchestraError as OverseerError, SignalsReceived, Spawner, Subsystem, SubsystemContext, - SubsystemIncomingMessages, SubsystemInstance, SubsystemMeterReadouts, SubsystemMeters, - SubsystemSender, TimeoutExt, ToOrchestra, TrySendError, + contextbounds, orchestra, subsystem, FromOrchestra, HighPriority, MapSubsystem, MessagePacket, + NormalPriority, OrchestraError as OverseerError, Priority, PriorityLevel, SignalsReceived, + Spawner, Subsystem, SubsystemContext, SubsystemIncomingMessages, SubsystemInstance, + SubsystemMeterReadouts, SubsystemMeters, SubsystemSender, TimeoutExt, ToOrchestra, + TrySendError, }; #[cfg(any(target_os = "linux", feature = "jemalloc-allocator"))] @@ -495,7 +496,7 @@ pub struct Overseer { RuntimeApiMessage, ProspectiveParachainsMessage, ChainApiMessage, - ])] + ], can_receive_priority_messages)] statement_distribution: StatementDistribution, #[subsystem(AvailabilityDistributionMessage, sends: [ @@ -524,7 +525,7 @@ pub struct Overseer { RuntimeApiMessage, NetworkBridgeTxMessage, ProvisionerMessage, - ])] + ], can_receive_priority_messages)] bitfield_distribution: BitfieldDistribution, #[subsystem(ProvisionerMessage, sends: [ @@ -580,7 +581,7 @@ pub struct Overseer { #[subsystem(blocking, message_capacity: 64000, ApprovalDistributionMessage, sends: [ NetworkBridgeTxMessage, ApprovalVotingMessage, - ])] + ], can_receive_priority_messages)] approval_distribution: ApprovalDistribution, #[subsystem(blocking, ApprovalVotingMessage, sends: [ @@ -599,7 +600,7 @@ pub struct Overseer { NetworkBridgeRxMessage, // TODO RuntimeApiMessage, ChainSelectionMessage, - ])] + ], can_receive_priority_messages)] gossip_support: GossipSupport, #[subsystem(blocking, message_capacity: 32000, DisputeCoordinatorMessage, sends: [ diff --git a/polkadot/node/subsystem-test-helpers/src/lib.rs b/polkadot/node/subsystem-test-helpers/src/lib.rs index 375121c374637..bdb0647fee6f5 100644 --- a/polkadot/node/subsystem-test-helpers/src/lib.rs +++ b/polkadot/node/subsystem-test-helpers/src/lib.rs @@ -36,7 +36,7 @@ use std::{ convert::Infallible, future::Future, pin::Pin, - sync::Arc, + sync::{atomic::AtomicUsize, Arc}, task::{Context, Poll, Waker}, time::Duration, }; @@ -146,12 +146,13 @@ pub fn single_item_sink() -> (SingleItemSink, SingleItemStream) { #[derive(Clone)] pub struct TestSubsystemSender { tx: mpsc::UnboundedSender, + message_counter: MessageCounter, } /// Construct a sender/receiver pair. pub fn sender_receiver() -> (TestSubsystemSender, mpsc::UnboundedReceiver) { let (tx, rx) = mpsc::unbounded(); - (TestSubsystemSender { tx }, rx) + (TestSubsystemSender { tx, message_counter: MessageCounter::default() }, rx) } #[async_trait::async_trait] @@ -161,6 +162,11 @@ where OutgoingMessage: Send + 'static, { async fn send_message(&mut self, msg: OutgoingMessage) { + self.send_message_with_priority::(msg).await; + } + + async fn send_message_with_priority(&mut self, msg: OutgoingMessage) { + self.message_counter.increment(P::priority()); self.tx.send(msg.into()).await.expect("test overseer no longer live"); } @@ -168,6 +174,14 @@ where &mut self, msg: OutgoingMessage, ) -> Result<(), TrySendError> { + self.try_send_message_with_priority::(msg) + } + + fn try_send_message_with_priority( + &mut self, + msg: OutgoingMessage, + ) -> Result<(), TrySendError> { + self.message_counter.increment(P::priority()); self.tx.unbounded_send(msg.into()).expect("test overseer no longer live"); Ok(()) } @@ -277,6 +291,9 @@ pub struct TestSubsystemContextHandle { /// Direct access to the receiver. pub rx: mpsc::UnboundedReceiver, + + /// Message counter over subsystems. + pub message_counter: MessageCounter, } impl TestSubsystemContextHandle { @@ -322,6 +339,34 @@ pub fn make_subsystem_context( make_buffered_subsystem_context(spawner, 0) } +/// Message counter over subsystems. +#[derive(Default, Clone)] +pub struct MessageCounter { + total: Arc, + with_high_priority: Arc, +} + +impl MessageCounter { + /// Increment the message counter. + pub fn increment(&mut self, priority_level: overseer::PriorityLevel) { + self.total.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + if matches!(priority_level, overseer::PriorityLevel::High) { + self.with_high_priority.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + } + } + + /// Reset the message counter. + pub fn reset(&mut self) { + self.total.store(0, std::sync::atomic::Ordering::SeqCst); + self.with_high_priority.store(0, std::sync::atomic::Ordering::SeqCst); + } + + /// Get the messages with high priority count. + pub fn with_high_priority(&self) -> usize { + self.with_high_priority.load(std::sync::atomic::Ordering::SeqCst) + } +} + /// Make a test subsystem context with buffered overseer channel. Some tests (e.g. /// `dispute-coordinator`) create too many parallel operations and deadlock unless /// the channel is buffered. Usually `buffer_size=1` is enough. @@ -331,15 +376,23 @@ pub fn make_buffered_subsystem_context( ) -> (TestSubsystemContext>, TestSubsystemContextHandle) { let (overseer_tx, overseer_rx) = mpsc::channel(buffer_size); let (all_messages_tx, all_messages_rx) = mpsc::unbounded(); + let message_counter = MessageCounter::default(); ( TestSubsystemContext { - tx: TestSubsystemSender { tx: all_messages_tx }, + tx: TestSubsystemSender { + tx: all_messages_tx, + message_counter: message_counter.clone(), + }, rx: overseer_rx, spawn: SpawnGlue(spawner), message_buffer: VecDeque::new(), }, - TestSubsystemContextHandle { tx: overseer_tx, rx: all_messages_rx }, + TestSubsystemContextHandle { + tx: overseer_tx, + rx: all_messages_rx, + message_counter: message_counter.clone(), + }, ) } diff --git a/prdoc/pr_4755.prdoc b/prdoc/pr_4755.prdoc new file mode 100644 index 0000000000000..1018446cb67e7 --- /dev/null +++ b/prdoc/pr_4755.prdoc @@ -0,0 +1,24 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Send PeerViewChange with high priority + +doc: + - audience: Node Dev + description: | + - orchestra updated to 0.4.0, which introduces support for prioritizing system messages. + - PeerViewChange sent with high priority and should be processed first in a queue. + - To count them in tests added tracker to TestSender and TestOverseer. It acts more like a smoke test though. + + +crates: + - name: polkadot-overseer + bump: minor + - name: polkadot-network-bridge + bump: patch + - name: polkadot-availability-distribution + bump: patch + - name: polkadot-test-malus + bump: patch + - name: polkadot-node-subsystem-test-helpers + bump: patch From 0db509263c18ff011dcb64af0b0e87f6f68a7c16 Mon Sep 17 00:00:00 2001 From: Alin Dima Date: Wed, 17 Jul 2024 12:27:11 +0300 Subject: [PATCH 13/13] add elastic scaling MVP guide (#4663) Resolves https://github.com/paritytech/polkadot-sdk/issues/4468 Gives instructions on how to enable elastic scaling MVP to parachain teams. Still a draft because it depends on further changes we make to the slot-based collator: https://github.com/paritytech/polkadot-sdk/pull/4097 Parachains cannot use this yet because the collator was not released and no relay chain network has been configured for elastic scaling yet --- Cargo.lock | 1 + cumulus/polkadot-parachain/Cargo.toml | 1 + cumulus/polkadot-parachain/src/service.rs | 71 ++++++--- .../src/guides/enable_elastic_scaling_mvp.rs | 142 ++++++++++++++++++ docs/sdk/src/guides/mod.rs | 3 + prdoc/pr_4663.prdoc | 14 ++ 6 files changed, 215 insertions(+), 17 deletions(-) create mode 100644 docs/sdk/src/guides/enable_elastic_scaling_mvp.rs create mode 100644 prdoc/pr_4663.prdoc diff --git a/Cargo.lock b/Cargo.lock index 3866a74b3f215..ad75224fefdc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13766,6 +13766,7 @@ dependencies = [ "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-relay-chain-interface", + "docify", "frame-benchmarking", "frame-benchmarking-cli", "frame-support", diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index 7085211dad26a..b20d2a28fa7f3 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -24,6 +24,7 @@ hex-literal = { workspace = true, default-features = true } log = { workspace = true, default-features = true } serde = { features = ["derive"], workspace = true, default-features = true } serde_json = { workspace = true, default-features = true } +docify = { workspace = true } # Local rococo-parachain-runtime = { workspace = true } diff --git a/cumulus/polkadot-parachain/src/service.rs b/cumulus/polkadot-parachain/src/service.rs index f5f6189d1f0d6..6a6cf15635e01 100644 --- a/cumulus/polkadot-parachain/src/service.rs +++ b/cumulus/polkadot-parachain/src/service.rs @@ -15,13 +15,16 @@ // along with Cumulus. If not, see . use cumulus_client_cli::{CollatorOptions, ExportGenesisHeadCommand}; -use cumulus_client_collator::service::CollatorService; -use cumulus_client_consensus_aura::collators::{ - lookahead::{self as aura, Params as AuraParams}, - slot_based::{self as slot_based, Params as SlotBasedParams}, +use cumulus_client_collator::service::{ + CollatorService, ServiceInterface as CollatorServiceInterface, +}; +use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams}; +#[docify::export(slot_based_colator_import)] +use cumulus_client_consensus_aura::collators::slot_based::{ + self as slot_based, Params as SlotBasedParams, }; use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport; -use cumulus_client_consensus_proposer::Proposer; +use cumulus_client_consensus_proposer::{Proposer, ProposerInterface}; use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; #[allow(deprecated)] use cumulus_client_service::old_consensus; @@ -62,6 +65,7 @@ use sc_sysinfo::HwBench; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sc_transaction_pool::FullPool; use sp_api::ProvideRuntimeApi; +use sp_inherents::CreateInherentDataProviders; use sp_keystore::KeystorePtr; use sp_runtime::{app_crypto::AppCrypto, traits::Header as HeaderT}; use std::{marker::PhantomData, pin::Pin, sync::Arc, time::Duration}; @@ -623,6 +627,48 @@ pub(crate) struct StartSlotBasedAuraConsensus( PhantomData<(RuntimeApi, AuraId)>, ); +impl StartSlotBasedAuraConsensus +where + RuntimeApi: ConstructNodeRuntimeApi>, + RuntimeApi::RuntimeApi: AuraRuntimeApi, + AuraId: AuraIdT + Sync, +{ + #[docify::export_content] + fn launch_slot_based_collator( + params: SlotBasedParams< + ParachainBlockImport, + CIDP, + ParachainClient, + ParachainBackend, + Arc, + CHP, + Proposer, + CS, + >, + task_manager: &TaskManager, + ) where + CIDP: CreateInherentDataProviders + 'static, + CIDP::InherentDataProviders: Send, + CHP: cumulus_client_consensus_common::ValidationCodeHashProvider + Send + 'static, + Proposer: ProposerInterface + Send + Sync + 'static, + CS: CollatorServiceInterface + Send + Sync + Clone + 'static, + { + let (collation_future, block_builder_future) = + slot_based::run::::Pair, _, _, _, _, _, _, _, _>(params); + + task_manager.spawn_essential_handle().spawn( + "collation-task", + Some("parachain-block-authoring"), + collation_future, + ); + task_manager.spawn_essential_handle().spawn( + "block-builder-task", + Some("parachain-block-authoring"), + block_builder_future, + ); + } +} + impl StartConsensus for StartSlotBasedAuraConsensus where @@ -683,19 +729,10 @@ where slot_drift: Duration::from_secs(1), }; - let (collation_future, block_builder_future) = - slot_based::run::::Pair, _, _, _, _, _, _, _, _>(params); + // We have a separate function only to be able to use `docify::export` on this piece of + // code. + Self::launch_slot_based_collator(params, task_manager); - task_manager.spawn_essential_handle().spawn( - "collation-task", - Some("parachain-block-authoring"), - collation_future, - ); - task_manager.spawn_essential_handle().spawn( - "block-builder-task", - Some("parachain-block-authoring"), - block_builder_future, - ); Ok(()) } } diff --git a/docs/sdk/src/guides/enable_elastic_scaling_mvp.rs b/docs/sdk/src/guides/enable_elastic_scaling_mvp.rs new file mode 100644 index 0000000000000..bc4f36c271fe3 --- /dev/null +++ b/docs/sdk/src/guides/enable_elastic_scaling_mvp.rs @@ -0,0 +1,142 @@ +//! # Enable elastic scaling MVP for a parachain +//! +//!

+//! +//! ## Quick introduction to elastic scaling +//! +//! [Elastic scaling](https://polkadot.network/blog/elastic-scaling-streamling-growth-on-polkadot) +//! is a feature that will enable parachains to seamlessly scale up/down the number of used cores. +//! This can be desirable in order to increase the compute or storage throughput of a parachain or +//! to lower the latency between a transaction being submitted and it getting built in a parachain +//! block. +//! +//! At present, with Asynchronous Backing enabled, a parachain can only include a block on the relay +//! chain every 6 seconds, irregardless of how many cores the parachain acquires. Elastic scaling +//! builds further on the 10x throughput increase of Async Backing, enabling collators to submit up +//! to 3 parachain blocks per relay chain block, resulting in a further 3x throughput increase. +//! +//! ## Current limitations of the MVP +//! +//! The full implementation of elastic scaling spans across the entire relay/parachain stack and is +//! still [work in progress](https://github.com/paritytech/polkadot-sdk/issues/1829). +//! The MVP is still considered experimental software, so stability is not guaranteed. +//! If you encounter any problems, +//! [please open an issue](https://github.com/paritytech/polkadot-sdk/issues). +//! Below are described the current limitations of the MVP: +//! +//! 1. **Limited core count**. Parachain block authoring is sequential, so the second block will +//! start being built only after the previous block is imported. The current block production is +//! capped at 2 seconds of execution. Therefore, assuming the full 2 seconds are used, a +//! parachain can only utilise at most 3 cores in a relay chain slot of 6 seconds. If the full +//! execution time is not being used, higher core counts can be achieved. +//! 2. **Single collator requirement for consistently scaling beyond a core at full authorship +//! duration of 2 seconds per block.** Using the current implementation with multiple collators +//! adds additional latency to the block production pipeline. Assuming block execution takes +//! about the same as authorship, the additional overhead is equal the duration of the authorship +//! plus the block announcement. Each collator must first import the previous block before +//! authoring a new one, so it is clear that the highest throughput can be achieved using a +//! single collator. Experiments show that the peak performance using more than one collator +//! (measured up to 10 collators) is utilising 2 cores with authorship time of 1.3 seconds per +//! block, which leaves 400ms for networking overhead. This would allow for 2.6 seconds of +//! execution, compared to the 2 seconds async backing enabled. +//! [More experiments](https://github.com/paritytech/polkadot-sdk/issues/4696) are being +//! conducted in this space. +//! 3. **Trusted collator set.** The collator set needs to be trusted until thereā€™s a mitigation +//! that would prevent or deter multiple collators from submitting the same collation to multiple +//! backing groups. A solution is being discussed +//! [here](https://github.com/polkadot-fellows/RFCs/issues/92). +//! 4. **Fixed scaling.** For true elasticity, the parachain must be able to seamlessly acquire or +//! sell coretime as the user demand grows and shrinks over time, in an automated manner. This is +//! currently lacking - a parachain can only scale up or down by ā€œmanuallyā€ acquiring coretime. +//! This is not in the scope of the relay chain functionality. Parachains can already start +//! implementing such autoscaling, but we aim to provide a framework/examples for developing +//! autoscaling strategies. +//! +//! Another hard limitation that is not envisioned to ever be lifted is that parachains which create +//! forks will generally not be able to utilise the full number of cores they acquire. +//! +//! ## Using elastic scaling MVP +//! +//! ### Prerequisites +//! +//! - Ensure Asynchronous Backing is enabled on the network and you have enabled it on the parachain +//! using [`crate::guides::async_backing_guide`]. +//! - Ensure the `AsyncBackingParams.max_candidate_depth` value is configured to a value that is at +//! least double the maximum targeted parachain velocity. For example, if the parachain will build +//! at most 3 candidates per relay chain block, the `max_candidate_depth` should be at least 6. +//! - Use a trusted single collator for maximum throughput. +//! - Ensure enough coretime is assigned to the parachain. For maximum throughput the upper bound is +//! 3 cores. +//! +//!
Phase 1 is not needed if using the `polkadot-parachain` binary built +//! from the latest polkadot-sdk release! Simply pass the `--experimental-use-slot-based` parameter +//! to the command line and jump to Phase 2.
+//! +//! The following steps assume using the cumulus parachain template. +//! +//! ### Phase 1 - (For custom parachain node) Update Parachain Node +//! +//! This assumes you are using +//! [the latest parachain template](https://github.com/paritytech/polkadot-sdk/tree/master/templates/parachain). +//! +//! This phase consists of plugging in the new slot-based collator. +//! +//! 1. In `node/src/service.rs` import the slot based collator instead of the lookahead collator. +#![doc = docify::embed!("../../cumulus/polkadot-parachain/src/service.rs", slot_based_colator_import)] +//! +//! 2. In `start_consensus()` +//! - Remove the `overseer_handle` param (also remove the +//! `OverseerHandle` type import if itā€™s not used elsewhere). +//! - Rename `AuraParams` to `SlotBasedParams`, remove the `overseer_handle` field and add a +//! `slot_drift` field with a value of `Duration::from_secs(1)`. +//! - Replace the single future returned by `aura::run` with the two futures returned by it and +//! spawn them as separate tasks: +#![doc = docify::embed!("../../cumulus/polkadot-parachain/src/service.rs", launch_slot_based_collator)] +//! +//! 3. In `start_parachain_node()` remove the `overseer_handle` param passed to `start_consensus`. +//! +//! ### Phase 2 - Activate fixed factor scaling in the runtime +//! +//! This phase consists of a couple of changes needed to be made to the parachainā€™s runtime in order +//! to utilise fixed factor scaling. +//! +//! First of all, you need to decide the upper limit to how many parachain blocks you need to +//! produce per relay chain block (in direct correlation with the number of acquired cores). This +//! should be either 1 (no scaling), 2 or 3. This is called the parachain velocity. +//! +//! If you configure a velocity which is different from the number of assigned cores, the measured +//! velocity in practice will be the minimum of these two. +//! +//! The chosen velocity will also be used to compute: +//! - The slot duration, by dividing the 6000 ms duration of the relay chain slot duration by the +//! velocity. +//! - The unincluded segment capacity, by multiplying the velocity with 2 and adding 1 to +//! it. +//! +//! Letā€™s assume a desired maximum velocity of 3 parachain blocks per relay chain block. The needed +//! changes would all be done in `runtime/src/lib.rs`: +//! +//! 1. Rename `BLOCK_PROCESSING_VELOCITY` to `MAX_BLOCK_PROCESSING_VELOCITY` and increase it to the +//! desired value. In this example, 3. +//! +//! ```ignore +//! const MAX_BLOCK_PROCESSING_VELOCITY: u32 = 3; +//! ``` +//! +//! 2. Set the `MILLISECS_PER_BLOCK` to the desired value. +//! +//! ```ignore +//! const MILLISECS_PER_BLOCK: u32 = +//! RELAY_CHAIN_SLOT_DURATION_MILLIS / MAX_BLOCK_PROCESSING_VELOCITY; +//! ``` +//! Note: for a parachain which measures time in terms of its own block number, changing block +//! time may cause complications, requiring additional changes. See here more information: +//! [`crate::guides::async_backing_guide#timing-by-block-number`]. +//! +//! 3. Increase the `UNINCLUDED_SEGMENT_CAPACITY` to the desired value. +//! +//! ```ignore +//! const UNINCLUDED_SEGMENT_CAPACITY: u32 = 2 * MAX_BLOCK_PROCESSING_VELOCITY + 1; +//! ``` diff --git a/docs/sdk/src/guides/mod.rs b/docs/sdk/src/guides/mod.rs index 8296ed447e143..9384f4c82ab3e 100644 --- a/docs/sdk/src/guides/mod.rs +++ b/docs/sdk/src/guides/mod.rs @@ -41,3 +41,6 @@ pub mod async_backing_guide; /// How to enable metadata hash verification in the runtime. pub mod enable_metadata_hash; + +/// How to enable elastic scaling MVP on a parachain. +pub mod enable_elastic_scaling_mvp; diff --git a/prdoc/pr_4663.prdoc b/prdoc/pr_4663.prdoc new file mode 100644 index 0000000000000..74b1274828d5c --- /dev/null +++ b/prdoc/pr_4663.prdoc @@ -0,0 +1,14 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Add elastic scaling MVP guide + +doc: + - audience: Node Operator + description: | + Adds a guide for parachains that want to use the experimental elastic scaling MVP. + Will be viewable at: https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/enable_elastic_scaling_mvp/index.html + +crates: + - name: polkadot-parachain-bin + bump: none