Transaction execution method and device, electronic equipment and storage medium

By using a unique value generation function in a smart contract to generate the unique value corresponding to the transaction and execute transactions concurrently, the problem of low transaction execution efficiency in blockchain technology is solved, and full concurrent execution and efficient transaction processing are achieved.

CN120069875APending Publication Date: 2025-05-30TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311615017.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-29
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

When executing contract transactions, existing blockchain technology cannot achieve full concurrent execution, especially transactions with resource competition, resulting in low transaction execution efficiency.

Method used

By obtaining transaction requests for smart contracts, using unique values ​​in smart contracts to generate functions, generating unique values ​​corresponding to each transaction, and executing transactions concurrently based on these unique values, achieving full concurrent execution.

Benefits of technology

Complete concurrent execution of transactions with resource competition is achieved, which greatly improves transaction execution efficiency and avoids resource waste caused by serial execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120069875A_ABST
    Figure CN120069875A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a transaction execution method and device, electronic equipment and a storage medium. The transaction execution method provided by the embodiment of the invention can comprise the following steps: acquiring a transaction request for a smart contract; the transaction request carries transaction information of a plurality of transactions, and the smart contract comprises a unique value generation function; generating a unique value corresponding to each transaction in the plurality of transactions according to the transaction information and the unique value generation function; and concurrently executing each transaction based on the unique value to obtain an execution result of each transaction corresponding to the smart contract. According to the scheme, batch transaction concurrent execution can be realized, and transaction execution efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and particularly to a transaction execution method, apparatus, electronic device, and storage medium. Background Art

[0002] In recent years, using blockchain for contract transactions has become a popular development trend. The decentralized feature of blockchain technology and the programmability of smart contracts make contract transactions more efficient, transparent, and secure.

[0003] Currently, when executing contract transactions through blockchain, the Directed Acyclic Graph (DAG) technology is generally used to sort transactions. By analyzing the correlation and resource competition between transactions, a directed acyclic graph reflecting the transaction dependency relationship is established, that is, the transaction DAG. In the DAG, transactions without dependency relationships are used as the first batch and are executed concurrently first. After execution, the transactions that depend on them will subtract the transactions in the first batch contained in their own dependencies. At this time, the newly emerged transactions without dependency relationships after updating the dependencies are executed concurrently, and so on until all transactions are executed.

[0004] However, the DAG technology can only parallelize transactions without resource correlation. For transactions with resource competition, a transaction dependency graph needs to be organized according to the mutually exclusive resources used by the transactions. Therefore, for transactions with resource competition, the execution is still serial and cannot achieve full concurrent execution, resulting in low transaction execution efficiency. Summary of the Invention

[0005] Embodiments of this application provide a transaction execution method, apparatus, electronic device, and storage medium, which can improve transaction execution.

[0006] Embodiments of this application provide a transaction execution method, including:

[0007] Obtain a transaction request for a smart contract; the transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function;

[0008] Generate a unique value corresponding to each of the multiple transactions according to the transaction information and the unique value generation function;

[0009] Concurrently execute each of the transactions based on the unique value to obtain the execution result of each transaction corresponding to the smart contract.

[0010] Embodiments of this application also provide a transaction execution apparatus, including:

[0011] An acquisition unit for acquiring a transaction request for a smart contract; the transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function;

[0012] A generation unit for generating a unique value corresponding to each of the multiple transactions according to the transaction information and the unique value generation function;

[0013] An execution unit for concurrently executing each of the transactions based on the unique value to obtain an execution result of each transaction corresponding to the smart contract.

[0014] In some embodiments, the generation unit includes:

[0015] A quantity extraction subunit for extracting the transaction quantity of the multiple transactions from the transaction information;

[0016] A unique value generation subunit for calling the unique value generation function according to the transaction quantity to generate a unique value corresponding to each of the multiple transactions.

[0017] In some embodiments, the transaction execution device further includes:

[0018] A label detection unit for detecting a preset label in the transaction request, where the preset label is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently;

[0019] A first execution unit for, when detecting that the preset label exists in the transaction request, executing the step of extracting the transaction quantity of the multiple transactions from the transaction information.

[0020] In some embodiments, the transaction execution device further includes:

[0021] A transaction acquisition unit for acquiring a current transaction, where the current transaction is a transaction executed by the blockchain corresponding to the smart contract at the current moment;

[0022] A second execution unit for, when the current transaction is one of the multiple transactions requested to be executed by the transaction request, executing the step of detecting a preset label in the transaction request.

[0023] In some embodiments, the transaction execution device further includes:

[0024] A deployment request acquisition unit for acquiring a contract deployment request for a smart contract;

[0025] An archive establishment unit for establishing a contract archive in the smart contract according to the contract deployment request;

[0026] A storage unit for storing the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file.

[0027] In some embodiments, the storage unit is specifically configured to:

[0028] Parse the state variables of the contract source code of the smart contract to obtain at least one state variable;

[0029] Obtain the storage slot and variable identifier of each state variable in the at least one state variable;

[0030] Determine the state variable whose variable identifier in the at least one state variable matches the unique value identifier as the target state variable;

[0031] Determine the storage slot corresponding to the target state variable as the target storage slot;

[0032] Based on the target storage slot, store the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file.

[0033] In some embodiments, the transaction execution device further includes:

[0034] A transaction number extraction unit for extracting the transaction number of each transaction from the transaction information;

[0035] A storage unit for storing the unique value corresponding to each transaction in the multiple transactions into a specified storage area based on the transaction number of each transaction.

[0036] In some embodiments, the transaction execution device further includes:

[0037] A variable read instruction acquisition unit for acquiring the variable read instruction corresponding to the current transaction;

[0038] A transaction number acquisition unit for acquiring the transaction number corresponding to the current transaction when the variable read instruction meets a preset read condition;

[0039] A unique value extraction unit for extracting the unique value corresponding to the current transaction from the specified storage area according to the transaction number corresponding to the current transaction.

[0040] In some embodiments, the smart contract includes a pre-established contract file, and the contract file includes a unique value identifier and the storage slot corresponding to the unique value identifier. The transaction execution device further includes:

[0041] A first index value acquisition unit for acquiring the index value corresponding to the variable read instruction;

[0042] A first comparison unit for comparing the index value with the storage slot;

[0043] A matching unit for determining that the variable read instruction meets a preset read condition when the index matches the storage slot.

[0044] In some embodiments, the transaction execution device further includes:

[0045] A write execution acquisition unit for acquiring a variable write instruction corresponding to the current transaction;

[0046] A write execution unit for executing the variable write instruction when the variable write instruction meets a preset write condition.

[0047] In some embodiments, the transaction execution device further includes:

[0048] A label detection unit for detecting a preset label in the transaction request, where the preset label is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently;

[0049] A first determination unit for determining that the variable write instruction meets a preset write condition when it is detected that the preset label does not exist in the transaction request.

[0050] In some embodiments, the transaction execution device further includes:

[0051] A label detection unit for detecting a preset label in the transaction request, where the preset label is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently;

