A block processing method and related equipment

By running block verification contracts on the virtual machine of blockchain nodes, the problem of cumbersome modification and maintenance of block verification functions in the existing technology is solved, and efficient and flexible maintenance of block verification functions is achieved.

CN110599175BActive Publication Date: 2025-04-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN201910903649.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-09-23
Publication Date
2025-04-25
Estimated Expiration
2039-09-23

AI Technical Summary

Technical Problem

In the existing blockchain network, the block verification module is set in the underlying architecture, resulting in cumbersome modification and maintenance of the block verification function, requiring downtime for each node, which is huge and inefficient.

Method used

Set the block verification module to be a smart contract running on the virtual machine, and specifically, by running the block verification contract on the virtual machine of the blockchain node, block size verification and transaction signature verification of the on-chain block are realized.

Benefits of technology

The block verification function of blockchain nodes is realized, and the maintenance and update process of block verification function is simplified, avoiding node downtime, and improving efficiency and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110599175B_ABST
    Figure CN110599175B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a block processing method and related equipment. The embodiment of the present invention adds a block verification contract as a smart contract. When a block to be chained is chained, the block verification contract is run on a virtual machine to implement a block size verification operation and a transaction signature verification operation of the block to be chained. Not only can the block verification function of the blockchain node be implemented, but also when the block verification function is maintained and updated, only the block verification contract code needs to be modified and the code needs to be chained, so that the block verification function can be changed. The method has strong flexibility, and the maintenance and update process of the block verification function is convenient and efficient. The blockchain node does not need to be shut down, thereby ensuring the normal operation of the blockchain network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, specifically to the field of blockchain technology, and in particular to a block processing method, a block processing device, a terminal device and a computer storage medium. Background Art

[0002] Blockchain technology, also known as distributed ledger technology, is an emerging technology in which several computing devices jointly participate in "bookkeeping" and jointly maintain a complete distributed database. Blockchain technology has been widely used in many fields because of its decentralized, open and transparent characteristics, each computing device can participate in database records, and data can be quickly synchronized between computing devices.

[0003] In the prior art, since the program code of the block verification function is written into the underlying architecture code of the blockchain, when the logic of the block verification function of the blockchain is modified, after rewriting the program code of the block verification function, each node in the blockchain needs to stop working to load the new program code, and then restart the node to finally complete the modification, resulting in a cumbersome upgrade and maintenance process for the blockchain and a huge workload; moreover, if a large number of nodes are shut down during the upgrade and maintenance process, it will have a huge impact on the normal operation of the blockchain. Summary of the invention

[0004] The embodiment of the present invention provides a block processing method and related equipment, which can not only realize block verification, but also flexibly change the block verification function, and the maintenance and update process of the block verification function is convenient and efficient.

[0005] On the one hand, an embodiment of the present invention provides a block processing method, which is applied to a blockchain node in a blockchain network, wherein a virtual machine for running a smart contract is deployed on the blockchain node, and the smart contract includes a block verification contract; the block processing method includes:

[0006] Receive a transaction to generate a block to be uploaded to the chain, wherein the transaction includes transaction data and transaction signature;

[0007] Calling the block verification contract through the virtual machine to perform block size verification and transaction signature verification operations on the block to be chained;

[0008] After the block size verification and transaction signature verification are passed, a consensus vote is conducted on the block to be put on the chain;

[0009] When the number of votes in the consensus vote meets the preset conditions, the block to be chained is added to the blockchain.

[0010] On the other hand, an embodiment of the present invention provides a block processing device, on which a virtual machine for running a smart contract is deployed, and the smart contract includes a block verification contract; the block processing device includes:

[0011] A block generation module, used to receive transactions and generate blocks to be uploaded to the blockchain, wherein the transactions include transaction data and transaction signatures;

[0012] The block verification module to be chained is used to call the block verification contract through the virtual machine to perform block size verification and transaction signature verification operations on the block to be chained;

[0013] The voting module is used to conduct consensus voting on the block to be put on the chain after the block size verification and transaction signature verification are passed;

[0014] The first on-chain module is used to add the block to be on-chain to the blockchain when the number of votes in the consensus vote meets a preset condition.

[0015] Wherein, the block processing device further includes:

[0016] A receiving module, used for receiving network broadcast blocks broadcasted by adjacent block processing devices;

[0017] A broadcast block verification module, used to call the block verification contract through the virtual machine to perform a node signature verification operation on the network broadcast block;

[0018] The second on-chain module is used to add the network broadcast block to the blockchain after the node signature verification is passed.

