CN111695991B - Block-based contract processing method and device, block chain node and storage medium - Google Patents

Block-based contract processing method and device, block chain node and storage medium Download PDF

Info

Publication number
CN111695991B
CN111695991B CN201910192618.5A CN201910192618A CN111695991B CN 111695991 B CN111695991 B CN 111695991B CN 201910192618 A CN201910192618 A CN 201910192618A CN 111695991 B CN111695991 B CN 111695991B
Authority
CN
China
Prior art keywords
contract
consensus
block
execution result
execution
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.)
Active
Application number
CN201910192618.5A
Other languages
Chinese (zh)
Other versions
CN111695991A (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.)
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Wodong Tianjun Information Technology Co Ltd
Priority to CN201910192618.5A priority Critical patent/CN111695991B/en
Publication of CN111695991A publication Critical patent/CN111695991A/en
Application granted granted Critical
Publication of CN111695991B publication Critical patent/CN111695991B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

Abstract

The embodiment of the invention provides a contract processing method and device based on a block, a block chain node and a storage medium. According to the method, the block structure is adjusted, contract execution result information is added to the block header, when the block packing operation is executed, a consensus contract is obtained, whether the current block meets the execution conditions of the consensus contract is judged, if the current block meets the execution conditions of the consensus contract, the consensus contract is executed, the execution result of the consensus contract is added to the block header of the current block, and the consensus contract based on the block level is realized, so that the corresponding data processing based on the block level can be completed through the execution of the consensus contract in the process of packing and generating the block, and then the query result can be obtained by querying the data in the latest block without traversing all the blocks and without affecting the performance and efficiency of the block chain node.

Description