[0052] A second index value acquisition unit for acquiring an index value corresponding to the variable write instruction when it is detected that the preset label exists in the transaction request;

[0053] A second comparison unit for comparing the index value corresponding to the variable write instruction with the storage slot;

[0054] A second determination unit for determining that the variable write instruction meets a preset write condition when the index value corresponding to the variable write instruction does not match the storage slot.

[0055] An embodiment of the present application further provides an electronic device, including a memory storing multiple instructions; the processor loads the instructions from the memory to execute the steps in any one of the transaction execution methods provided by the embodiments of the present application.

[0056] The embodiments of the present application also provide a computer-readable storage medium, which stores multiple instructions. The instructions are suitable for being loaded by a processor to execute the steps in any one of the transaction execution methods provided by the embodiments of the present application.

[0057] The embodiments of the present application also provide a computer program product, including a computer program / instructions. When the computer program / instructions are executed by a processor, the steps in any one of the transaction execution methods provided by the embodiments of the present application are implemented.

[0058] The embodiments of the present application can obtain a transaction request for a smart contract. Among them, the transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function. Then, according to the transaction information and the unique value generation function, a unique value corresponding to each transaction among the multiple transactions is generated. Finally, each transaction is concurrently executed based on the unique value to obtain the execution result of each transaction corresponding to the smart contract. That is to say, when the smart contract contains a unique value variable and the smart contract is batch-called, a unique value generation function can be built into the smart contract. Through this unique value generation function, a unique value corresponding to each transaction is generated in advance, and then multiple transactions can be directly concurrently executed based on the pre-generated unique values, avoiding the situation where resource competition is required when accessing the unique value, resulting in serial execution of batch transactions. Thus, full concurrent execution of batch transactions is achieved, greatly improving the transaction execution efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative efforts.

[0060] Figure 1a is a schematic structural diagram of a distributed system provided by the embodiments of the present application;

[0061] Figure 1b is a schematic structural diagram of a block structure provided by the embodiments of the present application;

[0062] Figure 1c is a schematic flowchart of a transaction execution method provided by the embodiments of the present application;

[0063] Figure 2a is a schematic flowchart of the transaction execution method applied to a server provided by the embodiments of the present application;

[0064] Figure 2b is a schematic diagram of the response of the blockchain to a contract deployment request and a transaction request provided by the embodiments of the present application;

[0065] Figure 3 It is a schematic structural diagram of a transaction execution device provided by an embodiment of the present application;

[0066] Figure 4 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Specific Embodiments

[0067] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.

[0068] An embodiment of the present application provides a transaction execution method, device, electronic device, and storage medium.

[0069] Among them, the transaction execution device can be specifically integrated in an electronic device, and the electronic device can be a device such as a terminal or a server. Among them, the terminal can be a device such as a mobile phone, a tablet computer, a smart Bluetooth device, a notebook computer, or a personal computer (PC); the server can be a single server or a server cluster composed of multiple servers.

[0070] In some embodiments, the transaction execution device can also be integrated in multiple electronic devices. For example, the transaction execution device can be integrated in multiple servers, and multiple servers are used to implement the transaction execution method of the present application.

[0071] In some embodiments, the server can also be implemented in the form of a terminal.

[0072] For example, the transaction execution method of the present application can be applied to a blockchain system composed of the above-mentioned electronic devices. Among them, the blockchain system involved in the embodiments of the present application can be a distributed system formed by connecting a client and multiple nodes (any form of computing device connected to the network, such as a server or a user terminal) through network communication. Specifically, the transaction execution method can be applied to any one of the multiple nodes.

[0073] Taking the distributed system as an example of a blockchain system, refer to Figure 1a , Figure 1aFIG. 0 is an optional schematic structural diagram of the distributed system 100 provided by the embodiments of the present application when applied to a blockchain system, which is formed by multiple nodes 200 (any form of computing device connected to the network, such as a server or a user terminal) and a client 300. A peer-to-peer network is formed among the nodes 200, and the peer-to-peer network protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In the distributed system, any machine such as a server or a terminal can join and become a node 200. The node 200 includes a hardware layer, an intermediate layer, an operating system layer, and an application layer. Among them, the above nodes can also be referred to as blockchain nodes.

[0074] See Figure 1a the functions of each node in the blockchain system shown, and the functions involved include:

[0075] 1) Routing, a basic function of a node, used to support communication between nodes.

[0076] In addition to the routing function, a node may also have the following functions:

[0077] 2) Application, which is used to be deployed in the blockchain, implement specific services according to actual business requirements, record the data related to the implemented functions to form record data, carry a digital signature in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes verify the source and integrity of the record data successfully, the record data is added to the temporary block.

[0078] For example, the services implemented by the application include:

[0079] 2.1) Wallet, which is used to provide the function of conducting electronic currency transactions, including initiating a transaction (that is, sending the transaction record of the current transaction to other nodes in the blockchain system. After other nodes verify successfully, as a response to acknowledging the validity of the transaction, the record data of the transaction is deposited into the temporary block of the blockchain; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address;

[0080] 2.2) Shared ledger, which is used to provide functions such as storage, query, and modification of account data, send the record data of the operations on the account data to other nodes in the blockchain system. After other nodes verify the validity, as a response to acknowledging the validity of the account data, the record data is deposited into the temporary block, and can also send a confirmation to the node that initiated the operation.

[0081] 2.3) A smart contract is a programmed contract written in a computer language that will be automatically executed when the triggering conditions are met, mainly used in the blockchain field. Specifically, a smart contract is a computerized protocol that can execute the terms of a certain contract. It is implemented by code deployed on a shared ledger and used to execute when certain conditions are met. According to actual business needs, the code is used to complete automated transactions, such as querying the logistics status of the goods purchased by the buyer and transferring the buyer's electronic currency to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received information.

[0082] 3) A blockchain includes a series of blocks (Blocks) that are sequentially connected in the order of generation. Once a new block is added to the blockchain, it will not be removed again. The block records the record data submitted by the nodes in the blockchain system.

[0083] See Figure 1b , Figure 1b is an optional schematic diagram of the block structure provided by the embodiments of the present invention. Each block includes the hash value of the transaction records stored in this block (the hash value of this block) and the hash value of the previous block. The blocks are connected through the hash values to form a blockchain. In addition, the block may also include information such as the timestamp when the block is generated. A blockchain, in essence, is a decentralized database, a string of data blocks generated by using cryptographic methods. Each data block contains relevant information for verifying the validity of its information (anti-counterfeiting) and generating the next block.

[0084] Among them, it can be understood that in the specific implementation manner of this application, it involves relevant data such as the user's transaction information, transaction requests, and contract deployment requests. When the following embodiments of this application are applied to specific products or technologies, permission or consent needs to be obtained, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.

[0085] The following will be described in detail respectively. It should be noted that the serial numbers of the following embodiments do not limit the preferred order of the embodiments.

