sp-std removal from substrate/primitives (#3274)

This PR removes sp-std crate from substrate/primitives sub-directories.

For now crates that have `pub use` of sp-std or export macros that would
necessitate users of the macros to `extern crate alloc` have been
excluded from this PR.

There should be no breaking changes in this PR.

---------

Co-authored-by: Koute <koute@users.noreply.github.com>
This commit is contained in:
Squirrel
2024-03-18 05:29:35 +00:00
committed by GitHub
parent 6b1179f13b
commit 1b5f4243d1
110 changed files with 254 additions and 278 deletions
@@ -15,9 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use alloc::{vec, vec::Vec};
use codec::{Decode, Encode, Error, Input};
use core::cmp;
use scale_info::TypeInfo;
use sp_std::{cmp, prelude::*};
use crate::{Payload, ValidatorSetId};
@@ -97,10 +98,10 @@ pub struct SignedCommitment<TBlockNumber, TSignature> {
pub signatures: Vec<Option<TSignature>>,
}
impl<TBlockNumber: sp_std::fmt::Debug, TSignature> sp_std::fmt::Display
impl<TBlockNumber: core::fmt::Debug, TSignature> core::fmt::Display
for SignedCommitment<TBlockNumber, TSignature>
{
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let signatures_count = self.signatures.iter().filter(|s| s.is_some()).count();
write!(
f,
@@ -254,8 +255,8 @@ pub enum VersionedFinalityProof<N, S> {
V1(SignedCommitment<N, S>),
}
impl<N: sp_std::fmt::Debug, S> sp_std::fmt::Display for VersionedFinalityProof<N, S> {
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
impl<N: core::fmt::Debug, S> core::fmt::Display for VersionedFinalityProof<N, S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
VersionedFinalityProof::V1(sc) => write!(f, "VersionedFinalityProof::V1({})", sc),
}
@@ -31,6 +31,8 @@
//! it will use a different set of keys. For Polkadot use case we plan to use `secp256k1` for BEEFY,
//! while GRANDPA uses `ed25519`.
extern crate alloc;
mod commitment;
mod payload;
@@ -44,13 +46,13 @@ pub mod test_utils;
pub use commitment::{Commitment, SignedCommitment, VersionedFinalityProof};
pub use payload::{known_payloads, BeefyPayloadId, Payload, PayloadProvider};
use alloc::vec::Vec;
use codec::{Codec, Decode, Encode};
use core::fmt::{Debug, Display};
use scale_info::TypeInfo;
use sp_application_crypto::{AppCrypto, AppPublic, ByteArray, RuntimeAppPublic};
use sp_core::H256;
use sp_runtime::traits::{Hash, Keccak256, NumberFor};
use sp_std::prelude::*;
/// Key type for BEEFY module.
pub const KEY_TYPE: sp_core::crypto::KeyTypeId = sp_application_crypto::key_types::BEEFY;
@@ -26,7 +26,8 @@
//! but we imagine they will be useful for other chains that either want to bridge with Polkadot
//! or are completely standalone, but heavily inspired by Polkadot.
use crate::{ecdsa_crypto::AuthorityId, ConsensusLog, MmrRootHash, Vec, BEEFY_ENGINE_ID};
use crate::{ecdsa_crypto::AuthorityId, ConsensusLog, MmrRootHash, BEEFY_ENGINE_ID};
use alloc::vec::Vec;
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{
@@ -150,10 +151,11 @@ pub use mmr_root_provider::MmrRootProvider;
mod mmr_root_provider {
use super::*;
use crate::{known_payloads, payload::PayloadProvider, Payload};
use alloc::sync::Arc;
use core::marker::PhantomData;
use sp_api::ProvideRuntimeApi;
use sp_mmr_primitives::MmrApi;
use sp_runtime::traits::NumberFor;
use sp_std::{marker::PhantomData, sync::Arc};
/// A [`crate::Payload`] provider where payload is Merkle Mountain Range root hash.
///
@@ -15,10 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use alloc::{vec, vec::Vec};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_runtime::traits::Block;
use sp_std::prelude::*;
/// Id of different payloads in the [`crate::Commitment`] data.
pub type BeefyPayloadId = [u8; 2];
@@ -23,9 +23,8 @@
//! verification. This allows lowering the data and computation cost of verifying the
//! signed commitment.
use sp_std::prelude::*;
use crate::commitment::{Commitment, SignedCommitment};
use alloc::vec::Vec;
/// A light form of [SignedCommitment].
///