CN116663050A - Intelligent contract data rapid query method based on database - Google Patents

Intelligent contract data rapid query method based on database Download PDF

Info

Publication number
CN116663050A
CN116663050A CN202310558103.9A CN202310558103A CN116663050A CN 116663050 A CN116663050 A CN 116663050A CN 202310558103 A CN202310558103 A CN 202310558103A CN 116663050 A CN116663050 A CN 116663050A
Authority
CN
China
Prior art keywords
data
version number
intelligent contract
query
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310558103.9A
Other languages
Chinese (zh)
Inventor
邱炜伟
匡立中
李伟
梅王清
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202310558103.9A priority Critical patent/CN116663050A/en
Publication of CN116663050A publication Critical patent/CN116663050A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6227Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database where protection concerns the structure of data, e.g. records, types, queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computational Linguistics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The application discloses a database-based intelligent contract data rapid query method, which comprises the following steps: firstly, a data writer calls an intelligent contract to write data, logs of corresponding operations are recorded according to different operation types in the intelligent contract, the log version number is increased by 1, the data writer can perform multiple operations, then a query service provider queries the latest version number on the intelligent contract, the latest version number is compared with the local version number of the query service provider, and a log set stored in the corresponding intelligent contract is queried according to the version number difference value. And finally, mapping the data change value to a database local to the query service provider, so that the data in the database is consistent with the data in the intelligent contract. The external system can directly inquire the local database, so that the inquiry efficiency is improved. The application calls the database to query the data, and can greatly improve the query efficiency of the data compared with directly calling the intelligent contract to query the data.

Description