Block-based contract processing method and device, block chain node and storage medium
Technical Field
The embodiment of the invention relates to the technical field of blockchain, in particular to a method and a device for processing contracts based on blocks, a blockchain node and a storage medium.
Background
With the development of blockchain technology, the current technology of blockchain has not just performed data storage, but it supports smart contracts (a programmable program) so that people can process data through the smart contracts before the blockchain actually stores.
Currently, blockchain smart contracts are defined at the transaction level, that is, various programmatic processes are performed to initiate a transaction. If the data processing based on the block level is needed, all blocks need to be traversed, the information of each block is obtained, and then the information of each block is subjected to comprehensive data processing to obtain a processing result. For example, all the transaction totals up to the current block need to be checked, all the blocks need to be traversed, the transaction data in each block is acquired, the number of transactions in each block is calculated, and then summed.
However, because the transaction number is very huge and the number of blocks in the blockchain is large, the information of each block is read by traversing all the blocks, the read-write performance of the blockchain node is seriously affected, and the data processing efficiency of the blockchain node is affected.
Disclosure of Invention
The embodiment of the invention provides a contract processing method and device based on blocks, a block chain node and a storage medium, which are used for solving the problems that the read-write performance of the block chain node and the processing efficiency of block chain node data are affected seriously when the information of each block is read by traversing all blocks due to the huge transaction quantity and the large number of blocks in the block chain in the data processing based on the block hierarchy in the prior art.
An aspect of an embodiment of the present invention provides a method for processing a contract based on a block, including:
when the block packing operation is executed, a consensus contract is obtained;
judging whether the current block meets the execution condition of the consensus contract or not;
if the current block meets the execution conditions of the consensus contract, executing the consensus contract to obtain an execution result;
and adding the execution result of the consensus contract into the block header of the current block.
Another aspect of an embodiment of the present invention provides a contract processing apparatus for a block, including:
an actuator module for:
when the block packing operation is executed, a consensus contract is obtained;
judging whether the current block meets the execution condition of the consensus contract or not;
if the current block meets the execution conditions of the consensus contract, executing the consensus contract to obtain an execution result;
and adding the execution result of the consensus contract into the block header of the current block.
Another aspect of an embodiment of the present invention is to provide a blockchain node, including:
a memory, a processor, and a computer program stored on the memory and executable on the processor,
the processor implements the block-based contract processing method described above when running the computer program.
It is another aspect of embodiments of the present invention to provide a computer readable storage medium storing a computer program which when executed by a processor implements the above-described block-based contract processing method.
According to the contract processing method, the device, the block chain node and the storage medium based on the block, the block structure is adjusted, contract execution result information is added in the block header, when the block packing operation is executed, the common contract is obtained, whether the current block meets the execution conditions of the common contract is judged, if the current block meets the execution conditions of the common contract, the common contract is executed, the execution result of the common contract is added in the block header of the current block, the common contract based on the block hierarchy is realized, and therefore, in the process of packing and generating the block, the corresponding data processing based on the block hierarchy can be completed through the execution of the common contract, the query result can be obtained only by querying the data in the latest block, all the blocks do not need to be traversed, and the performance and the efficiency of the block chain node are not influenced.
Drawings
FIG. 1 is a flowchart of a block-based contract processing method according to an embodiment of the invention;
fig. 2 is a block header structure schematic diagram according to a first embodiment of the present invention;
FIG. 3 is a flowchart of a block-based contract processing method according to a second embodiment of the invention;
FIG. 4 is a schematic diagram of a block-based contract processing apparatus according to a fourth embodiment of the invention;
fig. 5 is a schematic structural diagram of a blockchain node according to a fifth embodiment of the present invention.
Specific embodiments of the present invention have been shown by way of the above drawings and will be described in more detail below. The drawings and the written description are not intended to limit the scope of the inventive embodiments in any way, but rather to illustrate the inventive concepts to those skilled in the art by reference to the specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with embodiments of the invention. Rather, they are merely examples of apparatus and methods consistent with aspects of embodiments of the invention as detailed in the accompanying claims.
The terms "first," "second," and the like, according to embodiments of the present invention, are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the following description of the embodiments, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.
Example 1
FIG. 1 is a flowchart of a block-based contract processing method according to an embodiment of the invention; fig. 2 is a block header structure diagram according to an embodiment of the present invention. The embodiment of the invention aims at the problems that in the prior art, the read-write performance of a block chain node is seriously influenced and the data processing efficiency of block chain link points is influenced due to the fact that the transaction quantity is huge and the block quantity in a block chain is large, and the information of each block is read by traversing all blocks.
The method of the present embodiment is applied to nodes, typically consensus nodes, in the block link points for performing block packing operations. In other embodiments, the method may also be applied to other devices, and this embodiment is schematically illustrated using a consensus node as an example.
As shown in fig. 1, the method specifically comprises the following steps:
step S101, when performing the block packing operation, a consensus contract is obtained.
Wherein, the consensus contract refers to an intelligent contract passing through a consensus block layer.
In this embodiment, a developer may develop and generate a consensus contract by processing data of a block level to be executed. For example, the consensus contract may perform the function of calculating the total number of all transactions that are blocked to the current block; when the current block is generated, the total number of all the transactions reaching the current block can be obtained by summing the total number of the transactions recorded in the last block and the transaction number of the current block, and the current block is not required to be traversed, so that the method is simple and quick.
When the consensus contract is executed by the consensus node, the function of data processing of the block level corresponding to the consensus contract can be realized, and the execution result is the processing result of the data processing of the corresponding block level.
The consensus node, when performing the block packing operation, obtains one or more consensus contracts that have been consensus-agreed. If there are multiple consensus contracts, the following steps S102-S104 are performed for each consensus contract, and each consensus contract is executed to obtain an execution result, and the execution result is added to the block header of the current block.
In addition, if the block hash value in the block structure is a hash value of the entire block, it is necessary to complete the process of executing the consensus contract and adding the execution result to the block header of the current block before calculating the block hash value.
Step S102, judging whether the current block meets the execution condition of the consensus contract.
Before each consensus contract is executed, the consensus node first determines whether the current block satisfies the execution condition of the consensus contract.
For each consensus contract, if the current block meets the execution condition of the consensus contract, steps S103-S104 are executed. If the current block does not meet the execution condition of the consensus contract, the consensus contract is not required to be executed.
Step S103, if the current block meets the execution condition of the consensus contract, executing the consensus contract.
Step S104, adding the execution result of the consensus contract to the block header of the current block.
In this embodiment, the block structure is adjusted, and contract execution result information is added to the block header. The contract execution result information includes at least: contract identification information and execution results.
The contract identification information is used for uniquely identifying a consensus contract, has uniqueness, can be used as the unique identification of the consensus contract, and can also be used for uniquely identifying the execution result of the consensus contract. The contract identification information may be any information that can be used to uniquely identify a consensus contract, and the present embodiment is not particularly limited herein. For example, the contract identification information may include contract name and/or contract version information.
In addition, the execution results of different consensus contracts may have different structures, and the structure of the corresponding execution result may be determined by contract identification information. The execution result of the consensus contract may be a result set, and the specific structure of the execution result may be set by a technician according to the function and the requirement of the consensus contract, which is not specifically limited herein.
Further, the contract execution result information in the block header of the block structure may include zero, one, or multiple execution results of the consensus contract.
For example, as shown in fig. 2, the structure of the adjusted block header may include the original attribute information of the block header and the contract execution result information of the consensus contract. The block header shown in fig. 2 includes contract execution result information corresponding to 3 consensus contracts, and the block header includes a formula contract result set composed of execution results of a plurality of consensus contracts. The contract execution result information includes contract identification information, which is a combination of a contract name and a contract version number, and an execution result.
In fig. 2, the contract execution result information is schematically described by taking the example before other attribute information of the block header, and the position of the contract execution result information is not particularly limited.
According to the embodiment of the invention, the block structure is adjusted, contract execution result information is added in the block header, when the block packing operation is executed, the consensus contract is acquired, whether the current block meets the execution condition of the consensus contract is judged, if the current block meets the execution condition of the consensus contract, the consensus contract is executed, the execution result of the consensus contract is added into the block header of the current block, and the consensus contract based on the block level is realized, so that the corresponding data processing based on the block level can be completed through the execution of the consensus contract in the process of packing and generating the block, the query result can be obtained only by querying the data in the latest block, all blocks do not need to be traversed, and the performance and the efficiency of the block chain node are not influenced.
Example two
Fig. 3 is a flowchart of a block-based contract processing method according to a second embodiment of the invention. On the basis of the first embodiment, in this embodiment, when performing the block packing operation, obtaining the consensus contract includes: when a block packing operation is performed, the loaded consensus contract is obtained. Accordingly, before the obtaining of the consensus contract when performing the block packing operation, the method further comprises: analyzing the new consensus contract which is subjected to consensus, and judging whether the new consensus contract has grammar errors or not; if the new consensus contract has no grammar error, loading the new consensus contract.
As shown in fig. 3, the method specifically comprises the following steps:
step S201, analyzing the new consensus contract which is subjected to consensus, and judging whether the new consensus contract has grammar errors or not.
Wherein, the consensus contract refers to an intelligent contract passing through a consensus block layer.
In this embodiment, a developer may develop and generate a consensus contract by processing data of a block level to be executed. For example, the consensus contract may perform the function of calculating the total number of all transactions that are blocked to the current block; when the current block is generated, the total number of all the transactions reaching the current block can be obtained by summing the total number of the transactions recorded in the last block and the transaction number of the current block, and the current block is not required to be traversed, so that the method is simple and quick.
In this embodiment, the consensus node may perform the function of block-based contract processing through the following four program modules: an adapter module, a parser module, a loader module, and an executor module.
The adapter module is used for exposing the variable or interface of the blockchain to provide the corresponding variable or interface for the developer to use. For example: at least the following variables or interfaces may be provided: the $ { blockHeight } is the current block height, $ { blockHash } is the current block Hash value (block Hash), $ { txCount } is the number of transactions in the current block, etc.
The common contract is essentially program code for realizing corresponding functions, and the parser module is used for carrying out code parsing and compiling on the common contract provided by the developer, so as to ensure that the common contract has no grammar errors.
Specifically, the new consensus contract after consensus is analyzed and processed to determine whether the new consensus contract has grammar errors. If the new consensus contract has grammar errors, the consensus contract is not loaded.
Alternatively, the new consensus contract may be obtained before parsing the new consensus contract that has undergone consensus; and carrying out consensus processing on the new consensus contracts according to a consensus algorithm to obtain consensus contracts after consensus.
In particular, the new consensus contract may be a consensus contract submitted by an open person. The consensus is performed by all consensus nodes when performing the block packing operation after the consensus has been reached by the consensus nodes.
The consensus algorithm may be set by a technician according to actual needs, and the embodiment is not specifically limited herein. The process of performing the consensus processing on the new consensus contract according to the consensus algorithm is consistent with the existing consensus processing, and this embodiment is not described herein.
In addition, consensus contracts are developed by developers themselves, the patent is not limited to development languages, but the contracts themselves include, but are not limited to, the following: contract identification information, contract execution conditions, and contract execution programs. The contract execution program may call a variable or interface of the blockchain.
Step S202, if the new consensus contract has no grammar error, loading the new consensus contract.
The loader module is configured to load the parsed consensus contract to the loader module based on the consensus contract being free of errors.
Step S203, when the block packing operation is performed, the loaded consensus contract is obtained.
When the consensus contract is executed by the consensus node, the function of data processing of the block level corresponding to the consensus contract can be realized, and the execution result is the processing result of the data processing of the corresponding block level.
The consensus node obtains the loaded one or more consensus contracts from the loader module when performing the block packing operation.
If a plurality of consensus contracts are acquired, each of the consensus contracts is taken as a target contract, and the following processing of steps S203 to S206 is performed on the target contract, so that all the loaded consensus contracts are traversed.
In addition, if the block hash value in the block structure is a hash value of the entire block, it is necessary to complete the process of executing the consensus contract and adding the execution result to the block header of the current block before calculating the block hash value.
Step S204, judging whether the current block meets the execution condition of the consensus contract.
One of the main functions of the actuator module is: and judging whether the current block meets the execution condition of the consensus contract.
Before each consensus contract is executed, a contract execution condition interface is called first to determine whether the current block meets the execution condition of the consensus contract. And if the current block meets the execution condition of the consensus contract, calling a contract execution interface to execute the consensus contract. If the current block is determined not to meet the execution condition of the consensus contract, the consensus contract is not executed.
In step S205, if the current block meets the execution condition of the consensus contract, the consensus contract is executed.
Another main function of the actuator module is: when the current block is determined to meet the execution condition of the consensus contract, the consensus contract is executed, and the execution result is added to the block header of the current block.
Step S206, adding the execution result of the consensus contract to the block header of the current block.
In this embodiment, the block structure is adjusted, and contract execution result information is added to the block header. The contract execution result information includes at least: contract identification information and execution results.
The contract identification information is used for uniquely identifying a consensus contract, has uniqueness, can be used as the unique identification of the consensus contract, and can also be used for uniquely identifying the execution result of the consensus contract. The contract identification information may be any information that can be used to uniquely identify a consensus contract, and the present embodiment is not particularly limited herein. For example, the contract identification information may include contract name and/or contract version information.
In addition, the execution results of different consensus contracts may have different structures, and the structure of the corresponding execution result may be determined by contract identification information. The execution result of the consensus contract may be a result set, and the specific structure of the execution result may be set by a technician according to the function and the requirement of the consensus contract, which is not specifically limited herein.
Further, the contract execution result information in the block header of the block structure may include zero, one, or multiple execution results of the consensus contract.
For example, as shown in fig. 2, the structure of the adjusted block header may include the original attribute information of the block header and the contract execution result information of the consensus contract. The block header shown in fig. 2 includes contract execution result information corresponding to 3 consensus contracts, and the block header includes a formula contract result set composed of execution results of a plurality of consensus contracts. The contract execution result information includes contract identification information, which is a combination of a contract name and a contract version number, and an execution result.
In fig. 2, the contract execution result information is schematically described by taking the example before other attribute information of the block header, and the position of the contract execution result information is not particularly limited.
In this step, the execution result is written into the contract execution result information of the block header of the current block, so that the execution result can be written into the specified position of the block header (the position where the contract execution result information is located).
According to the embodiment of the invention, the block structure is adjusted, contract execution result information is added in the block header, when the block packing operation is executed, a consensus contract is obtained, whether the current block meets the execution condition of the consensus contract is judged, if the current block meets the execution condition of the consensus contract, the consensus contract is executed, the execution result of the consensus contract is added into the block header of the current block, and the block-level-based consensus contract is realized, so that the corresponding block-level-based data processing can be completed through the execution of the consensus contract in the process of packing and generating the block, the query result can be obtained only by querying the data in the latest block, all blocks do not need to be traversed, and the performance and the efficiency of a block chain node are not influenced; and the consensus contract can realize smooth upgrading, and different data processing based on block level can be realized by upgrading the consensus contract without repeatedly adjusting the block structure.
Example III
The third embodiment of the invention provides a contract processing device based on a block. The contract processing device based on the block provided by the embodiment of the invention can execute the processing flow provided by the contract processing method based on the block. In this embodiment, a block-based contract processing apparatus includes an executor module.
Specifically, the actuator module is configured to:
when the block packing operation is executed, a consensus contract is obtained; judging whether the current block meets the execution condition of the consensus contract or not; if the current block meets the execution conditions of the consensus contract, executing the consensus contract to obtain an execution result; the execution result of the consensus contract is added to the block header of the current block.
The apparatus provided in the embodiment of the present invention may be specifically used to perform the method embodiment provided in the first embodiment, and specific functions are not described herein.
According to the embodiment of the invention, the block structure is adjusted, contract execution result information is added in the block header, when the block packing operation is executed, the consensus contract is acquired, whether the current block meets the execution condition of the consensus contract is judged, if the current block meets the execution condition of the consensus contract, the consensus contract is executed, the execution result of the consensus contract is added into the block header of the current block, and the consensus contract based on the block level is realized, so that the corresponding data processing based on the block level can be completed through the execution of the consensus contract in the process of packing and generating the block, the query result can be obtained only by querying the data in the latest block, all blocks do not need to be traversed, and the performance and the efficiency of the block chain node are not influenced.
Example IV
Fig. 4 is a schematic structural diagram of a contract processing apparatus based on a block according to a fourth embodiment of the invention. In the third embodiment, in the block structure of the block chain, the block header includes contract execution result information, and the contract execution result information includes at least: contract identification information and execution results.
The contract execution result information in the block header of the block structure comprises execution results of zero, one or a plurality of consensus contracts.
Optionally, the actuator module is further configured to:
writing the execution result into contract execution result information of the block head of the current block.
Optionally, the actuator module is further configured to:
when a block packing operation is performed, the loaded consensus contract is obtained.
Alternatively, as shown in fig. 4, the block-based contract processing apparatus 30 may include: an executor module 301, a loader module 302 and an analyzer module 303.
The parser module 303 is configured to: and analyzing the new consensus contract which is subjected to consensus, and judging whether the new consensus contract has grammar errors or not.
The loader module 302 is configured to: if the new consensus contract has no grammar error, loading the new consensus contract.
Optionally, as shown in fig. 4, the block-based contract processing apparatus 30 may further include: a consensus module 304.
The consensus module 304 is configured to:
acquiring a new consensus contract; and carrying out consensus processing on the new consensus contracts according to a consensus algorithm.
The apparatus provided in the embodiment of the present invention may be specifically used to execute the method embodiment provided in the second embodiment, and specific functions are not described herein.
According to the embodiment of the invention, the block structure is adjusted, contract execution result information is added in the block header, when the block packing operation is executed, a consensus contract is obtained, whether the current block meets the execution condition of the consensus contract is judged, if the current block meets the execution condition of the consensus contract, the consensus contract is executed, the execution result of the consensus contract is added into the block header of the current block, and the block-level-based consensus contract is realized, so that the corresponding block-level-based data processing can be completed through the execution of the consensus contract in the process of packing and generating the block, the query result can be obtained only by querying the data in the latest block, all blocks do not need to be traversed, and the performance and the efficiency of a block chain node are not influenced; and the consensus contract can realize smooth upgrading, and different data processing based on block level can be realized by upgrading the consensus contract without repeatedly adjusting the block structure.
Example five
Fig. 5 is a schematic structural diagram of a blockchain node according to a fifth embodiment of the present invention. As shown in fig. 5, the blockchain node 50 includes: a processor 501, a memory 502, and a computer program stored on the memory 502 and executable by the processor 501.
The processor 501, when executing a computer program stored on the memory 502, implements the block-based contract processing method provided by any of the method embodiments described above.
According to the embodiment of the invention, the block structure is adjusted, contract execution result information is added in the block header, when the block packing operation is executed, the consensus contract is acquired, whether the current block meets the execution condition of the consensus contract is judged, if the current block meets the execution condition of the consensus contract, the consensus contract is executed, the execution result of the consensus contract is added into the block header of the current block, and the consensus contract based on the block level is realized, so that the corresponding data processing based on the block level can be completed through the execution of the consensus contract in the process of packing and generating the block, the query result can be obtained only by querying the data in the latest block, all blocks do not need to be traversed, and the performance and the efficiency of the block chain node are not influenced.
In addition, the embodiment of the invention also provides a computer readable storage medium, which stores a computer program, and the computer program realizes the block-based contract processing method provided by any one of the method embodiments when being executed by a processor.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
The integrated units implemented in the form of software functional units described above may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform part of the steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above. The specific working process of the above-described device may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It is to be understood that the invention is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (12)

