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

Remove sp_runtime::RuntimeString and replace with Cow<'static, str> or String depending on use case #5693

Merged
merged 11 commits into from
Nov 5, 2024
4 changes: 2 additions & 2 deletions cumulus/client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ impl RelayChainInterface for DummyRelayChainInterface {
.to_vec();

Ok(RuntimeVersion {
spec_name: sp_version::create_runtime_str!("test"),
impl_name: sp_version::create_runtime_str!("test"),
spec_name: Cow::Borrowed("test"),
impl_name: Cow::Borrowed("test"),
authoring_version: 1,
spec_version: 1,
impl_version: 0,
Expand Down
4 changes: 2 additions & 2 deletions cumulus/client/pov-recovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ impl RelayChainInterface for Relaychain {
.to_vec();

Ok(RuntimeVersion {
spec_name: sp_version::create_runtime_str!("test"),
impl_name: sp_version::create_runtime_str!("test"),
spec_name: Cow::Borrowed("test"),
impl_name: Cow::Borrowed("test"),
authoring_version: 1,
spec_version: 1,
impl_version: 0,
Expand Down
4 changes: 2 additions & 2 deletions cumulus/pallets/parachain-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ frame_support::construct_runtime!(

parameter_types! {
pub Version: RuntimeVersion = RuntimeVersion {
spec_name: sp_version::create_runtime_str!("test"),
impl_name: sp_version::create_runtime_str!("system-test"),
spec_name: alloc::borrow::Cow::Borrowed("test"),
impl_name: alloc::borrow::Cow::Borrowed("system-test"),
authoring_version: 1,
spec_version: 1,
impl_version: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ mod preset_names {
/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
use preset_names::*;
let patch = match id.try_into() {
Ok(PRESET_GENESIS) => asset_hub_rococo_genesis(
let patch = match id.as_ref() {
PRESET_GENESIS => asset_hub_rococo_genesis(
// initial collators.
vec![
// E8XC6rTJRsioKCp6KMy6zd24ykj4gWsusZ3AkSeyavpVBAG
Expand Down Expand Up @@ -100,7 +100,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
ASSET_HUB_ROCOCO_ED * 524_288,
1000.into(),
),
Ok(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET) => asset_hub_rococo_genesis(
sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => asset_hub_rococo_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
Expand All @@ -110,7 +110,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
testnet_parachains_constants::rococo::currency::UNITS * 1_000_000,
1000.into(),
),
Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => asset_hub_rococo_genesis(
sp_genesis_builder::DEV_RUNTIME_PRESET => asset_hub_rococo_genesis(
// initial collators.
vec![(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into())],
vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use cumulus_primitives_core::{AggregateMessageOrigin, ClaimQueueOffset, CoreSele
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, Verify},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Permill,
Expand Down Expand Up @@ -120,8 +120,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("statemine"),
impl_name: create_runtime_str!("statemine"),
spec_name: alloc::borrow::Cow::Borrowed("statemine"),
impl_name: alloc::borrow::Cow::Borrowed("statemine"),
authoring_version: 1,
spec_version: 1_016_002,
impl_version: 0,
Expand Down Expand Up @@ -1556,7 +1556,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ mod preset_names {
/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
use preset_names::*;
let patch = match id.try_into() {
Ok(PRESET_GENESIS) => asset_hub_westend_genesis(
let patch = match id.as_ref() {
PRESET_GENESIS => asset_hub_westend_genesis(
// initial collators.
vec![
(
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
ASSET_HUB_WESTEND_ED * 4096,
1000.into(),
),
Ok(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET) => asset_hub_westend_genesis(
sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => asset_hub_westend_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
Expand All @@ -115,7 +115,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
WND * 1_000_000,
1000.into(),
),
Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => asset_hub_westend_genesis(
sp_genesis_builder::DEV_RUNTIME_PRESET => asset_hub_westend_genesis(
// initial collators.
vec![(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into())],
vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use parachains_common::{
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, Verify},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill, Permill, RuntimeDebug,
Expand Down Expand Up @@ -124,8 +124,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// Note: "westmint" is the legacy name for this chain. It has been renamed to
// "asset-hub-westend". Many wallets/tools depend on the `spec_name`, so it remains "westmint"
// for the time being. Wallets/tools should update to treat "asset-hub-westend" equally.
spec_name: create_runtime_str!("westmint"),
impl_name: create_runtime_str!("westmint"),
spec_name: alloc::borrow::Cow::Borrowed("westmint"),
impl_name: alloc::borrow::Cow::Borrowed("westmint"),
authoring_version: 1,
spec_version: 1_016_004,
impl_version: 0,
Expand Down Expand Up @@ -1736,7 +1736,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ fn bridge_hub_rococo_genesis(

/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
let patch = match id.try_into() {
Ok(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET) => bridge_hub_rococo_genesis(
let patch = match id.as_ref() {
sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => bridge_hub_rococo_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
Expand All @@ -106,7 +106,7 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<
Some(bp_messages::LegacyLaneId([0, 0, 0, 2])),
)],
),
Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => bridge_hub_rococo_genesis(
sp_genesis_builder::DEV_RUNTIME_PRESET => bridge_hub_rococo_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use pallet_bridge_messages::LaneIdOf;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
Expand Down Expand Up @@ -235,8 +235,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bridge-hub-rococo"),
impl_name: create_runtime_str!("bridge-hub-rococo"),
spec_name: alloc::borrow::Cow::Borrowed("bridge-hub-rococo"),
impl_name: alloc::borrow::Cow::Borrowed("bridge-hub-rococo"),
authoring_version: 1,
spec_version: 1_016_001,
impl_version: 0,
Expand Down Expand Up @@ -1070,7 +1070,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ fn bridge_hub_westend_genesis(

/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
let patch = match id.try_into() {
Ok(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET) => bridge_hub_westend_genesis(
let patch = match id.as_ref() {
sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => bridge_hub_westend_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
Expand All @@ -106,7 +106,7 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<
Some(bp_messages::LegacyLaneId([0, 0, 0, 2])),
)],
),
Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => bridge_hub_westend_genesis(
sp_genesis_builder::DEV_RUNTIME_PRESET => bridge_hub_westend_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use cumulus_primitives_core::{ClaimQueueOffset, CoreSelector, ParaId};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
Expand Down Expand Up @@ -220,8 +220,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bridge-hub-westend"),
impl_name: create_runtime_str!("bridge-hub-westend"),
spec_name: alloc::borrow::Cow::Borrowed("bridge-hub-westend"),
impl_name: alloc::borrow::Cow::Borrowed("bridge-hub-westend"),
authoring_version: 1,
spec_version: 1_016_001,
impl_version: 0,
Expand Down Expand Up @@ -955,7 +955,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ fn collectives_westend_genesis(

/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
let patch = match id.try_into() {
Ok(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET) => collectives_westend_genesis(
let patch = match id.as_ref() {
sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => collectives_westend_genesis(
// initial collators.
vec![
(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
Expand All @@ -79,7 +79,7 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<
Sr25519Keyring::well_known().map(|k| k.to_account_id()).collect(),
1001.into(),
),
Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => collectives_westend_genesis(
sp_genesis_builder::DEV_RUNTIME_PRESET => collectives_westend_genesis(
// initial collators.
vec![(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into())],
vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use impls::{AllianceProposalProvider, EqualOrGreatestRootCmp};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill,
Expand Down Expand Up @@ -123,8 +123,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("collectives-westend"),
impl_name: create_runtime_str!("collectives-westend"),
spec_name: alloc::borrow::Cow::Borrowed("collectives-westend"),
impl_name: alloc::borrow::Cow::Borrowed("collectives-westend"),
authoring_version: 1,
spec_version: 1_016_001,
impl_version: 0,
Expand Down Expand Up @@ -1061,7 +1061,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use cumulus_primitives_core::{AggregateMessageOrigin, ClaimQueueOffset, CoreSele
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill,
Expand Down Expand Up @@ -141,8 +141,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("contracts-rococo"),
impl_name: create_runtime_str!("contracts-rococo"),
spec_name: alloc::borrow::Cow::Borrowed("contracts-rococo"),
impl_name: alloc::borrow::Cow::Borrowed("contracts-rococo"),
authoring_version: 1,
spec_version: 1_016_001,
impl_version: 0,
Expand Down Expand Up @@ -772,7 +772,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill, RuntimeDebug,
Expand Down Expand Up @@ -146,8 +146,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("coretime-rococo"),
impl_name: create_runtime_str!("coretime-rococo"),
spec_name: alloc::borrow::Cow::Borrowed("coretime-rococo"),
impl_name: alloc::borrow::Cow::Borrowed("coretime-rococo"),
authoring_version: 1,
spec_version: 1_016_001,
impl_version: 0,
Expand Down Expand Up @@ -918,7 +918,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill, RuntimeDebug,
Expand Down Expand Up @@ -146,8 +146,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("coretime-westend"),
impl_name: create_runtime_str!("coretime-westend"),
spec_name: alloc::borrow::Cow::Borrowed("coretime-westend"),
impl_name: alloc::borrow::Cow::Borrowed("coretime-westend"),
authoring_version: 1,
spec_version: 1_016_001,
impl_version: 0,
Expand Down Expand Up @@ -910,7 +910,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

Expand Down
Loading
Loading