Blockchain transaction processing method, related device, and medium
By introducing target relay nodes and relay contracts into blockchain transaction processing, support for terminal personalized signature algorithms on the blockchain network is achieved, which solves the lack of quantum attack resistance and business compatibility of signature algorithms in the existing technology. Inadequate issues have been addressed and the security and compatibility of transaction processing have been improved.
Patent Information
- Application Number
- PCT/CN2023/124129
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-01-31
- Filing Date
- 2023-10-12
- Publication Date
- 2024-09-19
AI Technical Summary
In existing blockchain transaction processing technology, signature algorithms lack the ability to resist quantum attacks and are not flexible enough, making it difficult to meet the business compatibility requirements of zero-knowledge proof-related applications.
By introducing the target relay node, the terminal's signature sub-request is packaged and a universal signature is generated. After verifying the signature using the universal signature algorithm of the blockchain node, the relay contract is called to perform the second layer signature verification with the personalized terminal contract. Support terminals to use personalized signature algorithms on the blockchain network.
It improves the security and business compatibility of transaction processing, ensures information security and adapts to different business needs.
Smart Images

Figure CN2023124129_19092024_PF_FP_ABST
Abstract
Description
Blockchain transaction processing method, related equipment and media
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on January 31, 2023, application number 202310145364.8, and application name “Blockchain transaction processing method, related equipment and medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] This application relates to the field of blockchain, and in particular to a blockchain transaction processing technology. Background Art
[0003] When a terminal generates a transaction that needs to be uploaded to the blockchain, it must sign the transaction and send it to the blockchain node for verification. Once the signature is verified, consensus is reached and the transaction is uploaded to the blockchain. In related technologies, the terminal must use the signature algorithm provided by the consensus layer when signing, and the blockchain node must also use the corresponding signature algorithm when verifying the signature. However, this signature algorithm lacks quantum attack resistance and is easily cracked by third parties. Furthermore, this signature algorithm lacks flexibility in terms of business compatibility, hindering the development of zero-knowledge proof-related applications.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide a blockchain transaction processing method, related devices, and media, which can support terminals to use personalized signature algorithms on blockchain networks, improve business compatibility, and improve resistance to quantum attacks.
[0006] According to one aspect of the present application, a blockchain transaction processing method is provided, wherein the blockchain transaction processing method is used for a blockchain node, comprising:
[0007] receiving a transaction request and a first signature of the transaction request from a target relay node, wherein the first signature is generated by signing the transaction request using a first signature algorithm of the blockchain node, the transaction request includes a transaction subrequest received by the target relay node from a terminal, the transaction subrequest having a second signature, and the second signature is generated using a second signature algorithm in a terminal contract of the terminal;
[0008] Performing a first signature verification on the first signature using the first signature algorithm;
[0009] After determining that the first signature verification is successful, the relay contract of the target relay node is called, and a transaction sub-request is obtained from the transaction request based on the relay contract. The terminal contract of the terminal corresponding to the transaction sub-request is called, and the second signature algorithm in the terminal contract is used to perform a second signature verification on the transaction sub-request.
[0010] According to one aspect of the present application, a blockchain node is provided, comprising:
[0011] a first receiving unit, configured to receive a transaction request and a first signature of the transaction request from a target relay node, wherein the first signature is generated by signing the transaction request using a first signature algorithm of the blockchain node, the transaction request includes a transaction subrequest received by the target relay node from a terminal, the transaction subrequest has a second signature, and the second signature is generated using a second signature algorithm in a terminal contract of the terminal;
[0012] a first signature verification unit, configured to perform a first signature verification on the first signature using the first signature algorithm;
[0013] The second signature verification unit is used to call the relay contract of the target relay node after determining that the first signature verification is successful, obtain a transaction sub-request from the transaction request based on the relay contract, and call the terminal contract of the terminal corresponding to the transaction sub-request, and use the second signature algorithm in the terminal contract to perform a second signature verification on the transaction sub-request.
[0014] According to one aspect of the present application, an electronic device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the blockchain transaction processing method as described above when executing the computer program.
[0015] According to one aspect of the present application, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the blockchain transaction processing method as described above is implemented.
[0016] According to one aspect of the present application, a computer program product is provided, which includes a computer program, and the computer program is read and executed by a processor of a computer device, so that the computer device performs the blockchain transaction processing method as described above.
[0017] In this embodiment of the present application, the terminal does not directly request the blockchain node to execute the transaction and upload it to the blockchain. Instead, it sends a transaction subrequest to the target relay node. The target relay node then incorporates the transaction subrequest into the transaction request, generates a first signature, and sends it to the blockchain node. This first signature is generated using a common first signature algorithm for blockchain nodes, allowing it to be successfully verified by the blockchain node. After verification, the target relay node's relay contract is invoked. As a smart contract, a relay contract can specify any customized processing. The relay node specifies in the relay contract that, when executing the relay contract, the transaction subrequest within the transaction request is extracted and the corresponding terminal contract is invoked for second signature verification. This second signature verification is personalized. The terminal's terminal contract contains an object-specific second signature algorithm, and the transaction subrequest contains a second signature signed using the customized second signature algorithm. Therefore, the customized second signature algorithm in the terminal contract can be used to perform personalized verification on the second signature of the transaction subrequest signed using the customized second signature algorithm. In this way, this embodiment of the present application enables terminals to use customized signature algorithms on blockchain networks, improving service compatibility and resistance to quantum attacks. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings are used to provide a further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0019] FIG1 is a system architecture diagram of a system for applying the blockchain transaction processing method provided in an embodiment of the present application;
[0020] Figures 2A-2H are schematic diagrams of the blockchain transaction processing method provided by an embodiment of the present application applied in a virtual resource transfer scenario;
[0021] FIG3 is a flowchart of a blockchain transaction processing method provided by an embodiment of the present application;
[0022] FIG4 is a flow chart of the process of generating a transaction request in step 310 of FIG3 ;
[0023] 5A-5C are schematic diagrams of the structure of the transaction sub-request in step 410 of FIG. 4 ;
[0024] FIG6 is an example flow chart of step 430 of FIG4 ;
[0025] FIG7 is another system architecture diagram of a system for applying the blockchain transaction processing method provided in an embodiment of the present application;
[0026] 8A-8B are two flow charts of step 410 in FIG. 4 ;
[0027] FIG9 is a specific flow chart of executing the relay contract of the target relay node in step 330 in FIG3 ;
[0028] FIG10 is a schematic diagram of a structure of a transaction request in step 910 in FIG9 ;
[0029] FIG11 is a flow chart of step 920 in FIG9 ;
[0030] FIG12 is a schematic diagram of the structure of the first block in step 1120 of FIG11 ;
[0031] FIG13 is a specific flow chart of the process of formulating the relay contract in step 330;
[0032] FIG14 is a specific flow chart of calling a terminal contract in step 330 of FIG3 ;
[0033] FIG15 is a specific flow chart of the process of calling the terminal contract corresponding to the terminal identifier in step 1420 of FIG14;
[0034] FIG16 is a specific flow chart of the process of formulating the terminal contract in step 330;
[0035] FIG17 is a detailed flow chart showing the process of executing a transaction logic contract based on FIG3 ;
[0036] FIG18 is a specific flow chart of calling a transaction logic contract corresponding to a transaction type in step 1720 of FIG17 ;
[0037] FIG19 is a specific flow chart showing a process of notifying the target terminal of the execution result after adding the process of notifying the target terminal of the execution result based on FIG17;
[0038] 20A-20B are schematic diagrams of the results of the integration execution in step 1910 in FIG. 19 ;
[0039] FIG21 is a more detailed flowchart of the blockchain transaction processing method according to an embodiment of the present application;
[0040] FIG22 is a module diagram of a blockchain node provided in an embodiment of the present application;
[0041] FIG23 is a diagram showing the structure of a terminal for implementing the blockchain transaction processing method shown in FIG3 according to an embodiment of the present application;
[0042] FIG24 is a server structure diagram for implementing the blockchain transaction processing method shown in FIG3 according to an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0044] Before further explaining the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations:
[0045] Blockchain: Blockchain is a new application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a series of data blocks linked using cryptographic methods. Each block contains information about a batch of transactions, used to verify the validity of the information (to prevent counterfeiting) and link it to the previous block.
[0046] Signature algorithms: Signature algorithms are a crucial component of blockchain security. Blockchain addresses, public keys, and private keys are all related to signature algorithms. Blockchain ownership is established through private keys, blockchain addresses, and digital signatures. Private keys are owned by the subject and stored only on the subject's terminal. Ownership authentication and management are based on signature algorithms, so trust in blockchains is built on the successful verification of signature algorithms.
[0047] Smart contract: It is a piece of code written on the blockchain. Once the terms of the contract are triggered in the blockchain at a certain time, the code will be automatically executed.
[0048] Many applications are now using blockchain networks because their decentralized nature offers the following advantages: strong fault tolerance, vulnerability to attacks, and data tamper-proofing. This allows users to trust applications that deploy blockchains. With the increasing activity of off-chain objects on blockchains, more and more transactions need to be processed on-chain. Consequently, there is a need to ensure both information security and business compatibility during the on-chain transaction process.
[0049] In related technologies, the specific implementation method for on-chain transactions is as follows: when a terminal generates a transaction that needs to be uploaded to the blockchain, the terminal signs the transaction and sends the transaction and signature to the blockchain node. The blockchain node verifies the signature, and after the signature is verified, the consensus is uploaded to the blockchain. This implementation method has two drawbacks: first, the terminal must use the consensus layer's unified signature algorithm when signing, and the blockchain node will only use this signature algorithm when verifying the signature. However, this unified signature algorithm is not resistant to quantum attacks and can be easily cracked by third parties, making it impossible to guarantee information security. Second, some businesses require different signature algorithms. Therefore, it is not flexible in terms of business compatibility, which is not conducive to the development of zero-knowledge proof-related applications.
[0050] The embodiments of the present application can use different signature algorithms for signature verification, thereby improving the security and business compatibility of transactions on the chain.
[0051] System architecture and scenario description of the application examples
[0052] Figure 1 is a system architecture diagram of the blockchain transaction processing method application of an embodiment of the present application, which includes a terminal, a target relay node, a blockchain node, and a contract customization node.
[0053] Terminals are used to initiate blockchain transaction requests. These can take the form of desktop computers, laptops, mobile phones, personal digital assistants (PDAs), vehicle-mounted terminals, dedicated terminals, servers, and more. Blockchain transaction requests are requests that require blockchain transactions, such as virtual resource exchange or transfers, virtual resource queries, and so on. Transactions can be signed by a subject, typically a user.
[0054] The target relay node is used to receive transaction sub-requests and terminal signatures (e.g., second signatures) from multiple terminals, package the received multiple transaction sub-requests and terminal signatures to form a transaction request, sign the transaction request on the target relay node side (e.g., first signature), and send the transaction request and the signature of the target relay node to the blockchain node.
[0055] The blockchain node is the core processing unit of the blockchain transaction processing method in the embodiments of the present application. It verifies the signatures of the transaction request issued by the relay node and the target relay node (e.g., the first signature verification). After the signature verification is successful, it calls the relay contract to retrieve the terminal contract corresponding to each transaction sub-request. Each transaction sub-request may use a different signature algorithm due to different business operations. Therefore, it is necessary to call the corresponding terminal contract for each transaction sub-request to verify the signature (e.g., the second signature verification) in order to process the transaction. The general signature verification process of the blockchain node cannot support this. Therefore, the embodiments of the present application hide this personalized signature verification process in the process of executing the relay contract after the signature verification of the target relay node is successful. As a smart contract, the relay contract can specify any personalized processing. This is also the key to the blockchain transaction processing method in the embodiments of the present application being able to use different signature algorithms to sign transaction requests to ensure information security and business compatibility. The specific implementation method will be expanded in the detailed description below. The blockchain node is also used to receive contract formulation rules from different nodes and send the contract formulation rules to the contract formulation node. Blockchain nodes can communicate with each other for data transmission.
[0056] The contract creation node is a unit used to generate contracts. It encodes the received contract creation rules and transmits the created contract to the blockchain node for storage.
[0057] The embodiments of the present application can be applied in various scenarios, such as the scenario of virtual resource transfer shown in Figures 2A to 2H.
[0058] Blockchain can be used to transfer virtual resources between accounts. If an entity has a virtual resource account in a blockchain network, it can operate on the virtual resource within blockchain processing applications. Typically, when transferring virtual resources, the terminal signs the transaction request once and then sends it to the blockchain node for upload. The signature algorithm used is fixed. However, this method is vulnerable to attacks during transmission, threatening information security. This has led to the need for less vulnerable transaction processing methods to ensure information security.
[0059] The transaction processing method of the embodiment of the present application can meet this demand. The object can choose different signature algorithms to sign the virtual resource transfer request. However, if the blockchain node uses a new signature algorithm to verify the signature every time it receives a new request, the efficiency of transaction processing will be very low. Therefore, the processing method of the embodiment of the present application sets up a relay node to package multiple transaction sub-requests and sign the packaged transaction requests once. In this way, the blockchain node first verifies the signature of the transaction request once, and then processes each transaction sub-request one by one after the verification is passed. This not only avoids the problem of reduced processing efficiency, but also retains the different signature algorithms used by different transaction sub-requests, effectively improving the security of transaction processing.
[0060] For example, object A wants to transfer 20 virtual resources to object B.
[0061] As shown in Figure 2A, Object A's blockchain processing application displays his account information, including his account name and virtual resource account balance. Currently, Object A's virtual resource account balance is 100 virtual resources. Object A can select the "Virtual Resource Transfer" function to generate a virtual resource transfer transaction request to transfer virtual resources to Object B's account.
[0062] After object A selects the "Virtual Resource Transfer" function, the interface changes to Figure 2B, where object A needs to enter object B and the number of virtual resources to be transferred. As shown in the figure, object A wants to transfer 20 virtual resources to object B.
[0063] After Subject A confirms the virtual resource transfer information, the blockchain processing application generates a transfer request. At this point, as shown in Figure 2C, Subject A is required to select a signature algorithm to sign the transfer request. The blockchain processing application displays a "Please Select Signature Algorithm" window. The signature algorithm can be customized by the subject, and Subject A selects Signature Algorithm A.
[0064] As shown in Figure 2D, after Object A selects a signature algorithm, the blockchain processing application generates a signature for the transfer request based on the corresponding signature algorithm and sends the transfer request and signature to the target relay node. A pop-up window appears in the application stating, "Signed using signature algorithm A and sent to target relay node. Waiting for target relay node to package and submit."
[0065] As shown in Figure 2E, the target relay node packages the transfer request (i.e., the transaction subrequest sent by target A's terminal) and its signature with the transaction subrequests and signatures received from other terminals and transmits them to the blockchain node. A pop-up window appears in the blockchain processing application, stating that the target relay node has submitted the request to the blockchain node, awaiting verification by the blockchain node.
[0066] As shown in Figure 2F, the blockchain node performs signature verification on the transfer request. After successful verification, the virtual resource transfer is performed. A pop-up window appears in the blockchain processing application interface prompting "Blockchain node verification is successful, and virtual resource transfer is in progress."
[0067] As shown in Figure 2G, the blockchain network completes the virtual resource transfer and feeds back the processing results to Subject A. Subject A is the initiator of the transfer request. A pop-up window appears on Subject A's blockchain processing application, prompting "Virtual resource transfer successful." At this point, Subject A's virtual resource account balance is 80 virtual resources.
[0068] As shown in Figure 2H, the blockchain network completes the virtual resource transfer and feeds back the processing results to Object B. Object B is the recipient of the virtual resources. A pop-up window appears on Object B's blockchain processing application, prompting "20 virtual resources received." Before receiving the virtual resources, Object B's virtual resource account balance was 0, but now it has 20 virtual resources.
[0069] General description of the embodiments of this application
[0070] According to one embodiment of the present application, a blockchain transaction processing method is provided. Blockchain transaction processing specifically refers to processing transaction requests from outside the blockchain and uploading the processing results to the blockchain. The blockchain transaction processing method is executed by blockchain nodes in a blockchain network.
[0071] As shown in FIG3 , according to one embodiment of the present application, a blockchain transaction processing method includes:
[0072] Step 310: Receive a transaction request and a first signature of the transaction request from a target relay node;
[0073] Step 320: Perform a first signature verification on the first signature using a first signature algorithm;
[0074] Step 330: After determining that the first signature verification is successful, call the relay contract of the target relay node, obtain the transaction sub-request from the transaction request based on the relay contract, and call the terminal contract of the terminal corresponding to the transaction sub-request, and use the second signature algorithm in the terminal contract to perform a second signature verification on the transaction sub-request.
[0075] Steps 310 - 330 are briefly described below.
[0076] The first signature in step 310 is generated by signing the transaction request using the blockchain node's first signature algorithm. The first signature algorithm is the signature algorithm specified by the blockchain network for sending transaction requests. It is often consistent with the signature algorithm used by each blockchain node during pre-on-chain consensus, otherwise consensus will be difficult. A transaction request is a collection of multiple transaction sub-requests, consisting of transaction sub-requests received by the target relay node from different terminals. A transaction sub-request is a terminal-generated transaction sub-request containing a second signature. This second signature is generated using the second signature algorithm in the terminal's terminal contract. The second signature algorithm can be customized by the client to meet different business needs. The terminal contract is a smart contract established between the terminal and the blockchain network. It can specify customized processing based on the client's needs, such as a customized signature algorithm. Different transaction sub-requests within a transaction request may use different second signature algorithms, which improves transaction processing security and business compatibility.
[0077] Signing can refer to using a digest algorithm (such as a hash algorithm) to generate a digest of the signature subject, and then encrypting the digest using the signer's private key (or public key). Signature algorithms can differ in, for example, the use of different digest algorithms. When generating the first signature, the target relay node uses a universal (non-personalized) digest algorithm to generate a digest of the transaction request and encrypts the digest using the blockchain node's public key. When generating the second signature, the terminal uses a terminal-specific digest algorithm to generate a digest of the generated transaction subrequest and encrypts the digest using the terminal's private key.
[0078] In step 320, the first signature generated in step 310 is verified on the blockchain node using the first signature algorithm.
[0079] Signature verification can refer to decrypting the signature using the signer's public key (or private key), applying a digest algorithm (such as a hash algorithm) to the signature, and comparing the decrypted result with the digest. If the two match, the verification is successful. When performing the first signature verification on the first signature, the blockchain node decrypts the first signature using the blockchain node's private key, uses a universal digest algorithm (non-personalized) to digest the transaction request, and compares the decrypted result with the digest. If the two match, the verification is successful.
[0080] In step 330, after confirming the success of the first signature verification, the target relay node's relay contract is invoked. The target relay node's relay contract invokes the corresponding terminal contract based on the transaction subrequest in the transaction request. The terminal contract verifies the transaction subrequest using the object's customized second signature algorithm and executes the transaction subrequest.
[0081] The relay contract is a smart contract concluded between the relay node and the blockchain network. It can specify some personalized processing of the relay node according to the needs of the relay node. For example, in the embodiment of the present application, the relay contract stipulates that for each transaction sub-request included in the transaction request, the terminal contract corresponding to each transaction sub-request shall be executed one by one, and the terminal contract stipulates that the transaction sub-request shall be verified using the second signature algorithm personalized for each terminal. In this way, the personalized signature algorithm required by the terminal can be verified without violating the general signature verification process.
[0082] When verifying the second signature, the second verification method can be that the terminal contract uses the corresponding terminal's public key to decrypt the second signature, uses the terminal's personalized digest algorithm to request a digest for the transaction sub-request, and compares the decryption result with the digest. If the two are consistent, the verification is successful.
[0083] The above is a brief description of steps 310-330. The following will describe in detail the specific implementation of each step of steps 310-330.
[0084] Detailed description of step 310
[0085] In step 310, the blockchain node receives the transaction request and the first signature from the target relay node.
[0086] A transaction request is composed of multiple transaction sub-requests. As shown in FIG4 , in one embodiment, the process of generating a transaction request includes:
[0087] Step 410: Receive multiple transaction sub-requests from multiple terminals;
[0088] Step 420: Group multiple transaction sub-requests.
[0089] Step 430: Pack the transaction sub-requests in the same sub-request group to generate a transaction request.
[0090] Steps 410-430 are performed by the target relay node. The following is a detailed description of steps 410-430.
[0091] In step 410, the target relay node receives multiple transaction sub-requests in various ways.
[0092] In one embodiment, a target relay node receives multiple transaction subrequests directly from multiple terminals, without passing through any other intermediate nodes. This can occur in two scenarios. In one scenario, the target relay node is the only relay node. Any terminal generating a transaction subrequest can only send it to that target relay node. In another scenario, there are multiple relay nodes, but the terminals and relay nodes are bound to each other. The relay node corresponding to a specific terminal is unique. The relay node bound to a specific terminal is called the target relay node. In this scenario, a transaction subrequest generated by that terminal can only be sent to the target relay node. If the target relay node has no remaining storage space or processing capacity, the transaction subrequest sent by the terminal will be queued until the target relay node has sufficient storage space or processing capacity to process the transaction subrequest.
[0093] In another embodiment, the target relay node receives the transaction sub-request through the distribution node. As shown in the system architecture diagram of Figure 7, there are multiple relay nodes. The relay node is a node that receives transaction sub-requests and packages them into transaction requests to send to the blockchain node. There is a distribution node between the terminal and the multiple relay nodes, which is used to receive the transaction sub-requests from the terminal and send the transaction sub-requests to the relay node. Each of the multiple relay nodes can receive the transaction sub-requests assigned by the distribution node and send the packaged transaction requests to the blockchain node. In this embodiment, the specific process of the distribution node sending the transaction request includes:
[0094] Receive transaction sub-request from the terminal;
[0095] Selecting one of the multiple relay nodes as a target relay node;
[0096] Send the transaction sub-request to the target relay node.
[0097] The advantage of using the embodiment of the distribution node is that it alleviates the problem of reduced transaction processing efficiency due to uneven distribution of work among relay nodes that may occur when using the direct reception method. For example, the remaining storage space of relay node 1 is 3, the remaining storage space of relay node 2 is 1, and the remaining storage space of relay node 3 is 0. The terminal that is communicating with relay node 3 is still transmitting transaction sub-requests to it. At this time, the transaction sub-request received by relay node 3 needs to enter the queue sequence and wait for the current processing to be completed. Relay node 1 and relay node 2 have extra space but do not receive new transaction sub-requests, which results in low transaction processing efficiency of the relay node. Setting up a distribution node can alleviate this problem. When the distribution node receives a transaction sub-request, it will select a suitable relay node as the target relay node to ensure that all relay nodes can work efficiently.
[0098] In one embodiment, as shown in FIG8A , selecting one of the multiple relay nodes as a target relay node includes:
[0099] Step 81010: Obtain the remaining storage space and remaining processing capacity of each relay node;
[0100] Step 81020: Determine a target relay node among multiple relay nodes based on the remaining storage space and remaining processing capacity of each relay node.
[0101] Steps 81010-81020 are executed by the distribution node. The following is a detailed description of steps 81010-81020.
[0102] The transaction subrequests received by the distribution node are sent directly from the terminal. The distribution node evaluates the current operating capacity of each relay node to determine which relay node to select for the transaction subrequest, maximizing efficiency. In this embodiment, the evaluation metrics used are the remaining storage space and remaining processing capacity of the relay node.
[0103] A relay node's remaining storage space is the total storage space of the relay node minus the space occupied by existing transaction subrequests. The remaining processing capacity is the difference between the maximum number of tasks a relay node can simultaneously process and the number of tasks currently being processed. For example, if a relay node has 10MB of total storage space, 4MB of space occupied by transaction subrequests in the relay node, a maximum number of tasks it can simultaneously process, and 800 tasks currently being processed, the relay node's remaining storage space is 6MB (10-4), and its remaining processing capacity is 200 tasks (1000-800).
[0104] The reason for considering remaining storage space is that it determines whether a relay node can accommodate transaction subrequests. The reason for considering remaining processing capacity is that this determines the relay node's processing speed. A higher remaining processing capacity value results in faster processing. Remaining storage space and remaining processing capacity together determine whether a relay node is eligible to become a target relay node. This comprehensive consideration improves the accuracy of target relay node selection.
[0105] When determining a target relay node from among multiple relay nodes based on the remaining storage space and remaining processing capacity of each relay node, the total score of a relay node can be calculated using the remaining storage space and the remaining processing capacity, and the one with the highest total score is selected as the target relay node. In one embodiment, step 81020 includes:
[0106] determining a first score based on the remaining storage space of the relay node;
[0107] determining a second score based on the remaining processing capacity of the relay node;
[0108] determining a total score for each relay node based on the first score and the second score;
[0109] Based on the total score of each relay node, a target relay node is determined among the plurality of relay nodes.
[0110] The first score is determined based on the remaining storage space of the relay node. This can be done by looking up a comparison table between the remaining storage space and the first score, or by using a formula.
[0111] The remaining storage space and first score comparison table lists the correspondence between the remaining storage space range and the first score. First, based on the remaining storage space of the relay node, determine the remaining storage space range to which the remaining storage space belongs. Then, based on this, search the remaining storage space and first score comparison table to obtain the first score. The following is an example of a remaining storage space and first score comparison table:
[0112] Table 1
[0113] In the above example, the remaining storage space of the relay node is 6 MB. By looking up Table 1, the corresponding first score is 60.
[0114] The above method of searching the comparison table between the remaining storage space and the first score has the advantages of being simple and easy to implement with low processing overhead.
[0115] When the formula method is used, in one embodiment, the first fraction may be set to be proportional to the remaining storage space, for example: S1 = K1·P Formula 1
[0116] Wherein, S1 represents the first score, P represents the remaining storage space, and K1 is a preset constant that can be set according to actual needs. For example, K1 = 5 / MB, after substituting P = 6MB, the first score S1 = 30.
[0117] The advantages of the above method of determining the first score by using a formula are high accuracy, and the formula can be adjusted as needed, which is highly flexible.
[0118] The second score is determined based on the remaining processing capacity of the relay node. This can be done by looking up a comparison table between the remaining processing capacity and the second score, or by using a formula.
[0119] An example of a comparison table of remaining processing capacity and the second score is as follows:
[0120] Table 2
[0121] In the above example, the remaining processing capacity of the relay node is 200 tasks. By looking up Table 2, the corresponding second score is 80.
[0122] Advantages of the embodiment of searching the comparison table between the remaining processing capacity and the second score are similar to those of the embodiment of searching the comparison table between the remaining storage space and the first score, and therefore are not described in detail.
[0123] When the formula method is used, in one embodiment, the second score can be set to be proportional to the remaining processing capacity, for example: S2 = K2·Q Formula 1
[0124] Wherein, S2 represents the second fraction, Q represents the remaining storage capacity, and K1 is a preset constant that can be set according to actual needs. For example, K2 = 0.4, after substituting Q = 200, the second fraction S2 = 80.
[0125] The advantages of the above method of determining the second score by a formula are similar to those of the above method of determining the first score by a formula, so they are not described in detail.
[0126] The total score of each relay node is determined based on the first score and the second score, and an average or weighted average of the first score and the second score may be calculated.
[0127] When calculating the total score as the average of the first and second scores, for example, if relay node 1 has a first score of 60 and a second score of 40, then relay node 1's total score is (60 + 40) / 2 = 50; if relay node 2 has a first score of 50 and a second score of 30, then relay node 2's total score is (50 + 30) / 2 = 40; and if relay node 3 has a first score of 40 and a second score of 70, then relay node 3's total score is (40 + 70) / 2 = 55. The advantage of using the average to calculate the total score of a relay node is that it equally reflects the impact of remaining storage space and remaining processing power on the selection of a target relay node.
[0128] When calculating the total score as the weighted average of the first and second scores, for example, with weights of 0.6 and 0.4 set for remaining storage space and remaining processing power, respectively, if relay node 1 has a first score of 60 and a second score of 40, then relay node 1's total score is 60 × 0.6 + 40 × 0.4 = 52; relay node 2 has a first score of 50 and a second score of 30, then relay node 2's total score is 50 × 0.6 + 30 × 0.4 = 42; and relay node 3 has a first score of 40 and a second score of 70, then relay node 3's total score is 40 × 0.6 + 70 × 0.4 = 52. Using a weighted average to calculate the total score has the advantage of allowing different weights to be set for remaining storage space and remaining processing power, increasing flexibility in selecting target relay nodes.
[0129] When determining a target relay node from multiple relay nodes based on the total score of each relay node, in one embodiment, the relay node with the highest total score can be selected as the target relay node. This embodiment has the advantage of improving the accuracy of selecting the target relay node.
[0130] When determining a target relay node from multiple relay nodes based on each relay node's total score, in another embodiment, any relay node with a total score greater than a predetermined score threshold can be selected as the target relay node. This embodiment has the advantage that a total score greater than the predetermined score threshold indicates that the relay node meets the requirements for becoming a target relay node, and any relay node can be selected from the selected relay nodes. This avoids consistently assigning the same relay node as the target relay node for incoming transaction sub-requests over a period of time, which could cause re-congestion of the relay node.
[0131] The advantage of the above-mentioned embodiment in which the distribution node uses the remaining storage space and the remaining processing capacity to select the target relay node is that by effectively evaluating the capabilities of each relay node, the transaction sub-request is transmitted to the appropriate relay node, which can avoid the problem of uneven work distribution among some relay nodes, avoid the waste of resources, and improve the efficiency of the relay node in processing transactions.
[0132] In step 420, the received transaction subrequests need to be grouped. Grouping can mean grouping different transaction subrequests into a subrequest group for subsequent packaging. The reason for grouping is that the transaction subrequests in the target relay node need to be packaged. If there are a large number of transaction subrequests, grouping the transaction subrequests into different subrequest groups and then packaging them helps improve packaging efficiency and transaction processing efficiency.
[0133] In one embodiment, received transaction sub-requests are grouped in the order of their entry into the target relay node. The target relay node contains only one uncompleted sub-request group. After entering the target relay node, transaction sub-requests are queued in the uncompleted sub-request group in the order of their entry. Once the sub-request group meets a packaging condition, such as reaching a predetermined length or a specific time, the group no longer accepts new transaction sub-requests and becomes a completed sub-request group. The target relay node then allocates another uncompleted sub-request group to accommodate transaction sub-requests that enter in chronological order. The advantage of this embodiment is that a completed group can be formed in a minimal amount of time, thereby improving grouping and packaging efficiency.
[0134] In another embodiment, received transaction subrequests are grouped based on commonalities between them. Certain transaction subrequests may share commonalities that may make it easier for blockchain nodes to process these subrequests, thereby improving the processing efficiency of the embodiments of the present application. Grouping based on commonalities between transaction subrequests specifically includes:
[0135] Get the characteristics of the transaction subrequest;
[0136] Transaction subrequests with the same characteristics are grouped into a subrequest group.
[0137] In one embodiment, the transaction sub-request is characterized by a terminal identifier. A terminal can send one or more transaction sub-requests. The advantage of grouping transaction sub-requests from the same terminal into a sub-request group for packaging is that transaction sub-requests from the same terminal may be transaction sub-requests of the same type, and these transaction sub-requests may all be signed using the same second signature algorithm. The same second signature algorithm may be used when verifying the signature, which facilitates the subsequent verification and processing of the blockchain node in the embodiment of the present application and improves processing efficiency. For example, object A has multiple virtual resource transfer transactions to be processed, and object A plans to process them together in sequence. Multiple transaction sub-requests are sent out from the terminal of object A in sequence. The target relay node receives these transaction sub-requests one after another and recognizes that these transaction sub-requests come from the same terminal, thereby grouping all these transaction sub-requests into a sub-request group to facilitate the blockchain node to improve the efficiency of transaction processing.
[0138] In this embodiment, the structure of a transaction subrequest is shown in FIG5A , and includes a transaction subrequest body, a second signature, a terminal identifier, and a transaction type. The terminal identifier is used to identify the terminal, and each terminal has a unique terminal identifier. Transaction subrequests with the same terminal identifier can be grouped into a subrequest group based on the terminal identifier. The transaction type indicates the type of transaction subrequest.
[0139] In another embodiment, the transaction subrequest is characterized by a terminal group, which may refer to the group to which a terminal belongs. The same terminal group refers to terminals that are in the same group due to sharing common characteristics or being associated with each other. Terminal groups include: the group to which a terminal object belongs when registering a blockchain application, groups divided by geographic region, and groups to which terminal objects in third-party applications belong.
[0140] The group to which the terminal object belongs when registering a blockchain application can refer to the group specified in the registration information provided by the terminal object when registering the blockchain application. For example, if object A specifies that their organization is "XX Company" when first registering a blockchain application, then "XX Company" will be the group to which the terminal object belongs when registering the blockchain application. The advantage of this embodiment is that since object A specifies that they belong to the group during registration, it is likely that members of this group have similar transactions in their daily lives and work, and utilize similar signature algorithms. Grouping these groups may help improve the efficiency of signature verification and processing at blockchain nodes.
[0141] Geographical groups are groups related to the current geographic region of the terminal. This geographic region can be an administrative region, such as China or the United States, or a physical region on a map, such as the XX company region or the XX school region.
[0142] Within administrative regions, entities within the same region may issue identical transaction subrequests at the same time, while entities in other regions may not. For example, from January to February each year, most transaction subrequests from terminals in China are for virtual resource transfers, as this coincides with a Chinese holiday. These transaction subrequests may require similar signature algorithms, so grouping them together may help improve signature verification and processing efficiency on blockchain nodes.
[0143] For geographical areas divided by entities on a map, in this embodiment of the application, geographical areas belonging to the same category can be grouped together. For example, all transaction sub-requests from terminals at movie theaters can be grouped together. Because transaction sub-requests generated by objects in the same geographical area are likely similar, grouping them using similar signature algorithms may help improve signature verification and processing efficiency of blockchain nodes.
[0144] In this embodiment, the transaction sub-request structure is shown in Figure 5B , which includes a transaction sub-request body, a second signature, terminal location information, a terminal identifier, and a transaction type. Unlike Figure 5A , this embodiment's transaction sub-request structure also includes terminal location information. The target relay node uses this terminal location information to determine the terminal's current geographic location.
[0145] The group to which an object in a third-party application belongs can refer to the group to which the object belongs within the third-party application. For example, in addition to using the aforementioned blockchain application, the object also uses a third-party application. In this third-party application, the object belongs to a certain group. Objects in this group may frequently perform the same transactions. Grouping transaction subrequests for objects in the same group can improve the efficiency of blockchain node transaction processing.
[0146] In another embodiment, multiple received transaction subrequests can be grouped according to the type of the second signature algorithm. In this embodiment, the second signature algorithm can be customized by the target, and the signing and verification processes for the same second signature algorithm are similar. By grouping transaction subrequests using the same second signature algorithm, blockchain nodes can use the same second signature algorithm to uniformly verify these transaction subrequests, reducing the need to repeatedly call different second signature algorithms for verification and improving verification efficiency. For example, if a blockchain node receives a transaction request where all transaction subrequests are signed using signature algorithm B, the blockchain node can use signature algorithm B for all of these transaction subrequests, mitigating the problem of reduced blockchain node processing efficiency caused by the need to repeatedly change signature algorithms. In this embodiment, as shown in Figure 5C, the structure of the transaction subrequest received by the target relay node includes: a transaction subrequest body, a second signature, a second signature algorithm type, a terminal identifier, and a transaction type. The second signature algorithm type serves as the basis for grouping transaction subrequests in this embodiment.
[0147] As previously described, in one embodiment of step 410, the target relay node receives a transaction subrequest via the distribution node. The distribution node selects a target relay node for the transaction subrequest based on the remaining storage space and processing capacity of each relay node. If the target relay node groups multiple transaction subrequests according to the second signature algorithm type, in one embodiment, the distribution node may also select a target relay node based on the second signature algorithm type. As shown in FIG8B , selecting a target relay node from multiple relay nodes includes:
[0148] Step 82011: Obtain the second signature algorithm type in the received transaction sub-request;
[0149] Step 82021: Obtain a second number of transaction sub-requests of the second signature algorithm type that have not been packaged in each relay node;
[0150] Step 82031: Based on the second number, select a target relay node from multiple relay nodes.
[0151] The following is a detailed description of steps 82011-82031.
[0152] As previously described, in Figure 5C , the structure of a transaction subrequest includes: a transaction subrequest body, a second signature, a second signature algorithm type, a terminal identifier, and a transaction type. The second signature algorithm type is primarily used to help the target relay node group transaction subrequests. The advantage of counting the second number of unpackaged transaction subrequests of the second signature algorithm type at each relay node and selecting a target relay node from multiple relay nodes based on this second number is that, when multiple relay nodes exist, transaction subrequests of the same second signature algorithm type may be assigned to multiple relay nodes. Each relay node groups transaction subrequests according to the second signature algorithm type. Consequently, each relay node may have only a small number of transaction subrequests of the same second signature algorithm type within its group, which may not meet the packaging criteria and therefore cannot be packaged and issued. In this embodiment, the second number of unpackaged transaction subrequests of the second signature algorithm type at each relay node is counted, and newly received transaction subrequests of the second signature algorithm type are assigned to the relay node with the largest accumulated second number of such subrequests. This allows the transaction subrequests of the second signature algorithm type at that relay node to more easily meet the packaging criteria, allowing for faster packaging and issuance, thereby improving transaction subrequest processing efficiency.
[0153] For example, there are two relay nodes, and the number of transaction sub-requests using the second signature algorithm A is 2, and the number of transaction sub-requests using the second signature algorithm B is 4. In each relay node, the number of transaction sub-requests using the second signature algorithm A is 1, and the number of transaction sub-requests using the second signature algorithm B is 2. If each relay node uses the second signature algorithm type for grouping, then the transaction sub-requests in both relay nodes will be divided into two sub-request groups, with numbers 1 and 2, respectively. The relay node will need to perform two sub-request groupings. Moreover, numbers 1 and 2 do not meet the grouping requirements. If the distribution node selects the target relay node directly based on the second number of accumulated transaction sub-requests using the same type of second signature algorithm, Then, when the first relay node has accumulated a transaction sub-request of the first signature algorithm A, and the second relay node has accumulated a transaction sub-request of the first signature algorithm B, subsequent transaction sub-requests of the first signature algorithm A are sent to the first relay node, and subsequent transaction sub-requests of the first signature algorithm B are sent to the second relay node. Each relay node only needs to perform packaging once, and it is easy to meet the packaging requirements, which effectively improves the packaging efficiency and the efficiency of transmission to the blockchain nodes.
[0154] The second signature algorithm type in steps 82011 and 82021 is obtained through the second signature algorithm type field in the transaction sub-request as shown in FIG5C. In one embodiment, step 82021 further includes:
[0155] Get the unpackaged transaction sub-requests in each relay node;
[0156] The number of transaction sub-requests that have not yet been packaged and that use the second signature algorithm is counted.
[0157] An unpackaged transaction subrequest can be one that has already entered a subrequest group, or it can be a recently received transaction subrequest that has not yet entered any subrequest group. Packaged transaction requests cannot be modified, so the transaction subrequests within them will not affect the subrequest groups of unpackaged transaction subrequests. Therefore, packaged transaction subrequests are not considered in this embodiment. After obtaining a transaction subrequest, the second signature algorithm type used by the transaction subrequest can be obtained through the second signature algorithm type field in the transaction subrequest structure.
[0158] Finding a suitable target relay node for a transaction subrequest requires counting the number of transaction subrequests using the second signature algorithm on each relay node. For example, the correspondence between the unpackaged transaction subrequests and their second signature algorithm types on relay node A is: {transaction subrequest a: second signature algorithm type 3; transaction subrequest b: second signature algorithm type 1; transaction subrequest c: second signature algorithm type 2; transaction subrequest d: second signature algorithm type 1; transaction subrequest e: second signature algorithm type 3}. For a particular transaction subrequest, if the second signature algorithm type is 3, then traversing the transaction subrequests sequentially reveals that the number of transaction subrequests using the second signature algorithm type 3 on relay node A is 2.
[0159] Step 82031 is to select a target relay node according to the second number.
[0160] In one embodiment, the relay node with the largest second number is selected as the target relay node. This embodiment has the advantage of enabling the transaction sub-requests of the second signature algorithm type at the target relay node to meet the packaging criteria and be packaged as quickly as possible, effectively improving the response efficiency of the transaction sub-requests.
[0161] In summary, the benefit of the embodiment of steps 82011-82031 is that it can improve the packaging and transmission efficiency of the target relay node, thereby improving the response efficiency of the target transaction sub-request.
[0162] In step 430, the target relay node packages the transaction sub-requests according to the sub-request groups. Conditions need to be set for the packaging to ensure that the packaging process can proceed in an orderly manner.
[0163] In one embodiment, the target relay node packages the transaction sub-requests in a group every predetermined period. For example, the transaction sub-requests in a sub-request group are packaged every 1 minute. Within the predetermined period, each sub-request group can continue to receive new transaction sub-requests. For example, the target relay node is divided into 6 groups according to the second signature algorithm type. At the end of 11:54 on December 31, 2022, the number of transaction sub-requests in the 6 sub-request groups is: 6, 0, 2, 0, 1, 0, respectively. Then, the 6 transaction sub-requests in the first sub-request group are packaged into one package, the 2 transaction sub-requests in the third sub-request group are packaged into one package, and the 1 transaction sub-request in the fifth sub-request group is packaged into one package. The advantages of this embodiment are simple implementation and low processing overhead.
[0164] In another embodiment, as shown in FIG6 , the target relay node packages the packets, including:
[0165] Step 610: Determine a first number of transaction sub-requests assigned to the same sub-request group.
[0166] Step 620: Pack the transaction sub-requests in the sub-request group whose first number reaches the first threshold to generate a transaction request.
[0167] The first threshold value is a value used to determine whether a sub-request group meets the packaging requirements and represents the number of transaction sub-requests in the sub-request group. The first threshold value is set by determining the number of transaction sub-requests in the sub-request group at which the target relay node's packaging efficiency is highest, so that the packaging process can be completed quickly without wasting processing space. The advantage of using the first threshold value to determine packaging is that the number of transaction sub-requests in each sub-request group is fixed, which facilitates packaging at the target relay node and ensures that the efficiency of the packaging process is maximized.
[0168] FIG10 shows an example of a transaction request formed after packaging, in which the body of the transaction request contains multiple transaction sub-requests grouped into the same group.
[0169] The advantage of the embodiment of steps 410-430 is that the target relay node groups and packages multiple transaction sub-requests from multiple terminals to form a transaction request and sends it to the blockchain node, which can batch process multiple transaction sub-requests and improve processing efficiency. At the same time, after being packaged into a transaction request, a unified first signature can be performed using a common first signature algorithm, so that the first signature can be successfully passed subsequently, thereby paving the way for the process of calling the terminal contract for personalized second signature verification.
[0170] The transaction request generation process in step 310 has been described in detail above. The process for generating the first signature has been described in the general description of the blockchain transaction processing method in the embodiments of this application. This process may include generating a digest of the transaction request using the digest algorithm in the first signature algorithm, obtaining the public key of the blockchain node, and encrypting the digest using the obtained public key. The following describes how to obtain the public key of the blockchain node.
[0171] The blockchain node public key is the opposite of the blockchain node private key. The blockchain node private key is a key held secretly by the blockchain node and known only to the blockchain node itself. The blockchain node public key is a key that is publicly disclosed by the blockchain node and accessible to all nodes outside the blockchain node. The public key and private key form a pair of keys used for encryption and decryption. When encryption is performed with the private key, the public key is generally used for decryption. When encryption is performed with the public key, the private key is generally used for decryption. In the embodiments of the present application, since the target relay node does not know the blockchain node's private key but has access to its public key, it can encrypt the digest with the blockchain node public key to obtain a first signature. After receiving this first signature, the blockchain node, knowing its own private key, can decrypt it with the blockchain node private key for signature verification.
[0172] The public and private keys of a blockchain node are typically generated by the blockchain node through a request from an authorization center (not shown). The authorization center then generates the public and private keys and distributes them to the blockchain node. After receiving the generated public and private keys, the blockchain node retains the blockchain node private key and publishes the blockchain node public key.
[0173] One way to publish a blockchain node's public key is to broadcast it to other nodes. In this embodiment, the target relay node can obtain the blockchain node's public key by, upon receiving the blockchain node's broadcasted public key, storing it locally in correspondence with the blockchain node's identifier. When a transaction request requires a first signature, the target relay node retrieves the blockchain node's public key locally based on the blockchain node's identifier. This embodiment offers the advantage of efficient acquisition, eliminating the need for external lookup and enabling direct local access to the blockchain node's public key.
[0174] Another way to publish blockchain node public keys is to publish them on the blockchain network's website. When a transaction request requires a first signature, the target relay node directly obtains the blockchain node public key from the website. This embodiment has the advantage of conserving internal storage space on the target relay node.
[0175] Detailed description of step 320
[0176] In step 320, the blockchain node uses the first signature algorithm to perform a first verification on the transaction request and the first signature received from the target relay node.
[0177] As introduced in the general description of the blockchain transaction processing method in the embodiment of the present application, the above-mentioned signature verification process includes: using the private key of the blockchain node to decrypt the first signature to obtain a decrypted digest; using the digest algorithm in the first signature algorithm to generate a digest for the transaction request; comparing the decrypted digest with the digest generated for the transaction request. If the two digests are consistent, the verification is successful; otherwise, the verification fails.
[0178] Note that when the target relay node performs the first signature, it uses the digest algorithm in the first signature algorithm to generate a digest of the transaction request. When the blockchain node verifies the signature, it also uses the digest algorithm in the first signature algorithm to generate a digest of the transaction request. The two digest algorithms are consistent, ensuring the correctness of the signature verification. The private key of the blockchain node is held by the blockchain node itself and can therefore be obtained smoothly.
[0179] The purpose of this signature verification is to verify that the transaction request was authentically generated by the target relay node and that it was not lost in transit. If a portion of the transaction request is lost in transit, the generated digest will not be consistent with the decrypted digest, and the signature verification will fail. Furthermore, this signature verification is a prerequisite for triggering the execution of the relay contract, enabling it to execute the personalized signature verification process specified in the relay contract, calling the terminal contract.
[0180] If the signature verification fails, the target relay node can be directly notified of the signature verification failure message, and the target relay node will transmit it again.
[0181] Detailed description of step 330
[0182] After the first signature verification succeeds in step 320, the blockchain node needs to call the relay contract of the target relay node in step 330. Different relay nodes have different relay contracts. The relay contract's execution condition is that the first signature verification passes. The relay contract specifies that each transaction sub-request in the transaction request from the target relay node be retrieved and the corresponding terminal contract be called for each transaction sub-request. The terminal contract specifies that a second signature verification be performed using a second signature algorithm personalized for the terminal.
[0183] A relay contract is a smart contract pre-established between a relay node and the blockchain network. It executes any customized processing the relay node wishes the blockchain network to perform. For example, in the embodiments of this application, for each transaction sub-request contained in a transaction request, the corresponding terminal contract is invoked and executed. Let's first describe the process of developing a relay contract.
[0184] In one embodiment, the relay contract is formulated by the contract formulation node to code the relay contract rules desired by the target relay node. As shown in Figure 13, it specifically includes:
[0185] 1310. Receive a relay contract formulation request from a target relay node, where the relay contract formulation request includes the relay node identifier of the target relay node and relay contract rules.
[0186] 1320. Send the relay contract rules to the contract formulation node, which will encode the relay contract rules and generate a relay contract.
[0187] 1330. Receive the relay contract from the contract formulation node, and store the relay contract in correspondence with the relay node identifier of the target relay node.
[0188] The following is a detailed description of steps 1310-1330.
[0189] The relay contract formulation process occurs before step 310 of the embodiment of the present application. In step 1310, the blockchain node receives a relay contract formulation request from the target relay node. The relay contract formulation request is a request for formulating a relay contract and may include the relay node identifier of the target relay node and relay contract rules. The relay node identifier is an identifier used to indicate the relay node, such as the relay node address, relay node code, etc. Different relay nodes have different identifiers. The relay contract rules are a text description used to describe the personalized operations that the target relay node requires the blockchain node to perform. The relay contract is a code representation of the personalized operations that the target relay node requires the blockchain node to perform. The difference between relay contract rules and relay contracts is that the former is a text description, while the latter is the corresponding code of the former. The contract formulation node serves to codify the relay contract rules.
[0190] In step 1320, the process of coding the relay contract rules by the contract formulation node can be implemented automatically or by programmer programming. In the automatic implementation embodiment, a number of code segments corresponding to various keywords are pre-set, and the code segments contain parameters that need to be filled in. Keywords are identified from the relay contract rules; code segments corresponding to the keywords are obtained; the semantics of the relay contract rules are identified using a semantic recognition algorithm, and the parameters in the code segments are determined based on the identified semantics and filled in the code segments. This automatic implementation method can automatically generate a relay contract for the relay contract rules through artificial intelligence, thereby improving the efficiency of generating relay contracts.
[0191] In step 1330, the relay contract is stored in correspondence with the relay node identifier of the target relay node, so that after the first signature verification is successful, when the relay contract needs to be executed in step 330, the corresponding relay contract can be found through the relay node identifier.
[0192] In one embodiment, the relay contract and the relay node identifier of the target relay node are stored locally. The relay contract and the relay node identifier are stored locally in pairs, and can be called directly according to the relay node identifier when used.
[0193] In another embodiment, the relay contract and the relay node identifier of the target relay node are stored in the following manner: the relay contract is stored in the blockchain, and the relay node identifier and the block identifier are stored locally in pairs. In one embodiment, the process specifically includes:
[0194] Store the relay contract in the first block and record the first block in the blockchain;
[0195] Get the first block identifier;
[0196] The correspondence between the relay node identifier and the first block identifier is added to a local first correspondence table.
[0197] The structure of the first block after the relay contract is stored in the first block is shown in Figure 12. The first block consists of a block body and a block header. The block body is divided into multiple blocks. The relay contract can occupy only one, several, or all of these blocks. Figure 12 shows a scenario where the relay contract occupies all of these blocks. In the case of occupying only one or several of these blocks, the remaining blocks record other transactions that other nodes need to upload to the blockchain. Specifically, the blockchain node packages the blocks occupied by the relay contract and the blocks corresponding to transactions that other nodes need to upload into a block body, adds the block header to form a single block, and records it on the blockchain. The block header indicates relevant information about the block, including its version number, characteristic value, timestamp, and difficulty value. The first block identifier distinguishes the first block from other blocks, such as its height or characteristic value. The characteristic value of the first block is generally a digest value generated by a digest algorithm using the block body of the first block. Because different block bodies have different digest values, digest values can uniquely distinguish blocks. The height of the first block indicates the block number of the first block recorded on the blockchain. The height of the first block can also uniquely distinguish the first block from other blocks. The first correspondence table is stored locally and indicates the correspondence between the relay node identifier and the first block identifier.
[0198] The advantage of recording relay contracts through blockchain is that it is easy for other nodes to check, the relay contract is not easily tampered with, and the security of the relay contract is improved.
[0199] The advantage of the embodiment of the above steps 1310-1330 is that the relay contract is formulated and stored through the cooperation of the blockchain node, the contract formulation node and the target relay node, thereby improving the generation efficiency of the relay contract, and improving the security of the formulation process through the cooperation of multiple nodes.
[0200] Once the relay contract is established, the target relay node's relay contract can be called in response to a successful first signature verification in step 330. As a smart contract, the relay contract can specify any personalized processing for the target relay node. In this embodiment of the present application, the relay contract stipulates that after a successful first signature verification, the corresponding terminal contract is called for each transaction sub-request in the transaction request to complete a personalized second signature verification.
[0201] Since there may be multiple relay nodes, and different relay nodes correspond to different relay contracts, in one embodiment, executing the relay contract of the relay node, as shown in FIG9 , includes:
[0202] Step 910: Obtain the relay node identifier in the transaction request;
[0203] Step 920: Call the relay contract corresponding to the relay node identifier.
[0204] The following is a detailed description of steps 910-920.
[0205] The relay node identifier distinguishes the relay node from other relay nodes. It can be the relay node's address, number, or other identifier. In step 910, the relay node identifier is obtained from the transaction request because each relay node corresponds to a relay contract, and the corresponding relay contract can be found using the relay node identifier. The relay node identifier is shown in Figure 10.
[0206] In the aforementioned embodiment where the relay node identifier and the relay contract are stored in pairs locally on the blockchain node, step 920 may include: retrieving the relay contract corresponding to the relay node identifier from the local according to the relay node identifier.
[0207] In the embodiment of the relay contract being stored on-chain, as shown in FIG11 , step 920 may include:
[0208] Step 1110: Search a first correspondence table between relay node identifiers and first block identifiers to obtain a first block identifier corresponding to the relay node identifier of the target relay node.
[0209] Step 1120: Search for the first block on the blockchain according to the obtained first block identifier, and obtain the relay contract from the first block.
[0210] The first correspondence table is stored locally. In the first correspondence table, each relay node ID corresponds to a first block ID, which indicates the first block in the blockchain where the relay contract for that relay node is stored. Using the first block ID, the first block can be found and the relay contract retrieved from it.
[0211] The advantages of the embodiment of steps 1110-1120 are: using blockchain to save relay contracts improves security and occupies less local storage space of the blockchain node.
[0212] In step 330, after the relay contract is called, the relay contract will call the corresponding terminal contract according to each transaction sub-request in the transaction request.
[0213] A terminal contract is a smart contract established in advance between the terminal and the blockchain network to perform any personalized processing that the terminal wishes the blockchain network to perform, such as the second signature verification using the terminal's personalized second signature algorithm in the embodiments of this application. The following describes the process of establishing a terminal contract.
[0214] Similar to the aforementioned relay contract formulation process, as shown in FIG16 , in one embodiment, the terminal contract formulation process includes:
[0215] Step 1610: accepting a terminal contract formulation request from the terminal, where the terminal contract formulation request includes the terminal identifier and terminal contract rules of the terminal;
[0216] Step 1620: Send the terminal contract rules to the contract formulation node. The contract designation node encodes the terminal contract rules to generate a terminal contract.
[0217] Step 1630: Receive the terminal contract from the contract formulation node, and store the terminal contract in correspondence with the terminal identifier of the terminal.
[0218] The terminal contract creation request is a request for creating a terminal contract. The terminal identifier is used to identify the terminal, such as the terminal address or terminal code. The terminal contract rules are textual descriptions of the personalized operations that the terminal requires the blockchain node to perform. The terminal contract is a code representation of the personalized operations that the terminal requires the blockchain node to perform. The difference between the terminal contract rules and the terminal contract is that the former is a textual description, while the latter is the corresponding code. Steps 1610-1620 are similar to the corresponding steps in the relay contract creation process described above and can be referred to in the relevant descriptions. For step 1630, the terminal contract can be stored locally or on-chain.
[0219] In one embodiment, the terminal identification and the terminal contract are stored locally. The terminal identification and the terminal contract are stored locally in pairs, and can be directly called according to the terminal identification when in use.
[0220] In another embodiment, the terminal identifier and the terminal contract are stored in a manner as follows: the terminal contract is stored in the blockchain, and the terminal identifier and the block identifier are stored locally in pairs. In one embodiment, the process specifically includes:
[0221] Store the terminal contract in the second block and record the second block in the blockchain;
[0222] Get the second block identifier;
[0223] The correspondence between the terminal identifier and the second block identifier is added to the second correspondence table.
[0224] The second block is the block where the terminal contract is stored. The second block identifier distinguishes the second block from other blocks and may include the second block characteristic value, the second block height, etc. The second correspondence table is a table that records the correspondence between the terminal identifier and the second block identifier. The block structure after storing the terminal contract in the second block is similar to the block structure after storing the relay contract in the first block, as shown in Figure 12, so it will not be repeated here. The advantage of recording the terminal contract on the blockchain is that it is easy for other nodes to check, the terminal contract is not easily tampered with, and the security of the terminal contract is improved.
[0225] After the terminal contract is established, in one embodiment, the relay contract can call the corresponding terminal contract for each transaction sub-request and verify the second signature using the second signature algorithm. As shown in Figure 14, this process can specifically include:
[0226] Step 1410: Obtain the terminal identifier in the transaction sub-request;
[0227] Step 1420: Call the terminal contract corresponding to the terminal identifier, and the terminal contract performs a second signature verification using a second signature algorithm.
[0228] In step 1410, the terminal identifier can be directly obtained from the transaction sub-request, as shown in Figures 5A to 5C. Calling the corresponding terminal contract according to the terminal identifier requires a corresponding relationship between the terminal identifier and the terminal contract.
[0229] In the above embodiment where the terminal identification and the terminal contract are directly stored locally in pairs, in step 1420 , the terminal contract corresponding to the terminal identification can be directly found locally using the terminal identification.
[0230] In the embodiment where the terminal contract is stored on the blockchain, in step 1420, the second block identifier can be found through the terminal identifier, and then the corresponding terminal contract can be obtained based on the second block identifier. As shown in Figure 15, in one embodiment, calling the terminal contract using the terminal identifier includes:
[0231] Step 1510: Search a second correspondence table between terminal identifiers and second block identifiers to obtain a second block identifier corresponding to the terminal identifier of the terminal;
[0232] Step 1520: Search for the second block on the blockchain according to the obtained second block identifier, and obtain the terminal contract from the second block.
[0233] The second correspondence table is stored locally. In the second correspondence table, terminal identifiers are stored in a one-to-one correspondence with second block identifiers. After obtaining the terminal identifier, the second block identifier corresponding to the terminal identifier can be found in the second correspondence table. The block indicated by the second block identifier stores the terminal contract for the terminal indicated by the terminal identifier. The advantages of using the blockchain to store terminal contracts and access them using block identifiers are: using the blockchain to store terminal contracts improves security and occupies less local storage space on the blockchain node.
[0234] The advantage of the embodiment of steps 1410-1420 is that the terminal contract is quickly called by using the terminal identification method, thereby improving the efficiency of terminal contract calling.
[0235] The terminal contract specifies the use of a second signature algorithm for a transaction sub-request's second signature verification. This second signature algorithm is a personalized signature algorithm used by the terminal when performing the second signature on the transaction sub-request. For example, if the terminal uses second signature algorithm A to perform the second signature on the transaction sub-request, the terminal contract will then perform a second signature verification on the second signature using the same second signature algorithm A.
[0236] After the second signature is verified using the terminal contract, the specific transaction request content in the transaction sub-request is obtained, that is, the transaction that needs to be processed on the blockchain node. There are many types of transactions, including virtual resource transfers and information updates, and different transaction types require different processing methods. The blockchain nodes of the embodiments of the present application handle different transaction types by using different transaction logic contracts.
[0237] When a blockchain network needs to process a transaction of a new transaction type, a transaction logic contract corresponding to the transaction type needs to be generated. In one embodiment, the specific generation method includes:
[0238] Formulate transaction logic contract rules based on transaction types;
[0239] Send the transaction logic contract rules to the contract formulation node, which will encode the transaction logic contract rules and generate a transaction logic contract;
[0240] Receive the transaction logic contract from the contract formulation node and store the transaction type corresponding to the transaction logic contract.
[0241] The generation process of the transaction logic contract is similar to that of the relay contract and terminal contract, and will not be repeated here.
[0242] In one embodiment, the transaction type and transaction logic contract are stored through blockchain, specifically including:
[0243] Store the transaction logic contract in the third block and record the third block in the blockchain;
[0244] Get the third block identifier;
[0245] The correspondence between the transaction type and the third block identifier is stored in a third correspondence table.
[0246] The structure of the third block is similar to that of the first block in the previous sequence (Figure 12). The transaction logic contract is stored in the block body, and the third block identifier can be a feature value in the block header, etc.
[0247] The third correspondence table is stored locally on the blockchain node. In the third correspondence table, the transaction type and the third block identifier are in one-to-one correspondence.
[0248] The advantage of storing transaction logic contracts on-chain is that it improves the security of transaction contracts.
[0249] The process of calling the transaction logic contract to execute the transaction subrequest occurs after steps 310-330, as shown in FIG17. In one embodiment, the process may include:
[0250] Step 1710: Obtain the transaction type in the transaction sub-request;
[0251] Step 1720: Call the transaction logic contract corresponding to the transaction type, execute the transaction subrequest, and record the execution result of the transaction subrequest to the blockchain.
[0252] The transaction type is recorded in the transaction sub-request sent by the terminal. As shown in Figures 5A-5C , various transaction sub-request embodiments all include the transaction type. The purpose of recording the transaction type is to enable quick access to the transaction logic contract based on the transaction type, improving transaction processing efficiency.
[0253] In the case where the aforementioned transaction logic contract is stored on-chain, in one embodiment, the transaction logic contract is called according to the transaction type, as shown in FIG18 , specifically including:
[0254] Step 1810: Search a third correspondence table between transaction types and third block identifiers to obtain a third block identifier corresponding to the transaction type included in the transaction sub-request.
[0255] Step 1820: Search for the third block on the blockchain according to the obtained third block identifier, and obtain the transaction logic contract from the third block.
[0256] The third correspondence table stores the correspondence between transaction types and third block identifiers. The third block identifier can be obtained based on the transaction type. The third block indicated by the third block identifier stores the transaction logic contract corresponding to that transaction type. The benefits of using a blockchain to store transaction logic contracts and call them via block identifiers are similar to those of using a blockchain to store relay contracts, and will not be further elaborated here.
[0257] The transaction logic contract includes the specific code for executing the transaction type. By bringing the specific parameters in the target transaction subrequest into it, the execution result of the target transaction subrequest can be obtained, and finally the execution result is chained on the blockchain.
[0258] In one embodiment, uploading the execution results to the chain includes:
[0259] Get the execution result of the transaction subrequest;
[0260] Record the execution results on the blockchain.
[0261] In this embodiment, the transaction processing process can be completed by recording the execution results on the blockchain.
[0262] In another embodiment, uploading the execution result to the chain includes:
[0263] Get the execution result of the transaction subrequest;
[0264] Record the execution results on the blockchain and obtain the corresponding block ID.
[0265] In this embodiment, after recording the execution results on the blockchain, the corresponding block identifier is also obtained. This approach provides a clear understanding of which block or blocks have been modified. When transaction data needs to be modified, the block in which the data is recorded can be directly found based on the block identifier. For example, after processing a virtual resource transfer transaction for an object, the object may wish to withdraw the transaction. Upon receiving the withdrawal request, the blockchain node can directly obtain the block identifier of the block that previously recorded the result and modify the corresponding block, improving transaction processing efficiency.
[0266] After the execution results are uploaded to the chain, the corresponding terminal needs to be notified of the execution results. An exemplary specific process is shown in Figure 19, including:
[0267] Step 1910: Return the execution results corresponding to the multiple transaction sub-requests to the relay contract. The relay contract integrates the execution results corresponding to the multiple transaction sub-requests as the integrated execution result.
[0268] Step 1920: Notify the target relay node of the integrated execution result through the relay contract, and the target relay node notifies the corresponding terminals of the execution results of the multiple transaction sub-requests in the integrated execution result.
[0269] Below is a detailed description of steps 1910-1920.
[0270] Because the relay contract traverses the transaction request and sequentially executes the corresponding terminal contract and transaction logic contract for each transaction subrequest, the relay contract will receive the execution results of the transaction subrequests in sequence (but the order in which the execution results are received may not be the same as the order in which the terminal contract and transaction logic contract are retrieved and executed). The relay contract contains a transaction execution result set, which is used to temporarily store transaction execution result-related data, including data related to the execution results of transaction subrequests. The transaction execution result set and the relay node identifier of the target relay node constitute the integrated execution result.
[0271] In one embodiment, the relay contract integrates the execution results corresponding to multiple transaction sub-requests, including:
[0272] Obtain the execution result of each transaction sub-request in the transaction request, and store the execution result and the corresponding terminal identifier in the transaction execution result set;
[0273] Obtain the relay node identifier of the target relay node;
[0274] The transaction execution result set is integrated with the relay node identifier of the target relay node to form an integrated execution result.
[0275] Each execution result corresponds to a terminal identifier, which indicates that the execution result should be notified to the corresponding terminal. An exemplary structure of a transaction execution result set is {terminal 1: execution result 1; terminal 2: execution result 2; terminal 3: execution result 3}.
[0276] After all transaction sub-requests in a transaction request have been executed and stored in a transaction execution result set, the transaction execution result set and the relay node identifier of the target relay node are combined to form an integrated execution result. The structure of the integrated execution result is shown in FIG20A .
[0277] In the aforementioned embodiment of obtaining the execution result of a transaction subrequest, recording the execution result on the blockchain, and obtaining the corresponding block identifier, the relay contract integrates the execution results corresponding to multiple transaction subrequests as the integrated execution result, which may include:
[0278] Obtain the execution result of each transaction subrequest in the transaction request, and store the execution result, the corresponding block identifier, and the corresponding terminal identifier in the transaction execution result set;
[0279] Obtain the relay node identifier of the target relay node;
[0280] The transaction execution result set is integrated with the relay node identifier of the target relay node to form an integrated execution result.
[0281] In addition to the execution results, the relay contract also receives the corresponding block identifier, which indicates the block where the execution result is stored. Therefore, in this embodiment, the data stored in the transaction execution result set includes: execution result, block identifier, and terminal identifier. An exemplary structure of the transaction execution result set is: {Terminal 1: (execution result 1, block identifier 1); Terminal 2: (execution result 2, block identifier 2); Terminal 3: (execution result 3, block identifier 3)}. The integrated execution result of this embodiment is shown in Figure 20B. The integrated execution result includes the execution results of all transaction sub-requests packaged and issued by the target relay node, the terminal identifiers of the terminals that need to be notified, and the block identifiers of the blocks where the execution results are stored.
[0282] After receiving the consolidated execution results, the relay contract needs to notify the corresponding terminal of the execution results of each transaction sub-request. Each transaction sub-request contains a terminal identifier, and the execution results are sent to the terminal in turn according to the terminal identifier.
[0283] The advantage of the above embodiment is that the execution result of the transaction sub-request is returned along with the block identifier, which makes it easier for the object to check whether the execution result is correctly uploaded to the chain, thereby improving the security of the execution result on the chain.
[0284] In one embodiment, based on the structure of the integrated execution result in FIG20A , the relay node notifies the terminal of the transaction sub-request execution result, specifically including:
[0285] Get the execution result and terminal ID;
[0286] According to the terminal identification, the execution result is notified to the corresponding terminal.
[0287] During the above process, the relay node can obtain the corresponding terminal identifier for each execution result and notify the corresponding terminal of the execution result based on the terminal identifier. Alternatively, the relay node can aggregate the execution results for the same terminal identifier and notify the terminal corresponding to the terminal identifier. The latter approach helps improve notification efficiency.
[0288] In another embodiment, based on the structure of the integrated execution result in FIG. 20B , notifying the terminal of the transaction sub-request execution result specifically includes:
[0289] Get the execution result and terminal ID;
[0290] According to the terminal ID, the execution result and block ID are notified to the corresponding terminal.
[0291] The difference between this embodiment and the previous embodiment is that the block identifier is notified to the corresponding terminal at the same time, which is conducive to the on-chain transmission of the object inspection execution result and improves the security of the on-chain transmission.
[0292] Implementation details of the blockchain transaction processing method of this application embodiment
[0293] 21 , the implementation details of the blockchain transaction processing method according to the embodiment of the present application will be described in detail.
[0294] In step 2101, object A opens the blockchain processing application on the corresponding terminal and enters the operation instruction required for resource transfer, instructing to transfer object A's 1,000 virtual resources to object B.
[0295] In step 2102, the terminal generates a transaction sub-request according to the resource transfer operation instruction of object A, and generates a second signature using the second signature algorithm personalized for object A.
[0296] In step 2103, the terminal sends a transaction sub-request with a second signature to the distribution node.
[0297] In step 2104, the distribution node transmits the transaction sub-request to the target relay node.
[0298] In step 2105, the target relay node collects the transaction sub-requests sent by the terminal of object A and the transaction sub-requests sent by other terminals, and packages them into a transaction request.
[0299] In step 2106, the target relay node signs the transaction request using the first signature algorithm of the blockchain node to obtain a first signature.
[0300] In step 2107, the target relay node sends the transaction request and the first signature to the blockchain node.
[0301] In step 2108, the blockchain node performs a first verification on the first signature using a first signature algorithm.
[0302] In step 2109, after the first signature verification is successful, the blockchain node obtains the relay node identifier in the transaction request.
[0303] In step 2110, the blockchain node calls the relay contract corresponding to the relay node identifier based on the relay node identifier.
[0304] In step 2111, the relay contract obtains the terminal identifier in each transaction sub-request in the transaction request.
[0305] In step 2112, the relay contract calls the terminal contract corresponding to the terminal identifier based on the terminal identifier.
[0306] In step 2113, the terminal contract uses the second signature algorithm of the blockchain node to perform a second verification on the second signature in the transaction sub-request.
[0307] In step 2114, after the second signature verification is passed, the terminal contract calls the transaction logic contract corresponding to the transaction type according to the transaction type in the transaction sub-request.
[0308] In step 2115, the transaction logic contract executes each transaction sub-request and records the execution results on the blockchain.
[0309] In step 2116, the transaction logic contract returns the execution result to the terminal contract.
[0310] In step 2117, the terminal contract returns the execution result to the relay contract.
[0311] In step 2118, the relay contract integrates the execution results of each transaction sub-request to form an integrated execution result.
[0312] In step 2119, the relay contract notifies the target relay node of the integrated execution result.
[0313] In step 2120 , the target relay node notifies the corresponding terminal of the execution result of each transaction sub-request in the integrated execution result.
[0314] Description of the apparatus and device of the embodiments of the present application
[0315] It is to be understood that, although the steps in the above-mentioned flowcharts are shown in sequence according to the arrow representations, these steps are not necessarily performed in sequence according to the order represented by the arrows. Unless otherwise specified in the present embodiment, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flowcharts may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.
[0316] It is understandable that when the above embodiments of the present application are applied to specific products or technologies, the processing of relevant data such as user information requires the user's permission or consent, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. In addition, when the embodiments of the present application need to obtain object registration information, the object's separate permission or separate consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the object's separate permission or separate consent, the necessary object-related data for the normal operation of the embodiments of the present application will be obtained.
[0317] 22 , which is a schematic diagram of the structure of a blockchain node 2200 provided in an embodiment of the present application, includes:
[0318] A first receiving unit 2210 is configured to receive a transaction request and a first signature of the transaction request from a target relay node, wherein the first signature is generated by signing the transaction request using a first signature algorithm of the blockchain node, and the transaction request includes a transaction subrequest received by the target relay node from a terminal, the transaction subrequest having a second signature, and the second signature is generated using a second signature algorithm in a terminal contract of the terminal;
[0319] A first signature verification unit 2220, configured to perform a first signature verification on the first signature using a first signature algorithm;
[0320] The second signature verification unit 2230 is used to call the relay contract of the target relay node after determining that the first signature verification is successful, obtain the transaction sub-request from the transaction request based on the relay contract, and call the terminal contract of the terminal corresponding to the transaction sub-request, and use the second signature algorithm in the terminal contract to perform a second signature verification on the transaction sub-request.
[0321] Optionally, the transaction request further includes a relay node identifier of the target relay node;
[0322] The second signature verification unit 2230 is specifically configured to:
[0323] Get the relay node ID in the transaction request;
[0324] Call the relay contract corresponding to the relay node identifier.
[0325] Optionally, the second signature verification unit 2230 is specifically configured to:
[0326] Searching a first correspondence table between relay node identifiers and first block identifiers to obtain a first block identifier corresponding to the relay node identifier of the target relay node;
[0327] The first block on the blockchain is searched according to the obtained first block identifier, and the relay contract is obtained from the first block.
[0328] Optionally, the blockchain node 2200 further includes:
[0329] a second receiving unit (not shown), configured to receive a relay contract formulation request from a target relay node, the relay contract formulation request including the relay node identifier of the target relay node and relay contract rules, the relay contract rules being used to invoke the terminal contract to perform a second signature verification on the transaction sub-request;
[0330] A first sending unit (not shown) is used to send the relay contract rules to the contract formulation node, and the contract formulation node is used to encode the relay contract rules to generate a relay contract;
[0331] The third receiving unit (not shown) is used to receive the relay contract from the contract formulation node, and store the relay contract in correspondence with the relay node identifier of the target relay node.
[0332] Optionally, the transaction sub-request further includes a terminal identifier of the terminal;
[0333] The second signature verification unit 2230 is specifically configured to:
[0334] Get the terminal ID in the transaction sub-request;
[0335] The terminal contract corresponding to the terminal identifier is called, and the terminal contract is used to perform a second signature verification using a second signature algorithm.
[0336] Optionally, the second signature verification unit 2230 is specifically configured to:
[0337] Searching a second correspondence table between terminal identifiers and second block identifiers to obtain a second block identifier corresponding to the terminal identifier of the terminal;
[0338] The second block on the blockchain is searched according to the obtained second block identifier, and the terminal contract is obtained from the second block.
[0339] Optionally, the blockchain node 2200 further includes:
[0340] a fourth receiving unit, configured to receive a terminal contract formulation request from a terminal, the terminal contract formulation request including a terminal identifier and a terminal contract rule, the terminal contract rule including a second signature algorithm;
[0341] The second sending unit is used to send the terminal contract rules to the contract formulation node, and the contract formulation node is used to encode the terminal contract rules and generate a terminal contract;
[0342] The fifth receiving unit is used to receive the terminal contract from the contract formulation node and store the terminal contract and the terminal identifier of the terminal in correspondence.
[0343] Optionally, the transaction request is generated by the target relay node in the following way:
[0344] receiving multiple transaction sub-requests from multiple terminals;
[0345] Group multiple transaction sub-requests;
[0346] Package the transaction subrequests in the same subrequest group to generate a transaction request.
[0347] Optionally, the transaction sub-request includes a second signature algorithm type;
[0348] Grouping the multiple transaction sub-requests includes grouping the multiple transaction sub-requests according to the second signature algorithm type.
[0349] Optionally, the transaction sub-requests in the same sub-request group are packaged to generate a transaction request, including:
[0350] determining a first number of transaction subrequests grouped into the same subrequest group;
[0351] The transaction sub-requests in the sub-request group whose first number reaches a first threshold are packaged to generate a transaction request.
[0352] Optionally, receiving multiple transaction sub-requests from multiple terminals includes: receiving multiple transaction sub-requests from multiple terminals forwarded by a distribution node;
[0353] The target relay node is selected by the distribution node from multiple relay nodes in the following way:
[0354] Obtain the remaining storage space and remaining processing capacity of each relay node;
[0355] A target relay node is determined among the plurality of relay nodes based on the remaining storage space and the remaining processing capacity of each relay node.
[0356] Optionally, receiving multiple transaction sub-requests from multiple terminals includes: receiving multiple transaction sub-requests from multiple terminals forwarded by a distribution node;
[0357] The target relay node is selected by the distribution node from multiple relay nodes in the following way:
[0358] Obtain the second signature algorithm type in the received transaction sub-request;
[0359] Obtaining a second number of transaction sub-requests of the second signature algorithm type that have not been packaged in each relay node;
[0360] A target relay node is selected among the plurality of relay nodes based on the second number.
[0361] Optionally, the transaction subrequest also includes a transaction type;
[0362] Blockchain node 2200 also includes:
[0363] An acquisition unit, used to acquire the transaction type in the transaction sub-request;
[0364] The calling unit is used to call the transaction logic contract corresponding to the transaction type. The transaction logic contract is used to execute the transaction sub-request and record the execution results of the transaction sub-request to the blockchain.
[0365] Optionally, the calling unit is specifically used to:
[0366] Searching a third correspondence table between transaction types and third block identifiers to obtain a third block identifier corresponding to the transaction type included in the transaction sub-request;
[0367] The third block on the blockchain is searched according to the third block identifier obtained, and the transaction logic contract is obtained from the third block.
[0368] Optionally, the transaction request includes multiple transaction sub-requests, and the blockchain node 2200 further includes:
[0369] The return unit is used to return the execution results corresponding to multiple transaction sub-requests to the relay contract. The relay contract is used to integrate the execution results corresponding to multiple transaction sub-requests as the integrated execution result;
[0370] The notification unit is used to notify the target relay node of the integrated execution result through the relay contract, and the target relay node is used to notify the corresponding terminal of the execution results corresponding to the multiple transaction sub-requests in the integrated execution result.
[0371] 23 , which is a block diagram of a portion of a terminal for implementing the blockchain transaction processing method according to an embodiment of the present application, includes components such as a radio frequency (RF) circuit 2310, a memory 2315, an input unit 2330, a display unit 2340, a sensor 2350, an audio circuit 2360, a wireless fidelity (WiFi) module 2370, a processor 2380, and a power supply 2390. Those skilled in the art will appreciate that the terminal structure shown in FIG23 does not limit the scope of a mobile phone or computer, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0372] The RF circuit 2310 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving downlink information from the base station, it is sent to the processor 2380 for processing. In addition, the designed uplink data is sent to the base station.
[0373] The memory 2315 may be used to store software programs and modules. The processor 2380 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the memory 2315 .
[0374] The input unit 2330 may be configured to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 2330 may include a touch panel 2331 and other input devices 2332 .
[0375] The display unit 2340 may be configured to display input information or provided information and various menus of the terminal. The display unit 2340 may include a display panel 2341.
[0376] The audio circuit 2360 , the speaker 2361 , and the microphone 2362 may provide an audio interface.
[0377] In this embodiment, the processor 2380 included in the terminal can execute the blockchain transaction processing method of the previous embodiment.
[0378] The terminals of the embodiments of the present application include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The embodiments of the present application can be applied to various scenarios, including but not limited to blockchain, digital signatures, smart contracts, etc.
[0379] Figure 24 is a block diagram of a portion of a server 2400 implementing a blockchain transaction processing method according to an embodiment of the present application. Server 2400 may vary significantly depending on configuration or performance. It may include one or more processors, such as a central processing unit (CPU) 2422, as well as memory 2432 and one or more storage media 2430 (e.g., one or more mass storage devices) storing application programs 2442 or data 2444. Memory 2432 and storage media 2430 may be either ephemeral or persistent storage. The programs stored in storage media 2430 may include one or more modules (not shown), each of which may include a series of instructions for operating on server 2400. Furthermore, CPU 2422 may be configured to communicate with storage media 2430 to execute the series of instructions stored in storage media 2430 on server 2400.
[0380] The server 2400 may also include one or more power supplies 2426, one or more wired or wireless network interfaces 2450, one or more input and output interfaces 2458, and / or one or more operating systems 2441, such as Windows Server 2003. TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM etc.
[0381] The central processor 2422 in the server 2400 can be used to execute the blockchain transaction processing method of the embodiment of the present application.
[0382] An embodiment of the present application further provides a computer-readable storage medium, which is used to store program code, and the program code is used to execute the blockchain transaction processing method of each of the aforementioned embodiments.
[0383] The present application also provides a computer program product, which includes a computer program. A processor of a computer device reads and executes the computer program, so that the computer device executes the above-mentioned blockchain transaction processing method.
[0384] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the numbers used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "comprise" and "comprising" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0385] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0386] It should be understood that in the description of the embodiments of the present application, multiple (or multiple items) means more than two, greater than, less than, exceed, etc. are understood to exclude the number itself, and above, below, within, etc. are understood to include the number itself.
[0387] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0388] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0389] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0390] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0391] It should also be understood that the various implementation methods provided in the embodiments of the present application can be combined arbitrarily to achieve different technical effects.
[0392] The above is a specific description of the implementation methods of the present application, but the present application is not limited to the above implementation methods. Technical personnel familiar with the art can also make various equivalent modifications or substitutions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A blockchain transaction processing method, the blockchain transaction processing method being used for a blockchain node, comprising: Receiving a transaction request from a target relay node and a first signature of the transaction request, wherein the first signature is generated by signing the transaction request using a first signature algorithm of the blockchain node, the transaction request includes a transaction sub-request received by the target relay node from a terminal, the transaction sub-request has a second signature, and the second signature is generated using a second signature algorithm in a terminal contract of the terminal; Performing a first signature verification on the first signature using the first signature algorithm; After determining that the first signature verification is successful, the relay contract of the target relay node is called, a transaction sub-request is obtained from the transaction request based on the relay contract, and the terminal contract of the terminal corresponding to the transaction sub-request is called, and the second signature algorithm in the terminal contract is used to perform a second signature verification on the transaction sub-request.
2. The blockchain transaction processing method according to claim 1, wherein the transaction request further includes a relay node identifier of the target relay node; The calling of the relay contract of the target relay node includes: Obtaining a relay node identifier in the transaction request; Call the relay contract corresponding to the relay node identifier.
3. The blockchain transaction processing method according to claim 2, wherein the calling of the relay contract corresponding to the relay node identifier comprises: Searching a first correspondence table between relay node identifiers and first block identifiers to obtain a first block identifier corresponding to the relay node identifier of the target relay node; The first block on the blockchain is searched according to the obtained first block identifier, and the relay contract is obtained from the first block.
4. The blockchain transaction processing method according to claim 2 or 3, before receiving the transaction request and the first signature of the transaction request from the target relay node, the blockchain transaction processing method further comprises: Receiving a relay contract formulation request from the target relay node, the relay contract formulation request including the relay node identifier of the target relay node and a relay contract rule, the relay contract rule being used to call the terminal contract to perform a second signature verification on the transaction sub-request; Sending the relay contract rules to a contract formulation node, wherein the contract formulation node is used to encode the relay contract rules and generate the relay contract; The relay contract is received from the contract formulation node, and the relay contract is stored in correspondence with the relay node identifier of the target relay node.
5. According to the blockchain transaction processing method according to any one of claims 1 to 4, the transaction sub-request also includes a terminal identifier of the terminal; The calling of the terminal contract of the terminal corresponding to the transaction sub-request, and performing a second signature verification on the transaction sub-request using the second signature algorithm in the terminal contract, includes: Obtaining the terminal identifier in the transaction sub-request; The terminal contract corresponding to the terminal identifier is called, and the terminal contract is used to perform a second signature verification using the second signature algorithm.
6. According to the blockchain transaction processing method of claim 5, the calling of the terminal contract corresponding to the terminal identifier comprises: Searching a second correspondence table between terminal identifiers and second block identifiers to obtain a second block identifier corresponding to the terminal identifier of the terminal; The second block on the blockchain is searched according to the obtained second block identifier, and the terminal contract is obtained from the second block.
7. The blockchain transaction processing method according to claim 5 or 6, before receiving the transaction request and the first signature from the target relay node, the blockchain transaction processing method further comprises: receiving a terminal contract formulation request from the terminal, wherein the terminal contract formulation request includes a terminal identifier and a terminal contract rule of the terminal, and the terminal contract rule includes the second signature algorithm; Sending the terminal contract rules to a contract formulation node, wherein the contract formulation node is used to encode the terminal contract rules and generate the terminal contract; The terminal contract is received from the contract formulation node, and the terminal contract is stored in correspondence with the terminal identifier of the terminal.
8. According to the blockchain transaction processing method according to any one of claims 1 to 7, the transaction request is generated by the target relay node in the following manner: receiving a plurality of transaction sub-requests from a plurality of terminals; Grouping a plurality of the transaction sub-requests; The transaction sub-requests in the same sub-request group are packaged to generate the transaction request.
9. The blockchain transaction processing method according to claim 8, wherein each of the transaction sub-requests includes a second signature algorithm type; The grouping of the plurality of transaction sub-requests comprises: According to the second signature algorithm type, the multiple transaction sub-requests are grouped.
10. The blockchain transaction processing method according to claim 8 or 9, wherein the step of packaging the transaction sub-requests in the same sub-request group to generate the transaction request comprises: determining a first number of transaction sub-requests grouped into the same sub-request group; The transaction sub-requests in the sub-request group whose first number reaches a first threshold are packaged to generate the transaction request.
11. According to any one of claims 8 to 10, the receiving of multiple transaction sub-requests from multiple terminals comprises: receiving multiple transaction sub-requests from multiple terminals forwarded by a distribution node; The target relay node is selected by the distribution node from a plurality of relay nodes in the following manner: Obtaining the remaining storage space and remaining processing capacity of each of the relay nodes; The target relay node is determined among the plurality of relay nodes based on the remaining storage space and the remaining processing capacity of each of the relay nodes.
12. According to any one of claims 8 to 10, the receiving of multiple transaction sub-requests from multiple terminals comprises: receiving multiple transaction sub-requests from multiple terminals forwarded by a distribution node; The target relay node is selected by the distribution node from a plurality of relay nodes in the following manner: Obtaining the second signature algorithm type in the received transaction sub-request; Obtaining a second number of transaction sub-requests of the second signature algorithm type that have not been packaged in each of the relay nodes; The target relay node is selected among the plurality of relay nodes based on the second number.
13. According to the blockchain transaction processing method according to any one of claims 1 to 12, the transaction sub-request further includes a transaction type; After determining that the first signature verification is successful, calling the relay contract of the target relay node, obtaining a transaction subrequest from the transaction request based on the relay contract, calling the terminal contract of the terminal corresponding to the transaction subrequest, and performing a second signature verification on the transaction subrequest using the second signature algorithm in the terminal contract, the blockchain transaction processing method further includes: Obtaining the transaction type in the transaction sub-request; Calling a transaction logic contract corresponding to the transaction type, wherein the transaction logic contract is used to execute the transaction sub-request and record the execution result of the transaction sub-request to the blockchain.
14. The blockchain transaction processing method according to claim 13, wherein the calling of the transaction logic contract corresponding to the transaction type comprises: Searching a third correspondence table between transaction types and third block identifiers to obtain a third block identifier corresponding to the transaction type included in the transaction sub-request; The third block on the blockchain is searched according to the obtained third block identifier, and the transaction logic contract is obtained from the third block.
15. According to claim 13 or 14, the transaction request includes multiple transaction sub-requests, and after calling the transaction logic contract corresponding to the transaction type, the transaction logic contract is used to execute the transaction sub-request and record the execution result of the transaction sub-request to the blockchain, the blockchain transaction processing method further includes: Returning the execution results corresponding to the multiple transaction sub-requests to the relay contract, wherein the relay contract is used to integrate the execution results corresponding to the multiple transaction sub-requests as the integrated execution result; The integrated execution result is notified to the target relay node through the relay contract, and the target relay node is used to notify the corresponding terminal of the execution results corresponding to the multiple transaction sub-requests in the integrated execution result.
16. A blockchain node, comprising: a first receiving unit, configured to receive a transaction request from a target relay node and a first signature of the transaction request, wherein the first signature is generated by signing the transaction request using a first signature algorithm of the blockchain node, the transaction request includes a transaction sub-request received by the target relay node from a terminal, the transaction sub-request has a second signature, and the second signature is generated using a second signature algorithm in a terminal contract of the terminal; A first signature verification unit, configured to perform a first signature verification on the first signature using the first signature algorithm; The second signature verification unit is used to call the relay contract of the target relay node after determining that the first signature verification is successful, obtain a transaction sub-request from the transaction request based on the relay contract, and call the terminal contract of the terminal corresponding to the transaction sub-request, and use the second signature algorithm in the terminal contract to perform a second signature verification on the transaction sub-request.
17. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the blockchain transaction processing method according to any one of claims 1 to 15.
18. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the blockchain transaction processing method according to any one of claims 1 to 15.
19. A computer program product, comprising a computer program, wherein the computer program is read and executed by a processor of a computer device, so that the computer device executes the blockchain transaction processing method according to any one of claims 1 to 15.
