Fix nostd build of several crates (#4060)

Preparation for https://github.com/paritytech/polkadot-sdk/pull/3935

Changes:
- Add some `default-features = false` for the case that a crate and that
dependency both support nostd builds.
- Shuffle files around of some benchmarking-only crates. These
conditionally disabled the `cfg_attr` for nostd and pulled in libstd.
Example [here](https://github.com/ggwpez/zepter/pull/95). The actual
logic is moved into a `inner.rs` to preserve nostd capability of the
crate in case the benchmarking feature is disabled.
- Add some `use sp_std::vec` where needed.
- Remove some `optional = true` in cases where it was not optional.
- Removed one superfluous `cfg_attr(not(feature = "std"), no_std..`.

All in all this should be logical no-op.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2024-04-17 18:52:00 +03:00
committed by GitHub
parent bfbf7f5d6f
commit 7a2c9d4a9a
36 changed files with 1800 additions and 1601 deletions
+2 -3
View File
@@ -24,7 +24,7 @@ pallet-staking = { path = "../staking", default-features = false }
frame-support = { path = "../support", default-features = false }
frame-system = { path = "../system", default-features = false }
sp-runtime = { path = "../../primitives/runtime" }
sp-runtime = { path = "../../primitives/runtime", default-features = false }
sp-staking = { path = "../../primitives/staking", default-features = false }
[dev-dependencies]
@@ -34,7 +34,7 @@ pallet-staking-reward-curve = { path = "../staking/reward-curve" }
sp-core = { path = "../../primitives/core" }
sp-io = { path = "../../primitives/io", default-features = false }
sp-std = { path = "../../primitives/std", default-features = false }
sp-std = { path = "../../primitives/std" }
frame-election-provider-support = { path = "../election-provider-support" }
@@ -74,5 +74,4 @@ std = [
"sp-io/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
]
+4 -1
View File
@@ -27,6 +27,9 @@ mod mock;
#[cfg(test)]
mod tests;
extern crate alloc;
use alloc::vec::Vec;
use pallet_session::historical::IdentificationTuple;
use pallet_staking::{BalanceOf, Exposure, ExposureOf, Pallet as Staking};
use sp_runtime::Perbill;
@@ -112,7 +115,7 @@ pub mod pallet {
.into_iter()
.map(|(o, _)| OffenceDetails::<T> {
offender: (o.clone(), Staking::<T>::eras_stakers(now, &o)),
reporters: vec![],
reporters: Default::default(),
})
.collect())
}