1. A block-based contract processing method, comprising:
when a block packing operation is executed, a consensus contract is obtained, wherein the consensus contract is used for completing the function of calculating the total number of all transactions ending to the current block, and the consensus contract refers to an intelligent contract passing through a consensus block layer;
judging whether the current block meets the execution condition of the consensus contract or not;
if the current block meets the execution conditions of the consensus contract, executing the consensus contract to obtain an execution result;
adding the execution result of the consensus contract to a block header of the current block;
in a block structure of a blockchain, a blockhead includes contract execution result information, the contract execution result information at least including: contract identification information and execution results; the adding the execution result of the consensus contract to the block header of the current block comprises:
writing the execution result into contract execution result information of the block head of the current block.
2. The method of claim 1, wherein the contract execution result information in a block header of the block structure includes execution results of zero, one, or multiple consensus contracts.
3. The method according to claim 1 or 2, wherein the obtaining a consensus contract when performing a block packing operation comprises:
when a block packing operation is performed, the loaded consensus contract is obtained.
4. The method of claim 3, wherein before the obtaining the consensus contract when performing the block packing operation, further comprising:
analyzing the new consensus contract which is subjected to consensus, and judging whether the new consensus contract has grammar errors or not;
and if the new consensus contract has no grammar error, loading the new consensus contract.
5. The method of claim 4, wherein the parsing the new consensus contract after the consensus is performed, and before determining whether the new consensus contract has a grammar error, further comprising:
acquiring a new consensus contract;
and carrying out consensus processing on the new consensus contract according to a consensus algorithm.
6. A block-based contract processing apparatus, comprising:
an actuator module for:
when a block packing operation is executed, a consensus contract is obtained, wherein the consensus contract is used for completing the function of calculating the total number of all transactions ending to the current block, and the consensus contract refers to an intelligent contract passing through a consensus block layer;
judging whether the current block meets the execution condition of the consensus contract or not;
if the current block meets the execution conditions of the consensus contract, executing the consensus contract to obtain an execution result;
adding the execution result of the consensus contract to a block header of the current block;
in a block structure of a blockchain, a blockhead includes contract execution result information, the contract execution result information at least including: contract identification information and execution results;
the actuator module is further configured to:
writing the execution result into contract execution result information of the block head of the current block.
7. The apparatus of claim 6, wherein the contract execution result information in a block header of the block structure includes execution results of zero, one, or multiple consensus contracts.
8. The apparatus of claim 6 or 7, wherein the actuator module is further configured to:
when a block packing operation is performed, the loaded consensus contract is obtained.
9. The apparatus of claim 8, wherein the apparatus further comprises: a loader module and a parser module,
the parser module is configured to: analyzing the new consensus contract which is subjected to consensus, and judging whether the new consensus contract has grammar errors or not;
the loader module is used for: and if the new consensus contract has no grammar error, loading the new consensus contract.
10. The apparatus of claim 9, wherein the apparatus further comprises: the consensus module is used for:
acquiring a new consensus contract;
and carrying out consensus processing on the new consensus contract according to a consensus algorithm.
11. A blockchain node, comprising:
a memory, a processor, and a computer program stored on the memory and executable on the processor,
the processor, when running the computer program, implements the method according to any of claims 1-5.
12. A computer-readable storage medium, in which a computer program is stored,
the computer program implementing the method according to any of claims 1-5 when executed by a processor.
CN201910192618.5A 2019-03-14 2019-03-14 Block-based contract processing method and device, block chain node and storage medium Active CN111695991B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910192618.5A CN111695991B (en) 2019-03-14 2019-03-14 Block-based contract processing method and device, block chain node and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910192618.5A CN111695991B (en) 2019-03-14 2019-03-14 Block-based contract processing method and device, block chain node and storage medium

