CN116541397A - State data query method and device - Google Patents

State data query method and device Download PDF

Info

Publication number
CN116541397A
CN116541397A CN202310477379.4A CN202310477379A CN116541397A CN 116541397 A CN116541397 A CN 116541397A CN 202310477379 A CN202310477379 A CN 202310477379A CN 116541397 A CN116541397 A CN 116541397A
Authority
CN
China
Prior art keywords
state
state data
transaction
target
query
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
CN202310477379.4A
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.)
East China Normal University
Ant Blockchain Technology Shanghai Co Ltd
Original Assignee
East China Normal University
Ant Blockchain Technology Shanghai 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 East China Normal University, Ant Blockchain Technology Shanghai Co Ltd filed Critical East China Normal University
Priority to CN202310477379.4A priority Critical patent/CN116541397A/en
Publication of CN116541397A publication Critical patent/CN116541397A/en
Pending legal-status Critical Current

Links

Classifications

    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • 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
    • 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
    • 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)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

One or more embodiments of the present disclosure provide a method and an apparatus for querying status data. The method is applied to a block chain system, a state tree and a state database special for state data query are maintained in the block chain system, and the state database records the mapping relation between an account and state data thereof in the form of key value pairs; wherein, the blockchain system is configured with a query index for each group of mapping relations; the method comprises the following steps: under the condition that the received transaction is used for inquiring state data, reading index information contained in the transaction to determine a target mapping relation corresponding to the index information from the state database based on the index information; and returning the target state data contained in the target mapping relation to the initiator of the transaction.

Description

