CN114078052A - Execution method of intelligent contracts in block chain, node and block chain system - Google Patents
Execution method of intelligent contracts in block chain, node and block chain system Download PDFInfo
- Publication number
- CN114078052A CN114078052A CN202010824718.8A CN202010824718A CN114078052A CN 114078052 A CN114078052 A CN 114078052A CN 202010824718 A CN202010824718 A CN 202010824718A CN 114078052 A CN114078052 A CN 114078052A
- Authority
- CN
- China
- Prior art keywords
- contract
- node
- control node
- transaction request
- transaction
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 44
- 238000012795 verification Methods 0.000 claims description 11
- 238000004590 computer program Methods 0.000 claims description 9
- 230000004044 response Effects 0.000 claims description 4
- 238000010586 diagram Methods 0.000 description 17
- 230000006870 function Effects 0.000 description 5
- 230000008569 process Effects 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 230000000903 blocking effect Effects 0.000 description 1
- 230000015556 catabolic process Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000005070 sampling Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
- G06F21/6218—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
- G06F21/6227—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database where protection concerns the structure of data, e.g. records, types, queries
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Finance (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- Accounting & Taxation (AREA)
- Economics (AREA)
- General Business, Economics & Management (AREA)
- Technology Law (AREA)
- Strategic Management (AREA)
- Marketing (AREA)
- Development Economics (AREA)
- Databases & Information Systems (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The disclosure relates to an execution method of an intelligent contract in a block chain, a node and a block chain system, and relates to the technical field of computers. The method of the present disclosure comprises: each of the plurality of control nodes receives a contract invoking transaction request sent by the service node, and the contract invoking transaction request comprises: an expected outcome of contract execution; sending a contract calling transaction request to each non-control node, wherein the number of the non-control nodes is less than the maximum allowable malicious node number; receiving contract calling transaction results returned by the non-control nodes, and verifying whether the contract calling transaction results returned by the non-control nodes are matched with expected contract execution results or not; and in the case that the result of the contract calling transaction returned by each non-control node is matched with the expected result of the contract execution, broadcasting the contract calling transaction request to other nodes to execute the contract calling transaction.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an execution method of an intelligent contract in a blockchain, a node, and a blockchain system.
Background
The data on the block chain has the characteristics of public transparency, non-tampering and the like, and the safety of data storage is improved. An intelligent contract is a program that is stored on a blockchain and can be automatically executed.
Currently, most blockchain networks execute an intelligent contract transaction, and all or most of the nodes of the blockchain networks need to execute the intelligent contract at the same time.
Disclosure of Invention
The inventor finds that: if the intelligent contract code is problematic or malicious code is present, the nodes that execute the intelligent contract will all be affected. It may happen that too many nodes are in a blocking state or an uncontrollable state at the same time, which may lead to a breakdown of the blockchain network, and may also lead to a wrong transaction result, reducing the security of the transaction process.
One technical problem to be solved by the present disclosure is: how to improve the security of intelligent contract execution and the fault tolerance of a blockchain system.
According to some embodiments of the present disclosure, there is provided a method for executing an intelligent contract in a blockchain, including: each of the plurality of control nodes receives a contract invoking transaction request sent by the service node, and the contract invoking transaction request comprises: an expected outcome of contract execution; sending a contract calling transaction request to each non-control node, wherein the number of the non-control nodes is less than the maximum allowable malicious node number; receiving contract calling transaction results returned by the non-control nodes, and verifying whether the contract calling transaction results returned by the non-control nodes are matched with expected contract execution results or not; and in the case that the result of the contract calling transaction returned by each non-control node is matched with the expected result of the contract execution, broadcasting the contract calling transaction request to other nodes to execute the contract calling transaction.
In some embodiments, sending the contract invocation transaction request to each non-control node comprises: and sending the contract calling transaction request and the non-control node indication mark to each non-control node, wherein the non-control node indication mark is used for indicating each non-control node to execute the contract calling transaction.
In some embodiments, receiving the results of the contract invocation transaction returned by each non-control node comprises: and receiving contract invoking transaction results returned by the non-control nodes within preset time.
In some embodiments, receiving the contract invocation transaction request sent by the service node includes: receiving a contract calling transaction request, a control node indication identifier and identifiers of all control nodes sent by a service node; determining the identification of the non-control node according to the identification of each control node; sending the contract invocation transaction request to each non-control node includes: and sending the contract invoking transaction request to each non-control node according to the control node indication identification and the identification of the non-control node.
In some embodiments, the method further comprises: in the event that the results of the contract invocation transaction returned by the various non-control nodes do not match the expected results of the contract execution, the contract invocation transaction request is discarded.
In some embodiments, the method further comprises: a service node receives a transaction request initiated by a user; the service node takes the node as a control node under the condition that the received transaction request comprises a contract calling transaction request, and randomly selects nodes with a preset number as the control node, wherein the preset number is more than or equal to the maximum allowable malicious node number; the service node sends the contract invoking transaction request to each control node.
In some embodiments, the method further comprises: each of the plurality of non-control nodes receives a contract invoking transaction request sent by the control node; executing contract calling transaction according to the contract calling transaction request, obtaining a result of the contract calling transaction and returning the result to the control node; the results of the contract invocation transaction are stored.
In some embodiments, the method further comprises: each of the plurality of non-control nodes, in response to receiving the contract calling transaction request again, inquiring whether to store a result of the contract calling transaction corresponding to the contract calling transaction request; and under the condition that the result of the contract calling transaction corresponding to the stored contract calling transaction request is obtained, synchronously broadcasting the result of the contract calling transaction.
In some embodiments, the method further comprises: and the nodes with the block right receive the contract calling transaction results broadcasted by each node, generate blocks after the consensus verification of the contract calling transaction results broadcasted by each node is completed, synchronize the blocks to other nodes, and write the blocks into the local account book after the other nodes verify the blocks.
According to other embodiments of the present disclosure, there is provided a node in a block chain, where the node is selected as a control node, the node including: the receiving module is used for receiving a contract invoking transaction request sent by the service node, and the contract invoking transaction request comprises: an expected outcome of contract execution; the sending module is used for sending the contract calling transaction request to each non-control node, wherein the number of the non-control nodes is less than the maximum allowable malicious node number; the verification module is used for receiving the contract calling transaction results returned by the non-control nodes and verifying whether the contract calling transaction results returned by the non-control nodes are matched with the expected contract execution results; and the broadcasting module is used for broadcasting the contract calling transaction request to other nodes to execute the contract calling transaction under the condition that the result of the contract calling transaction returned by each non-control node is matched with the expected result of the contract execution.
In some embodiments, the sending module is configured to send the contract invocation transaction request and the non-control node indication identifier to each non-control node, where the non-control node indication identifier is used to indicate each non-control node to execute the contract invocation transaction; or the verification module is used for receiving contract invoking transaction results returned by each non-control node within preset time; or the receiving module is used for receiving the contract invoking transaction request, the control node indication identifier and the identifiers of the control nodes sent by the service node; determining the identification of the non-control node according to the identification of each control node; the sending module is used for sending the contract calling transaction request to each non-control node according to the control node indication identification and the identification of the non-control node; alternatively, the broadcast module is further configured to discard the contract invocation transaction request if the result of the contract invocation transaction returned by each non-control node does not match the expected result of the contract execution.
In some embodiments, in the case that the node is a serving node, the method further includes: the service module is used for receiving a transaction request initiated by a user; taking the node as a control node under the condition that the received transaction request comprises a contract calling transaction request, and randomly selecting nodes with a preset number as the control node, wherein the preset number is greater than or equal to the maximum allowable rogue node number; and sending the contract invoking transaction request to each control node.
According to still other embodiments of the present disclosure, there is provided a blockchain system including: the node of any of the preceding embodiments as a control node; and a plurality of non-control nodes; the non-control node is used for receiving a contract invoking transaction request sent by the control node; executing contract calling transaction according to the contract calling transaction request, obtaining a result of the contract calling transaction and returning the result to the control node; the results of the contract invocation transaction are stored.
In some embodiments, the non-control node is configured to, in response to receiving the contract invocation transaction request again, query whether to store a result of the contract invocation transaction corresponding to the contract invocation transaction request; and under the condition that the result of the contract calling transaction corresponding to the stored contract calling transaction request is obtained, synchronously broadcasting the result of the contract calling transaction.
In some embodiments, in the case that any node is a node with block right, the node is configured to receive a result of a contract invocation transaction broadcast by each node, generate a block after the result of the contract invocation transaction broadcast by each node completes consensus verification, synchronize the block to another node, and write a local ledger after the block is verified by another node.
According to still further embodiments of the present disclosure, there is provided an electronic device including: a processor; and a memory coupled to the processor for storing instructions that, when executed by the processor, cause the processor to perform a method for performing intelligent contracts in a blockchain as in any of the embodiments described above.
According to further embodiments of the present disclosure, a non-transitory computer-readable storage medium is provided, on which a computer program is stored, wherein the program, when executed by a processor, implements the steps of the method for executing intelligent contracts in blockchains of any of the foregoing embodiments.
Nodes in a blockchain system are divided into control nodes and non-control nodes in the present disclosure, with the number of non-control nodes being less than the maximum number of allowed rogue nodes. The control node sends the contract calling transaction request to each non-control node, the non-control nodes execute the contract calling transaction first, the control node verifies the result of the contract calling transaction returned by the non-control nodes, and under the condition that the result is verified, the contract calling transaction request is broadcasted to other nodes to execute the contract calling transaction. Through the process, whether the intelligent contract has errors or insecurity or not can be found, and whether insecurity factors exist in the node or not can be found. And the operation and the safety of the block chain system cannot be influenced under the condition that the maximum allowable operation node number is smaller than the operation node number, namely the operation node number is smaller than the operation node number, even if potential safety hazards exist in non-control nodes or intelligent contracts, the performance of the whole block chain system cannot be influenced, and the execution safety of the intelligent contracts and the fault tolerance of the block chain system are improved.
Other features of the present disclosure and advantages thereof will become apparent from the following detailed description of exemplary embodiments thereof, which proceeds with reference to the accompanying drawings.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 illustrates a flow diagram of a method for executing an intelligent contract in a blockchain of some embodiments of the present disclosure.
Fig. 2 is a flow diagram illustrating a method for executing an intelligent contract in a blockchain according to further embodiments of the present disclosure.
Fig. 3 illustrates a structural schematic of a node in a blockchain of some embodiments of the present disclosure.
Fig. 4 illustrates a structural schematic diagram of a blockchain system of some embodiments of the present disclosure.
Fig. 5 shows a schematic structural diagram of an electronic device of some embodiments of the present disclosure.
Fig. 6 shows a schematic structural diagram of an electronic device of further embodiments of the disclosure.
Detailed Description
The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, and not all of the embodiments. The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the disclosure, its application, or uses. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
The present disclosure provides a method for executing an intelligent contract in a block chain, which is described below with reference to fig. 1 to 2.
Fig. 1 is a flow chart of some embodiments of a method for executing intelligent contracts in a blockchain according to the present disclosure. As shown in fig. 1, the method of this embodiment includes: each of the plurality of control nodes executes steps S102 to S108.
In step S102, a contract invocation transaction request sent by the service node is received.
A contract invocation transaction is a transaction that requires execution of a particular contract. The control node may be randomly selected by the serving node, and the serving node itself may also serve as one of the control nodes. The number of control nodes other than the serving node is greater than or equal to the maximum allowed number of rogue nodes. The maximum allowable number of rogue nodes is determined by a consensus algorithm, for example, PoW (Proof of Work) consensus algorithm, which is 50% of the total number of nodes, and the like, but is not limited to the example.
The contract invocation transaction request may include: expected outcome of contract execution. The expected result of contract execution may be sent to the service node after the user adds to the contract invocation transaction request. The expected result of a contract execution may be a value, a range of values, True or Flase, or other form. The contract invocation transaction request may further include: the communication protocol version, the method in the contract to be called, the address of the calling party, the input data required for executing the contract function, the contract address, and the like may refer to the prior art, and are not described herein again.
In step S104, a contract invocation transaction request is sent to each non-control node.
The number of non-control nodes is less than the maximum allowed number of rogue nodes. In some embodiments, the control node receives a contract invoking transaction request sent by the service node, a control node indication identifier and identifiers of various control nodes; and determining the identifier of the non-control node according to the identifier of each control node, and sending a contract invoking transaction request to each non-control node according to the control node indication identifier and the identifier of the non-control node. The control node indication flag is used to indicate the received identified node as the control node, and for example, the control node indication flag is represented as flag ═ ctrl. The control node can acquire the identification of the whole network node, and further can exclude the control node from determining the identification of the non-control node according to the identification of each control node.
In some embodiments, the contract invocation transaction request and the non-control node indication identifier are sent to respective non-control nodes. The node of the non-control node indication mark is used for indicating the received node of the mark as a non-control node and indicating each non-control node to execute contract invoking transaction. For example, the non-control node indication flag is represented as flag ═ exec. And the non-control node executes the contract calling transaction according to the contract calling transaction request and the non-control node indication identifier to obtain a result of the contract calling transaction.
In step S106, the result of the contract invocation transaction returned by each non-control node is received, and it is verified whether the result of the contract invocation transaction returned by each non-control node matches the expected result of the contract execution.
In some embodiments, the control node receives the result of the contract invocation transaction returned by each non-control node within a preset time. If the non-control node returns the result of the contract invocation transaction after the preset time, the control node may not consider the result of the contract invocation transaction any more. And the control node compares the contract calling transaction result returned by each non-control node with an expected contract execution result, and if the contract calling transaction results of the non-control nodes all accord with the expected contract execution result, the matching is successful.
In step S108, in the case that the result of the contract invocation transaction returned by each non-control node matches the expected result of the contract execution, the contract invocation transaction request is broadcast to other nodes to execute the contract invocation transaction.
After the control node verifies that the result of the contract invoking transaction returned by each non-control node is matched with the expected result of the contract execution, the control node proves the safety of the contract and can also prove that each non-control node does not belong to the malicious node.
The nodes in the blockchain system in the above embodiments are divided into control nodes and non-control nodes, and the number of the non-control nodes is less than the maximum allowed number of rogue nodes. The control node sends the contract calling transaction request to each non-control node, the non-control nodes execute the contract calling transaction first, the control node verifies the result of the contract calling transaction returned by the non-control nodes, and under the condition that the result is verified, the contract calling transaction request is broadcasted to other nodes to execute the contract calling transaction. Through the process, whether the intelligent contract has errors or insecurity or not can be found, and whether insecurity factors exist in the node or not can be found. And the operation and the safety of the block chain system cannot be influenced under the condition that the maximum allowable operation node number is smaller than the operation node number, namely the operation node number is smaller than the operation node number, even if potential safety hazards exist in non-control nodes or intelligent contracts, the performance of the whole block chain system cannot be influenced, and the execution safety of the intelligent contracts and the fault tolerance of the block chain system are improved.
Further embodiments of methods for executing intelligent contracts in blockchains according to the present disclosure are described below in conjunction with fig. 2.
Fig. 2 is a flow chart of another embodiment of a method for executing intelligent contracts in a blockchain according to the present disclosure. As shown in fig. 2, the method of this embodiment includes: steps S202 to S222.
In step S202, the service node receives a transaction request initiated by a user.
For example, serving node C1Receiving a transaction request TX initiated by a user, and collecting the transaction requests TX and converging the transaction requests into a transaction request set { TX }by each service nodei. If the user initiates a contract to invoke a transaction request, the expected result parameter { presult } of the contract execution is included.
In step S204, when the received transaction request includes a contract invoking transaction request, the service node uses the node as a control node, and randomly selects a preset number of nodes as control nodes.
If { TX }iThe contract included in (C) calls the transaction request TXq, and the service node may adopt a random sampling algorithm to select M (the preset number is greater than or equal to the maximum allowable cost) nodes again as the control nodes { C }n,n∈{1,2,3…M-1,M}。
In step S206, the service node sends the contract invoking transaction request to each control node, and correspondingly, the control node receives the contract invoking transaction request sent by the service node.
Service node C1The contract invocation transaction request, the control node indication flag ctrl, and the identification of each control node may be sent to the control node { C }n. The service node proceeds normally for other transactions.
In step S208, the control node sends the contract-invoking transaction request to each non-control node, and correspondingly, each non-control node receives the contract-invoking transaction request sent by the control node.
And after receiving the contract calling transaction and the control node indication identification flag, the control node modifies the non-control node indication identification flag with the flag being ctrl, and forwards the modified non-control node indication identification flag with the flag being exec to the non-control node.
In step S210, the non-control node executes the contract invoking transaction according to the contract invoking transaction request, obtains a result of the contract invoking transaction, returns the result to the control node, and stores the result of the contract invoking transaction.
Non-control node, contract pre-execution node { D }N-nAfter receiving, executing the contract in advance, returning the result to the control node, and caching the result.
In step S212, the control node receives the contract invoking transaction result returned by each non-control node within the preset time, and verifies whether the contract invoking transaction result returned by each non-control node matches with the expected result of contract execution, if yes, step S214 is executed, otherwise, step S213 is executed.
And after receiving the result of the contract calling transaction within the preset time, the control node checks whether the result of the contract calling transaction conforms to the result.
In step S213, the control node discards the contract invocation transaction request.
And if the control node fails to check, discarding the contract invoking transaction request and returning the failure to the service node.
In step S214, the control node broadcasts a contract invocation transaction request.
The other nodes may be all nodes or some nodes that receive the contract invocation transaction request.
In step S216, the node that receives the contract invoking transaction request queries whether to store the result of the contract invoking transaction corresponding to the contract invoking transaction request, if so, step S218 is executed, otherwise, step S217 is executed.
The node receiving the contract Call transaction request TXq adds TXq to the transaction request set { TX }(i+k)In (1). If the node receiving the contract calling transaction request comprises a non-control node, responding to the fact that the contract calling transaction request is received again, and inquiring whether a result of the contract calling transaction corresponding to the contract calling transaction request is stored or not; under the condition of the result of the contract calling transaction corresponding to the stored contract calling transaction request, the contract calling transaction is not executed any moreIs easy.
In step S217, the node that receives the contract invoking transaction request executes the contract invoking transaction, and obtains a result of the contract invoking transaction.
In step S218, the node that receives the contract invocation transaction request synchronously broadcasts the result of the contract invocation transaction.
In step S220, the node with block right receives the result of the contract invocation transaction broadcast by each node, generates a block after the result of the contract invocation transaction broadcast by each node is verified, and synchronizes the block to other nodes.
In step S222, each node verifies the block and writes the block into the local ledger.
Each node may verify the hash value in the block, and the like, and specifically, the prior art may be referred to first, and details are not described here.
The method of the embodiment can find whether the intelligent contract has errors or insecurity, and find whether the node has insecurity factors. If the result of the contract calling transaction does not accord with the expected result, the contract calling transaction is discarded, all nodes are not required to execute the contract calling transaction, the efficiency is improved, and meanwhile the safety of intelligent contract execution and the fault tolerance of the block chain system are improved.
The present disclosure also provides a node in a blockchain, described below in conjunction with fig. 3.
Fig. 3 is a block diagram of some embodiments of nodes in the disclosed blockchain. As shown in fig. 3, in the case where the node 30 in the block chain of the embodiment is selected as the control node, the method includes: a receiving module 310, a sending module 320, a verifying module 330, and a broadcasting module 340.
The receiving module 310 is configured to receive a contract invoking transaction request sent by a service node, where the contract invoking transaction request includes: expected outcome of contract execution.
The sending module 320 is configured to send the contract invocation transaction request to each non-control node, where the number of the non-control nodes is less than the maximum allowable malicious node number.
In some embodiments, the receiving module 310 is configured to receive a contract invocation transaction request sent by a service node, a control node indication identifier, and an identifier of each control node; determining the identification of the non-control node according to the identification of each control node; the sending module 320 is configured to send the contract invoking transaction request to each non-control node according to the control node indication identifier and the identifier of the non-control node.
In some embodiments, the sending module 320 is configured to send the contract invocation transaction request and the non-control node indication identifier to each non-control node, wherein the non-control node indication identifier is configured to indicate that each non-control node executes the contract invocation transaction.
The verification module 330 is configured to receive the result of the contract invocation transaction returned by each non-control node, and verify whether the result of the contract invocation transaction returned by each non-control node matches the expected result of the contract execution.
In some embodiments, the verification module 330 is configured to receive a result of the contract invocation transaction returned by each non-control node within a preset time.
And the broadcasting module 340 is used for broadcasting the contract calling transaction request to other nodes to execute the contract calling transaction when the result of the contract calling transaction returned by each non-control node is matched with the expected result of the contract execution.
In some embodiments, the broadcast module 340 is further configured to discard the contract invocation transaction request if the result of the contract invocation transaction returned by the respective non-control node does not match the expected result of the contract execution.
In some embodiments, in the case that the node is a serving node, the method further includes: a service module 350, configured to receive a transaction request initiated by a user; taking the node as a control node under the condition that the received transaction request comprises a contract calling transaction request, and randomly selecting nodes with a preset number as the control node, wherein the preset number is greater than or equal to the maximum allowable rogue node number; and sending the contract invoking transaction request to each control node.
The present disclosure also provides a blockchain system, described below in conjunction with fig. 4.
Fig. 4 is a block diagram of some embodiments of the blockchain system of the present disclosure. As shown in fig. 4, the block chain system 4 of this embodiment includes: the node 30 in the block chain of any of the preceding embodiments, being the control node 30, and a plurality of non-control nodes 42;
the non-control node 42 is used for receiving the contract invoking transaction request sent by the control node 30; executing contract calling transaction according to the contract calling transaction request to obtain a result of the contract calling transaction and returning the result to the control node 30; the results of the contract invocation transaction are stored.
In some embodiments, the non-control node 42 is configured to, in response to receiving the contract invocation transaction request again, query whether to store a result of the contract invocation transaction corresponding to the contract invocation transaction request; and under the condition that the result of the contract calling transaction corresponding to the stored contract calling transaction request is obtained, synchronously broadcasting the result of the contract calling transaction.
In some embodiments, in the case that any node is a node with block right, the node is configured to receive a result of a contract invocation transaction broadcast by each node, generate a block after the result of the contract invocation transaction broadcast by each node completes consensus verification, synchronize the block to another node, and write a local ledger after the block is verified by another node.
The electronic devices in the embodiments of the present disclosure, such as the control nodes, non-control nodes, etc. in the blockchain, may each be implemented by various computing devices or computer systems, which are described below in conjunction with fig. 5 and 6.
Fig. 5 is a block diagram of some embodiments of an electronic device of the present disclosure. As shown in fig. 5, the electronic apparatus 50 of this embodiment includes: a memory 510 and a processor 520 coupled to the memory 510, the processor 520 being configured to perform the steps of the method for performing intelligent contracts in blockchains in any of the embodiments of the present disclosure based on instructions stored in the memory 510.
Fig. 6 is a block diagram of further embodiments of the electronic device of the present disclosure. As shown in fig. 6, the electronic device 60 of this embodiment includes: memory 610 and processor 620 are similar to memory 510 and processor 520, respectively. An input output interface 630, a network interface 640, a storage interface 650, and the like may also be included. These interfaces 630, 640, 650 and the connections between the memory 610 and the processor 620 may be, for example, via a bus 660. The input/output interface 630 provides a connection interface for input/output devices such as a display, a mouse, a keyboard, and a touch screen. The network interface 640 provides a connection interface for various networking devices, such as a database server or a cloud storage server. The storage interface 650 provides a connection interface for external storage devices such as an SD card and a usb disk.
As will be appreciated by one skilled in the art, embodiments of the present disclosure may be provided as a method, system, or computer program product. Accordingly, the present disclosure may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable non-transitory storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present disclosure is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the disclosure. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only exemplary of the present disclosure and is not intended to limit the present disclosure, so that any modification, equivalent replacement, or improvement made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.
Claims (17)
1. An execution method of intelligent contracts in a block chain comprises the following steps: each of the plurality of control nodes is configured to,
receiving a contract invoking transaction request sent by a service node, wherein the contract invoking transaction request comprises: an expected outcome of contract execution;
sending the contract calling transaction request to each non-control node, wherein the number of the non-control nodes is less than the maximum allowable malicious node number;
receiving contract calling transaction results returned by the non-control nodes, and verifying whether the contract calling transaction results returned by the non-control nodes are matched with expected contract execution results;
and in the case that the result of the contract calling transaction returned by each non-control node is matched with the expected result of the contract execution, broadcasting the contract calling transaction request to other nodes to execute the contract calling transaction.
2. The execution method of claim 1, wherein the sending the contract invocation transaction request to each non-control node comprises:
and sending the contract invoking transaction request and a non-control node indication identifier to each non-control node, wherein the non-control node indication identifier is used for indicating each non-control node to execute the contract invoking transaction.
3. The execution method of claim 1, wherein the receiving the results of the contract invocation transaction returned by each non-control node comprises:
and receiving contract invoking transaction results returned by the non-control nodes within preset time.
4. The execution method of claim 1, wherein receiving the contract invocation transaction request sent by the service node comprises:
receiving a contract calling transaction request, a control node indication identifier and identifiers of all control nodes sent by a service node;
determining the identification of the non-control node according to the identification of each control node;
the sending the contract invocation transaction request to each non-control node comprises:
and sending the contract invoking transaction request to each non-control node according to the control node indication identification and the identification of the non-control node.
5. The execution method as recited in claim 1, further comprising:
in the event that the results of the contract invocation transaction returned by each non-control node do not match the expected results of the contract execution, discarding the contract invocation transaction request.
6. The execution method as recited in claim 1, further comprising:
a service node receives a transaction request initiated by a user;
the service node takes the node as a control node under the condition that the received transaction request comprises a contract calling transaction request, and randomly selects nodes with a preset number as the control node, wherein the preset number is greater than or equal to the maximum allowable malicious node number;
and the service node sends the contract invoking transaction request to each control node.
7. The execution method as recited in claim 1, further comprising: each of a plurality of said non-control nodes,
receiving the contract invoking transaction request sent by the control node;
executing contract calling transaction according to the contract calling transaction request, obtaining a result of the contract calling transaction and returning the result to the control node;
and storing the result of the contract invoking transaction.
8. The execution method of claim 7, further comprising: each of a plurality of said non-control nodes,
in response to receiving the contract calling transaction request again, inquiring whether a result of the contract calling transaction corresponding to the contract calling transaction request is stored;
and under the condition that the result of the contract calling transaction corresponding to the contract calling transaction request is stored, synchronously broadcasting the result of the contract calling transaction.
9. The execution method of claim 8, further comprising:
and the nodes with the block right receive the contract calling transaction results broadcast by each node, generate blocks after the consensus verification is completed on the contract calling transaction results broadcast by each node, synchronize the blocks to other nodes, and write the blocks into a local account book after the other nodes verify the blocks.
10. A node in a blockchain, wherein, in case the node is selected as a control node, comprising:
a receiving module, configured to receive a contract invoking transaction request sent by a service node, where the contract invoking transaction request includes: an expected outcome of contract execution;
the sending module is used for sending the contract calling transaction request to each non-control node, wherein the number of the non-control nodes is less than the maximum allowable malicious node number;
the verification module is used for receiving the contract calling transaction results returned by the non-control nodes and verifying whether the contract calling transaction results returned by the non-control nodes are matched with the expected contract execution result;
and the broadcasting module is used for broadcasting the contract calling transaction request to other nodes to execute the contract calling transaction under the condition that the result of the contract calling transaction returned by each non-control node is matched with the expected result of the contract execution.
11. The node in the blockchain of claim 10, wherein,
the sending module is used for sending the contract calling transaction request and a non-control node indication mark to each non-control node, wherein the non-control node indication mark is used for indicating each non-control node to execute contract calling transaction;
or, the verification module is used for receiving contract invoking transaction results returned by each non-control node within preset time;
or, the receiving module is used for receiving a contract invoking transaction request, a control node indication identifier and identifiers of each control node sent by the service node; determining the identification of the non-control node according to the identification of each control node; the sending module is used for sending the contract invoking transaction request to each non-control node according to the control node indication identification and the identification of the non-control node;
or, the broadcast module is further configured to discard the contract invocation transaction request if the result of the contract invocation transaction returned by each non-control node does not match the expected result of the contract execution.
12. The node in the blockchain of claim 10, wherein in case the node is a serving node, further comprising:
the service module is used for receiving a transaction request initiated by a user; taking the node as a control node under the condition that the received transaction request comprises a contract calling transaction request, and randomly selecting a preset number of nodes as the control node, wherein the preset number is greater than or equal to the maximum allowable rogue node number; and sending the contract invoking transaction request to each control node.
13. A blockchain system, comprising: a plurality of nodes according to any one of claims 10-11 as control nodes; and a plurality of non-control nodes;
the non-control node is used for receiving the contract invoking transaction request sent by the control node; executing contract calling transaction according to the contract calling transaction request, obtaining a result of the contract calling transaction and returning the result to the control node; and storing the result of the contract invoking transaction.
14. The blockchain system of claim 13, wherein,
the non-control node is used for responding to the fact that the contract calling transaction request is received again, and inquiring whether a result of the contract calling transaction corresponding to the contract calling transaction request is stored or not; and under the condition that the result of the contract calling transaction corresponding to the contract calling transaction request is stored, synchronously broadcasting the result of the contract calling transaction.
15. The blockchain system of claim 13, wherein, in a case that any node is a node having a block right, the blockchain system is configured to receive a result of the contract invocation transaction broadcast by each node, generate a block after the result of the contract invocation transaction broadcast by each node is subjected to consensus verification, synchronize the block to other nodes, and write a local ledger after the block is verified by other nodes.
16. An electronic device, comprising:
a processor; and
a memory coupled to the processor for storing instructions that, when executed by the processor, cause the processor to perform a method of performing intelligent contracts in blockchains as recited in any of claims 1-9.
17. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the program when executed by a processor implements the steps of the method of any one of claims 1-9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010824718.8A CN114078052A (en) | 2020-08-17 | 2020-08-17 | Execution method of intelligent contracts in block chain, node and block chain system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010824718.8A CN114078052A (en) | 2020-08-17 | 2020-08-17 | Execution method of intelligent contracts in block chain, node and block chain system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114078052A true CN114078052A (en) | 2022-02-22 |
Family
ID=80281058
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010824718.8A Pending CN114078052A (en) | 2020-08-17 | 2020-08-17 | Execution method of intelligent contracts in block chain, node and block chain system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114078052A (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110233823A (en) * | 2019-05-06 | 2019-09-13 | 深圳壹账通智能科技有限公司 | Block chain implementation method, system and storage medium |
CN111371739A (en) * | 2020-02-14 | 2020-07-03 | 重庆邮电大学 | Internet of things data access control method based on block chain technology |
-
2020
- 2020-08-17 CN CN202010824718.8A patent/CN114078052A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110233823A (en) * | 2019-05-06 | 2019-09-13 | 深圳壹账通智能科技有限公司 | Block chain implementation method, system and storage medium |
CN111371739A (en) * | 2020-02-14 | 2020-07-03 | 重庆邮电大学 | Internet of things data access control method based on block chain technology |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109345388B (en) | Block chain intelligent contract verification method and device and storage medium | |
CN108549580B (en) | Method for automatically deploying Kubernets slave nodes and terminal equipment | |
US11343103B2 (en) | Sending cross-chain authenticatable messages | |
CN111163182B (en) | Block chain-based device registration method and apparatus, electronic device, and storage medium | |
US10742415B2 (en) | Method and apparatus for inter-blockchain transmission of authenticable message | |
CN110661658B (en) | Node management method and device of block chain network and computer storage medium | |
US20220329591A1 (en) | Method, apparatus and device for generating device fingerprint and storage medium | |
CN110597918A (en) | Account management method and device and computer readable storage medium | |
CN111294390A (en) | Block data rapid synchronization method, device, equipment and storage medium | |
CN112184436B (en) | Data synchronization method, electronic device and readable storage medium | |
CN111447069A (en) | Low-frequency access data processing method based on block chain | |
CN111597537B (en) | Block chain network-based certificate issuing method, related equipment and medium | |
US11307790B2 (en) | Method, device, and computer program product for managing data placement | |
CN116502283A (en) | Privacy data processing method and device | |
CN113541987A (en) | Method and device for updating configuration data | |
CN111722994A (en) | Task request response method and device | |
CN110784551A (en) | Data processing method, device, equipment and medium based on multiple tenants | |
CN114666411B (en) | Request processing method, device, server, storage medium and product | |
CN116303343A (en) | Data slicing method, device, electronic equipment and storage medium | |
CN114078052A (en) | Execution method of intelligent contracts in block chain, node and block chain system | |
CN110730063A (en) | Security verification method and system, Internet of things platform, terminal and readable storage medium | |
CN114338060B (en) | Authority verification method, device, system, equipment and storage medium | |
CN113590352A (en) | Data calling method, device, equipment and readable storage medium | |
CN107704557B (en) | Processing method and device for operating mutually exclusive data, computer equipment and storage medium | |
CN108462713B (en) | Method and system for client to perform credibility verification |
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 |