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

Refactor the host <-> runtime interface machinery #7375

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
20fab05
Refactor the host <-> runtime interface machinery
koute Mar 14, 2024
e854ff3
Rename the prdoc file to the correct PR number
koute Mar 14, 2024
b1346cc
Remove redundant lifetimes
koute Mar 14, 2024
5180738
Fix crate name in prdocs
koute Mar 14, 2024
2745774
Remove more redundant lifetimes
koute Mar 14, 2024
d13c67f
Also adjust FRAME benchmarking runtime interface
koute Mar 14, 2024
e0fb03b
Update `polkadot-runtime-metrics` crate
koute Mar 14, 2024
3b87116
Remove `sp-std` dependency from `sp-wasm-interface`
koute Mar 14, 2024
1aab744
Add missing imports to `sp-runtime-interface`
koute Mar 14, 2024
64c37e5
Make `sp_wasm_interface::Result` always return a `String` as an error
koute Mar 14, 2024
d71e093
Make `sp-runtime-interface` always `#[no_std]`
koute Mar 14, 2024
4cd6caa
Merge remote-tracking branch 'origin/master' into master_runtime_inte…
koute Mar 18, 2024
b8aebe1
Switch `runtime-interface` macros to use `substrate_runtime`
koute Mar 18, 2024
feeda1a
Fix `check-features-variants.sh` scripts
koute Mar 18, 2024
11dfa9f
More `feature = "std"` cleanups; fix `full-crypto` feature compilation
koute Mar 18, 2024
8a8dcb0
Update `secp256k1` and `secp256k1-sys` to fix WASM compilation
koute Mar 19, 2024
1163801
Fix `sp-io` compilation under non-runtime `no_std`
koute Mar 19, 2024
af46473
Build frame examples with `--cfg substrate_runtime` on the CI
koute Mar 19, 2024
0a254f5
Propagate `sp-core/std` -> `futures/std` cargo feature
koute Mar 19, 2024
7ff56da
Merge remote-tracking branch 'origin/master' into master_runtime_inte…
koute Mar 19, 2024
2763e81
Fix `pallet_ui` tests
koute Mar 20, 2024
a3dee1f
Merge 'origin/master'; update `crypto_bytes.rs`
koute Mar 20, 2024
022c32c
Disable default features for `sp-externalities` dep in `sp-core`
koute Mar 20, 2024
9a446a8
More `feature = "std"` cleanups to fix `full_crypto` compilation
koute Mar 20, 2024
29c8ddf
Merge remote-tracking branch 'origin/master' into master_runtime_inte…
koute Apr 5, 2024
1e53458
Remove unnecessary `RIType` and `IntoFFIValue` impls
koute Apr 5, 2024
c240e1e
Use associated types in return types
koute Apr 5, 2024
6ac3d06
Make `Primitive` safe and private
koute Apr 5, 2024
ba683e7
Cleanups
koute Apr 5, 2024
1cb22ca
Rename `PassByCodec` to `PassFatPointerAndDecode`
koute Apr 5, 2024
6e606ad
Rename `PassSliceRefByCodec` -> `PassFatPointerAndDecodeSlice`
koute Apr 5, 2024
6d90a1d
Update doc comment
koute Apr 5, 2024
0001db0
Update the docs about the deprecated marshaling strategies
koute Apr 5, 2024
182a6e8
Remove redundant links in the docs
koute Apr 5, 2024
589690d
Merge remote-tracking branch 'origin/master' into master_runtime_inte…
koute Apr 8, 2024
c794600
Update prdoc
koute Apr 8, 2024
a6af3b2
Merge remote-tracking branch 'origin/master' into master_runtime_inte…
koute Apr 16, 2024
60b24a4
Merge remote-tracking branch 'origin/master' into master_runtime_inte…
s0me0ne-unkn0wn Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More feature = "std" cleanups to fix full_crypto compilation
  • Loading branch information
koute committed Mar 20, 2024
commit 9a446a8fb67b3cc53ec5ef777eac43c2078988a4
5 changes: 2 additions & 3 deletions substrate/primitives/externalities/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ pub struct Extensions {
extensions: BTreeMap<TypeId, Box<dyn Extension>>,
}

