Skip to content

Commit

Permalink
reference-docs: Start state and mention well known keys (paritytech…
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr authored Jan 13, 2025
1 parent 738282a commit 7d8e3a4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
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

0 comments on commit 7d8e3a4

Please sign in to comment.