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
@@ -37,7 +37,7 @@ pallet-nfts = { path = "../../../../../substrate/frame/nfts", default-features =
pallet-nfts-runtime-api = { path = "../../../../../substrate/frame/nfts/runtime-api", default-features = false }
pallet-proxy = { path = "../../../../../substrate/frame/proxy", default-features = false }
pallet-session = { path = "../../../../../substrate/frame/session", default-features = false }
pallet-state-trie-migration = { path = "../../../../../substrate/frame/state-trie-migration", default-features = false, optional = true }
pallet-state-trie-migration = { path = "../../../../../substrate/frame/state-trie-migration", default-features = false }
pallet-timestamp = { path = "../../../../../substrate/frame/timestamp", default-features = false }
pallet-transaction-payment = { path = "../../../../../substrate/frame/transaction-payment", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { path = "../../../../../substrate/frame/transaction-payment/rpc/runtime-api", default-features = false }
@@ -102,14 +102,6 @@ substrate-wasm-builder = { path = "../../../../../substrate/utils/wasm-builder",
[features]
default = ["std"]
# When enabled the `state_version` is set to `1`.
# This means that the chain will start using the new state format. The migration is lazy, so
# it requires to write a storage value to use the new state format. To migrate all the other
# storage values that aren't touched the state migration pallet is added as well.
# This pallet will migrate the entire state, controlled through some account.
#
# This feature should be removed when the main-net will be migrated.
state-trie-version-1 = ["pallet-state-trie-migration"]
runtime-benchmarks = [
"assets-common/runtime-benchmarks",
"cumulus-pallet-parachain-system/runtime-benchmarks",
@@ -107,7 +107,6 @@ impl_opaque_keys! {
}
}
#[cfg(feature = "state-trie-version-1")]
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
@@ -120,19 +119,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
state_version: 1,
};
#[cfg(not(feature = "state-trie-version-1"))]
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 1_010_000,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 14,
state_version: 0,
};
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
@@ -953,7 +939,6 @@ construct_runtime!(
PoolAssets: pallet_assets::<Instance3> = 55,
AssetConversion: pallet_asset_conversion = 56,
#[cfg(feature = "state-trie-version-1")]
StateTrieMigration: pallet_state_trie_migration = 70,
// TODO: the pallet instance should be removed once all pools have migrated
@@ -1695,7 +1680,6 @@ cumulus_pallet_parachain_system::register_validate_block! {
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
}
#[cfg(feature = "state-trie-version-1")]
parameter_types! {
// The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high)
pub const MigrationSignedDepositPerItem: Balance = CENTS;
@@ -1703,7 +1687,6 @@ parameter_types! {
pub const MigrationMaxKeyLen: u32 = 512;
}
#[cfg(feature = "state-trie-version-1")]
impl pallet_state_trie_migration::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
@@ -1721,13 +1704,11 @@ impl pallet_state_trie_migration::Config for Runtime {
type MaxKeyLen = MigrationMaxKeyLen;
}
#[cfg(feature = "state-trie-version-1")]
frame_support::ord_parameter_types! {
pub const MigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
pub const RootMigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
}
#[cfg(feature = "state-trie-version-1")]
#[test]
fn ensure_key_ss58() {
use frame_support::traits::SortedMembers;
@@ -22,8 +22,8 @@ frame-system-rpc-runtime-api = { path = "../../../../../substrate/frame/system/r
frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true }
frame-try-runtime = { path = "../../../../../substrate/frame/try-runtime", default-features = false, optional = true }
pallet-aura = { path = "../../../../../substrate/frame/aura", default-features = false }
pallet-glutton = { path = "../../../../../substrate/frame/glutton", default-features = false, optional = true }
pallet-sudo = { path = "../../../../../substrate/frame/sudo", default-features = false, optional = true }
pallet-glutton = { path = "../../../../../substrate/frame/glutton", default-features = false }
pallet-sudo = { path = "../../../../../substrate/frame/sudo", default-features = false }
pallet-timestamp = { path = "../../../../../substrate/frame/timestamp", default-features = false }
sp-api = { path = "../../../../../substrate/primitives/api", default-features = false }
sp-block-builder = { path = "../../../../../substrate/primitives/block-builder", default-features = false }