Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove sp-std usage #1422

Merged
merged 7 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions frame/dynamic-fee/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ frame-support = { workspace = true }
frame-system = { workspace = true }
sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-std = { workspace = true }
# Frontier
fp-dynamic-fee = { workspace = true }
fp-evm = { workspace = true }
Expand All @@ -37,7 +36,6 @@ std = [
# Substrate
"sp-core/std",
"sp-inherents/std",
"sp-std/std",
# Substrate
"frame-system/std",
"frame-support/std",
Expand Down
2 changes: 1 addition & 1 deletion frame/dynamic-fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#[cfg(test)]
mod tests;

use core::cmp::{max, min};
use frame_support::{inherent::IsFatalError, traits::Get, weights::Weight};
use sp_core::U256;
use sp_inherents::{InherentData, InherentIdentifier};
use sp_std::cmp::{max, min};

pub use self::pallet::*;
#[cfg(feature = "std")]
Expand Down
2 changes: 0 additions & 2 deletions frame/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ frame-support = { workspace = true }
frame-system = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
# Frontier
fp-consensus = { workspace = true }
fp-ethereum = { workspace = true }
Expand Down Expand Up @@ -55,7 +54,6 @@ std = [
"frame-system/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
# Frontier
"fp-consensus/std",
"fp-ethereum/std",
Expand Down
7 changes: 5 additions & 2 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
#![allow(clippy::comparison_chain, clippy::large_enum_variant)]
#![warn(unused_crate_dependencies)]

extern crate alloc;

#[cfg(all(feature = "std", test))]
mod mock;
#[cfg(all(feature = "std", test))]
mod tests;

use alloc::{vec, vec::Vec};
use core::marker::PhantomData;
pub use ethereum::{
AccessListItem, BlockV2 as Block, LegacyTransactionMessage, Log, ReceiptV3 as Receipt,
TransactionAction, TransactionV2 as Transaction,
Expand All @@ -55,7 +59,6 @@ use sp_runtime::{
},
RuntimeDebug, SaturatedConversion,
};
use sp_std::{marker::PhantomData, prelude::*};
// Frontier
use fp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID};
pub use fp_ethereum::TransactionData;
Expand Down Expand Up @@ -689,7 +692,7 @@ impl<T: Config> Pallet<T> {
PostDispatchInfo {
actual_weight: {
let mut gas_to_weight = T::GasWeightMapping::gas_to_weight(
sp_std::cmp::max(
core::cmp::max(
used_gas.standard.unique_saturated_into(),
used_gas.effective.unique_saturated_into(),
),
Expand Down
2 changes: 0 additions & 2 deletions frame/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ frame-system = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
# Frontier
fp-account = { workspace = true }
fp-evm = { workspace = true, features = ["serde"] }
Expand Down Expand Up @@ -59,7 +58,6 @@ std = [
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
# Frontier
"fp-account/std",
"fp-evm/std",
Expand Down
1 change: 0 additions & 1 deletion frame/evm/precompile/dispatch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pallet-utility = { workspace = true, features = ["default"] }
sp-core = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
sp-runtime = { workspace = true, features = ["default"] }
sp-std = { workspace = true, features = ["default"] }

[features]
default = ["std"]
Expand Down
3 changes: 2 additions & 1 deletion frame/evm/precompile/dispatch/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

//! Test mock for unit tests and benchmarking

use alloc::boxed::Box;
use core::str::FromStr;
use frame_support::{
derive_impl, parameter_types,
traits::{ConstU32, FindAuthor},
Expand All @@ -25,7 +27,6 @@ use frame_support::{
};
use sp_core::{H160, H256, U256};
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
use sp_std::{boxed::Box, prelude::*, str::FromStr};

use fp_evm::{ExitError, ExitReason, Transfer};
use pallet_evm::{
Expand Down
3 changes: 0 additions & 3 deletions frame/evm/precompile/storage-cleaner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ frame-support = { workspace = true }
frame-system = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
# Frontier
fp-evm = { workspace = true }
pallet-evm = { workspace = true }
Expand All @@ -31,7 +30,6 @@ rlp = { workspace = true }
sp-core = { workspace = true, features = ["default"] }
sp-io = { workspace = true, features = ["default"] }
sp-runtime = { workspace = true, features = ["default"] }
sp-std = { workspace = true, features = ["default"] }

# Frontier
precompile-utils = { workspace = true, features = ["std", "testing"] }
Expand All @@ -45,7 +43,6 @@ std = [
"frame-system/std",
"sp-runtime/std",
"sp-core/std",
"sp-std/std",
# Frontier
"fp-evm/std",
"pallet-evm/std",
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/precompile/storage-cleaner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;

use alloc::vec::Vec;
use core::marker::PhantomData;
use fp_evm::{PrecompileFailure, ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_STORAGE_PROOF_SIZE};
use pallet_evm::AddressMapping;
use precompile_utils::{prelude::*, EvmResult};
use sp_core::H160;
use sp_runtime::traits::ConstU32;
use sp_std::vec::Vec;

#[cfg(test)]
mod mock;
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ benchmarks! {

use rlp::RlpStream;
use sp_core::{H160, U256};
use sp_std::vec;
use alloc::vec;

// contract bytecode below is for:
//
Expand Down
19 changes: 11 additions & 8 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#![warn(unused_crate_dependencies)]
#![allow(clippy::too_many_arguments)]

extern crate alloc;

#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;

Expand All @@ -65,6 +67,8 @@ pub mod runner;
mod tests;
pub mod weights;

use alloc::{collections::btree_map::BTreeMap, vec::Vec};
use core::cmp::min;
pub use evm::{
Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed,
};
Expand Down Expand Up @@ -94,7 +98,6 @@ use sp_runtime::{
traits::{BadOrigin, NumberFor, Saturating, UniqueSaturatedInto, Zero},
AccountId32, DispatchErrorWithPostInfo,
};
use sp_std::{cmp::min, collections::btree_map::BTreeMap, vec::Vec};
// Frontier
use fp_account::AccountId20;
use fp_evm::GenesisAccount;
Expand Down Expand Up @@ -651,7 +654,7 @@ where
}

/// Ensure that the origin is root.
pub struct EnsureAddressRoot<AccountId>(sp_std::marker::PhantomData<AccountId>);
pub struct EnsureAddressRoot<AccountId>(core::marker::PhantomData<AccountId>);

impl<OuterOrigin, AccountId> EnsureAddressOrigin<OuterOrigin> for EnsureAddressRoot<AccountId>
where
Expand All @@ -668,7 +671,7 @@ where
}

/// Ensure that the origin never happens.
pub struct EnsureAddressNever<AccountId>(sp_std::marker::PhantomData<AccountId>);
pub struct EnsureAddressNever<AccountId>(core::marker::PhantomData<AccountId>);

impl<OuterOrigin, AccountId> EnsureAddressOrigin<OuterOrigin> for EnsureAddressNever<AccountId> {
type Success = AccountId;
Expand Down Expand Up @@ -731,7 +734,7 @@ impl<T: From<H160>> AddressMapping<T> for IdentityAddressMapping {
}

/// Hashed address mapping.
pub struct HashedAddressMapping<H>(sp_std::marker::PhantomData<H>);
pub struct HashedAddressMapping<H>(core::marker::PhantomData<H>);

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

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

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

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

impl<T, F, OU> OnChargeEVMTransaction<T> for EVMFungibleAdapter<F, OU>
where
Expand Down
3 changes: 2 additions & 1 deletion frame/evm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

//! Test mock for unit tests and benchmarking

use alloc::boxed::Box;
use core::str::FromStr;
use frame_support::{
derive_impl, parameter_types,
traits::{ConstU32, FindAuthor},
Expand All @@ -27,7 +29,6 @@ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
ConsensusEngineId,
};
use sp_std::{boxed::Box, prelude::*, str::FromStr};

use crate::{
EnsureAddressNever, EnsureAddressRoot, FeeCalculator, IdentityAddressMapping,
Expand Down
Loading
Loading