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

reference-docs: Start state and mention well known keys #7037

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ sp-offchain = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
sp-runtime-interface = { workspace = true, default-features = true }
sp-std = { workspace = true, default-features = true }
sp-storage = { workspace = true, default-features = true }
sp-tracing = { workspace = true, default-features = true }
sp-version = { workspace = true, default-features = true }
sp-weights = { workspace = true, default-features = true }
Expand Down
3 changes: 3 additions & 0 deletions docs/sdk/src/reference_docs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ pub mod custom_runtime_api_rpc;

/// The [`polkadot-omni-node`](https://crates.io/crates/polkadot-omni-node) and its related binaries.
pub mod omni_node;

/// Learn about the state in Substrate.
pub mod state;
12 changes: 12 additions & 0 deletions docs/sdk/src/reference_docs/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! # State
//!
//! The state is abstracted as a key-value like database. Every item that
//! needs to be persisted by the [State Transition
//! Function](crate::reference_docs::blockchain_state_machines) is written to the state.
//!
//! ## Special keys
//!
//! The key-value pairs in the state are represented as byte sequences. The node
//! doesn't know how to interpret most the key-value pairs. However, there exist some
//! special keys and its values that are known to the node, the so-called
//! [`well-known-keys`](sp_storage::well_known_keys).
4 changes: 4 additions & 0 deletions substrate/primitives/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,15 @@ pub mod well_known_keys {
/// Wasm code of the runtime.
///
/// Stored as a raw byte vector. Required by substrate.
///
/// Encodes to `0x3A636F6465`.
pub const CODE: &[u8] = b":code";

/// Number of wasm linear memory pages required for execution of the runtime.
///
/// The type of this value is encoded `u64`.
///
/// Encodes to `0x307833413633364636343635`
pub const HEAP_PAGES: &[u8] = b":heappages";

/// Current extrinsic index (u32) is stored under this key.
Expand Down
Loading