Publications (2)

Publication Number Publication Date
CN111695991A CN111695991A (en) 2020-09-22
CN111695991B true CN111695991B (en) 2024-02-06

Family

ID=72474967

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910192618.5A Active CN111695991B (en) 2019-03-14 2019-03-14 Block-based contract processing method and device, block chain node and storage medium

Country Status (1)

Country Link
CN (1) CN111695991B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108365993A (en) * 2018-03-09 2018-08-03 深圳前海微众银行股份有限公司 Block chain link point dynamic altering method, system and computer readable storage medium
CN108595535A (en) * 2018-03-30 2018-09-28 李欣宇 Knowledge Q-A system and method based on the double-chain block chain of same root
CN108960797A (en) * 2018-07-18 2018-12-07 百度在线网络技术(北京)有限公司 Block generates and verification method, device, equipment and storage medium
CN108961052A (en) * 2018-06-25 2018-12-07 百度在线网络技术(北京)有限公司 Verification method, storage method, device, equipment and the medium of block chain data
CN109033814A (en) * 2018-07-18 2018-12-18 百度在线网络技术(北京)有限公司 intelligent contract triggering method, device, equipment and storage medium
WO2018236479A1 (en) * 2017-06-22 2018-12-27 Mastercard International Incorporated Method and system for indexing consumer enrollment using blockchain
CN109117097A (en) * 2018-09-05 2019-01-01 深圳正品创想科技有限公司 A kind of date storage method and system based on block chain
CN109241359A (en) * 2018-08-18 2019-01-18 深圳市网心科技有限公司 Block chain node device, block catenary system, block data processing system and method
CN109256813A (en) * 2018-11-28 2019-01-22 杨胜杰 A kind of distribution type electric energy stocking system and operation method based on block chain
CN109345388A (en) * 2018-09-20 2019-02-15 百度在线网络技术(北京)有限公司 Block chain intelligence contract verification method, device and storage medium
CN109395392A (en) * 2018-09-29 2019-03-01 杭州复杂美科技有限公司 Predict guessing game dispositions method and method for gaming, equipment and storage medium

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018236479A1 (en) * 2017-06-22 2018-12-27 Mastercard International Incorporated Method and system for indexing consumer enrollment using blockchain
CN108365993A (en) * 2018-03-09 2018-08-03 深圳前海微众银行股份有限公司 Block chain link point dynamic altering method, system and computer readable storage medium
CN108595535A (en) * 2018-03-30 2018-09-28 李欣宇 Knowledge Q-A system and method based on the double-chain block chain of same root
CN108961052A (en) * 2018-06-25 2018-12-07 百度在线网络技术(北京)有限公司 Verification method, storage method, device, equipment and the medium of block chain data
CN108960797A (en) * 2018-07-18 2018-12-07 百度在线网络技术(北京)有限公司 Block generates and verification method, device, equipment and storage medium
CN109033814A (en) * 2018-07-18 2018-12-18 百度在线网络技术(北京)有限公司 intelligent contract triggering method, device, equipment and storage medium
CN109241359A (en) * 2018-08-18 2019-01-18 深圳市网心科技有限公司 Block chain node device, block catenary system, block data processing system and method
CN109117097A (en) * 2018-09-05 2019-01-01 深圳正品创想科技有限公司 A kind of date storage method and system based on block chain
CN109345388A (en) * 2018-09-20 2019-02-15 百度在线网络技术(北京)有限公司 Block chain intelligence contract verification method, device and storage medium
CN109395392A (en) * 2018-09-29 2019-03-01 杭州复杂美科技有限公司 Predict guessing game dispositions method and method for gaming, equipment and storage medium
CN109256813A (en) * 2018-11-28 2019-01-22 杨胜杰 A kind of distribution type electric energy stocking system and operation method based on block chain

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘敖迪 ; 杜学绘 ; 王娜 ; 李少卓 ; .区块链技术及其在信息安全领域的研究进展.软件学报.2018,(第07期),全文. *