#[cfg(feature = "std")]
impl std::fmt::Debug for Extensions {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl core::fmt::Debug for Extensions {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "Extensions: ({})", self.extensions.len())
}
}
Expand Down
40 changes: 18 additions & 22 deletions substrate/primitives/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ use core::{
use ref_cast::RefCast;

/// Storage key.
#[derive(PartialEq, Eq, RuntimeDebug)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize, Hash, PartialOrd, Ord, Clone, Encode, Decode)
)]
#[derive(PartialEq, Eq, RuntimeDebug, Hash, PartialOrd, Ord, Clone, Encode, Decode)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct StorageKey(
#[cfg_attr(feature = "serde", serde(with = "impl_serde::serialize"))] pub Vec<u8>,
);
Expand Down Expand Up @@ -98,8 +95,8 @@ impl From<Vec<u8>> for TrackedStorageKey {
}

/// Storage key of a child trie, it contains the prefix to the key.
#[derive(PartialEq, Eq, RuntimeDebug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize, Hash, PartialOrd, Ord, Clone))]
#[derive(PartialEq, Eq, RuntimeDebug, Hash, PartialOrd, Ord, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[repr(transparent)]
#[derive(RefCast)]
pub struct PrefixedStorageKey(
Expand Down Expand Up @@ -139,22 +136,24 @@ impl PrefixedStorageKey {
}

/// Storage data associated to a [`StorageKey`].
#[derive(PartialEq, Eq, RuntimeDebug)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize, Hash, PartialOrd, Ord, Clone, Encode, Decode, Default)
)]
#[derive(PartialEq, Eq, RuntimeDebug, Hash, PartialOrd, Ord, Clone, Encode, Decode, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct StorageData(
#[cfg_attr(feature = "serde", serde(with = "impl_serde::serialize"))] pub Vec<u8>,
);

/// Map of data to use in a storage, it is a collection of
/// byte key and values.
pub type StorageMap = alloc::collections::BTreeMap<Vec<u8>, Vec<u8>>;

/// Map of storage children.
#[cfg(feature = "std")]
pub type StorageMap = std::collections::BTreeMap<Vec<u8>, Vec<u8>>;
pub type ChildrenMap = std::collections::HashMap<Vec<u8>, StorageChild>;

#[cfg(not(feature = "std"))]
pub type ChildrenMap = alloc::collections::BTreeMap<Vec<u8>, StorageChild>;

/// Child trie storage data.
#[cfg(feature = "std")]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct StorageChild {
/// Child data for storage.
Expand All @@ -165,19 +164,18 @@ pub struct StorageChild {
}

/// Struct containing data needed for a storage.
#[cfg(feature = "std")]
#[derive(Default, Debug, Clone)]
pub struct Storage {
/// Top trie storage data.
pub top: StorageMap,
/// Children trie storage data. Key does not include prefix, only for the `default` trie kind,
/// of `ChildType::ParentKeyId` type.
pub children_default: std::collections::HashMap<Vec<u8>, StorageChild>,
pub children_default: ChildrenMap,
}

/// Storage change set
#[derive(RuntimeDebug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize, PartialEq, Eq, Clone))]
#[derive(RuntimeDebug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct StorageChangeSet<Hash> {
/// Block hash
Expand Down Expand Up @@ -245,8 +243,7 @@ pub mod well_known_keys {
pub const TRIE_VALUE_NODE_THRESHOLD: u32 = 33;

/// Information related to a child state.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode))]
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode, Debug, Clone)]
pub enum ChildInfo {
/// This is the one used by default.
ParentKeyId(ChildTrieParentKeyId),
Expand Down Expand Up @@ -392,8 +389,7 @@ impl ChildType {
/// It shares its trie nodes backend storage with every other child trie, so its storage key needs
/// to be a unique id that will be use only once. Those unique id also required to be long enough to
/// avoid any unique id to be prefixed by an other unique id.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode))]
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Encode, Decode, Debug, Clone)]
pub struct ChildTrieParentKeyId {
/// Data is the storage key without prefix.
data: Vec<u8>,
Expand Down
Loading