Intelligent contract data rapid query method based on database
Technical Field
The application relates to the field of data storage based on a blockchain and the field of data synchronization of storage media with different query efficiencies, in particular to an intelligent contract rapid query method based on a database.
Background
Blockchain technology refers to a technical solution that collectively maintains a reliable database by means of decentralization and de-trust. In colloquial terms, blockchain technology refers to a way for the whole population to participate in billing. Transaction confirmation on the blockchain is completed by consensus of all nodes on the blockchain, and after the consensus is successful, the blocks are packed and written. The blockchain maintains a common ledger for all transactions on the blockchain network, and all systems have a database behind them, which you can see as a big ledger. It becomes important who keeps track of this ledger. At present, the system of whom is accounting, the micro-letter account book is the Tencentrated account book, and the panned account book is the Ali account book. In this way we call it a blockchain technique.
From the user's perspective, a smart contract is generally considered an automatically vouched-for account, e.g., when certain conditions are met, the program releases and transfers funds. From a technical perspective, intelligent contracts are considered web servers, except that these servers are not built on the internet using IP addresses, but on blockchains. So that a specific contract program can be run thereon. The smart contract is an assembly language programmed on the blockchain. Often one will not write bytecodes by himself, but will compile it from higher level languages, such as solubility, LLL, etc., through intelligent contracts to enable data storage, reading and writing, and some logical operations on blockchain, most blockchain applications are currently run based on intelligent contracts. The intelligent contract uses the intelligent language which is complete in figure and can realize all operations of application business logic.
Disclosure of Invention
The non-tamperable nature of the blockchain may guarantee the authority of the data. The feature of blockchain distributed storage may deploy nodes between participants for synchronization of data. The smart contracts on the blockchain may perform preset logic, adding additional logic operations to the stored data. However, because the blockchain needs to use the common knowledge of this process for synchronization of data and tamper resistance, the associated operations on the blockchain for data are not efficient as compared to conventional databases. Based on the problem, the application provides a database-based intelligent contract data rapid query method.
The aim of the application is realized by the following technical scheme: a method for quickly inquiring intelligent contract data based on a database comprises the following steps:
(1) The transaction initiator in the intelligent contract has the authority to write data, the transaction initiator with the writing authority is called a data writer, and the log version number needs to be saved in the intelligent contract, is digital and is incremented from 0. The data writer calls the intelligent contract to write the data.
(2) In the intelligent contract, according to different operation types, logs of corresponding operations are recorded, the logs comprise the types of the operations, the change of data, the time and other log contents agreed by all parties in advance, and a data writer can perform multiple operations, wherein the different operation types comprise adding operation, deleting operation and modifying operation.
(3) The log result after corresponding operation is stored and recorded in the intelligent contract, and the version number is increased by 1 after each operation.
(4) The query service provider has the authority of reading the intelligent contract data, provides the service of querying the intelligent contract data on the blockchain for an external system, has a database locally, and stores the local version number and the data of the query service provider. After the query service provider monitors that the block chain has new block generation or is triggered by a data timing update task preset in advance, the query service provider queries the latest version number on the intelligent contract and compares the latest version number with the local version number of the query service provider.
(5) And if the latest version number stored in the intelligent contract is larger than the local version number of the query service provider, querying the corresponding log set stored in the intelligent contract according to the version difference value.
(6) And carrying out format analysis on the queried log set, analyzing the format into specific adding, deleting or modifying operation, and mapping the specific adding, deleting or modifying operation to a database local to a query service provider according to the data change value so as to enable the data in the database to be consistent with the data in the intelligent contract.
(7) When the external system queries, the query service provider can directly query the local database without directly passing through the intelligent contract, thereby improving the query efficiency.
Further, in the steps (4) and (5), the database in the query service provider performs timing query on the data in the intelligent contract, and performs log query and processing between incremental versions according to the difference between the version number and the local version number of the intelligent contract.
Further, in the steps (6) and (7), the log set of the query is parsed by the log format agreed in advance, and the operations of adding, deleting and modifying the existing data of the local database of the query service provider are performed synchronously. And after synchronization, the data of the database is consistent with the data stored in the intelligent contract, and the subsequent inquiry is directly carried out through the database inquiry.
Further, the query service provider also has a data timing verification task, specifically, the query service provider needs to query the full amount of latest data stored in the intelligent contract, and compares the full amount of latest data with the data stored in the local database. If the data is inconsistent, the local database of the query service provider is tampered, and manual intervention is needed.
The beneficial effects of the application are as follows:
the query service provider performs incremental synchronization on the logs on the intelligent contracts through a version number mechanism, analyzes the log structure after querying the incremental logs, and performs operations of adding, deleting and modifying on the local database, so that the consistency of the local database data and the intelligent contract data is achieved. In addition, the query service provider defines a verification task, and regularly verifies whether the database data and the latest data of the intelligent contract are consistent or not, so that the situation that the data are tampered can be timely found. By the two means, the data in the local database of the data service provider is consistent with the data in the intelligent contract. When the external system needs to inquire the data in the intelligent contract, the inquiry service provider can inquire the data stored in the local database and return the data to the external system.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings that are required to be used in the embodiments or the description of the prior art. It is evident that the drawings in the following description are only some embodiments of the present application and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a data synchronization flow of a database-based intelligent contract data quick query method.
Detailed Description
The database-based intelligent contract data query acceleration method of the present application is further described below in connection with specific embodiments. The described embodiments are only some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
As shown in fig. 1, a method for quickly querying intelligent contract data based on a database, the method comprises the following steps:
(1) The transaction initiator in the intelligent contract has the authority to write data, the transaction initiator with the writing authority is called a data writer, and the log version number needs to be saved in the intelligent contract, is digital and is incremented from 0. The data writer calls the intelligent contract to write the data.
(2) In the intelligent contract, according to different operation types, logs of corresponding operations are recorded, the logs comprise the types of the operations, the change of data, the time and other log contents agreed by all parties in advance, and a data writer can perform multiple operations, wherein the different operation types comprise adding operation, deleting operation and modifying operation.
(3) The log result after corresponding operation is stored and recorded in the intelligent contract, and the version number is increased by 1 after each operation.
(4) The query service provider has the authority of reading the intelligent contract data, provides the service of querying the intelligent contract data on the blockchain for an external system, has a database locally, and stores the local version number and the data of the query service provider. After monitoring that a new block is generated in the block chain or a preset data timing update task is triggered in advance, the query service provider queries the latest version number on the intelligent contract, and performs log query and processing between incremental versions according to the difference between the version number and the local version number of the intelligent contract. The query service provider also has a data timing verification task, specifically, the query service provider needs to query the full amount of latest data stored in the intelligent contract and compare the full amount of latest data with the data stored in the local database. If the data is inconsistent, the local database of the query service provider is tampered, and manual intervention is needed.
(5) And if the latest version number stored in the intelligent contract is larger than the local version number of the query service provider, querying the corresponding log set stored in the intelligent contract according to the version difference value.
(6) Analyzing the log set of the query through the log format agreed in advance, carrying out synchronous adding, deleting and modifying operation on the existing data of the local database of the query service provider, mapping to the local database of the query service provider according to the data change value, enabling the data in the database to be consistent with the data in the intelligent contract, and inquiring the follow-up query through the database.
(7) When the external system queries, the query service provider can directly query the local database without directly passing through the intelligent contract, thereby improving the query efficiency.
Examples:
fig. 1 is a data synchronization flow of an intelligent contract data query acceleration method based on a database according to the present embodiment. The method may be as follows. In this embodiment, a scene that may actually occur is taken as an example. The data writer in the scene is an authority A, the citizen data is stored in the intelligent contract, the query service provider is a query system B provided by the authority, the external system is an enterprise C, and the enterprise C needs to query the citizen data through the query system B, and the specific scene is described in detail below as an example.
The authority A is composed of a plurality of sub-mechanisms, which maintain blockchain nodes to form a blockchain network. An intelligent contract is defined on the blockchain network, the intelligent contract stores citizen data, an authority A has write-in authority, and a query system B has read-in authority. The smart contract stores a version number, which is data, incremented from 0.
The authority A writes the data and the corresponding operation log into the intelligent contract when the citizen data is newly added, modified and deleted, and the intelligent contract increases the version number according to preset intelligent contract logic.
Query system B the local database stores the local version number.
The query system B queries the intelligent contracts on the blockchain for the latest version number when the blockchain change or the predefined data synchronization task trigger is monitored.
If the latest version number stored in the intelligent contract is greater than the version number stored in the local database of the query system B, the log set corresponding to the difference value of the two version numbers in the intelligent contract needs to be queried.
And the query system B sequentially analyzes the records in the database according to the queried log set, and performs operations of adding, deleting and modifying the records in the database.
When the predefined data checking task is triggered, the query system B needs to query the latest full-quantity data in the intelligent contracts on the blockchain and compare the latest full-quantity data with the local database data. If the data is found to be inconsistent, the local database is tampered, and manual processing is needed.
And the enterprise C inquires the required citizen data through the inquiry system B, and the inquiry system B returns to the database required by the enterprise C after screening in the local database.
Compared with the method that the intelligent contract is directly called to perform data query, the database is called to perform data query, and the data query efficiency can be greatly improved.
The above-described embodiments are intended to illustrate the present application, not to limit it, and any modifications and variations made thereto are within the spirit of the application and the scope of the appended claims.

