#
pezkuwi_sdk_docs/reference_docs/
blockchain_state_machines.rs

    1//! # State Transition Function
    2//!
    3//! This document briefly explains how in the context of Bizinikiwi-based blockchains, we view the
    4//! blockchain as a **decentralized state transition function**.
    5//!
    6//! Recall that a blockchain's main purpose is to help a permissionless set of entities to agree on
    7//! a shared data-set, and how it evolves. This is called the **State**, also referred to as
    8//! "onchain" data, or *Storage* in the context of FRAME. The state is where the account balance of
    9//! each user is, for example, stored, and there is a canonical version of it that everyone agrees
    10//! upon.
    11//!
    12//! Then, recall that a typical blockchain system will alter its state through execution of blocks.
    13//! *The component that dictates how this state alteration can happen is called the state transition
    14//! function*.
    15#![doc = simple_mermaid::mermaid!("../../../mermaid/stf_simple.mmd")]
    16//!
    17//! In Bizinikiwi-based blockchains, the state transition function is called the *Runtime*. This is
    18//! explained further in [`crate::reference_docs::wasm_meta_protocol`].
    19//!
    20//! With this in mind, we can paint a complete picture of a blockchain as a state machine:
    21#![doc = simple_mermaid::mermaid!("../../../mermaid/stf.mmd")]
    22//!
    23//! In essence, the state of the blockchain at block N is the outcome of applying the state
    24//! transition function to the previous state, and the current block as input. This can be
    25//! mathematically represented as:
    26//!
    27//! ```math
    28//! STF = F(State_N, Block_N) -> State_{N+1}
    29//! ```