WO2024092932A1 - 交易执行方法和区块链节点 - Google Patents

交易执行方法和区块链节点 Download PDF

Info

Publication number
WO2024092932A1
WO2024092932A1 PCT/CN2022/135423 CN2022135423W WO2024092932A1 WO 2024092932 A1 WO2024092932 A1 WO 2024092932A1 CN 2022135423 W CN2022135423 W CN 2022135423W WO 2024092932 A1 WO2024092932 A1 WO 2024092932A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
target
read
executed
node
Prior art date
Application number
PCT/CN2022/135423
Other languages
English (en)
French (fr)
Inventor
刘晓建
Original Assignee
蚂蚁区块链科技(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 蚂蚁区块链科技(上海)有限公司 filed Critical 蚂蚁区块链科技(上海)有限公司
Publication of WO2024092932A1 publication Critical patent/WO2024092932A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials

Definitions

  • the embodiments of this specification belong to the field of blockchain technology, and more particularly to a transaction execution method and a blockchain node.
  • Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc.
  • data blocks are combined into a chain data structure in a sequential manner according to time order, and a distributed ledger that cannot be tampered with or forged is guaranteed by cryptography. Due to the characteristics of blockchain such as decentralization, information cannot be tampered with, and autonomy, blockchain has also received more and more attention and application.
  • each participating node in the blockchain system needs to execute a transaction independently. That is to say, the same transaction needs to be executed on each participating node in the blockchain system, which will lead to a waste of computing resources.
  • the embodiments of this specification provide a transaction execution method and a blockchain node, which can reduce the redundancy of transaction execution in a blockchain system and reduce the waste of computing resources in the blockchain system.
  • a transaction execution method which is applied to a first node of a blockchain, and the method includes: based on read-write sets of multiple transactions, grouping the multiple transactions to obtain multiple first transaction groups, and the multiple first transaction groups access different variables; obtaining a target read set and a target write set generated by a second node executing the target first transaction group through a trusted execution environment; verifying the target read set based on a world state; and if the verification passes, using the target write set as the execution result of the target first transaction group.
  • a blockchain node including: a grouping unit, configured to group the multiple transactions based on read-write sets to obtain multiple first transaction groups, wherein the multiple first transaction groups access different variables; an acquisition unit, configured to acquire a target read set and a target write set generated by a second node executing the target first transaction group through a trusted execution environment; a verification unit, configured to verify the target read set based on a world state; and a result determination unit, configured to use the target write set as the execution result of the target first transaction group if the verification passes.
  • a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed in a computer, the computer is caused to execute the method described in any implementation manner in the first aspect.
  • a blockchain node comprising a memory and a processor, wherein an executable code is stored in the memory, and when the processor executes the executable code, a method as described in any implementation manner in the first aspect is implemented.
  • the transaction execution method and blockchain node provided by the embodiment of this specification, first, based on the read-write sets of multiple transactions, multiple transactions are grouped to obtain multiple first transaction groups, and multiple first transaction groups access different variables, so multiple first transaction groups can be executed in parallel.
  • the first node can obtain the target read set and target write set generated by the second node executing the target first transaction group through the trusted execution environment, and verify the target read set based on the world state. If the verification passes, the target write set is used as the execution result of the target first transaction group. Since the target write set is generated by the trusted execution environment of the second node, and the trusted execution environment can ensure the security, authentication and integrity of its internal code.
  • the expected execution result can be obtained through the trusted execution environment. Therefore, when the target read set verification passes, the target write set obtained through the trusted execution environment is credible. Therefore, the first node can store the target write set as the execution result of the target first transaction group locally, and the local does not need to execute the transactions in the target first transaction group. As a result, the redundancy of transaction execution in the blockchain system can be reduced, and the waste of computing resources in the blockchain system can be reduced. And multiple first transaction groups can be executed in parallel, which improves the efficiency of transaction execution.
  • FIG1 shows a blockchain architecture diagram in one embodiment
  • FIG2 is a schematic diagram showing an application scenario in which the embodiments of this specification can be applied.
  • FIG3 shows a schematic flow chart of a transaction execution method according to an embodiment
  • FIG4 shows a schematic diagram of the structure of a blockchain node according to an embodiment.
  • FIG. 1 shows a diagram of a blockchain architecture in one embodiment.
  • 8 nodes are included in the blockchain 100.
  • the lines between the nodes schematically represent P2P (Peer to Peer) connections.
  • P2P Peer to Peer
  • These nodes can store a full amount of ledgers, that is, the status of all blocks and all accounts.
  • each node in the blockchain can generate the same state in the blockchain by executing the same transaction, and each node in the blockchain can store the same state database.
  • FIG. 1 shows that the blockchain includes 8 nodes, the embodiments of this specification are not limited to this, but may include other numbers of nodes.
  • Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain.
  • Transactions usually include a send field (From), a receive field (To), and a data field (Data).
  • the From field indicates the account address that initiates the transaction (i.e., initiates a transfer task to another account)
  • the To field indicates the account address that receives the transaction (i.e., receives the transfer)
  • the Data field includes the transfer amount.
  • the From field indicates the account address that initiates the transaction
  • the To field indicates the account address of the contract called by the exchange
  • the Data field includes the function name in the calling contract, and the incoming parameters of the function, etc., which are used to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
  • the blockchain can provide the function of smart contracts.
  • Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system.
  • Smart contracts can be defined in the form of code. Calling a smart contract in Ethereum is to initiate a transaction pointing to the smart contract address, so that each node in the Ethereum network runs the smart contract code in a distributed manner.
  • smart contracts can also be set by the system in the genesis block. This type of contract is generally called a genesis contract.
  • genesis contract Generally, some blockchain data structures, parameters, properties and methods can be set in the genesis contract.
  • accounts with system administrator privileges can create system-level contracts or modify system-level contracts (referred to as system contracts). Among them, the system contract can be used to add data structures of data for different businesses in the blockchain.
  • Bob sends a transaction containing information about creating a smart contract (i.e., deploying a contract) to the blockchain shown in Figure 1.
  • the data field of the transaction includes the code of the contract to be created (such as bytecode or machine code), and the to field of the transaction is empty to indicate that the transaction is used to deploy a contract.
  • the contract address "0x6f8ae93" of the contract is determined, and each node adds a contract account corresponding to the contract address of the smart contract in the state database, allocates the state storage corresponding to the contract account, and saves the contract code in the state storage of the contract, so that the contract is successfully created.
  • Bob sends a transaction for calling a smart contract to the blockchain shown in Figure 1.
  • the from field of the transaction is the address of the account of the transaction initiator (i.e. Bob), and the "0x6f8ae93" in the to field represents the address of the smart contract being called.
  • the data field of the transaction includes the method and parameters for calling the smart contract.
  • each participating node in the blockchain system needs to execute a transaction independently. That is, the same transaction needs to be executed on each participating node in the blockchain system, which will lead to a waste of computing resources.
  • FIG. 2 shows a schematic diagram of an application scenario in which the embodiment of this specification can be applied.
  • node A can obtain multiple transactions Tx1, Tx2, Tx3, Tx4, Tx5...TxN after consensus, and read-write sets of multiple transactions, wherein the read-write set may include variables that need to be read and written in the process of executing the transaction.
  • Node A can group multiple transactions based on the read-write sets of multiple transactions to obtain multiple first transaction groups such as ⁇ Tx1, Tx3, Tx4, Tx8 ⁇ , ⁇ Tx2, Tx5, Tx11 ⁇ , ⁇ Tx6, Tx11, Tx12 ⁇ , etc., wherein multiple first transaction groups access different variables.
  • multiple first transaction groups can be executed in parallel.
  • Node A can obtain the target read set and target write set generated by node B executing the target first transaction group ⁇ Tx2, Tx5, Tx11 ⁇ through the trusted execution environment.
  • the target read set may include variables and variable information (for example, variable values, hashes of variable values, etc.) that need to be read
  • the target write set may include variables and variable values that need to be written.
  • Node A can verify the target read set based on the locally stored world state. If the verification passes, node A can use the target write set as the execution result of the target first transaction group ⁇ Tx2, Tx5, Tx11 ⁇ , and update the local world state according to the execution result.
  • node A does not need to execute the transactions in the target first transaction group ⁇ Tx2, Tx5, Tx11 ⁇ to obtain the execution result.
  • transactions in the same transaction group no longer need to be executed by all nodes, which can reduce the redundancy of transaction execution in the blockchain system and reduce the waste of computing resources in the blockchain system.
  • multiple first transaction groups can be executed in parallel, which can improve the efficiency of transaction execution.
  • FIG. 3 shows a flow chart of a transaction execution method according to an embodiment.
  • the method can be executed by a first node and a second node of a blockchain system. It can be understood that each node in the blockchain can execute a transaction like the first node or the second node.
  • the transaction execution method can include the following steps:
  • Step S301 The first node groups multiple transactions based on the read-write sets of the multiple transactions to obtain multiple first transaction groups.
  • the first node can obtain multiple transactions after consensus and determine the read-write sets of multiple transactions.
  • the read-write set can include a read set (Rset) and a write set (Wset)
  • the read set can include variables that need to be read in the process of executing the transaction
  • the write set can include variables that need to be written in the process of executing the transaction.
  • the first node can group multiple transactions based on the read-write sets of multiple transactions to obtain multiple first transaction groups.
  • multiple first transaction groups access different variables. In other words, there is no read-write conflict between multiple first transaction groups, and the change of the world state caused by the execution of one first transaction group will not affect the execution of other first transaction groups.
  • Multiple first transaction groups can be executed in parallel.
  • the read set and write set used when grouping multiple transactions may only include the variable name of the variable, but not the specific variable value.
  • the variable name and variable value can be recorded in the form of a key-value pair.
  • the read-write set used when grouping transactions may only include the key, but not the value.
  • each transaction can be statically analyzed to analyze the transaction body of the transaction and the contract code of the contract called in the transaction, so as to determine the account and/or variable name, i.e., key, that each transaction needs to read and write when executing.
  • the transaction is a transfer transaction
  • the read and write parameters in the transaction can be obtained based on the data analysis in the transaction.
  • the parameters for reading and writing in the transaction can be obtained based on the code analysis of the contract.
  • the consensus proposal node can also determine the account and/or variable name that each transaction needs to read and write when executing by pre-execution.
  • each node in the blockchain system can pre-store the same grouping algorithm to ensure that the grouping results in each node are the same, that is, the transactions and transaction order included in each group are the same.
  • the node can directly group them.
  • the node For the received private transactions, the node first needs to decrypt them in the private computing environment and then group the transactions.
  • Step S302 The second node executes the target first transaction group through the trusted execution environment, generates a target read set and a target write set, and sends the target read set and the target write set.
  • Step S303 The first node obtains a target read set and a target write set generated by the second node executing the target first transaction group through the trusted execution environment.
  • the smart contract of the blockchain can be deployed in the trusted execution environment (TEE) of each blockchain node, and the transaction can be executed in the trusted execution environment.
  • the first node can obtain the target read set and the target write set generated by the second node executing each transaction in the target first transaction group through the trusted execution environment.
  • the target read set and the target write set can include variable names and variable values, that is, Key and Value.
  • the target read set may include the KV pairs of variables that are first read by multiple transactions in the target first transaction group.
  • the target write set may include the KV pairs that will eventually be written to the database after multiple transactions in the target first transaction group are written.
  • the second node can send the target read set and the target write set directly (for example, in a broadcasting manner) to the first node, that is, the first node can directly obtain the target read set and the target write set from the second node.
  • the second node can store the target read set and the target write set in a preset storage location known to each node, so that the first node can obtain the target read set and the target write set from the storage location.
  • the trusted execution environment is a secure area built in the central processing unit through software and hardware methods to ensure that the programs and data loaded inside it are protected in terms of confidentiality and integrity.
  • the hardware and software resources of the system can be divided into a trusted execution environment and a normal execution environment.
  • the two execution environments are securely isolated, with independent internal data paths and storage space required for calculations.
  • Applications in the normal execution environment cannot access the TEE.
  • Even within the TEE the operation of multiple applications is independent of each other and cannot access each other without authorization. Therefore, when the input is determined, the expected execution result can be obtained through the trusted execution environment.
  • the trusted execution environment has the characteristic that if the input is trusted, the output must be trusted. For transactions executed by the trusted execution environment, as long as the correctness of its input data can be confirmed, the correctness of its execution result can be trusted.
  • the transaction execution method may further include the following:
  • the second node can also generate verification information for the target read set, and the verification information can be used to verify the integrity of the target read set. For example, assuming that the target read set includes multiple key-value pairs, the second node can connect multiple Values included in the multiple Key-Values to calculate a hash value, and use the hash value as the verification information. Similarly, the second node can also generate verification information for the target write set, and the verification information can be used to verify the integrity of the target write set. Afterwards, the second node can send the target read set and its verification information together, and send the target write set and its verification information together. In this way, the first node will also obtain the corresponding verification information while obtaining the target read set and the target write set.
  • the first node after receiving the target read set and its verification information, can verify the integrity of the target read set. Specifically, multiple Values included in multiple Key-Values in the target read set are connected to calculate a hash value, and the calculated hash value is compared with the verification information of the target read set. If the two are consistent, the target read set is confirmed to be complete. Similarly, after receiving the target write set and its verification information, the first node can verify the integrity of the target write set. If the integrity check of the target read set and the target write set passes, it means that the acquired target read set and the target write set are complete, and there is no data loss, Value tampering, etc. during the data transmission process. After confirming the integrity of the target read set and the target write set, the subsequent verification of the target read set can be performed.
  • Step S304 The first node verifies the target read set based on the world state.
  • the first node can verify the acquired target read set. Specifically, the first node can determine whether the variable value in the target read set is consistent with the variable value in the locally stored world state. If they are consistent, it means that the verification is passed; if they are inconsistent, it means that the verification fails. If the verification fails, it means that the target read set is unreliable, and the target read set and the target write set can be discarded.
  • Step S305 If the verification is successful, the first node uses the target write set as the execution result of the target first transaction group.
  • the first node when the target read set is verified, the first node can use the target write set as the execution result of the target first transaction group to update the locally stored world state. Therefore, the first node does not need to execute the transactions in the target first transaction group.
  • the status of the transaction group with execution results can be set to executed, and the status of the transaction group without execution results can be set to unexecuted.
  • the transaction execution method can also include the following steps:
  • Step 1 Select a first transaction group from the first transaction groups in the unexecuted state as the to-be-executed first transaction group, and execute the transactions in the to-be-executed first transaction group in the trusted execution environment.
  • the first node may select a first transaction group from the first transaction groups that are in an unexecuted state as the first transaction group to be executed in various ways, such as a random selection method. Afterwards, the first node may execute each transaction in the first transaction group to be executed in the trusted execution environment.
  • Step 2 Send the read set and write set generated when the first transaction group to be executed is executed.
  • the first node can send the read set and write set generated when the first transaction group to be executed is executed for verification and storage by other nodes in the blockchain system.
  • the first node can directly send the read set and write set generated when the first transaction group to be executed is executed to other nodes, for example, by broadcasting to other nodes.
  • the first node can also send the read set and write set generated when the first transaction group to be executed is executed to a preset storage location. In this way, other nodes can go to the storage location to pull the read set and write set generated when the transaction group is executed.
  • the first node can select (for example, randomly select) the unexecuted first transaction grouping for execution, and send the read-write set generated during the execution for verification and storage by other nodes.
  • the number of unexecuted first transaction groups will decrease until all are executed.
  • a first transaction grouping may be executed by multiple nodes, so that even if a node in the blockchain fails or acts maliciously, it will not cause the entire blockchain to stop working.
  • the multiple transactions obtained by the first node are arranged in order. Based on this, the above-mentioned read-write set based on multiple transactions, grouping multiple transactions to obtain multiple first transaction groups, can be specifically implemented as follows:
  • the plurality of first transactions are grouped according to the read-write sets of the plurality of first transactions to obtain a plurality of first transaction groups.
  • the transactions ranked in the top N% can be taken as first transactions, and the multiple first transactions can be grouped according to the read-write sets of the multiple first transactions to obtain multiple first transaction groups. There is no read-write conflict between the multiple first transaction groups obtained by grouping, and the multiple first transaction groups can be executed in parallel.
  • the remaining transactions that is, the transactions arranged in the last (100-N)%, are divided into the same group, and the group is used as the second transaction group.
  • the first transaction group and the second transaction group are executed serially. Specifically, after all multiple first transaction groups are executed, the second transaction group is executed. It can be understood that after grouping, the order of transactions in each transaction group is the same as before grouping. For example, suppose that transaction TxA is ranked before transaction TxB before grouping. After grouping, transaction TxA and transaction TxB are divided into the same transaction group, and in this transaction group, transaction TxA is still ranked before transaction TxB. Through this implementation method, multiple transactions can be divided into a first transaction group and a second transaction group.
  • the transaction execution method may further include the following contents:
  • the first node in response to determining that the states of the plurality of first transaction groups are all executed, the first node may further determine whether to obtain the read set and the write set generated by other nodes executing the second transaction group through the trusted execution environment.
  • the first node can verify the obtained read set of the second transaction group based on the locally stored world state. If the verification passes, the obtained write set of the second transaction group is used as the execution result of the second transaction group to update the locally stored world state. As a result, the first node does not need to execute the second transaction group again.
  • the first node may execute the transactions in the second transaction group in the trusted execution environment.
  • the first node may send the read set and write set generated when the second transaction group is executed, for example, by broadcasting to other nodes, or by sending to a preset storage location for other nodes to obtain.
  • the first node can obtain the target read set and target write set generated by the second node executing the target first transaction group through the trusted execution environment, and verify the target read set based on the world state. If the verification passes, the target write set is used as the execution result of the target first transaction group. Since the target write set is generated by the trusted execution environment of the second node, and the trusted execution environment can ensure the security, authentication and integrity of its internal code. Therefore, when the input is determined, the expected execution result can be obtained through the trusted execution environment.
  • the target write set obtained through the trusted execution environment is credible. Therefore, the first node can store the target write set as the execution result of the target first transaction group locally, and the local does not need to execute the transactions in the target first transaction group. As a result, the redundancy of transaction execution in the blockchain system can be reduced, and the waste of computing resources in the blockchain system can be reduced. And multiple first transaction groups can be executed in parallel, which improves the efficiency of transaction execution.
  • a blockchain node is provided.
  • Figure 4 shows a schematic diagram of the structure of a blockchain node according to an embodiment.
  • the blockchain node 400 includes: a grouping unit 401, configured to group the above-mentioned multiple transactions based on the read-write sets of multiple transactions to obtain multiple first transaction groups, and the above-mentioned multiple first transaction groups access different variables; an acquisition unit 402, configured to obtain a target read set and a target write set generated by the second node executing the target first transaction group through a trusted execution environment; a verification unit 403, configured to verify the above-mentioned target read set based on the world state; a result determination unit 404, configured to use the above-mentioned target write set as the execution result of the target first transaction group when the verification is passed.
  • the blockchain node 400 also includes: an execution unit (not shown in the figure), configured to select a first transaction group from the first transaction groups with an unexecuted status as a first transaction group to be executed, and execute the transactions in the above-mentioned first transaction group to be executed in a trusted execution environment; a sending unit (not shown in the figure), configured to send the read set and the write set generated when the above-mentioned first transaction group to be executed is executed.
  • the sending unit is further configured to: send the read set and the write set generated when the above-mentioned first transaction group to be executed is executed to other nodes, or to a preset storage location.
  • the acquisition unit 402 is further configured to: acquire, from the second node or a preset storage location, a target read set and a target write set generated by the second node executing the target first transaction group through the trusted execution environment.
  • the blockchain node 400 further includes: an information acquisition unit (not shown in the figure), configured to obtain verification information of the above-mentioned target read set and verification information of the above-mentioned target write set generated by the above-mentioned target first transaction group; a verification unit (not shown in the figure), configured to verify the integrity of the above-mentioned target read set and the above-mentioned target write set according to the verification information.
  • the above-mentioned multiple transactions are arranged in order, and the grouping unit 401 is further configured to: for a plurality of first transactions with a preset proportion arranged at the top, group the above-mentioned multiple first transactions according to the read-write sets of the above-mentioned multiple first transactions to obtain multiple first transaction groups; and divide the remaining transactions into second transaction groups.
  • the blockchain node 400 further includes: a judgment unit (not shown in the figure), configured to, in response to determining that the status of the above-mentioned multiple first transaction groups is executed, determine whether the read set and write set generated by other nodes executing the above-mentioned second transaction group through the trusted execution environment are obtained; a verification and determination unit (not shown in the figure), configured to, if obtained, verify the obtained read set of the above-mentioned second transaction group based on the world state, and if the verification passes, use the obtained write set of the above-mentioned second transaction group as the execution result of the above-mentioned second transaction group; a second transaction group execution unit (not shown in the figure), configured to execute the transactions in the above-mentioned second transaction group in the trusted execution environment if not obtained; a read-write set sending unit (not shown in the figure), configured to send the read set and write set generated when the above-mentioned second transaction group is executed.
  • a judgment unit (not shown in the figure), configured to
  • a computer-readable storage medium is further provided, on which a computer program is stored.
  • the computer program is executed in a computer, the computer is caused to execute the method described in FIG. 3 .
  • a computing device including a memory and a processor, wherein executable code is stored in the memory, and when the processor executes the executable code, the method described in FIG. 3 is implemented.
  • a hardware improvement for example, improvements to the circuit structure of diodes, transistors, switches, etc.
  • a software improvement improvement of the method flow
  • PLD programmable logic device
  • FPGA field programmable gate array
  • HDL Hardware Description Language
  • HDL Very-High-Speed Integrated Circuit Hardware Description Language
  • ABEL Advanced Boolean Expression Language
  • AHDL Altera Hardware Description Language
  • HDCal Joint CHDL
  • JHDL Java Hardware Description Language
  • Lava Lava
  • Lola MyHDL
  • PALASM RHDL
  • VHDL Very-High-Speed Integrated Circuit Hardware Description Language
  • Verilog Verilog
  • the controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer readable medium storing a computer readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory.
  • a computer readable program code e.g., software or firmware
  • the controller may be implemented in the form of a logic gate, a switch, an application specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the means for implementing various functions included therein may also be considered as a structure within the hardware component. Or even, the means for implementing various functions may be considered as both a software module for implementing the method and a structure within the hardware component.
  • the systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions.
  • a typical implementation device is a server system.
  • the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
  • one or more embodiments of the present specification provide method operation steps as described in the embodiments or flow charts, more or less operation steps may be included based on conventional or non-creative means.
  • the order of steps listed in the embodiments is only one way of executing the order of many steps, and does not represent the only execution order.
  • the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment).
  • each module can be implemented in the same or more software and/or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units, etc.
  • the device embodiments described above are only schematic.
  • the division of the units is only a logical function division. There may be other division methods in actual implementation.
  • 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 through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
  • These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
  • a computing device includes one or more processors (CPU), input/output interfaces, network interfaces, and memory.
  • processors CPU
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in a computer-readable medium, in the form of random access memory (RAM) and/or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash memory
  • Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information.
  • Information can be computer readable instructions, data structures, program modules or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
  • computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
  • one or more embodiments of the present specification may be provided as a method, system or computer program product. Therefore, one or more embodiments of the present specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, one or more embodiments of the present specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules.
  • program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
  • One or more embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network.
  • program modules may be located in local and remote computer storage media, including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Strategic Management (AREA)
  • Signal Processing (AREA)
  • Technology Law (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • General Business, Economics & Management (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Development Economics (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本说明书实施例提供了一种交易执行方法和区块链节点。该方法的一具体实施方式包括:基于多个交易的读写集,对所述多个交易进行分组得到多个第一交易分组,所述多个第一交易分组访问不相同的变量;获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集;基于世界状态对所述目标读集进行验证;在验证通过的情况下,将所述目标写集作为目标第一交易分组的执行结果。

Description

交易执行方法和区块链节点
本申请要求于2022年10月31日提交中国国家知识产权局、申请号为202211346010.1、申请名称为“交易执行方法和区块链节点”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本说明书实施例属于区块链技术领域,尤其涉及一种交易执行方法和区块链节点。
背景技术
区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链系统中按照时间顺序将数据区块以顺序相连的方式组合成链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。由于区块链具有去中心化、信息不可篡改、自治性等特性,区块链也受到人们越来越多的重视和应用。
在当前区块链技术中,区块链系统的每个参与节点都需要独立执行一遍交易,也就是说,同一个交易需要在区块链系统中的每个参与节点上都执行一遍,这会导致计算资源的浪费。
发明内容
本说明书的实施例提供了一种交易执行方法和区块链节点,可以减少区块链系统中交易执行的冗余度,降低区块链系统中计算资源的浪费。
根据第一方面,提供了一种交易执行方法,应用于区块链的第一节点,上述方法包括:基于多个交易的读写集,对上述多个交易进行分组得到多个第一交易分组,上述多个第一交易分组访问不相同的变量;获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集;基于世界状态对上述目标读集进行验证;在验证通过的情况下,将上述目标写集作为目标第一交易分组的执行结果。
根据第二方面,提供了一种区块链节点,包括:分组单元,配置为基于多个交易的读写集,对上述多个交易进行分组得到多个第一交易分组,上述多个第一交易分组访问不相同的变量;获取单元,配置为获取第二节点通过可信执行环境执行目标第一 交易分组所产生的目标读集和目标写集;验证单元,配置为基于世界状态对上述目标读集进行验证;结果确定单元,配置为在验证通过的情况下,将上述目标写集作为目标第一交易分组的执行结果。
根据第三方面,提供了一种计算机可读存储介质,其上存储有计算机程序,当上述计算机程序在计算机中执行时,令计算机执行如第一方面中任一实现方式描述的方法。
根据第四方面,提供了一种区块链节点,包括存储器和处理器,其特征在于,上述存储器中存储有可执行代码,上述处理器执行上述可执行代码时,实现如第一方面中任一实现方式描述的方法。
根据本说明书实施例提供的交易执行方法和区块链节点,首先,基于多个交易的读写集,对多个交易进行分组得到多个第一交易分组,多个第一交易分组访问不相同的变量,因此,多个第一交易分组可以并行执行。基于此,第一节点可以获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集,并基于世界状态对目标读集进行验证,在验证通过的情况下,将目标写集作为目标第一交易分组的执行结果。由于目标写集是由第二节点的可信执行环境产生的,而可信执行环境可以保证其内部代码的安全性、认证性和完整性。所以,在输入确定的情况下,通过可信执行环境可以得到预期执行结果。因此,在目标读集验证通过的情况下,通过可信执行环境得到的目标写集可信。所以第一节点可以将目标写集作为目标第一交易分组的执行结果存储到本地,而本地不需要执行目标第一交易分组中的交易。由此,可以减少区块链系统中交易执行的冗余度,降低区块链系统中计算资源的浪费。且多个第一交易分组可以并行执行,提高了交易执行的效率。
附图说明
为了更清楚地说明本说明书实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1示出了一个实施例中的区块链架构图;
图2示出了本说明书实施例可以应用于其中的一个应用场景的示意图;
图3示出了根据一个实施例的交易执行方法的流程示意图;
图4示出了根据一个实施例的区块链节点的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。
图1示出了一实施例中的区块链架构图。在图1所示的区块链架构图中,区块链100中例如包含8个节点。节点之间的连线示意性的表示P2P(Peer to Peer,点对点)连接。这些节点上可存储全量的账本,即存储全部区块和全部账户的状态。其中,区块链中的每个节点可通过执行相同的交易而产生区块链中的相同的状态,区块链中的每个节点可存储相同的状态数据库。可以理解,图1中虽然示出了区块链中包括8个节点,本说明书实施例不限于此,而是可以包括其他数目的节点。
区块链领域中的交易可以指在区块链中执行并记录在区块链中的任务单元。交易中通常包括发送字段(From)、接收字段(To)和数据字段(Data)。其中,在交易为转账交易的情况中,From字段表示发起该交易(即发起对另一个账户的转账任务)的账户地址,To字段表示接收该交易(即接收转账)的账户地址,Data字段中包括转账金额。在交易调用区块链中的智能合约的情况中,From字段表示发起该交易的账户地址,To字段表示交易所调用的合约的账户地址,Data字段中包括调用合约中的函数名、及对该函数的传入参数等数据,以用于在交易执行时从区块链中获取该函数的代码并执行该函数的代码。
区块链中可提供智能合约的功能。区块链上的智能合约是在区块链系统上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。在以太坊中调用智能合约,是发起一笔指向智能合约地址的交易,使得以太坊网络中每个节点分布式地运行智能合约代码。需要说明的是,除了可以由用户创建智能合约,也可以在创世块中由系统设置智能合约。这类合约一般称为创世合约。一般的,创世合约中可以设置一些区块链的数据结构、参数、属性和方法。此外,具有系统管理员权限的账户可以创建系统级的合约,或者修改系统级的合约(简称为系统合约)。其中,所述系统合约可用于在区块链中增加不同业务的数据的数据结构。
在部署合约的场景中,例如,Bob将一个包含创建智能合约信息(即部署合约)的交易发送到如图1所示的区块链中,该交易的data字段包括待创建的合约的代码(如字节码或者机器码),交易的to字段为空,以表示该交易用于部署合约。节点间通过共识机制达成一致后,确定合约的合约地址“0x6f8ae93…”,各个节点在状态数据库中添加与该智能合约的合约地址对应的合约账户,分配与该合约账户对应的状态存储,并将合约代码保存在该合约的状态存储中,从而合约创建成功。
在调用合约的场景中,例如,Bob将一个用于调用智能合约的交易发送到如图1所示的区块链中,该交易的from字段是交易发起方(即Bob)的账户的地址,to字段中的“0x6f8ae93…”代表了被调用的智能合约的地址,交易的data字段包括调用智能合约的方法和参数。在区块链中对该交易进行共识之后,区块链中的各个节点可分别执行该交易,从而分别执行该合约,基于该合约的执行更新状态数据库。
如前所述,在当前区块链技术中,区块链系统的每个参与节点都需要独立执行一遍交易,也就是说,同一个交易需要在区块链系统中的每个参与节点上都执行一遍,这会导致计算资源的浪费。
为此,本说明书的实施例提供了一种交易执行方法,从而减少区块链系统中交易执行的冗余度,降低区块链系统中计算资源的浪费。作为示例,图2示出了本说明书实施例可以应用于其中的一个应用场景的示意图。如图2所示,在本应用场景中,节点A可以获取到经过共识后的多个交易Tx1、Tx2、Tx3、Tx4、Tx5……TxN,以及多个交易的读写集,其中,读写集中可以包括执行交易的过程中需要读取的变量和写入的变量。节点A可以基于多个交易的读写集,对多个交易进行分组,得到{Tx1、Tx3、Tx4、Tx8}、{Tx2、Tx5、Tx11}、{Tx6、Tx11、Tx12}、……等多个第一交易分组,其中,多个第一交易分组访问不相同的变量。也就是说,多个第一交易分组的访问变量没有读写冲突,一个分组的执行导致的世界状态的改变不会影响另一个分组的执行。因此,多个第一交易分组可以并行执行。
节点A可以获取节点B通过可信执行环境执行目标第一交易分组{Tx2、Tx5、Tx11}所产生的目标读集和目标写集。其中,目标读集可以包括需要读取的变量以及变量信息(例如,变量值、变量值的哈希等等),目标写集可以包括需要写入的变量以及变量值。节点A可以基于本地存储的世界状态对目标读集进行验证,在验证通过的情况下,节点A可以将目标写集作为目标第一交易分组{Tx2、Tx5、Tx11}的执行结果,并根据执行结果更新本地的世界状态。由此,节点A不需要执行目标第一交易分组{Tx2、Tx5、 Tx11}中的交易,就可以得到执行结果。这样,同一个交易分组中的交易不再需要所有的节点都执行,可以减少区块链系统中交易执行的冗余度,降低区块链系统中计算资源的浪费。且多个第一交易分组可以并行执行,可以提高了交易执行的效率。
继续参见图3,图3示出了根据一个实施例的交易执行方法的流程图。该方法可以由区块链系统的第一节点和第二节点执行,可以理解,区块链中的各个节点都可以如第一节点或第二节点那样执行交易。如图3所示,该交易执行方法,可以包括以下步骤:
步骤S301,第一节点基于多个交易的读写集,对多个交易进行分组得到多个第一交易分组。
在本实施例中,第一节点可以获取到经过共识后的多个交易,并确定多个交易的读写集。其中,读写集可以包括读集(Rset)和写集(Wset),读集可以包括执行交易的过程中需要读取的变量,写集可以包括执行交易的过程中需要写入的变量。实践中,如果两个交易的访问变量没有读写冲突,则其中一个交易的执行导致的世界状态的改变不会影响另一个交易的执行,因此,这两个交易可以并行执行。如果两个交易的访问变量存在读写冲突,则只能串行执行。基于此,第一节点可以基于多个交易的读写集,对多个交易进行分组得到多个第一交易分组。其中,多个第一交易分组访问不相同的变量。也就是说,多个第一交易分组之间没有读写冲突,一个第一交易分组的执行导致的世界状态的改变,不会影响其他第一交易分组的执行。多个第一交易分组之间可以并行执行。
可以理解,对多个交易进行分组时所使用的读集和写集,可以只包括变量的变量名,而不包括具体的变量值。举例来说,变量名和变量值可以以键值(Key-Value)对的形式进行记录。交易分组时所使用的读写集中可以只包括Key,而不包括Value。作为一个示例,可以对各个交易进行静态分析,分析交易的交易体以及交易中调用的合约的合约代码,从而确定各个交易在执行时需要读取和写入的账户和/或变量名称,即key。举例来说,如果交易为转账交易,可以根据交易中的数据分析得到交易中的读写参数。如果交易是调用合约的交易,可以根据合约的代码分析得到交易中读写的参数。作为另一示例,还可以是共识提议节点通过预执行的方式,确定各个交易在执行时需要读取和写入的账户和/或变量名称。
可以理解,区块链系统中的各个节点可以预先存储有相同的分组算法,从而保证各个节点内的分组结果相同,即,各分组中包括的交易和交易顺序相同。对于接收到的明文交易,节点可以直接进行分组。对于接收到的隐私交易,节点首先需要在隐私 计算环境中进行解密,然后再进行交易分组。
步骤S302,第二节点通过可信执行环境执行目标第一交易分组,生成目标读集和目标写集,并将目标读集和目标写集进行发送。
步骤S303,第一节点获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集。
在本实施例中,区块链的智能合约可以部署在各区块链节点的可信执行环境(Trusted Execution Environment,TEE)中,交易可以在可信执行环境中执行。第一节点可以获取第二节点通过可信执行环境执行目标第一交易分组中的各个交易所产生的目标读集和目标写集。这里,目标读集和目标写集中可以包含变量名和变量值,即,包含Key和Value。举例来说,目标读集可以包括目标第一交易分组中多个交易首次读取的变量的KV对。目标写集可以包括目标第一交易分组中多个交易进行写入之后最终将要写入数据库的KV对。作为一个示例,第二节点可以将目标读集和目标写集直接发送(例如,以广播的方式)给第一节点,即,第一节点可以直接从第二节点获取目标读集和目标写集。作为另一个示例,第二节点可以将目标读集和目标写集存储到一个预设的、各个节点都知晓的存储位置,这样,第一节点可以从该存储位置获取目标读集和目标写集。
可信执行环境是通过软硬件方法在中央处理器中构建的一个安全区域,保证其内部加载的程序和数据在机密性和完整性上得到保护。实践中,可以将系统的硬件和软件资源划分为可信执行环境和普通执行环境。这两个执行环境是安全隔离的,有独立的内部数据通路和计算所需存储空间。普通执行环境的应用程序无法访问TEE,即使在TEE内部,多个应用的运行也是相互独立的,不能无授权而互访。因此,在输入确定的情况下,通过可信执行环境可以得到预期执行结果。也就是说,可信执行环境具有输入可信则输出一定可信的特征,针对可信执行环境所执行的交易,只要能够确认其输入数据的正确性,就可以相信其执行结果的正确性。
在一些可选的实现方式中,上述交易执行方法还可以包括以下内容:
①,获取目标第一交易分组所产生的目标读集的校验信息和目标写集的校验信息。
在本实现方式中,第二节点还可以生成目标读集的校验信息,该校验信息可以用于校验目标读集的完整性。举例来说,假设目标读集包括多个键值(Key-Value)对,第二节点可以将多个Key-Value中包括的多个Value连接起来计算一个哈希值,并将该哈希值作为校验信息。同理,第二节点还可以生成目标写集的校验信息,该校验信息 可以用于校验目标写集的完整性。之后,第二节点可以将目标读集及其校验信息一并发送,将目标写集及其校验信息一并发送。这样,第一节点在获取目标读集和目标写集的同时也会获取对应的校验信息。
②,根据校验信息校验目标读集和目标写集的完整性。
在本实现方式中,第一节点在接收到目标读集及其校验信息之后,可以校验目标读集的完整性。具体的,使用目标读集中的多个Key-Value中包括的多个Value连接起来计算哈希值,并将计算的哈希值与目标读集的校验信息进行比较,如果两者一致,则确认目标读集完整。同理,第一节点在接收到目标写集及其校验信息之后,可以校验目标写集的完整性。目标读集和目标写集完整性校验通过,则表示获取的目标读集和目标写集是完整的,数据传输过程中不存在数据丢失、Value被篡改等问题。在确认目标读集和目标写集的完整性之后,才可以进行后续的目标读集的验证。
步骤S304,第一节点基于世界状态对目标读集进行验证。
在本实施例中,第一节点可以对所获取的目标读集进行验证。具体的,第一节点可以判断目标读集中的变量值与本地存储的世界状态中的变量值是否一致,如果一致,则表示验证通过;如果不一致,则表示验证不通过。如果验证不通过,则表示目标读集不可信,可以丢弃目标读集和目标写集。
步骤S305,在验证通过的情况下,第一节点将目标写集作为目标第一交易分组的执行结果。
在本实施例中,在对目标读集验证通过的情况下,第一节点可以将目标写集作为目标第一交易分组的执行结果,以用于更新本地存储的世界状态。由此,第一节点不需要再执行目标第一交易分组中的交易。
在一些可选的实现方式中,可以将具有执行结果的交易分组的状态设置为已执行,将不具有执行结果的交易分组的状态设置为未执行。基于此,上述交易执行方法还可以包括以下步骤:
步骤一,从状态为未执行的第一交易分组中选取一个第一交易分组作为待执行第一交易分组,在可信执行环境中执行待执行第一交易分组中的交易。
在本实现方式中,第一节点可以采用各种方式,例如,随机选取的方式,从状态为未执行的第一交易分组中选取一个第一交易分组作为待执行第一交易分组。之后,第一节点可以在可信执行环境中执行待执行第一交易分组中的各个交易。
步骤二,将待执行第一交易分组执行时生成的读集和写集进行发送。
在本实现方式中,第一节点可以将待执行第一交易分组执行时,生成的读集和写集进行发送,以供区块链系统中的其他节点验证和存储。作为一个示例,第一节点可以将待执行第一交易分组执行时生成的读集和写集,直接发送给其他节点,例如,以广播的方式发送给其他节点。作为另一个示例,第一节点也可以将待执行第一交易分组执行时生成的读集和写集发送到一个预设的存储位置。这样,其他节点可以去该存储位置拉取交易分组执行时生成的读集和写集。
通过本实现方式,第一节点可以选取(例如,随机选取)未执行的第一交易分组进行执行,并将执行时生成的读写集发送,以供其他节点验证和存储。由此,未执行的第一交易分组会越来越少,直至全部执行完。此外,一个第一交易分组可能会被多个节点执行,这样,即使区块链中的某个节点出现故障或者作恶,也不会导致整个区块链停止工作。
在一些可选的实现方式中,第一节点获取的多个交易是按顺序排列的。基于此,上述基于多个交易的读写集,对多个交易进行分组得到多个第一交易分组,可以具体如下实现:
1),对于排列靠前的预设比例的多个第一交易,根据多个第一交易的读写集,将多个第一交易进行分组,得到多个第一交易分组。
2),将剩余的交易划分为第二交易分组。
举例来说,可以将排列在前N%(例如,90%)的交易作为第一交易,根据多个第一交易的读写集,将多个第一交易进行分组,得到多个第一交易分组。其中,分组得到的多个第一交易分组之间没有读写冲突,多个第一交易分组之间可以并行执行。
之后,将剩余的交易,即排列在后(100-N)%,的交易划分到同一个分组,将该分组作为第二交易分组。第二交易分组与第一交易分组之间可能存在读写冲突,因此,第一交易分组与第二交易分组之间串行执行。具体的,多个第一交易分组全部执行完之后,再执行第二交易分组。可以理解,分组后,各个交易分组内的交易的先后顺序关系与分组前相同。举例来说,假设分组前交易TxA排在交易TxB之前,分组后,交易TxA和交易TxB分到了同一个交易分组中,在该交易分组中,交易TxA仍然排在交易TxB之前。通过本实现方式,可以将多个交易划分为第一交易分组和第二交易分组。
可选的,上述交易执行方法还可以包括以下内容:
a),响应于确定多个第一交易分组的状态全部为已执行,第一节点还可以进一步判断是否获取到其他节点通过可信执行环境执行第二交易分组所产生的读集和写集。
b),如果获取到其他节点通过可信执行环境执行第二交易分组所产生的读集和写集,则第一节点可以基于本地存储的世界状态对获取的第二交易分组的读集进行验证,在验证通过的情况下,将获取的第二交易分组的写集作为第二交易分组的执行结果,以用于更新本地存储的世界状态。由此,第一节点不需要再执行第二交易分组。
c),如果未获取到其他节点通过可信执行环境执行第二交易分组所产生的读集和写集,则第一节点可以在可信执行环境中执行第二交易分组中的交易。
d),第一节点可以将第二交易分组执行时生成的读集和写集进行发送。例如,以广播的方式发送给其他节点,或者,发送到一个预设的存储位置,以供其他节点获取。
回顾以上过程,在本说明书的实施例中,首先,基于多个交易的读写集,对多个交易进行分组得到多个第一交易分组,多个第一交易分组访问不相同的变量,因此,多个第一交易分组可以并行执行。基于此,第一节点可以获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集,并基于世界状态对目标读集进行验证,在验证通过的情况下,将目标写集作为目标第一交易分组的执行结果。由于目标写集是由第二节点的可信执行环境产生的,而可信执行环境可以保证其内部代码的安全性、认证性和完整性。所以,在输入确定的情况下,通过可信执行环境可以得到预期执行结果。因此,在目标读集验证通过的情况下,通过可信执行环境得到的目标写集可信。所以第一节点可以将目标写集作为目标第一交易分组的执行结果存储到本地,而本地不需要执行目标第一交易分组中的交易。由此,可以减少区块链系统中交易执行的冗余度,降低区块链系统中计算资源的浪费。且多个第一交易分组可以并行执行,提高了交易执行的效率。
根据另一方面的实施例,提供了一种区块链节点。图4示出了根据一个实施例的区块链节点的结构示意图。如图4所示,该区块链节点400包括:分组单元401,配置为基于多个交易的读写集,对上述多个交易进行分组得到多个第一交易分组,上述多个第一交易分组访问不相同的变量;获取单元402,配置为获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集;验证单元403,配置为基于世界状态对上述目标读集进行验证;结果确定单元404,配置为在验证通过的情况下,将上述目标写集作为目标第一交易分组的执行结果。
在本实施例的一些可选的实现方式中,具有执行结果的交易分组的状态为已执行,不具有执行结果的交易分组的状态为未执行,以及区块链节点400还包括:执行单元(图中未示出),配置为从状态为未执行的第一交易分组中选取一个第一交易分组作 为待执行第一交易分组,在可信执行环境中执行上述待执行第一交易分组中的交易;发送单元(图中未示出),配置为将上述待执行第一交易分组执行时生成的读集和写集进行发送。
在本实施例的一些可选的实现方式中,发送单元进一步配置为:将上述待执行第一交易分组执行时生成的读集和写集,发送给其他节点,或者发送到预设的存储位置。
在本实施例的一些可选的实现方式中,获取单元402进一步配置为:从上述第二节点或者预设的存储位置,获取上述第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集。
在本实施例的一些可选的实现方式中,区块链节点400还包括:信息获取单元(图中未示出),配置为获取上述目标第一交易分组所产生的上述目标读集的校验信息和上述目标写集的校验信息;校验单元(图中未示出),配置为根据校验信息校验上述目标读集和上述目标写集的完整性。
在本实施例的一些可选的实现方式中,上述多个交易按顺序排列,以及,分组单元401进一步配置为:对于排列靠前的预设比例的多个第一交易,根据上述多个第一交易的读写集,将上述多个第一交易进行分组,得到多个第一交易分组;将剩余的交易划分为第二交易分组。
在本实施例的一些可选的实现方式中,区块链节点400还包括:判断单元(图中未示出),配置为响应于确定上述多个第一交易分组的状态为已执行,判断是否获取到其他节点通过可信执行环境执行上述第二交易分组所产生的读集和写集;验证和确定单元(图中未示出),配置为如果获取到,基于世界状态对获取的上述第二交易分组的读集进行验证,在验证通过的情况下,将获取的上述第二交易分组的写集作为上述第二交易分组的执行结果;第二交易分组执行单元(图中未示出),配置为如果未获取到,在可信执行环境中执行上述第二交易分组中的交易;读写集发送单元(图中未示出),配置为将上述第二交易分组执行时生成的读集和写集进行发送。
根据另一方面的实施例,还提供一种计算机可读存储介质,其上存储有计算机程序,当上述计算机程序在计算机中执行时,令计算机执行图3所描述的方法。
根据再一方面的实施例,还提供一种计算设备,包括存储器和处理器,其特征在于,上述存储器中存储有可执行代码,上述处理器执行上述可执行代码时,实现图3所描述的方法。
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例 如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以 是硬件部件内的结构。
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为服务器系统。当然,本申请不排除随着未来计算机技术的发展,实现上述实施例功能的计算机例如可以为个人计算机、膝上型计算机、车载人机交互设备、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。
虽然本说明书一个或多个实施例提供了如实施例或流程图所述的方法操作步骤,但基于常规或者无创造性的手段可以包括更多或者更少的操作步骤。实施例中列举的步骤顺序仅仅为众多步骤执行顺序中的一种方式,不代表唯一的执行顺序。在实际中的装置或终端产品执行时,可以按照实施例或者附图所示的方法顺序执行或者并行执行(例如并行处理器或者多线程处理的环境,甚至为分布式数据处理环境)。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、产品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、产品或者设备所固有的要素。在没有更多限制的情况下,并不排除在包括所述要素的过程、方法、产品或者设备中还存在另外的相同或等同要素。例如若使用到第一,第二等词语用来表示名称,而并不表示任何特定的顺序。
为了描述的方便,描述以上装置时以功能分为各种模块分别描述。当然,在实施本说明书一个或多个时可以把各模块的功能在同一个或多个软件和/或硬件中实现,也可以将实现同一功能的模块由多个子模块或子单元的组合实现等。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
本发明是参照根据本发明实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据 处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储、石墨烯存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
本领域技术人员应明白,本说明书一个或多个实施例可提供为方法、系统或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本说明书的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。
以上所述仅为本说明书一个或多个实施例的实施例而已,并不用于限制本本说明书一个或多个实施例。对于本领域技术人员来说,本说明书一个或多个实施例可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在权利要求范围之内。