[0086] Artificial Intelligence (AI) is a technology that uses digital computers to simulate the human ability to perceive the environment, acquire knowledge, and use knowledge. This technology enables machines to have functions similar to human perception, reasoning, and decision-making. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, autonomous driving, and intelligent transportation.

[0087] Among them, a transaction: refers to the process of value transfer or information transmission using blockchain technology. On the blockchain, a transaction is realized through data blocks created, verified, and recorded in a block.

[0088] Solidity: A programming language used to write smart contracts. Smart contracts written in Solidity are executed by the EVM virtual machine.

[0089] EVM: A virtual machine used to execute Solidity smart contracts. A virtual machine is a software or hardware environment that simulates and runs other operating systems on a physical computer. It divides and isolates computer resources (including processors, memory, storage, and networks, etc.) through virtualization technology, enabling each virtual machine to independently run and manage a complete operating system and applications.

[0090] Pre-compiled contract: An extended function interface of the EVM. Functions developed following this interface specification can be registered into the EVM virtual machine, and Solidity contracts can call the registered extended functions through the call interface of the pre-compiled contract.

[0091] Unique value operation variable (hereinafter also referred to as unique value variable): Smart contracts have operation scenarios for obtaining unique values. This unique value is unique within the scope of the contract. For example, each non-fungible token (NFT) minted by an ERC721 contract must be unique. In this embodiment, a unique value built-in mode is added. In this mode, this variable can only be read and cannot be written, and the value read is provided by the EVM built-in.

[0092] In this embodiment, a transaction execution method based on a smart contract involving blockchain technology is provided. This method can be applied to the above blockchain system, such as Figure 1c As shown, the specific process of this transaction execution method can be as follows:

[0093] 101. Obtain a transaction request for the smart contract; the transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function.

[0094] Among them, a transaction request is usually used to indicate operations such as buying, selling, transferring, or other related operations on a certain asset or service. In this embodiment, the transaction request is used to indicate a request for the blockchain to execute a transaction through a smart contract.

[0095] Among them, transaction information is information related to a transaction. For example, transaction information may include, but is not limited to: the transaction quantity of multiple transactions to be executed, the transaction number of each transaction, the transaction type (such as buy, sell, transfer, etc.), the transaction time (such as the exact time and date when the transaction occurs), the transaction participants (such as the initiator and recipient of the transaction, and any intermediary institutions), and the transaction status (such as the current status of the transaction, such as pending, completed, cancelled, etc.) and other information.

[0096] Among them, the unique value generation function is the logical code for calculating the unique value within the contract. The calculated unique value will be written into the unique value temporary storage area and read by the unique value variable. Among them, the unique value temporary storage area is the area where the unique value will be temporarily stored after being calculated in advance. This unique value temporary storage area is for the unique value variable to read. Among them, the unique values in the unique value temporary storage area are ordered and need to be read in order according to the transaction number.

[0097] Among them, the smart contract can be pre-deployed in the blockchain system. Optionally, the smart contract can be a solidity contract.

[0098] In some embodiments, the above blockchain system can receive transaction requests in real time. Specifically, at least one blockchain node in the blockchain system can be communicatively connected to the user terminal to receive the transaction requests sent by the user terminal in real time. Optionally, the transaction request can be a transaction request for batch transactions. For example, the user terminal can package multiple transactions, then generate a transaction request based on the packaged transactions, and send the transaction request to the blockchain system for execution.

[0099] In some embodiments, if the number of received transaction requests is multiple, the multiple transaction requests can be stored in a request queue, and then retrieved and processed according to the processing priority corresponding to each transaction request in the request queue. Optionally, the processing priority can be determined according to information such as the reception time of the transaction request and the corresponding transaction quantity, and can also be custom-set according to actual needs, which is not limited herein.

[0100] In some embodiments, before step 101, the method may further include:

[0101] S1. Obtain a contract deployment request for the smart contract.

[0102] Among them, the contract deployment request is a request for deploying a smart contract on a blockchain network. The contract deployment request may carry information such as contract code (hereinafter also referred to as contract source code), contract address, deployment parameters, contract version, etc. In this embodiment, the contract deployment request may also carry a unique value tag and a unique value generation function corresponding to the unique value identifier. Among them, the unique value tag is used to indicate a unique value variable. Exemplarily, for example, the unique value tag a may be used to indicate a user-bound unique number. Another example is that the unique value tag b may be used to indicate the count value of a transaction, etc. Optionally, the unique value tag may be the variable name, serial number, etc. of the unique value variable it indicates, which is not limited herein.

[0103] In some embodiments, the blockchain system may receive the contract deployment request sent by the user terminal in real time to obtain the contract deployment request.

[0104] S2. Establish a contract file in the smart contract according to the contract deployment request.

[0105] Among them, the contract file may be a field in the smart contract for storing some specified contract information. In this embodiment, the contract file may store contract information such as the contract name, contract type, contract version, unique value tag, unique value type, unique value generation function, etc. of the smart contract.

[0106] In some embodiments, a part of the fields in the smart contract may be divided as the contract file according to the contract deployment request, and then the part of the fields is partitioned. The fields in different partitions may be used to store different types of contract information.

[0107] S3. Store the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file.

[0108] Among them, the contract deployment request carries the unique value identifier and the unique value generation function corresponding to the unique value identifier. Continuing with the above example, after partitioning the contract file, the unique value identifier and the unique value generation function may be stored in the corresponding areas respectively.

[0109] In some embodiments, in step S3, the specific implementation of storing the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file may include:

[0110] S31. Parse the state variables of the contract source code of the smart contract to obtain at least one state variable.

[0111] Among them, in Solidity, a state variable refers to a variable stored in the contract's storage space, and its value is persistently stored on the blockchain. It can be understood that in Solidity, the storage location of state variables is relatively fixed, and they are stored in the contract's storage space according to certain rules. Specifically, Solidity divides the contract's storage space into 256-bit (32-byte) slots, and each state variable is placed in one or more consecutive slots.

[0112] In some embodiments, the contract source code can be obtained from a contract deployment request, scanned, and then all state variables in the contract source code can be parsed.

[0113] S32. Obtain the storage slot and variable identifier of each state variable among at least one state variable.

[0114] In some embodiments, for each state variable among at least one state variable, the storage slot of the state variable can be determined according to the variable information of the state variable. Optionally, the variable information may include, but is not limited to: size (such as the number of bytes), position, type, etc. Exemplarily, state variables can be pre-stored in the corresponding storage slots according to their variable information in combination with the storage layout rules of Solidity. Therefore, the storage slot of the state variable can be inferred by combining the variable information of the state variable and the storage layout rules of Solidity.

[0115] After determining the storage slot of the state variable, a mapping relationship can be established between the storage slot and the variable identifier of the state variable, so as to obtain the mapping relationship between the variable identifiers of all state variables and all storage slots. Exemplarily, the mapping relationship between the variable identifier and the storage slot can be as shown in Table 1:

[0116] Table 1

[0117] Variable identifier Storage slot Variable identifier 1 Storage slot 1 Variable identifier 2 Storage slot 2 … … Variable identifier n Storage slot N