Claims (10)

1. The method is applied to a server of a query service provider, wherein the query service provider has the reading authority of an intelligent contract and a local database, and the local database stores the local version number and data of the query service provider, and is characterized by comprising the following steps:
inquiring the latest version number on the intelligent contract when the block chain meets the first preset condition;
if the latest version number is larger than the local version number, determining a version number difference value between the latest version number and the local version number, and determining a log set corresponding to the version number difference value from the intelligent contract based on the version number difference value;
performing format analysis on the log set to determine data change information in the intelligent contract, and updating a local database based on an operation type corresponding to the data change information and change data; the local database stores data in the smart contracts and provides data query services for external systems with respect to the smart contracts.
2. The method of claim 1, wherein querying the latest version number on the smart contract when the blockchain is determined to satisfy the first preset condition comprises:
and inquiring the latest version number when determining that a new block is generated on the block chain or a preset data timing update task is triggered.
3. The method of claim 1, wherein the determining a version number difference between the latest version number and the local version number and determining a set of logs corresponding to the version number difference from the smart contract based on the version number difference comprises:
and performing incremental query and processing on the logs in the intelligent contract based on the version number difference value to determine the log set.
4. The method of claim 1, wherein the operation types include an add type, a delete type, and a modify type.
5. The method of claim 1, wherein the parsing the log collection to determine data change information in the smart contract and updating a local database based on the type of operation and change data corresponding to the data change information comprises:
analyzing the log set based on a preset log format to acquire the data change information;
executing data operation corresponding to the operation type on the local database based on the data change information so as to generate data change corresponding to the data change information on the existing data in the local database, so that the data stored in the local database is consistent with the data in the intelligent contract; the data operations include data operations of at least one operation type of an add operation, a delete operation, and a modify operation.
6. The method of claim 5, wherein the parsing the log collection to determine data change information in the smart contract and updating a local database based on the type of operation and change data corresponding to the data change information comprises:
sequentially analyzing the log sets to determine data change information in the intelligent contract; the data change information includes an operation type and change data.
7. The method of claim 1, wherein querying for the latest version number on the smart contract when the blockchain is determined to satisfy the first preset condition comprises:
periodically inquiring the total latest data in the intelligent contract;
and if the total latest data is inconsistent with the existing data in the local database, determining that the local database is tampered.
8. A database-based smart contract data rapid query method applied to a device for providing smart contracts in a blockchain, comprising:
when a data writer invokes an intelligent contract to write data, generating a log on the write operation based on the operation type corresponding to the write operation, a data change value, time and pre-agreed log content; the data writer is a transaction initiator with writing authority in the blockchain;
increasing the existing version number in the intelligent contract based on preset intelligent contract logic; the version number is used for determining a version number difference value at a query service provider; the version number difference value is used by the query service provider for querying a corresponding log set; the log set is used for enabling data stored in a local database of the query service party to be consistent with data in the intelligent contract.
9. The method of claim 8, wherein the version number has an initial value of 0 and is incremented from 0.
10. The method of claim 8, wherein the predetermined smart contract logic adds 1 to the version number each time a write operation is performed by the data writer; the operation types of the write operation include a delete type, an add type, and a modify type.
CN202310558103.9A 2019-12-31 2019-12-31 Intelligent contract data rapid query method based on database Pending CN116663050A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310558103.9A CN116663050A (en) 2019-12-31 2019-12-31 Intelligent contract data rapid query method based on database

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911418150.3A CN111143476B (en) 2019-12-31 2019-12-31 Intelligent contract data rapid query method based on database
CN202310558103.9A CN116663050A (en) 2019-12-31 2019-12-31 Intelligent contract data rapid query method based on database

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201911418150.3A Division CN111143476B (en) 2019-12-31 2019-12-31 Intelligent contract data rapid query method based on database