Claims (10)

  1. 一种交易执行方法,应用于区块链的第一节点,所述方法包括:
    基于多个交易的读写集,对所述多个交易进行分组得到多个第一交易分组,所述多个第一交易分组访问不相同的变量;
    获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集;
    基于世界状态对所述目标读集进行验证;
    在验证通过的情况下,将所述目标写集作为目标第一交易分组的执行结果。
  2. 根据权利要求1所述的方法,其中,具有执行结果的交易分组的状态为已执行,不具有执行结果的交易分组的状态为未执行,以及所述方法还包括:
    从状态为未执行的第一交易分组中选取一个第一交易分组作为待执行第一交易分组,在可信执行环境中执行所述待执行第一交易分组中的交易;
    将所述待执行第一交易分组执行时生成的读集和写集进行发送。
  3. 根据权利要求2所述的方法,其中,所述将所述待执行第一交易分组执行时生成的读集和写集进行发送,包括:
    将所述待执行第一交易分组执行时生成的读集和写集,发送给其他节点,或者发送到预设的存储位置。
  4. 根据权利要求1所述的方法,其中,所述获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集,包括:
    从所述第二节点或者预设的存储位置,获取所述第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集。
  5. 根据权利要求1所述的方法,其中,所述方法还包括:
    获取所述目标第一交易分组所产生的所述目标读集的校验信息和所述目标写集的校验信息;
    根据校验信息校验所述目标读集和所述目标写集的完整性。
  6. 根据权利要求1所述的方法,其中,所述多个交易按顺序排列,以及,所述基于多个交易的读写集,对所述多个交易进行分组得到多个第一交易分组,包括:
    对于排列靠前的预设比例的多个第一交易,根据所述多个第一交易的读写集,将所述多个第一交易进行分组,得到多个第一交易分组;
    将剩余的交易划分为第二交易分组。
  7. 根据权利要求6所述的方法,其中,所述方法还包括:
    响应于确定所述多个第一交易分组的状态为已执行,判断是否获取到其他节点通过可信执行环境执行所述第二交易分组所产生的读集和写集;
    如果获取到,基于世界状态对获取的所述第二交易分组的读集进行验证,在验证通过的情况下,将获取的所述第二交易分组的写集作为所述第二交易分组的执行结果;
    如果未获取到,在可信执行环境中执行所述第二交易分组中的交易;
    将所述第二交易分组执行时生成的读集和写集进行发送。
  8. 一种区块链节点,包括:
    分组单元,配置为基于多个交易的读写集,对所述多个交易进行分组得到多个第一交易分组,所述多个第一交易分组访问不相同的变量;
    获取单元,配置为获取第二节点通过可信执行环境执行目标第一交易分组所产生的目标读集和目标写集;
    验证单元,配置为基于世界状态对所述目标读集进行验证;
    结果确定单元,配置为在验证通过的情况下,将所述目标写集作为目标第一交易分组的执行结果。
  9. 一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行权利要求1-7中任一项所述的方法。
  10. 一种区块链节点,包括存储器和处理器,其特征在于,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现权利要求1-7中任一项所述的方法。