[0118] S33. Determine the state variables among at least one state variable whose variable identifiers match the unique value identifiers as target state variables.

[0119] Exemplarily, referring to Table 1, for example, the unique value identifier can be compared with each variable identifier in Table 1 respectively. If the comparison result is that the unique value identifier is consistent with "Variable Identifier 2", then the state variable corresponding to "Variable Identifier 2" can be determined as the target state variable.

[0120] S34. Determine the storage slot corresponding to the target state variable as the target storage slot.

[0121] Continuing with the above example, according to Table 1, there is a mapping relationship between "Variable Identifier 2" and "Storage Slot 2", so "Storage Slot 2" can be determined as the target storage slot.

[0122] S35. Based on the target storage slot, store the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier in the contract file.

[0123] In some embodiments, an associated slot corresponding to the target storage slot can be preset in the contract file, and this associated slot can be used to store content related to the content stored in the target storage slot.

[0124] After that, the unique value identifier corresponding to the contract deployment request can be stored in the target storage slot, and the unique value generation function corresponding to the unique value identifier can be stored in this associated slot.

[0125] Optionally, this associated slot can be set adjacent to the target storage slot.

[0126] Considering that in practical applications, when the unique value identifier is usually accessed, the associated unique value generation function is also very likely to be accessed. In this embodiment, based on the target storage slot, the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier are stored in the contract file, and the associated slot can be set adjacent to or close to the target storage slot, so as to place the state variables with frequent mutual access together, in order to reduce the storage and access costs, make the most of the byte alignment rule, avoid padding bytes, and thus reduce the waste of storage space.

[0127] 102. Generate the unique value corresponding to each of the multiple transactions according to the transaction information and the unique value generation function.

[0128] Among them, in step 102, the specific implementation of generating the unique value corresponding to each of the multiple transactions according to the transaction information and the unique value generation function may include:

[0129] 1021. Extract the transaction quantity of the multiple transactions from the transaction information.

[0130] 1022. Call the unique value generation function according to the transaction quantity to generate the unique value corresponding to each of the multiple transactions.

[0131] Exemplarily, for example, the number of transactions is M, where M is a positive integer. The unique value generation function can be repeatedly called. Each time the unique value generation function is called, a unique value can be generated. When the unique value generation function reaches M, the call to the unique value generation function can be stopped. At this time, M unique values can be obtained. Then, the M unique values are evenly distributed to each of the M transactions, and the unique value corresponding to each transaction can be obtained.

[0132] Optionally, multiple transactions can be numbered in advance to obtain the transaction number of each transaction. Each transaction number corresponds to a transaction. Then, based on the ascending order of the transaction numbers, the unique value generation function is called in sequence. Each time the unique value generation function is called to obtain a unique value, the currently obtained unique value is assigned to the transaction corresponding to the current transaction number.

[0133] In this embodiment, by calling the unique value generation function according to the number of transactions, a unique value can be accurately assigned to each of the multiple transactions.

[0134] In some embodiments, before step 1021, the method may further include:

[0135] A1. Detect a preset tag in the transaction request. The preset tag is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently.

[0136] Exemplarily, it can be detected whether the preset tag is carried in the transaction request. If the preset tag is carried in the transaction request, it indicates that the batch transaction corresponding to the transaction request (i.e., the above-mentioned multiple transactions) has the requirement of concurrent reading of unique values, that is, multiple transactions need to be executed concurrently. Then, the unique value built-in mode can be entered when performing the transaction. Among them, in the unique value built-in mode, the unique value corresponding to each of the multiple transactions can be generated in advance according to the unique value generation function in the contract file.

[0137] If the preset tag is not carried in the transaction request, it indicates that the batch transaction corresponding to the transaction request has no requirement of concurrent reading of unique values. Then, the above batch transaction can be executed according to the default transaction execution process, that is, when each transaction is executed, the smart contract is called once to generate a unique value to complete a transaction.

[0138] A2. When it is detected that there is a preset tag in the transaction request, execute the step of extracting the number of transactions of the multiple transactions from the transaction information.

[0139] In this embodiment, by detecting a preset tag in a transaction request and, when the preset tag is detected in the transaction request, performing the step of extracting the transaction quantities of multiple transactions from the transaction information, it is possible to accurately and effectively determine whether there is a need for concurrent execution of the multiple transactions requested by the transaction request, and only when there is a need, perform the step of extracting the transaction quantities of multiple transactions from the transaction information, thereby improving the transaction execution efficiency.

[0140] In some embodiments, before step A1, the method may further include:

[0141] Obtain the current transaction, where the current transaction is a transaction executed by the blockchain corresponding to the smart contract at the current moment.

[0142] When the current transaction is one of the multiple transactions requested by the transaction request, perform the step of detecting a preset tag in the transaction request.

[0143] Exemplarily, for example, it is detected that the transaction number of the current transaction is 0026, and the transaction numbers of the multiple transactions requested by the transaction request include 0001, 0002, 0026, 0045, and 0120. At this time, when the current transaction is one of the multiple transactions requested by the transaction request, it can be indicated that the current transaction and the multiple transactions corresponding to the transaction request are transactions of the same batch, and thus the step of detecting a preset tag in the transaction request can be continued.

[0144] Optionally, when the current transaction is not one of the multiple transactions requested by the transaction request, the above batch transactions may be executed according to the default transaction execution process, that is, when each transaction is executed, a smart contract is called to generate a unique value to complete a transaction.

[0145] In this embodiment, by obtaining the current transaction and, when the current transaction is one of the multiple transactions requested by the transaction request, performing the step of detecting a preset tag in the transaction request, it is possible to ensure that the subsequent concurrently executed transactions are transactions of the same batch, improving the accuracy of transaction execution.

[0146] In some embodiments, after step 102, the method may further include:

[0147] C1. Extract the transaction number of each transaction from the transaction information.

[0148] C2. Based on the transaction number of each transaction, store the unique value corresponding to each transaction among the multiple transactions in a specified storage area.

[0149] Among them, the specified storage area can be equivalent to the above-mentioned unique value temporary storage area. The specified storage area can be opened within the blockchain program (that is, a unique value temporary storage area is created within the EVM virtual machine) for recording the pre-generated unique values.

[0150] Then, the unique values corresponding to each transaction in multiple transactions can be sequentially stored in the specified storage area in the order from largest to smallest or from smallest to largest according to the transaction numbers.

[0151] 103. Execute each transaction concurrently based on the unique value to obtain the execution result of the smart contract corresponding to each transaction.

[0152] In some embodiments, each transaction in multiple transactions can be executed simultaneously according to the unique value corresponding to each transaction, so as to obtain the execution result corresponding to each transaction. Exemplarily, for example, when batch minting tokens for an NFT contract, after obtaining the unique value corresponding to each transaction, a token ID can be generated according to the unique value. Another example is that when the unique value is the count value of a counter, the unique value generation function can generate a hash value according to the counter and return it as the token ID.

