Research on Smart Contract Database Traversal
Term DefinitionBlockchainA distributed database that uses cryptography to record transaction information and ensure the security and immutability of data.Smart ContractA computer code that runs on the blockchain and contains a set of predetermined rules that are automatically executed when specific conditions are met.EthereumAn open source blockchain platform that supports the development and deployment of smart contracts and decentralized applications (DApps).State MachineAn abstract model used to describe the transitions between different states of a system. In blockchain, state machines are used to track the execution status of smart contracts.Key-Value Pair (KVP)A data storage method that associates a value with a unique key.Merkle Patricia Tree (MPT)A data structure for efficiently storing and retrieving key-value pairs.Logical MapA data structure proposed in this patent to simplify the traversal operation of MPT.Hash ValueAn algorithm that converts data of arbitrary length into a fixed-length string, usually used to verify the integrity of data.
Short Answer Questions
What are smart contracts? How do they work?
What is the role of Merkle Patricia Tree (MPT) in blockchain?
What is the purpose of the logical map proposed in this patent?
How does the logical map help traverse the MPT?
What types of key-value pairs are included in the logical map?
How is the index of the logical map generated?
How to add a new KVP to the logical map?
How to delete a KVP from the logical map?
How does the logical map handle deleted KVPs?
What are the advantages of the method proposed in this patent over the prior art?
Short answer questions
Smart contracts are programs stored on the blockchain that are automatically executed when predefined conditions are met. They achieve decentralization and automation by using code to define and execute the terms of the agreement.
MPT is used to efficiently store and retrieve key-value pairs, such as transaction information and account balances, in the blockchain. It organizes data by using hash pointers, thereby achieving efficient data verification and update.
The logical map is designed to simplify the traversal operation of the MPT, allowing users to more conveniently access and operate data stored in the MPT.
The logical map simplifies the traversal operation by associating the KVP in the MPT with a set of indexes. Users can use these indexes to locate and access specific KVPs in the MPT without having to understand the underlying structure of the MPT.
The logical map contains multiple types of key-value pairs, including key-value pairs representing KVP values in the MPT, key-value pairs representing KVP indexes, and key-value pairs representing the properties of the logical map itself, such as size and length.
The index of the logical map is generated based on the order in which the KVPs are added. When a new KVP is added to the logical map, it is assigned a unique index number.
To add a new KVP to the logical map, first determine a new index number, then associate the new KVP with the index number, and update the size of the logical map.
To delete a KVP from the logical map, mark the index associated with it as "deleted" and reduce the length of the logical map by 1.
The logical map handles deleted KVPs by using "deletion markers". When a KVP is deleted, the index associated with it is not immediately removed from the logical map, but is marked as "deleted".
Compared with the existing technology that requires understanding the underlying structure of MPT, the method proposed in this patent simplifies the traversal operation of MPT, improves data access efficiency, and reduces the complexity of operation.