The on-chain facet of the Storage Layer is tasked with managing lightweight metadata entries, such as Content Identifiers (CIDs), which function as references to [[Off-Chain Data Management with IPFS and Filecoin|off-chain datasets.]] These entries, typically on the order of 100 bytes each, are sufficiently compact to mitigate undue burden on the blockchain's resource footprint. They are organized within Substrate's Patricia Tries, which provide efficient state management optimized for blockchain operations. ## Design Rationale for Patricia Tries The selection of Patricia Tries within [[Substrate]]'s framework is motivated by several attributes that align with the demands of blockchain systems: - **Immutable State Preservation:** Upon integration into the blockchain, metadata entries are rendered immutable through Substrate's state commitment mechanism, establishing an indelible record amenable to subsequent verification and auditability. This permanence ensures historical integrity, a cornerstone for trust in decentralized systems [114]. - **Scalable Performance:** [[Patricia Tries]] exhibit logarithmic time complexity, denoted as O(log n), for operations such as insertion, deletion, and lookup. This scalability ensures sustained performance as the volume of metadata entries grows, even into the millions, while leveraging Substrate's optimized storage backend. - **Efficient [[ZKP/ZKP Base Layer/ZKP Blockchain/Technical Build Application Layer/Privacy-Preserving Computations with ZK Wrappers/Privacy-Preserving Computations with ZK Wrappers|Proof Generation:]]** Leveraging their Merkleized structure, Patricia Tries enable the production of compact proofs of inclusion through Substrate's native proof generation system, which can be verified efficiently within the runtime. This efficiency is pivotal for enabling [[ZKP/ZKP Base Layer/ZKP Blockchain/Technical Build Consensus Layer/Consensus Model|rapid consensus]] and state validation across distributed nodes [114]. _Consider a system with 1 million metadata entries: the Patricia Trie's compressed structure ensures efficient traversal and proof generation. [[Substrate]]'s optimized implementation maintains high performance even as the dataset expands, a vital attribute for supporting large-scale AI applications through custom storage pallets integrated with the unified runtime._ See also: [[Off-Chain Data Management with IPFS and Filecoin]]