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 PDF

Info

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
transaction request
result
contract invocation
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.)
Granted
Application number
CN202010824718.8A
Other languages
Chinese (zh)
Other versions
CN114078052B (en
Inventor
刘岩
梁伟
赵君
梁燕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Telecom Corp Ltd
Original Assignee
China Telecom Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN202010824718.8A priority Critical patent/CN114078052B/en
Publication of CN114078052A publication Critical patent/CN114078052A/en
Application granted granted Critical
Publication of CN114078052B publication Critical patent/CN114078052B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6227Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database where protection concerns the structure of data, e.g. records, types, queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures

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

Execution method of intelligent contracts in block chain, node and block chain system
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.
Memory 510 may include, for example, system memory, fixed non-volatile storage media, and the like. The system memory stores, for example, an operating system, an application program, a Boot Loader (Boot Loader), a database, and other programs.
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.一种区块链中智能合约的执行方法,包括:多个控制节点中的每一个,1. A method for executing a smart contract in a blockchain, comprising: each of a plurality of control nodes, 接收服务节点发送的合约调用交易请求,所述合约调用交易请求包括:合约执行的预期结果;Receive a contract invocation transaction request sent by the service node, where the contract invocation transaction request includes: the expected result of contract execution; 将所述合约调用交易请求发送至各个非控制节点,其中,所述非控制节点的数量小于最大容许作恶节点数;sending the contract invocation transaction request to each non-controlling node, wherein the number of the non-controlling nodes is less than the maximum allowable number of malicious nodes; 接收各个非控制节点返回的合约调用交易的结果,并验证各个非控制节点返回的合约调用交易的结果与所述合约执行的预期结果是否匹配;Receive the result of the contract invocation transaction returned by each non-controlling node, and verify whether the result of the contract invocation transaction returned by each non-controlling node matches the expected result of the contract execution; 在各个非控制节点返回的合约调用交易的结果与所述合约执行的预期结果匹配的情况下,将所述合约调用交易请求广播至其他节点执行合约调用交易。When the result of the contract invocation transaction returned by each non-controlling 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. 2.根据权利要求1中所述的执行方法,其中,所述将所述合约调用交易请求发送至各个非控制节点包括:2. The execution method according to claim 1, wherein the sending the contract invocation transaction request to each non-controlling node comprises: 将所述合约调用交易请求和非控制节点指示标识发送至各个非控制节点,其中,所述非控制节点指示标识用于指示各个非控制节点执行合约调用交易。The contract invocation transaction request and the non-controlling node indication identifier are sent to each non-controlling node, wherein the non-controlling node indication identifier is used to instruct each non-controlling node to execute the contract invoking transaction. 3.根据权利要求1中所述的执行方法,其中,所述接收各个非控制节点返回的合约调用交易的结果包括:3. The execution method according to claim 1, wherein the receiving the result of the contract invocation transaction returned by each non-controlling node comprises: 在预设时间内接收各个非控制节点返回的合约调用交易的结果。Receive the contract call transaction result returned by each non-controlling node within a preset time. 4.根据权利要求1中所述的执行方法,其中,所述接收服务节点发送的合约调用交易请求包括:4. The execution method according to claim 1, wherein the receiving the contract invocation transaction request sent by the service node comprises: 接收服务节点发送的合约调用交易请求、控制节点指示标识和各个控制节点的标识;Receive the contract invocation transaction request sent by the service node, the control node indication ID and the ID of each control node; 根据各个控制节点的标识确定非控制节点的标识;Determine the identity of the non-control node according to the identity of each control node; 所述将所述合约调用交易请求发送至各个非控制节点包括:The sending the contract invocation transaction request to each non-controlling node includes: 根据所述控制节点指示标识和非控制节点的标识将所述合约调用交易请求发送至各个非控制节点。The contract invocation transaction request is sent to each non-control node according to the control node indication identifier and the non-control node identifier. 5.根据权利要求1中所述的执行方法,还包括:5. The execution method according to claim 1, further comprising: 在各个非控制节点返回的合约调用交易的结果与所述合约执行的预期结果的不匹配的情况下,将所述合约调用交易请求丢弃。In the case that the result of the contract invocation transaction returned by each non-controlling node does not match the expected result of the contract execution, the contract invocation transaction request is discarded. 6.根据权利要求1中所述的执行方法,还包括:6. The execution method according to claim 1, further comprising: 服务节点接收用户发起的交易请求;The service node receives the transaction request initiated by the user; 所述服务节点在接收到的交易请求中包括合约调用交易请求的情况下,将本节点作为一个控制节点,并随机选取预设数量的节点作为控制节点,其中,所述预设数量大于或等于最大容许作恶节点数;In the case where the received transaction request includes a contract invocation transaction request, the service node takes this node as a control node, and randomly selects a preset number of nodes as control nodes, wherein the preset number is greater than or equal to Maximum allowable number of malicious nodes; 所述服务节点将所述合约调用交易请求发送至各个控制节点。The service node sends the contract invocation transaction request to each control node. 7.根据权利要求1中所述的执行方法,还包括:多个所述非控制节点中的每一个,7. The execution method according to claim 1, further comprising: each of a plurality of said non-controlling nodes, 接收所述控制节点发送的所述合约调用交易请求;receiving the contract invocation transaction request sent by the control node; 根据所述合约调用交易请求执行合约调用交易,得到合约调用交易的结果并返回至所述控制节点;Execute the contract invocation transaction according to the contract invocation transaction request, obtain the result of the contract invocation transaction and return it to the control node; 将所述合约调用交易的结果进行存储。The result of the contract invocation transaction is stored. 8.根据权利要求7所述的执行方法,还包括:多个所述非控制节点中的每一个,8. The execution method according to claim 7, further comprising: each of a plurality of said non-controlling nodes, 响应于再次接收到所述合约调用交易请求,查询是否存储所述合约调用交易请求对应的合约调用交易的结果;In response to receiving the contract invocation transaction request again, query whether to store the contract invocation transaction result corresponding to the contract invocation transaction request; 在已存储所述合约调用交易请求对应的合约调用交易的结果的情况下,将所述合约调用交易的结果进行同步广播。When the result of the contract invocation transaction corresponding to the contract invocation transaction request has been stored, the result of the contract invocation transaction is broadcast synchronously. 9.根据权利要求8所述的执行方法,还包括:9. The execution method according to claim 8, further comprising: 具有出块权的节点接收各个节点广播的所述合约调用交易的结果,对各个节点广播的所述合约调用交易的结果完成共识验证之后,生成区块,并将所述区块同步至其他节点,由其他节点验证区块后写入本地账本。The node with the right to produce a block receives the result of the contract invocation transaction broadcast by each node, and after completing consensus verification on the result of the contract invocation transaction broadcast by each node, generates a block and synchronizes the block to other nodes. , and the block is verified by other nodes and written to the local ledger. 10.一种区块链中的节点,其中,在所述节点被选作控制节点的情况下,包括:10. A node in a blockchain, wherein, when the node is selected as a control node, comprising: 接收模块,用于接收服务节点发送的合约调用交易请求,所述合约调用交易请求包括:合约执行的预期结果;a receiving module, configured to receive a contract invocation transaction request sent by the service node, where the contract invocation transaction request includes: an expected result of contract execution; 发送模块,用于将所述合约调用交易请求发送至各个非控制节点,其中,所述非控制节点的数量小于最大容许作恶节点数;a sending module, configured to send the contract invocation transaction request to each non-controlling node, wherein the number of the non-controlling nodes is less than the maximum allowable number of malicious nodes; 验证模块,用于接收各个非控制节点返回的合约调用交易的结果,并验证各个非控制节点返回的合约调用交易的结果与所述合约执行的预期结果是否匹配;The verification module is used to receive the result of the contract invocation transaction returned by each non-controlling node, and verify whether the result of the contract invocation transaction returned by each non-controlling node matches the expected result of the execution of the contract; 广播模块,用于在各个非控制节点返回的合约调用交易的结果与所述合约执行的预期结果匹配的情况下,将所述合约调用交易请求广播至其他节点执行合约调用交易。The broadcasting module is configured to broadcast the contract invocation transaction request to other nodes to execute the contract invocation transaction when the result of the contract invocation transaction returned by each non-controlling node matches the expected result of the contract execution. 11.根据权利要求10所述的区块链中的节点,其中,11. The node in the blockchain of claim 10, wherein, 所述发送模块用于将所述合约调用交易请求和非控制节点指示标识发送至各个非控制节点,其中,所述非控制节点指示标识用于指示各个非控制节点执行合约调用交易;The sending module is configured to send the contract invocation transaction request and the non-controlling node indicator to each non-controlling node, wherein the non-controlling node indicator is used to instruct each non-controlling node to execute the contract invoking transaction; 或者,所述验证模块用于在预设时间内接收各个非控制节点返回的合约调用交易的结果;Alternatively, the verification module is configured to receive the result of the contract invocation transaction returned by each non-controlling node within a preset time; 或者,所述接收模块用于接收服务节点发送的合约调用交易请求、控制节点指示标识和各个控制节点的标识;根据各个控制节点的标识确定非控制节点的标识;所述发送模块用于根据所述控制节点指示标识和非控制节点的标识将所述合约调用交易请求发送至各个非控制节点;Or, the receiving module is used to receive the contract invocation transaction request sent by the service node, the indication identifier of the control node and the identifier of each control node; the identifier of the non-control node is determined according to the identifier of each control node; the sending module is used to determine the identifier of the non-control node according to the The control node indication identifier and the non-control node identifier send the contract invocation transaction request to each non-control node; 或者,所述广播模块还用于在各个非控制节点返回的合约调用交易的结果与所述合约执行的预期结果的不匹配的情况下,将所述合约调用交易请求丢弃。Alternatively, the broadcasting module is further configured to discard the contract invocation transaction request when the result of the contract invocation transaction returned by each non-controlling node does not match the expected result of the contract execution. 12.根据权利要求10所述的区块链中的节点,其中,在所述节点作为服务节点的情况下,还包括:12. The node in the blockchain according to claim 10, wherein, in the case of the node as a service node, further comprising: 服务模块,用于接收用户发起的交易请求;在接收到的交易请求中包括合约调用交易请求的情况下,将本节点作为一个控制节点,并随机选取预设数量的节点作为控制节点,其中,所述预设数量大于或等于最大容许作恶节点数;将所述合约调用交易请求发送至各个控制节点。The service module is used to receive the transaction request initiated by the user; when the received transaction request includes a contract invocation transaction request, this node is used as a control node, and a preset number of nodes are randomly selected as control nodes, wherein, The preset number is greater than or equal to the maximum allowable number of malicious nodes; the contract invocation transaction request is sent to each control node. 13.一种区块链系统,包括:多个权利要求10-11任一项所述的节点,作为控制节点;以及多个非控制节点;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-controlling nodes; 所述非控制节点用于接收所述控制节点发送的所述合约调用交易请求;根据所述合约调用交易请求执行合约调用交易,得到合约调用交易的结果并返回至所述控制节点;将所述合约调用交易的结果进行存储。The non-controlling node is configured to receive the contract invocation transaction request sent by the control node; execute the contract invocation transaction according to the contract invocation transaction request, obtain the result of the contract invocation transaction and return it to the control node; The contract calls the result of the transaction for storage. 14.根据权利要求13所述的区块链系统,其中,14. The blockchain system of claim 13, wherein, 所述非控制节点用于响应于再次接收到所述合约调用交易请求,查询是否存储所述合约调用交易请求对应的合约调用交易的结果;在已存储所述合约调用交易请求对应的合约调用交易的结果的情况下,将所述合约调用交易的结果进行同步广播。The non-controlling node is configured to, in response to receiving the contract invocation transaction request again, query whether to store the result of the contract invocation transaction corresponding to the contract invocation transaction request; if the contract invocation transaction corresponding to the contract invocation transaction request has been stored In the case of the result of the contract, the result of the contract invocation transaction is broadcast synchronously. 15.根据权利要求13所述的区块链系统,其中,在任意节点作为具有出块权的节点的情况下,用于接收各个节点广播的所述合约调用交易的结果,对各个节点广播的所述合约调用交易的结果完成共识验证之后,生成区块,并将所述区块同步至其他节点,由其他节点验证区块后写入本地账本。15. The blockchain system according to claim 13, wherein, in the case where any node is a node with the right to produce blocks, for receiving the result of the contract invocation transaction broadcast by each node, the data broadcast by each node is After the result of the contract calling transaction completes the consensus verification, a block is generated, and the block is synchronized to other nodes, and the other nodes verify the block and write it into the local ledger. 16.一种电子设备,包括:16. An electronic device comprising: 处理器;以及processor; and 耦接至所述处理器的存储器,用于存储指令,所述指令被所述处理器执行时,使所述处理器执行如权利要求1-9任一项所述的区块链中智能合约的执行方法。A memory coupled to the processor for storing instructions that, when executed by the processor, cause the processor to execute the smart contract in the blockchain according to any one of claims 1-9 method of execution. 17.一种非瞬时性计算机可读存储介质,其上存储有计算机程序,其中,该程序被处理器执行时实现权利要求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.
CN202010824718.8A 2020-08-17 2020-08-17 Execution method, node and blockchain system of smart contracts in blockchain Active CN114078052B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010824718.8A CN114078052B (en) 2020-08-17 2020-08-17 Execution method, node and blockchain system of smart contracts in blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010824718.8A CN114078052B (en) 2020-08-17 2020-08-17 Execution method, node and blockchain system of smart contracts in blockchain

Publications (2)

Publication Number Publication Date
CN114078052A true CN114078052A (en) 2022-02-22
CN114078052B CN114078052B (en) 2025-01-28

Family

ID=80281058

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010824718.8A Active CN114078052B (en) 2020-08-17 2020-08-17 Execution method, node and blockchain system of smart contracts in blockchain

Country Status (1)

Country Link
CN (1) CN114078052B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115016959A (en) * 2022-06-23 2022-09-06 北京链道科技有限公司 Calling methods between blockchain smart contracts

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106656974A (en) * 2016-10-17 2017-05-10 江苏通付盾科技有限公司 Block chain grouping consensus method and system
CN110233823A (en) * 2019-05-06 2019-09-13 深圳壹账通智能科技有限公司 Block chain implementation method, system and storage medium
US20190372985A1 (en) * 2018-05-30 2019-12-05 International Business Machines Corporation Sensitive information accessibility in blockchain
CN111275555A (en) * 2020-02-24 2020-06-12 中国工商银行股份有限公司 Block chain transaction processing method, transaction node and block chain system
CN111371739A (en) * 2020-02-14 2020-07-03 重庆邮电大学 A method of Internet of Things data access control based on blockchain technology

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106656974A (en) * 2016-10-17 2017-05-10 江苏通付盾科技有限公司 Block chain grouping consensus method and system
US20190372985A1 (en) * 2018-05-30 2019-12-05 International Business Machines Corporation Sensitive information accessibility in blockchain
CN110233823A (en) * 2019-05-06 2019-09-13 深圳壹账通智能科技有限公司 Block chain implementation method, system and storage medium
CN111371739A (en) * 2020-02-14 2020-07-03 重庆邮电大学 A method of Internet of Things data access control based on blockchain technology
CN111275555A (en) * 2020-02-24 2020-06-12 中国工商银行股份有限公司 Block chain transaction processing method, transaction node and block chain system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115016959A (en) * 2022-06-23 2022-09-06 北京链道科技有限公司 Calling methods between blockchain smart contracts

Also Published As

Publication number Publication date
CN114078052B (en) 2025-01-28

Similar Documents

Publication Publication Date Title
CN112446785B (en) Cross-chain transaction method, system, device, equipment and storage medium
CN110727712B (en) Data processing method and device based on block chain network, electronic equipment and storage medium
CN108549580B (en) Method for automatically deploying Kubernets slave nodes and terminal equipment
CN111163182B (en) Block chain-based device registration method and apparatus, electronic device, and storage medium
US11336451B2 (en) Cross-blockchain resource transmission
US11343103B2 (en) Sending cross-chain authenticatable messages
US10924281B2 (en) Method and apparatus for inter-blockchain transmission of authenticable message
US20220329591A1 (en) Method, apparatus and device for generating device fingerprint and storage medium
WO2018076760A1 (en) Block chain-based transaction processing method, system, electronic device, and storage medium
CN110597918A (en) Account management method and device and computer readable storage medium
CN112035144B (en) Upgrading method and device of block chain system, computer equipment and storage medium
CN111597537B (en) Block chain network-based certificate issuing method, related equipment and medium
CN116502283A (en) Privacy data processing method and device
CN113961600A (en) A data query method, device, computer equipment and storage medium
US11307790B2 (en) Method, device, and computer program product for managing data placement
CN111817859A (en) Data sharing method, device, device and storage medium based on zero-knowledge proof
CN113541987A (en) A method and apparatus for updating configuration data
CN114078052A (en) Execution method of intelligent contracts in block chain, node and block chain system
CN112181599B (en) Model training method, device and storage medium
CN110730063A (en) Security verification method and system, Internet of things platform, terminal and readable storage medium
CN111722994A (en) A method and device for responding to a task request
CN111371811A (en) Resource calling method, resource calling device, client and service server
CN110784551A (en) Data processing method, device, equipment and medium based on multiple tenants
CN113590180B (en) Detection strategy generation method and device
CN114338060B (en) Authority verification method, device, system, equipment and storage medium

Legal Events

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