[0153] In some embodiments, before step 103, the method may further include:

[0154] D1. Obtain the variable reading instruction corresponding to the current transaction.

[0155] Among them, when reading the unique value from the specified storage area, the variable reading instruction corresponding to the current transaction can be obtained. In this embodiment, the variable reading instruction can be the SLOAD instruction. The SLOAD instruction is an assembly instruction in Solidity used to load a single word (32 bytes) of data from the contract storage. This instruction is usually used to read the value of a contract state variable.

[0156] D2. When the variable reading instruction meets the preset reading condition, obtain the transaction number corresponding to the current transaction.

[0157] In some embodiments, the smart contract includes a pre-established contract file. The contract file includes a unique value identifier and the storage slot corresponding to the unique value identifier. Before step D2, the solution may further include:

[0158] Obtain the index value corresponding to the variable reading instruction.

[0159] Compare the index value with the storage slot.

[0160] When the index matches the storage slot, it is determined that the variable reading instruction meets the preset reading condition.

[0161] Exemplarily, the key popped from the stack by the current SLOAD instruction can be used as the index value corresponding to the variable read instruction. Then, the index value corresponding to the variable read instruction is compared with the storage slot corresponding to the unique value identifier in the contract file. If the two are the same, it can be determined that the variable read instruction meets the preset read condition.

[0162] In some embodiments, before the step of "obtaining the index value corresponding to the variable read instruction", the method may further include:

[0163] Detect a preset tag in the transaction request, and when the preset tag is detected in the transaction request, execute the step of "obtaining the index value corresponding to the variable read instruction".

[0164] D3. Extract the unique value corresponding to the current transaction from the specified storage area according to the transaction number corresponding to the current transaction.

[0165] That is to say, in this embodiment, in the unique value built-in mode, the modified SLOAD instruction is executed, that is, the variable read instruction is executed according to the logic of steps D1 to D3 above. If not in the unique value built-in mode, the logic of the original SLOAD instruction is executed without additional special processing, so that the execution method of the transaction can be more flexibly selected according to needs.

[0166] In some embodiments, the method may further include.

[0167] E1. Obtain the variable write instruction corresponding to the current transaction.

[0168] Among them, the variable write instruction may be an SSTORE instruction. SSTORE is an assembly instruction in Solidity used to store a single word (32 bytes) of data into the contract storage. This instruction is usually used to write the value of a contract state variable.

[0169] E2. When the variable write instruction meets the preset write condition, execute the variable write instruction.

[0170] As an implementation, before step E2, the method may include:

[0171] Detect a preset tag in the transaction request. The preset tag is used to indicate that multiple transactions requested by the transaction request need to be executed concurrently.

[0172] When it is detected that the preset tag does not exist in the transaction request, it is determined that the variable write instruction meets the preset write condition.

[0173] Among them, when it is detected that there is no preset tag in the transaction request, it indicates that the current transaction is not in the unique value built-in mode and there is no need to execute transactions concurrently. Therefore, the variable write instruction can be executed according to the original logic of the SSTORE instruction, that is, the value of the contract state variable is normally written.

[0174] As another implementation manner, before step E2, the method may further include:

[0175] Detect a preset tag in the transaction request, where the preset tag is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently.

[0176] When it is detected that there is a preset tag in the transaction request, obtain the index value corresponding to the variable write instruction.

[0177] Compare the index value corresponding to the variable write instruction with the storage slot.

[0178] When the index value corresponding to the variable write instruction does not match the storage slot, it is determined that the variable write instruction meets the preset write condition.

[0179] Among them, when the index value corresponding to the variable write instruction does not match the storage slot, it indicates that the value of the contract state variable to be written by the current variable write instruction is not for a unique value variable. Therefore, the variable write instruction can be executed according to the original logic of the SSTORE instruction.

[0180] Considering that in this embodiment, in the unique value built-in mode, that is, when multiple transactions need to be executed concurrently, the unique value variable is locked in a read-only state to prevent the contract code from randomly modifying its value and causing undefined behavior. In this implementation manner, by modifying the SSTORE instruction in the unique value built-in mode. Specifically, when it is detected that there is a preset tag in the transaction request and the index value corresponding to the variable write instruction matches the storage slot, the unique value variable is locked in a read-only state and is not allowed to be changed. Only when it is detected that there is no preset tag in the transaction request, or when it is detected that there is a preset tag in the transaction request and the index value corresponding to the variable write instruction does not match the storage slot, is the variable write instruction allowed to be executed normally, thereby ensuring the execution accuracy of the transaction and improving the transaction execution efficiency.

[0181] It can be seen that in this embodiment, by obtaining a transaction request for a smart contract, where the transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function; then, according to the transaction information and the unique value generation function, a unique value corresponding to each transaction among the multiple transactions is generated; finally, each transaction is concurrently executed based on the unique value to obtain the execution result of each transaction corresponding to the smart contract. That is to say, when a smart contract contains a unique value variable and the smart contract is batch-called, a unique value generation function can be built into the smart contract. By using this unique value generation function, a unique value corresponding to each transaction is generated in advance, and then multiple transactions can be directly concurrently executed based on the pre-generated unique values, avoiding the situation where resource competition is required when accessing the unique value, resulting in serial execution of batch transactions (that is, calling the smart contract once to execute one transaction, and then calling the smart contract again to execute the next transaction). Thus, full concurrent execution of batch transactions is achieved, greatly improving the transaction execution efficiency.

[0182] It can be understood that the transaction execution solution provided in the embodiments of the present application can be applied to various transaction execution scenarios. For example, calling an ERC721 type contract to batch-create NFTs, batch-register users and bind unique numbers to users, etc. By adopting the solution provided in the embodiments of the present application, full concurrent execution of batch transactions can be achieved, improving the transaction execution efficiency.

[0183] According to the method described in the above embodiments, further detailed description will be made below.

[0184] In this embodiment, taking the server in the blockchain system where the transaction execution is applied as an example, the method of the embodiments of the present application will be described in detail.

[0185] As Figure 2a shown, the specific process of a transaction execution method is as follows:

[0186] 201. The server obtains a contract deployment request for a smart contract.

[0187] 202. The server creates a contract file in the smart contract according to the contract deployment request.

[0188] 203. The server stores the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file.

[0189] Among them, the specific implementation manner of step 203 may include:

[0190] Parse the state variables of the contract source code of the smart contract to obtain at least one state variable.

[0191] Obtain the storage slot and variable identifier of each state variable among the at least one state variable.

[0192] Determine the state variable whose variable identifier in the at least one state variable matches the unique value identifier as the target state variable.

[0193] Determine the storage slot corresponding to the target state variable as the target storage slot.

[0194] Based on the target storage slot, store the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file.

[0195] Exemplarily, as Figure 2b shown, when storing a smart contract in the server of the blockchain, in addition to saving the contract code, a contract file is established. In addition to recording basic information such as the name, type, and version of the contract in the file, fields are also required to record the unique value variable and the unique value generation function of the contract.

