Block processing method and device, computer equipment, storage medium and program product
By obtaining and utilizing transaction dependencies and estimated resource consumption information in blockchain technology, the transactions in the block are sorted, and the problem of low block verification efficiency is solved, and a more efficient transaction verification process is achieved.
Patent Information
- Application Number
- CN202310662460.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-05
- Publication Date
- 2024-12-06
AI Technical Summary
In blockchain technology, the verification efficiency of blocks is lower than that of existing technologies, mainly because the transaction dependencies cannot be properly sorted, resulting in serious transaction dependencies during verification, which affects efficiency.
By receiving the block to be verified sent by the proposal node, the block verification instructions of the block are obtained, including transaction dependencies and estimated resource consumption information of each transaction, and sort multiple transactions based on this information to determine reasonable verification sequentially and verify in order.
Improve the verification efficiency of blocks, ensure reasonable sorting under transaction dependencies, and reduce resource waste and time delay during the verification process.
Smart Images

Figure CN119090630A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, in particular to the field of blockchain technology, and specifically to a block processing method, a block processing device, a computer device, a computer-readable storage medium, and a computer program product. Background Art
[0002] In blockchain technology, block verification is required before a block is uploaded to the blockchain. Block verification refers to the verification of transactions in the block. Transactions in a block have transaction dependencies. During the block verification process, if transactions cannot be verified in a reasonable verification order, it will lead to serious transaction dependencies during verification. For example, transaction A depends on transaction B. If transaction B is not verified, then even if there are idle transaction verification resources, transaction A cannot be verified, which will seriously affect the verification efficiency of the block. Summary of the invention
[0003] The embodiments of the present application provide a block processing method, apparatus, computer equipment, storage medium, and program product, which can improve the verification efficiency of blocks.
[0004] On the one hand, an embodiment of the present application provides a block processing method, the block processing method comprising:
[0005] Receive blocks to be verified sent by the proposal node; blocks include multiple transactions to be verified;
[0006] Obtain block verification indication information of a block; the block verification indication information includes transaction dependencies between multiple transactions and transaction verification indication information of each transaction under the transaction dependencies; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction;
[0007] Sorting multiple transactions according to the transaction dependency and transaction verification indication information of each transaction to obtain a verification order of the multiple transactions;
[0008] During the block verification process, multiple transactions are verified in the verification order to obtain the verification result of the block, and the verification result is fed back to the proposal node.
[0009] Accordingly, an embodiment of the present application provides a block processing device, the block processing device comprising:
[0010] A communication unit, used to receive a block to be verified sent by a proposal node; a block includes multiple transactions to be verified;
[0011] A processing unit, configured to obtain block verification indication information of a block; the block verification indication information includes transaction dependencies between multiple transactions and transaction verification indication information of each transaction under the transaction dependencies; the transaction verification indication information of any transaction is used to indicate estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction;
[0012] The processing unit is further used to sort the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction to obtain the verification order of the multiple transactions;
[0013] The processing unit is also used to verify multiple transactions in the verification order during the block verification process, obtain the verification result of the block, and feed back the verification result to the proposal node.
[0014] In one implementation, the processing unit is used to sort multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction, and when obtaining the verification order of the multiple transactions, specifically to perform the following steps:
[0015] According to the transaction dependency, a first transaction belonging to a first order priority is determined among the multiple transactions; the first transaction is a transaction that has no dependent transaction among the multiple transactions;
[0016] Determining, according to a numerical relationship between the transaction verification indication information of each first transaction, a verification order of each first transaction under a first sequence priority;
[0017] According to the transaction dependency, determining a second transaction belonging to a second order priority among the multiple transactions; the second transaction is a transaction that depends on the first transaction among the multiple transactions;
[0018] Determining the verification order of each second transaction under the second sequence priority according to the numerical relationship between the transaction verification indication information of each second transaction;
[0019] Continue to determine the subsequent transactions belonging to the subsequent sequence priority, and determine the verification order of each subsequent transaction under the subsequent sequence priority; wherein the verification order of the first sequence priority is earlier than the second sequence priority.
[0020] In one implementation, the block verification indication information is read from a block verification graph; the block verification graph includes nodes and directed edges, the nodes in the block verification graph represent transactions in the block, the node values of the nodes in the block verification graph represent transaction verification indication information of the transactions in the block, and the directed edges in the block verification graph represent transaction dependencies between transactions in the block;
[0021] The directed edge connected to the target node in the block verification graph includes at least one of the following: an incoming edge and an outgoing edge; the existence of an incoming edge in the target node indicates that the target node depends on other nodes, and other nodes are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge in the target node indicates that the target node is dependent on the reference node, and the reference node is connected to the target node through the outgoing edge of the target node; the target node is any node in the block verification graph;
[0022] The first transaction is the transaction represented by the first node in the block verification graph, and the first node has an outgoing edge but no incoming edge; the second transaction is the transaction represented by the second node in the block verification graph, and the second node is connected to the outgoing edge of the first node.
[0023] In one implementation, the processing unit is used to obtain the block verification indication information of the block, and is specifically used to perform the following steps:
[0024] Receive block verification instruction information sent by the proposal node; or, receive block execution instruction information sent by the proposal node, and generate block verification instruction information according to the block execution instruction information;
[0025] The block execution indication information includes transaction dependencies and transaction execution indication information of each transaction; the transaction execution indication information of any transaction is used to indicate the separate resource consumption information for executing the corresponding transaction.
[0026] In one implementation, the processing unit is used to generate the block verification indication information according to the block execution indication information, and is specifically used to perform the following steps:
[0027] Creating a block execution graph according to the block execution instruction information;
[0028] Convert the block execution graph into a block verification graph;
[0029] Read block verification instructions from the block verification graph.
[0030] In one implementation, the processing unit is used to create a block execution graph according to the block execution instruction information, and is specifically used to perform the following steps:
[0031] Identify transactions in a block as nodes in a block execution graph;
[0032] Determine the transaction execution indication information of the transaction in the block as the node value of the node in the block execution graph;
[0033] Determine the transaction dependencies between transactions in a block as directed edges between corresponding nodes in the block execution graph;
[0034] Among them, the directed edge connected to the target node in the block execution graph includes at least one of the following: an incoming edge and an outgoing edge; the existence of an incoming edge of the target node indicates that the target node depends on other nodes, and the other nodes are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge of the target node indicates that the target node is dependent on the reference node, and the reference node is connected to the target node through the outgoing edge of the target node; the target node is any node in the block execution graph.
[0035] In one implementation, the processing unit is used to convert the block execution graph into the block verification graph, and is specifically used to perform the following steps:
[0036] Determine the starting node in the block execution graph; the starting node is a node in the block execution graph that has an incoming edge but no outgoing edge;
[0037] Determine a transition node connected to the start node through an incoming edge of the start node;
[0038] Using the node sum value between the start node and the transition node, update the node value of the transition node;
[0039] The conversion node is determined as the new starting node, and new conversion nodes are continuously determined, and the node values of the new conversion nodes are updated until all nodes in the block execution graph are traversed to obtain the block verification graph.
[0040] In one implementation, there are multiple starting nodes connected to the conversion node; the processing unit is used to use the node sum value between the starting node and the conversion node to update the node value of the conversion node, specifically for performing the following steps:
[0041] Determine the nodes and values between the transition node and each starting node respectively;
[0042] The node value of the transition node is updated by taking the maximum sum value among the node sum values between the transition node and each start node.
[0043] In one implementation, the block also includes a first transaction execution result of each of the multiple transactions; the processing unit is used to verify the multiple transactions in the verification order during the verification process of the block, and when the verification result of the block is obtained, specifically to perform the following steps:
[0044] Execute multiple transactions in a verification order to obtain a second transaction execution result of each transaction in the multiple transactions;
[0045] If the first transaction execution result and the second transaction execution result of each transaction in the multiple transactions are the same, a verification result indicating that the block verification has passed is generated.
[0046] On the other hand, an embodiment of the present application provides a block processing method, the block processing method comprising:
[0047] Get multiple transactions from the transaction pool;
[0048] Packing multiple transactions into a block to be verified, sending the block to a verification node, allowing the verification node to sort the multiple transactions based on the block verification indication information of the block to obtain the verification order of the multiple transactions, and in the verification process of the block, verifying the multiple transactions according to the verification order to obtain the verification result of the block;
[0049] Receive verification results from verification nodes;
[0050] Among them, the block verification indication information includes the transaction dependency relationship between multiple transactions, and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction.
[0051] Accordingly, an embodiment of the present application provides a block processing device, the block processing device comprising:
[0052] A processing unit, used to obtain multiple transactions from the transaction pool;
[0053] The processing unit is further used to package the multiple transactions into a block to be verified, send the block to the verification node, and enable the verification node to sort the multiple transactions based on the block verification indication information of the block to obtain the verification order of the multiple transactions, and verify the multiple transactions according to the verification order during the verification process of the block to obtain the verification result of the block;
[0054] A communication unit, used to receive the verification result fed back by the verification node;
[0055] Among them, the block verification indication information includes the transaction dependency relationship between multiple transactions, and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction.
[0056] In one implementation, the processing unit is further configured to perform the following steps:
[0057] Obtaining block execution instruction information of the block, generating block verification instruction information according to the block execution instruction information, and sending the block verification instruction information to the verification node; or obtaining block execution instruction information of the block, and sending the block execution instruction information to the verification node, so that the verification node generates block verification instruction information according to the block execution instruction information;
[0058] The block execution indication information includes transaction dependencies and transaction execution indication information of each transaction; the transaction execution indication information of any transaction is used to indicate the separate resource consumption information for executing the corresponding transaction.
[0059] In one implementation, the processing unit is used to package multiple transactions into a block to be verified, and is specifically used to perform the following steps:
[0060] Create M transaction execution resources, where M is an integer greater than or equal to 2;
[0061] Use M transaction execution resources to execute multiple transactions concurrently;
[0062] Package multiple transactions and the transaction execution results of multiple transactions into blocks.
[0063] In one implementation, multiple transactions need to call N smart contracts for execution, where N is a positive integer; the processing unit is used to use M transaction execution resources to concurrently execute multiple transactions, and is specifically used to perform the following steps:
[0064] When N is greater than or equal to M, each of the M transaction execution resources is used to execute a transaction under a smart contract;
[0065] When N is less than M, at least two of the M transaction execution resources are used to execute transactions under the same smart contract.
[0066] In one implementation, any one of the M transaction execution resources is a target transaction execution resource, the target transaction execution resource is used to execute a transaction under a target smart contract, the target smart contract includes a plurality of contract methods, and the transaction under the target smart contract is executed by calling at least one contract method among the plurality of contract methods;
[0067] The process of using the target transaction execution resource to execute the transaction under the target smart contract includes:
[0068] Get the resource consumption experience information of each contract method in the target smart contract;
[0069] Determine the execution resource consumption information required to execute the transaction under the target smart contract based on the resource consumption experience information of the contract method called by the transaction under the target smart contract;
[0070] According to the execution resource consumption information required to execute the transactions under the target smart contract, the transactions under the target smart contract are sorted to obtain the transaction execution order of the transactions under the target smart contract;
[0071] The target transaction execution resource is used to call the target smart contract, and the transactions under the target smart contract are executed in the transaction execution order.
[0072] In one implementation, transactions under a reference smart contract among N smart contracts need to be executed using P transaction execution resources among M transaction execution resources, where P is an integer greater than or equal to 2 and less than or equal to M; the reference smart contract includes multiple contract methods, and the P transaction execution resources are respectively used to call different contract methods in the reference smart contract; transactions under the reference smart contract are executed by calling at least one contract method among the multiple contract methods;
[0073] The process of using P transaction execution resources to execute transactions under the reference smart contract includes:
[0074] Get the resource consumption experience information of each contract method in the reference smart contract;
[0075] Determine the total resource consumption experience information of each contract method in the reference smart contract based on the resource consumption experience information of each contract method in the reference smart contract and the number of transactions under the corresponding contract method;
[0076] Based on the total resource consumption experience of each contract method in the reference smart contract, multiple contract methods are allocated to P transaction execution resources;
[0077] Use P transaction execution resources to call the allocated contract method and execute transactions under the allocated contract method.
[0078] Accordingly, an embodiment of the present application provides a computer device, the computer device comprising:
[0079] a processor suitable for implementing a computer program;
[0080] A computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the above-mentioned block processing method.
[0081] Accordingly, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is read and executed by a processor of a computer device, the computer device executes the above-mentioned block processing method.
[0082] Accordingly, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned block processing method.
[0083] In an embodiment of the present application, multiple transactions can be sorted according to the transaction dependency relationship between multiple transactions included in the block to be verified, and the transaction verification indication information of each transaction under the transaction dependency relationship, to obtain the verification order of the multiple transactions. Then, in the verification process of the block, the multiple transactions can be verified according to the verification order, and the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the beginning of verification of the transaction to the end of verification of all transactions in the dependency chain of the transaction. It can be seen that when sorting multiple transactions in the block, the estimated resource consumption information of each transaction under the transaction dependency relationship is taken into account, so that the verification order obtained by sorting is reasonable, so that in the verification process of the block, multiple transactions are verified according to a reasonable verification order, which can improve the verification efficiency of the block. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0085] Figure 1 This is a schematic diagram of the architecture of a blockchain network provided in an embodiment of the present application;
[0086] Figure 2 This is a schematic diagram of the structure of a blockchain provided by an embodiment of the present application;
[0087] Figure 3 It is a structural schematic diagram of a block generation process provided by an embodiment of the present application;
[0088] Figure 4 It is a schematic diagram of the architecture of a block processing system provided by an embodiment of the present application;
[0089] Figure 5 It is a flowchart of a block processing method provided in an embodiment of the present application;
[0090] Figure 6a It is a schematic diagram of a block execution graph provided by the real-time example of this application;
[0091] Figure 6b is a schematic diagram of another block execution graph provided in an embodiment of the present application;
[0092] Figure 7 It is a schematic diagram of a conversion process of a block execution graph provided in an embodiment of the present application;
[0093] Figure 8It is a schematic diagram of another conversion process of a block execution graph provided in an embodiment of the present application;
[0094] Figure 9a is a schematic diagram of a block verification diagram provided in an embodiment of the present application;
[0095] Figure 9b is a schematic diagram of another block verification diagram provided in an embodiment of the present application;
[0096] Fig.10 It is a flowchart of another block processing method provided in an embodiment of the present application;
[0097] Fig.11 It is a flowchart of another block processing method provided in an embodiment of the present application;
[0098] Fig.12 It is a flowchart of a proposal block provided in an embodiment of the present application;
[0099] Fig.13 It is a flowchart of a verification block provided by an embodiment of the present application;
[0100] Fig.14 It is a structural schematic diagram of a block processing device provided in an embodiment of the present application;
[0101] Fig.15 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0102] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0103] In order to more clearly understand the technical solution provided by the embodiments of the present application, the key terms involved in the embodiments of the present application are introduced here:
[0104] (1) Blockchain network:
[0105] The blockchain network is a P2P (Peer to Peer) network, which is a point-to-point network. Each blockchain node connected point-to-point is called a peer node. The P2P network is based on a specific type of network protocol, so that there is no need for a central node to maintain the network status between peer nodes. Each peer node maintains the node status of the entire network and its connection status with adjacent nodes through broadcast interactions with adjacent nodes.
[0106] P2P network can be understood as Figure 1 The data sharing system 10 shown. The data sharing system 10 refers to a system for sharing data between blockchain nodes and blockchain nodes, and the data sharing system may include multiple blockchain nodes 101, and the multiple blockchain nodes 101 may refer to each client, terminal or server in the data sharing system. Each blockchain node 101 can receive input information (for example, transaction) when performing normal work, and maintain the shared data in the data sharing system based on the received input information. In order to ensure the information intercommunication in the data sharing system, there may be an information connection between each blockchain node in the data sharing system, and information can be transmitted between blockchain nodes through the above information connection. For example, when any blockchain node in the data sharing system receives input information, other nodes in the data sharing system obtain the input information according to the consensus algorithm, and store the input information as data in the shared data, so that the data stored on all blockchain nodes in the data sharing system are consistent. For each blockchain node in the data sharing system, there is a node identifier corresponding to it, and each blockchain node in the data sharing system can store the node identifiers of other blockchain nodes in the data sharing system, so that the generated blocks can be broadcast to other blockchain nodes in the data sharing system according to the node identifiers of other blockchain nodes in the data sharing system. Each blockchain node can maintain a node identification list as shown in Table 1 below, and store the node name and node identification in the node identification list. The node identification can be an IP (Internet Protocol, a protocol for interconnecting networks) address or any other information that can be used to identify the blockchain node. Table 1 only uses the IP address as an example for explanation:
[0107] Table 1
[0108] Node Name Node ID Node 1 XXX.XXX.XXX.XX1 Node 2 XXX.XXX.XXX.XX2 … … Node N XXX.XXX.XXX.XXN
[0109] The blockchain nodes in the blockchain network can include at least two types: proposal nodes and verification nodes. Among them: the proposal node can be used to propose blocks, and the proposed blocks need to be sent to the verification node for verification; the number of verification nodes is at least one, and the verification node can be used to verify the proposed blocks. When the number of verification nodes that have passed the block verification exceeds the node number threshold (for example, the node number value can be the number of all verification nodes, or a certain proportion of the number of verification nodes, etc.), the block can be uploaded to the blockchain for storage. In addition, in the blockchain network, the proposal node and the verification node can be converted to each other. It can be understood that the blockchain node in the blockchain network has the proposal function for a period of time and can be used as a proposal node, and the blockchain node has the verification function for another period of time and can be used as a verification node.
[0110] (2) Blockchain:
[0111] Each blockchain node in the blockchain network stores an identical blockchain. Blockchain is a distributed ledger technology in the field of information technology. It is generally composed of consensus, transaction blocks, state data storage, cryptographic identity security, etc. Since the ledger is distributed and the blocks are consensus-based, it has the characteristics of being tamper-proof, traceable, and jointly maintained. The blockchain consists of multiple blocks, which can be seen in Figure 2 As shown in the blockchain structure, the blockchain consists of multiple blocks. The genesis block in the blockchain includes a block header and a block body. The block header of the genesis block stores input information feature values, version numbers, timestamps and difficulty values, and the block body of the genesis block stores input information (i.e., transactions). The next block of the genesis block takes the genesis block as its parent block, and the next block also includes a block header and a block body. In addition to storing the input information feature values, version numbers, timestamps and difficulty values of the current block, the block header of the next block also stores the feature values of the block header of the parent block, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in its parent block, thereby ensuring the security of the input information in the block.
[0112] When generating each block in the blockchain, refer to Figure 3 In the block generation process shown in the figure, when the blockchain node where the blockchain is located receives the input information, it verifies the input information. After the verification is completed, the input information is stored in the transaction pool, and the hash tree used to record the input information is updated; then, the update timestamp is updated to the time when the input information is received, and different random numbers are tried, and the eigenvalue calculation is performed multiple times, so that the calculated eigenvalue can satisfy the following formula:
[0113] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x)) <TARGET
[0114] Among them, SHA256 (Secure Hash Algorithm 256, a secure hash algorithm) is the eigenvalue algorithm used to calculate the eigenvalue; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header eigenvalue of the parent block of the current block; merkle_root is the eigenvalue of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value within a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the eigenvalue threshold, which can be determined based on nbits.
[0115] In this way, when the random number that satisfies the above formula is calculated, the information can be stored accordingly, the block header and block body can be generated, and the current block can be obtained. Subsequently, the blockchain node where the blockchain is located sends the newly generated block to other blockchain nodes in the data sharing system where it is located according to the node identification of other blockchain nodes in the data sharing system. Other blockchain nodes verify the newly generated block and add the newly generated block to the blockchain stored in it after the verification is completed.
[0116] (3) Block Verification:
[0117] Block verification refers to the verification of transactions included in the block. When all transactions included in the block are verified, the block can be determined to have been verified. Transaction verification refers to executing the transaction to obtain the transaction execution result. When the transaction execution result obtained by executing the transaction is the same as the transaction execution result in the block, the transaction can be determined to have been verified.
[0118] (4) Transaction dependencies:
[0119] Transaction dependency refers to the order in which transactions are executed. For any two transactions in a block (for example, transaction A and transaction B), the transaction dependency between transaction A and transaction B can be, for example, transaction A depends on transaction B. Transaction A depends on transaction B, which means that the execution order of transaction B precedes that of transaction A, that is, transaction B needs to be executed before transaction A, otherwise, transaction A will not be able to be executed.
[0120] Based on the relevant description of the above key terms, the embodiment of the present application proposes a block processing method that can improve the verification efficiency of the block. When determining the verification order of multiple transactions in a block, the block processing method takes into account the transaction dependencies between multiple transactions in the block, as well as the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction refers to the estimated resource consumption information required from the start of verification of the transaction to the end of verification of all transactions in the dependency chain of the transaction, that is, the transaction verification indication information of any transaction refers to the estimated resource consumption information required from the start of verification of the transaction to the end of verification of all transactions in the dependency chain of the transaction; the dependency chain of a transaction refers to a transaction chain with the current transaction as the dependency starting point, a transaction that is not dependent as the dependency end point, and from the dependency starting point to the dependency end point, the latter transaction depends on the previous transaction. In the verification order determined by the block processing method, transactions with higher transaction verification indication information (i.e., estimated resource consumption information under transaction dependency) are verified first, that is, the dependency chain with higher estimated resource consumption information under transaction dependency is executed first, so that the serious serialization caused by the last execution of transactions with higher estimated resource consumption information under transaction dependency can be avoided. It can be seen that the verification order determined by the block processing method is more reasonable, so that in the process of block verification, the transactions in the block are verified according to a reasonable verification order, which can improve the verification efficiency of the block.
[0121] Furthermore, the resource consumption information (e.g., estimated resource consumption information) mentioned in the embodiments of the present application may refer to the transaction execution time or the transaction Gas consumption value. The transaction execution time refers to the time required to execute a transaction. The transaction Gas consumption value refers to the amount of computation required to execute a transaction. The transaction Gas consumption value can more accurately quantify the complexity of the transaction and can avoid the problem of inaccurate transaction execution time estimation due to uneven resource allocation of individual blockchain nodes. Therefore, when the transaction Gas consumption value is used as the resource consumption information of the transaction, the rationality of the determined verification order can be improved to a certain extent, thereby further improving the verification efficiency of the block.
[0122] A block processing system suitable for implementing the block processing method provided in an embodiment of the present application is introduced below in conjunction with the accompanying drawings.
[0123] like Figure 4As shown, the block processing system may include blockchain nodes, which may be clients, terminals or servers; the client may be, for example, an application, a mini-program, and software, etc.; the terminal may be any one of a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a car terminal, and smart home appliances, but is not limited thereto; the server may be a separate physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0124] Blockchain nodes can be used to perform tasks such as block generation, consensus (including verification), and storage. Blockchain nodes can include network modules, authentication modules, transaction pool modules, block generation / verification modules, virtual machine modules, and data storage modules. The following are introductions to these modules:
[0125] (1) Network module: The network module can be used to communicate with blockchain nodes and transaction providers. When the network module is used to communicate with blockchain nodes, it can be used to propose blocks and send the proposed blocks to blockchain nodes (herein, blockchain nodes can be verification nodes) for verification. Proposing blocks refers to the process of packaging transactions into blocks, or it can be used to receive blocks proposed by blockchain nodes (herein, blockchain nodes can be proposal nodes) for verification; when the network module is used to communicate with transaction providers, it can be used to receive transactions provided by transaction providers.
[0126] (2) Authentication module: The authentication module can be used to store digital certificates and perform legitimacy verification on other blockchain nodes and transaction providers that communicate with the current blockchain node; the legitimacy verification mentioned in the embodiment of the present application can include two parts: digital certificate verification and digital signature verification. If both parts are verified, it can be considered that the legitimacy verification has passed; the digital certificate can be used to uniquely identify the identity of the certificate holder; the digital signature (also known as the public key digital signature) is a digital string that can only be generated by the sender of the information and cannot be forged by others. This digital string is also an effective proof of the authenticity of the information sent by the sender of the information. The signature verification is the receiver's need to confirm whether the ciphertext file he received is really sent by the sender. What needs to be confirmed is whether it has been tampered with in the middle (different from decryption). The signature verification is ultimately compared based on the message digest. The authentication module may include a certificate submodule and an authentication algorithm submodule. Among them: the certificate submodule can be used to verify the digital certificate and store the digital certificate that has passed the verification; the authentication algorithm submodule contains the relevant cryptographic algorithm for verifying the digital signature, which can be used to verify the digital signature.
[0127] (3) Transaction pool module: The transaction pool module can be used to select transactions to be packaged and produced. The transaction pool module can include a transaction verification submodule, a transaction entry submodule, a priority sorting submodule, and a transaction selection submodule. Among them: the transaction verification submodule can be used to verify the legitimacy of the transaction before the transaction is added to the transaction pool; the transaction pool is a pool for temporarily storing block transactions on the blockchain. Each transaction to be produced will first arrive at the transaction pool for temporary storage and be sorted according to a certain priority order. When generating a new block, the transaction is obtained from the transaction pool in order. After that, the blockchain executes and verifies the transaction. After finally determining that the block verification is passed, the transaction in the block is deleted from the transaction pool. The transaction entry submodule can be used to parse the verified transactions and store them in the transaction pool. The priority sorting submodule can be used to prioritize the transactions in the transaction pool according to the transaction sorting rules, and the transactions in the transaction pool are produced in order according to the priority order. The transaction selection submodule can be used to select the transactions that need to be produced from the transaction pool.
[0128] (4) Block generation / verification module: The block generation / verification module can be used to generate blocks and verify blocks. The block generation / verification module can include a transaction packaging submodule, a transaction conflict determination submodule, a block execution graph generation submodule, and a block verification graph generation submodule. Among them: the transaction packaging submodule can be used to initiate transaction acquisition and packaging before generating a block. The transaction conflict determination submodule can be used to perform conflict determination on transactions after the transaction execution is completed. The block execution graph generation submodule can be used to generate a block execution graph, and the transaction dependencies between transactions in the block and the execution resource consumption information of each transaction can be read from the block execution graph. The verification execution graph generation submodule can be used to generate a verification execution graph, and the transaction dependencies between transactions in the block and the estimated resource consumption information of each transaction under the transaction dependencies can be read from the verification execution graph.
[0129] (5) Virtual machine module: The virtual machine module can be used to execute transactions. The virtual machine module can include a transaction execution submodule, a read-write set cache submodule, an execution time statistics submodule, and an execution calculation amount statistics submodule. Among them: the transaction execution submodule can be used to schedule and execute transactions in the virtual machine. The read-write set cache submodule can be used to cache the read and write status generated during the transaction execution process into the read-write set. The execution time statistics submodule can be used to count the transaction execution time. The execution calculation amount statistics submodule can be used to count the transaction gas consumption value.
[0130] Among them, during the transaction, a read-write set will be prepared for the transaction; the read set contains the keys read by the transaction during the simulation, and the write set contains the new values of the transaction write keys (which can overlap with the keys in the read set); the transaction execution process will continuously update the read-write set, and when executing transactions concurrently, if there is a read-write conflict, the transaction needs to be re-executed. In the embodiment of the present application, the key is a combination of Field (number) and Key (value). For example, Account-007 is numbered Account and the value is 007. The combination of the two represents a unique key, and the value is the detailed content of Account numbered 007. The final storage will also be prefixed with the contract name, that is, there can be no read-write set conflict between contracts.
[0131] (6) Data storage module: The data storage module can be used to store the latest state of data. The data storage module can include a state database submodule and an account data submodule. Among them: the database submodule can be used to store the latest state of data in the database. The account data submodule can be used to store the content of all blocks and data, including all change history of the data.
[0132] The blockchain node may include a proposal node 401 and a verification node 402; the proposal node 401 and the verification node may establish a direct communication connection by wired communication, or an indirect communication connection may be established by wireless communication. It should be noted that the various functional modules in the blockchain node are not necessarily used in the same blockchain node; for example, when the blockchain node is a proposal node 401, the functional modules used in the proposal node 401 are: a network module, an authentication module, a transaction pool module, a block generation / verification module (specifically, a transaction packaging submodule, a transaction conflict determination submodule, and a block execution graph generation submodule in the block generation / verification module), a virtual machine module, and a data storage module; for another example, when the blockchain node is a verification node 402, the functional modules used in the verification node 402 are: a network module, an authentication module, a block generation / verification module (specifically, a block execution graph generation submodule and a block verification graph generation submodule in the block generation / verification module), a virtual machine module, and a data storage module.
[0133] As described above, the proposal node 401 can be used to propose a block, and the proposed block needs to be sent to the verification node 402 for verification. The verification node 402 can be used to verify the block proposed by the proposal node 401. The verification node 402 verifies the block, which means that the verification node 402 verifies multiple transactions in the block. The embodiment of the present application can consider the transaction dependencies between multiple transactions in the block, and the estimated resource consumption information of each transaction under the transaction dependency, and determine the reasonable verification order of multiple transactions in the block. Thus, in the verification process of the block, the transactions in the block can be verified according to the reasonable verification order, and the verification efficiency of the block can be improved. In addition, the resource consumption information in the embodiment of the present application can be measured by the transaction execution Gas consumption value. The transaction Gas consumption value can more accurately quantify the transaction complexity, and can avoid the problem of inaccurate transaction execution time estimation due to uneven resource allocation of individual blockchain nodes. In addition, the legitimacy of other blockchain nodes and transaction providing objects that communicate with the current blockchain node is verified by the authentication module, which ensures the overall security and stability of the block processing system.
[0134] It can be understood that the block processing system described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided in the embodiment of the present application. Ordinary technicians in this field can know that with the evolution of the system architecture and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.
[0135] The block processing method provided in the embodiment of the present application is described in more detail below with reference to the accompanying drawings.
[0136] The embodiment of the present application provides a block processing method, which mainly introduces the block verification process. The block processing method can be executed by a computer device, which can be, for example, a verification node in the above block processing system. Figure 5 As shown, the block processing method may include but is not limited to the following steps S501 to S504:
[0137] S501, receiving a block to be verified sent by a proposing node; the block includes multiple transactions to be verified.
[0138] The block to be verified is sent by the proposing node, and the block can include multiple transactions to be verified.
[0139] S502, obtaining block verification indication information of a block; the block verification indication information includes transaction dependency relationships between multiple transactions, and transaction verification indication information of each transaction under the transaction dependency relationships.
[0140] The block verification indication information of a block may include the transaction dependency relationship between multiple transactions, and the transaction verification indication information of each transaction under the transaction dependency relationship. As described above, the transaction dependency relationship between multiple transactions in a block refers to the transaction execution order between multiple transactions in a block; the transaction verification indication information of any transaction can be used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the end of verification of all transactions in the dependency chain of the corresponding transaction; the transaction dependency chain refers to a transaction chain with the current transaction as the dependency starting point, the non-dependent transaction as the dependency end point, and the direction from the dependency starting point to the dependency end point, and the latter transaction depends on the previous transaction; the estimated resource consumption information may include the comprehensive transaction execution time, or the comprehensive transaction execution Gas consumption value.
[0141] The block verification indication information of the block can be obtained in any of the following two ways: first, the block verification indication information sent by the proposal node can be directly received; second, the block execution indication information sent by the proposal node can be received, and then the block verification indication information can be generated according to the block execution indication information; the block execution indication information can include the transaction dependency between multiple transactions in the block, and the transaction execution indication information of each transaction. The transaction execution indication information of any transaction can be used to indicate the separate resource consumption information for executing the corresponding transaction. The separate resource consumption information can include the separate transaction execution time, or the separate transaction execution Gas consumption value. The following is an introduction to the process of generating block verification indication information according to block execution information, which can specifically include the following sub-steps s11-sub-steps s13:
[0142] s11, creating a block execution graph according to the block execution instruction information.
[0143] The block execution instruction information may include transaction dependencies between multiple transactions in the block, and transaction execution instruction information of each transaction. The block execution graph may be a forward DAG (Directed Acyclic Graph) created according to the block execution instruction information; wherein, DAG refers to a directed graph in graph theory that cannot return to any vertex through several edges starting from any vertex.
[0144] The process of creating a block execution graph may include: determining transactions in a block as nodes in the block execution graph; determining transaction execution indication information of transactions in a block as node values of nodes in the block execution graph; and determining transaction dependencies between transactions in a block as directed edges between corresponding nodes in the block execution graph. Wherein, for any node in the block execution graph (which may be referred to as a target node), the directed edge connected to the target node in the block execution graph may include at least one of the following: an incoming edge (an incoming edge refers to a directed edge with the target node as the end point of the direction) and an outgoing edge (an outgoing edge refers to a directed edge with the target node as the starting point of the direction); the presence of an incoming edge at a target node indicates that the target node depends on other nodes, and the other nodes that the target node depends on are connected to the target node through the incoming edge of the target node; the presence of an outgoing edge at a target node indicates that the target node is dependent on a reference node, and the reference node is connected to the target node through the outgoing edge of the target node.
[0145] Figure 6a An exemplary block execution graph that uses individual transaction execution time as individual resource consumption information is shown. The 10 transactions in the block are represented as 10 nodes in the block execution graph (including node 1, node 2, node 3, ..., node 10); the individual transaction execution time of the 10 transactions in the block is represented as the node value of the 10 nodes in the block execution graph; the transaction dependency relationship between the 10 transactions in the block is represented as the directed edges between the 10 nodes in the block execution graph. Taking node 2 as an example, node 2 includes an outgoing edge and an incoming edge. The outgoing edge of node 2 is connected to node 1, and the incoming edge of node 2 is connected to node 4, indicating that node 1 depends on node 2, node 2 depends on node 4, and the execution order of the transaction corresponding to node 4 is before the execution order of the transaction corresponding to node 2, and the execution order of the transaction corresponding to node 2 is before the execution order of the transaction corresponding to node 1. Similarly, Figure 6b An exemplary block execution diagram that uses the Gas consumption value of a single transaction execution as separate resource consumption information is shown.
[0146] s12, convert the block execution graph into the block verification graph.
[0147] The block verification indication information needs to be read from the block verification graph, so the block execution graph needs to be converted into the block verification graph, which can be understood as the reverse DAG obtained by converting the block execution graph. The process of converting the block execution graph into the block verification graph may include: determining the starting node in the block execution graph; the starting node is a node in the block execution graph that has an incoming edge but no outgoing edge; determining the conversion node connected to the starting node through the incoming edge of the starting node; using the node and value between the starting node and the conversion node to update the node value of the conversion node; determining the conversion node as the new starting node, continuing to determine the new conversion node, and updating the node value of the new conversion node until all nodes in the block execution graph are traversed to obtain the block verification graph.
[0148] Figure 6a The process of converting the block execution graph into the block verification graph is as shown in Figure 7 As shown, the nodes represented by solid circles are nodes whose node values have been updated (or can be called converted nodes), and the nodes represented by dotted circles are nodes whose node values have not been updated (or can be called unconverted nodes); Node 1 in the block execution graph is the starting node, and nodes 2 and 3 connected to the incoming edge of node 1 are both conversion nodes. Taking node 2 as an example, the node value (1.2s) of node 2 can be assigned to the incoming edge, and the node value of node 2 is updated by the sum (3.3s) of the node value (2.1s) of node 1 and the value (1.2s) assigned to the incoming edge. Figure 7 The dotted arrow in the figure indicates the update direction of the node value, that is, the node value (3.3s) between the node value (2.1s) of node 1 and the node value (1.2s) of node 2 can be used to update the node value of node 2. Then, node 2 and node 3 can be used as new starting nodes to continue to determine new conversion nodes and update the node values of the new conversion nodes until all nodes in the block execution graph are traversed to obtain the block verification graph.
[0149] Furthermore, when there are multiple starting nodes connected to the conversion node, the node sum value used to update the node value of the conversion node is the maximum sum value of the node sum values between the conversion node and the multiple starting nodes respectively; that is, the node sum value between the conversion node and each starting node can be determined respectively, and the node value of the conversion node is updated by using the maximum sum value of the node sum values between the conversion node and each starting node; the same is true for a new starting node and a new conversion node. Figure 6a The process of converting the block execution graph into the block verification graph is as shown in Figure 8As shown, the nodes represented by the solid circle are nodes with updated node values (or can be called converted nodes), and the nodes represented by the dotted circle are nodes with unupdated node values (or can be called unconverted nodes); when node 6 is used as a conversion node, there are two starting nodes connected to the conversion node (node 2 and node 3), the node sum value between the node value of node 2 (3.3s) and the node value of node 6 (3.2s) is 6.5s, and the node sum value between the node value of node 3 (4.0s) and the node value of node 6 (3.2s) is 7.2s, Figure 8 The dotted arrow in the figure indicates the update direction of the node value. The maximum sum value 7.2s can be used to update the node value of node 6. The bold outgoing edge indicates that the node sum value between the node value of node 3 and the node value of node 6 connected to the conversion node through the bold outgoing edge is selected to update the node value of node 6. Nodes 8 and 9 are similar to node 6. Here, the maximum sum value is used to update the node value of the conversion node because the transaction represented by the starting node corresponding to the maximum sum value is executed, which ensures that all transactions on the dependency chain of the transaction represented by the conversion node can be executed. Figure 9a Shows Figure 6a The block verification graph obtained by converting the block execution graph shown, Figure 9b Shows Figure 6b The block verification graph obtained by converting the block execution graph shown.
[0150] s13, read block verification instruction information from the block verification graph.
[0151] The block verification instruction information can be read from the block verification graph. The following is an introduction to the information that the block verification graph can express: Figure 9a or Figure 9bAs shown, the block verification graph may include nodes and directed edges, the nodes in the block verification graph represent transactions in the block, the node values of the nodes in the block verification graph represent transaction verification indication information of the transactions in the block, and the directed edges in the block verification graph represent transaction dependencies between transactions in the block. Among them, for any node in the block execution graph (which can be called the target node), the directed edge connected to the target node in the block execution graph may include at least one of the following: an incoming edge (an incoming edge refers to a directed edge with the target node as the end point of the direction) and an outgoing edge (an outgoing edge refers to a directed edge with the target node as the starting point of the direction); the existence of an incoming edge in the target node indicates that the target node depends on other nodes, and the other nodes that the target node depends on are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge in the target node indicates that the target node is dependent on the reference node, and the reference node is connected to the target node through the outgoing edge of the target node; the node value of the target node indicates the transaction verification indication information of the transaction represented by the target node (i.e., the estimated resource consumption information required from the start of verification of the transaction represented by the target node to the end of verification of all transactions in the dependency chain of the transaction represented by the target node), and the value assigned to the outgoing edge of the target node indicates the transaction execution indication information of the transaction represented by the target node (i.e., the separate resource consumption information for executing the transaction represented by the target node). Thus, the block verification indication information can be read from the block verification graph.
[0152] S503, sorting the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction to obtain the verification order of the multiple transactions.
[0153] The verification order of multiple transactions included in the block can be obtained by sorting the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction. Specifically, the process of sorting the multiple transactions can include:
[0154] First, according to the transaction dependency, the first transaction of the first priority can be determined among multiple transactions; the first transaction is a transaction that does not have a dependent transaction among multiple transactions. Correspondingly, in the block verification graph, the first transaction can be the transaction represented by the first node in the block verification graph, and the first node has an outgoing edge but no incoming edge, for example, Figure 9a or Figure 9b Node 7, node 8, node 9 and node 10 in are all first nodes. Secondly, the verification order of each first transaction under the first priority can be determined according to the numerical relationship between the transaction verification indication information of each first transaction; the first transaction with a larger transaction verification indication information (i.e., the higher the estimated resource consumption information indicated by the transaction verification indication information), the higher the verification order under the first priority. For example, Figure 9aThe verification order of the transactions represented by nodes 7, 8, 9 and 10 is: the transaction represented by node 10, the transaction represented by node 9, the transaction represented by node 8, and the transaction represented by node 7. Then, according to the transaction dependency, the second transaction belonging to the second order priority can be determined among the multiple transactions; the second transaction is a transaction that depends on the first transaction among the multiple transactions. Correspondingly, in the block verification graph, the second transaction can be the transaction represented by the second node in the block verification graph, and the second node is connected to the outgoing edge of the first node, for example, Figure 9a or Figure 9b Node 4, node 5 and node 6 in are all second nodes. Similarly, the verification order of each second transaction under the second priority can be determined according to the numerical relationship between the transaction verification indication information of each second transaction; the second transaction with a larger transaction verification indication information (i.e., the higher the estimated resource consumption information indicated by the transaction verification indication information), the higher the verification order under the second priority. For example, Figure 9a The verification order of the transactions represented by nodes 4, 5 and 6 is: the transaction represented by node 5, the transaction represented by node 6, and the transaction represented by node 4. Then, the subsequent transactions belonging to the subsequent order priority can be determined, and the verification order of each subsequent transaction under the subsequent order priority can be determined.
[0155] The verification order of the first priority is earlier than that of the second priority. Figure 9a For example, the verification order of the transactions represented by each node is: the transaction represented by node 10, the transaction represented by node 9, the transaction represented by node 8, the transaction represented by node 7, the transaction represented by node 5, the transaction represented by node 6, the transaction represented by node 4, the transaction represented by node 3, the transaction represented by node 2, and the transaction represented by node 1.
[0156] It should be added that multiple transactions in a block can be added to a priority queue, and when the block is verified, the transactions that are dequeued can be obtained from the head of the priority queue for verification. A priority queue refers to a collection of multiple elements, each of which has a priority, and the element with the highest priority is taken out of the priority queue each time. In an embodiment of the present application, the priority of a transaction in a priority queue is the transaction verification indication information of the transaction. The larger the transaction verification indication information, the higher the position of the transaction in the priority queue, that is, the higher the dequeuing order. By combining the priority queue with the process of determining the verification order of multiple transactions in a block, it can be obtained that after determining the first transaction belonging to the first sequence priority among multiple transactions, the first transaction can be added to the priority queue, and the comparison method of the first transaction in the priority queue is the transaction verification indication information. The larger the transaction verification indication information, the higher the dequeue order of the first transaction in the priority queue. In other words, the priority queue can determine the verification order of each first transaction under the first sequence priority according to the numerical relationship between the transaction verification indication information of each first transaction, and the verification order of each first transaction under the first sequence priority is the dequeue order of each first transaction under the first sequence priority; then, after determining the second transaction belonging to the second sequence priority among multiple transactions, the second transaction can be added to the priority queue, and the comparison method of the second transaction in the priority queue is the transaction verification indication information. The larger the transaction verification indication information, the higher the dequeue order of the second transaction in the priority queue. In other words, the priority queue can determine the verification order of each second transaction under the second sequence priority according to the numerical relationship between the transaction verification indication information of each second transaction, and the verification order of each second transaction under the second sequence priority is the dequeue order of each second transaction under the second sequence priority.
[0157] S504: During the verification process of the block, multiple transactions are verified in the verification order to obtain the verification result of the block, and the verification result is fed back to the proposal node.
[0158] As described above, the block may also include the transaction execution result of each transaction in the multiple transactions in the block (the transaction execution result here may be referred to as the first transaction execution result). The verification process of the block may specifically include: executing multiple transactions in a verification order to obtain a second transaction execution result of each transaction in the multiple transactions; if the first transaction execution result and the second transaction execution result of each transaction in the multiple transactions are the same, a verification result indicating that the block verification has passed may be generated; if there is a transaction in the multiple transactions whose first transaction execution result and the second transaction execution result are different, a verification result indicating that the block verification has failed may be generated.
[0159] It should be added that in the verification process of the block, multiple transactions in the block can be verified concurrently in the verification order. Specifically, S transaction verification resources can be created, and the number of transaction verification resources S can be equal to the number of cores of the CPU (Central Processing Unit) in the verification node, and S is an integer greater than or equal to 2. Multiple transactions in a block can be added to a priority queue, and the order in which multiple transactions in the block are dequeued from the priority queue is the verification order of multiple transactions. The S transaction verification resources can obtain the transaction that is dequeued at the head of the priority queue and call the virtual machine module to execute the transaction for transaction verification.
[0160] Among them, transaction verification resources may include any of the following: processes, threads, and coroutines, etc.; a process refers to a running activity of a program in a computer on a data set; a thread refers to a single sequential control flow in a process; a coroutine is not a system-level thread. In many cases, a coroutine is called a "lightweight thread", "microthread", "fiber", etc. In simple terms, a coroutine can be considered to be a different function in a thread, which can switch quickly with each other. A coroutine is very close to a user-mode thread, and switching between user-mode threads does not require trapping into the kernel, but switching of user-mode threads in some operating systems requires the assistance of kernel-mode threads.
[0161] In an embodiment of the present application, the verification node can sort multiple transactions according to the transaction dependency relationship between multiple transactions included in the block to be verified, and the transaction verification indication information of each transaction under the transaction dependency relationship, to obtain the verification order of the multiple transactions. Then, during the verification process of the block, the multiple transactions can be verified according to the verification order, and the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the beginning of verification of the transaction to the end of verification of all transactions in the dependency chain of the transaction. It can be seen that when the verification node sorts the multiple transactions in the block, the estimated resource consumption information of each transaction under the transaction dependency relationship is taken into account, so that the verification order obtained by sorting is reasonable. Therefore, during the verification process of the block, the verification node can verify the multiple transactions in a reasonable verification order, which can improve the verification efficiency of the block.
[0162] The embodiment of the present application provides a block processing method, which mainly introduces the block proposal process. The block processing method can be executed by a computer device, which can be, for example, a proposal node in the above block processing system. Fig.10 As shown, the block processing method may include but is not limited to the following steps S1001 to S1003:
[0163] S1001, obtain multiple transactions from the transaction pool.
[0164] The transaction pool is a pool where proposal nodes temporarily store transactions. Each transaction to be generated will first arrive at the transaction pool for temporary storage and sorted in a certain priority order. When generating a new block, multiple transactions are obtained from the transaction pool in order.
[0165] S1002, packing multiple transactions into a block to be verified, sending the block to the verification node, allowing the verification node to sort the multiple transactions based on the block verification indication information of the block, obtain the verification order of the multiple transactions, and during the verification process of the block, verify the multiple transactions according to the verification order to obtain the verification result of the block.
[0166] The acquired multiple transactions can be packaged into a block to be verified and sent to the verification node for verification. The verification node can sort the multiple transactions based on the block verification indication information of the block to obtain the verification order of the multiple transactions, and verify the multiple transactions according to the verification order during the block verification process to obtain the verification result of the block. The block verification process of the verification node can be specifically referred to above. Figure 5 The relevant descriptions in the illustrated embodiments are not repeated here. The block verification indication information includes the transaction dependency relationship between multiple transactions and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the end of verification of all transactions in the dependency chain of the corresponding transaction.
[0167] The process of packaging multiple transactions into a block to be verified may specifically include: creating M transaction execution resources, where M is an integer greater than or equal to 2; using M transaction execution resources to concurrently execute multiple transactions; packaging multiple transactions and the transaction execution results of multiple transactions into a block. Among them, the number of transaction execution resources M may be equal to the number of cores of the CPU (Central Processing Unit) in the proposal node. Similar to the transaction verification resources in the verification node, the transaction execution resources may include any of the following: processes, threads, and coroutines, etc. A process refers to a running activity of a program in a computer on a data set; a thread refers to a single sequential control flow in a process; a coroutine is not a system-level thread. In many cases, a coroutine is called a "lightweight thread", "microthread", "fiber", etc. In simple terms, a coroutine can be considered to be a different function in a thread, and these functions can be quickly switched to each other. The coroutine is very close to the user-mode thread. The switching between user-mode threads does not need to fall into the kernel, but the switching of user-mode threads in some operating systems requires the assistance of kernel-mode threads.
[0168] Furthermore, the process of M transaction execution resources concurrently executing multiple transactions is related to the number of smart contracts that need to be called to execute multiple transactions. Here, in order to facilitate understanding of the relationship between the concurrent execution process and the number of smart contracts, the number of smart contracts that need to be called to execute multiple transactions is expressed as N, that is, multiple transactions need to call N smart contracts to execute, and N is a positive integer. Among them, smart contracts refer to a program running on the blockchain. Unlike ordinary programs, smart contracts must ensure that the results of running in each blockchain node of the blockchain network are exactly the same, so that any blockchain node can verify whether the results of the smart contract execution in the block are correct. The relationship between the process of M transaction execution resources concurrently executing multiple transactions and the number of smart contracts that need to be called to execute multiple transactions can be specifically described as follows: when N is greater than or equal to M (that is, the number of smart contracts that need to be called to execute multiple transactions is greater than or equal to the number of transaction execution resources), each of the M transaction execution resources can be used to execute a transaction under a smart contract; when N is less than M (that is, the number of smart contracts that need to be called to execute multiple transactions is less than the number of transaction execution resources), there are surplus transaction execution resources, and at least two of the M transaction execution resources can be used to execute transactions under the same smart contract. Among them:
[0169] For the case where each of the M transaction execution resources is used to execute a transaction under a smart contract, the transactions under each smart contract need to be sorted according to the experience value of the resource consumption information required for execution, and the transactions with high experience values of the resource consumption information required for execution under each smart contract are given priority; and the smart contract may include multiple contract methods, and the transaction under the smart contract may be executed by calling at least one of the multiple contract methods, and the experience value of the resource consumption information required for the transaction execution under the smart contract may be determined based on the resource consumption experience information of the called contract method. Specifically, for ease of understanding, the case where any one of the M transaction execution resources executes a transaction is introduced here, and any one of the M transaction execution resources may be represented as a target transaction execution resource, and the target transaction execution resource may be used for transactions under a target smart contract. The target smart contract may include multiple contract methods, and the transaction under the target smart contract may be executed by calling at least one of the multiple contract methods. The process of using the target transaction execution resource to execute transactions under the target smart contract may specifically include:
[0170] The resource consumption experience information of each contract method in the target smart contract is obtained. The resource consumption experience information of the contract method refers to the experience value of the resource consumption information required to call the contract method to execute the transaction; then, the execution resource consumption information required to execute the transaction under the target smart contract can be determined according to the resource consumption experience information of the contract method called by the exchange under the target smart contract. The execution resource consumption information required to execute the transaction under the target smart contract can be the sum of the resource consumption experience information of each contract method called by the exchange under the target smart contract; then, the transactions under the target smart contract can be sorted according to the execution resource consumption information required to execute the transaction under the target smart contract to obtain the transaction execution order of the transactions under the target smart contract. In the transaction execution order under the target smart contract, the transaction with high execution resource consumption information under the target smart contract is executed first; then, the target transaction execution resource can be used to call the target smart contract, and the transaction under the target smart contract is executed according to the transaction execution order. In the case where each of M transaction execution resources is used to execute a transaction under a smart contract, the M transaction execution resources can be reasonably arranged to concurrently execute multiple transactions to be packaged and blocked, thereby improving transaction execution efficiency; and transactions under the same smart contract can be sorted according to the execution resource consumption information of the transactions, and executed in sequence according to the transaction execution order obtained by the sorting, thereby ensuring that transactions with high execution resource consumption information are executed first, thereby improving the execution efficiency of transactions under the same smart contract.
[0171] For the case where at least two of the M transaction execution resources are used to execute transactions under the same smart contract, the smart contract may include multiple contract methods. When at least two transaction execution resources execute transactions under the same smart contract, the multiple contract methods included in the smart contract are allocated to different transaction execution resources for calling, and the allocation is made according to the total resource consumption experience information of the contract methods, and the contract methods with high total resource consumption experience information are allocated first. Specifically, for ease of understanding, the process of a reference smart contract among N smart contracts being called by at least two transaction execution resources to execute transactions is introduced here. The reference smart contract needs to call P of the M transaction execution resources for execution. The reference smart contract may include multiple contract methods. The P transaction execution resources may be used to call different contract methods in the reference smart contract respectively, and the transaction under the reference smart contract may be executed by calling at least one of the multiple contract methods, where P is an integer greater than or equal to 2 and less than or equal to M. The process of using P transaction execution resources to execute transactions under the reference smart contract may specifically include:
[0172] The resource consumption experience information of each contract method in the reference smart contract is obtained. The resource consumption experience information of the contract method refers to the experience value of the resource consumption information required to call the contract method to execute the transaction; then, the total resource consumption experience information of each contract method in the reference smart contract can be determined according to the resource consumption experience information of each contract method in the reference smart contract and the number of transactions under the corresponding contract method. The total resource consumption experience information of the contract method can be the product of the resource consumption experience information of the contract method and the number of transactions under the contract method; then, according to the total resource consumption experience information of each contract method in the reference smart contract, multiple contract methods can be allocated to the P transaction execution resources, and the contract method with high total resource consumption experience information in the reference smart contract can be allocated first; then, the P transaction execution resources can be used to call the allocated contract method to execute the transaction under the allocated contract method. In the case where at least two of the M transaction execution resources are used to execute transactions under the same smart contract, among the contract methods under the same smart contract, the contract method with high total resource consumption experience information can be allocated first, which can ensure that the contract method with high total resource consumption experience information is executed first, and the efficiency of transactions under the same smart contract being executed by at least two transaction execution resources can be improved. Moreover, similar to the case where the target transaction execution resources are used to execute transactions under the target smart contract, when at least two transaction execution resources execute transactions under the same smart contract, they can also be sorted according to the execution resource consumption information of the transactions. Transactions with higher execution resource consumption information are executed first, which can further improve the efficiency of transactions under the same smart contract being executed by at least two transaction execution resources.
[0173] The content of the above step S1002 mainly introduces the relevant content of the concurrent execution of multiple transactions in the process of packaging multiple transactions into a block. What needs to be introduced in step S1002 is that the basis for the verification node to sort the multiple transactions in the block (i.e., the block verification indication information) can be that the proposal node obtains the block execution indication information of the block, and the proposal node generates the block verification indication information according to the block execution indication information, and then sends the block verification indication information to the verification node; or, the basis for the verification node to sort the multiple transactions in the block (i.e., the block verification indication information) can be that the proposal node obtains the block execution indication information of the block and sends it to the verification node, and then the verification node generates the block verification execution information according to the block execution indication information; the process of the proposal node generating the block verification execution information according to the block execution indication information is the same as the process of the verification node generating the block verification indication information according to the block execution indication information, and both include the above Figure 5 For details of the contents described in sub-steps s11 to s13 in the embodiment shown, please refer to the above Figure 5 The relevant description of the illustrated embodiment will not be repeated here.
[0174] S1003, receiving the verification result fed back by the verification node.
[0175] The proposal node can receive the verification results fed back by the verification node. Among the verification results fed back by the verification node, if the number of verification results that have passed the verification (that is, the number of verification nodes that have passed the verification) exceeds (is greater than or equal to) the node number threshold (for example, the node number value can be the number of all verification nodes, or a certain proportion of the number of verification nodes, etc.), it can be determined that the consensus on the block has passed, and the block can be uploaded to the blockchain for storage; if the number of verification results that have passed the verification (that is, the number of verification nodes that have passed the verification) is less than the node number threshold, it can be determined that the consensus on the block has not passed, and the block can be discarded.
[0176] In the embodiment of the present application, the proposal node can generate block verification execution information according to the block execution instruction information, and send the block verification instruction information to the verification node, so that the verification node can sort multiple transactions in the block according to the block verification instruction information, obtain the verification order of multiple transactions in the block, and verify multiple transactions in the block according to the verification order during the verification process of the block, thereby improving the verification efficiency of the block. In addition, during the process of proposing a block, the proposal node can create multiple transaction execution resources and concurrently execute multiple transactions to be packaged out of the block, thereby improving the transaction execution efficiency.
[0177] The present application embodiment provides a block processing method, which can be interactively executed by a proposal node and a verification node in a block processing system. Fig.11 As shown, the block processing method may include but is not limited to the following steps S1101 to S1109:
[0178] S1101, the proposal node obtains multiple transactions from the transaction pool.
[0179] S1102, the proposing node packages multiple transactions into a block to be verified.
[0180] S1103, sending the block to the verification node.
[0181] S1104, the proposal node obtains the block execution instruction information of the block.
[0182] S1105, the proposal node generates block verification indication information according to the block execution indication information.
[0183] S1106, the proposing node sends the block verification instruction information to the verification node.
[0184] Steps S1101-S1106 mainly introduce the process of the proposal node proposing a block (including packaging multiple transactions into a block to be verified, and providing block verification instruction information to the verification node). It should be noted that in the process of the proposal node proposing a block, the proposal node can obtain the block execution instruction information of the block, generate block verification instruction information according to the block execution instruction information, and then send the block verification instruction information to the verification node; or, the proposal node can obtain the block execution instruction information of the block and send it to the verification node, and the verification node generates block verification instruction information according to the block execution instruction information. Taking the generation of block verification instruction information by the proposal node as an example, the detailed process of the proposal node proposing a block can be summarized as follows: Fig.12 The flowchart shown:
[0185] First, the proposal node can obtain multiple transactions from the transaction pool. Multiple transactions need to call N smart contracts for execution. M transaction execution resources can be created to execute multiple transactions concurrently. When N is greater than or equal to M (that is, the number of smart contracts required to execute multiple transactions is greater than or equal to the number of transaction execution resources), each of the M transaction execution resources can be used to execute a transaction under a smart contract; when N is less than M (that is, the number of smart contracts required to execute multiple transactions is less than the number of transaction execution resources), there is a surplus of transaction execution resources, and at least two of the M transaction execution resources can be used to execute transactions under the same smart contract. In addition, the transaction execution results of multiple transactions can be written into the read-write cache. In addition, the transaction can be conflict-determined. If the transaction conflict determination is successful (indicating that there is a conflicting transaction), the transaction needs to be re-executed; if the transaction conflict determination fails (indicating that there is no conflicting transaction), it can be determined whether all the transactions selected from the transaction pool have been executed. If so, multiple transactions and the transaction execution results of each transaction can be packaged as a block to be verified and sent to the verification node. If not, the unexecuted transaction can continue to be executed.
[0186] Secondly, block verification indication information can be generated according to the block execution indication information and sent to the verification node. The process of generating block verification indication information according to the block execution indication information may include: a block execution graph may be created according to the block execution indication information, and then the block execution graph may be converted into a block verification graph, and then the block verification indication information may be read from the block verification graph. In more detail, the process of converting the block execution graph into the block verification graph may include: determining the starting node in the block execution graph; the starting node is a node in the block execution graph that has an incoming edge but no outgoing edge; determining the conversion node connected to the starting node through the incoming edge of the starting node; using the node and value between the starting node and the conversion node to update the node value of the conversion node; judging whether the node values of the nodes in the block execution graph are all updated, if so, a block verification graph is obtained, if not, the conversion node is determined as a new starting node, and a new conversion node is continuously determined, and the node value of the new conversion node is updated until all nodes in the block execution graph are traversed to obtain a block verification graph. Moreover, when there are multiple starting nodes connected to the conversion node, the node sum value used to update the node value of the conversion node is the maximum sum value of the node sum values between the conversion node and the multiple starting nodes respectively; that is, the node sum value between the conversion node and each starting node can be determined respectively, and the node value of the conversion node is updated by using the maximum sum value of the node sum values between the conversion node and each starting node.
[0187] S1107, the verification node sorts the multiple transactions in the block to be verified based on the block verification indication information to obtain the verification order of the multiple transactions.
[0188] S1108, during the verification process of the block, the verification node verifies multiple transactions in a verification order to obtain a verification result of the block.
[0189] Steps S1107-S1108 mainly introduce the process of verification nodes verifying blocks. The detailed process of verification nodes verifying blocks can be summarized as follows: Fig.13 The flowchart shown:
[0190] First, M transaction verification resources and priority queues can be created. Multiple transactions to be verified in a block can be added to the priority queue. The M transaction verification resources can obtain the transaction at the head of the priority queue for verification.
[0191] Secondly, the block verification indication information can be represented by a block verification graph. The first transaction of the first order priority can be determined among the multiple transactions included in the block, and the first transaction can be added to the priority queue; the priority queue can determine the verification order of each first transaction under the first order priority according to the numerical relationship between the transaction verification indication information of each first transaction, and the verification order of each first transaction under the first order priority is the dequeue order of each first transaction under the first order priority; the first transaction refers to the transaction represented by the first node in the block verification graph, and the first node has an outgoing edge but an incoming edge in the block verification graph. If there is a second transaction belonging to the second order priority among the multiple transactions included in the block, the second transaction can be added to the priority queue; the priority queue can determine the verification order of each second transaction under the second order priority according to the numerical relationship between the transaction verification indication information of each second transaction, and the verification order of each second transaction under the second order priority is the dequeue order of each second transaction under the second order priority; the second transaction refers to the transaction represented by the second node in the block verification graph, and the second node is connected to the outgoing edge of the first node in the block verification graph. If there is no second transaction belonging to the second sequence priority among the multiple transactions included in the block or after the second transaction is added to the priority queue, it can be determined whether all the multiple transactions in the block are added to the priority queue. If so, the verification order of the multiple transactions in the block is determined to be ended. If not, the subsequent transactions belonging to the subsequent sequence priority can be continued to be determined, and the subsequent transactions belonging to the subsequent sequence priority can be added to the priority queue to determine the verification order of each subsequent transaction under the subsequent sequence priority.
[0192] Then, during the verification process of the block, the M transaction verification resources can obtain the transaction at the head of the priority queue for verification, so that the transaction verification can be executed concurrently to obtain the verification result of the block.
[0193] S1109, the verification node feeds back the verification result to the proposal node.
[0194] The verification node can feed back the verification results to the proposal node. Among the verification results fed back by the verification node, if the number of verification results that have passed the verification (that is, the number of verification nodes that have passed the verification) exceeds (is greater than or equal to) the node number threshold (for example, the node number value can be the number of all verification nodes, or a certain proportion of the number of verification nodes, etc.), it can be determined that the consensus on the block has been passed, and the block can be uploaded to the blockchain for storage; if the number of verification results that have passed the verification (that is, the number of verification nodes that have passed the verification) is less than the node number threshold, it can be determined that the consensus on the block has not been passed, and the block can be discarded.
[0195] In an embodiment of the present application, the proposal node can generate block verification execution information based on the block execution indication information, and send the block verification indication information to the verification node, so that the verification node can sort the multiple transactions in the block according to the block verification indication information, obtain the verification order of the multiple transactions in the block, and verify the multiple transactions in the block according to the verification order during the verification process of the block, thereby improving the verification efficiency of the block; and, in the process of proposing a block, the proposal node can create multiple transaction execution resources and concurrently execute multiple transactions to be packaged out of the block, thereby improving the transaction execution efficiency. The verification node can sort multiple transactions according to the transaction dependency relationship between multiple transactions included in the block to be verified, and the transaction verification indication information of each transaction under the transaction dependency relationship, to obtain the verification order of multiple transactions. Then, in the verification process of the block, the multiple transactions can be verified according to the verification order. The transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the transaction to the end of verification of all transactions in the dependency chain of the transaction. It can be seen that when sorting multiple transactions in the block, the verification node considers the estimated resource consumption information of each transaction under the transaction dependency relationship, so that the verification order obtained by sorting is reasonable. Therefore, in the verification process of the block, the verification node can verify multiple transactions in a reasonable verification order, which can improve the verification efficiency of the block.
[0196] The method of the embodiment of the present application is described in detail above. In order to facilitate better implementation of the above scheme of the embodiment of the present application, the device of the embodiment of the present application is provided below accordingly.
[0197] See also Fig.14 , Fig.14 It is a structural diagram of a block processing device provided in an embodiment of the present application. The block processing device can be set in a computer device provided in an embodiment of the present application, and the computer device can be a verification node. Fig.14 The block processing device shown may be a computer program (including program code) running in a computer device, and the block processing device may be used to execute Figure 5 or Fig.11 In the method embodiment shown, verify some or all of the steps performed by the node. Fig.12 , the block processing device may include the following units:
[0198] The communication unit 1401 is used to receive a block to be verified sent by a proposal node; the block includes multiple transactions to be verified;
[0199] Processing unit 1402 is used to obtain block verification indication information of a block; the block verification indication information includes transaction dependencies between multiple transactions and transaction verification indication information of each transaction under the transaction dependencies; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction;
[0200] The processing unit 1402 is further configured to sort the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction to obtain a verification order of the multiple transactions;
[0201] The processing unit 1402 is also used to verify multiple transactions in a verification order during the block verification process, obtain the verification result of the block, and feed back the verification result to the proposal node.
[0202] In one implementation, the processing unit 1402 is used to sort the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction, and when obtaining the verification order of the multiple transactions, specifically to perform the following steps:
[0203] According to the transaction dependency, a first transaction belonging to a first order priority is determined among the multiple transactions; the first transaction is a transaction that has no dependent transaction among the multiple transactions;
[0204] Determining, according to a numerical relationship between the transaction verification indication information of each first transaction, a verification order of each first transaction under a first sequence priority;
[0205] According to the transaction dependency, determining a second transaction belonging to a second order priority among the multiple transactions; the second transaction is a transaction that depends on the first transaction among the multiple transactions;
[0206] Determining the verification order of each second transaction under the second sequence priority according to the numerical relationship between the transaction verification indication information of each second transaction;
[0207] Continue to determine the subsequent transactions belonging to the subsequent sequence priority, and determine the verification order of each subsequent transaction under the subsequent sequence priority; wherein the verification order of the first sequence priority is earlier than the second sequence priority.
[0208] In one implementation, the block verification indication information is read from a block verification graph; the block verification graph includes nodes and directed edges, the nodes in the block verification graph represent transactions in the block, the node values of the nodes in the block verification graph represent transaction verification indication information of the transactions in the block, and the directed edges in the block verification graph represent transaction dependencies between transactions in the block;
[0209] The directed edge connected to the target node in the block verification graph includes at least one of the following: an incoming edge and an outgoing edge; the existence of an incoming edge in the target node indicates that the target node depends on other nodes, and other nodes are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge in the target node indicates that the target node is dependent on the reference node, and the reference node is connected to the target node through the outgoing edge of the target node; the target node is any node in the block verification graph;
[0210] The first transaction is the transaction represented by the first node in the block verification graph, and the first node has an outgoing edge but no incoming edge; the second transaction is the transaction represented by the second node in the block verification graph, and the second node is connected to the outgoing edge of the first node.
[0211] In one implementation, the processing unit 1402 is used to obtain the block verification indication information of the block, and is specifically used to perform the following steps:
[0212] Receive block verification instruction information sent by the proposal node; or, receive block execution instruction information sent by the proposal node, and generate block verification instruction information according to the block execution instruction information;
[0213] The block execution indication information includes transaction dependencies and transaction execution indication information of each transaction; the transaction execution indication information of any transaction is used to indicate the separate resource consumption information for executing the corresponding transaction.
[0214] In one implementation, the processing unit 1402 is configured to generate the block verification indication information according to the block execution indication information, and is specifically configured to perform the following steps:
[0215] Creating a block execution graph according to the block execution instruction information;
[0216] Convert the block execution graph into a block verification graph;
[0217] Read block verification instructions from the block verification graph.
[0218] In one implementation, the processing unit 1402 is used to create a block execution graph according to the block execution indication information, and is specifically used to perform the following steps:
[0219] Identify transactions in a block as nodes in a block execution graph;
[0220] Determine the transaction execution indication information of the transaction in the block as the node value of the node in the block execution graph;
[0221] Determine the transaction dependencies between transactions in a block as directed edges between corresponding nodes in the block execution graph;
[0222] Among them, the directed edge connected to the target node in the block execution graph includes at least one of the following: an incoming edge and an outgoing edge; the existence of an incoming edge of the target node indicates that the target node depends on other nodes, and the other nodes are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge of the target node indicates that the target node is dependent on the reference node, and the reference node is connected to the target node through the outgoing edge of the target node; the target node is any node in the block execution graph.
[0223] In one implementation, the processing unit 1402 is used to convert the block execution graph into the block verification graph by performing the following steps:
[0224] Determine the starting node in the block execution graph; the starting node is a node in the block execution graph that has an incoming edge but no outgoing edge;
[0225] Determine a transition node connected to the start node through an incoming edge of the start node;
[0226] Using the node sum value between the start node and the transition node, update the node value of the transition node;
[0227] The conversion node is determined as the new starting node, and new conversion nodes are continuously determined, and the node values of the new conversion nodes are updated until all nodes in the block execution graph are traversed to obtain the block verification graph.
[0228] In one implementation, there are multiple starting nodes connected to the conversion node; the processing unit 1402 is used to use the node sum value between the starting node and the conversion node to update the node value of the conversion node, specifically for performing the following steps:
[0229] Determine the nodes and values between the transition node and each starting node respectively;
[0230] The node value of the transition node is updated by taking the maximum sum value among the node sum values between the transition node and each start node.
[0231] In one implementation, the block also includes the first transaction execution result of each of the multiple transactions; the processing unit 1402 is used to verify the multiple transactions in the verification order during the verification process of the block, and when the verification result of the block is obtained, it is specifically used to perform the following steps:
[0232] Execute multiple transactions in a verification order to obtain a second transaction execution result of each transaction in the multiple transactions;
[0233] If the first transaction execution result and the second transaction execution result of each transaction in the multiple transactions are the same, a verification result indicating that the block verification has passed is generated.
[0234] According to another embodiment of the present application, Fig.14 The various units in the block processing device shown can be separately or completely combined into one or several other units to form, or one (some) of the units can be further divided into multiple smaller units in function to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the block processing device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0235] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 5 or Fig.11 A computer program (including program code) for each step involved in part or all of the method executed by the verification node shown in the figure is used to construct a computer program (including program code) for each step involved in the method executed by the verification node shown in the figure Fig.14 The block processing device shown in the block processing device and the block processing method of the embodiment of the present application are implemented. The computer program can be recorded on a computer-readable storage medium, for example, and loaded into the above-mentioned computing device through the computer-readable storage medium and run therein.
[0236] In an embodiment of the present application, multiple transactions can be sorted according to the transaction dependency relationship between multiple transactions included in the block to be verified, and the transaction verification indication information of each transaction under the transaction dependency relationship, to obtain the verification order of the multiple transactions. Then, in the verification process of the block, the multiple transactions can be verified according to the verification order, and the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the beginning of verification of the transaction to the end of verification of all transactions in the dependency chain of the transaction. It can be seen that when sorting multiple transactions in the block, the estimated resource consumption information of each transaction under the transaction dependency relationship is taken into account, so that the verification order obtained by sorting is reasonable, so that in the verification process of the block, multiple transactions are verified according to a reasonable verification order, which can improve the verification efficiency of the block.
[0237] See also Fig.14 , Fig.14 It is a structural diagram of a block processing device provided in an embodiment of the present application. The block processing device can be set in a computer device provided in an embodiment of the present application, and the computer device can be a proposal node. Fig.14The block processing device shown may be a computer program (including program code) running in a computer device, and the block processing device may be used to execute Fig.10 or Fig.11 The method embodiment shown in the figure proposes some or all steps performed by the node. Fig.14 , the block processing device may include the following units:
[0238] The processing unit 1402 is used to obtain multiple transactions from the transaction pool;
[0239] The processing unit 1402 is further used to package the multiple transactions into a block to be verified, send the block to the verification node, and enable the verification node to sort the multiple transactions based on the block verification indication information of the block to obtain the verification order of the multiple transactions, and verify the multiple transactions according to the verification order during the verification process of the block to obtain the verification result of the block;
[0240] The communication unit 1401 is used to receive the verification result fed back by the verification node;
[0241] Among them, the block verification indication information includes the transaction dependency relationship between multiple transactions, and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction.
[0242] In one implementation, the processing unit 1402 is further configured to perform the following steps:
[0243] Obtaining block execution instruction information of the block, generating block verification instruction information according to the block execution instruction information, and sending the block verification instruction information to the verification node; or obtaining block execution instruction information of the block, and sending the block execution instruction information to the verification node, so that the verification node generates block verification instruction information according to the block execution instruction information;
[0244] The block execution indication information includes transaction dependencies and transaction execution indication information of each transaction; the transaction execution indication information of any transaction is used to indicate the separate resource consumption information for executing the corresponding transaction.
[0245] In one implementation, the processing unit 1402 is used to package multiple transactions into a block to be verified, and is specifically used to perform the following steps:
[0246] Create M transaction execution resources, where M is an integer greater than or equal to 2;
[0247] Use M transaction execution resources to execute multiple transactions concurrently;
[0248] Package multiple transactions and the transaction execution results of multiple transactions into blocks.
[0249] In one implementation, multiple transactions need to call N smart contracts for execution, where N is a positive integer; the processing unit 1402 is used to use M transaction execution resources to concurrently execute multiple transactions, specifically to perform the following steps:
[0250] When N is greater than or equal to M, each of the M transaction execution resources is used to execute a transaction under a smart contract;
[0251] When N is less than M, at least two of the M transaction execution resources are used to execute transactions under the same smart contract.
[0252] In one implementation, any one of the M transaction execution resources is a target transaction execution resource, the target transaction execution resource is used to execute a transaction under a target smart contract, the target smart contract includes a plurality of contract methods, and the transaction under the target smart contract is executed by calling at least one contract method among the plurality of contract methods;
[0253] The process of using the target transaction execution resource to execute the transaction under the target smart contract includes:
[0254] Get the resource consumption experience information of each contract method in the target smart contract;
[0255] Determine the execution resource consumption information required to execute the transaction under the target smart contract based on the resource consumption experience information of the contract method called by the transaction under the target smart contract;
[0256] According to the execution resource consumption information required to execute the transactions under the target smart contract, the transactions under the target smart contract are sorted to obtain the transaction execution order of the transactions under the target smart contract;
[0257] The target transaction execution resource is used to call the target smart contract, and the transactions under the target smart contract are executed in the transaction execution order.
[0258] In one implementation, transactions under a reference smart contract among N smart contracts need to be executed using P transaction execution resources among M transaction execution resources, where P is an integer greater than or equal to 2 and less than or equal to M; the reference smart contract includes multiple contract methods, and the P transaction execution resources are respectively used to call different contract methods in the reference smart contract; transactions under the reference smart contract are executed by calling at least one contract method among the multiple contract methods;
[0259] The process of using P transaction execution resources to execute transactions under the reference smart contract includes:
[0260] Get the resource consumption experience information of each contract method in the reference smart contract;
[0261] Determine the total resource consumption experience information of each contract method in the reference smart contract based on the resource consumption experience information of each contract method in the reference smart contract and the number of transactions under the corresponding contract method;
[0262] Based on the total resource consumption experience of each contract method in the reference smart contract, multiple contract methods are allocated to P transaction execution resources;
[0263] Use P transaction execution resources to call the allocated contract method and execute transactions under the allocated contract method.
[0264] According to another embodiment of the present application, Fig.14 The various units in the block processing device shown can be separately or completely combined into one or several other units to form, or one (some) of the units can be further divided into multiple smaller units in function to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the block processing device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0265] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Fig.10 or Fig.11 A computer program (including program code) of each step involved in part or all of the method performed by the proposal node shown is constructed as follows Fig.14 The block processing device shown in the block processing device and the block processing method of the embodiment of the present application are implemented. The computer program can be recorded on a computer-readable storage medium, for example, and loaded into the above-mentioned computing device through the computer-readable storage medium and run therein.
[0266] In an embodiment of the present application, multiple transactions can be sorted according to the transaction dependency relationship between multiple transactions included in the block to be verified, and the transaction verification indication information of each transaction under the transaction dependency relationship, to obtain the verification order of the multiple transactions. Then, in the verification process of the block, the multiple transactions can be verified according to the verification order, and the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the beginning of verification of the transaction to the end of verification of all transactions in the dependency chain of the transaction. It can be seen that when sorting multiple transactions in the block, the estimated resource consumption information of each transaction under the transaction dependency relationship is taken into account, so that the verification order obtained by sorting is reasonable, so that in the verification process of the block, multiple transactions are verified according to a reasonable verification order, which can improve the verification efficiency of the block.
[0267] Based on the above method and device embodiments, the present application embodiment provides a computer device, which may be a server in a digital collection sharing system. Fig.15 , Fig.15 It is a structural diagram of a computer device provided in an embodiment of the present application. Fig.15 The computer device shown includes at least a processor 1501, an input interface 1502, an output interface 1503, and a computer-readable storage medium 1504. The processor 1501, the input interface 1502, the output interface 1503, and the computer-readable storage medium 1504 may be connected via a bus or other means.
[0268] The computer-readable storage medium 1504 may be stored in the memory of the computer device. The computer-readable storage medium 1504 is used to store a computer program. The computer program includes computer instructions. The processor 1501 is used to execute the program instructions stored in the computer-readable storage medium 1504. The processor 1501 (or CPU (Central Processing Unit)) is the computing core and control core of the computer device, which is suitable for implementing one or more computer instructions, and is specifically suitable for loading and executing one or more computer instructions to implement the corresponding method flow or corresponding function.
[0269] The embodiment of the present application also provides a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides a storage space that stores the operating system of the computer device. In addition, one or more computer instructions suitable for being loaded and executed by the processor are also stored in the storage space. These computer instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory, or a non-volatile memory (Non-VolatileMemory), such as at least one disk storage; optionally, it can also be at least one computer-readable storage medium located away from the aforementioned processor.
[0270] In some embodiments, the processor 1501 may load and execute one or more computer instructions stored in the computer-readable storage medium 1504 to implement the above-mentioned Figure 5 or Fig.11 The corresponding steps performed by the verification node in the block processing method shown. In a specific implementation, the computer instructions in the computer-readable storage medium 1504 are loaded by the processor 1501 and execute the following steps:
[0271] Receive blocks to be verified sent by the proposal node; blocks include multiple transactions to be verified;
[0272] Obtain block verification indication information of a block; the block verification indication information includes transaction dependencies between multiple transactions and transaction verification indication information of each transaction under the transaction dependencies; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction;
[0273] Sorting multiple transactions according to the transaction dependency and transaction verification indication information of each transaction to obtain a verification order of the multiple transactions;
[0274] During the block verification process, multiple transactions are verified in the verification order to obtain the verification result of the block, and the verification result is fed back to the proposal node.
[0275] In one implementation, the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 to sort the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction to obtain the verification order of the multiple transactions, specifically for performing the following steps:
[0276] According to the transaction dependency, a first transaction belonging to a first order priority is determined among the multiple transactions; the first transaction is a transaction that has no dependent transaction among the multiple transactions;
[0277] Determining, according to a numerical relationship between the transaction verification indication information of each first transaction, a verification order of each first transaction under a first sequence priority;
[0278] According to the transaction dependency, determining a second transaction belonging to a second order priority among the multiple transactions; the second transaction is a transaction that depends on the first transaction among the multiple transactions;
[0279] Determining the verification order of each second transaction under the second sequence priority according to the numerical relationship between the transaction verification indication information of each second transaction;
[0280] Continue to determine the subsequent transactions belonging to the subsequent sequence priority, and determine the verification order of each subsequent transaction under the subsequent sequence priority; wherein the verification order of the first sequence priority is earlier than the second sequence priority.
[0281] In one implementation, the block verification indication information is read from a block verification graph; the block verification graph includes nodes and directed edges, the nodes in the block verification graph represent transactions in the block, the node values of the nodes in the block verification graph represent transaction verification indication information of the transactions in the block, and the directed edges in the block verification graph represent transaction dependencies between transactions in the block;
[0282] The directed edge connected to the target node in the block verification graph includes at least one of the following: an incoming edge and an outgoing edge; the existence of an incoming edge in the target node indicates that the target node depends on other nodes, and other nodes are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge in the target node indicates that the target node is dependent on the reference node, and the reference node is connected to the target node through the outgoing edge of the target node; the target node is any node in the block verification graph;
[0283] The first transaction is the transaction represented by the first node in the block verification graph, and the first node has an outgoing edge but no incoming edge; the second transaction is the transaction represented by the second node in the block verification graph, and the second node is connected to the outgoing edge of the first node.
[0284] In one implementation, when the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 to obtain the block verification indication information of the block, they are specifically used to perform the following steps:
[0285] Receive block verification instruction information sent by the proposal node; or, receive block execution instruction information sent by the proposal node, and generate block verification instruction information according to the block execution instruction information;
[0286] The block execution indication information includes transaction dependencies and transaction execution indication information of each transaction; the transaction execution indication information of any transaction is used to indicate the separate resource consumption information for executing the corresponding transaction.
[0287] In one implementation, when the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 to generate block verification instruction information according to the block execution instruction information, they are specifically used to perform the following steps:
[0288] Creating a block execution graph according to the block execution instruction information;
[0289] Convert the block execution graph into a block verification graph;
[0290] Read block verification instructions from the block verification graph.
[0291] In one implementation, when the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 to create a block execution graph according to the block execution instruction information, the computer instructions are specifically used to perform the following steps:
[0292] Identify transactions in a block as nodes in a block execution graph;
[0293] Determine the transaction execution indication information of the transaction in the block as the node value of the node in the block execution graph;
[0294] Determine the transaction dependencies between transactions in a block as directed edges between corresponding nodes in the block execution graph;
[0295] Among them, the directed edge connected to the target node in the block execution graph includes at least one of the following: an incoming edge and an outgoing edge; the existence of an incoming edge of the target node indicates that the target node depends on other nodes, and the other nodes are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge of the target node indicates that the target node is dependent on the reference node, and the reference node is connected to the target node through the outgoing edge of the target node; the target node is any node in the block execution graph.
[0296] In one implementation, when the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 to convert the block execution graph into the block verification graph, they are specifically used to perform the following steps:
[0297] Determine the starting node in the block execution graph; the starting node is a node in the block execution graph that has an incoming edge but no outgoing edge;
[0298] Determine a transition node connected to the start node through an incoming edge of the start node;
[0299] Using the node sum value between the start node and the transition node, update the node value of the transition node;
[0300] The conversion node is determined as the new starting node, and new conversion nodes are continuously determined, and the node values of the new conversion nodes are updated until all nodes in the block execution graph are traversed to obtain the block verification graph.
[0301] In one implementation, there are multiple starting nodes connected to the conversion node; when the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 and the node and value between the starting node and the conversion node are used to update the node value of the conversion node, they are specifically used to perform the following steps:
[0302] Determine the nodes and values between the transition node and each starting node respectively;
[0303] The node value of the transition node is updated by taking the maximum sum value among the node sum values between the transition node and each start node.
[0304] In one implementation, the block also includes the first transaction execution result of each of the multiple transactions; the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 during the verification process of the block, and the multiple transactions are verified in the verification order. When the verification result of the block is obtained, it is specifically used to perform the following steps:
[0305] Execute multiple transactions in a verification order to obtain a second transaction execution result of each transaction in the multiple transactions;
[0306] If the first transaction execution result and the second transaction execution result of each transaction in the multiple transactions are the same, a verification result indicating that the block verification has passed is generated.
[0307] In other embodiments, the processor 1501 may load and execute one or more computer instructions stored in the computer-readable storage medium 1504 to implement the above-mentioned Figure 5 or Fig.11 The corresponding steps performed by the proposal node in the block processing method shown. In a specific implementation, the computer instructions in the computer-readable storage medium 1504 are loaded by the processor 1501 and execute the following steps:
[0308] Get multiple transactions from the transaction pool;
[0309] Packing multiple transactions into a block to be verified, sending the block to a verification node, allowing the verification node to sort the multiple transactions based on the block verification indication information of the block to obtain the verification order of the multiple transactions, and in the verification process of the block, verifying the multiple transactions according to the verification order to obtain the verification result of the block;
[0310] Receive verification results from verification nodes;
[0311] Among them, the block verification indication information includes the transaction dependency relationship between multiple transactions, and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction.
[0312] In one implementation, the computer instructions in the computer readable storage medium 1504 are loaded by the processor 1501 and are further used to perform the following steps:
[0313] Obtaining block execution instruction information of the block, generating block verification instruction information according to the block execution instruction information, and sending the block verification instruction information to the verification node; or obtaining block execution instruction information of the block, and sending the block execution instruction information to the verification node, so that the verification node generates block verification instruction information according to the block execution instruction information;
[0314] The block execution indication information includes transaction dependencies and transaction execution indication information of each transaction; the transaction execution indication information of any transaction is used to indicate the separate resource consumption information for executing the corresponding transaction.
[0315] In one implementation, when the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 to package multiple transactions into a block to be verified, they are specifically used to perform the following steps:
[0316] Create M transaction execution resources, where M is an integer greater than or equal to 2;
[0317] Use M transaction execution resources to execute multiple transactions concurrently;
[0318] Package multiple transactions and the transaction execution results of multiple transactions into blocks.
[0319] In one implementation, multiple transactions require calling N smart contracts for execution, where N is a positive integer; when the computer instructions in the computer-readable storage medium 1504 are loaded and executed by the processor 1501 and multiple transactions are executed concurrently using M transaction execution resources, the computer instructions are specifically used to perform the following steps:
[0320] When N is greater than or equal to M, each of the M transaction execution resources is used to execute a transaction under a smart contract;
[0321] When N is less than M, at least two of the M transaction execution resources are used to execute transactions under the same smart contract.
[0322] In one implementation, any one of the M transaction execution resources is a target transaction execution resource, the target transaction execution resource is used to execute a transaction under a target smart contract, the target smart contract includes a plurality of contract methods, and the transaction under the target smart contract is executed by calling at least one contract method among the plurality of contract methods;
[0323] The process of using the target transaction execution resource to execute the transaction under the target smart contract includes:
[0324] Get the resource consumption experience information of each contract method in the target smart contract;
[0325] Determine the execution resource consumption information required to execute the transaction under the target smart contract based on the resource consumption experience information of the contract method called by the transaction under the target smart contract;
[0326] According to the execution resource consumption information required to execute the transactions under the target smart contract, the transactions under the target smart contract are sorted to obtain the transaction execution order of the transactions under the target smart contract;
[0327] The target transaction execution resource is used to call the target smart contract, and the transactions under the target smart contract are executed in the transaction execution order.
[0328] In one implementation, transactions under a reference smart contract among N smart contracts need to be executed using P transaction execution resources among M transaction execution resources, where P is an integer greater than or equal to 2 and less than or equal to M; the reference smart contract includes multiple contract methods, and the P transaction execution resources are respectively used to call different contract methods in the reference smart contract; transactions under the reference smart contract are executed by calling at least one contract method among the multiple contract methods;
[0329] The process of using P transaction execution resources to execute transactions under the reference smart contract includes:
[0330] Get the resource consumption experience information of each contract method in the reference smart contract;
[0331] Determine the total resource consumption experience information of each contract method in the reference smart contract based on the resource consumption experience information of each contract method in the reference smart contract and the number of transactions under the corresponding contract method;
[0332] Based on the total resource consumption experience of each contract method in the reference smart contract, multiple contract methods are allocated to P transaction execution resources;
[0333] Use P transaction execution resources to call the allocated contract method and execute transactions under the allocated contract method.
[0334] In an embodiment of the present application, multiple transactions can be sorted according to the transaction dependency relationship between multiple transactions included in the block to be verified, and the transaction verification indication information of each transaction under the transaction dependency relationship, to obtain the verification order of the multiple transactions. Then, in the verification process of the block, the multiple transactions can be verified according to the verification order, and the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the beginning of verification of the transaction to the end of verification of all transactions in the dependency chain of the transaction. It can be seen that when sorting multiple transactions in the block, the estimated resource consumption information of each transaction under the transaction dependency relationship is taken into account, so that the verification order obtained by sorting is reasonable, so that in the verification process of the block, multiple transactions are verified according to a reasonable verification order, which can improve the verification efficiency of the block.
[0335] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the block processing method provided in the above-mentioned various optional modes.
[0336] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A block processing method, characterized in that: include: Receive a block to be verified sent by a proposal node; the block includes multiple transactions to be verified; Obtaining block verification indication information of the block; The block verification indication information includes the transaction dependency relationship between the multiple transactions and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the completion of verification of all transactions in the dependency chain of the corresponding transaction; Sorting the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction to obtain a verification order of the multiple transactions; During the verification process of the block, the multiple transactions are verified in the verification order to obtain the verification result of the block, and the verification result is fed back to the proposal node.
2. The method according to claim 1, characterized in that The step of sorting the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction to obtain the verification order of the multiple transactions includes: According to the transaction dependency, determining a first transaction of a first priority level among the multiple transactions; the first transaction is a transaction without any dependent transaction among the multiple transactions; determining, according to a numerical relationship between the transaction verification indication information of each of the first transactions, a verification order of each of the first transactions under the first sequence priority; According to the transaction dependency, determining a second transaction belonging to a second order priority among the multiple transactions; the second transaction is a transaction among the multiple transactions that depends on the first transaction; determining, according to a numerical relationship between the transaction verification indication information of each of the second transactions, a verification order of each of the second transactions under the second sequence priority; Continue to determine subsequent transactions belonging to the subsequent sequence priority, and determine the verification order of each of the subsequent transactions under the subsequent sequence priority; wherein the verification order of the first sequence priority is earlier than that of the second sequence priority.
3. The method according to claim 2, characterized in that The block verification indication information is read from a block verification graph; the block verification graph includes nodes and directed edges, the nodes in the block verification graph represent transactions in the block, the node values of the nodes in the block verification graph represent transaction verification indication information of the transactions in the block, and the directed edges in the block verification graph represent transaction dependencies between transactions in the block; The directed edge connected to the target node in the block verification graph includes at least one of the following: an incoming edge and an outgoing edge; the existence of an incoming edge of the target node indicates that the target node depends on other nodes, and the other nodes are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge of the target node indicates that the target node is dependent on a reference node, and the reference node is connected to the target node through the outgoing edge of the target node; The target node is any node in the block verification graph; The first transaction is a transaction represented by a first node in the block verification graph, and the first node has an outgoing edge but no incoming edge; the second transaction is a transaction represented by a second node in the block verification graph, and the second node is connected to the outgoing edge of the first node.
4. The method according to claim 1, characterized in that The obtaining block verification indication information of the block includes: receiving the block verification instruction information sent by the proposal node; or, Receiving the block execution instruction information sent by the proposal node, and generating the block verification instruction information according to the block execution instruction information; The block execution indication information includes the transaction dependency and the transaction execution indication information of each transaction; the transaction execution indication information of any transaction is used to indicate the separate resource consumption information for executing the corresponding transaction.
5. The method according to claim 1, characterized in that The generating the block verification indication information according to the block execution indication information includes: Creating a block execution graph according to the block execution instruction information; Converting the block execution graph into a block verification graph; The block verification indication information is read from the block verification map.
6. The method according to claim 5, characterized in that The creating a block execution graph according to the block execution indication information includes: Determining transactions in the block as nodes in the block execution graph; Determine the transaction execution indication information of the transaction in the block as the node value of the node in the block execution graph; Determining transaction dependencies between transactions in the block as directed edges between corresponding nodes in the block execution graph; Among them, the directed edge connected to the target node in the block execution graph includes at least one of the following: an incoming edge and an outgoing edge; the existence of an incoming edge of the target node indicates that the target node depends on other nodes, and the other nodes are connected to the target node through the incoming edge of the target node; the existence of an outgoing edge of the target node indicates that the target node is dependent on a reference node, and the reference node is connected to the target node through the outgoing edge of the target node; the target node is any node in the block execution graph.
7. The method according to claim 6, characterized in that The converting the block execution graph into a block verification graph includes: Determine a starting node in the block execution graph; the starting node is a node in the block execution graph that has an incoming edge but no outgoing edge; Determine a transition node connected to the start node through an incoming edge of the start node; Using the node sum value between the starting node and the transition node, updating the node value of the transition node; The conversion node is determined as a new starting node, new conversion nodes are continuously determined, and node values of the new conversion nodes are updated until all nodes in the block execution graph are traversed to obtain the block verification graph.
8. The method according to claim 7, characterized in that The number of the starting nodes connected to the conversion node is multiple; the adopting the node sum value between the starting node and the conversion node to update the node value of the conversion node includes: respectively determining nodes and values between the conversion node and each of the starting nodes; The node value of the conversion node is updated by adopting the maximum sum value among the node sum values between the conversion node and each of the start nodes.
9. The method according to claim 1, characterized in that The block also includes a first transaction execution result of each of the multiple transactions; during the verification process of the block, the multiple transactions are verified in the verification order to obtain the verification result of the block, including: Execute the multiple transactions according to the verification order to obtain a second transaction execution result of each transaction in the multiple transactions; If the first transaction execution result and the second transaction execution result of each transaction in the multiple transactions are the same, then the verification result of passing the verification of the block is generated.
10. A block processing method, characterized in that: include: Get multiple transactions from the transaction pool; Packing the multiple transactions into a block to be verified, sending the block to a verification node, causing the verification node to sort the multiple transactions based on the block verification indication information of the block to obtain a verification order of the multiple transactions, and in a verification process of the block, verifying the multiple transactions according to the verification order to obtain a verification result of the block; Receiving the verification result fed back by the verification node; The block verification indication information includes the transaction dependency relationship between the multiple transactions and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the end of verification of all transactions in the dependency chain of the corresponding transaction.
11. The method according to claim 10, characterized in that The method further comprises: acquiring block execution instruction information of the block, generating the block verification instruction information according to the block execution instruction information, and sending the block verification instruction information to the verification node; or, Acquire block execution instruction information of the block, and send the block execution instruction information to the verification node, so that the verification node generates the block verification instruction information according to the block execution instruction information; The block execution indication information includes the transaction dependency and the transaction execution indication information of each transaction; the transaction execution indication information of any transaction is used to indicate the separate resource consumption information for executing the corresponding transaction.
12. The method according to claim 10, characterized in that Packaging the multiple transactions into a block to be verified includes: Create M transaction execution resources, where M is an integer greater than or equal to 2; Using the M transaction execution resources to concurrently execute the multiple transactions; The multiple transactions and transaction execution results of the multiple transactions are packaged into the block.
13. The method according to claim 12, characterized in that The multiple transactions require calling N smart contracts for execution, where N is a positive integer; and the using the M transaction execution resources to concurrently execute the multiple transactions includes: When N is greater than or equal to M, each of the M transaction execution resources is used to execute a transaction under a smart contract respectively; When N is less than M, at least two of the M transaction execution resources are used to execute transactions under the same smart contract.
14. The method according to claim 13, characterized in that Any one of the M transaction execution resources is a target transaction execution resource, and the target transaction execution resource is used to execute transactions under a target smart contract, and the target smart contract includes multiple contract methods, and the transaction under the target smart contract is executed by calling at least one contract method among the multiple contract methods; The process of using the target transaction execution resource to execute the transaction under the target smart contract includes: Obtaining resource consumption experience information of each contract method in the target smart contract; Determine the execution resource consumption information required to execute the transaction under the target smart contract based on the resource consumption experience information of the contract method called by the transaction under the target smart contract; Sort the transactions under the target smart contract according to the execution resource consumption information required to execute the transactions under the target smart contract to obtain the transaction execution order of the transactions under the target smart contract; The target transaction execution resource is used to call the target smart contract, and the transaction under the target smart contract is executed according to the transaction execution order.
15. The method according to claim 13, characterized in that The transaction under the reference smart contract among the N smart contracts needs to be executed using P transaction execution resources among the M transaction execution resources, where P is an integer greater than or equal to 2 and less than or equal to M; the reference smart contract includes multiple contract methods, and the P transaction execution resources are respectively used to call different contract methods in the reference smart contract; The transaction under the reference smart contract is executed by calling at least one contract method among the multiple contract methods; The process of using the P transaction execution resources to execute the transaction under the reference smart contract includes: Obtaining resource consumption experience information of each contract method in the reference smart contract; Determine the total resource consumption experience information of each contract method in the reference smart contract according to the resource consumption experience information of each contract method in the reference smart contract and the number of transactions under the corresponding contract method; Allocate the multiple contract methods to the P transaction execution resources according to the total resource consumption experience information of each contract method in the reference smart contract; The P transaction execution resources are used to call the allocated contract method and execute transactions under the allocated contract method.
16. A block processing device, characterized in that: include: A communication unit, configured to receive a block to be verified sent by a proposal node; the block includes a plurality of transactions to be verified; A processing unit, configured to obtain block verification indication information of the block; the block verification indication information includes the transaction dependency relationship between the multiple transactions and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the end of verification of all transactions in the dependency chain of the corresponding transaction; The processing unit is further configured to sort the multiple transactions according to the transaction dependency and the transaction verification indication information of each transaction to obtain a verification order of the multiple transactions; The processing unit is further used to verify the multiple transactions in the verification order during the verification process of the block, obtain the verification result of the block, and feed back the verification result to the proposal node.
17. A block processing device, characterized in that: include: A processing unit, used to obtain multiple transactions from the transaction pool; The processing unit is further configured to package the multiple transactions into a block to be verified, send the block to a verification node, and enable the verification node to sort the multiple transactions based on the block verification indication information of the block to obtain a verification order of the multiple transactions, and verify the multiple transactions according to the verification order during the verification process of the block to obtain a verification result of the block; A communication unit, configured to receive the verification result fed back by the verification node; The block verification indication information includes the transaction dependency relationship between the multiple transactions and the transaction verification indication information of each transaction under the transaction dependency relationship; the transaction verification indication information of any transaction is used to indicate the estimated resource consumption information required from the start of verification of the corresponding transaction to the end of verification of all transactions in the dependency chain of the corresponding transaction.
18. A computer device, characterized in that: The computer device comprises: a processor suitable for implementing a computer program; A computer-readable storage medium storing a computer program, wherein the computer program is suitable for being loaded by the processor and executing the block processing method according to any one of claims 1 to 9, or the block processing method according to any one of claims 10 to 15.
19. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the block processing method according to any one of claims 1 to 9, or the block processing method according to any one of claims 10 to 15.
20. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed by a processor, the block processing method according to any one of claims 1 to 9 or the block processing method according to any one of claims 10 to 15 is implemented.