PCT/CN2022/135423 2022-10-31 2022-11-30 交易执行方法和区块链节点 WO2024092932A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211346010.1 2022-10-31
CN202211346010.1A CN115714652A (zh) 2022-10-31 2022-10-31 交易执行方法和区块链节点

Publications (1)

Publication Number Publication Date
WO2024092932A1 true WO2024092932A1 (zh) 2024-05-10

Family

ID=85231791

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135423 WO2024092932A1 (zh) 2022-10-31 2022-11-30 交易执行方法和区块链节点

Country Status (2)

Country Link
CN (1) CN115714652A (zh)
WO (1) WO2024092932A1 (zh)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180158034A1 (en) * 2016-12-07 2018-06-07 International Business Machines Corporation Dynamic reordering of blockchain transactions to optimize performance and scalability
CN112887437A (zh) * 2021-04-28 2021-06-01 支付宝(杭州)信息技术有限公司 区块链交易处理方法、区块链节点和区块链
CN115098594A (zh) * 2022-06-29 2022-09-23 蚂蚁区块链科技(上海)有限公司 在区块链系统中执行交易的方法、区块链系统和节点

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180158034A1 (en) * 2016-12-07 2018-06-07 International Business Machines Corporation Dynamic reordering of blockchain transactions to optimize performance and scalability
CN112887437A (zh) * 2021-04-28 2021-06-01 支付宝(杭州)信息技术有限公司 区块链交易处理方法、区块链节点和区块链
CN115098594A (zh) * 2022-06-29 2022-09-23 蚂蚁区块链科技(上海)有限公司 在区块链系统中执行交易的方法、区块链系统和节点