State data query method and device
Technical Field
One or more embodiments of the present disclosure relate to the field of blockchain technologies, and in particular, to a method and an apparatus for querying status data.
Background
The blockchain technology (also called as the distributed ledger technology) is a decentralised distributed database technology, has various characteristics of decentralization, disclosure transparency, non-tampering, trust and the like, and is suitable for application scenes with high demands on data reliability.
In view of the above advantages of blockchain technology, users pay more and more attention to their own private data, and large amounts of data are stored in blockchain systems.
Disclosure of Invention
In view of this, one or more embodiments of the present disclosure provide a method and apparatus for querying status data.
In order to achieve the above object, one or more embodiments of the present disclosure provide the following technical solutions:
according to a first aspect of one or more embodiments of the present specification, a state data query method is provided, and is applied to a blockchain system, wherein a state tree and a state database dedicated to state data query are maintained in the blockchain system, and the state database records a mapping relation between an account and state data thereof in the form of key value pairs; wherein, the blockchain system is configured with a query index for each group of mapping relations; the method comprises the following steps:
under the condition that the received transaction is used for inquiring state data, reading index information contained in the transaction to determine a target mapping relation corresponding to the index information from the state database based on the index information;
and returning the target state data contained in the target mapping relation to the initiator of the transaction.
According to a second aspect of one or more embodiments of the present specification, a state data certification method is presented, applied to a blockchain system in which a state tree and a state database dedicated to state data queries are maintained; the method comprises the following steps:
acquiring to-be-authenticated state data of a target account, and storing the mapping relation between the target account and the to-be-authenticated state data into the state database in a key value pair mode;
and configuring a query index for the mapping relation.
According to a third aspect of one or more embodiments of the present specification, a state data query device is provided, which is applied to a blockchain system, wherein a state tree and a state database dedicated to state data query are maintained in the blockchain system, and the state database records the mapping relation between an account and state data thereof in the form of key value pairs; wherein, the blockchain system is configured with a query index for each group of mapping relations; the device comprises:
a determining unit, configured to read index information included in a received transaction when the received transaction is used to query status data, so as to determine a target mapping relationship corresponding to the index information from the status database based on the index information;
And the return unit returns the target state data contained in the target mapping relation to the initiator of the transaction.
According to a fourth aspect of one or more embodiments of the present specification, a state data certification device is presented for use in a blockchain system having a state tree maintained therein and a state database dedicated to state data queries; the device comprises:
the verification unit is used for obtaining to-be-verified state data of a target account, and verifying the mapping relation between the target account and the to-be-verified state data to the state database in a key value pair mode;
and the configuration unit configures a query index for the mapping relation.
According to a fifth aspect of one or more embodiments of the present specification, there is provided an electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of the first or second aspect by executing the executable instructions.
According to a sixth aspect of one or more embodiments of the present description, there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method according to the first or second aspect.
Drawings
Fig. 1 is a flow chart of a method for storing status data according to an exemplary embodiment.
Fig. 2 is a flow chart of a method for querying status data according to an exemplary embodiment.
Fig. 3 is an interaction diagram of a method for storing status data according to an exemplary embodiment.
Fig. 4 is an interaction diagram of a method for querying status data according to an exemplary embodiment.
Fig. 5 is a schematic diagram of an apparatus according to an exemplary embodiment.
Fig. 6 is a block diagram of a status data querying device provided by an exemplary embodiment.
Fig. 7 is a block diagram of a state data certification device provided by an exemplary embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of the present specification. Rather, they are merely examples of apparatus and methods consistent with aspects of one or more embodiments of the present description as detailed in the accompanying claims.
It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than described in this specification. Furthermore, individual steps described in this specification, in other embodiments, may be described as being split into multiple steps; while various steps described in this specification may be combined into a single step in other embodiments.
In view of the fact that the blockchain technology has the characteristics of decentralization, non-tampering and the like, more and more users choose to document data to the blockchain system so as to ensure the security of the data. The data maintained in the blockchain system may include block data and status data, wherein the block data is multi-fingered: transaction data packed into blocks; and the state data is multi-fingered: the data used for recording the transaction execution result, which is updated continuously along with the transaction execution, is usually recorded in the state tree of the corresponding block. The state tree may be, for example, an MPT tree or a merck tree, etc.
Since the state data is recorded in the state tree, in the process of actually searching the state data, the blockchain system needs to search the state tree of a plurality of blocks until the target state data is searched in the specific state tree of the specific block.
It should be understood that, because any state tree in the related art records the full amount of state data of the block corresponding to itself and all previous history blocks, when searching the state data in any state tree, the related art needs to traverse each node of the state tree, and most likely cannot search the required state data in a single state tree, so that the related art needs to traverse each node of a plurality of state trees to search the required state data, and different state trees usually maintain nodes corresponding to the same account, so that the related art repeatedly searches the state data of the same account. Therefore, the related art has serious problems of reading and amplifying in a mode of searching the state data in the state tree, and the state data searching efficiency is quite low.
For this purpose, the present specification proposes a state data query method that generates a state database dedicated to state data query in addition to recording state data in a state tree, and records the mapping relationship of an account and its state data in the state database in the form of key value pairs. On the basis, the blockchain system in the specification can search the required state data in the state database, and the state database stores the state data in a key value pair mode, so that the query efficiency is far higher than that of a mode of traversing state tree nodes in the related technology, and the condition that the related technology queries repeated nodes of the same account in different state trees does not exist, so that the required state data can be quickly searched.
Since the present specification generates a state database dedicated to the state data query, the state data certification method of the present specification is preferentially described before the state data query method of the present specification is described.
Fig. 1 is a flowchart of a method for storing status data according to an exemplary embodiment of the present disclosure. The method is applied to a blockchain system in which a state tree and a state database dedicated to state data queries are maintained. As shown in fig. 1, the method may include the steps of:
step 102, obtaining to-be-authenticated state data of a target account, and storing the mapping relation between the target account and the to-be-authenticated state data in the state database in a key value pair mode.
As described above, in addition to the state tree, the present specification may construct a state database dedicated to the state data query to verify the mapping of each account to its state data in the form of key-value pairs. In the actual implementation process, the blockchain system can pre-construct the state database so as to store the acquired state data at any time.
In this specification, a target account refers to: and the account to which the state data to be stored belongs. The present description may obtain the to-be-authenticated status data of the target account in a variety of ways.
In one embodiment, because the state tree maintains the stored state data, the blockchain system may obtain the state data of at least one account stored to the state tree as to-be-stored state data that needs to be stored to the state database. For example, the state data of each account may be acquired from the state tree, and the acquired state data may be recorded in the state database with each account acquired as a key and the acquired state data as a value.
In another embodiment, since the status data is updated based on the execution of the transaction, the updated status data may be acquired as the to-be-authenticated status data of the target account in the case where the update operation of the status data of the target account is completed based on the received transaction.
Of course, the above two embodiments are merely illustrative, and how the blockchain system obtains the state data stored in the state database can be determined by those skilled in the art according to the practical situation, it should be understood that any available state data can be used as the state data stored in the state database, and the obtaining manner is not limited in this specification.
In the present specification, after obtaining the state data to be authenticated of the target account, the mapping relationship between the target account and the state data to be authenticated may be authenticated to the state database in the form of a key value pair. For example, a mapping relationship can be constructed by taking a target account as a key and state data to be stored as a value, and the mapping relationship is stored in a state database; or the mapping relation can be constructed by taking the state data to be stored as a key and the target account as a value, and the mapping relation is stored in a state database. It should be understood that, in particular, how to document the target account and its state data to be authenticated to the state database in the form of key-value pairs, which can be determined by those skilled in the art according to actual requirements, and this specification is not limited thereto.
It is noted that, the present specification may construct the mapping relationship between the target account and the state data to be authenticated in different ways. For example, in the mapping relationship, the target account may be characterized by one of "account address of the target account, hash value of the account address, unique identifier of the target account"; the state data to be authenticated may be characterized by one of "original data of the state data, hash value of the original data, unique identifier of the state data". Of course, the examples herein are merely illustrative, and the specific manner in which the target account and its state data to be authenticated are represented in the mapping relationship may be determined by those skilled in the art according to actual needs, which is not limited in this specification.
Step 104, configuring a query index for the mapping relation.
In the present specification, after the mapping relationship between the target data and the state data to be authenticated is authenticated to the state database in the form of key value pairs, a query index may be configured for the mapping relationship, so as to perform a query based on the query index when the state data needs to be queried.
In one embodiment, the specification may configure the query index for its mapping according to the target account. For example, the account address of the target account may be configured as a query index of the mapping relationship of the target account; for another example, the unique identifier of the target account may be configured as a query index of the mapping relationship of the target account; for another example, the hash value of the account address of the target account may be used as the query index of the mapping relationship of the target account. Of course, the examples herein are merely illustrative, and specific how to configure the query index for the mapping relationship according to the target account can be determined by those skilled in the art according to actual requirements, which is not limited in this specification.
In another embodiment, the forensic status data of the target account may include: attribute information of the target account in a plurality of dimensions. For example, the attribute information for the plurality of dimensions may include "account type of the target account, such as a personal account, a collective account, and the like; a unique identifier of the target account; the party to which the target account belongs; at least one of the description information "of the party to which the target account belongs, of course, this example is merely illustrative, and the attribute information of the target account in multiple dimensions may specifically include which information may be determined by those skilled in the art according to the actual situation, which is not limited in this specification.
In this embodiment, when the to-be-authenticated status data includes attribute information of a plurality of dimensions, the attribute information of at least one of the plurality of dimensions may be used as a query index of the mapping relationship of the target account. For example, if the to-be-authenticated status data of the target account includes "the unique identifier of the target account, the description information of the target account, and the account type information of the target account", the unique identifier of the target account may be set as the query index of the mapping relationship of the target account. Of course, this example is also illustrative, and when the to-be-authenticated status data includes attribute information of multiple dimensions, how to set the query index may be determined by those skilled in the art according to actual needs, which is not limited in this specification.
In this specification, the query indexes configured by the blockchain system for each set of mappings may have sequential relationships. On the basis, when the state data is required to be queried, a querying party can search the range in the state database only by providing the index range so as to acquire the state data in batches.
It should be stated that, the blockchain system in the present specification may be deployed based on the conventional architecture of the blockchain technology, that is, all nodes in the blockchain system are formed by deploying blockchain codes on corresponding physical devices, and in most cases, each node corresponds to one physical device; the blockchain system of the specification can also be deployed based on a BaaS (Blockchain as a Service) architecture in the blockchain technology, namely all nodes in the blockchain system are formed by deploying blockchain codes on virtual machines realized by cloud services, and the blockchain nodes do not need to correspond to corresponding entity devices one by one.
According to the technical scheme, the state data of the account is maintained through the state tree, and the state data is recorded in the additionally constructed state database. The state database stores the mapping relation of the account and the state data thereof in the form of key value pairs, so that the state data can be quickly queried in the specification, and the problem of low state data query efficiency caused by the fact that the state data is required to be queried in a state tree in the related technology is avoided.
Fig. 2 is a flowchart of a status data query method according to an exemplary embodiment of the present disclosure. The method is applied to a block chain system, a state tree and a state database special for state data query are maintained in the block chain system, and the state database records the mapping relation between an account and state data thereof in the form of key value pairs; the block chain system is configured with a query index for each set of mapping relationships. As shown in fig. 2, the method may include the steps of:
step 202, under the condition that the received transaction is used for inquiring state data, reading index information contained in the transaction, so as to determine a target mapping relation corresponding to the index information from the state database based on the index information.
As described above, the blockchain system in this specification may record the mapping of accounts and their state data in the form of key-value pairs in a state database. For example, the certification may be performed in the manner shown in fig. 1, and the related content may be described above, which is not repeated here.
In this specification, when a transaction is received, the blockchain system may preferentially determine whether the received transaction is used for querying state data, and if yes, read index information included in the transaction to query state data in a state database. In this specification, a mapping relationship queried from the state database based on the index information may be referred to as a target mapping relationship.
In the present specification, the target mapping relationship may be searched from the state database according to the read index information in various manners.
In one embodiment, the account addresses of the respective accounts are indexed by the blockchain system as queries of the respective mappings. In this case, if the querying party needs to query the state data of the target account, the account address of the target account, that is, the target account address, may be added as index information to the transaction, and on this basis, the blockchain system may read the target account address included in the transaction, so as to determine, from the state database, the target mapping relationship corresponding to the target account address based on the target account address.
In another embodiment, the state data of any set of mappings in the state database may comprise, as described above: attribute information of the respective account in a plurality of dimensions, and attribute information of at least one of the plurality of dimensions is used as a query index of the respective mapping relation by the blockchain system. In this case, if the querying party needs to query the state data of the target account, the target attribute information of the target account in the at least one dimension may be added as a query index to the transaction, so that the blockchain system may read the target attribute information belonging to the at least one dimension included in the transaction, and determine, from the state database, a target mapping relationship corresponding to the target attribute information based on the read target attribute information. On the basis, the attribute information belonging to the plurality of dimensions in the target mapping relation can be returned to the sponsor of the transaction as the searched target state data.
In this specification, as described above, there may be a sequential relationship between the query indexes configured for the respective sets of mapping relationships. In this case, when the querying party needs to query the target mapping relationship from the state database, an index range may be added in the transaction, and on this basis, the blockchain system may read the index range included in the transaction, and determine, from all the query indexes, a plurality of query indexes belonging to the index range, so as to determine a plurality of groups of target mapping relationships respectively corresponding to the plurality of query indexes.
In this specification, the blockchain system may execute a transaction in a different manner after making a determination as to whether the transaction is for a status data query. And if the transaction is used for inquiring the state data, executing the inquiring operation based on the state database, otherwise, executing the transaction based on the state data in the state tree.
For example, a transaction processing contract may be pre-deployed in a blockchain system, and the transaction processing contract may include a tree call interface for a state tree and a library call interface for a state database. On the basis, the blockchain system can execute the transaction processing contract under the condition of receiving the transaction so as to read the information contained in the transaction processing contract, and if the read information contains index information, the transaction is determined to be used for inquiring the state data, so that a state database can be called through a library calling interface contained in the transaction processing contract so as to determine a target mapping relation corresponding to the index information contained in the transaction from the state database. In contrast, if the information read from the received transaction by executing the transaction processing contract does not include index information, it may be determined that the transaction is not for querying the status data, and therefore, the status tree may be invoked through a tree invocation interface included in the transaction processing contract to execute the transaction based on the information recorded in the status tree.
In other words, the present description performs a query operation based on a status database in the case where a received transaction is used to query status data; and in the event that the received transaction is not for querying the status data, the transaction is performed based on the information recorded in the status tree.
In this specification, the transaction processing contract described above may include state data query logic for querying state data in a state database. On the basis, the blockchain system can call and execute a transaction processing contract under the condition of receiving a transaction to read information contained in the transaction, and execute state data query logic contained in the transaction processing contract under the condition that the read information contains index information to determine a target mapping relation corresponding to the index information from a state database based on the read index information.
Of course, the foregoing examples are merely illustrative, and in particular, how to determine the target mapping relationship corresponding to the index information from the state database when the received transaction is used for the state data query, which may be determined by those skilled in the art according to actual requirements, and the present specification is not limited thereto.
And step 204, returning the target state data contained in the target mapping relation to the initiator of the transaction.
In the present specification, after the target mapping relationship is queried, the target state data contained in the target mapping relationship may be returned to the initiator of the transaction. For example, because the state database stores the account and its state data in the form of key-value pairs, if the blockchain system stores the state data as a value in a key-value pair, the value in the target mapping relationship may be read after the target mapping relationship is queried and returned to the initiator of the transaction.
Of course, instead of returning only the found status data to the initiator of the transaction, all the information contained in the target mapping relationship may be directly returned to the initiator, which is not limited in this specification.
It should be stated that, the blockchain system in the present specification may be deployed based on the conventional architecture of the blockchain technology, that is, all nodes in the blockchain system are formed by deploying blockchain codes on corresponding physical devices, and in most cases, each node corresponds to one physical device; the blockchain system of the specification can also be deployed based on a BaaS (Blockchain as a Service) architecture in the blockchain technology, namely all nodes in the blockchain system are formed by deploying blockchain codes on virtual machines realized by cloud services, and the blockchain nodes do not need to correspond to corresponding entity devices one by one.
According to the technical scheme, the state database which is different from the state tree is constructed in the specification, and the mapping relation of the account and the state data thereof is stored in the state database in the form of key value pairs, so that the specification can directly inquire the required state data from the state database in the state data inquiry stage.
It should be understood that, in the related art, the state data of the account is stored in the state tree, both the merck tree and the MPT tree need to store the total amount of state data, that is, the state data of each account, in the state tree corresponding to each block, so in the query stage of the state data, not only each node of a single state tree needs to be traversed, but also nodes of the same account in different state trees may be repeatedly queried, which causes serious query amplification problem and reduces the query efficiency of the state data. The state database additionally constructed in the specification stores the state data in the form of key value pairs, so that the problem of query amplification caused by repeated query and the like is avoided, and the data query efficiency stored in the form of key value pairs is high, so that the query efficiency of the state data is greatly improved through the technical scheme of the specification.
The technical scheme of the present specification will be described below by taking the constructed status database as a KV database and the recorded status data as student information as an example.
Fig. 3 is an interaction diagram of a method for storing status data according to an exemplary embodiment of the present disclosure. As shown in fig. 2, the method may comprise the steps of:
in step 301, the depositor generates status data depositor transactions based on student information.
In this embodiment, since the status data requiring the certification is student information, the certification party may be a teacher, a teaching owner, or the like, who is responsible for managing the student information. The student information that needs to be checked by the checking party specifically includes which can be determined according to the actual situation, for example, may include the number, name, sex, age, etc., which is not limited in this embodiment. After the depositor obtains student information, the depositor can input the student information into equipment held by the depositor so as to generate state data depositor transaction, and the generated transaction is sent to the blockchain system.
Step 302, the depositor sends the generated status data depositor transaction to the blockchain system.
In step 303, the blockchain system reads student information contained in the transaction.
In this embodiment, after receiving the status data certification transaction, the blockchain system may read student information included in the transaction, so as to certify the read information in the form of key value pairs in a pre-constructed KV database.
Step 304, the blockchain system stores the student information in the KV database in the form of key value pairs.
By adopting the above example, the embodiment can use the student's number as the unique account identifier of the corresponding student, so as to use the student's number as the Key Value in the mapping relationship, and use the name, sex, age and the like as the Value, and store the Value in the KV database. For example, after the certification is completed, the mapping relationship recorded in the KV database may be as shown in the following table one:
TABLE 1
Notably, the present embodiment can default the Key value to the query index, so that the blockchain system queries the various information of the student based on the student's number in the data query phase.
It should also be noted that various information for each student is also validated to the status tree for use by the blockchain system to perform other operations.
Next, after the student information is stored in the KV database based on the storage method shown in fig. 3, various data of the student can be obtained from the blockchain system through the method shown in fig. 4.
Fig. 4 is an interaction diagram of a status data query method according to an exemplary embodiment of the present disclosure. As shown in fig. 4, the method may include the steps of:
in step 401, a querying party generates status data query transactions based on student numbers.
In this embodiment, the inquirer may determine according to the actual situation, for example, may be the above-mentioned certificate depositor, may be a parent of a student, and so on. The inquirer can use the student number as an inquiry index to generate a status data inquiry transaction and send the generated status data inquiry transaction to the blockchain system.
In step 402, the querying party sends a status data query transaction to the blockchain system.
In step 403, the blockchain system reads the student number included in the query transaction.
In this embodiment, after receiving the status data query transaction, the blockchain system may read the student number contained therein to query the status data from the KV database based on the student number.
At step 404, the blockchain system queries status data from the KV database based on the student number.
In this embodiment, a transaction processing contract may be pre-deployed in the blockchain system for reading information from a received transaction and executing the transaction based on the read information. When the received transaction includes a query index for querying the status data, for example, the number in this embodiment, a library call interface of the KV database included in the transaction processing contract may be called to query the status data from the KV database.
For example, assuming that the query index included in the status data query transaction is number 1, the Value corresponding to key=1 may be "name: xiaoming; gender: a male; age: 16 "are returned to the querying party as queried state data. Assuming that the query index included in the status data query transaction may be in the range of "1-3", the Value corresponding to key=1, the Value corresponding to key=2, and the Value corresponding to key=3 may be returned to the querying party, i.e. student information of all three of Xiaoming, xiaohong, and Xiaobai.
Notably, the blockchain system in the present embodiment can deploy the transaction processing contracts in a variety of ways. For example, in a blockchain system such as an ethernet, where a smart contract already exists for executing transactions, a technician may, based on the existing smart contract, double encode the smart contract so that it may call a state database, such as the technician may add a library call interface of the state database described above to the smart contract for calling the state database. Of course, this example is merely illustrative, and how to deploy the transaction processing contract may be determined by one skilled in the art according to actual needs, which is not limited by the present embodiment.
The blockchain system returns the queried state data to the querying party, step 405.
According to the technical scheme, the state database which stores the mapping relation between the account and the state data in the form of key value pairs is constructed by the blockchain system, so that the blockchain system can directly inquire the state data in the state database when receiving the transaction for inquiring the state data, and the problem of inquiry amplification caused by inquiring the state data in the state tree in the related technology is avoided.
Fig. 5 is a schematic block diagram of an apparatus according to an exemplary embodiment. Referring to fig. 5, at the hardware level, the device includes a processor 502, an internal bus 504, a network interface 506, a memory 508, and a nonvolatile memory 510, although other hardware may be included as needed for other services. One or more embodiments of the present description may be implemented in a software-based manner, such as by the processor 502 reading a corresponding computer program from the non-volatile storage 510 into the memory 508 and then running. Of course, in addition to software implementation, one or more embodiments of the present disclosure do not exclude other implementation manners, such as a logic device or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or a logic device.
Referring to fig. 6, the status data query device may be applied to the apparatus shown in fig. 5 to implement the technical solution of the present specification. The state data query device is applied to a block chain system, a state tree and a state database special for state data query are maintained in the block chain system, and the state database records the mapping relation between an account and state data thereof in the form of key value pairs; wherein, the blockchain system is configured with a query index for each group of mapping relations; the apparatus may include:
a determining unit 601, configured to read index information included in a received transaction when the received transaction is used to query status data, so as to determine, from the status database based on the index information, a target mapping relationship corresponding to the index information;
and a return unit 602, configured to return the target state data included in the target mapping relationship to the initiator of the transaction.
Optionally, the account address of each account is used as a query index of the corresponding mapping relation by the blockchain system; the determining unit 601 is further configured to:
and reading a target account address contained in the transaction, so as to determine a target mapping relation corresponding to the target account address from the state database based on the target account address.
Optionally, the state data of any set of mapping relations in the state database includes: attribute information of the corresponding account in multiple dimensions; attribute information of at least one dimension of the plurality of dimensions is used as a query index of a corresponding mapping relation by the blockchain system;
the determining unit 601 is further configured to: reading target attribute information belonging to the at least one dimension contained in the transaction, so as to determine a target mapping relation corresponding to the target attribute information from the state database based on the read target attribute information;
the return unit 602 is further adapted to: and returning the attribute information belonging to the multiple dimensions in the target mapping relation to the initiator of the transaction as target state data.
Optionally, a sequential relationship exists between the query indexes configured for each group of mapping relationships; the determining unit 601 is further configured to:
and reading the index range contained in the transaction, and determining a plurality of query indexes belonging to the index range from all query indexes to determine a plurality of groups of target mapping relations respectively corresponding to the plurality of query indexes.
Optionally, the determining unit 601 is further configured to:
Invoking a transaction processing contract, wherein the transaction processing contract comprises a tree invoking interface of the state tree and a library invoking interface of the state database;
executing the transaction processing contract to read information contained in the received transaction, and calling the state database through the library calling interface under the condition that the read information contains index information so as to determine a target mapping relation corresponding to the index information from the state database.
Optionally, the determining unit 601 is further configured to:
invoking a transaction processing contract, wherein the transaction processing contract comprises a tree invoking interface of the state tree and a library invoking interface of the state database;
executing the transaction processing contract to read information contained in the received transaction, and calling the state tree through the tree calling interface to execute the transaction based on the information recorded in the state tree under the condition that the read information does not contain index information.
Optionally, the determining unit 601 is further configured to:
and calling and executing a transaction processing contract to read information contained in the received transaction, and executing state data query logic contained in the transaction processing contract under the condition that index information is contained in the read information so as to determine a target mapping relation corresponding to the index information from the state database based on the index information.
Referring to fig. 7, the state data storage device may be applied to the apparatus shown in fig. 5 to implement the technical solution of the present specification. The state data certification device is applied to a block chain system, and a state tree and a state database special for state data inquiry are maintained in the block chain system; the apparatus may include:
the verification unit 701 obtains to-be-verified state data of a target account, and verifies the mapping relation between the target account and the to-be-verified state data to the state database in a key value pair mode;
the configuration unit 702 configures a query index for the mapping relation.
Optionally, the certification unit 701 is further configured to:
acquiring state data of at least one account which is already stored in the state tree, and taking the state data as to-be-stored state data of the state database; or alternatively, the process may be performed,
and under the condition that the updating operation of the state data of the target account is completed based on the received transaction, acquiring the updated state data, and taking the acquired updated state data as the to-be-stored state data of the target account.
Alternatively to this, the method may comprise,
the configuration unit 702 is further configured to: configuring an account address of the target account as a query index of the mapping relation; or alternatively, the process may be performed,
The state data to be stored comprises: attribute information of the target account in multiple dimensions; the configuration unit 702 is further configured to: and taking the attribute information of at least one dimension of the plurality of dimensions as a query index of the mapping relation.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
In a typical configuration, a computer includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, read only compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by the computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of the present description to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
The foregoing description of the preferred embodiment(s) is (are) merely intended to illustrate the embodiment(s) of the present invention, and it is not intended to limit the embodiment(s) of the present invention to the particular embodiment(s) described.

