[[Substrate]]'s **Runtime Interface** defines key mechanisms that enable efficient interaction between the [[Consensus Model|Consensus]] and [[ZKP/ZKP Base Layer/ZKP Blockchain/Technical Build Application Layer/Application Layer|Application Layer]] through the FRAME system [111]: - **validate_transaction:** Validates transaction format (e.g., signatures, weight limits) in approximately 1ms through the transaction pool. - **execute_block:** Executes state transitions (e.g., updating the Patricia Trie) in about 5ms during block execution. - **finalize_block:** Finalizes the state by committing the storage root hash in roughly 2ms through GRANDPA finality. The [[ZKP/ZKP Base Layer/ZKP Blockchain/Technical Build Application Layer/Overview of Components|Application Layer]] emits events via Substrate's event system e.g., Event::DatasetStored(CID), which are included in block headers and distributed to nodes through GRANDPA's gossip protocol in approximately 50ms with configurable network topology [109, 110]. In the [[ZKP/ZKP Base Layer/ZKP Blockchain/Performance/Storage Layer|Storage Layer,]] off-chain workers leverage decentralized storage networks, such as [[Off-Chain Storage with IPFS|IPFS]], for efficient data retrieval. IPFS's Distributed Hash Table (DHT), based on the Kademlia protocol [25] with (k = 20), enables data lookup in (O(log n)) hops, averaging around 100ms for a network of 1,000 nodes. This content-addressed, decentralized storage ensures that large datasets—essential for AI-driven applications—remain accessible and tamper-proof. Data integrity is preserved by anchoring the dataset's root hash on-chain through custom storage pallets, allowing verification without storing the full dataset on the blockchain. The ecosystem integrates with various decentralized storage solutions to maintain flexibility and scalability, supporting the demands of secure and efficient off-chain data management. **Event-Driven Synchronization:** Events operate through Substrate's native event system, with the runtime processing events synchronously within each block. For example, a DatasetStored event triggers a call to the PoSp pallet to confirm storage commitments, processed within the same block execution (typically 2-6 seconds per block), ensuring deterministic alignment across pallets [116]. [[ZKP/ZKP Base Layer/ZKP Blockchain/Technical Build Application Layer/Performance Overhead and Gas Costs|Cross-Layer Weight Optimization:]] Transactions spanning layers (e.g., [[ZKP/ZKP Base Layer/ZKP Blockchain/Technical Build Application Layer/Smart Contract Execution Environments EVM|EVM]] to native pallets) incur weight costs in Substrate's weight-based fee system: EVM transactions (~21,000 gas base, converted to weight), WASM calls (~10,000 weight), and off-chain storage interactions (~5,000 weight). Substrate's unified weight system tracks these costs, converting them to transaction fees ((\text{Fee} = \text{Weight} \times \text{WeightToFee})), ensuring fair resource allocation and preventing DoS attacks through the weight-based execution model [117]. See also: [[ZKP/ZKP Base Layer/ZKP Blockchain/Strategic Rationale/Strategic Rationale|Strategic Rationale]]