[0019] On the other hand, an embodiment of the present invention provides a terminal device, including: a processor and a memory;

[0020] The processor is connected to a memory, wherein the memory is used to store program codes, and the processor is used to call the program codes to execute the block processing method.

[0021] On the other hand, an embodiment of the present invention provides a computer storage medium, wherein the computer storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the block processing method is executed.

[0022] The embodiment of the present invention adds a block verification contract as a smart contract. When the block to be chained is chained, the block verification contract is run on a virtual machine to implement the block size verification operation and the transaction signature verification operation of the block to be chained. Not only can the block verification function of the blockchain node be realized, but also when the block verification function is maintained and updated, only the block verification contract code needs to be modified and the code needs to be chained, so that the block verification function can be changed. The flexibility is strong, and the maintenance and update process of the block verification function is convenient and efficient. The blockchain node does not need to be shut down, thereby ensuring the normal operation of the blockchain network. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0024] Figure 1 It is a schematic diagram of data uplinking in a block processing method provided by an embodiment of the present invention;

[0025] Figure 2 It is a flowchart of a block processing method provided by an embodiment of the present invention;

[0026] Figure 3 It is a flowchart of a block processing method provided by an embodiment of the present invention;

[0027] Figure 4 is a structural schematic diagram of a block processing device provided by an embodiment of the present invention;

[0028] Figure 5 is a structural schematic diagram of a block processing device provided by an embodiment of the present invention;

[0029] Figure 6 It is a structural diagram of a terminal device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0031] First of all, the blockchain network is a distributed database that maintains a growing list of data records. Each node in the blockchain network stores the list of data records. In the blockchain, a batch of multiple data records is called a block, and each row of data records in a block is called a transaction. Specifically, the structure of a block includes block size, block header, transaction counter, and transaction.

[0032] The block size, as the name implies, refers to the data size of the block; the block header contains all information except transaction-related information, including data referencing the parent block hash value, which is used to connect the block to the previous block in the blockchain; a timestamp that records the approximate time when the block was generated; a Merkle tree root used to efficiently summarize all transactions in the block; a version number used to track software or protocol updates; and a difficulty target and calculator related to the block's proof-of-work algorithm.

[0033] In addition, the transaction counter records the number of transactions included in the block, while the transaction records the information of the transaction in the block. There are narrow transactions and broad transactions in the blockchain. The narrow transaction refers to a value transfer issued by the user to the blockchain. For example, in the blockchain network about virtual assets (such as game coins in the game), the transaction can be a transfer initiated by the user in the blockchain. The broad transaction refers to a business data with business intentions issued by the user to the blockchain through the node device, such as the data information stored for the goods and their holders during the circulation of goods. For example, when deploying a contract in Ethereum, one deployment is a transaction, and the transaction data is the contract code; when voting for a candidate, one vote is another transaction.

[0034] A smart contract program is not just a computer program that can be executed automatically: it is itself a system participant. It responds to the information it receives, it can receive and store value, and it can also send information and value outward. This program is like a trusted person who can temporarily keep assets and always execute operations according to the pre-set rules. Ethereum is blockchain technology plus smart contracts. Ethereum is an implementation of blockchain that can be used to program, decentralize, guarantee and trade anything, such as voting, domain names, financial exchanges, crowdfunding, company management, contracts, etc. Ethereum allows anyone to build and use decentralized applications that run on blockchain technology on the platform. In the Ethereum network, many nodes are connected to each other to form the Ethereum network. The Ethereum blockchain not only stores data and code, but each node also contains a virtual machine (EVM: Ethereum Virtual Machine) to execute contract code. In addition, the Ethereum node software provides two core functions: data storage and contract code execution. In each Ethereum full node, complete blockchain data is stored. Ethereum not only stores transaction data on the chain, but also the compiled smart contract code is stored on the chain.

[0035] In order to solve the technical problems raised in the background technology, in the existing blockchain network, the block verification module is set in the underlying architecture of the blockchain, and the code of the block verification module is set in the underlying architecture code. Each time a block verification is performed, it needs to be executed in the blockchain system; and each time the block verification module needs to be modified or maintained, each blockchain node in the blockchain needs to be modified; when modifying specifically, the blockchain node needs to be shut down, and then the modified block verification module code is loaded into the node, and then the blockchain node is restarted to complete the modification or maintenance, which not only has a huge workload, but also has low efficiency, which is very unfavorable to the normal operation of the blockchain network. Therefore, the embodiment of the present invention provides a new solution, and the overall idea is:

[0036] The block verification module is set as a smart contract running on a virtual machine, namely, a block verification contract. When the block verification function is maintained and updated, only the block verification contract code needs to be modified and the code is uploaded to the chain to change the block verification function. The flexibility is strong, and the maintenance and update process of the block verification function is convenient and efficient. The blockchain node does not need to be shut down to ensure the normal operation of the blockchain network. In addition, by adding a block verification contract as a smart contract, when the chained block is uploaded, the block verification contract is run on the virtual machine to implement the block size operation and transaction signature verification operation of the chained block, so as to realize the block verification function of the blockchain node.

[0037] Specifically, refer to Figure 1 , Figure 1It is a schematic diagram of data on-chain in a block processing method provided by an embodiment of the present invention. When client D submits a new transaction to the blockchain network, it will first be broadcast to all nodes in the blockchain network (such as node A, node B and node C). Each node will collect several unverified transactions into blocks. Each block can contain hundreds or thousands of transactions. The node that completes block size verification, transaction signature verification and consensus voting fastest, such as node A, will put its own block on the chain and propagate the block to other nodes in the blockchain network to achieve chain. Node A broadcasts its own block to node B and node C, and node B and node C put the received block on the chain.

[0038] Based on the above ideas, an embodiment of the present invention provides a block processing method, which is applied to a blockchain node in a blockchain network. A virtual machine for running a smart contract is deployed on the blockchain node, and the smart contract includes a block verification contract. Taking a single blockchain node in the network as an example, the data chaining process is described. Figure 2 , Figure 2 : is a flowchart of a block processing method provided by an embodiment of the present invention, the block processing method comprising:

[0039] Step S101, receiving a transaction to generate a block to be uploaded to the blockchain, wherein the transaction includes transaction data and a transaction signature;

[0040] Specifically, blockchain node A is taken as an example. In an application scenario, a user can submit a transaction to blockchain node A through a client (the transaction can be specific transaction data or business data, etc.). Before submitting transaction data to the blockchain node, the client can first use an asymmetric encryption algorithm to create a key pair; the asymmetric encryption algorithm here may include but is not limited to: Elgamal algorithm (an asymmetric encryption algorithm), Rabin algorithm (an asymmetric encryption algorithm), Diffie-Hellman algorithm (an asymmetric encryption algorithm), ECC algorithm (elliptic curve encryption algorithm). Among them, the key pair includes a public key and a private key; the public key is used to identify the transaction address of the client. It should be noted that the transaction address in the blockchain network is unique, and one transaction address corresponds to one client (i.e., user); that is, the public key can mark the user identity of the user indicated by the client. The private key is used by the client to sign the transaction data. After creating the key pair, the client can upload the public key in the key pair to the blockchain network so that the blockchain network uses the public key in the key pair as the transaction address of the client; and the private key is kept by the client. Before submitting the transaction data, the client uses the private key to sign the transaction data (equivalent to encrypting the transaction data with the secret key) to obtain a digital string (i.e., the transaction signature), and then submits the transaction data and the transaction signature to the blockchain node A. After receiving the transaction data and the transaction signature, the blockchain node A packages several such data into a block to obtain the block to be chained.

[0041] Step S102, calling the block verification contract through the virtual machine to perform block size verification and transaction signature verification operations on the block to be chained;

[0042] Specifically, the virtual machine on blockchain node A is used to call the block verification contract to perform block size verification operations and transaction signature verification operations on the on-chain blocks.

[0043] Step S103: after the block size verification and transaction signature verification are passed, a consensus vote is performed on the block to be put on the chain;

[0044] Specifically, when the block to be chained passes the block size verification and transaction signature verification, blockchain node A initiates a consensus vote on the block to be chained; the block to be chained can be sent to the voting nodes in the blockchain network, and the voting nodes collect the voting results, and the voting nodes return the voting results to blockchain node A.

[0045] Step S104, when the number of votes in the consensus vote meets the preset conditions, the block to be chained is added to the blockchain;

[0046] Specifically, the voting result determines whether the number of votes meets the preset condition. When the number of votes reaches the preset condition, it indicates that the block to be chained has passed the vote, and the block to be chained can be added to the blockchain. The preset condition is not particularly limited.

[0047] Step S105, broadcasting the block to be chained to the remaining blockchain nodes in the blockchain network.

[0048] Specifically, when blockchain node A adds the block to be chained to the blockchain, it needs to broadcast the block to be chained to the rest of the blockchain nodes in the network, that is, the blockchain nodes that are adjacent to and connected to blockchain node A, for example Figure 1 After blockchain node B and blockchain node C receive the block to be chained, they write the block to be chained into their own ledgers, completing the chaining; and continue to broadcast the block to be chained to the blockchain nodes connected to themselves, so that all nodes in the entire blockchain network will chain the block to be chained, ensuring that the ledgers of each node in the network are exactly the same.