Claims (14)

1. The state data query method is applied to a block chain system, wherein a state tree and a state database special for state data query are maintained in the block chain system, and the state database records the mapping relation between an account and state data thereof in the form of key value pairs; wherein, the blockchain system is configured with a query index for each group of mapping relations; the method comprises the following steps:
under the condition that the received transaction is used for inquiring state data, reading index information contained in the transaction to determine a target mapping relation corresponding to the index information from the state database based on the index information;
and returning the target state data contained in the target mapping relation to the initiator of the transaction.
2. The method of claim 1, account addresses of respective accounts being indexed by the blockchain system as queries of respective mappings; the reading the index information contained in the transaction to determine, based on the index information, a target mapping relationship corresponding to the index information from the state database, including:
And reading a target account address contained in the transaction, so as to determine a target mapping relation corresponding to the target account address from the state database based on the target account address.
3. The method of claim 1, the state data of any set of mappings in the state database comprising: attribute information of the corresponding account in multiple dimensions; attribute information of at least one dimension of the plurality of dimensions is used as a query index of a corresponding mapping relation by the blockchain system;
the reading the index information contained in the transaction to determine, based on the index information, a target mapping relationship corresponding to the index information from the state database, including: reading target attribute information belonging to the at least one dimension contained in the transaction, so as to determine a target mapping relation corresponding to the target attribute information from the state database based on the read target attribute information;
the returning the target state data contained in the target mapping relationship to the initiator of the transaction includes: and returning the attribute information belonging to the multiple dimensions in the target mapping relation to the initiator of the transaction as target state data.
4. The method of claim 1, wherein there are sequential relationships between the query indexes configured for each set of mapping relationships; the reading the index information contained in the transaction to determine, based on the index information, a target mapping relationship corresponding to the index information from the state database, including:
and reading the index range contained in the transaction, and determining a plurality of query indexes belonging to the index range from all query indexes to determine a plurality of groups of target mapping relations respectively corresponding to the plurality of query indexes.
5. The method according to claim 1, wherein in the case that the received transaction is used for querying state data, the step of reading index information included in the transaction to determine, based on the index information, a target mapping relationship corresponding to the index information from the state database includes:
invoking a transaction processing contract, wherein the transaction processing contract comprises a tree invoking interface of the state tree and a library invoking interface of the state database;
executing the transaction processing contract to read information contained in the received transaction, and calling the state database through the library calling interface under the condition that the read information contains index information so as to determine a target mapping relation corresponding to the index information from the state database.
6. The method of claim 1, further comprising:
invoking a transaction processing contract, wherein the transaction processing contract comprises a tree invoking interface of the state tree and a library invoking interface of the state database;
executing the transaction processing contract to read information contained in the received transaction, and calling the state tree through the tree calling interface to execute the transaction based on the information recorded in the state tree under the condition that the read information does not contain index information.
7. The method according to claim 1, wherein in the case that the received transaction is used for querying state data, the step of reading index information included in the transaction to determine, based on the index information, a target mapping relationship corresponding to the index information from the state database includes:
and calling and executing a transaction processing contract to read information contained in the received transaction, and executing state data query logic contained in the transaction processing contract under the condition that index information is contained in the read information so as to determine a target mapping relation corresponding to the index information from the state database based on the index information.
8. A state data certification method is applied to a block chain system, wherein a state tree and a state database special for state data query are maintained in the block chain system; the method comprises the following steps:
acquiring to-be-authenticated state data of a target account, and storing the mapping relation between the target account and the to-be-authenticated state data into the state database in a key value pair mode;
and configuring a query index for the mapping relation.
9. The method of claim 8, the obtaining the forensic status data of the target account comprising:
acquiring state data of at least one account which is already stored in the state tree, and taking the state data as to-be-stored state data of the state database; or alternatively, the process may be performed,
and under the condition that the updating operation of the state data of the target account is completed based on the received transaction, acquiring the updated state data, and taking the acquired updated state data as the to-be-stored state data of the target account.
10. The method according to claim 8, wherein the method comprises,
the configuring the query index for the mapping relation includes: configuring an account address of the target account as a query index of the mapping relation; or alternatively, the process may be performed,
the state data to be stored comprises: attribute information of the target account in multiple dimensions; the configuring the query index for the mapping relation includes: and taking the attribute information of at least one dimension of the plurality of dimensions as a query index of the mapping relation.
11. The state data query device is applied to a block chain system, wherein a state tree and a state database special for state data query are maintained in the block chain system, and the state database records the mapping relation between an account and state data thereof in the form of key value pairs; wherein, the blockchain system is configured with a query index for each group of mapping relations; the device comprises:
a determining unit, configured to read index information included in a received transaction when the received transaction is used to query status data, so as to determine a target mapping relationship corresponding to the index information from the status database based on the index information;
and the return unit returns the target state data contained in the target mapping relation to the initiator of the transaction.
12. A state data certification device, which is applied to a blockchain system, wherein a state tree and a state database special for state data inquiry are maintained in the blockchain system; the device comprises:
the verification unit is used for obtaining to-be-verified state data of a target account, and verifying the mapping relation between the target account and the to-be-verified state data to the state database in a key value pair mode;
And the configuration unit configures a query index for the mapping relation.
13. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any of claims 1-10 by executing the executable instructions.
14. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of any of claims 1-10.
CN202310477379.4A 2023-04-27 2023-04-27 State data query method and device Pending CN116541397A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310477379.4A CN116541397A (en) 2023-04-27 2023-04-27 State data query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310477379.4A CN116541397A (en) 2023-04-27 2023-04-27 State data query method and device