Publications (1)

Publication Number Publication Date
CN116663050A true CN116663050A (en) 2023-08-29

Family

ID=70522914

Family Applications (2)

Application Number Title Priority Date Filing Date
CN201911418150.3A Active CN111143476B (en) 2019-12-31 2019-12-31 Intelligent contract data rapid query method based on database
CN202310558103.9A Pending CN116663050A (en) 2019-12-31 2019-12-31 Intelligent contract data rapid query method based on database

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN201911418150.3A Active CN111143476B (en) 2019-12-31 2019-12-31 Intelligent contract data rapid query method based on database

Country Status (1)

Country Link
CN (2) CN111143476B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111813788A (en) * 2020-05-20 2020-10-23 北京金山云网络技术有限公司 Information query method and device and information synchronization method and device
CN112417033A (en) * 2020-10-19 2021-02-26 中国科学院计算机网络信息中心 Method and system for realizing multi-node data consistency of distributed graph database
CN112434108A (en) * 2020-11-10 2021-03-02 深圳市明源云科技有限公司 Database synchronization method, device and equipment
CN112905536B (en) * 2021-02-07 2024-01-02 全链通有限公司 Data verification synchronization method and device based on block chain
CN113065871A (en) * 2021-04-22 2021-07-02 中国工商银行股份有限公司 Transaction data processing method and device
CN113312365A (en) * 2021-05-27 2021-08-27 上海万向区块链股份公司 Method, system, medium and equipment for quickly inquiring intelligent contract data

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100082538A1 (en) * 2008-09-29 2010-04-01 Heiko Rentsch Isolated replication of shared objects
US9529880B2 (en) * 2014-05-28 2016-12-27 International Business Machines Corporation Synchronizing a disaster-recovery system of a database
CN107918666B (en) * 2017-11-24 2020-05-12 中钞信用卡产业发展有限公司杭州区块链技术研究院 Data synchronization method and system on block chain
US20190305957A1 (en) * 2018-04-02 2019-10-03 Ca, Inc. Execution smart contracts configured to establish trustworthiness of code before execution
CN109255251B (en) * 2018-10-31 2023-10-10 安徽中科晶格技术有限公司 File data protection system and method based on block chain technology

Also Published As

Publication number Publication date
CN111143476B (en) 2023-06-27
CN111143476A (en) 2020-05-12

Similar Documents

Publication Publication Date Title
CN111143476B (en) Intelligent contract data rapid query method based on database
CN107038242B (en) Block chain-oriented global intelligent contract service data analysis method
WO2020237797A1 (en) Dynamic configuration management method and system in microservice framework
CN107402963B (en) Search data construction method, incremental data pushing device and equipment
US20020062237A1 (en) Transactional monitoring system and method
CN102929771B (en) Log recording apparatus and log recording method
CN109857724B (en) Method and equipment for supporting various databases based on block chain
US20080212616A1 (en) Services For Data Sharing And Synchronization
CN110263014A (en) Block chain storage system and method towards timing type data
US11176173B2 (en) Arrangement for enriching data stream in a communications network and related method
CN112380180A (en) Data synchronization processing method, device, equipment and storage medium
CN109918435A (en) A kind of processing method and system of business interface
CN103645908A (en) Full life circle development achievement system of intemetware
CN112905616B (en) Storage system of block chain account book
CN108536521A (en) Based on emulation platform offline environment checking method and device
WO2023011022A1 (en) Blockchain-based data processing method, and device and computer-readable storage medium
CN102355499A (en) Cloud computing system
US20070208577A1 (en) Position common object
CN113486114B (en) Block chain intelligent contract calling management method
CN114385760A (en) Method and device for real-time synchronization of incremental data, computer equipment and storage medium
CN112214802B (en) Block chain intelligent contract message publishing and subscribing method
CN108280215A (en) A kind of hybrid update method of the electric business index file based on Solr
CN113111125A (en) Business evidence storage method based on block chain
CN116360931A (en) Link tracking method, device, system and storage medium
CN110275893A (en) A kind of data manipulation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination