Please describe your proposed solution.
Introduction:
As decentralized applications (DApps) become more prevalent, the necessity for effective information management escalates. Conventional applications typically utilize relational databases, which contain multiple tables with records. These records are interconnected through identifiers, facilitating complex queries encompassing multiple tables. Similar to traditional applications, DApps also need information management to handle the states and transactions of their services.
Conceptual Framework:
In the context of Cardano, information is stored on the blockchain through datums in UTXOs (Unspent Transaction Outputs). The Cardano network utilizes a UTXO Ledger to manage its state, which differs from the Account Ledger used by Bitcoin and Ethereum. The UTXO Ledger comprises a list of inputs, each harboring a balance and a datum, and is intrinsically tied to an address. The datum acts as a repository for the application-specific information.
For our solution, we propose a database that bridges the gap between information on the blockchain and that displayed on the user interface, ensuring seamless synchronization between both sources. The blockchain data will act as the authoritative source, resolving any inconsistencies.
Analogy:
In the proposed database, each datum in a UTXO is analogous to a record in a relational database. This analogy posits that:
- datum = record
Additionally, each contract in a DApp can be considered equivalent to a datum type, which correlates to a table in our database. This draws another equivalence:
- contract = datum type = table
This structure allows the decentralized application to maintain a sophisticated state with various tables, each containing multiple records.
Concurrency Management:
The proposed database incorporates features to manage concurrency. As transactions consume UTXOs and generate new ones, the database must monitor UTXOs involved in ongoing transactions. By marking UTXOs that are being utilized for transactions that are either being constructed or awaiting network validation, we minimize the risk of conflict arising from multiple transactions attempting to use the same UTXO.
Query Optimization:
The database will also act as a cache, optimizing resource usage and mitigating redundant API queries, especially when the application server relies on external services like Blockfrost for Cardano network data. This not only enhances performance but also curtails the costs associated with API calls.
Indexing and Synchronization:
The synchronization of the database is vital to ensuring that the data is up-to-date with the blockchain. Various methodologies, including the utilization of webhooks or periodic backend checks, can be employed to ascertain that the database reflects the latest state of the contract addresses. This process, termed network indexing, can be executed using various sources, including Blockfrost, direct node queries, or other Cardano-related data services.
Data Processing:
To streamline the processing, conversion, and storage of network information in the database, a JSON configuration file will be employed. This file will dictate the contract addresses, corresponding database tables, and data structure, thus governing the connection between the records in the tables and the blockchain data.
API Access and Portability:
An integral component of this solution is API access. The database will be accessible from both the frontend and backend through an API. This facilitates not only portability but also scalability, as the data and smart contracts can be accessed from anywhere, not confined to the initial deployment portal. This architecture enables the development of versatile applications with diverse access points.
Drivers of Impact:
- Community Contribution and Knowledge Sharing: By developing this solution as an open-source project, it aligns with OSDE's challenge of sharing efforts with the community. Our project will provide documentation, examples, and the source code, enabling other developers to understand, adopt, or contribute to the project. This promotes an environment of collaboration and shared knowledge, which is fundamental to the growth of the Cardano ecosystem.
- Improved Efficiency and Resource Optimization: The proposed database will optimize queries made to the Cardano network, which is particularly beneficial for developers with limited resources. By functioning as a cache, the database prevents repetitive API queries, thus minimizing costs and improving performance. This efficiency is likely to attract more developers to build on Cardano.
- Enhanced Concurrency Control: Our solution will provide mechanisms to handle the concurrency of transactions effectively. By marking UTXOs that are being used in ongoing transactions, it ensures that the state of the database remains consistent and reliable. This is crucial for the robustness of applications built on Cardano.
- Scalability and Accessibility: The database will be accessible through an API, allowing both the front-end and back-end to interact with it. This opens the door for scalability as the data can be accessed from anywhere, not just from the portal where it is deployed. This is crucial for the development of distributed applications on Cardano and promotes interoperability.
Conclusion:
This proposed solution aims to provide a robust, efficient, and scalable database system for decentralized applications on the Cardano blockchain. By bridging the gap between the blockchain data and user interfaces, optimizing queries, and ensuring synchronization, this database presents an innovative and formal solution crucial for the burgeoning DApp ecosystem. Moreover, the API access enhances the portability and versatility of applications built on this platform.