Publications (1)

Publication Number Publication Date
CN116541397A true CN116541397A (en) 2023-08-04

Family

ID=87457041

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310477379.4A Pending CN116541397A (en) 2023-04-27 2023-04-27 State data query method and device

Country Status (1)

Country Link
CN (1) CN116541397A (en)

Similar Documents

Publication Publication Date Title
US10877930B2 (en) Blockchain-based cross-chain data access method and apparatus
CN111898139B (en) Data reading and writing method and device and electronic equipment
CN110275884B (en) Data storage method and node
JP6963006B2 (en) Data storage, data checking, and data concatenation methods and equipment
US10042931B2 (en) Data query method and apparatus
CN110032599B (en) Data structure reading and updating method and device, and electronic equipment
CN110019540B (en) Implementation method, display method, device and equipment of enterprise atlas
CN110032598B (en) Method and device for updating field and electronic equipment
CN107015985B (en) Data storage and acquisition method and device
CN113220717B (en) Block chain-based data verification method and device and electronic equipment
US11775507B2 (en) Methods and apparatuses for reading and updating data structures, and electronic devices
CN106776795B (en) Data writing method and device based on Hbase database
CN105468644A (en) Method and device for performing query in database
CN114840487A (en) Metadata management method and device for distributed file system
WO2024021409A1 (en) Data retrieval method and device
CN116541397A (en) State data query method and device
CN115221559A (en) Data account access authorization method and device
CN111506577B (en) Data operation method and device based on multiple state organization modes on block chain
CN104239576A (en) Method and device for searching for all lines in column values of HBase list
CN116956359A (en) Evidence storage method and device
CN117271513A (en) Data processing method, data query method and device
CN113987322A (en) Index data query method and device, computer equipment and computer program product
CN117093419A (en) Unstructured data storage method and device, electronic equipment and storage medium
CN117827747A (en) Management method, device, equipment and storage medium of custom function file
CN117609303A (en) Multi-table joint query method, device, equipment and storage medium

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