[0049] From the above, it can be seen that by setting up a block verification contract, in an embodiment of the present invention, when the blockchain node is uploading data to the chain, the block verification contract can be directly called through the virtual machine to complete the block size verification operation and the transaction signature verification operation of the block to be chained. Not only is the operation simple, but the modification and maintenance of the block verification logic is also very simple. It only needs to modify the code of the block verification contract and then complete the code uploading, that is, the update and maintenance of the block verification function can be completed at one time, which effectively improves efficiency and reduces maintenance workload; it has strong flexibility and can flexibly change the transaction verification logic.

[0050] Furthermore, for the block generated by the blockchain node itself, i.e., the block to be put on the chain, the block size verification operation and the transaction signature verification operation on the block to be put on the chain include:

[0051] Determine whether the block size of the block to be chained exceeds the preset block size. If it is determined that it does not exceed, the block to be chained passes the block size verification and enters the transaction signature verification operation of the block to be chained; otherwise, the block size verification of the block to be chained fails;

[0052] The transaction signature verification operation includes:

[0053] Obtaining the transaction data and corresponding transaction signature of the block to be chained;

[0054] Obtaining the public key of the transaction initiator according to the transaction signature;

[0055] The transaction signature is decrypted using the public key to obtain first decrypted data, and the first decrypted data is compared with the transaction data. If the comparison is the same, the transaction data passes the transaction signature verification; otherwise, the transaction data fails the transaction signature verification.

[0056] Specifically, different blockchain networks have different restrictions on the size of blocks that can be transferred. Therefore, in order to avoid the block size being too large and causing the information transmission of the blockchain network to be blocked, different blockchain networks can preset different preset block sizes. The specific values ​​can be set according to different blockchain networks and different needs. When the block size of the block to be chained exceeds the preset block size, the block size verification fails and the processing flow of the block to be chained stops; and when the block size of the block to be chained is less than the preset block size, it indicates that the block to be chained has passed the block size verification and can enter the transaction signature verification operation of the block to be chained.

[0057] Specifically, in order to ensure that the transaction is initiated by the transaction initiator and has not been tampered with, the transaction signature needs to be verified.

[0058] Since a block includes multiple transactions, the corresponding transaction data and the corresponding transaction signature are stored in the block. The transaction signature verification operation is performed on each transaction in the block. Taking a single transaction as an example, it can be seen from the above description that the transaction signature is a digital string obtained by encrypting the transaction data with a private key. After obtaining the transaction, since the public key is usually added to the transaction data, the public key of the transaction initiator (that is, the client) can be directly obtained from the transaction data, and then the transaction signature can be verified using the public key, that is, the transaction signature is decrypted using the public key to obtain the decrypted data, and then the decrypted data is compared with the transaction data. If the comparison is the same, it means that the transaction data was sent by the transaction initiator himself and the transaction data has not been tampered with. In addition, the ECDSA algorithm used by Ethereum has a very interesting feature: the public key can be derived from the signature. The transaction format of Ethereum only contains the signature. Before verifying the transaction signature, the public key is first derived from the transaction signature using the algorithm, and then the signature is verified.

[0059] In addition, before performing the block size verification operation on the on-chain block, the transaction quantity verification operation may also be performed on the on-chain block, and the transaction quantity verification operation includes:

[0060] Get the total transaction volume of the block to be chained;

[0061] Determine whether the total transaction volume of the block to be chained exceeds the preset total transaction volume. If it is judged to be exceeded, the verification fails and the processing of the block to be chained is stopped. If the verification passes, the block size verification of the block to be chained is entered.

[0062] Specifically, the transaction counter in the block to be chained is used to obtain the number of transactions in the block (i.e., the total number of transactions), and the transaction number is compared with the preset total number of transactions. When the transaction number is less than the preset total number of transactions, the block to be chained passes the transaction number verification and can enter the block size verification of the block to be chained; otherwise, the verification fails, and the excessive number of transactions indicates that the block size may exceed the block size that can be transmitted by the blockchain network, and the processing of the block to be chained is stopped at this time.

[0063] In particular, in order to improve the accuracy of block size verification, a multi-level transaction total amount comparison threshold can be set, for example, a first preset transaction total amount and a second preset transaction total amount are set, the first preset transaction total amount is smaller than the second preset transaction total amount, when the number of transactions of the block to be chained is greater than the first preset transaction total amount, but the number of transactions is less than the second preset transaction total amount, the block size verification operation of the block to be chained is entered, and when the block to be chained passes the block size verification operation, the block to be chained can enter the transaction signature verification; and when the number of transactions is greater than the second preset transaction total amount, the processing of the block to be chained is stopped.

