Skip to content

Commit

Permalink
Remove sp_runtime::RuntimeString and replace with `Cow<'static, str…
Browse files Browse the repository at this point in the history
…>` or `String` depending on use case
  • Loading branch information
nazar-pc committed Sep 12, 2024
1 parent a34cc8d commit f3778c1
Show file tree
Hide file tree
Showing 52 changed files with 197 additions and 374 deletions.
4 changes: 2 additions & 2 deletions cumulus/client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,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 @@ -85,8 +85,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 @@ -118,7 +118,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
ASSET_HUB_ROCOCO_ED * 524_288,
1000.into(),
),
Ok(PRESET_LOCAL) => asset_hub_rococo_genesis(
PRESET_LOCAL => asset_hub_rococo_genesis(
// initial collators.
vec![
(
Expand Down Expand Up @@ -147,7 +147,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
testnet_parachains_constants::rococo::currency::UNITS * 1_000_000,
1000.into(),
),
Ok(PRESET_DEVELOPMENT) => asset_hub_rococo_genesis(
PRESET_DEVELOPMENT => asset_hub_rococo_genesis(
// initial collators.
vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
Expand All @@ -162,7 +162,7 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
testnet_parachains_constants::rococo::currency::UNITS * 1_000_000,
1000.into(),
),
Err(_) | Ok(_) => return None,
_ => return None,
};

Some(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_genesis_builder::PresetId;
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 @@ -121,8 +121,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_015_000,
impl_version: 0,
Expand Down Expand Up @@ -1441,7 +1441,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 @@ -65,7 +65,7 @@ use parachains_common::{
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, Perbill, Permill, RuntimeDebug,
Expand Down Expand Up @@ -119,8 +119,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_015_000,
impl_version: 0,
Expand Down Expand Up @@ -1535,7 +1535,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 @@ -45,7 +45,7 @@ use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
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 @@ -231,8 +231,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_000,
impl_version: 0,
Expand Down Expand Up @@ -1041,7 +1041,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 @@ -44,7 +44,7 @@ use cumulus_primitives_core::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 @@ -206,8 +206,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_000,
impl_version: 0,
Expand Down Expand Up @@ -927,7 +927,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 @@ -55,7 +55,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 @@ -122,8 +122,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_015_000,
impl_version: 0,
Expand Down Expand Up @@ -1047,7 +1047,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;
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_015_000,
impl_version: 0,
Expand Down Expand Up @@ -761,7 +761,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 @@ -64,7 +64,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::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill,
Expand Down Expand Up @@ -143,8 +143,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_015_000,
impl_version: 0,
Expand Down Expand Up @@ -770,7 +770,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 @@ -64,7 +64,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::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, MultiAddress, Perbill,
Expand Down Expand Up @@ -142,8 +142,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_015_000,
impl_version: 0,
Expand Down Expand Up @@ -761,7 +761,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 @@ -55,7 +55,7 @@ use sp_api::impl_runtime_apis;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
Expand Down Expand Up @@ -99,8 +99,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("glutton-westend"),
impl_name: create_runtime_str!("glutton-westend"),
spec_name: alloc::borrow::Cow::Borrowed("glutton-westend"),
impl_name: alloc::borrow::Cow::Borrowed("glutton-westend"),
authoring_version: 1,
spec_version: 1_015_000,
impl_version: 0,
Expand Down Expand Up @@ -451,7 +451,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
8 changes: 4 additions & 4 deletions cumulus/parachains/runtimes/people/people-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
Expand Down Expand Up @@ -131,8 +131,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("people-rococo"),
impl_name: create_runtime_str!("people-rococo"),
spec_name: alloc::borrow::Cow::Borrowed("people-rococo"),
impl_name: alloc::borrow::Cow::Borrowed("people-rococo"),
authoring_version: 1,
spec_version: 1_015_000,
impl_version: 0,
Expand Down Expand Up @@ -733,7 +733,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
8 changes: 4 additions & 4 deletions cumulus/parachains/runtimes/people/people-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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::Block as BlockT,
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
Expand Down Expand Up @@ -131,8 +131,8 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("people-westend"),
impl_name: create_runtime_str!("people-westend"),
spec_name: alloc::borrow::Cow::Borrowed("people-westend"),
impl_name: alloc::borrow::Cow::Borrowed("people-westend"),
authoring_version: 1,
spec_version: 1_015_000,
impl_version: 0,
Expand Down Expand Up @@ -733,7 +733,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

0 comments on commit f3778c1

Please sign in to comment.