Skip to content

Commit b846a22

Browse files
yjhmelodykoushiro
andauthored
chore: remove sp-std usage (#1422)
* wip * done * fmt * Update primitives/ethereum/src/lib.rs Co-authored-by: Qinxuan Chen <[email protected]> * Update precompiles/tests-external/lib.rs Co-authored-by: Qinxuan Chen <[email protected]> * fix * no need to import alloc or sp-std --------- Co-authored-by: Qinxuan Chen <[email protected]>
1 parent a08df20 commit b846a22

File tree

50 files changed

+99
-120
lines changed

Some content is hidden

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

50 files changed

+99
-120
lines changed

Cargo.lock

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frame/dynamic-fee/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ frame-support = { workspace = true }
1818
frame-system = { workspace = true }
1919
sp-core = { workspace = true }
2020
sp-inherents = { workspace = true }
21-
sp-std = { workspace = true }
2221
# Frontier
2322
fp-dynamic-fee = { workspace = true }
2423
fp-evm = { workspace = true }
@@ -37,7 +36,6 @@ std = [
3736
# Substrate
3837
"sp-core/std",
3938
"sp-inherents/std",
40-
"sp-std/std",
4139
# Substrate
4240
"frame-system/std",
4341
"frame-support/std",

frame/dynamic-fee/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
#[cfg(test)]
2323
mod tests;
2424

25+
use core::cmp::{max, min};
2526
use frame_support::{inherent::IsFatalError, traits::Get, weights::Weight};
2627
use sp_core::U256;
2728
use sp_inherents::{InherentData, InherentIdentifier};
28-
use sp_std::cmp::{max, min};
2929

3030
pub use self::pallet::*;
3131
#[cfg(feature = "std")]

frame/ethereum/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ frame-support = { workspace = true }
2121
frame-system = { workspace = true }
2222
sp-io = { workspace = true }
2323
sp-runtime = { workspace = true }
24-
sp-std = { workspace = true }
2524
# Frontier
2625
fp-consensus = { workspace = true }
2726
fp-ethereum = { workspace = true }
@@ -55,7 +54,6 @@ std = [
5554
"frame-system/std",
5655
"sp-io/std",
5756
"sp-runtime/std",
58-
"sp-std/std",
5957
# Frontier
6058
"fp-consensus/std",
6159
"fp-ethereum/std",

frame/ethereum/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@
2525
#![allow(clippy::comparison_chain, clippy::large_enum_variant)]
2626
#![warn(unused_crate_dependencies)]
2727

28+
extern crate alloc;
29+
2830
#[cfg(all(feature = "std", test))]
2931
mod mock;
3032
#[cfg(all(feature = "std", test))]
3133
mod tests;
3234

35+
use alloc::{vec, vec::Vec};
36+
use core::marker::PhantomData;
3337
pub use ethereum::{
3438
AccessListItem, BlockV2 as Block, LegacyTransactionMessage, Log, ReceiptV3 as Receipt,
3539
TransactionAction, TransactionV2 as Transaction,
@@ -55,7 +59,6 @@ use sp_runtime::{
5559
},
5660
RuntimeDebug, SaturatedConversion,
5761
};
58-
use sp_std::{marker::PhantomData, prelude::*};
5962
// Frontier
6063
use fp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID};
6164
pub use fp_ethereum::TransactionData;
@@ -689,7 +692,7 @@ impl<T: Config> Pallet<T> {
689692
PostDispatchInfo {
690693
actual_weight: {
691694
let mut gas_to_weight = T::GasWeightMapping::gas_to_weight(
692-
sp_std::cmp::max(
695+
core::cmp::max(
693696
used_gas.standard.unique_saturated_into(),
694697
used_gas.effective.unique_saturated_into(),
695698
),

frame/evm/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ frame-system = { workspace = true }
2929
sp-core = { workspace = true }
3030
sp-io = { workspace = true }
3131
sp-runtime = { workspace = true }
32-
sp-std = { workspace = true }
3332
# Frontier
3433
fp-account = { workspace = true }
3534
fp-evm = { workspace = true, features = ["serde"] }
@@ -59,7 +58,6 @@ std = [
5958
"sp-core/std",
6059
"sp-io/std",
6160
"sp-runtime/std",
62-
"sp-std/std",
6361
# Frontier
6462
"fp-account/std",
6563
"fp-evm/std",

frame/evm/precompile/dispatch/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pallet-utility = { workspace = true, features = ["default"] }
2626
sp-core = { workspace = true, features = ["default"] }
2727
sp-io = { workspace = true, features = ["default"] }
2828
sp-runtime = { workspace = true, features = ["default"] }
29-
sp-std = { workspace = true, features = ["default"] }
3029

3130
[features]
3231
default = ["std"]

frame/evm/precompile/dispatch/src/mock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
//! Test mock for unit tests and benchmarking
1919
20+
use alloc::boxed::Box;
21+
use core::str::FromStr;
2022
use frame_support::{
2123
derive_impl, parameter_types,
2224
traits::{ConstU32, FindAuthor},
@@ -25,7 +27,6 @@ use frame_support::{
2527
};
2628
use sp_core::{H160, H256, U256};
2729
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
28-
use sp_std::{boxed::Box, prelude::*, str::FromStr};
2930

3031
use fp_evm::{ExitError, ExitReason, Transfer};
3132
use pallet_evm::{

frame/evm/precompile/storage-cleaner/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ frame-support = { workspace = true }
1414
frame-system = { workspace = true }
1515
sp-core = { workspace = true }
1616
sp-runtime = { workspace = true }
17-
sp-std = { workspace = true }
1817
# Frontier
1918
fp-evm = { workspace = true }
2019
pallet-evm = { workspace = true }
@@ -31,7 +30,6 @@ rlp = { workspace = true }
3130
sp-core = { workspace = true, features = ["default"] }
3231
sp-io = { workspace = true, features = ["default"] }
3332
sp-runtime = { workspace = true, features = ["default"] }
34-
sp-std = { workspace = true, features = ["default"] }
3533

3634
# Frontier
3735
precompile-utils = { workspace = true, features = ["std", "testing"] }
@@ -45,7 +43,6 @@ std = [
4543
"frame-system/std",
4644
"sp-runtime/std",
4745
"sp-core/std",
48-
"sp-std/std",
4946
# Frontier
5047
"fp-evm/std",
5148
"pallet-evm/std",

frame/evm/precompile/storage-cleaner/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#![cfg_attr(not(feature = "std"), no_std)]
2222
extern crate alloc;
2323

24+
use alloc::vec::Vec;
2425
use core::marker::PhantomData;
2526
use fp_evm::{PrecompileFailure, ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_STORAGE_PROOF_SIZE};
2627
use pallet_evm::AddressMapping;
2728
use precompile_utils::{prelude::*, EvmResult};
2829
use sp_core::H160;
2930
use sp_runtime::traits::ConstU32;
30-
use sp_std::vec::Vec;
3131

3232
#[cfg(test)]
3333
mod mock;

frame/evm/src/benchmarking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ benchmarks! {
3535

3636
use rlp::RlpStream;
3737
use sp_core::{H160, U256};
38-
use sp_std::vec;
38+
use alloc::vec;
3939

4040
// contract bytecode below is for:
4141
//

frame/evm/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
#![warn(unused_crate_dependencies)]
5656
#![allow(clippy::too_many_arguments)]
5757

58+
extern crate alloc;
59+
5860
#[cfg(feature = "runtime-benchmarks")]
5961
pub mod benchmarking;
6062

@@ -65,6 +67,8 @@ pub mod runner;
6567
mod tests;
6668
pub mod weights;
6769

70+
use alloc::{collections::btree_map::BTreeMap, vec::Vec};
71+
use core::cmp::min;
6872
pub use evm::{
6973
Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed,
7074
};
@@ -94,7 +98,6 @@ use sp_runtime::{
9498
traits::{BadOrigin, NumberFor, Saturating, UniqueSaturatedInto, Zero},
9599
AccountId32, DispatchErrorWithPostInfo,
96100
};
97-
use sp_std::{cmp::min, collections::btree_map::BTreeMap, vec::Vec};
98101
// Frontier
99102
use fp_account::AccountId20;
100103
use fp_evm::GenesisAccount;
@@ -651,7 +654,7 @@ where
651654
}
652655

653656
/// Ensure that the origin is root.
654-
pub struct EnsureAddressRoot<AccountId>(sp_std::marker::PhantomData<AccountId>);
657+
pub struct EnsureAddressRoot<AccountId>(core::marker::PhantomData<AccountId>);
655658

656659
impl<OuterOrigin, AccountId> EnsureAddressOrigin<OuterOrigin> for EnsureAddressRoot<AccountId>
657660
where
@@ -668,7 +671,7 @@ where
668671
}
669672

670673
/// Ensure that the origin never happens.
671-
pub struct EnsureAddressNever<AccountId>(sp_std::marker::PhantomData<AccountId>);
674+
pub struct EnsureAddressNever<AccountId>(core::marker::PhantomData<AccountId>);
672675

673676
impl<OuterOrigin, AccountId> EnsureAddressOrigin<OuterOrigin> for EnsureAddressNever<AccountId> {
674677
type Success = AccountId;
@@ -731,7 +734,7 @@ impl<T: From<H160>> AddressMapping<T> for IdentityAddressMapping {
731734
}
732735

733736
/// Hashed address mapping.
734-
pub struct HashedAddressMapping<H>(sp_std::marker::PhantomData<H>);
737+
pub struct HashedAddressMapping<H>(core::marker::PhantomData<H>);
735738

736739
impl<H: Hasher<Out = H256>> AddressMapping<AccountId32> for HashedAddressMapping<H> {
737740
fn into_account_id(address: H160) -> AccountId32 {
@@ -750,7 +753,7 @@ pub trait BlockHashMapping {
750753
}
751754

752755
/// Returns the Substrate block hash by number.
753-
pub struct SubstrateBlockHashMapping<T>(sp_std::marker::PhantomData<T>);
756+
pub struct SubstrateBlockHashMapping<T>(core::marker::PhantomData<T>);
754757
impl<T: Config> BlockHashMapping for SubstrateBlockHashMapping<T> {
755758
fn block_hash(number: u32) -> H256 {
756759
let number = <NumberFor<T::Block>>::from(number);
@@ -764,7 +767,7 @@ pub trait GasWeightMapping {
764767
fn weight_to_gas(weight: Weight) -> u64;
765768
}
766769

767-
pub struct FixedGasWeightMapping<T>(sp_std::marker::PhantomData<T>);
770+
pub struct FixedGasWeightMapping<T>(core::marker::PhantomData<T>);
768771
impl<T: Config> GasWeightMapping for FixedGasWeightMapping<T> {
769772
fn gas_to_weight(gas: u64, without_base_weight: bool) -> Weight {
770773
let mut weight = T::WeightPerGas::get().saturating_mul(gas);
@@ -953,7 +956,7 @@ pub trait OnChargeEVMTransaction<T: Config> {
953956
/// trait (eg. the pallet_balances) using an unbalance handler (implementing
954957
/// `OnUnbalanced`).
955958
/// Similar to `CurrencyAdapter` of `pallet_transaction_payment`
956-
pub struct EVMCurrencyAdapter<C, OU>(sp_std::marker::PhantomData<(C, OU)>);
959+
pub struct EVMCurrencyAdapter<C, OU>(core::marker::PhantomData<(C, OU)>);
957960

958961
impl<T, C, OU> OnChargeEVMTransaction<T> for EVMCurrencyAdapter<C, OU>
959962
where
@@ -1053,7 +1056,7 @@ where
10531056
///
10541057
/// Equivalent of `EVMCurrencyAdapter` but for fungible traits. Similar to `FungibleAdapter` of
10551058
/// `pallet_transaction_payment`
1056-
pub struct EVMFungibleAdapter<F, OU>(sp_std::marker::PhantomData<(F, OU)>);
1059+
pub struct EVMFungibleAdapter<F, OU>(core::marker::PhantomData<(F, OU)>);
10571060

10581061
impl<T, F, OU> OnChargeEVMTransaction<T> for EVMFungibleAdapter<F, OU>
10591062
where

frame/evm/src/mock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
//! Test mock for unit tests and benchmarking
1919
20+
use alloc::boxed::Box;
21+
use core::str::FromStr;
2022
use frame_support::{
2123
derive_impl, parameter_types,
2224
traits::{ConstU32, FindAuthor},
@@ -27,7 +29,6 @@ use sp_runtime::{
2729
traits::{BlakeTwo256, IdentityLookup},
2830
ConsensusEngineId,
2931
};
30-
use sp_std::{boxed::Box, prelude::*, str::FromStr};
3132

3233
use crate::{
3334
EnsureAddressNever, EnsureAddressRoot, FeeCalculator, IdentityAddressMapping,

0 commit comments

Comments
 (0)