[0064] Furthermore, the preset conditions include that the number of votes in the consensus vote is greater than or equal to a preset threshold, such as 3 / 4 of the total votes, to ensure that the block to be chained is supported by the majority of nodes in the blockchain network, thereby improving the credibility of the block to be chained.

[0065] In addition, for the blocks to be put on the chain, after passing the block size verification and transaction signature verification, before the consensus vote on the blocks to be put on the chain, blockchain node A can also execute business logic through the virtual machine to complete specific functions, including ledger verification, game rewards and penalties, etc. The ledger verification is to compare the transactions of the blocks to be put on the chain with the existing transactions on the ledger of blockchain node A to determine whether the transaction is a duplicate transaction. When the transaction is repeated, blockchain node A returns an error message to the client, reminding the client that the transaction is repeated and needs to be modified. If it is determined that all transactions of the blocks to be put on the chain are not repeated with existing transactions, the consensus vote on the blocks to be put on the chain is entered.

[0066] refer to Figure 3 , Figure 3 is a flow chart of a block processing method provided by an embodiment of the present invention, wherein the block processing method further includes:

[0067] Step 201, receiving the network broadcast block broadcasted by the adjacent blockchain node;

[0068] Specifically, taking blockchain node A as an example, blockchain node A receives the network broadcast block broadcasted by the adjacent blockchain node through the network. The network broadcast block is a block that has passed block size verification, transaction signature verification, and consensus voting by other blockchain nodes.

[0069] Step 202, calling the block verification contract through the virtual machine to perform a node signature verification operation on the network broadcast block;

[0070] Specifically, similar to the verification process of the block to be chained, blockchain node A calls the blockchain verification contract through the virtual machine to perform node signature verification on the received network broadcast block.

[0071] Step 203: After the node signature is verified, the network broadcast block is added to the blockchain.

[0072] Specifically, similar to the block to be chained, when the block verification is passed, blockchain node A adds the network broadcast block to the blockchain to complete the chaining.

[0073] Furthermore, the node signature verification operation includes:

[0074] Obtaining the broadcast public key corresponding to the adjacent blockchain node;

[0075] The node signature of the network broadcast block is decrypted using the broadcast public key to obtain second decrypted data, and the second decrypted data is compared with the network broadcast block for information. If the comparison is the same, the network broadcast block passes the node signature verification, otherwise, the network broadcast block fails the node signature verification.

