Transaction query method and system based on block chain network, and electronic equipment
By having consensus nodes send target blocks to accounting nodes in the blockchain network and obtain failure messages in case of anomalies, the problem of being unable to query the latest data when nodes are abnormal is solved, thus achieving high availability of the system and consistency of business processing.
Patent Information
- Application Number
- CN202411034256.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-15
AI Technical Summary
In a blockchain network, when a node encounters an anomaly, it cannot promptly retrieve the latest transaction data, leading to errors in the business system.
The consensus node sends the target block to all ledger nodes, which then verify and update the world state. In case of anomalies, a failure message is sent to the message storage block. The consensus node queries the failure message record and sends query instructions to other ledger nodes to obtain the latest data.
This ensures that the latest ledger data can be obtained when a node fails, improving the system's high availability and the consistency of business processing, and reducing the need for post-event data synchronization and manual intervention.
Smart Images

Figure CN118964483A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology or other related fields, and in particular to a transaction query method based on a blockchain network and a system and electronic device thereof. Background Art
[0002] In the field of blockchain technology, different participants can establish a distributed blockchain network by deploying corresponding nodes. The decentralized (or multi-centralized) distributed ledger constructed by the chain block network is stored on each node (or most nodes, such as consensus nodes) in the distributed blockchain network. Such a blockchain system needs to solve the problem of consistency and correctness of the ledger data on multiple decentralized nodes. Blockchain programs are running on each node (or multiple nodes). Under the design of certain fault tolerance requirements, the consensus mechanism is used to ensure that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have consistent execution results for the same transaction, and packaging the transactions and execution results to generate blocks. The current mainstream consensus mechanisms include: proof of work, proof of equity, delegated proof of equity, practical Byzantine fault tolerance algorithm, honey badger Byzantine fault tolerance algorithm, etc.
[0003] In the related technology, in order to improve the system processing efficiency, there is no consensus process for querying contracts. Only a query request is sent to a certain accounting node, and the node returns the execution result after executing the contract. If the local accounting node fails and fails to update and synchronize the latest transaction data in time, then the business system will make mistakes when using the query results of the ledger to process business during the failure period.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a transaction query method based on a blockchain network, a system thereof, and an electronic device, so as to at least solve the technical problem in the related art that the latest data cannot be queried when a node processes abnormally.
[0006] According to one aspect of an embodiment of the present invention, a transaction query method based on a blockchain network is provided, which is applied to a blockchain network, wherein the blockchain network includes: an accounting node and a consensus node on which a smart contract has been deployed, and the transaction query method based on the blockchain network includes: the consensus node in the blockchain network sends a target block to all the accounting nodes, and the accounting nodes verify the target block and update the world state, wherein the target block is obtained after the consensus nodes perform consensus processing on financial transaction information; when an exception occurs when a target accounting node among all the accounting nodes verifies the target block or updates the world state, a target block verification failure message or a world state update failure message message is sent to a message storage block; the consensus node in the blockchain network responds to a transaction query request submitted by a client, queries whether there is a failure message record in the message storage block, and when it is confirmed that there is a failure message record in the message storage block, sends a query instruction to other accounting nodes in the blockchain network except the target accounting node, and the other accounting nodes execute the smart contract and return the query result.
[0007] Optionally, the transaction query method based on the blockchain network also includes: a consensus node in the blockchain network receives financial transaction information submitted by a client, and performs consensus processing on the financial transaction information, wherein the financial transaction information includes a transaction request and an endorsement result, and the consensus processing includes: a block packaging operation and a consensus operation, wherein the consensus operation refers to coordinating the consistency of the packaged blocks in each consensus node; when the consensus processing process is normal, the consensus node sends the target block to all the accounting nodes in the blockchain network.
[0008] Optionally, before the consensus node in the blockchain network receives the financial transaction information submitted by the client, it also includes: the accounting node in the blockchain network receives the endorsement request initiated by the client; the accounting node executes the smart contract according to the endorsement request, endorses and signs the contract execution result, and returns the endorsement result, wherein the endorsement signature refers to the signature of a valid certificate attached to the contract execution result.
[0009] Optionally, after endorsing and signing the contract execution result and returning the endorsement result, the transaction query method based on the blockchain network also includes: when the consensus node detects that the client has not collected the target number of endorsement results within a specified time period, confirming that the endorsement request has failed and the request process is terminated; when an abnormality occurs during the consensus processing of the consensus node, confirming that the endorsement request has failed and the request process is terminated.
[0010] Optionally, the transaction query method based on the blockchain network also includes: the consensus node sorting the received financial transaction information, packaging the sorted financial transaction information, and consensus processing the packaged blocks.
[0011] Optionally, the transaction query method based on the blockchain network also includes: when the accounting node successfully updates the world state, the accounting node synchronizes the transaction result to the client.
[0012] Optionally, the transaction query method based on the blockchain network also includes: the message storage block regularly compares the block heights of each of the accounting nodes, and when the block heights are consistent, confirms that the block information of the accounting nodes has been synchronized, and clears the block information of the client associated with the historical record in the message storage block.
[0013] According to another aspect of an embodiment of the present invention, a transaction query system based on a blockchain network is also provided, which is applied to a blockchain network, wherein the blockchain network includes: an accounting node and a consensus node on which a smart contract has been deployed, and the transaction query system based on the blockchain network includes: a verification unit, which is used for the consensus node in the blockchain network to send a target block to all the accounting nodes, and the accounting node to verify the target block and update the world state, wherein the target block is obtained after the consensus node performs consensus processing on the financial transaction information; a failure message message recording unit, which is used for sending a target block verification failure message or a world state update failure message message to a message storage block when an abnormality occurs when a target accounting node among all the accounting nodes verifies the target block or updates the world state; a query unit, which is used for the consensus node in the blockchain network to respond to a transaction query request submitted by a client, query whether there is a failure message record in the message storage block, and when it is confirmed that there is a failure message record in the message storage block, send a query instruction to other accounting nodes in the blockchain network except the target accounting node, and the other accounting nodes execute the smart contract and return the query result.
[0014] Optionally, the transaction query system based on the blockchain network also includes: a consensus unit, which is used for the consensus node in the blockchain network to receive financial transaction information submitted by the client and perform consensus processing on the financial transaction information, wherein the financial transaction information includes a transaction request and an endorsement result, and the consensus processing includes: a block packaging operation and a consensus operation, wherein the consensus operation refers to coordinating the consistency of the packaged blocks in each consensus node; a block sending unit, which is used for the consensus node to send the target block to all the accounting nodes in the blockchain network when the consensus processing process is normal.
[0015] Optionally, the transaction query system based on the blockchain network also includes: a request receiving unit, which is used for the accounting node in the blockchain network to receive an endorsement request initiated by the client before the consensus node in the blockchain network receives the financial transaction information submitted by the client; a request execution unit, which is used for the accounting node to execute the smart contract according to the endorsement request, endorse and sign the contract execution result, and return the endorsement result, wherein the endorsement signature refers to the signature of a valid certificate attached to the contract execution result.
[0016] Optionally, the transaction query system based on the blockchain network also includes: a first confirmation unit, which is used to endorse and sign the contract execution result and return the endorsement result. When the consensus node detects that the client has not collected the target number of endorsement results within a specified time period, confirm that the endorsement request has failed and the request process is terminated; a second confirmation unit, which is used to confirm that the endorsement request has failed and the request process is terminated when an abnormality occurs during the consensus processing of the consensus node.
[0017] Optionally, the transaction query system based on the blockchain network also includes: an information packaging unit, which is used by the consensus node to sort the received financial transaction information, package the sorted financial transaction information, and consensus the packaged blocks.
[0018] Optionally, the transaction query system based on the blockchain network also includes: a block placement unit, which is used for synchronizing the transaction results to the client by the accounting node when the accounting node successfully updates the world state.
[0019] Optionally, the transaction query system based on the blockchain network also includes: a block information synchronization unit, which is used for the message storage block to regularly compare the block heights of each of the accounting nodes, and when the block heights are consistent, confirm that the block information of the accounting nodes has been synchronized, and clear the block information of the client associated with the historical record in the message storage block.
[0020] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above-mentioned transaction query methods based on the blockchain network.
[0021] According to another aspect of an embodiment of the present invention, a computer program product is also provided, including a computer program, which, when executed by a processor, implements the steps of any one of the above-mentioned transaction query methods based on a blockchain network.
[0022] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is also provided, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned transaction query methods based on the blockchain network.
[0023] In the present disclosure, a transaction query method based on a blockchain network is provided, which is applied to a blockchain network, wherein the blockchain network includes: an accounting node and a consensus node on which a smart contract has been deployed, and the transaction query method based on the blockchain network includes: the consensus node in the blockchain network sends a target block to all the accounting nodes, and the accounting nodes verify the target block and update the world state, wherein the target block is obtained after the consensus nodes perform consensus processing on financial transaction information; when an abnormality occurs when a target accounting node among all the accounting nodes verifies the target block or updates the world state, a target block verification failure message or a world state update failure message message is sent to a message storage block; the consensus node in the blockchain network responds to a transaction query request submitted by a client, queries whether there is a failure message record in the message storage block, and when it is confirmed that there is a failure message record in the message storage block, sends a query instruction to other accounting nodes in the blockchain network except the target accounting node, and the other accounting nodes execute the smart contract and return the query result.
[0024] In the present disclosure, consensus processing is performed by consensus nodes. When the consensus processing process is normal, the consensus node sends the target block to the accounting node, the accounting node verifies the target block, and the accounting node updates the world state. When an exception occurs when the accounting node verifies the target block or updates the world state, the accounting node sends the target block and a message packet of failure to update the world state to the message storage block, and then queries whether there is a failure record in the message storage block. When it is determined that there is a failure record, the latest ledger data is obtained through other trusted accounting nodes, thereby solving the technical problem in the related art that the latest data cannot be queried when the node processing is abnormal. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0026] Figure 1 is a flowchart of an optional transaction query method based on a blockchain network according to an embodiment of the present invention;
[0027] Figure 2is a flow chart of an optional execution of an endorsement request according to an embodiment of the present invention;
[0028] Figure 3 is a flow chart of an optional execution query request according to an embodiment of the present invention;
[0029] Figure 4 It is a structural diagram of a message storage block in an optional transaction query method based on a blockchain network according to an embodiment of the present invention;
[0030] Figure 5 It is a structural diagram of a client in an optional transaction query method based on a blockchain network according to an embodiment of the present invention;
[0031] Figure 6 It is a structural diagram of an accounting node in an optional transaction query method based on a blockchain network according to an embodiment of the present invention;
[0032] Figure 7 is a structural diagram of a consensus node in an optional transaction query method based on a blockchain network according to an embodiment of the present invention;
[0033] Figure 8 is a schematic diagram of an optional transaction query system based on a blockchain network according to an embodiment of the present invention;
[0034] Fig. 9 It is a hardware structure block diagram of an electronic device (or mobile device) according to a transaction query method based on a blockchain network according to an embodiment of the present invention. DETAILED DESCRIPTION
[0035] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0037] To facilitate those skilled in the art to understand the present invention, some terms or nouns involved in the embodiments of the present invention are explained below:
[0038] Smart contract: A computer protocol that uses information to disseminate, verify or execute agreed logic processing, which is reflected as an automatically executable computer program on the blockchain network.
[0039] Consensus algorithm: used to ensure that the execution results of the same transaction by each node in the blockchain network remain consistent, and to prevent malicious nodes from attacking or destroying the blockchain network.
[0040] Consortium blockchain: A type of blockchain where the consensus process is controlled by a group of pre-selected nodes. For example, you can imagine a consortium of 15 financial offices, each of which runs a node, of which ten members must sign on a block for it to be valid.
[0041] It should be noted that the transaction query method based on blockchain network and its system in the present disclosure can be used in the field of blockchain technology when executing client query requests based on blockchain smart contracts, and can also be used in any field outside the field of blockchain technology when executing client query requests based on blockchain smart contracts. The present disclosure does not limit the application field of the transaction query method based on blockchain network and its system.
[0042] It should be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) collected by this disclosure are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with the relevant laws, regulations and standards of the relevant regions, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation portals are provided for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0043] It should be noted that in the present disclosure, when collecting and analyzing customer information, corresponding operation entrances are provided for users to choose to agree or reject the automated decision results; if the user chooses to reject, the expert decision-making process is entered.
[0044] In the present invention, an endorsement request can be sent to the accounting node in the blockchain network, and the accounting node executes the smart contract according to the endorsement request, endorses and signs the contract execution result, and returns the endorsement result. When it is detected that the client has collected the target number of endorsement results within the specified time period, the transaction information is submitted to the consensus node, and the consensus node performs consensus processing. When the consensus processing process is normal, the consensus node sends the target block to the accounting node, and the accounting node verifies the target block, and the accounting node updates the world state. When the accounting node verifies that the target block is abnormal or the update of the world state is abnormal, the accounting node sends a target block failure report and a world state update failure message to the message storage block. At this time, there is a failure record of updating the world state in the message storage block. When executing a query request, the client first queries whether there is a failure record in the message storage block. When confirming that there is a failure record in the message storage block, a query instruction is sent to other accounting nodes in the blockchain, and the smart contract modules in other accounting nodes execute the smart contract and return the query result.
[0045] In the present invention, the target block is verified by the accounting node, and the world state is updated by the accounting node. When an exception occurs when the accounting node verifies the target block or updates the world state, the accounting node sends a target block failure message and a world state update failure message to the message storage block, and then queries whether there is a failure record in the message storage block. When it is determined that there is a failure record, it is determined that the target accounting node processes the exception, resulting in inaccurate account book data. When executing the query request, the latest account book data is obtained from other trusted accounting nodes instead.
[0046] The present invention is described in detail below in conjunction with various embodiments.
[0047] Embodiment 1
[0048] According to an embodiment of the present invention, an embodiment of a transaction query method based on a blockchain network is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.
[0049] According to one aspect of an embodiment of the present invention, a transaction query method based on a blockchain network is provided, which is applied to a blockchain network, wherein the blockchain network includes: accounting nodes and consensus nodes on which smart contracts have been deployed.
[0050] Figure 1 is a flowchart of an optional transaction query method based on a blockchain network according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0051] Step S101, the consensus node in the blockchain network sends the target block to all accounting nodes, and the accounting nodes verify the target block and update the world state, wherein the target block is obtained after the consensus nodes perform consensus processing on the financial transaction information.
[0052] Step S102: When the target accounting node among all accounting nodes verifies the target block or updates the world state abnormally, a target block verification failure message or a world state update failure message is sent to the message storage block.
[0053] Step S103, the consensus node in the blockchain network responds to the transaction query request submitted by the client, queries whether there is a failed message record in the message storage block, and when it is confirmed that there is a failed message record in the message storage block, sends a query instruction to other accounting nodes in the blockchain network except the target accounting node (i.e., obtains the latest ledger data from other trusted accounting nodes), and other accounting nodes execute the smart contract and return the query result.
[0054] Through the above steps, the consensus node in the blockchain network can send the target block to all accounting nodes, and the accounting node verifies the target block and updates the world state, wherein the target block is obtained after the consensus node performs consensus processing on the financial transaction information. When the target accounting node among all accounting nodes verifies the target block or updates the world state abnormally, a target block verification failure message or a world state update failure message is sent to the message storage block. The consensus node in the blockchain network responds to the transaction query request submitted by the client, and queries whether there is a failure message record in the message storage block. When it is confirmed that there is a failure message record in the message storage block, a query instruction is sent to other accounting nodes in the blockchain network except the target accounting node, and other accounting nodes execute the smart contract and return the query result. In this embodiment, the smart contract in the blockchain network has been pre-consensused, and the consensus processing is performed by the consensus node. When the consensus processing process is normal, the consensus node sends the target block to the accounting node, the accounting node verifies the target block, and the accounting node updates the world state. When the accounting node verifies the target block or updates the world state abnormally, the accounting node sends the target block and a message of failure to update the world state to the message storage block, and then queries whether there is a failure record in the message storage block. When it is determined that there is a failure record, the latest ledger data is obtained through other trusted accounting nodes, thereby solving the technical problem in the related technology that the latest data cannot be queried when the node processing is abnormal.
[0055] Figure 2 is a flowchart of an optional execution of an endorsement request according to an embodiment of the present invention. Figure 3 The flowchart of an optional execution query request according to an embodiment of the present invention.
[0056] It should be noted that the transaction query system mentioned in this embodiment refers to the system currently deployed in financial institutions for recording, querying, updating, deleting and other operations of financial transactions. Figure 2As shown, for a transaction query system based on a blockchain network, its blockchain network includes: a consensus node and an accounting node, and the blockchain network is connected to a client and a message storage block. Among them, the blockchain network mentioned in this embodiment can have one or more consensus nodes and multiple accounting nodes. For each business hall, local branches and headquarters of the current financial institution, at least one accounting node is set. The transaction account data of the financial transaction business generated by the financial institution is recorded and updated through the accounting node. Each transaction account data is stored in the form of a block, and each transaction account data carries a timestamp. As for the message storage block, it can represent a storage area for recording block verification failure message messages, world state update failure message messages and consensus failure message messages. The message storage block is an independent, restricted storage area that can only write and read messages. The message storage block is connected to the consensus node and each accounting node in the blockchain network respectively.
[0057] Each accounting node will have an independent accounting function, and through the consensus node, it will continuously update the latest ledger data. In this way, even if an abnormality occurs in a certain accounting node, the latest ledger data can be obtained through other accounting nodes.
[0058] In addition, it should be noted that the client mentioned in this embodiment refers to a terminal used by business personnel or management in a financial institution, and the types include but are not limited to: PCs, notebooks, and self-service terminals in business halls.
[0059] like Figure 2 As shown, when conducting a transaction query, in step 1, an endorsement request is submitted to the accounting node through the client, in step 2, the accounting node executes the contract and endorses and signs the contract execution result, in step 3, the accounting node returns the endorsement result to the client, in step 4, the client collects the endorsement result, in step 5, when it is detected that the client has collected the target number of endorsement results within the specified time period, the financial transaction data and the endorsement result are submitted to the consensus node, in the case where it is detected that the client has not collected the target number of endorsement results within the specified time period, it is determined that the endorsement request has failed, and the endorsement request process is terminated, in step 6, the consensus node packages the block and performs consensus processing, in step 7, the packaged block is delivered to the accounting node, in step 8, the accounting node verifies the block and updates the world state, and in step 9, the accounting node waits for transaction synchronization / block drop operations. In the process of executing the endorsement request in the embodiment of the present invention, there is a processing exception. When the accounting node verifies the target block and updates the world state, an exception of failure to update the world state will occur. At this time, the failure record of updating the world state will be written into the message storage block (corresponding to Figure 2 Step 8.1 in the above example), the message storage block will receive the failure message (corresponding to Figure 2 Step 9.1 in the previous step).
[0060] like Figure 3 As shown, when executing a query request, the embodiment of the present invention will first query whether there is a failure record in the message storage block. If there is a failure record in the message storage block, the client will instead send a query instruction to other accounting nodes in the blockchain, and the smart contract module in the other accounting nodes will execute the smart contract and return the query result, wherein the other accounting nodes are accounting nodes corresponding to other trusted institutions other than the current financial institution.
[0061] It should be noted here that the other accounting nodes mentioned in this embodiment are accounting nodes that belong to the current financial institution and have established network connections. For example, if the target accounting node A (corresponding to a business hall in area A) has a corresponding failure record, a query instruction is sent to other accounting nodes B, C, D, etc. (corresponding to other business halls in areas B, C, D, etc.). Through the independence, tamper-proof information, and traceability of each accounting node in the blockchain network, the latest ledger data can be queried.
[0062] The embodiment of the present invention is described in detail below in combination with the above steps.
[0063] It should be noted that in this embodiment, the consensus node in the blockchain network sends the target block to all accounting nodes, including: the consensus node in the blockchain network receives the financial transaction information submitted by the client, and performs consensus processing on the financial transaction information, wherein the financial transaction information includes the transaction request and the endorsement result, and the consensus processing includes: block packaging operation and consensus operation, wherein the consensus operation refers to coordinating the consistency of the packaged blocks in each consensus node; when the consensus processing process is normal, the consensus node sends the target block to all accounting nodes in the blockchain network.
[0064] Optionally, before the consensus node in the blockchain network receives the financial transaction information submitted by the client, it also includes: the accounting node in the blockchain network receives the endorsement request initiated by the client; the accounting node executes the smart contract according to the endorsement request, endorses and signs the contract execution result, and returns the endorsement result, wherein the endorsement signature refers to the signature of a valid certificate attached to the contract execution result.
[0065] In the blockchain network provided in this embodiment, an endorsement request is a request initiated to one or a group of accounting nodes to verify and confirm transaction information or smart contract execution results, which is used to ensure that the transaction or smart contract is correctly executed and verified.
[0066] In this embodiment, the smart contract is a computer protocol for each node in the blockchain network to transmit information, verify or execute agreed logic processing.
[0067] In this embodiment, endorsement signature is a process of providing proof. Attaching a signature of a valid certificate to the execution result of the smart contract can indicate that the institution corresponding to the accounting node has agreed to the content of the transaction.
[0068] In an embodiment of the present invention, the client sends an endorsement request to the accounting node. The accounting node executes the corresponding smart contract according to the endorsement request, and then endorses and signs the execution result, and finally obtains the result of the endorsement request and returns it to the client.
[0069] In an embodiment of the present invention, a specified time period and a target number of endorsement results are pre-set. If the client collects the target number of endorsement results within the specified time period, the client submits the transaction information to the consensus node, which performs consensus block processing.
[0070] It should be noted that the consensus processing mentioned in this embodiment includes the block packaging operation and the consensus operation. Before the block packaging operation, the consensus node will first sort the transaction information according to the established rules, and then package the sorted transaction information, organize multiple transaction information into a block, and then perform a consensus operation on the block. The consensus operation can ensure that all consensus nodes receive consistent blocks, thereby maintaining the stability and security of the blockchain.
[0071] Optionally, after endorsing and signing the contract execution result and returning the endorsement result, it also includes: when the consensus node detects that the client has not collected the target number of endorsement results within the specified time period, confirming that the endorsement request has failed and the request process has terminated; when an exception occurs during the consensus processing of the consensus node, confirming that the endorsement request has failed and the request process has terminated.
[0072] In an embodiment of the present invention, when determining whether the client has collected the target number of endorsement results within a specified time period, there is a situation where the client fails to collect the target number of endorsement results within the specified time period. At this time, the endorsement request will be directly determined to have failed, and the endorsement request process will be terminated.
[0073] In this embodiment, when consensus processing is performed on transaction information, if an abnormality occurs during the consensus processing, the endorsement request will be directly judged as failed and the endorsement request process will be terminated.
[0074] Step S101, the consensus node in the blockchain network sends the target block to all accounting nodes, and the accounting nodes verify the target block and update the world state, wherein the target block is obtained after the consensus nodes perform consensus processing on the financial transaction information.
[0075] In an embodiment of the present invention, when the consensus processing process is normal, the consensus node will send a target block to the accounting node. The target block is a block of transaction information that has been sorted, packaged, and consensus-operated. The accounting node will verify the target. The verification process includes the endorsement signature verification and read-write set verification of the block. When the verification results of all target blocks are correct, all target blocks are calculated according to established rules to obtain a result. This result is called the world state. The accounting node will record this world state and use the world state to replace the old world state, thereby realizing the update of the world state by the accounting node.
[0076] Optionally, after the target block is verified by the accounting node, it also includes: when the accounting node successfully updates the world state, the accounting node synchronizes the transaction result to the client.
[0077] In an embodiment of the present invention, the accounting node will calculate the world state for all target blocks according to established rules, and then use the new world state to update the old world state. When the entire process of obtaining the world state from the target block and updating the world state is normal, the accounting node will synchronize the transaction results to the client.
[0078] Step S102: When the target accounting node among all accounting nodes verifies the target block or updates the world state abnormally, a target block verification failure message or a world state update failure message is sent to the message storage block.
[0079] In an embodiment of the present invention, when all target blocks are calculated according to established rules to obtain the world state and the accounting node updates the world state, processing exceptions may occur. The processing exceptions include calculation exceptions and update exceptions. When any processing exception occurs in the process, the accounting node will send the target block and the world state update failure message to the message storage block. At this time, the message storage block has a world state update failure record.
[0080] Step S103, the consensus node in the blockchain network responds to the transaction query request submitted by the client, queries whether there is a failed message record in the message storage block, and when it is confirmed that there is a failed message record in the message storage block, sends a query instruction to other accounting nodes in the blockchain network except the target accounting node, and other accounting nodes execute the smart contract and return the query result.
[0081] In the embodiment of the present invention, when the accounting node performs block verification and world state update, a processing exception occurs, resulting in a world state update failure record in the message storage block. When the client initiates a query request, it first queries the message storage block to see if there is a failure record. As long as the message storage block is found to contain a world state update failure record corresponding to the query request, the client sends a query instruction to the accounting node of other trusted institutions instead, and the smart contract module in the accounting node executes the smart contract, returns the query result, and the client obtains the latest account book data.
[0082] In this embodiment, the consensus node sorts the received financial transaction information, packages the sorted financial transaction information, and performs consensus processing on the packaged blocks. Here, consensus processing refers to coordinating the consistency of the packaging results in each consensus node.
[0083] It should be noted that, in this embodiment, when the accounting node successfully updates the world state, the accounting node synchronizes the transaction result to the client.
[0084] In addition, in this embodiment, the message storage block can also periodically compare the block heights of each accounting node. When the block heights are consistent, it is confirmed that the block information of the accounting node has been synchronized, and the block information of the client associated with the historical record in the message storage block is cleared.
[0085] Figures 4 to 7 They are respectively structural diagrams of an optional message storage block, client, accounting node and consensus node according to an embodiment of the present invention.
[0086] like Figure 4 As shown, the message storage block 40 includes a processing module 41 and a notification module 42, wherein the processing module 41 is used to regularly compare the block heights of each accounting node, and when the block heights are consistent, confirm that the block information of the accounting node has been synchronized, and clear the block information of the client associated with the historical record in the message storage block; the notification module 42 is used to send an abnormal notification to the management end in the event of an abnormal record.
[0087] In an embodiment of the present invention, the blockchain includes a message storage block, a client, a consensus node and an accounting node, wherein the message storage block includes a processing module and a notification module, the client includes a communication module and a verification module, the consensus node includes an account book module, a smart contract module, an endorsement module and a verification module, and the accounting node includes an account book module and a consensus module.
[0088] In the blockchain network, the block height is used to indicate the number and order of blocks. The block height is an increasing integer value, starting from 0. When each new block is generated, the block height increases by 1. The processing module in the message storage block will regularly compare the block heights of each accounting node. When the block heights are consistent, it is confirmed that the block information of the accounting node has been synchronized, and the block information of the client associated with the historical record in the message storage block can be cleared.
[0089] like Figure 5 As shown, the client 50 includes a communication module 51 and a verification module 52, wherein the communication module 51 is used to establish communication with the accounting node, the consensus node and the message storage block; the verification module 52 is used to detect whether the client has collected the target number of endorsement results within a specified time period.
[0090] like Figure 6 As shown, the accounting node 60 includes an account book module 61, a smart contract module 62, an endorsement module 63, and a verification module 64, wherein the account book module 61 is used to store the account book data of the blockchain; the smart contract module 62 is used to execute the smart contract; the endorsement module 63 is used to endorse and sign the contract execution result after the smart contract is executed, wherein the endorsement signature refers to the signature of a valid certificate attached to the contract execution result; the verification module 64 is used to verify the sorted block data, wherein the verification process includes at least one of the following: correctness verification of the endorsement signature and correctness verification of the read-write set.
[0091] In the blockchain network, endorsement signature verification is to verify whether the signature matches the transaction information. If the signature matches the transaction information, it is considered to be verified. In the blockchain, each block contains a read-write set, which contains all read and write operations that have occurred since the previous block. Read-write set verification includes verifying the consistency, security and compliance of the read-write set. Among them, consistency verification ensures that the execution results of the smart contract are consistent on all nodes to avoid data inconsistency caused by network delays or node differences. Security verification mainly verifies whether the smart contract follows the predetermined security rules to prevent malicious code or security vulnerabilities from damaging data. Compliance verification mainly verifies whether the execution of the smart contract complies with relevant laws, regulations and industry standards to ensure the legality of the transaction.
[0092] like Figure 7 As shown, the consensus node 70 includes a ledger module 71 and a consensus module 72, wherein the ledger module 71 is used to store the ledger data of the blockchain; the consensus module 72 is used to sort the received transaction information, package the sorted transaction information, and perform consensus processing on the packaged blocks, wherein the consensus processing refers to coordinating the consistency of the packaging results in each consensus node.
[0093] Through the above embodiments, the high availability of the system is improved. As long as the communication module of the accounting node functions normally, even if the local ledger data on the node is not up to date or has been damaged, reliable data can be obtained normally.
[0094] At the same time, this embodiment can improve the consistency of business system processing and reduce the need for additional data synchronization and manual intervention due to inconsistencies found in subsequent on-chain and off-chain reconciliations.
[0095] The following is a detailed description in conjunction with another embodiment.
[0096] Embodiment 2
[0097] A transaction query system based on a blockchain network provided in this embodiment includes multiple implementation units, each implementation unit corresponding to each implementation step in the above-mentioned embodiment one.
[0098] According to another aspect of an embodiment of the present invention, a transaction query system based on a blockchain network is also provided, which is applied to a blockchain network. The blockchain network includes: accounting nodes and consensus nodes on which smart contracts have been deployed.
[0099] Figure 8 is a schematic diagram of an optional transaction query system based on a blockchain network according to an embodiment of the present invention, such as Figure 8 As shown, the transaction query system based on the blockchain network may include: a verification unit 81, a failure message recording unit 82, and a query unit 83.
[0100] Among them, the verification unit 81 is used for the consensus node in the blockchain network to send the target block to all accounting nodes, and the accounting nodes verify the target block and update the world state, wherein the target block is obtained after the consensus nodes perform consensus processing on the financial transaction information.
[0101] The failure message recording unit 82 is used to send a target block verification failure message or a world state update failure message to the message storage block when an abnormality occurs when a target accounting node among all accounting nodes verifies a target block or updates a world state.
[0102] The query unit 83 is used for the consensus node in the blockchain network to respond to the transaction query request submitted by the client, query whether there is a failed message record in the message storage block, and when it is confirmed that there is a failed message record in the message storage block, send a query instruction to other accounting nodes in the blockchain network except the target accounting node, and the other accounting nodes execute the smart contract and return the query result.
[0103] The transaction query system based on the blockchain network can send the target block to all accounting nodes through the verification unit 81 by the consensus node in the blockchain network, and the accounting node verifies the target block and updates the world state, wherein the target block is obtained after the consensus node performs consensus processing on the financial transaction information, and when the target accounting node among all accounting nodes verifies the target block or updates the world state abnormally through the failure message message recording unit 82, a target block verification failure message or a world state update failure message message is sent to the message storage block, and the consensus node in the blockchain network responds to the transaction query request submitted by the client through the query unit 83, and queries whether there is a failure message record in the message storage block. When it is confirmed that there is a failure message record in the message storage block, a query instruction is sent to other accounting nodes in the blockchain network except the target accounting node, and other accounting nodes execute the smart contract and return the query result. In this embodiment, consensus processing is performed by the consensus node. When the consensus processing process is normal, the consensus node sends the target block to the accounting node, the accounting node verifies the target block, and the accounting node updates the world state. When an exception occurs when the accounting node verifies the target block or updates the world state, the accounting node sends the target block and a message of failure to update the world state to the message storage block, and then queries whether there is a failure record in the message storage block. When it is determined that there is a failure record, the latest ledger data is obtained through other trusted accounting nodes, thereby solving the technical problem in the related art that the latest data cannot be queried when the node processing is abnormal.
[0104] Optionally, the transaction query system based on the blockchain network also includes: a consensus unit, which is used for the consensus node in the blockchain network to receive financial transaction information submitted by the client and perform consensus processing on the financial transaction information, wherein the financial transaction information includes transaction requests and endorsement results, and the consensus processing includes: block packaging operations and consensus operations, wherein the consensus operation refers to coordinating the consistency of packaged blocks in each consensus node; a block sending unit, which is used for the consensus node to send the target block to all accounting nodes in the blockchain network when the consensus processing process is normal.
[0105] Optionally, the transaction query system based on the blockchain network also includes: a request receiving unit, which is used for the accounting node in the blockchain network to receive the endorsement request initiated by the client before the consensus node in the blockchain network receives the financial transaction information submitted by the client; a request execution unit, which is used for the accounting node to execute the smart contract according to the endorsement request, endorse and sign the contract execution result, and return the endorsement result, wherein the endorsement signature refers to the signature of a valid certificate attached to the contract execution result.
[0106] Optionally, the transaction query system based on the blockchain network also includes: a first confirmation unit, which is used to endorse and sign the contract execution result and return the endorsement result. If the consensus node detects that the client has not collected the target number of endorsement results within a specified time period, it confirms that the endorsement request has failed and the request process is terminated; a second confirmation unit, which is used to confirm that the endorsement request has failed and the request process is terminated if an abnormality occurs during the consensus processing of the consensus node.
[0107] Optionally, the transaction query system based on the blockchain network also includes: an information packaging unit, which is used by the consensus node to sort the received financial transaction information, package the sorted financial transaction information, and perform consensus processing on the packaged blocks, wherein consensus processing refers to coordinating the consistency of the packaging results in each consensus node.
[0108] Optionally, the transaction query system based on the blockchain network also includes: a block placement unit, which is used for synchronizing the transaction results from the accounting node to the client when the accounting node successfully updates the world state.
[0109] Optionally, the transaction query system based on the blockchain network also includes: a block information synchronization unit, which is used to periodically compare the block heights of each accounting node by the message storage block, and when the block heights are consistent, confirm that the block information of the accounting node has been synchronized, and clear the block information of the client associated with the historical record in the message storage block.
[0110] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any one of the above-mentioned transaction query methods based on a blockchain network.
[0111] According to another aspect of an embodiment of the present invention, a computer program product is also provided, including a computer program, which, when executed by a processor, implements the steps of any one of the above-mentioned transaction query methods based on a blockchain network.
[0112] The above-mentioned transaction query system based on blockchain network may also include a processor and a memory. The above-mentioned verification unit 81, failure message message recording unit 82, query unit 83, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0113] The above processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and data record query can be realized based on blockchain smart contracts by adjusting kernel parameters.
[0114] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (fl ash RAM), and the memory includes at least one storage chip.
[0115] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, the computer-readable storage medium including a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the transaction query methods based on the blockchain network in the above-mentioned embodiment 1.
[0116] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the transaction query method based on the blockchain network of any one of the above-mentioned embodiments one.
[0117] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the transaction query method based on the blockchain network described in each embodiment of the present application.
[0118] The present application also provides a computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the transaction query method based on the blockchain network described in each embodiment of the present application are implemented.
[0119] Fig. 9 1 is a hardware structure block diagram of an electronic device (or mobile device) for a transaction query method based on a blockchain network according to an embodiment of the present invention. Fig. 9 As shown, the electronic device may include one or more ( Fig. 9 902a, 902b, ..., 902n are used to illustrate) processor 902 (processor 902 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), and memory 904 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. It can be understood by those skilled in the art that Fig. 9 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig. 9 More or fewer components as shown, or with Fig. 9 Different configurations are shown.
[0120] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0121] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0122] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0123] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0124] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0125] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0126] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A transaction query method based on a blockchain network, characterized in that: Applied in a blockchain network, the blockchain network includes: accounting nodes and consensus nodes that have deployed smart contracts, and the transaction query method based on the blockchain network includes: The consensus node in the blockchain network sends a target block to all the accounting nodes, and the accounting nodes verify the target block and update the world state, wherein the target block is obtained after the consensus nodes perform consensus processing on the financial transaction information; When the target accounting node among all the accounting nodes verifies the target block or updates the world state abnormally, sends a target block verification failure message or a world state update failure message to the message storage block; The consensus node in the blockchain network responds to the transaction query request submitted by the client, queries whether there is a failed message record in the message storage block, and when it is confirmed that there is a failed message record in the message storage block, sends a query instruction to other accounting nodes in the blockchain network except the target accounting node, and the other accounting nodes execute the smart contract and return the query result.
2. The transaction query method based on blockchain network according to claim 1 is characterized in that: Also includes: The consensus node in the blockchain network receives the financial transaction information submitted by the client and performs consensus processing on the financial transaction information, wherein the financial transaction information includes the transaction request and the endorsement result, and the consensus processing includes: a block packaging operation and a consensus operation, wherein the consensus operation refers to coordinating the consistency of the packaged blocks in each consensus node; When the consensus processing process is normal, the consensus node sends the target block to all the accounting nodes in the blockchain network.
3. The transaction query method based on blockchain network according to claim 2 is characterized in that: Before the consensus node in the blockchain network receives the financial transaction information submitted by the client, it also includes: The accounting node in the blockchain network receives the endorsement request initiated by the client; The accounting node executes the smart contract according to the endorsement request, endorses and signs the contract execution result, and returns the endorsement result, wherein the endorsement signature refers to the signature of a valid certificate attached to the contract execution result.
4. The transaction query method based on blockchain network according to claim 3 is characterized in that: After endorsing and signing the contract execution result and returning the endorsement result, it also includes: When the consensus node detects that the client has not collected the target number of endorsement results within the specified time period, it confirms that the endorsement request has failed and the request process is terminated; In the event that an exception occurs during the consensus processing of the consensus node, the endorsement request is confirmed to have failed and the request process is terminated.
5. The transaction query method based on blockchain network according to claim 2 is characterized in that: Also includes: The consensus node sorts the received financial transaction information, packages the sorted financial transaction information, and performs consensus processing on the packaged blocks.
6. The transaction query method based on blockchain network according to claim 1, characterized in that: Also includes: When the accounting node successfully updates the world state, the accounting node synchronizes the transaction result to the client.
7. The transaction query method based on blockchain network according to claim 1 is characterized in that: Also includes: The message storage block periodically compares the block heights of each of the accounting nodes. When the block heights are consistent, it is confirmed that the block information of the accounting nodes has been synchronized, and the block information of the client associated with the historical records in the message storage block is cleared.
8. A transaction query system based on blockchain network, characterized in that: Applied in a blockchain network, the blockchain network includes: accounting nodes and consensus nodes that have deployed smart contracts, and the transaction query system based on the blockchain network includes: A verification unit, configured to send a target block from the consensus node in the blockchain network to all the accounting nodes, and for the accounting nodes to verify the target block and update the world state, wherein the target block is obtained after the consensus nodes perform consensus processing on the financial transaction information; A failure message recording unit, configured to send a target block verification failure message or a world state update failure message to a message storage block when an abnormality occurs when a target accounting node among all the accounting nodes verifies the target block or updates the world state; The query unit is used for the consensus node in the blockchain network to respond to the transaction query request submitted by the client, query whether there is a failed message record in the message storage block, and when it is confirmed that there is a failed message record in the message storage block, send a query instruction to other accounting nodes in the blockchain network except the target accounting node, and the other accounting nodes execute the smart contract and return the query result.
9. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the transaction query method based on the blockchain network as described in any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the transaction query method based on the blockchain network described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
User data processing method and device based on block chain and storage medium
CN119831740A