[0196] Specifically, when deploying a smart contract (hereinafter referred to as a solidity contract), a contract deployment request can be sent to the server. The contract deployment request carries a unique value label (such as a variable name) and a unique value generation function (such as the function body code corresponding to the unique value label). The variable name is used to specify the unique value variable, and the function body is the code of the unique value generation function, which is used to batch calculate unique values.

[0197] When storing the contract information carried in the contract deployment request into the contract file, the contract source code can be obtained from the contract deployment request and the contract source code can be scanned. Then, all state variables in the source code are parsed, and based on information such as the position and type of the state variables, the storage slots of the state variables are inferred, and the mapping relationship between the variable name, type, and slot is recorded; then, according to the variable name of the unique value variable in the contract deployment request, the corresponding type and slot are found and written into the contract file.

[0198] It can be understood that the programming language of the unique value generation function is not particularly specified, as long as it can be docked with the blockchain programming language. It is optimal to be consistent with the blockchain development language for the convenience of direct invocation by the blockchain. If the blockchain development language is a statically typed language, the generated function can also be dynamically loaded and called after compilation. If the generated function is in solidity language, it can be compiled by calling the solc compiler and then executed by calling the evm virtual machine.

[0199] 204. The server obtains a transaction request for a smart contract; the transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function.

[0200] 205. The server generates a unique value corresponding to each of the multiple transactions according to the transaction information and the unique value generation function.

[0201] Among them, in step 205, generating a unique value corresponding to each transaction in the multiple transactions according to the transaction information and the unique value generation function may include:

[0202] Extracting the transaction quantity of the multiple transactions from the transaction information;

[0203] Invoking the unique value generation function according to the transaction quantity to generate a unique value corresponding to each transaction in the multiple transactions.

[0204] Among them, before extracting the transaction quantity of the multiple transactions from the transaction information, the method may further include:

[0205] Detecting a preset tag in the transaction request, where the preset tag is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently;

[0206] When detecting that the preset tag exists in the transaction request, executing the step of extracting the transaction quantity of the multiple transactions from the transaction information.

[0207] Among them, before detecting the preset tag in the transaction request, the method may further include:

[0208] Obtaining the current transaction, where the current transaction is a transaction executed by the blockchain corresponding to the smart contract at the current moment.

[0209] When the current transaction is one of the multiple transactions requested to be executed by the transaction request, executing the step of detecting the preset tag in the transaction request.

[0210] Continuing with the above example, please refer to Figure 2b , for a transaction request, the transaction numbers within the transaction request can be used, and the numbers of the transactions shall not be repeated.

[0211] Among them, adding a unique value concurrency flag (equivalent to the preset tag in the above embodiment) to the transaction request. If the flag does not exist in the transaction request, it means that the unique value built-in mode is closed. If the flag exists in the transaction request, it means that there is a need for concurrent reading of unique values for the batch transaction request, and the transaction execution enters the unique value built-in mode.

[0212] Then, open a unique value temporary storage area in the blockchain program for recording the pre-generated unique values.

[0213] 206. The server extracts the transaction number of each transaction from the transaction information.

[0214] 207. The server stores the unique value corresponding to each transaction in the multiple transactions into a specified storage area based on the transaction number of each transaction.

[0215] Among them, before step 208, the step of extracting the unique value from the specified storage area may include:

[0216] Obtain the variable reading instruction corresponding to the current transaction.

[0217] When the variable reading instruction meets the preset reading condition, obtain the transaction number corresponding to the current transaction.

[0218] Extract the unique value corresponding to the current transaction from the specified storage area according to the transaction number corresponding to the current transaction.

[0219] Among them, the smart contract includes a pre-established contract file, and the contract file includes a unique value identifier and a storage slot corresponding to the unique value identifier. The method further includes:

[0220] Obtain the index value corresponding to the variable reading instruction.

[0221] Compare the index value with the storage slot.

[0222] When the index matches the storage slot, determine that the variable reading instruction meets the preset reading condition.

[0223] In some embodiments, the method may further include:

[0224] Obtain the variable writing instruction corresponding to the current transaction.

[0225] When the variable writing instruction meets the preset writing condition, execute the variable writing instruction.

[0226] As an implementation, the method may further include:

[0227] Detect a preset tag in the transaction request, and the preset tag is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently.

[0228] When it is detected that the preset tag does not exist in the transaction request, determine that the variable writing instruction meets the preset writing condition.

[0229] As another implementation, the method may further include:

[0230] Detect a preset tag in the transaction request, and the preset tag is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently.

[0231] When it is detected that the preset tag exists in the transaction request, obtain the index value corresponding to the variable writing instruction.

[0232] Compare the index value corresponding to the variable writing instruction with the storage slot.

[0233] When the index value corresponding to the variable write instruction does not match the storage slot, it is determined that the variable write instruction meets the preset write condition.

[0234] Continuing with the above example, please refer again to Figure 2b , after storing the unique value in the unique value temporary storage area, the blockchain can construct an EVM virtual machine instance for the smart contract to execute the above multiple transactions.

[0235] Specifically, it can be checked whether the current transaction is one within the batch transaction corresponding to the transaction request.

[0236] If so, check whether the flag exists. If it exists, enter the unique value built-in mode, and then obtain the number of transactions within the batch transaction request.

[0237] After obtaining the number of transactions, obtain the unique value generation function from the contract file and automatically call it. The number of calls is equal to the number of transactions within the batch transaction request.

[0238] Store all the results calculated by the unique value generation function into the unique value temporary storage area in sequence.

[0239] In addition, please refer again to Figure 2b , in this embodiment, the SLOAD instruction in the virtual machine can be transformed.

[0240] Specifically, when executing the SLOAD instruction, first check whether there is a unique value concurrent flag in the batch transaction request.

[0241] If it exists, compare the key popped from the stack by the current SLOAD instruction with the slot of the unique value variable in the contract file.

[0242] If they are the same, it means that the contract reads the unique value variable, and then obtain the transaction number of the current transaction within the batch transaction request.

[0243] Using the transaction number as the key, read the corresponding unique value from the unique value temporary storage area and return it as the return value of the SLOAD instruction.

[0244] If there is no unique value concurrent flag in the batch transaction request, execute the original SLOAD logic without any additional special processing.

[0245] In addition, in this embodiment, since a built-in function for directly obtaining the unique value is provided for the smart contract, after enabling the unique value built-in mode, the unique value variable is locked in a read-only state to prevent the contract code from randomly modifying its value and causing undefined behavior. Therefore, the SSTORE instruction also needs to be transformed.

[0246] Specifically, when the SSTORE instruction is executed, first check whether there is a unique value concurrency flag in the batch transaction request.

[0247] If it exists, compare the key popped from the stack by the current SSTORE instruction (such as the bytes32 in Figure 2b ) with the slot of the unique value variable in the contract file.

[0248] If they are the same, it means that the contract is going to store a unique value variable. Since the unique value variable is read-only, no processing is done and the instruction returns directly.