[0076] Specifically, in a blockchain network, the broadcast public key of each blockchain node will be transmitted to each node through broadcast after the blockchain network is turned on. Since each node has an IP address, the broadcast public key and IP address can be used to identify each node in the network. That is, blockchain node A knows the broadcast public key of each node in the network, and can establish a public key correspondence table of the broadcast public key and the IP address to facilitate subsequent search for the public key. Before broadcasting a block to the network, each node will first sign the block with its own broadcast private key, that is, it can obtain the node signature, and broadcast the node signature and the network broadcast block. Blockchain node A receives the adjacent connected blockchain nodes (such as Figure 1 After the network broadcast block is broadcast by the blockchain node B in the blockchain, the corresponding broadcast public key of blockchain node B is found according to the IP address and public key correspondence table of blockchain node B, and then the node signature is verified using the broadcast public key. The verification process is the same as the verification of the transaction signature and will not be repeated here. If the verification passes, it indicates that the network broadcast block was sent by blockchain node B itself and has not been tampered with, ensuring that the ledger data of each node remains consistent.

[0077] In addition, for the network broadcast block, although it is broadcast after the block size verification and transaction signature verification of the node that broadcasts it, in order to avoid the error of a single blockchain node causing the erroneous network broadcast block to be completed on the chain in all nodes, and to further ensure the data credibility of the block on the chain, for the network broadcast block that has passed the node signature verification, the transaction quantity verification operation, block size verification operation and transaction signature verification operation can continue to be performed on it. The verification process is the same as the above-mentioned block to be chained. The transaction quantity, block size and transaction signature in the network broadcast block are verified, which will not be repeated. For the verification of transaction signatures and transaction quantities, the verification can be completed by traversing each transaction in the block.

[0078] Furthermore, the block processing method of the embodiment of the present invention also includes a method for deploying a block verification contract, and the deployment method includes:

[0079] Convert block verification logic into block verification contract code;

[0080] Compile the block verification contract code into binary code;

[0081] The binary code is packaged into a transaction and sent to the blockchain network. The transaction is added to the blockchain to complete the deployment of the block verification contract.

[0082] Specifically, the verification logic for on-chain blocks and network broadcast blocks is converted into block verification contract code, wherein the block verification logic includes the verification logic for on-chain blocks and network broadcast blocks, and the block verification contract code can be written in Solidity language, or can also be written in Serpent language, LLL language, etc.; then the block verification contract code is signed using the broadcast private key of the blockchain node, and the signed block verification contract code is compiled into binary code and packaged into a transaction. Taking Solidity language as an example, the block verification contract code is compiled into binary code using the SOLC compiler, and finally, the transaction is sent to the blockchain network so that the transaction is added to the blockchain, that is, recorded in the ledger of each blockchain node, thus completing the deployment of the block verification contract. Similarly, when the virtual machine calls the block verification contract, it also calls the block verification contract by creating a new transaction.

[0083] Based on the description of the above block processing method embodiment, the embodiment of the present invention further discloses a block processing device, on which a virtual machine for running a smart contract is deployed, and the smart contract includes a block verification contract; Figure 4 , Figure 41 is a schematic diagram of the structure of a block processing device provided by an embodiment of the present invention, wherein the block processing device comprises a block generation module 11, a to-be-chained block verification module 12, a voting module 13, a first chaining module 14 and a broadcasting module 15, wherein:

[0084] The block generation module 11 is used to receive transactions and generate blocks to be put on the chain, wherein the transactions include transaction data and transaction signatures;

[0085] The block verification module 12 to be chained is used to call the block verification contract through the virtual machine to perform block size verification and transaction signature verification operations on the block to be chained;

[0086] The voting module 13 is used to perform consensus voting on the block to be put on the chain after the block size verification and transaction signature verification are passed;

[0087] The first on-chain module 14 is used to add the block to be on-chain to the blockchain when the number of votes in the consensus vote meets a preset condition;

[0088] The broadcast module 15 is used to broadcast the block to be chained to other block processing devices in the blockchain network.

[0089] For the specific functional implementation of the block generation module 11, the block verification module 12, the voting module 13, the first chain module 14 and the broadcasting module 15, please refer to the description of step S101 to step S105, which will not be repeated here.

[0090] The block processing device of the embodiment of the present invention adds a block verification contract as a smart contract. When the block to be chained is chained, the block verification contract is run on the virtual machine to implement the block size verification operation and the transaction signature verification operation of the block to be chained. Not only can the block verification function of the block processing device be realized, but also when the block verification function is maintained and updated, only the block verification contract code needs to be modified and the code needs to be chained, so that the block verification function can be changed. It has strong flexibility, and the maintenance and update process of the block verification function is convenient and efficient. The block processing device does not need to be shut down, thereby ensuring the normal operation of the blockchain network.

[0091] Furthermore, the to-be-chained block verification module 12 is used to:

[0092] Determine whether the block size of the block to be chained exceeds the preset block size. If it is determined that it does not exceed the preset block size, the block to be chained passes the block size verification and enters the transaction signature verification operation of the block to be chained; otherwise, the block size verification of the block to be chained fails; the transaction signature verification operation includes: obtaining the transaction data and the corresponding transaction signature of the block to be chained; obtaining the public key of the transaction initiator according to the transaction signature; decrypting the transaction signature using the public key to obtain the first decrypted data, and comparing the first decrypted data with the transaction data. If the comparison is the same, the transaction data passes the transaction signature verification, otherwise, the transaction data fails the transaction signature verification.

[0093] Furthermore, the preset condition includes that the number of votes in the consensus vote is greater than or equal to a preset threshold.

[0094] Further, refer to Figure 5 , Figure 5 is a structural diagram of a block processing device provided by an embodiment of the present invention, wherein the block processing device further includes a receiving module 21, a broadcast block verification module 22, and a second uplink module 23, wherein:

[0095] The receiving module 21 is used to receive the network broadcast block broadcasted by the adjacent block processing device;

[0096] The broadcast block verification module 22 is used to call the block verification contract through the virtual machine to perform a node signature verification operation on the network broadcast block;

[0097] The second on-chain module 23 is used to add the network broadcast block to the blockchain after the node signature verification is passed.

[0098] Similarly, the specific functional implementation description of the receiving module 21, the broadcast block verification module 22 and the second uplink module 23 can refer to the description of step S201 to step S203, which will not be repeated here.

[0099] Furthermore, the broadcast block verification module 22 is specifically used for:

[0100] Obtaining a broadcast public key corresponding to the adjacent block processing device;

[0101] The node signature of the network broadcast block is decrypted using the broadcast public key to obtain second decrypted data, and the second decrypted data is compared with the network broadcast block for information. If the comparison is the same, the network broadcast block passes the node signature verification, otherwise, the network broadcast block fails the node signature verification.

[0102] Furthermore, the block processing device of the embodiment of the present invention further includes a block verification contract deployment module, which is used to:

[0103] Convert block verification logic into block verification contract code;

[0104] Compile the block verification contract code into binary code;

[0105] The binary code is packaged into a transaction and sent to the blockchain network. The transaction is added to the blockchain to complete the deployment of the block verification contract.

[0106] For further information, see Figure 6 , is a schematic diagram of the structure of a terminal device provided by an embodiment of the present invention. Figure 6 As shown above Figure 4 and Figure 5 The blockchain node in can be applied to the terminal device 1000, and the terminal device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the terminal device 1000 may also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As Figure 6 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.

[0107] exist Figure 6 In the terminal device 1000 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:

[0108] Receive a transaction to generate a block to be uploaded to the chain, wherein the transaction includes transaction data and transaction signature;

[0109] Calling the block verification contract through the virtual machine to perform block size verification and transaction signature verification operations on the block to be chained;

[0110] After the block size verification and transaction signature verification are passed, a consensus vote is conducted on the block to be put on the chain;

[0111] When the number of votes in the consensus vote meets the preset conditions, the block to be chained is added to the blockchain.

[0112] In one embodiment, the preset condition includes that the number of votes in the consensus vote is greater than 3 / 4 of the total votes. The block size verification operation and transaction signature verification operation of the block to be chained include:

[0113] Determine whether the block size of the block to be chained exceeds the preset block size. If it is determined that it does not exceed, the block to be chained passes the block size verification and enters the transaction signature verification operation of the block to be chained; otherwise, the block size verification of the block to be chained fails;

[0114] The transaction signature verification operation includes:

[0115] Obtaining the transaction data and corresponding transaction signature of the block to be chained;

[0116] Obtaining the public key of the transaction initiator according to the transaction signature;

[0117] Decrypting the transaction signature using the public key to obtain first decrypted data, and comparing the first decrypted data with the transaction data; if the comparison is the same, the transaction data passes the transaction signature verification; otherwise, the transaction data fails the transaction signature verification;

[0118] In one embodiment, the processor 1001 further performs a transaction quantity verification operation on the block to be chained before performing the block size verification operation on the block to be chained, and the transaction quantity verification operation includes:

[0119] Get the total transaction volume of the block to be chained;

[0120] Determine whether the total transaction volume of the block to be chained exceeds the preset total transaction volume. If it is judged to be exceeded, the verification fails and the processing of the block to be chained is stopped. If the verification passes, the block size verification of the block to be chained is entered.

[0121] In one embodiment, the processor 1001 further performs the following steps:

[0122] Receive network broadcast blocks broadcasted by adjacent blockchain nodes;

[0123] Calling the block verification contract through the virtual machine to perform a node signature verification operation on the network broadcast block;

[0124] After the node signature is verified, the network broadcast block is added to the blockchain.

[0125] The node signature verification operation includes:

[0126] Obtaining the broadcast public key corresponding to the adjacent blockchain node;

[0127] The node signature of the network broadcast block is decrypted using the broadcast public key to obtain second decrypted data, and the second decrypted data is compared with the network broadcast block for information. If the comparison is the same, the network broadcast block passes the node signature verification, otherwise, the network broadcast block fails the node signature verification.

[0128] The specific working process of the terminal device 1000 can refer to the description of the above-mentioned blockchain node and will not be repeated here.

[0129] In addition, it should be pointed out here that: an embodiment of the present invention further provides a computer storage medium, and the computer storage medium stores a computer program executed by the blockchain node mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the above-mentioned Figures 1 to 3 The description of the block processing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer storage medium embodiment involved in the present invention, please refer to the description of the method embodiment of the present invention.

[0130] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0131] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. A block processing method, characterized in that: A blockchain node applied to a blockchain network, wherein a virtual machine for running a smart contract is deployed on the blockchain node, wherein the smart contract includes a block verification contract; and the block processing method includes: Receive a transaction to generate a block to be uploaded to the chain, wherein the transaction includes transaction data and transaction signature; Calling the block verification contract through the virtual machine to perform block size verification and transaction signature verification operations on the block to be chained; After the block size verification and transaction signature verification are passed, a consensus vote is conducted on the block to be put on the chain; When the number of votes in the consensus vote meets the preset conditions, the block to be chained is added to the blockchain, and the block to be chained is written into its own account book, and the chaining is completed; The deployment of the block verification contract includes: converting the block verification logic into a block verification contract code; signing the block verification contract code using the broadcast private key of the blockchain node, compiling the signed block verification contract code into binary code and packaging it into a transaction; sending the transaction to the blockchain network, and the transaction is added to the ledger of each blockchain node, and the deployment of the block verification contract is completed. The block verification logic includes the verification logic for the on-chain blocks and the network broadcast blocks; After the blockchain node adds the block to be chained to the blockchain, the block to be chained is broadcasted to the other blockchain nodes in the blockchain network; Receive network broadcast blocks broadcasted by adjacent blockchain nodes. Network broadcast blocks are blocks that have passed block size verification, transaction signature verification, and consensus voting by other blockchain nodes; The block verification contract is called by the virtual machine to perform a node signature verification operation on the network broadcast block. After the node signature verification passes, the network broadcast block is added to the blockchain.