Also Published As

Publication number Publication date
CN111695991A (en) 2020-09-22

Similar Documents

Publication Publication Date Title
US9632916B2 (en) Method and apparatus to semantically connect independent build and test processes
CN110941528B (en) Log buried point setting method, device and system based on fault
KR101995285B1 (en) Method and apparatur for patching security vulnerable executable binaries
CN110968437A (en) Method, device, equipment and medium for parallel execution of single contract based on Java intelligent contract
CN111158741B (en) Method and device for monitoring dependency relationship change of service module on third party class library
CN109032631A (en) Application program service packs acquisition methods, device, computer equipment and storage medium
CN103186463B (en) Determine the method and system of the test specification of software
US20170277466A1 (en) In-memory data analytic system that provides an integrated tracking mechanism for explicit memory resources
CN111679852B (en) Detection method and device for conflict dependency library
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN111767213B (en) Database check point testing method and device, electronic equipment and storage medium
US9064042B2 (en) Instrumenting computer program code by merging template and target code methods
CN111695991B (en) Block-based contract processing method and device, block chain node and storage medium
CN116841906A (en) Intelligent contract detection method and device and electronic equipment
CN114706586A (en) Code compiling method, code running method, code compiling device, code running device, computer equipment and storage medium
CN114816984A (en) JAVA program regression test method and test device
US8321844B2 (en) Providing registration of a communication
KR101737575B1 (en) Method and device for verifying data based on sql sentences generated automatically
CN112860284B (en) SP upgrade package generation method and device for equipment remote upgrade and computer equipment
CN109308256A (en) A kind of java dynamically analyzing of program method, equipment and storage medium
CN116775040B (en) Pile inserting method for realizing code vaccine and application testing method based on code vaccine
CN107632934B (en) Function copying method and device in C-sharp
CN116700840B (en) File execution method, device, electronic equipment and readable storage medium
CN116661758B (en) Method, device, electronic equipment and medium for optimizing log framework configuration
CN111158746B (en) Method and device for acquiring call relationship

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