Also Published As

Publication number Publication date
CN115714652A (zh) 2023-02-24

Similar Documents

Publication Publication Date Title
EP3591510B1 (en) Method and device for writing service data in block chain system
CN110032883B (zh) 区块链中实现隐私保护的方法、系统和节点
CN109886682B (zh) 区块链中实现合约调用的方法及节点、存储介质
CN110033267B (zh) 区块链中实现隐私保护的方法、节点、系统和存储介质
TWI737107B (zh) 資料處理方法、裝置、區塊鏈客戶端和區塊鏈節點
EP3531668A1 (en) Method and device for processing service request
CN110008735B (zh) 区块链中实现合约调用的方法及节点、存储介质
CN110060054B (zh) 区块链中实现隐私保护的方法、节点、系统和存储介质
CN110689349B (zh) 一种区块链中的交易哈希值存储和搜索方法及装置
CN110245942B (zh) 结合用户类型和判断条件的收据存储方法和节点
CN110020856B (zh) 区块链中实现混合交易的方法、节点和存储介质
US11201870B2 (en) Using commit tokens to coordinate permissions submissions to address transaction conflict in blockchain systems
CN113438219B (zh) 一种基于区块链一体机的重放交易识别方法及装置
CN111612462B (zh) 区块链中实现隐私保护的方法、节点和存储介质
CN113079200A (zh) 一种数据处理的方法、装置及系统
US11563805B2 (en) Method, apparatus, client terminal, and server for data processing
CN110245943B (zh) 基于判断条件的收据存储方法和节点
TW202008763A (zh) 資料處理方法和裝置、用戶端
WO2023109520A1 (zh) 基于区块链的随机数生成方法及装置
CN111639362B (zh) 区块链中实现隐私保护的方法、节点和存储介质
WO2023160083A1 (zh) 执行交易的方法、区块链、主节点和从节点
WO2023160085A1 (zh) 执行交易的方法、区块链、主节点和从节点
WO2023231335A1 (zh) 在区块链中执行交易的方法及区块链的主节点
WO2024001032A1 (zh) 在区块链系统中执行交易的方法、区块链系统和节点
WO2024066005A1 (zh) 重放区块链交易的方法及装置