[0249] If the unique value concurrency flag in the batch transaction request does not exist, execute the original SSTORE logic without any additional special processing.

[0250] 208. The server executes each transaction based on the unique value and obtains the execution result of each transaction corresponding to the smart contract.

[0251] It can be seen that the transaction execution method provided in this embodiment solves the problem that contracts containing unique value operation variables can only be executed serially. Through concurrent execution, the execution efficiency of such contracts can be greatly improved. In addition, the unique value reading ability is built-in, which improves the simplicity of the contract code and simplifies the call logic. In addition, the unique value generation logic can be customized, not limited to integer auto-increment, string concatenation, hash value calculation, etc., which is more free and flexible and has a wider applicability.

[0252] Especially for the scenario of smart contracts containing unique value acquisition operations, it provides parallelization capabilities. Under a multi-core CPU, it can make full use of computing resources, avoid waste of computing resources caused by serial execution, and greatly improve the execution efficiency of transactions. In the construction of batch data relying on unique value acquisition, such as the scenario of centralized data generation and numbering, the data construction time can be greatly compressed. It simplifies the operation logic of unique value variables. When the contract obtains a unique value, it can get the unique value without first calling the relevant calculation method, and also avoids data duplication and pollution caused by the lack of call to the unique value calculation method.

[0253] To better implement the above method, an embodiment of the present application also provides a transaction execution device. The transaction execution device can be specifically integrated in an electronic device, and the electronic device can be a device such as a terminal or a server. Among them, the terminal can be a device such as a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, or a personal computer; the server can be a single server or a server cluster composed of multiple servers.

[0254] For example, in this embodiment, the method of the embodiment of the present application will be described in detail by taking the transaction execution device specifically integrated in the transaction execution as an example.

[0255] For example, as Figure 3 shown, the transaction execution device may include an acquisition unit 301, a generation unit 302, and an execution unit 303, as follows:

[0256] The acquisition unit 301 is configured to acquire a transaction request for a smart contract; the transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function;

[0257] The generation unit 302 is configured to generate a unique value corresponding to each of the multiple transactions according to the transaction information and the unique value generation function;

[0258] The execution unit 303 is configured to concurrently execute each transaction based on the unique value to obtain an execution result of the smart contract corresponding to each transaction.

[0259] In some embodiments, the generation unit 302 includes:

[0260] A quantity extraction subunit, configured to extract the transaction quantities of the multiple transactions from the transaction information;

[0261] A unique value generation subunit, configured to call the unique value generation function according to the transaction quantity to generate a unique value corresponding to each of the multiple transactions.

[0262] In some embodiments, the transaction execution device further includes:

[0263] A label detection unit, configured to detect a preset label in the transaction request, where the preset label is used to indicate that the multiple transactions requested to be executed by the transaction request need to be concurrently executed;

[0264] A first execution unit 303, configured to execute the step of extracting the transaction quantities of the multiple transactions from the transaction information when it is detected that there is a preset label in the transaction request.

[0265] In some embodiments, the transaction execution device further includes:

[0266] A transaction acquisition unit 301, configured to acquire a current transaction, where the current transaction is a transaction executed by the blockchain corresponding to the smart contract at the current moment;

[0267] A second execution unit 303, configured to execute the step of detecting a preset label in the transaction request when the current transaction is one of the multiple transactions requested to be executed by the transaction request.

[0268] In some embodiments, the transaction execution device further includes:

[0269] A contract deployment request acquisition unit 301, configured to acquire a contract deployment request for the smart contract;

[0270] An archive creation unit, configured to create a contract archive in the smart contract according to a contract deployment request;

[0271] A storage unit, configured to store the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract archive.

[0272] In some embodiments, the storage unit is specifically configured to:

[0273] Parse the state variables of the contract source code of the smart contract to obtain at least one state variable;

[0274] Obtain the storage slot and variable identifier of each state variable in the at least one state variable;

[0275] Determine the state variables in which the variable identifiers in the at least one state variable match the unique value identifier as target state variables;

[0276] Determine the storage slot corresponding to the target state variable as the target storage slot;

[0277] Based on the target storage slot, store the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract archive.

[0278] In some embodiments, the transaction execution device further includes:

[0279] A number extraction unit, configured to extract the transaction number of each transaction from the transaction information;

[0280] A storage unit, configured to store the unique value corresponding to each transaction in multiple transactions into a specified storage area based on the transaction number of each transaction.

[0281] In some embodiments, the transaction execution device further includes:

[0282] A read instruction acquisition unit 301, configured to acquire a variable read instruction corresponding to the current transaction;

[0283] A number acquisition unit 301, configured to acquire the transaction number corresponding to the current transaction when the variable read instruction meets a preset read condition;

[0284] A unique value extraction unit, configured to extract the unique value corresponding to the current transaction from the specified storage area according to the transaction number corresponding to the current transaction.

[0285] In some embodiments, the smart contract includes a pre-established contract archive, and the contract archive includes a unique value identifier and a storage slot corresponding to the unique value identifier. The transaction execution device further includes:

[0286] A first index value acquisition unit 301, configured to acquire an index value corresponding to the variable read instruction;

[0287] The first comparison unit is configured to compare the index value with the storage slot;

[0288] The matching unit is configured to determine that the variable read instruction meets the preset read condition when the index matches the storage slot.

[0289] In some embodiments, the transaction execution device further includes:

[0290] The write execution acquisition unit 301 is configured to acquire a variable write instruction corresponding to the current transaction;

[0291] The write execution unit 303 is configured to execute the variable write instruction when the variable write instruction meets the preset write condition.

[0292] In some embodiments, the transaction execution device further includes:

[0293] The tag detection unit is configured to detect a preset tag in the transaction request, and the preset tag is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently;

[0294] The first determination unit is configured to determine that the variable write instruction meets the preset write condition when it is detected that the preset tag does not exist in the transaction request.

[0295] In some embodiments, the transaction execution device further includes:

[0296] The tag detection unit is configured to detect a preset tag in the transaction request, and the preset tag is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently;

[0297] The second index value acquisition unit 301 is configured to acquire the index value corresponding to the variable write instruction when it is detected that the preset tag exists in the transaction request;

[0298] The second comparison unit is configured to compare the index value corresponding to the variable write instruction with the storage slot;

[0299] The second determination unit is configured to determine that the variable write instruction meets the preset write condition when the index value corresponding to the variable write instruction does not match the storage slot.

[0300] In specific implementation, each of the above units can be implemented as an independent entity, or can be combined arbitrarily to be implemented as the same or several entities. For the specific implementation of each of the above units, reference can be made to the foregoing method embodiments, which will not be elaborated herein.

[0301] The embodiments of the present application further provide an electronic device, which may be a device such as a terminal, a server, etc. Among them, the terminal may be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer, etc.; the server may be a single server or a server cluster composed of multiple servers, etc.

[0302] In some embodiments, the transaction execution device may also be integrated in multiple electronic devices. For example, the transaction execution device may be integrated in multiple servers, and the transaction execution method of the present application may be implemented by multiple servers.