2. The method according to claim 1, characterized in that The block size verification operation and transaction signature verification operation of the block to be chained include: Determine whether the block size of the block to be chained exceeds the preset block size. If it is determined that it does not exceed, the block to be chained passes the block size verification and enters the transaction signature verification operation of the block to be chained; otherwise, the block size verification of the block to be chained fails; The transaction signature verification operation includes: Obtaining the transaction data and corresponding transaction signature of the block to be chained; Obtaining the public key of the transaction initiator according to the transaction signature; The transaction signature is decrypted using the public key to obtain first decrypted data, and the first decrypted data is compared with the transaction data. If the comparison is the same, the transaction data passes the transaction signature verification; otherwise, the transaction data fails the transaction signature verification.

3. The method according to claim 1, characterized in that The node signature verification operation includes: Obtaining the broadcast public key corresponding to the adjacent blockchain node; The node signature of the network broadcast block is decrypted using the broadcast public key to obtain second decrypted data, and the second decrypted data is compared with the network broadcast block for information. If the comparison is the same, the network broadcast block passes the node signature verification, otherwise, the network broadcast block fails the node signature verification.

4. The method according to any one of claims 1 to 3, characterized in that: The preset condition includes that the number of votes in the consensus vote is greater than a preset threshold.

5. A block processing device, characterized in that: A virtual machine for running a smart contract is deployed on the block processing device, and the smart contract includes a block verification contract; the block processing device includes: A block generation module, used to receive transactions and generate blocks to be uploaded to the blockchain, wherein the transactions include transaction data and transaction signatures; The block verification module to be chained is used to call the block verification contract through the virtual machine to perform block size verification and transaction signature verification operations on the block to be chained; The voting module is used to conduct consensus voting on the block to be put on the chain after the block size verification and transaction signature verification are passed; The first on-chain module is used to add the block to be on-chain to the blockchain and write the block to its own account book when the number of votes in the consensus vote meets the preset conditions, thus completing the on-chain process; The block verification contract deployment module is used to convert the block verification logic into the block verification contract code; use the broadcast private key of the blockchain node to sign the block verification contract code, compile the signed block verification contract code into binary code and package it into a transaction; send the transaction to the blockchain network, and the transaction is added to the ledger of each blockchain node, then the deployment of the block verification contract is completed. The block verification logic includes the verification logic for the on-chain blocks and the network broadcast blocks; A broadcast module, configured to broadcast the block to be chained to the remaining blockchain nodes in the blockchain network after the blockchain node adds the block to be chained to the blockchain; The receiving module is used to receive the network broadcast blocks broadcasted by the adjacent blockchain nodes. The network broadcast blocks are blocks that have passed the block size verification, transaction signature verification, and consensus voting of other blockchain nodes; A broadcast block verification module, used to call the block verification contract through the virtual machine to perform a node signature verification operation on the network broadcast block; The second on-chain module is used to add the network broadcast block to the blockchain after the node signature verification is passed.

6. A terminal device, characterized in that: include: Processor and memory; The processor is connected to a memory, wherein the memory is used to store program codes, and the processor is used to call the program codes to execute the method according to any one of claims 1 to 4.

7. A computer storage medium, characterized in that: The computer storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 4 is executed.

Citation Information

Patent Citations

  • Verification method for information in block chain network and verification system thereof

    CN106385319A

  • Consensus checking method and checking device

    CN107196900A

  • Blockchain intelligent contract implementation method and device, computer equipment and storage medium

    CN110111104A