[0303] In this embodiment, the electronic device of this embodiment will be taken as an example for detailed description. For example, as Figure 4 shown, it shows a schematic structural diagram of the electronic device involved in the embodiments of the present application. Specifically:

[0304] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, an input module 404, and a communication module 405. Those skilled in the art can understand that Figure 4 the structure of the electronic device shown in

[0305] does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Among them:

[0306] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the electronic device. In addition, the memory 402 can include high-speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 402 can also include a memory controller to provide the processor 401 with access to the memory 402.

[0307] The electronic device further includes a power supply 403 for powering each component. In some embodiments, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 403 can also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.

[0308] The electronic device may further include an input module 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0309] The electronic device may further include a communication module 405. In some embodiments, the communication module 405 can include a wireless module. The electronic device can perform short-range wireless transmission through the wireless module of the communication module 405, thereby providing users with wireless broadband Internet access. For example, the communication module 405 can be used to help users send and receive emails, browse the web, and access streaming media, etc.

[0310] Although not shown, the electronic device may further include a display unit, etc., which will not be elaborated here. Specifically, in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402 to implement various functions.

[0311] For the specific implementation of the above operations, reference can be made to the previous embodiments, which will not be elaborated here.

[0312] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions or by controlling related hardware through instructions. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0313] Therefore, an embodiment of the present application provides a computer-readable storage medium storing multiple instructions that can be loaded by a processor to execute the steps in any one of the transaction execution methods provided by the embodiments of the present application.

[0314] Among them, the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.

[0315] According to one aspect of the present application, there is provided a computer program product or computer program. The computer program product or computer program includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in the above embodiments.

[0316] Since the instructions stored in the storage medium can execute the steps in any one of the transaction execution methods provided by the embodiments of the present application, the beneficial effects achievable by any one of the transaction execution methods provided by the embodiments of the present application can be realized. For details, see the previous embodiments and will not be elaborated here.

[0317] The above has introduced in detail a transaction execution method, device, electronic device, and computer-readable storage medium provided by the embodiments of the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.

Claims

1. A transaction execution method, characterized in that, it includes: Obtain a transaction request for a smart contract; The transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function; Generate a unique value corresponding to each transaction among the multiple transactions according to the transaction information and the unique value generation function; Based on the unique values, concurrently execute each transaction to obtain the execution result of each transaction corresponding to the smart contract.

2. The method according to claim 1, characterized in that, The generating a unique value corresponding to each transaction among the multiple transactions according to the transaction information and the unique value generation function includes: Extract the transaction quantity of the multiple transactions from the transaction information; Call the unique value generation function according to the transaction quantity to generate a unique value corresponding to each transaction among the multiple transactions.

3. The method according to claim 2, characterized in that, Before extracting the transaction quantity of the multiple transactions from the transaction information, the method further includes: Detect a preset tag in the transaction request, where the preset tag is used to indicate that multiple transactions requested to be executed by the transaction request need to be executed concurrently; When the preset tag is detected in the transaction request, execute the step of extracting the transaction quantity of the multiple transactions from the transaction information.

4. The method according to claim 3, characterized in that, Before detecting the preset tag in the transaction request, the method further includes: Obtain the current transaction, where the current transaction is a transaction executed by the blockchain corresponding to the smart contract at the current moment; When the current transaction is one of the multiple transactions requested to be executed by the transaction request, execute the step of detecting the preset tag in the transaction request.

5. The method according to claim 1, characterized in that, Before obtaining the transaction request for the smart contract, the method further includes: Obtain a contract deployment request for the smart contract; According to the contract deployment request, establish a contract file in the smart contract; Store the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file.

6. The method according to claim 5, characterized in that, The storing the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file includes: Parse the state variables of the contract source code of the smart contract to obtain at least one state variable; Obtain the storage slot and variable identifier of each state variable in the at least one state variable; Determine the state variable whose variable identifier in the at least one state variable matches the unique value identifier as the target state variable; Determine the storage slot corresponding to the target state variable as the target storage slot; Based on the target storage slot, store the unique value identifier corresponding to the contract deployment request and the unique value generation function corresponding to the unique value identifier into the contract file.

7. The method according to claim 1, characterized in that, After generating the unique value corresponding to each of the multiple transactions according to the transaction information and the unique value generation function, the method further includes: Extracting the transaction number of each transaction from the transaction information; Based on the transaction number of each transaction, storing the unique value corresponding to each transaction among the multiple transactions in a specified storage area.

8. The method according to claim 7, wherein, Before concurrently executing each transaction based on the unique value to obtain the execution result of each transaction corresponding to the smart contract, the method further includes: Obtaining a variable reading instruction corresponding to the current transaction; When the variable reading instruction meets a preset reading condition, obtaining the transaction number corresponding to the current transaction; Extracting the unique value corresponding to the current transaction from the specified storage area according to the transaction number corresponding to the current transaction.

9. The method according to claim 8, wherein, The smart contract includes a pre-established contract file, and the contract file includes a unique value identifier and a storage slot corresponding to the unique value identifier. The method further includes: Obtaining an index value corresponding to the variable reading instruction; Comparing the index value with the storage slot; When the index matches the storage slot, determining that the variable reading instruction meets the preset reading condition.

10. The method according to claim 7, wherein, The method further includes: Obtaining a variable writing instruction corresponding to the current transaction; When the variable writing instruction meets a preset writing condition, executing the variable writing instruction.

11. The method according to claim 10, wherein, The method further includes: Detecting a preset tag in the transaction request, where the preset tag is used to indicate that multiple transactions requested by the transaction request need to be executed concurrently; When it is detected that the preset tag does not exist in the transaction request, determining that the variable writing instruction meets the preset writing condition.

12. The method according to claim 10, wherein, The method further includes: Detecting a preset tag in the transaction request, where the preset tag is used to indicate that multiple transactions requested by the transaction request need to be executed concurrently; When it is detected that the preset tag exists in the transaction request, obtaining an index value corresponding to the variable writing instruction; Comparing the index value corresponding to the variable writing instruction with the storage slot; When the index value corresponding to the variable writing instruction does not match the storage slot, determining that the variable writing instruction meets the preset writing condition.

13. A transaction execution device, wherein, Comprising: An obtaining unit, configured to obtain a transaction request for a smart contract; The transaction request carries transaction information of multiple transactions, and the smart contract includes a unique value generation function; A generating unit, configured to generate a unique value corresponding to each of the multiple transactions according to the transaction information and the unique value generation function; An execution unit, configured to concurrently execute each transaction based on the unique value to obtain the execution result of each transaction corresponding to the smart contract.

14. An electronic device, wherein, It includes a processor and a memory, and the memory stores multiple instructions; the processor loads the instructions from the memory to execute the steps in the transaction execution method according to any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that the computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the transaction execution method according to any one of claims 1 to 12.

16. A computer program product, characterized in that it includes a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps in the transaction execution method according to any one of claims 1 to 12 are implemented.