WO2023231339A1 - Transaction execution method and node in blockchain system, and blockchain system - Google Patents

Transaction execution method and node in blockchain system, and blockchain system Download PDF

Info

Publication number
WO2023231339A1
WO2023231339A1 PCT/CN2022/135280 CN2022135280W WO2023231339A1 WO 2023231339 A1 WO2023231339 A1 WO 2023231339A1 CN 2022135280 W CN2022135280 W CN 2022135280W WO 2023231339 A1 WO2023231339 A1 WO 2023231339A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
node
execution
resource consumption
consumption information
Prior art date
Application number
PCT/CN2022/135280
Other languages
French (fr)
Chinese (zh)
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 WO2023231339A1 publication Critical patent/WO2023231339A1/en

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]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • G06F21/53Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by executing in a restricted environment, e.g. sandbox or secure virtual machine
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/554Detecting local intrusion or implementing counter-measures involving event detection and direct action
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/08Payment architectures
    • G06Q20/10Payment architectures specially adapted for electronic funds transfer [EFT] systems; specially adapted for home banking systems
    • G06Q20/102Bill distribution or payments
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/22Payment schemes or models
    • G06Q20/223Payment schemes or models based on the use of peer-to-peer networks
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3825Use of electronic signatures
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification

Definitions

  • the embodiments of this specification belong to the field of blockchain technology, and particularly relate to a transaction execution method, node and blockchain system in a blockchain system.
  • Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • data blocks are combined into a chained data structure in a chronological manner and are cryptographically guaranteed to be an untamperable and unforgeable distributed ledger. Due to the characteristics of blockchain, such as decentralization, non-tamperable information, and autonomy, blockchain has also received more and more attention and applications.
  • the purpose of the present invention is to provide a transaction execution method, node and blockchain system in a blockchain system.
  • a transaction execution method in a blockchain system includes a first node and a second node, and the method is executed by the first node.
  • the method includes: pre-executing the first transaction in a trusted execution environment (TEE), obtaining resource consumption information and a pre-execution read-write set generated based on the resource consumption information; Consumption information generates trusted data; sends the trusted data and the pre-execution read and write set to the second node.
  • TEE trusted execution environment
  • a transaction execution method in a blockchain system includes a first node and a second node, and the method is executed by the first node.
  • the method includes: receiving trusted data and a pre-execution read-write set of the first transaction from the first node, the trusted data being generated by the first node based on the resource consumption information of the first transaction in its TEE, so The resource consumption information and the pre-execution read and write are obtained by pre-executing the first transaction in its TEE by the first node; executing the first transaction based on the resource consumption information, obtaining the The execution read-write set of the first transaction; determine whether the first node does evil in the process of pre-executing the first transaction based on the execution read-write set and the pre-execution read-write set, and if not, the execution The execution write set of the read and write set serves as the status data of the first transaction.
  • a first node in a blockchain system is provided, and the blockchain system further includes a second node.
  • the first node includes: a pre-execution process, deployed in the TEE of the first node, configured to pre-execute the first transaction, obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information; and Configured to generate trusted data based on the resource consumption information in the TEE; a network process configured to send the trusted data and the pre-execution read-write set to the second node.
  • a second node in a blockchain system is provided, and the blockchain system further includes a first node.
  • the second node includes: a network process configured to receive trusted data from the first node and a pre-execution read-write set of the first transaction, the trusted data being generated by the first node in its TEE based on the first transaction.
  • the resource consumption information of a transaction is generated, and the resource consumption information and the pre-execution read and write are obtained by the first node pre-executing the first transaction in its TEE; the calculation process is configured to be based on the Execute the first transaction using the resource consumption information to obtain the execution read-write set of the first transaction; and be configured to determine the pre-execution read-write set of the first node based on the execution read-write set and the pre-execution read-write set. Whether evil is committed during the execution of the first transaction, if not, use the execution write set of the execution read and write set as the status data of the first transaction.
  • the fifth aspect provides a blockchain system including a first node and a second node.
  • the first node is used to pre-execute the first transaction in the trusted execution environment TEE, obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information; in the TEE based on the resource Consumption information generates trusted data; sends the trusted data and the pre-execution read and write set to the second node; the second node is used to execute the first transaction based on the resource consumption information, and obtain The execution read-write set of the first transaction; determine whether the first node does evil during the process of pre-executing the first transaction according to the execution read-write set and the pre-execution read-write set. If not, all The execution write set of the execution read and write set is used as the status data of the first transaction.
  • the second node does not need to calculate the resource consumption information of the transaction again, but uses the resource consumption information of the transaction from the first node to execute the transaction, that is, using the resource consumption information of the transaction from the first node.
  • the resource consumption information of the transaction generates the execution write set of the transaction.
  • the execution write set of the transaction can be used as the status data of the transaction. and complete the execution of the transaction. In this way, the second node can complete the execution of the transaction more quickly because it does not need to calculate the resource consumption information of the transaction again.
  • Figure 1 is a schematic diagram of a blockchain system provided as an example in the embodiment of this specification.
  • Figure 2 is a schematic structural diagram of blockchain data storage provided as an example in the embodiment of this specification.
  • Figure 3 is a schematic structural diagram of any two nodes in the blockchain system provided as an example in the embodiment of this specification;
  • Figure 4 is a flow chart of a transaction execution method provided in the embodiment of this specification.
  • Figure 5 is one of the structural schematic diagrams of a blockchain node provided in the embodiment of this specification.
  • Figure 6 is the second structural schematic diagram of a blockchain node provided in the embodiment of this specification.
  • FIG. 1 is a schematic diagram of an exemplary blockchain system provided in the embodiment of this specification.
  • the blockchain system is a distributed network established through multiple nodes (Node), which includes communication between any two nodes at the application layer through a peer-to-peer (P2P) network. Connection, for example, any two nodes among the nodes n1 to n5 contained therein can realize communication connection at the application layer through the P2P network.
  • the blockchain system uses a decentralized (or multi-centered) distributed ledger constructed by a chain block structure, which is stored on each node (or most nodes, such as consensus) in the distributed blockchain network.
  • each node of the blockchain system runs a blockchain program.
  • the consensus mechanism is used to ensure that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have the same If the execution results of the transaction are consistent, the transaction is packaged into blocks and the world state is updated based on the execution results of the same transaction.
  • the current mainstream consensus mechanisms include but are not limited to: Proof of Work (POW), Proof of Stake (POS), Practical Byzantine Fault Tolerance (PBFT) algorithm, Honey Badger Byzantine Fault Tolerance ( HoneyBadgerBFT) algorithm and so on.
  • POW Proof of Work
  • POS Proof of Stake
  • PBFT Practical Byzantine Fault Tolerance
  • HoneyBadgerBFT Honey Badger Byzantine Fault Tolerance
  • Accounts in the blockchain system are usually divided into two types: user account/externally owned account (Externally owned account) and contract account (contract account); the contract account is used to store smart contract code and the values of related states in the smart contract code. , which can usually only be activated by calling an external account.
  • the design of external accounts and contract accounts is actually the mapping of account addresses to account status.
  • the status of an account can usually include, but is not limited to, nonce, balance, storage_Root, codeHash and other fields. Nonce and balance exist in both external accounts and contract accounts, while the codeHash and storage_Root attributes are usually only valid on contract accounts. Among the aforementioned fields, nonce represents the counter.
  • For external accounts it represents the number of transactions sent from the account address; for contract accounts, it represents the number of contracts created by the account.
  • Balance represents the number of digital resources owned by the corresponding external account.
  • storage_Root represents the hash of the root node of an MPT (Merkle Patricia Tree) tree. The MPT is used to organize the storage of state variables of contract accounts.
  • codeHash represents the hash value of the smart contract code.
  • contract accounts it is the hashed and stored code of the smart contract.
  • For external accounts it does not include smart contracts, so it can be an empty string/all 0 characters. string.
  • MPT is a tree structure that combines Merkle Tree (Merkle Tree) and Patricia Tree (Compressed Prefix Tree, a more space-saving Trie tree, dictionary tree).
  • Merkle Tree the Merkle tree algorithm calculates a Hash value for each transaction, and then connects the two to calculate the Hash again, all the way to the top-level Merkle root.
  • Ethereum uses an improved MPT tree, such as a 16-fork tree structure, which is often referred to as an MPT tree.
  • the data structure of the Ethereum MPT tree includes a state trie.
  • the state tree contains the key and value pair corresponding to the storage content of each account in Ethereum.
  • the "key" in the state tree can be a 160bits identifier (the address of an Ethereum account).
  • This account address is distributed in the storage starting from the root node of the state tree to the leaf nodes.
  • the "values" in the state tree are generated by encoding the Ethereum account information (using the Recursive-Length Prefix encoding (RLP) method).
  • RLP Recursive-Length Prefix encoding
  • the values include nonce and balance; for contract accounts, the values include nonce, balance, codehash, storage_Root, etc.
  • Contract accounts are used to store status related to smart contracts. After the smart contract is deployed in the blockchain system, a corresponding contract account will be generated. This contract account generally has some states, which are defined by the state variables in the smart contract and generate new values when the smart contract is created and executed.
  • the smart contract usually refers to a contract defined in digital form in a blockchain environment that can automatically execute terms. Once an event triggers a clause in the contract (execution conditions are met), the code can be executed automatically.
  • the relevant status of the contract is stored in the storage trie, and the hash value of the root node of the storage tree is stored in the above-mentioned storage_Root, thereby locking all the status of the contract to the contract account through hash.
  • the storage tree is also an MPT tree structure, which stores the key-value mapping from state addresses to state values.
  • the address of a state is stored from the root node of the storage tree to the leaf nodes, and the value of a state is stored in a leaf node.
  • the block header of a single block can include several fields, such as the previous block hash previous_Hash (PrevHash in the figure, or called the parent hash), the random number Nonce (in some blockchain systems This Nonce is not a random number, or the Nonce in the block header is not enabled in some blockchain systems), timestamp Timestamp, block number BlockNum, state root hash State_Root, transaction root hash Transaction_Root, receipt root hash Receipt_Root, etc. .
  • the PrevHash in the block header of the next block (such as block N+1) points to the previous block (such as block N), which is the hash value of the previous block.
  • state_root is the hash value of the root of the MPT tree composed of the status of all accounts in the current block, that is, the point pointing to state_root is a state tree in the form of MPT.
  • the root node of this MPT tree can be an extension node (Extension Node) or a branch node (Branch Node).
  • Extension Node Extension Node
  • Branch Node branch node
  • What is stored in state_root is generally the hash value of this root node.
  • a part of the value of each node from the root node of this MPT to the leaf node can be concatenated in order to form an account address and serve as a key.
  • the account information stored in the leaf node is the value corresponding to the account address, thus forming a key-value Key-value pairs.
  • the key can be sha3 (Address), which is the hash value of the account address (the hash algorithm uses the sha3 algorithm, for example), and its stored value value can be rlp (Account), which is the rlp encoding of the account information.
  • the account information can be a four-tuple consisting of [nonce, balance, storage_root, codeHash]. As mentioned before, for external accounts, there are generally only two items, nonce and balance, and the storage_root and codeHash fields store empty strings/all 0 strings by default. For contract accounts, contract accounts can include nonce, balance, storage_root, codeHash, etc.
  • Leaf Node From the extension node/branch node of the root node to the leaf node of each account, there may be several branch nodes and extension nodes in the middle.
  • this storage_Root points to another tree in the form of MPT, which stores the data of state variables involved in contract execution.
  • the tree in MPT form pointed to by this storage_Root is a storage tree, that is, the hash value of the root node of the storage tree.
  • this storage tree also stores key-value pairs.
  • a part of the data stored on the path from the root node to the leaf node is connected to form the key, and the value is stored in the leaf node.
  • this storage tree can also be a tree in the form of MPT, which can generally be a 16-fork tree, that is, for a branch node, it can have up to 16 child nodes, which may include extension nodes and/or leaf nodes.
  • For an extension node it generally can have one child node, which can be a branch node.
  • This storage tree can be up to 64 levels deep.
  • the status data generated after nodes in the blockchain system complete the execution of multiple transactions belonging to a certain block may include Contract status data related to the storage trie and world state data related to the state trie. Therefore, when a node submits state data, it usually needs to submit the contract state data first to obtain the storage_root of the contract account, then update the storage_root of the relevant contract account in the state trie, and submit the obtained world state data to obtain the state_root of the state tree.
  • Figure 3 is a schematic structural diagram of any two nodes (for example, node n1 as the master node/second node and node n2 as the slave node/first node) in the blockchain system provided as an example in the embodiment of this specification. Both node n1 and node n2 can run multiple processes to provide multiple services. For example, as shown in Figure 3, node n1 and node n2 can each run access processes for providing access services and caching services.
  • the process refers to a running activity of a program with certain independent functions in the application on a data collection. That is, a process is a process in the computer that is carried out by the CPU sequentially executing instructions in the application program, and each process is created when it is created. Allocate its own memory address space.
  • the multiple processes in node n1 may be multiple processes in multiple computing devices or virtual computing nodes, and the multiple processes in node n2 may be multiple processes in multiple computing devices or virtual computing nodes.
  • the solutions provided by the embodiments of this specification are not limited to the master-slave architecture blockchain system.
  • the access process can be used to receive transactions from the user device, and then the access process calls the cache process to add the received transactions to the pending transaction queue for caching.
  • the pre-execution process of node n2 can call the cache process to read its cached transactions in order from the pending transaction queue and verify the transaction, such as verifying the signature of the user device on the transaction and sending the verified transaction Returned to the cache process.
  • node n2 can broadcast the verified transactions stored in its cache process to the network processes of other nodes through its network process; furthermore, the transactions from node n2 received by node n1 through its network process can be added to the waiting list by its cache process cache. in the transaction queue for processing. Therefore, the pending transaction queue cached by the cache process of node n1 through its memory includes not only transactions received through its access process, but also transactions received from other nodes through its network process.
  • the pre-execution process of node n1 can also call the cache process to sequentially read its cached transactions from the pending transaction queue, and at least verify transactions from user devices connected to node n1.
  • the pre-execution process of node n2 can also pre-execute the transactions it receives in sequence from the cache process to obtain the pre-execution information of the transaction.
  • the pre-execution information includes, for example, the pre-execution read set, the pre-execution write set and the execution of the transaction.
  • the amount of digital resources/computing resources that need to be consumed i.e. resource consumption information).
  • the pre-execution process of node n1 can also return the pre-execution information of this batch of transactions to the cache process after each completion of the pre-execution of a batch of transactions, so that it can be cached in the transaction queue to be agreed upon. It should be noted that part of the status data can also be cached in the memory of the cache process of node n1; for any transaction pre-executed by the pre-execution process of node n1, during the process of pre-execution of any transaction , the pre-execution process can first call the cache process to query whether its cached status data includes the status value of any variable to be read. If so, obtain the status value of the arbitrary variable returned by the cache process.
  • the pre-execution process can Call the stored procedure to query the state value of this arbitrary variable from the state data submitted to the state database.
  • its cache process can also update the cache based on the pre-execution read and write set it receives. Process cached state data.
  • the pre-execution process can sequentially read transactions from the pending transaction queue cached by the cache process and pre-execute them, the cache process can also pre-execute them based on its cached pending transactions.
  • the queue caches in its memory the pre-execution order of multiple transactions pre-executed by the pre-execution process.
  • the pre-execution read set contains several unique keys (keys), and also includes the key values (values) corresponding to each of the aforementioned keys read from the submitted world state.
  • the pre-execution write set also contains a number of unique keys (keys), as well as the key values (values) corresponding to each of the aforementioned keys that are expected to be submitted; in addition, if a transaction deletes a certain key in the world state, the pre-execution write set will Executing the write set will also record the corresponding mark for the deleted key.
  • the pre-executed transaction is a contract call transaction used to call a smart contract
  • its pre-execution read and write set may not only contain state parameters related to external accounts, but may also involve contracts related to the smart contract. Several contract parameters related to the status.
  • node n1 sequentially pre-executes transactions Tx1 ⁇ transaction Tx5.
  • transactions Tx1 and transaction Tx2 are contract call transactions for calling smart contract C1 initiated by external account A1 and external account A2 respectively.
  • smart contract C1 corresponds to contract account B1;
  • transaction Tx3 is a transfer transaction initiated by external account A1 and directed to external account A3
  • transaction Tx4 is a transfer transaction initiated by external account A4 and directed to external account A5
  • transaction Tx5 is an external account A transfer transaction initiated by A6 to external account A7.
  • Node n1 pre-executes transactions Tx1 to Tx5 through its pre-execution process, and may obtain the respective pre-execution information of transactions Tx1 to Tx5 as shown in Table 1 below.
  • k1 represents the key of the balance of the external account A1
  • k2 represents the key of a certain state parameter under the contract account B1
  • k3 represents the key of the balance of the external account A2
  • k4 represents the contract.
  • the key of a certain state parameter under account B1, k5 ⁇ k9 in turn represent the keys of the balance under external account A3 ⁇ external account A7.
  • v11, v12, v13 and v21 ⁇ v92 respectively represent the values of their corresponding keys. It should be noted that since transaction Tx3 is executed after transaction Tx1, the value of k1 in the pre-execution read set of transaction Tx3 is the value of k1 in the pre-execution write set of transaction Tx1.
  • the consensus process of node n1 can call its cache process to sequentially read multiple transactions and their related data from the transaction queue to be agreed upon to generate a consensus proposal, where the consensus proposal can include, for example, the corresponding predetermined data of the multiple transactions.
  • Execution information, the consensus order of the multiple transactions (the consensus order of the multiple transactions is the same as the pre-execution order of the multiple transactions), and the multiple transactions or the respective instruction information of the multiple transactions (for example, the multiple transactions their respective summary values).
  • the conditions for the consensus process of node n1 to call its cache process may include but are not limited to calling the cache process according to a fixed time step, calling the cache process when the amount of transaction data cached by the cache process reaches a predetermined size, or The cache process is called when a predetermined number of pre-executed transactions cached by the cache process reaches a predetermined number, and so on.
  • the consensus process of node n1 can also send consensus proposals to the respective network processes of other nodes (such as node n2) participating in consensus on the consensus proposal through its network process, so as to communicate with the respective consensus processes of other nodes through its consensus process.
  • the consensus proposals it generates are subject to consensus.
  • node n1 can also calculate the grouping information corresponding to the multiple transactions based on the pre-execution information of each of the multiple transactions indicated by the consensus proposal, and carry the grouping information in the consensus proposal in order to participate in the consensus proposal.
  • Other nodes that propose consensus can group the aforementioned multiple transactions based on this grouping information.
  • the control process submits part or all of the pre-execution information of each of the aforementioned multiple transactions to the storage service as the state data of the corresponding block, and then obtains the state root used to generate the corresponding block and generates a state root containing the state root and the aforementioned multiple Transaction block.
  • node n2 may, during the process of consensus on the consensus proposal generated by node n1, or after reaching consensus on the consensus proposal generated by node n1, read the aforementioned plurality of consensus proposals from the consensus proposal through its consensus process and/or control process. Pre-execution information of each transaction, and then group the multiple transactions based on the pre-execution information of each transaction to obtain M transaction groups (M is greater than 1); or read the grouping of the aforementioned multiple transactions from the consensus proposal information and group the aforementioned multiple transactions based on the grouping information to obtain M transaction groups.
  • the consensus process of node n2 can calculate the grouping information based on the pre-execution information of each of the aforementioned multiple transactions, and send the grouping information, the aforementioned multiple transactions and their respective corresponding pre-execution read and write sets to the node n2. control process; then the control process of node n2 divides the aforementioned multiple transactions into M transaction groups based on the grouping information, and the control process of node n2 performs task scheduling on the N computing processes in node n2.
  • any two transactions in any two transaction groups do not conflict with each other. Any two transactions do not conflict with each other. Specifically, any two transactions do not have one of the following situations: the pre-execution read set of one transaction and the pre-execution write set of another transaction include the same key, the pre-execution write set of one transaction and Another transaction's pre-execution write set includes the same key. For any two transactions that conflict, they need to be divided into the same transaction group. In other words, if the pre-execution write sets of any two transactions contain the same key, it is considered that any two transactions Conflict transactions access the same parameters and conflict exists.
  • any two transactions need to be divided into the same transaction group; if the pre-execution read set of one of the two transactions is included in the pre-execution write set of the other transaction,
  • the same key means that any two transactions are considered to have accessed the same parameters and there is a conflict.
  • the any two transactions need to be divided into the same transaction group.
  • the aforementioned multiple transactions can be divided into M transaction groups. Usually, the grouping information can be determined according to the location of any two different transactions.
  • the aforementioned multiple transactions are grouped by the requirement that any two transactions in the group do not access the same parameters (that is, do not contain the same key).
  • the grouping situation may include, for example: transaction Tx1 and transaction Tx3 are divided into transaction group 1, transaction Tx2 is divided into transaction group 2, and transaction Tx4 and transaction Tx5 are divided respectively. Go to transaction group 3 and transaction group 4.
  • node n2 can be grouped into M transactions and execute multiple transactions in the M transaction groups in parallel through the N computing processes it runs.
  • the execution of the transaction requires consuming the computing resources of the node.
  • the node may need to execute a large number of instructions during the execution of the transaction. Therefore, it is usually necessary to execute the transaction based on the transaction.
  • the consumption instructions or the data volume of the transaction are used to count the resource consumption information of the transaction, and then the execution of the transaction is completed based on the resource consumption information. For example, the balance field of the external account that initiated the transaction is modified to modify the digital resources held by it. quantity. Calculating the resource consumption information of the transaction during the execution of the transaction will undoubtedly increase the execution time of the transaction, causing the calculation process to be unable to quickly complete the execution of the transaction.
  • FIG 4 is a flow chart of a transaction execution method in a blockchain system provided in the embodiment of this specification.
  • This method specifically involves any first node (such as node n1 as the master node) and second node (such as the node n2 as the slave node) in the blockchain system.
  • the first node and the second node can each be implemented as any A device, platform, device or cluster of devices with computing/processing capabilities.
  • the transaction execution process in the blockchain system will be described in detail, mainly taking node n1 and node n2 to cooperate to complete the execution of the transaction as an example.
  • the method may include but is not limited to the following steps 41 to 49.
  • Step 41 Node n1 pre-executes the first transaction in its TEE, and obtains resource consumption information and a pre-execution read-write set generated based on the resource consumption information.
  • the aforementioned first transaction is, for example, any transaction received by node n1 through its access process or network process.
  • the resource consumption information of the first transaction is calculated based on the data volume of the first transaction during the process of node n1 pre-executing the first transaction, or based on the first transaction during the process of node n1 pre-executing the first transaction. Calculated from the instructions consumed.
  • the pre-execution process of node n1 can run in its TEE, and other processes such as its access process and network process can run outside its TEE.
  • the pre-execution process running in the TEE can call the cache process outside the TEE to read its cached transactions in order from the pending transaction queue, and pre-execute the read transactions to obtain the required consumption of the transaction.
  • the number of digital resources that is, resource consumption information
  • the pre-execution write set of the pre-execution read-write set can usually include the status value of a certain status parameter calculated based on the resource consumption.
  • the status parameter is, for example, the balance of the external account that initiated the transaction.
  • a contract call transaction initiated by an external account to call a smart contract such as the aforementioned transaction Tx1 initiated by an external account A1 to call a smart contract C
  • its pre-execution read set includes the balace of the external account A1
  • the status value v11 also includes the status value v21 of a certain contract parameter in smart contract C1.
  • the virtual machine will also calculate the number of digital resources that it needs to consume for each instruction consumed by executing the aforementioned smart contract C1, and then after completing the execution of smart contract C1, it will obtain the The amount of digital resources consumed is the resource consumption information gas1 of transaction Tx1.
  • the pre-execution process located in the TTE can also calculate the status value v12 of k1 expected to be written in the pre-execution write set based on gas1 and the status value v11 of k1 in the pre-execution read set, that is, calculate the balance status of external account A1 Value v12.
  • the resource consumption information gas2 of transaction Tx3 can be calculated based on the data volume of transaction Tx3. Furthermore, the pre-execution process located in the TEE can calculate the status value v13 of the balance of the external account A1 based on the number of digital resources actually transferred by gas2 and Tx3.
  • Step 43 Node n1 generates trusted data based on resource consumption information in its TEE.
  • the trusted data is the ciphertext obtained by encrypting the resource consumption information, or the trusted data includes the resource consumption information and the signature of the resource consumption information.
  • the pre-execution process located in the TEE After the pre-execution process located in the TEE completes the pre-execution of the first transaction and generates the trusted data of the first transaction, it can also return the first transaction, the pre-execution read-write set of the first transaction and the trusted data to Cache process to cache into the transaction queue waiting for consensus.
  • the pre-execution process located in the TEE can sequentially read transactions from the pending transaction queue cached by the cache process and pre-execute them. Therefore, as mentioned above, the cache process can also perform pre-execution based on its cached pending transaction queue.
  • the transaction queue corresponds to the cache of the pre-execution sequence of multiple transactions pre-executed by the pre-execution process located in the TEE.
  • Step 45 Node n1 sends trusted data and pre-execution read and write sets to node n2.
  • Node n1 may send the trusted data of the first transaction and the pre-execution read-write set to node n2 during its consensus with node n2 on the consensus proposal generated by node n1 and sent to node n2.
  • the consensus process of node n1 can generate a consensus proposal for multiple transactions cached in the transaction queue to be agreed upon.
  • the consensus proposal can include the credible data of each of the multiple transactions and the pre-execution reads of each of the multiple transactions.
  • the consensus proposal may also include the multiple transactions or the respective indication information of the multiple transactions (such as the respective hash values of the multiple transactions).
  • the first transaction can be any one of the multiple transactions included or indicated in the consensus proposal. Therefore, node n2 can obtain the corresponding value of the first transaction from the consensus proposal from node n1. Trusted data and its pre-execution read and write sets.
  • node n2 can decrypt the trusted data to obtain the resource consumption information of the first transaction, and then perform subsequent step 47 based on the resource consumption information.
  • the trusted data includes resource consumption information and the signature of node n1 on the resource consumption information in its TEE
  • node n2 can also verify the signature in the trusted data, and only continue to perform subsequent steps 47 when the signature passes the verification.
  • node n2 can also have a TEE.
  • node n2 can process trusted data in its TEE, such as decrypting trusted data in the TEE or decrypting the trusted data in the TEE. Signature is verified.
  • Step 47 Node n2 executes the first transaction based on the resource consumption information and obtains the execution read-write set.
  • node n2 can, for example, through its control process, divide the multiple transactions into M transactions based on their respective pre-execution read and write sets. Grouping, where the value of M is not less than the number N of computing processes running on node n2, and the pre-execution read and write sets of some of the multiple transactions may also involve several contract parameters related to one or more smart contracts. .
  • node n2 can determine the computing processes corresponding to each of the M transaction groups, and then, for example, distribute the M transaction groups to the N computing processes it runs through its control process; for any of the M transaction groups Two transaction groups, if any two transactions in any two groups involve the same smart contract, for example, any two transaction requests in any two transaction groups call the same smart contract, then any two transaction groups need The controlled process is sent to the same computing process, so that the N computing processes of node n2 can submit in parallel the status data they each obtained after completing the execution of the transactions in each transaction group they received, thereby accelerating the processing of the multiple transactions.
  • Block generation For example, please continue to refer to the grouping of transactions Tx1 ⁇ transaction Tx5 in the previous example.
  • the control process of node n2 can, for example, send two transaction packets such as transaction group 1 and transaction group 2 to the calculation process 1 of node n2, send transaction group 3 to calculation process 2, and send transaction group 4 to calculation process 3.
  • the calculation process 1 to the calculation process 3 are caused to execute the transactions in the transaction groups they respectively received in parallel, and to submit in parallel the status data obtained by each of them after completing the execution of the transactions in each transaction group they received.
  • the computing process can serially execute the transactions in each transaction group it receives.
  • the computing process 1 can sequentially execute the transactions Tx1, transaction Tx2, and transaction Tx3 in the transaction group 1 and transaction group 2 it receives through a single worker thread.
  • the computing process can concurrently execute the transactions in each transaction group it receives through multiple threads in order to complete the execution of the transactions in each transaction group it receives more quickly; for example, computing process 1 can concurrently run worker thread 1 and work Thread 2 sequentially executes the transaction Tx1 and transaction Tx2 in the transaction group 1 it receives through the working thread 1, and executes the transaction Tx3 in the transaction group 2 it receives through the working thread 2.
  • the computing process can collect the status data obtained by executing the transactions in each transaction group it receives through the same storage object; for example, the computing process 1 can collect the transaction Tx1 it executes through the same storage object.
  • any computing process of node n2 does not need to calculate the resource consumption information of the transaction again, but can directly use the transaction from node n1
  • the resource consumption information of the transaction is used to execute the transaction, and the execution read-write set of the transaction is obtained. More specifically, the resource consumption information of the transaction from node n1 is used to generate the execution write set of the transaction during the execution of the transaction.
  • the computing process 1 of node n2 only needs to read k2 during the process of executing the smart contract C1 requested by the transaction Tx1 through its virtual machine.
  • the state value v21 of k2 corresponds to the state value v22 of k2.
  • Resource consumption information gas1 of Tx1 can directly use the resource consumption information gas1 from node n1, and calculate the status value v12 of k1 expected to be written in the execution write set of transaction Tx1 with the status value v11 of k1 read, that is Calculate the status value v12 of the balance of the external account A1, and then generate an execution write set containing the key-value pair k1-v12 and the key-value pair k2-v22.
  • the key-value pair k2-v22 in the write set may be used as computing process 1 to execute transaction Tx1 to obtain the contract status data of smart contract C1/contract account B1, while the key-value pair k1-v12 may be used as computing process 1 to execute transaction Tx1 to obtain the contract status data of smart contract C1/contract account B1. Obtained world state data. It should be noted that the status data of transaction Tx1 may be used by other transactions executed later in the calculation process 1. For example, the status value of k1 read by transaction Tx3 executed later should be v12 instead of v11.
  • the virtual machine used to execute the smart contract in the computing process can have the function of choosing whether to turn on computing resource consumption information according to the user's needs. If you choose to turn on this function, the During the specific execution of a transaction, the virtual machine can calculate the resource consumption information of the transaction based on the instructions consumed for executing the transaction. Since node n2 obtains the resource consumption information of the first transaction based on the trusted data from node n1, the computing process used to execute the first transaction can choose to turn off this function to complete the execution of the first transaction more quickly.
  • calculation process 1 of node n2 does not need to calculate the transaction based on the data volume of transaction Tx3 Resource consumption information gas2 of Tx3; calculation process 1 can calculate the balance of external account A1 based on the read status value v12 of k1, the resource consumption information gas2 of transaction Tx3 from node n1 and the number of digital resources actually transferred by Tx3 Status value v13, for example, after reading the status value v12 of the balance field of external account A1, subtract gas2 and the number of digital resources actually transferred by external account A1 to external account A2 through transaction Tx3 from the status value v12 to obtain The status value v13 of the balance of external account A1 is obtained, and the execution write set containing the key-value pair k1-v13 is obtained, and the execution write set containing the key-value pair k1-v13 may be used as the status
  • Step 49 Node n2 verifies whether node n1 did evil during the pre-execution of the first transaction based on the execution read-write set and the pre-execution read-write set. If not, the execution read-write set of the execution read-write set will be used as the status data of the first transaction.
  • node n2 After the computing process of node n2 completes the execution of any transaction (i.e., the first transaction) in each transaction group it receives, it can correspondingly obtain the execution read-write set of the first transaction, and further can determine the execution of the first transaction. Whether the read-write set is consistent with the pre-execution read-write set of the first transaction. When the execution read-write set is consistent with its pre-execution read-write set, the computing process can use the execution write set of the first transaction as the status data of the first transaction, so that the status data can be subsequently submitted to complete the transaction. Execution of the first transaction.
  • the execution read-write set of the first transaction is inconsistent with its pre-execution read-write set, it means that node n1 may do evil during the execution of the first transaction.
  • Wrong status data is provided to the TEE; at this time, the corresponding mechanism can be used to trigger the replacement of the master node of the blockchain system, and then the execution of the aforementioned multiple transactions including the first transaction can be reinitiated through a process similar to the above.
  • the status data obtained by each of the N computing processes will not involve the contract status data of the same smart contract/contract account, so the N computing processes of node n2 can Submit their respective status data in parallel without affecting each other. More specifically, if the state data obtained by the calculation process only includes world state data related to the state tree, it can directly submit the world state data it obtained; if the state data obtained by the calculation process contains both world state data and involves at least one contract status data of a smart contract, the computing process needs to first submit the contract status data of at least one smart contract it has obtained, for example, send the contract status data it obtains to the storage process, and the storage process updates the at least one smart contract accordingly.
  • the contract state tree (i.e., the aforementioned storage tree) obtains the respective storage roots of the at least one smart contract; and then merges and submits the respective storage roots of the at least one smart contract and the world state data obtained by the calculation process to the storage process, so that the storage process updates accordingly State parameters in the state tree.
  • control process can also call the storage process to submit the updated status tree and each storage tree to obtain the The state root of the corresponding block is then used by the control process to generate the corresponding block based on the state root and the aforementioned multiple transactions.
  • node n2 during the process of executing a transaction, node n2 does not need to calculate the resource consumption information of the transaction again, but uses the resource consumption information of the transaction from node n1 to execute the transaction, that is, using the resource consumption information of the transaction from node n1.
  • the resource consumption information of the transaction generates the execution write set of the transaction.
  • the execution write set of the transaction can be used as the status data of the transaction. Complete execution of the transaction. In this way, node n2 can complete the execution of the transaction more quickly because it does not need to calculate the resource consumption information of the transaction again.
  • the embodiments of this specification also provide a first node in a blockchain system, and the blockchain system further includes a second node.
  • the first node includes: a pre-execution process 52, deployed in the TEE of the first node, configured to pre-execute the first transaction, obtain resource consumption information and generate the resource consumption information based on the resource consumption information. Pre-execution read and write set; and configured to generate trusted data based on the resource consumption information in the TEE; network process 54, configured to send the trusted data and the pre-executed read and write to the second node set.
  • the embodiments of this specification also provide a second node in a blockchain system, and the blockchain system further includes a first node.
  • the second node includes: a network process 62 configured to receive trusted data and a pre-execution read-write set of the first transaction from the first node, the trusted data being provided by the first node.
  • the node generates resource consumption information based on the first transaction in its TEE, and the resource consumption information and the pre-execution read and write are obtained by the first node pre-executing the first transaction in its TEE;
  • the computing process 64 is configured to execute the first transaction based on the resource consumption information and obtain the execution read-write set of the first transaction; and, is configured to execute the read-write set based on the execution read-write set and the pre-execution read-write set. Determine whether the first node does evil in the process of pre-executing the first transaction, and if not, use the execution write set of the execution read and write set as the status data of the first transaction.
  • the embodiments of this specification also provide a blockchain system.
  • the blockchain system includes a first node and a second node.
  • the first node and the second node Nodes are any two blockchain nodes in the blockchain system.
  • the first node is used to pre-execute the first transaction in the trusted execution environment TEE, obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information; in the TEE based on the resource Consumption information generates trusted data; sends the trusted data and the pre-execution read and write set to the second node; the second node is used to execute the first transaction based on the resource consumption information, and obtain The execution read-write set of the first transaction; determine whether the first node does evil during the process of pre-executing the first transaction according to the execution read-write set and the pre-execution read-write set. If not, all The execution write set of the execution read and write set is used as the status data of the first transaction.
  • the first transaction is used to call a smart contract; the first node is used to execute the smart contract based on the first transaction in the TEE to obtain the resource consumption information .
  • the resource consumption information is calculated based on the data amount of the first transaction.
  • the trusted data is obtained by encrypting the resource consumption information; the second node is also used to decrypt the trusted data to obtain the resource consumption information.
  • the trusted data includes the resource consumption information and a signature corresponding to the resource consumption information; the second node is also used to verify the signature.
  • the first transaction is any one of multiple transactions included or indicated in the consensus proposal sent by the first node to the second node; the second node It is also used to divide the multiple transactions into M transaction groups according to their respective pre-execution read and write sets, and determine the calculation processes corresponding to each of the M transaction groups.
  • the second node is specifically configured to execute each transaction in each corresponding transaction group based on the respective resource consumption information of each transaction in each corresponding transaction group through the calculation process, and obtain each corresponding transaction.
  • Each transaction in the group has its own set of execution reads and writes.
  • the trusted data and the pre-execution read-write set are located in a consensus proposal sent by the first node to the second node, and the consensus proposal also includes the third A transaction or instruction information indicating the first transaction.
  • These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions
  • the device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device.
  • Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in computer-readable media, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash random access memory
  • Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information.
  • Information may be computer-readable instructions, data structures, modules of programs, 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), and read-only memory.
  • PRAM phase change memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • RAM random access memory
  • read-only memory read-only memory
  • ROM read-only memory
  • EEPROM electrically erasable programmable read-only memory
  • flash memory or other memory technology
  • compact disc read-only memory CD-ROM
  • DVD digital versatile disc
  • Magnetic tape magnetic tape storage, graphene storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device.
  • computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
  • one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein. Product form.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
  • program modules may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network.
  • program modules may be located in both local and remote computer storage media including storage devices.

Abstract

A transaction execution method and a node in a blockchain system, and a blockchain system. A first node in a blockchain system pre-executes a first transaction in a trusted execution environment (TEE) to obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information, and after generating trusted data on the basis of the resource consumption information in the TEE, sends the trusted data and the pre-execution read-write set to a second node in the blockchain system. The second node executes the first transaction on the basis of the resource consumption information to obtain an execution read-write set of the first transaction, and determines, according to the execution read-write set and the pre-execution read-write set, whether the first node made a mistake during the process of pre-executing the first transaction, and if not, uses an execution write set of the execution read-write set as state data of the first transaction.

Description

区块链系统中的交易执行方法、节点和区块链系统Transaction execution methods, nodes and blockchain systems in blockchain systems
本申请要求于2022年5月30日提交中国国家知识产权局、申请号为202210602801.X、申请名称为“区块链系统中的交易执行方法、节点和区块链系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires a Chinese patent application to be submitted to the State Intellectual Property Office of China on May 30, 2022, with the application number 202210602801.X and the application name "Transaction execution method, node and blockchain system in the blockchain system" priority, the entire contents of which are incorporated into this application by reference.
技术领域Technical field
本说明书实施例属于区块链技术领域,尤其涉及一种区块链系统中的交易执行方法、节点和区块链系统。The embodiments of this specification belong to the field of blockchain technology, and particularly relate to a transaction execution method, node and blockchain system in a blockchain system.
背景技术Background technique
区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链系统中按照时间顺序将数据区块以顺序相连的方式组合成链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本。由于区块链具有去中心化、信息不可篡改、自治性等特性,区块链也受到人们越来越多的重视和应用。Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. In the blockchain system, data blocks are combined into a chained data structure in a chronological manner and are cryptographically guaranteed to be an untamperable and unforgeable distributed ledger. Due to the characteristics of blockchain, such as decentralization, non-tamperable information, and autonomy, blockchain has also received more and more attention and applications.
发明内容Contents of the invention
本发明的目的在于提供一种区块链系统中的交易执行方法、节点和区块链系统。The purpose of the present invention is to provide a transaction execution method, node and blockchain system in a blockchain system.
第一方面,提供了一种区块链系统中的交易执行方法,所述区块链系统包括第一节点和第二节点,所述方法由所述第一节点执行。方法包括:在可信执行环境(trusted execution environment,TEE)中预执行第一交易,获得资源消费信息和基于所述资源消费信息生成的预执行读写集;在所述TEE中基于所述资源消费信息生成可信数据;向所述第二节点发送所述可信数据和所述预执行读写集。In a first aspect, a transaction execution method in a blockchain system is provided. The blockchain system includes a first node and a second node, and the method is executed by the first node. The method includes: pre-executing the first transaction in a trusted execution environment (TEE), obtaining resource consumption information and a pre-execution read-write set generated based on the resource consumption information; Consumption information generates trusted data; sends the trusted data and the pre-execution read and write set to the second node.
第二方面,提供了一种一种区块链系统中的交易执行方法,所述区块链系统包括第一节点和第二节点,所述方法由所述第一节点执行。方法包括:从所述第一节点接收可信数据和第一交易的预执行读写集,所述可信数据由所述第一节点在其TEE中基于第一交易的资源消费信息生成,所述资源消费信息和所述预执行读写及由所述第一节点在其TEE中对所述第一交易进行预执行以获得;基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集;根据所述执行读写集和所述预执行读写集确定所述第一节点在预执行所述第一交易的过程中是否作恶,如果否则将所述执行读写集的执行写集作为所述第一交易的状态数据。In a second aspect, a transaction execution method in a blockchain system is provided. The blockchain system includes a first node and a second node, and the method is executed by the first node. The method includes: receiving trusted data and a pre-execution read-write set of the first transaction from the first node, the trusted data being generated by the first node based on the resource consumption information of the first transaction in its TEE, so The resource consumption information and the pre-execution read and write are obtained by pre-executing the first transaction in its TEE by the first node; executing the first transaction based on the resource consumption information, obtaining the The execution read-write set of the first transaction; determine whether the first node does evil in the process of pre-executing the first transaction based on the execution read-write set and the pre-execution read-write set, and if not, the execution The execution write set of the read and write set serves as the status data of the first transaction.
第三方面,提供了一种区块链系统中的第一节点,所述区块链系统中还包括第二节点。所述第一节点包括:预执行进程,部署在所述第一节点的TEE中,配置为预执 行第一交易,获得资源消费信息和基于所述资源消费信息生成的预执行读写集;以及配置为在所述TEE中基于所述资源消费信息生成可信数据;网络进程,配置为向所述第二节点发送所述可信数据和所述预执行读写集。In a third aspect, a first node in a blockchain system is provided, and the blockchain system further includes a second node. The first node includes: a pre-execution process, deployed in the TEE of the first node, configured to pre-execute the first transaction, obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information; and Configured to generate trusted data based on the resource consumption information in the TEE; a network process configured to send the trusted data and the pre-execution read-write set to the second node.
第四方面,提供了一种区块链系统中的第二节点,所述区块链系统中还包括第一节点。所述第二节点包括:网络进程,配置为从所述第一节点接收可信数据和第一交易的预执行读写集,所述可信数据由所述第一节点在其TEE中基于第一交易的资源消费信息生成,所述资源消费信息和所述预执行读写及由所述第一节点在其TEE中对所述第一交易进行预执行以获得;计算进程,配置为基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集;以及,配置为根据所述执行读写集和所述预执行读写集确定所述第一节点在预执行所述第一交易的过程中是否作恶,如果否则将所述执行读写集的执行写集作为所述第一交易的状态数据。In a fourth aspect, a second node in a blockchain system is provided, and the blockchain system further includes a first node. The second node includes: a network process configured to receive trusted data from the first node and a pre-execution read-write set of the first transaction, the trusted data being generated by the first node in its TEE based on the first transaction. The resource consumption information of a transaction is generated, and the resource consumption information and the pre-execution read and write are obtained by the first node pre-executing the first transaction in its TEE; the calculation process is configured to be based on the Execute the first transaction using the resource consumption information to obtain the execution read-write set of the first transaction; and be configured to determine the pre-execution read-write set of the first node based on the execution read-write set and the pre-execution read-write set. Whether evil is committed during the execution of the first transaction, if not, use the execution write set of the execution read and write set as the status data of the first transaction.
第五方面,提供了一种区块链系统,包括第一节点和第二节点。其中:所述第一节点用于在可信执行环境TEE中预执行第一交易,获得资源消费信息和基于所述资源消费信息生成的预执行读写集;在所述TEE中基于所述资源消费信息生成可信数据;并向所述第二节点发送所述可信数据和所述预执行读写集;所述第二节点用于基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集;根据所述执行读写集和所述预执行读写集确定所述第一节点在预执行所述第一交易的过程中是否作恶,如果否则将所述执行读写集的执行写集作为所述第一交易的状态数据。The fifth aspect provides a blockchain system including a first node and a second node. Wherein: the first node is used to pre-execute the first transaction in the trusted execution environment TEE, obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information; in the TEE based on the resource Consumption information generates trusted data; sends the trusted data and the pre-execution read and write set to the second node; the second node is used to execute the first transaction based on the resource consumption information, and obtain The execution read-write set of the first transaction; determine whether the first node does evil during the process of pre-executing the first transaction according to the execution read-write set and the pre-execution read-write set. If not, all The execution write set of the execution read and write set is used as the status data of the first transaction.
上述实施例中,第二节点在执行交易的过程中,无需再次计算该交易的资源消费信息,而是使用来自第一节点的该交易的资源消费信息来执行该交易,即使用来自第一节点的该交易的资源消费信息生成该交易的执行写集。当第二节点确定该交易的执行读写集和预执行读写集确定出节点n1在执行该交易的过程中没有作恶的情况下,即可将该交易的执行写集作为该交易的状态数据而完成对该交易的执行。如此,第二节点因无需再次计算交易的资源消费信息而可以更为快速的完成对交易的执行。In the above embodiment, during the process of executing the transaction, the second node does not need to calculate the resource consumption information of the transaction again, but uses the resource consumption information of the transaction from the first node to execute the transaction, that is, using the resource consumption information of the transaction from the first node. The resource consumption information of the transaction generates the execution write set of the transaction. When the second node determines that the execution read-write set and the pre-execution read-write set of the transaction determine that node n1 has not done anything evil during the execution of the transaction, the execution write set of the transaction can be used as the status data of the transaction. and complete the execution of the transaction. In this way, the second node can complete the execution of the transaction more quickly because it does not need to calculate the resource consumption information of the transaction again.
附图说明Description of the drawings
为了更清楚地说明本说明书实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of this specification more clearly, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some of the embodiments recorded in this specification. , for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without exerting creative labor.
图1为本说明书实施例中示例性提供的区块链系统的示意图;Figure 1 is a schematic diagram of a blockchain system provided as an example in the embodiment of this specification;
图2为本说明书实施例中示例性提供的区块链数据存储的结构示意图;Figure 2 is a schematic structural diagram of blockchain data storage provided as an example in the embodiment of this specification;
图3为本说明书实施例中示例性提供的区块链系统中任意两个节点的结构示意图;Figure 3 is a schematic structural diagram of any two nodes in the blockchain system provided as an example in the embodiment of this specification;
图4为本说明书实施例中提供的一种交易执行方法的流程图;Figure 4 is a flow chart of a transaction execution method provided in the embodiment of this specification;
图5为本说明书实施例中提供的一种区块链节点的结构示意图之一;Figure 5 is one of the structural schematic diagrams of a blockchain node provided in the embodiment of this specification;
图6为本说明书实施例中提供的一种区块链节点的结构示意图之二。Figure 6 is the second structural schematic diagram of a blockchain node provided in the embodiment of this specification.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described The embodiments are only some of the embodiments of this specification, but not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts should fall within the scope of protection of this specification.
图1为本说明书实施例中示例性提供的区块链系统的示意图。如图1所示,区块链系统是通过多个节点(Node)来建立的分布式网络,其包含任意两个节点间通过点对点(Peer-to-Peer,P2P)网络实现在应用层的通信连接,例如其包含的节点n1~节点n5中的任意两个节点间均可通过P2P网络实现在应用层的通信连接。区块链系统利用链式区块结构构造的去中心化(或称为多中心化)的分布式账本,保存于分布式的区块链网络中的每个节点(或大多节点上,如共识节点)上,因此区块链系统需要解决去中心化(或多中心化)的多个节点上各自的账本数据的一致性和正确性的问题。鉴于此,区块链系统的每个节点上都运行着区块链程序,在一定容错需求的设计下,通过共识(consensus)机制保证所有忠诚节点具有相同的交易,从而保证所有忠诚节点对相同交易的执行结果一致,将交易打包成区块并基于相同交易的执行结果更新世界状态。其中当前主流的共识机制包括但不限于:工作量证明(Proof of Work,POW)、股权证明(Proof of Stake,POS)、实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)算法,蜜獾拜占庭容错(HoneyBadgerBFT)算法等等。Figure 1 is a schematic diagram of an exemplary blockchain system provided in the embodiment of this specification. As shown in Figure 1, the blockchain system is a distributed network established through multiple nodes (Node), which includes communication between any two nodes at the application layer through a peer-to-peer (P2P) network. Connection, for example, any two nodes among the nodes n1 to n5 contained therein can realize communication connection at the application layer through the P2P network. The blockchain system uses a decentralized (or multi-centered) distributed ledger constructed by a chain block structure, which is stored on each node (or most nodes, such as consensus) in the distributed blockchain network. node), so the blockchain system needs to solve the problem of consistency and correctness of the respective ledger data on multiple decentralized (or multi-centered) nodes. In view of this, each node of the blockchain system runs a blockchain program. Under the design of certain fault-tolerance requirements, the consensus mechanism is used to ensure that all loyal nodes have the same transactions, thereby ensuring that all loyal nodes have the same If the execution results of the transaction are consistent, the transaction is packaged into blocks and the world state is updated based on the execution results of the same transaction. Among them, the current mainstream consensus mechanisms include but are not limited to: Proof of Work (POW), Proof of Stake (POS), Practical Byzantine Fault Tolerance (PBFT) algorithm, Honey Badger Byzantine Fault Tolerance ( HoneyBadgerBFT) algorithm and so on.
区块链系统中的账户通常被划分为用户账户/外部账户(Externally owned account)和合约账户(contract account)两种类型;其中合约账户用于存储智能合约代码以及智能合约代码中相关状态的值,其通常只能通过外部账户进行调用激活。外部账户和合约账户的设计实际上是账户地址到账户状态的映射。账户的状态通常可以包括但不限于nonce、balance、storage_Root、codeHash等字段,其中nonce、balance在外部账户和合约账户中都存在,而codeHash和storage_Root属性通常仅在合约账户上有效。前述的各个字段中,nonce表征计数器,对于外部账户而言其代表从账户地址发送的交易的数量;对于合约账户而言其代表账户创建的合约数量。balance表征对应的外部账户拥有的数字资源的数量。storage_Root表征一个MPT(Merkle Patricia Tree)树根节点的哈希,该MPT用于对合约账户的状态变量的存储进行组织。codeHash表征智能合约代码的哈希值,对于合约账户而言其是智能合约被哈希计算并存储的代码,对于外部账户而言由于不包括智能合约,因此其可以是空字符串/全0字符串。Accounts in the blockchain system are usually divided into two types: user account/externally owned account (Externally owned account) and contract account (contract account); the contract account is used to store smart contract code and the values of related states in the smart contract code. , which can usually only be activated by calling an external account. The design of external accounts and contract accounts is actually the mapping of account addresses to account status. The status of an account can usually include, but is not limited to, nonce, balance, storage_Root, codeHash and other fields. Nonce and balance exist in both external accounts and contract accounts, while the codeHash and storage_Root attributes are usually only valid on contract accounts. Among the aforementioned fields, nonce represents the counter. For external accounts, it represents the number of transactions sent from the account address; for contract accounts, it represents the number of contracts created by the account. Balance represents the number of digital resources owned by the corresponding external account. storage_Root represents the hash of the root node of an MPT (Merkle Patricia Tree) tree. The MPT is used to organize the storage of state variables of contract accounts. codeHash represents the hash value of the smart contract code. For contract accounts, it is the hashed and stored code of the smart contract. For external accounts, it does not include smart contracts, so it can be an empty string/all 0 characters. string.
MPT是结合了Merkle Tree(默克尔树)和Patricia Tree(压缩前缀树,一种更节省空间的Trie树,字典树)的一种树形结构。Merkle Tree,默克尔树算法对每个交易都 计算一个Hash值,然后两两连接再次计算Hash,一直到最顶层的Merkle根。以太坊中采用改进的MPT树,例如16叉树的结构,通常也简称为MPT树。其中以太坊MPT树的数据结构包括状态树(state trie)。状态树中包含以太坊中每个账户所对应的存储内容的键值对(key and value pair)。状态树中的“键”可以是一个的160bits标识符(以太坊账户的地址),这个账户地址分布于从状态树的根节点开始到叶子节点的存储中。状态树中的“值”是通过对以太坊账户的信息进行编码(使用递归长度字典编码(Recursive-Length Prefix encoding,RLP)方法)生成的。如前所述,对于外部账户而言,值包括nonce和balance;对于合约账户而言,值包括nonce、balance、codehash和storage_Root等等。MPT is a tree structure that combines Merkle Tree (Merkle Tree) and Patricia Tree (Compressed Prefix Tree, a more space-saving Trie tree, dictionary tree). Merkle Tree, the Merkle tree algorithm calculates a Hash value for each transaction, and then connects the two to calculate the Hash again, all the way to the top-level Merkle root. Ethereum uses an improved MPT tree, such as a 16-fork tree structure, which is often referred to as an MPT tree. The data structure of the Ethereum MPT tree includes a state trie. The state tree contains the key and value pair corresponding to the storage content of each account in Ethereum. The "key" in the state tree can be a 160bits identifier (the address of an Ethereum account). This account address is distributed in the storage starting from the root node of the state tree to the leaf nodes. The "values" in the state tree are generated by encoding the Ethereum account information (using the Recursive-Length Prefix encoding (RLP) method). As mentioned before, for external accounts, the values include nonce and balance; for contract accounts, the values include nonce, balance, codehash, storage_Root, etc.
合约账户用于存储智能合约相关的状态。智能合约在区块链系统中完成部署后,会产生一个对应的合约账户。这个合约账户一般会具有一些状态,这些状态由智能合约中状态变量所定义并在智能合约创建、执行时产生新的值。所述的智能合约通常是指在区块链环境中以数字形式定义的能够自动执行条款的合约。一旦某个事件触发合约中的条款(满足执行条件),代码即可以自动执行。在区块链中,合约的相关状态保存在存储树(storage trie)中,存储树根节点的hash值即存储于上述storage_Root中,从而将该合约的所有状态通过hash锁定到该合约账户下。存储树也是一个MPT树形结构,存储了状态地址到状态值的key-value映射。从存储树的根节点到叶子节点存储有一个状态的地址,一个叶子节点中存储一个状态的值。Contract accounts are used to store status related to smart contracts. After the smart contract is deployed in the blockchain system, a corresponding contract account will be generated. This contract account generally has some states, which are defined by the state variables in the smart contract and generate new values when the smart contract is created and executed. The smart contract usually refers to a contract defined in digital form in a blockchain environment that can automatically execute terms. Once an event triggers a clause in the contract (execution conditions are met), the code can be executed automatically. In the blockchain, the relevant status of the contract is stored in the storage trie, and the hash value of the root node of the storage tree is stored in the above-mentioned storage_Root, thereby locking all the status of the contract to the contract account through hash. The storage tree is also an MPT tree structure, which stores the key-value mapping from state addresses to state values. The address of a state is stored from the root node of the storage tree to the leaf nodes, and the value of a state is stored in a leaf node.
请参见图2示例性提供的区块链数据存储的结构示意图。如图2所示,单个区块的区块头中可以包括若干字段,例如上一区块哈希previous_Hash(图中的PrevHash,或称为父hash),随机数Nonce(在一些区块链系统中这个Nonce不是随机数,或者在一些区块链系统中不启用区块头中的Nonce),时间戳Timestamp,区块号BlockNum,状态根哈希State_Root,交易根哈希Transaction_Root,收据根哈希Receipt_Root等。其中,下一区块(如区块N+1)的区块头中的PrevHash指向上一区块(如区块N),即为上一区块的hash值。通过这种方式,区块链上通过区块头实现了下一区块对上一区块的锁定。需要特别说明的是,state_root是当前区块中所有账户的状态组成的MPT树的根的哈希值,即指向state_root的为一棵MPT形式的状态树。这个MPT树的根节点可以为一个扩展节点(Extension Node)或一个分支节点(Branch Node),state_root中存储的一般为这个根节点的hash值。从这个MPT的根节点到叶子节点中每个节点的一部分值按照顺序串联起来可以构成账户地址并作为key,叶子节点中存储的账户信息为这个账户地址对应的value,这样,构成了key-value键值对。key可以是sha3(Address),即账户地址的hash值(hash算法例如采用sha3算法),其存储的值value可以为rlp(Account),即账户信息的rlp编码。其中账户信息可以是[nonce,balance,storage_root,codeHash]构成的四元组。如前所述,对于外部账户来说,一般只有nonce和balance两项,而storage_root、codeHash字段默认存储空字符串/全0字符串。对于合约账户来说,合约 账户可以包括nonce,balance,storage_root,codeHash等等。此外不论是外部账户还是合约账户,其账户信息一般都位于一个单独的叶子节点(Leaf Node)中。从根节点的扩展节点/分支节点到每个账户的叶子节点,可能中间会经过若干个分支节点以及扩展节点。Please refer to Figure 2 for an exemplary structural diagram of blockchain data storage. As shown in Figure 2, the block header of a single block can include several fields, such as the previous block hash previous_Hash (PrevHash in the figure, or called the parent hash), the random number Nonce (in some blockchain systems This Nonce is not a random number, or the Nonce in the block header is not enabled in some blockchain systems), timestamp Timestamp, block number BlockNum, state root hash State_Root, transaction root hash Transaction_Root, receipt root hash Receipt_Root, etc. . Among them, the PrevHash in the block header of the next block (such as block N+1) points to the previous block (such as block N), which is the hash value of the previous block. In this way, the next block locks the previous block through the block header on the blockchain. It should be noted that state_root is the hash value of the root of the MPT tree composed of the status of all accounts in the current block, that is, the point pointing to state_root is a state tree in the form of MPT. The root node of this MPT tree can be an extension node (Extension Node) or a branch node (Branch Node). What is stored in state_root is generally the hash value of this root node. A part of the value of each node from the root node of this MPT to the leaf node can be concatenated in order to form an account address and serve as a key. The account information stored in the leaf node is the value corresponding to the account address, thus forming a key-value Key-value pairs. The key can be sha3 (Address), which is the hash value of the account address (the hash algorithm uses the sha3 algorithm, for example), and its stored value value can be rlp (Account), which is the rlp encoding of the account information. The account information can be a four-tuple consisting of [nonce, balance, storage_root, codeHash]. As mentioned before, for external accounts, there are generally only two items, nonce and balance, and the storage_root and codeHash fields store empty strings/all 0 strings by default. For contract accounts, contract accounts can include nonce, balance, storage_root, codeHash, etc. In addition, whether it is an external account or a contract account, its account information is generally located in a separate leaf node (Leaf Node). From the extension node/branch node of the root node to the leaf node of each account, there may be several branch nodes and extension nodes in the middle.
对于状态树中的单个合约账户来说,其storage_Root指向另一棵同为MPT形式的树,其中存储了合约执行涉及的状态变量(state variable)的数据。这个storage_Root指向的MPT形式的树为存储树,即存储树的根节点的hash值。一般的,这个存储树存储的也是key-value键值对。从根节点到叶子节点的路径上存储的一部分数据连起来构成key,叶子节点中存储value。前面提到,这个存储树也可以是MPT形式的树,一般可以是16叉树,即对于分支节点而言,其最多可以有16个孩子节点,其中可能包括扩展节点和/或叶子节点。而对于扩展节点而言,其一般可以有1个孩子节点,其可以是分支节点。这棵存储树最多可以有64层的深度。For a single contract account in the state tree, its storage_Root points to another tree in the form of MPT, which stores the data of state variables involved in contract execution. The tree in MPT form pointed to by this storage_Root is a storage tree, that is, the hash value of the root node of the storage tree. Generally, this storage tree also stores key-value pairs. A part of the data stored on the path from the root node to the leaf node is connected to form the key, and the value is stored in the leaf node. As mentioned earlier, this storage tree can also be a tree in the form of MPT, which can generally be a 16-fork tree, that is, for a branch node, it can have up to 16 child nodes, which may include extension nodes and/or leaf nodes. For an extension node, it generally can have one child node, which can be a branch node. This storage tree can be up to 64 levels deep.
参照前文相关于存储树(storage trie)和状态树(state trie)的描述不难发现,区块链系统中的节点完成执行属于某个区块的多个交易后产生的状态数据,可能包括与storage trie相关的合约状态数据以及与state trie相关的世界状态数据。因此节点提交状态数据的过程中,通常需要先提交合约状态数据以获得合约账户的storage_root,进而更新state trie中相关合约账号的storage_root,并提交其获得的世界状态数据以获得状态树的state_root。Referring to the previous descriptions of storage trie and state trie, it is not difficult to find that the status data generated after nodes in the blockchain system complete the execution of multiple transactions belonging to a certain block may include Contract status data related to the storage trie and world state data related to the state trie. Therefore, when a node submits state data, it usually needs to submit the contract state data first to obtain the storage_root of the contract account, then update the storage_root of the relevant contract account in the state trie, and submit the obtained world state data to obtain the state_root of the state tree.
图3为本说明书实施例中示例性提供的区块链系统中任意两个节点(例如作为主节点/第二节点的节点n1和作为从节点/第一节点的节点n2)的结构示意图。节点n1和节点n2中均可运行多个进程以提供多种服务,例如参照图3所示,节点n1和节点n2均可各自运行用于提供接入服务的接入进程、用于提供缓存服务的缓存进程、用于提供预执行服务的预执行进程、用于提供网络服务的网络进程、用于提供共识服务的共识进程、用于提供区块管理服务的控制进程(或者表述为区块管理进程)和用于提供存储服务的存储进程;此外作为从节点的节点n2还可以运行用于提供计算服务的多个计算进程。其中进程指是应用中具有一定独立功能的程序关于一个数据集合的一次运行活动,即进程是计算机中通过由CPU顺序执行应用程序中的指令而进行的一个过程,而每个进程在创建时被分配自己的内存地址空间。节点n1中的多个进程可以为多个计算设备或虚拟计算节点中的多个进程,节点n2中的多个进程可以为多个计算设备或虚拟计算节点中的多个进程。此外需要说明的是本说明书实施例提供的方案并不局限于主从架构的区块链系统。Figure 3 is a schematic structural diagram of any two nodes (for example, node n1 as the master node/second node and node n2 as the slave node/first node) in the blockchain system provided as an example in the embodiment of this specification. Both node n1 and node n2 can run multiple processes to provide multiple services. For example, as shown in Figure 3, node n1 and node n2 can each run access processes for providing access services and caching services. The cache process, the pre-execution process used to provide pre-execution services, the network process used to provide network services, the consensus process used to provide consensus services, the control process used to provide block management services (or expressed as block management process) and a storage process used to provide storage services; in addition, node n2 as a slave node can also run multiple computing processes used to provide computing services. The process refers to a running activity of a program with certain independent functions in the application on a data collection. That is, a process is a process in the computer that is carried out by the CPU sequentially executing instructions in the application program, and each process is created when it is created. Allocate its own memory address space. The multiple processes in node n1 may be multiple processes in multiple computing devices or virtual computing nodes, and the multiple processes in node n2 may be multiple processes in multiple computing devices or virtual computing nodes. In addition, it should be noted that the solutions provided by the embodiments of this specification are not limited to the master-slave architecture blockchain system.
接入进程可以用于接收来自用户设备的交易,进而由接入进程调用缓存进程实现将其接收的交易加入待处理的交易队列中进行缓存。The access process can be used to receive transactions from the user device, and then the access process calls the cache process to add the received transactions to the pending transaction queue for caching.
节点n2的预执行进程可以调用缓存进程来实现从待处理的交易队列中按顺序读取其缓存的交易并对该交易进行验证,例如验证用户设备对该交易的签名,并将经验证 的交易返回给缓存进程。此外节点n2可以通过其网络进程向其余节点的网络进程广播其缓存进程中存储的经验证的交易;进而节点n1通过其网络进程接收的来自节点n2的交易,可以由其缓存进程缓存加入到待处理的交易队列中。由此节点n1的缓存进程通过其内存缓存的待处理的交易队列,不仅包括通过其接入进程接收的交易,还包括通过其网络进程接收的来自其它节点的交易。The pre-execution process of node n2 can call the cache process to read its cached transactions in order from the pending transaction queue and verify the transaction, such as verifying the signature of the user device on the transaction and sending the verified transaction Returned to the cache process. In addition, node n2 can broadcast the verified transactions stored in its cache process to the network processes of other nodes through its network process; furthermore, the transactions from node n2 received by node n1 through its network process can be added to the waiting list by its cache process cache. in the transaction queue for processing. Therefore, the pending transaction queue cached by the cache process of node n1 through its memory includes not only transactions received through its access process, but also transactions received from other nodes through its network process.
节点n1的预执行进程也可以调用缓存进程来实现从待处理的交易队列中按顺序读取其缓存的交易,并至少对来自与节点n1连接的用户设备的交易进行验证。此外节点n2的预执行进程还可以对其从缓存进程按顺序接收的交易进行预执行以得到该交易的预执行信息,其中预执行信息例如包括预执行读集、预执行写集以及执行该交易所需消耗的数字资源/计算资源的数量(即资源消费信息)。进而节点n1的预执行进程还可以在其每完成对一批交易的预执行后,将该批交易的预执行信息返回给缓存进程以缓存到待共识的交易队列中进行缓存。需要特别说明的是,节点n1的缓存进程的内存中还可以缓存有部分状态数据;对于由节点n1的预执行进程预执行的任一交易而言,在对该任一交易进行预执行的过程中,预执行进程可以首先调用缓存进程查询其缓存的状态数据中是否包括将要读取的任意变量的状态值,如果是则获得缓存进程返回的该任意变量的状态值,如果否则预执行进程可以调用存储进程从已提交到状态数据库的状态数据中查询该任意变量的状态值。此外还需要特别说明的是,由于节点n1的预执行进程会将其预执行的交易的预执行信息返回给缓存进程,因而其缓存进程还可以基于其接收的预执行读写集对应更新该缓存进程缓存的状态数据。此外还需要特别说明的是,由于预执行进程可以按顺序从缓存进程缓存的待处理的交易队列中依次读取交易并对其进行预执行,因而缓存进程还可以基于其缓存的待处理的交易队列在其内存中对应缓存由预执行进程预执行的多个交易的预执行顺序。The pre-execution process of node n1 can also call the cache process to sequentially read its cached transactions from the pending transaction queue, and at least verify transactions from user devices connected to node n1. In addition, the pre-execution process of node n2 can also pre-execute the transactions it receives in sequence from the cache process to obtain the pre-execution information of the transaction. The pre-execution information includes, for example, the pre-execution read set, the pre-execution write set and the execution of the transaction. The amount of digital resources/computing resources that need to be consumed (i.e. resource consumption information). Furthermore, the pre-execution process of node n1 can also return the pre-execution information of this batch of transactions to the cache process after each completion of the pre-execution of a batch of transactions, so that it can be cached in the transaction queue to be agreed upon. It should be noted that part of the status data can also be cached in the memory of the cache process of node n1; for any transaction pre-executed by the pre-execution process of node n1, during the process of pre-execution of any transaction , the pre-execution process can first call the cache process to query whether its cached status data includes the status value of any variable to be read. If so, obtain the status value of the arbitrary variable returned by the cache process. If not, the pre-execution process can Call the stored procedure to query the state value of this arbitrary variable from the state data submitted to the state database. In addition, it should be noted that since the pre-execution process of node n1 will return the pre-execution information of its pre-executed transactions to the cache process, its cache process can also update the cache based on the pre-execution read and write set it receives. Process cached state data. In addition, it should be noted that since the pre-execution process can sequentially read transactions from the pending transaction queue cached by the cache process and pre-execute them, the cache process can also pre-execute them based on its cached pending transactions. The queue caches in its memory the pre-execution order of multiple transactions pre-executed by the pre-execution process.
预执行读集中包含若干唯一键(key),还包括从已提交的世界状态中读取的与前述各个key相对应的键值(value)。预执行写集中也包含若干唯一键(key),还包括期望提交的与前述各个key相对应的键值(value);此外如果某个交易对世界状态中的某个key进行删除处理,则预执行写集中还会对被删除的key记录相应的标记。需要特别说明的是,如果被预执行的交易是用于调用智能合约的合约调用交易,则其预执行读写集中可能不仅仅包含与外部账户相关的状态参数,还可能涉及与智能合约的合约状态相关的若干合约参数。The pre-execution read set contains several unique keys (keys), and also includes the key values (values) corresponding to each of the aforementioned keys read from the submitted world state. The pre-execution write set also contains a number of unique keys (keys), as well as the key values (values) corresponding to each of the aforementioned keys that are expected to be submitted; in addition, if a transaction deletes a certain key in the world state, the pre-execution write set will Executing the write set will also record the corresponding mark for the deleted key. It should be noted that if the pre-executed transaction is a contract call transaction used to call a smart contract, its pre-execution read and write set may not only contain state parameters related to external accounts, but may also involve contracts related to the smart contract. Several contract parameters related to the status.
下面示例性描述节点n1依次对交易Tx1~交易Tx5进行预执行的过程,其中假设交易Tx1和和交易Tx2为用于外部账户A1和外部账户A2分别发起的用于调用智能合约C1的合约调用交易,并且假设智能合约C1对应合约账户B1;此外假设交易Tx3是外部账户A1发起的指向外部账户A3的转账交易,交易Tx4是外部账户A4发起的指向外部账户A5的转账交易,交易Tx5是外部账户A6发起的指向外部账户A7的转账交易。节点n1通过其预执行进程对交易Tx1~交易Tx5进行预执行,可能获得如下表1中示例的交易Tx1~ 交易Tx5各自的预执行信息。The following is an exemplary description of the process in which node n1 sequentially pre-executes transactions Tx1 ~ transaction Tx5. It is assumed that transactions Tx1 and transaction Tx2 are contract call transactions for calling smart contract C1 initiated by external account A1 and external account A2 respectively. , and assume that smart contract C1 corresponds to contract account B1; in addition, assume that transaction Tx3 is a transfer transaction initiated by external account A1 and directed to external account A3, transaction Tx4 is a transfer transaction initiated by external account A4 and directed to external account A5, and transaction Tx5 is an external account A transfer transaction initiated by A6 to external account A7. Node n1 pre-executes transactions Tx1 to Tx5 through its pre-execution process, and may obtain the respective pre-execution information of transactions Tx1 to Tx5 as shown in Table 1 below.
交易trade 预执行读集Pre-execution read set 预执行写集Pre-execution write set
交易Tx1Transaction Tx1 k1=v11,k2=v21k1=v11, k2=v21 k1=v12,k2=v22k1=v12, k2=v22
交易Tx2Transaction Tx2 k3=v31,k4=v41k3=v31, k4=v41 k3=v32,k4=v42k3=v32, k4=v42
交易Tx3Transaction Tx3 k1=v12,k5=v51k1=v12, k5=v51 k1=v13,k5=v52k1=v13, k5=v52
交易Tx4Transaction Tx4 k6=v61,k7=v71k6=v61, k7=v71 k6=v62,k7=v72k6=v62, k7=v72
交易Tx5Transaction Tx5 k8=v81,k9=v91k8=v81, k9=v91 k8=v82,k9=v92k8=v82, k9=v92
表1Table 1
对于前述表1中示例性提供的各个参数,例如k1表征外部账户A1的balance的key,k2表征合约账户B1下的某个状态参数的key,k3表征外部账户A2的balance的key,k4表征合约账户B1下的某个状态参数的key,k5~k9依次表征外部账户A3~外部账户A7下的balance的key。其中v11、v12、v13以及v21~v92分别表征其各自对应的key的值。需要特别说明的是,由于交易Tx3在交易Tx1之后执行,因此交易Tx3的预执行读集中k1的值为交易Tx1的预执行写集中k1的值。For each parameter provided as an example in Table 1, for example, k1 represents the key of the balance of the external account A1, k2 represents the key of a certain state parameter under the contract account B1, k3 represents the key of the balance of the external account A2, and k4 represents the contract. The key of a certain state parameter under account B1, k5 ~ k9, in turn represent the keys of the balance under external account A3 ~ external account A7. Among them, v11, v12, v13 and v21~v92 respectively represent the values of their corresponding keys. It should be noted that since transaction Tx3 is executed after transaction Tx1, the value of k1 in the pre-execution read set of transaction Tx3 is the value of k1 in the pre-execution write set of transaction Tx1.
节点n1的共识进程可以调用其缓存进程,从待共识的交易队列中按顺序读取多个交易以及其相关数据来生成共识提议,其中该共识提议中例如可以包括该多个交易各自对应的预执行信息、该多个交易的共识顺序(该多个交易的共识顺序与该多个交易的预执行顺序相同),以及该多个交易或者该多个交易各自的指示信息(例如该多个交易各自的摘要值)。需要特别说明的是,节点n1的共识进程调用其缓存进程的条件,可以包括但不限于按照固定时间步长调用缓存进程、通过缓存进程缓存的交易的数据量达到预定大小时调用缓存进程,或者通过缓存进程缓存的经预执行的交易达到预定数量时调用缓存进程等等。进而,节点n1的共识进程还可以通过其网络进程,向参与对共识提议进行共识的其余节点(例如节点n2)各自的网络进程发送共识提议,以便通过其共识进程与其余节点各自的共识进程对其生成的共识提议进行共识。此外需要特别说明的是,节点n1还可以基于共识提议所指示的多个交易各自的预执行信息,计算该多个交易对应的分组信息,并将该分组信息携带于共识提议中,以便参与对共识提议进行共识的其它节点可以基于该分组信息对前述多个交易进行分组。The consensus process of node n1 can call its cache process to sequentially read multiple transactions and their related data from the transaction queue to be agreed upon to generate a consensus proposal, where the consensus proposal can include, for example, the corresponding predetermined data of the multiple transactions. Execution information, the consensus order of the multiple transactions (the consensus order of the multiple transactions is the same as the pre-execution order of the multiple transactions), and the multiple transactions or the respective instruction information of the multiple transactions (for example, the multiple transactions their respective summary values). It should be noted that the conditions for the consensus process of node n1 to call its cache process may include but are not limited to calling the cache process according to a fixed time step, calling the cache process when the amount of transaction data cached by the cache process reaches a predetermined size, or The cache process is called when a predetermined number of pre-executed transactions cached by the cache process reaches a predetermined number, and so on. Furthermore, the consensus process of node n1 can also send consensus proposals to the respective network processes of other nodes (such as node n2) participating in consensus on the consensus proposal through its network process, so as to communicate with the respective consensus processes of other nodes through its consensus process. The consensus proposals it generates are subject to consensus. In addition, it should be noted that node n1 can also calculate the grouping information corresponding to the multiple transactions based on the pre-execution information of each of the multiple transactions indicated by the consensus proposal, and carry the grouping information in the consensus proposal in order to participate in the consensus proposal. Other nodes that propose consensus can group the aforementioned multiple transactions based on this grouping information.
对共识提议达成共识后,由于节点n1和节点n2各自从与其连接的用户设备接收的交易,均由节点n1的缓存进程按照接收顺序将其加入待处理的交易队列,并由节点n1的预执行进程按顺序对待处理的交易队列中的各交易进行预执行,因此节点n1的共识进程可以按照前述多个交易的预执行顺序/共识顺序将前述多个交易的预执行信息发送至其控制进程,由控制进程将前述多个交易各自的预执行信息部分或全部的作为相应区块的状态数据提交到存储服务,进而获得用于生成相应区块的状态根并生成包含该状态根以及前述多个交易的区块。After reaching a consensus on the consensus proposal, since the transactions received by node n1 and node n2 respectively from the user devices connected to them are added to the pending transaction queue in the order of reception by the cache process of node n1, and pre-executed by node n1 The process pre-executes each transaction in the transaction queue to be processed in order, so the consensus process of node n1 can send the pre-execution information of the aforementioned multiple transactions to its control process according to the pre-execution order/consensus order of the aforementioned multiple transactions. The control process submits part or all of the pre-execution information of each of the aforementioned multiple transactions to the storage service as the state data of the corresponding block, and then obtains the state root used to generate the corresponding block and generates a state root containing the state root and the aforementioned multiple Transaction block.
节点n2例如可以在对节点n1生成的共识提议进行共识的过程中,或者在对节点n1 生成的共识提议达成共识之后,通过其共识进程和/或控制进程从该共识提议中读取前述多个交易各自的预执行信息,进而基于该多个交易各自的预执行信息对该多个交易进行分组以得到M个交易分组(M大于1);或者从共识提议中读取前述多个交易的分组信息并基于该分组信息对前述多个交易进行分组以得到M个交易分组。更具体地,例如可以由节点n2的共识进程基于前述多个交易各自的预执行信息计算分组信息,并将分组信息、前述多个交易以及其各自对应的预执行读写集发送至节点n2的控制进程;进而由节点n2的控制进程基于分组信息将前述多个交易划分为M个交易分组,并由节点n2的控制进程对节点n2中的N个计算进程进行任务调度。For example, node n2 may, during the process of consensus on the consensus proposal generated by node n1, or after reaching consensus on the consensus proposal generated by node n1, read the aforementioned plurality of consensus proposals from the consensus proposal through its consensus process and/or control process. Pre-execution information of each transaction, and then group the multiple transactions based on the pre-execution information of each transaction to obtain M transaction groups (M is greater than 1); or read the grouping of the aforementioned multiple transactions from the consensus proposal information and group the aforementioned multiple transactions based on the grouping information to obtain M transaction groups. More specifically, for example, the consensus process of node n2 can calculate the grouping information based on the pre-execution information of each of the aforementioned multiple transactions, and send the grouping information, the aforementioned multiple transactions and their respective corresponding pre-execution read and write sets to the node n2. control process; then the control process of node n2 divides the aforementioned multiple transactions into M transaction groups based on the grouping information, and the control process of node n2 performs task scheduling on the N computing processes in node n2.
获得前述M个交易分组的过程中,需要确保位于任意两个交易分组中的任意两个交易互不冲突。任意两个交易互不冲突具体是指任意两个交易不存在如下情况之一:一个交易的预执行读集与另一个交易的预执行写集中包括相同的key、一个交易的预执行写集和另一个交易的预执行写集中包括相同的key。而对于存在冲突的任意两个交易,则其需要被划分到相同的交易分组中,换而言之即如果该任意两个交易各自的预执行写集中包含相同的key,即认为该任意两个冲突交易访问了相同的参数而存在冲突,该任意两个交易需要被划分到相同的交易分组;如果该任意两个交易中的一个交易的预执行读集与另一个交易的预执行写集中包含相同的key,即认为该任意两个交易访问了相同的参数而存在冲突,该任意两个交易需要被划分到相同的交易分组。在另一种可能的实施方式中,为了高效的实现确定出前述多个交易的分组信息或者说高效的完成将前述多个交易划分为M个交易分组,通常可以按照位于任意两个不同的交易分组中的任意两个交易不访问相同参数(即不包含相同的key)的要求来对前述多个交易进行分组。这样,对于前述示例的交易Tx1~交易Tx5,其分组情况例如可能包括:交易Tx1和交易Tx3被划分到交易分组1中,交易Tx2被划分到交易分组2中,交易Tx4和交易Tx5各自被划分到交易分组3和交易分组4中。In the process of obtaining the aforementioned M transaction groups, it is necessary to ensure that any two transactions in any two transaction groups do not conflict with each other. Any two transactions do not conflict with each other. Specifically, any two transactions do not have one of the following situations: the pre-execution read set of one transaction and the pre-execution write set of another transaction include the same key, the pre-execution write set of one transaction and Another transaction's pre-execution write set includes the same key. For any two transactions that conflict, they need to be divided into the same transaction group. In other words, if the pre-execution write sets of any two transactions contain the same key, it is considered that any two transactions Conflict transactions access the same parameters and conflict exists. Any two transactions need to be divided into the same transaction group; if the pre-execution read set of one of the two transactions is included in the pre-execution write set of the other transaction, The same key means that any two transactions are considered to have accessed the same parameters and there is a conflict. The any two transactions need to be divided into the same transaction group. In another possible implementation, in order to efficiently determine the grouping information of the aforementioned multiple transactions or to efficiently complete the aforementioned multiple transactions, the aforementioned multiple transactions can be divided into M transaction groups. Usually, the grouping information can be determined according to the location of any two different transactions. The aforementioned multiple transactions are grouped by the requirement that any two transactions in the group do not access the same parameters (that is, do not contain the same key). In this way, for the transactions Tx1 to Tx5 in the aforementioned example, the grouping situation may include, for example: transaction Tx1 and transaction Tx3 are divided into transaction group 1, transaction Tx2 is divided into transaction group 2, and transaction Tx4 and transaction Tx5 are divided respectively. Go to transaction group 3 and transaction group 4.
节点n2具体可以按照M个交易分组,通过其运行的N个计算进程并行执行该M个交易分组中的多个交易。然而交易的执行需要消费节点的计算资源,尤其对于请求调用智能合约的合约调用交易而言,节点在执行该交易的过程中可能需要执行大量指令,因此通常需要在执行交易的过程中基于该交易消费的指令或者该交易的数据量来统计该交易的资源消费信息,进而基于资源消费信息完成对该交易的执行,例如修改发起该交易的外部账户的balance字段以实现修改其持有的数字资源的数量。执行交易的过程中计算该交易的资源消费信息,无疑会额外增加该交易的执行时间,导致计算进程无法快速完成对交易的执行。Specifically, node n2 can be grouped into M transactions and execute multiple transactions in the M transaction groups in parallel through the N computing processes it runs. However, the execution of the transaction requires consuming the computing resources of the node. Especially for contract call transactions that request to call smart contracts, the node may need to execute a large number of instructions during the execution of the transaction. Therefore, it is usually necessary to execute the transaction based on the transaction. The consumption instructions or the data volume of the transaction are used to count the resource consumption information of the transaction, and then the execution of the transaction is completed based on the resource consumption information. For example, the balance field of the external account that initiated the transaction is modified to modify the digital resources held by it. quantity. Calculating the resource consumption information of the transaction during the execution of the transaction will undoubtedly increase the execution time of the transaction, causing the calculation process to be unable to quickly complete the execution of the transaction.
图4为本说明书实施例中提供的一种区块链系统中的交易执行方法的流程图。该方法具体涉及区块链系统中任意的第一节点(例如作为主节点的节点n1)和第二节点(例如作为从节点的节点n2),第一节点和第二节点均可各自实现为任何具有计算/处理能力的装置、平台、设备或设备集群。下文中将主要以节点n1与节点n2相协作以完成对 交易的执行为例,详细描述区块链系统中的交易执行过程。如图4所示,该方法可以包括但不限于如下步骤41~步骤49。Figure 4 is a flow chart of a transaction execution method in a blockchain system provided in the embodiment of this specification. This method specifically involves any first node (such as node n1 as the master node) and second node (such as the node n2 as the slave node) in the blockchain system. The first node and the second node can each be implemented as any A device, platform, device or cluster of devices with computing/processing capabilities. In the following, the transaction execution process in the blockchain system will be described in detail, mainly taking node n1 and node n2 to cooperate to complete the execution of the transaction as an example. As shown in Figure 4, the method may include but is not limited to the following steps 41 to 49.
步骤41,节点n1在其TEE中预执行第一交易,获得资源消费信息以及基于资源消费信息生成的预执行读写集。Step 41: Node n1 pre-executes the first transaction in its TEE, and obtains resource consumption information and a pre-execution read-write set generated based on the resource consumption information.
前述第一交易例如为节点n1通过其接入进程或网络进程接收的任一交易。第一交易的资源消费信息是节点n1对第一交易进行预执行的过程中基于该第一交易的数据量计算得到,或者是节点n1对第一交易进行预执行的过程中基于该第一交易消费的指令计算得到的。The aforementioned first transaction is, for example, any transaction received by node n1 through its access process or network process. The resource consumption information of the first transaction is calculated based on the data volume of the first transaction during the process of node n1 pre-executing the first transaction, or based on the first transaction during the process of node n1 pre-executing the first transaction. Calculated from the instructions consumed.
请继续参见图3,节点n1的预执行进程例如可以运行在其TEE中,其接入进程以及网络进程等其它进程可以运行在其TEE的外部。运行在TEE中的预执行进程可以调用TEE外部的缓存进程,实现从待处理的交易队列中按顺序读取其缓存的交易,并对其读取的交易进行预执行以得到该交易所需消费的数字资源的数量(即资源消费信息)和基于该资源消费信息生成的预执行读写集。预执行读写集的预执行写集中通常可以包括基于该资源消费计算的某个状态参数的状态值,该状态参数例如为发起交易的外部账户的balance。Please continue to refer to Figure 3. For example, the pre-execution process of node n1 can run in its TEE, and other processes such as its access process and network process can run outside its TEE. The pre-execution process running in the TEE can call the cache process outside the TEE to read its cached transactions in order from the pending transaction queue, and pre-execute the read transactions to obtain the required consumption of the transaction. The number of digital resources (that is, resource consumption information) and the pre-execution read and write set generated based on the resource consumption information. The pre-execution write set of the pre-execution read-write set can usually include the status value of a certain status parameter calculated based on the resource consumption. The status parameter is, for example, the balance of the external account that initiated the transaction.
对于由外部账户发起的用于调用智能合约的合约调用交易而言,例如由外部账户A1发起的用于调用智能合约C1的前述交易Tx1而言,其预执行读集中包括外部账户A1的balace的状态值v11,还包括智能合约C1中某个合约参数的状态值v21。位于节点n1的TEE中的预执行进程对交易Tx1进行预执行的过程中,例如该预执行进程通过虚拟机执行智能合约C1的过程中,将会获得将要写入的由k2表征的合约参数的状态值v22;此外该虚拟机还会计算其因执行前述智能合约C1而消费的每条指令各自需要消费的数字资源的数量,进而在完成执行智能合约C1后将会获得因执行智能合约C1而消费的数字资源的数量,即获得交易Tx1的资源消费信息gas1。最后,位于TTE中的预执行进程还可以基于gas1和预执行读集中k1的状态值v11,计算出预执行写集中期望写入的k1的状态值v12,即计算出外部账户A1的balance的状态值v12。For a contract call transaction initiated by an external account to call a smart contract, such as the aforementioned transaction Tx1 initiated by an external account A1 to call a smart contract C1, its pre-execution read set includes the balace of the external account A1 The status value v11 also includes the status value v21 of a certain contract parameter in smart contract C1. When the pre-execution process in the TEE of node n1 pre-executes transaction Tx1, for example, when the pre-execution process executes smart contract C1 through the virtual machine, it will obtain the contract parameters represented by k2 to be written. Status value v22; In addition, the virtual machine will also calculate the number of digital resources that it needs to consume for each instruction consumed by executing the aforementioned smart contract C1, and then after completing the execution of smart contract C1, it will obtain the The amount of digital resources consumed is the resource consumption information gas1 of transaction Tx1. Finally, the pre-execution process located in the TTE can also calculate the status value v12 of k1 expected to be written in the pre-execution write set based on gas1 and the status value v11 of k1 in the pre-execution read set, that is, calculate the balance status of external account A1 Value v12.
对于并非用于调用智能合约的交易而言,例如对于由外部账户A1发起的指向外部账户A3的用于实现转账功能的前述交易Tx3而言,预执行进程对交易Tx3进行预执行的过程中,可以基于交易Tx3的数据量计算交易Tx3的资源消费信息gas2。进而,位于TEE中的预执行进程可以基于gas2和Tx3实际转移的数字资源的数量计算外部账户A1的balance的状态值v13,具体例如读取外部账户A1的balance字段的当前值v12后,在v12的基础上减去gas2和外部账户A1通过交易Tx3向外部账户A2实际转移的数字资源的数量,获得外部账户A1的balance的状态值v13。For transactions that are not used to call smart contracts, for example, for the aforementioned transaction Tx3 initiated by external account A1 and directed to external account A3 to implement the transfer function, during the pre-execution process of transaction Tx3, The resource consumption information gas2 of transaction Tx3 can be calculated based on the data volume of transaction Tx3. Furthermore, the pre-execution process located in the TEE can calculate the status value v13 of the balance of the external account A1 based on the number of digital resources actually transferred by gas2 and Tx3. Specifically, for example, after reading the current value v12 of the balance field of the external account A1, in v12 On the basis of subtracting gas2 and the amount of digital resources actually transferred from external account A1 to external account A2 through transaction Tx3, the status value v13 of the balance of external account A1 is obtained.
步骤43,节点n1在其TEE中基于资源消费信息生成可信数据。可信数据是通过对资源消费信息进行加密而得到的密文,或者可信数据包括资源消费信息和对资源消费信息的签名。Step 43: Node n1 generates trusted data based on resource consumption information in its TEE. The trusted data is the ciphertext obtained by encrypting the resource consumption information, or the trusted data includes the resource consumption information and the signature of the resource consumption information.
位于TEE中的预执行进程在完成对第一交易的预执行,并且生成第一交易的可信数据后,还可以将第一交易、第一交易的预执行读写集以及可信数据返回给缓存进程以缓存到待共识的交易队列中。位于TEE中的预执行进程可以按顺序从缓存进程缓存的待处理的交易队列中依次读取交易并对其进行预执行,因而如前所述的是,缓存进程还可以基于其缓存的待处理的交易队列,对应缓存由位于TEE中的预执行进程预执行的多个交易的预执行顺序。After the pre-execution process located in the TEE completes the pre-execution of the first transaction and generates the trusted data of the first transaction, it can also return the first transaction, the pre-execution read-write set of the first transaction and the trusted data to Cache process to cache into the transaction queue waiting for consensus. The pre-execution process located in the TEE can sequentially read transactions from the pending transaction queue cached by the cache process and pre-execute them. Therefore, as mentioned above, the cache process can also perform pre-execution based on its cached pending transaction queue. The transaction queue corresponds to the cache of the pre-execution sequence of multiple transactions pre-executed by the pre-execution process located in the TEE.
步骤45,节点n1向节点n2发送可信数据以及预执行读写集。Step 45: Node n1 sends trusted data and pre-execution read and write sets to node n2.
节点n1可以在其与节点n2对由节点n1生成并发送至节点n2的共识提议进行共识的过程中向节点n2发送第一交易的可信数据和预执行读写集。例如节点n1的共识进程可以针对缓存于待共识的交易队列中的多个交易生成的共识提议,该共识提议中可以包括该多个交易各自的可信数据、该多个交易各自的预执行读写集以及该多个交易的预执行顺序/共识顺序,此外该共识提议中还可以包括该多个交易或者该多个交易各自的指示信息(例如该多个交易各自的哈希值)。其中如前所述的是前述第一交易具体可以是前述共识提议所包括或指示的多个交易中的任一交易,因而节点n2可以从来自节点n1的共识提议中对应获得前述第一交易的可信数据以及其预执行读写集。Node n1 may send the trusted data of the first transaction and the pre-execution read-write set to node n2 during its consensus with node n2 on the consensus proposal generated by node n1 and sent to node n2. For example, the consensus process of node n1 can generate a consensus proposal for multiple transactions cached in the transaction queue to be agreed upon. The consensus proposal can include the credible data of each of the multiple transactions and the pre-execution reads of each of the multiple transactions. The write set and the pre-execution order/consensus order of the multiple transactions. In addition, the consensus proposal may also include the multiple transactions or the respective indication information of the multiple transactions (such as the respective hash values of the multiple transactions). As mentioned above, the first transaction can be any one of the multiple transactions included or indicated in the consensus proposal. Therefore, node n2 can obtain the corresponding value of the first transaction from the consensus proposal from node n1. Trusted data and its pre-execution read and write sets.
当可信数据是通过对资源消费信息进行加密而得到的密文时,节点n2可以对可信数据进行解密以获得第一交易的资源消费信息,进而基于该资源消费信息执行后续步骤47。当可信数据包括资源消费信息以及节点n1在其TEE中对资源消费信息的签名时,节点n2还可以对可信数据中的签名进行验证,在签名通过验证的情况下才继续执行后续步骤47。此外需要特别说明的是,节点n2也可以具有TEE,与之相应的是节点n2可以在其TEE中对可信数据进行处理,例如在TEE中对可信数据进行解密或者对可信数据中的签名进行验证。When the trusted data is ciphertext obtained by encrypting the resource consumption information, node n2 can decrypt the trusted data to obtain the resource consumption information of the first transaction, and then perform subsequent step 47 based on the resource consumption information. When the trusted data includes resource consumption information and the signature of node n1 on the resource consumption information in its TEE, node n2 can also verify the signature in the trusted data, and only continue to perform subsequent steps 47 when the signature passes the verification. . In addition, it should be noted that node n2 can also have a TEE. Correspondingly, node n2 can process trusted data in its TEE, such as decrypting trusted data in the TEE or decrypting the trusted data in the TEE. Signature is verified.
步骤47,节点n2基于资源消费信息执行第一交易,获得执行读写集。Step 47: Node n2 executes the first transaction based on the resource consumption information and obtains the execution read-write set.
对于由节点n1发送至节点n2的共识提议所包括或指示的多个交易,节点n2例如可以通过其控制进程基于该多个交易各自的预执行读写集将该多个交易划分为M个交易分组,其中M的取值不小于节点n2运行的计算进程的数量N,而且该多个交易中的部分交易的预执行读写集还可能分别涉及与一个或多个智能合约相关的若干合约参数。与之对应的是,节点n2可以确定M个交易分组各自对应的计算进程,进而例如通过其控制进程将M个交易分组对应分发至其运行的N个计算进程;对于M个交易分组中的任意两个交易分组,如果该任意两个分组中的任意两个交易涉及相同的智能合约,例如任意两个交易分组中的任意两个交易请求调用相同的智能合约,则该任意两个交易分组需要被控制进程发送至相同的计算进程,以便节点n2的N个计算进程可以并行提交其各自在完成执行其接收的各个交易分组中的交易后获得的状态数据,从而加速对包含该多个交易的区块的生成。例如请继续参见前文示例的交易Tx1~交易Tx5的分组情况,由于交易分组1和交易分组2中的交易Tx1和交易Tx2分别涉及智 能合约C1中不同合约参数(k2和k4各自表征的合约参数),节点n2的控制进程例如可以将交易分组1和交易分组2等两个交易分组发送至节点n2的计算进程1,将交易分组3发送至计算进程2,将交易分组4发送至计算进程3,使得计算进程1~计算进程3并行执行其各自接收的交易分组中的交易,并且并行提交其各自在完成执行其接收的各个交易分组中的交易后获得的状态数据。For multiple transactions included or indicated in the consensus proposal sent by node n1 to node n2, node n2 can, for example, through its control process, divide the multiple transactions into M transactions based on their respective pre-execution read and write sets. Grouping, where the value of M is not less than the number N of computing processes running on node n2, and the pre-execution read and write sets of some of the multiple transactions may also involve several contract parameters related to one or more smart contracts. . Correspondingly, node n2 can determine the computing processes corresponding to each of the M transaction groups, and then, for example, distribute the M transaction groups to the N computing processes it runs through its control process; for any of the M transaction groups Two transaction groups, if any two transactions in any two groups involve the same smart contract, for example, any two transaction requests in any two transaction groups call the same smart contract, then any two transaction groups need The controlled process is sent to the same computing process, so that the N computing processes of node n2 can submit in parallel the status data they each obtained after completing the execution of the transactions in each transaction group they received, thereby accelerating the processing of the multiple transactions. Block generation. For example, please continue to refer to the grouping of transactions Tx1 ~ transaction Tx5 in the previous example. Since transaction Tx1 and transaction Tx2 in transaction group 1 and transaction group 2 respectively involve different contract parameters in smart contract C1 (the contract parameters represented by k2 and k4 respectively) , the control process of node n2 can, for example, send two transaction packets such as transaction group 1 and transaction group 2 to the calculation process 1 of node n2, send transaction group 3 to calculation process 2, and send transaction group 4 to calculation process 3. The calculation process 1 to the calculation process 3 are caused to execute the transactions in the transaction groups they respectively received in parallel, and to submit in parallel the status data obtained by each of them after completing the execution of the transactions in each transaction group they received.
计算进程可以串行执行其接收的各个交易分组中的交易,例如计算进程1可以通过单个工作线程依次执行其接收的交易分组1和交易分组2中的交易Tx1、交易Tx2和交易Tx3。或者计算进程可以通过多线程并发的执行其接收的各个交易分组中的交易,以便更为快速的完成执行其接收的各个交易分组中的交易;例如计算进程1可以并发的运行工作线程1和工作线程2,通过工作线程1依次执行其接收的交易分组1中的交易Tx1和交易Tx2,通过工作线程2执行其接收的交易分组2中的交易Tx3。需要特别说明的是,计算进程可通过相同的存储对象来搜集其通过执行其接收的各个交易分组中的交易以获得的状态数据;例如计算进程1可以通过相同的存储对象搜集到其执行交易Tx1~交易Tx3所获得的执行读写集,其中交易Tx1~交易Tx3的执行写集可能被作为计算进程1执行交易Tx1~交易Tx3以得到的状态数据。The computing process can serially execute the transactions in each transaction group it receives. For example, the computing process 1 can sequentially execute the transactions Tx1, transaction Tx2, and transaction Tx3 in the transaction group 1 and transaction group 2 it receives through a single worker thread. Or the computing process can concurrently execute the transactions in each transaction group it receives through multiple threads in order to complete the execution of the transactions in each transaction group it receives more quickly; for example, computing process 1 can concurrently run worker thread 1 and work Thread 2 sequentially executes the transaction Tx1 and transaction Tx2 in the transaction group 1 it receives through the working thread 1, and executes the transaction Tx3 in the transaction group 2 it receives through the working thread 2. It should be noted that the computing process can collect the status data obtained by executing the transactions in each transaction group it receives through the same storage object; for example, the computing process 1 can collect the transaction Tx1 it executes through the same storage object. ~Execution read and write sets obtained by transaction Tx3, in which the execution write sets of transactions Tx1~transaction Tx3 may be used as status data obtained by computing process 1 by executing transactions Tx1~transaction Tx3.
节点n2的任意计算进程在执行其接收的个交易分组中的任一交易(即第一交易)的过程中,无需再次计算该交易的资源消费信息,而是可以直接使用来自节点n1的该交易的资源消费信息来执行该交易,获得该交易的执行读写集,更具体地说是在执行该交易的过程中使用来自节点n1的该交易的资源消费信息生成该交易的执行写集。In the process of executing any transaction (i.e. the first transaction) in the transaction group it receives, any computing process of node n2 does not need to calculate the resource consumption information of the transaction again, but can directly use the transaction from node n1 The resource consumption information of the transaction is used to execute the transaction, and the execution read-write set of the transaction is obtained. More specifically, the resource consumption information of the transaction from node n1 is used to generate the execution write set of the transaction during the execution of the transaction.
对于请求调用智能合约的合约调用交易而言,例如对于前述示例的交易Tx1而言,节点n2的计算进程1通过其虚拟机执行交易Tx1请求调用的智能合约C1的过程中,仅需要读取k2的状态值v21并对应获得k2的状态值v22,无需计算其因执行智能合约C1而消费的每条指令各自需要消费的数字资源的数量,即无需基于因执行智能合约C1而消费的指令计算交易Tx1的资源消费信息gas1;计算进程1可以直接使用来自节点n1的资源消费信息gas1,与其读取的k1的状态值v11计算出交易Tx1的执行写集中期望写入的k1的状态值v12,即计算出外部账户A1的balance的状态值v12,进而生成包含键值对k1-v12和键值对k2-v22的执行写集。执行写集中键值对k2-v22可能被作为计算进程1执行交易Tx1以获得的智能合约C1/合约账户B1的合约状态数据,而键值对k1-v12可能被作为计算进程1执行交易Tx1以获得的世界状态数据。需要说明的是,交易Tx1的状态数据可能供计算进程1中在后执行的其它交易使用,例如在后执行的交易Tx3读取的k1的状态值应当为v12而并非v11。For a contract call transaction requesting the call of a smart contract, for example, for the transaction Tx1 in the aforementioned example, the computing process 1 of node n2 only needs to read k2 during the process of executing the smart contract C1 requested by the transaction Tx1 through its virtual machine. The state value v21 of k2 corresponds to the state value v22 of k2. There is no need to calculate the number of digital resources consumed by each instruction consumed due to the execution of smart contract C1, that is, there is no need to calculate transactions based on the instructions consumed due to the execution of smart contract C1. Resource consumption information gas1 of Tx1; calculation process 1 can directly use the resource consumption information gas1 from node n1, and calculate the status value v12 of k1 expected to be written in the execution write set of transaction Tx1 with the status value v11 of k1 read, that is Calculate the status value v12 of the balance of the external account A1, and then generate an execution write set containing the key-value pair k1-v12 and the key-value pair k2-v22. The key-value pair k2-v22 in the write set may be used as computing process 1 to execute transaction Tx1 to obtain the contract status data of smart contract C1/contract account B1, while the key-value pair k1-v12 may be used as computing process 1 to execute transaction Tx1 to obtain the contract status data of smart contract C1/contract account B1. Obtained world state data. It should be noted that the status data of transaction Tx1 may be used by other transactions executed later in the calculation process 1. For example, the status value of k1 read by transaction Tx3 executed later should be v12 instead of v11.
对于该多个计算进程中的任一计算进程而言,该计算进程中用于执行智能合约的虚拟机可以具有按照用户的需求选择是否开启计算资源消费信息的功能,如果选择开启该功能则该虚拟机在具体执行某个交易的过程中,可以基于因执行该交易而消费的指令计算该交易的资源消费信息。由于节点n2基于来自节点n1的可信数据获得第一 交易的资源消费信息,因而用于执行第一交易的计算进程可以选择关闭该功能,以便更为快速的完成对第一交易的执行。For any one of the multiple computing processes, the virtual machine used to execute the smart contract in the computing process can have the function of choosing whether to turn on computing resource consumption information according to the user's needs. If you choose to turn on this function, the During the specific execution of a transaction, the virtual machine can calculate the resource consumption information of the transaction based on the instructions consumed for executing the transaction. Since node n2 obtains the resource consumption information of the first transaction based on the trusted data from node n1, the computing process used to execute the first transaction can choose to turn off this function to complete the execution of the first transaction more quickly.
对于并非请求调用智能合约的交易而言,例如对于由外部账户A1发起的指向外部账户A3的用于实现转账的前述交易Tx3而言,节点n2的计算进程1无需基于交易Tx3的数据量计算交易Tx3的资源消费信息gas2;计算进程1可以基于读取的k1的状态值v12,以及来自节点n1的交易Tx3的资源消费信息gas2和Tx3实际转移的数字资源的数量,计算外部账户A1的balance的状态值v13,具体例如读取外部账户A1的balance字段的状态值v12后,在状态值v12的基础上减去gas2和外部账户A1通过交易Tx3向外部账户A2实际转移的数字资源的数量,获得外部账户A1的balance的状态值v13,即获得包含键值对k1-v13的执行写集,而包含键值对k1-v13的执行写集可能被作为交易Tx3的状态数据。For transactions that are not requests to call smart contracts, for example, for the aforementioned transaction Tx3 initiated by external account A1 and directed to external account A3 for transfer, the calculation process 1 of node n2 does not need to calculate the transaction based on the data volume of transaction Tx3 Resource consumption information gas2 of Tx3; calculation process 1 can calculate the balance of external account A1 based on the read status value v12 of k1, the resource consumption information gas2 of transaction Tx3 from node n1 and the number of digital resources actually transferred by Tx3 Status value v13, for example, after reading the status value v12 of the balance field of external account A1, subtract gas2 and the number of digital resources actually transferred by external account A1 to external account A2 through transaction Tx3 from the status value v12 to obtain The status value v13 of the balance of external account A1 is obtained, and the execution write set containing the key-value pair k1-v13 is obtained, and the execution write set containing the key-value pair k1-v13 may be used as the status data of transaction Tx3.
步骤49,节点n2根据执行读写集和预执行读写集验证节点n1在预执行第一交易的过程中是否作恶,如果否则将执行读写集的执行写集作为第一交易的状态数据。Step 49: Node n2 verifies whether node n1 did evil during the pre-execution of the first transaction based on the execution read-write set and the pre-execution read-write set. If not, the execution read-write set of the execution read-write set will be used as the status data of the first transaction.
节点n2的计算进程在完成执行其接收的各个交易分组中的任一交易(即第一交易)之后,可以对应获得该第一交易的执行读写集,进而还可以确定该第一交易的执行读写集与该第一交易的预执行读写集是否一致。当执行读写集与其预执行读写集一致的情况下,该计算进程可以将该第一交易的执行写集作为该第一交易的状态数据,以便在后续对该状态数据进行提交以完成对该第一交易的执行。特别需要说明的是,如果第一交易的执行读写集与其预执行读写集不一致,则说明节点n1在执行第一交的过程中可能作恶,例如在其TEE中预执行第一交易时,向TEE提供了错误的状态数据;此时可以通过相应的机制触发更换区块链系统的主节点,进而通过与前述相似的过程重新发起对包含该第一交易的前述多个交易的执行。After the computing process of node n2 completes the execution of any transaction (i.e., the first transaction) in each transaction group it receives, it can correspondingly obtain the execution read-write set of the first transaction, and further can determine the execution of the first transaction. Whether the read-write set is consistent with the pre-execution read-write set of the first transaction. When the execution read-write set is consistent with its pre-execution read-write set, the computing process can use the execution write set of the first transaction as the status data of the first transaction, so that the status data can be subsequently submitted to complete the transaction. Execution of the first transaction. It should be noted in particular that if the execution read-write set of the first transaction is inconsistent with its pre-execution read-write set, it means that node n1 may do evil during the execution of the first transaction. For example, when pre-executing the first transaction in its TEE, Wrong status data is provided to the TEE; at this time, the corresponding mechanism can be used to trigger the replacement of the master node of the blockchain system, and then the execution of the aforementioned multiple transactions including the first transaction can be reinitiated through a process similar to the above.
此外由于涉及相同的智能合约的交易由相同的计算进程执行,则N个计算进程各自获得的状态数据中不会涉及相同智能合约/合约账户的合约状态数据,因而节点n2的N个计算进程可以互不影响的并行提交其各自获得的状态数据。更具体地,如果计算进程获得的状态数据仅包括与状态树相关的世界状态数据,则其可以直接提交其获得的世界状态数据;如果计算进程获得的状态数据同时包含世界状态数据和涉及至少一个智能合约的合约状态数据,则该计算进程需要先提交其获得的至少一个智能合约的合约状态数据,例如将其获得的合约状态数据发送至存储进程,由存储进程对应更新该至少一个智能合约的合约状态树(即前述存储树),获得该至少一个智能合约各自的存储根;进而合并提交至少一个智能合约各自的存储根以及该计算进程获得的世界状态数据至存储进程,使存储进程对应更新状态树中的状态参数。In addition, since transactions involving the same smart contract are executed by the same computing process, the status data obtained by each of the N computing processes will not involve the contract status data of the same smart contract/contract account, so the N computing processes of node n2 can Submit their respective status data in parallel without affecting each other. More specifically, if the state data obtained by the calculation process only includes world state data related to the state tree, it can directly submit the world state data it obtained; if the state data obtained by the calculation process contains both world state data and involves at least one contract status data of a smart contract, the computing process needs to first submit the contract status data of at least one smart contract it has obtained, for example, send the contract status data it obtains to the storage process, and the storage process updates the at least one smart contract accordingly. The contract state tree (i.e., the aforementioned storage tree) obtains the respective storage roots of the at least one smart contract; and then merges and submits the respective storage roots of the at least one smart contract and the world state data obtained by the calculation process to the storage process, so that the storage process updates accordingly State parameters in the state tree.
节点n2的N个计算进程均完成提交其各自获得的状态数据到存储进程后,还可以由控制进程对存储进程进行调用来对其更新的状态树和各个存储树进行提交操作,获得用于生成相应区块的状态根,进而由控制进程基于该状态根和前述多个交易生成 相应区块。After the N computing processes of node n2 have completed submitting their respective obtained status data to the storage process, the control process can also call the storage process to submit the updated status tree and each storage tree to obtain the The state root of the corresponding block is then used by the control process to generate the corresponding block based on the state root and the aforementioned multiple transactions.
前述各个方法实施例中,节点n2在执行交易的过程中,无需再次计算该交易的资源消费信息,而是使用来自节点n1的该交易的资源消费信息来执行该交易,即使用来自节点n1的该交易的资源消费信息生成该交易的执行写集。当节点n2确定该交易的执行读写集和预执行读写集确定出节点n1在执行该交易的过程中没有作恶的情况下,即可将该交易的执行写集作为该交易的状态数据而完成对该交易的执行。如此,节点n2因无需再次计算交易的资源消费信息而可以更为快速的完成对交易的执行。In the foregoing method embodiments, during the process of executing a transaction, node n2 does not need to calculate the resource consumption information of the transaction again, but uses the resource consumption information of the transaction from node n1 to execute the transaction, that is, using the resource consumption information of the transaction from node n1. The resource consumption information of the transaction generates the execution write set of the transaction. When node n2 determines that the execution read-write set and the pre-execution read-write set of the transaction determine that node n1 did not do evil in the process of executing the transaction, the execution write set of the transaction can be used as the status data of the transaction. Complete execution of the transaction. In this way, node n2 can complete the execution of the transaction more quickly because it does not need to calculate the resource consumption information of the transaction again.
与前述方法实施例基于相同的构思,本说明书实施例中还提供了一种区块链系统中的第一节点,所述区块链系统中还包括第二节点。如图5所示,所述第一节点包括:预执行进程52,部署在所述第一节点的TEE中,配置为预执行第一交易,获得资源消费信息和基于所述资源消费信息生成的预执行读写集;以及配置为在所述TEE中基于所述资源消费信息生成可信数据;网络进程54,配置为向所述第二节点发送所述可信数据和所述预执行读写集。Based on the same concept as the foregoing method embodiments, the embodiments of this specification also provide a first node in a blockchain system, and the blockchain system further includes a second node. As shown in Figure 5, the first node includes: a pre-execution process 52, deployed in the TEE of the first node, configured to pre-execute the first transaction, obtain resource consumption information and generate the resource consumption information based on the resource consumption information. Pre-execution read and write set; and configured to generate trusted data based on the resource consumption information in the TEE; network process 54, configured to send the trusted data and the pre-executed read and write to the second node set.
与前述方法实施例基于相同的构思,本说明书实施例中还提供了一种区块链系统中的第二节点,所述区块链系统中还包括第一节点。如图6所示,所述第二节点包括:网络进程62,配置为从所述第一节点接收可信数据和第一交易的预执行读写集,所述可信数据由所述第一节点在其TEE中基于第一交易的资源消费信息生成,所述资源消费信息和所述预执行读写及由所述第一节点在其TEE中对所述第一交易进行预执行以获得;计算进程64,配置为基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集;以及,配置为根据所述执行读写集和所述预执行读写集确定所述第一节点在预执行所述第一交易的过程中是否作恶,如果否则将所述执行读写集的执行写集作为所述第一交易的状态数据。Based on the same concept as the foregoing method embodiments, the embodiments of this specification also provide a second node in a blockchain system, and the blockchain system further includes a first node. As shown in Figure 6, the second node includes: a network process 62 configured to receive trusted data and a pre-execution read-write set of the first transaction from the first node, the trusted data being provided by the first node. The node generates resource consumption information based on the first transaction in its TEE, and the resource consumption information and the pre-execution read and write are obtained by the first node pre-executing the first transaction in its TEE; The computing process 64 is configured to execute the first transaction based on the resource consumption information and obtain the execution read-write set of the first transaction; and, is configured to execute the read-write set based on the execution read-write set and the pre-execution read-write set. Determine whether the first node does evil in the process of pre-executing the first transaction, and if not, use the execution write set of the execution read and write set as the status data of the first transaction.
与前述方法实施例基于相同的构思,本说明书实施例中还提供了一种区块链系统,所述区块链系统包括第一节点和第二节点,所述第一节点和所述第二节点是所述区块链系统中的任意两个区块链节点。其中:所述第一节点用于在可信执行环境TEE中预执行第一交易,获得资源消费信息和基于所述资源消费信息生成的预执行读写集;在所述TEE中基于所述资源消费信息生成可信数据;并向所述第二节点发送所述可信数据和所述预执行读写集;所述第二节点用于基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集;根据所述执行读写集和所述预执行读写集确定所述第一节点在预执行所述第一交易的过程中是否作恶,如果否则将所述执行读写集的执行写集作为所述第一交易的状态数据。Based on the same concept as the foregoing method embodiments, the embodiments of this specification also provide a blockchain system. The blockchain system includes a first node and a second node. The first node and the second node Nodes are any two blockchain nodes in the blockchain system. Wherein: the first node is used to pre-execute the first transaction in the trusted execution environment TEE, obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information; in the TEE based on the resource Consumption information generates trusted data; sends the trusted data and the pre-execution read and write set to the second node; the second node is used to execute the first transaction based on the resource consumption information, and obtain The execution read-write set of the first transaction; determine whether the first node does evil during the process of pre-executing the first transaction according to the execution read-write set and the pre-execution read-write set. If not, all The execution write set of the execution read and write set is used as the status data of the first transaction.
在一种可能的实施方式中,所述第一交易用于调用智能合约;所述第一节点用于在所述TEE中基于所述第一交易执行所述智能合约,获得所述资源消费信息。In a possible implementation, the first transaction is used to call a smart contract; the first node is used to execute the smart contract based on the first transaction in the TEE to obtain the resource consumption information .
在一种可能的实施方式中,所述资源消费信息基于所述第一交易的数据量计算得到。In a possible implementation, the resource consumption information is calculated based on the data amount of the first transaction.
在一种可能的实施方式中,所述可信数据通过对所述资源消费信息进行加密而得到;所述第二节点还用于对所述可信数据进行解密以获得所述资源消费信息。In a possible implementation, the trusted data is obtained by encrypting the resource consumption information; the second node is also used to decrypt the trusted data to obtain the resource consumption information.
在一种可能的实施方式中,所述可信数据包括所述资源消费信息以及与所述资源消费信息对应的签名;所述第二节点还用于对所述签名进行验证。In a possible implementation, the trusted data includes the resource consumption information and a signature corresponding to the resource consumption information; the second node is also used to verify the signature.
在一种可能的实施方式中,所述第一交易是由所述第一节点发送至所述第二节点的共识提议所包括或指示的多个交易中的任一交易;所述第二节点还用于根据所述多个交易各自的预执行读写集将所述多个交易划分为M个交易分组,并确定M个所述交易分组各自对应的计算进程。所述第二节点具体用于通过所述计算进程基于其对应的各个交易分组中的每个交易各自的资源消费信息,执行其对应的各个交易分组中的每个交易,获得其对应的各个交易分组中的每个交易各自的执行读写集。In a possible implementation, the first transaction is any one of multiple transactions included or indicated in the consensus proposal sent by the first node to the second node; the second node It is also used to divide the multiple transactions into M transaction groups according to their respective pre-execution read and write sets, and determine the calculation processes corresponding to each of the M transaction groups. The second node is specifically configured to execute each transaction in each corresponding transaction group based on the respective resource consumption information of each transaction in each corresponding transaction group through the calculation process, and obtain each corresponding transaction. Each transaction in the group has its own set of execution reads and writes.
在一种可能的实施方式中,所述可信数据和所述预执行读写集位于所述第一节点向所述第二节点发送的共识提议中,所述共识提议中还包括所述第一交易或用于指示所述第一交易的指示信息。In a possible implementation, the trusted data and the pre-execution read-write set are located in a consensus proposal sent by the first node to the second node, and the consensus proposal also includes the third A transaction or instruction information indicating the first transaction.
虽然本说明书一个或多个实施例提供了如实施例或流程图所述的方法操作步骤,但基于常规或者无创造性的手段可以包括更多或者更少的操作步骤。实施例中列举的步骤顺序仅仅为众多步骤执行顺序中的一种方式,不代表唯一的执行顺序。在实际中的装置或终端产品执行时,可以按照实施例或者附图所示的方法顺序执行或者并行执行(例如并行处理器或者多线程处理的环境,甚至为分布式数据处理环境)。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、产品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、产品或者设备所固有的要素。在没有更多限制的情况下,并不排除在包括所述要素的过程、方法、产品或者设备中还存在另外的相同或等同要素。例如若使用到第一,第二等词语用来表示名称,而并不表示任何特定的顺序。Although one or more embodiments of this specification provide method operation steps as described in the embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-inventive means. The sequence of steps listed in the embodiment is only one way of executing the sequence of many steps, and does not represent the only execution sequence. When the actual device or terminal product is executed, it may be executed sequentially or in parallel according to the methods shown in the embodiments or figures (for example, a parallel processor or a multi-thread processing environment, or even a distributed data processing environment). The terms "comprises," "comprises" or any other variation thereof are intended to cover a non-exclusive inclusion such that a process, method, product or apparatus including a list of elements includes not only those elements but also others not expressly listed elements, or also elements inherent to the process, method, product or equipment. Without further limitation, it does not exclude the presence of additional identical or equivalent elements in a process, method, product or apparatus including the stated elements. For example, if the words "first" and "second" are used to express names, they do not indicate any specific order.
本发明是参照根据本发明实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each process and/or block in the flowchart illustrations and/or block diagrams, and combinations of processes and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device produce a use A device for realizing the functions specified in one process or multiple processes of the flowchart and/or one block or multiple blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions The device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device. Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in computer-readable media, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储、石墨烯存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information. Information may be computer-readable instructions, data structures, modules of programs, 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), and read-only memory. (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape, magnetic tape storage, graphene storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
本领域技术人员应明白,本说明书一个或多个实施例可提供为方法、系统或计算机程序产品。因此,本说明书一个或多个实施例可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书一个或多个实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。It should be understood by those skilled in the art that one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects. Furthermore, one or more embodiments of the present description may employ a computer program implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein. Product form.
本说明书一个或多个实施例可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本本说明书一个或多个实施例,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。One or more embodiments of this specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, 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 the present description may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本说明书的至少一个实施例或示例中。在本 说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。Each embodiment in this specification is described in a progressive manner. The same and similar parts between the various embodiments can be referred to each other. Each embodiment focuses on its differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For relevant details, please refer to the partial description of the method embodiment. In the description of this specification, reference to the terms "one embodiment," "some embodiments," "an example," "specific examples," or "some examples" or the like means that specific features are described in connection with the embodiment or example. , structures, materials or features are included in at least one embodiment or example of this specification. In this specification, the schematic expressions of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the specific features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine different embodiments or examples and features of different embodiments or examples described in this specification unless they are inconsistent with each other.
以上所述仅为本说明书一个或多个实施例的实施例而已,并不用于限制本本说明书一个或多个实施例。对于本领域技术人员来说,本说明书一个或多个实施例可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在权利要求范围之内。The above descriptions are only examples of one or more embodiments of this specification, and are not intended to limit one or more embodiments of this specification. For those skilled in the art, various modifications and changes may be made to one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification shall be included in the scope of the claims.

Claims (21)

  1. 一种区块链系统中的交易执行方法,所述区块链系统包括第一节点和第二节点,所述方法由所述第一节点执行,所述方法包括:A transaction execution method in a blockchain system. The blockchain system includes a first node and a second node. The method is executed by the first node. The method includes:
    在可信执行环境TEE中预执行第一交易,获得资源消费信息和基于所述资源消费信息生成的预执行读写集;Pre-execute the first transaction in the trusted execution environment TEE, and obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information;
    在所述TEE中基于所述资源消费信息生成可信数据;Generate trusted data in the TEE based on the resource consumption information;
    向所述第二节点发送所述可信数据和所述预执行读写集。Send the trusted data and the pre-execution read and write set to the second node.
  2. 根据权利要求1所述的方法,所述第一交易用于调用智能合约;所述在可信执行环境TEE中预执行第一交易,包括:在所述TEE中基于所述第一交易执行所述智能合约,获得所述资源消费信息。The method according to claim 1, the first transaction is used to call a smart contract; the pre-execution of the first transaction in a trusted execution environment TEE includes: executing the transaction based on the first transaction in the TEE. The smart contract is used to obtain the resource consumption information.
  3. 根据权利要求1所述的方法,所述资源消费信息基于所述第一交易的数据量计算得到。According to the method of claim 1, the resource consumption information is calculated based on the data volume of the first transaction.
  4. 根据权利要求1所述的方法,所述可信数据通过对所述资源消费信息进行加密而得到。According to the method of claim 1, the trusted data is obtained by encrypting the resource consumption information.
  5. 根据权利要求1所述的方法,所述可信数据包括所述资源消费信息以及与所述资源消费信息对应的签名。According to the method of claim 1, the trusted data includes the resource consumption information and a signature corresponding to the resource consumption information.
  6. 根据权利要求1-5中任一项所述的方法,所述可信数据和所述预执行读写集位于所述第一节点向所述第二节点发送的共识提议中,所述共识提议中还包括所述第一交易或用于指示所述第一交易的指示信息。According to the method according to any one of claims 1-5, the trusted data and the pre-execution read and write set are located in the consensus proposal sent by the first node to the second node, the consensus proposal also includes the first transaction or instruction information used to instruct the first transaction.
  7. 一种区块链系统中的交易执行方法,所述区块链系统包括第一节点和第二节点,所述方法由所述第一节点执行,所述方法包括:A transaction execution method in a blockchain system. The blockchain system includes a first node and a second node. The method is executed by the first node. The method includes:
    从所述第一节点接收可信数据和第一交易的预执行读写集,所述可信数据由所述第一节点在其TEE中基于第一交易的资源消费信息生成,所述资源消费信息和所述预执行读写及由所述第一节点在其TEE中对所述第一交易进行预执行以获得;Receive trusted data and a pre-execution read-write set of the first transaction from the first node. The trusted data is generated by the first node based on the resource consumption information of the first transaction in its TEE. The resource consumption The information and the pre-execution reading and writing are obtained by the first node pre-executing the first transaction in its TEE;
    基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集;Execute the first transaction based on the resource consumption information, and obtain the execution read and write set of the first transaction;
    根据所述执行读写集和所述预执行读写集确定所述第一节点在预执行所述第一交易的过程中是否作恶,如果否则将所述执行读写集的执行写集作为所述第一交易的状态数据。Determine whether the first node does evil in the process of pre-executing the first transaction according to the execution read-write set and the pre-execution read-write set. If not, use the execution read-write set of the execution read-write set as all The status data of the first transaction.
  8. 根据权利要求7所述的方法,所述资源消费信息基于所述第一交易的数据量计算得到。According to the method of claim 7, the resource consumption information is calculated based on the data volume of the first transaction.
  9. 根据权利要求7所述的方法,所述可信数据通过对所述资源消费信息进行加密而得到;所述方法还包括:对所述可信数据进行解密以获得所述资源消费信息。According to the method of claim 7, the trusted data is obtained by encrypting the resource consumption information; the method further includes: decrypting the trusted data to obtain the resource consumption information.
  10. 根据权利要求7所述的方法,所述可信数据包括所述资源消费信息以及与所述资源消费信息对应的签名;所述方法还包括:对所述签名进行验证。According to the method of claim 7, the trusted data includes the resource consumption information and a signature corresponding to the resource consumption information; the method further includes: verifying the signature.
  11. 根据权利要求7-10中任一项所述的方法,所述第一交易是来自所述第一节点 的共识提议所包括或指示的多个交易中的任一交易;所述方法还包括:根据所述多个交易各自的预执行读写集将所述多个交易划分为M个交易分组,并确定M个所述交易分组各自对应的计算进程;According to the method of any one of claims 7-10, the first transaction is any transaction among a plurality of transactions included or indicated by the consensus proposal from the first node; the method further includes: Divide the multiple transactions into M transaction groups according to their respective pre-execution read and write sets, and determine the calculation processes corresponding to each of the M transaction groups;
    所述基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集,具体包括:通过所述计算进程基于其对应的各个交易分组中的每个交易各自的资源消费信息,执行其对应的各个交易分组中的每个交易,获得其对应的各个交易分组中的每个交易各自的执行读写集。Executing the first transaction based on the resource consumption information and obtaining the execution read-write set of the first transaction specifically includes: using the calculation process to calculate the respective resources of each transaction in each corresponding transaction group. Consume the information, execute each transaction in its corresponding transaction group, and obtain the execution read-write set of each transaction in its corresponding transaction group.
  12. 根据权利要求7-10中任一项所述的方法,所述可信数据和所述预执行读写集位于所述第一节点向所述第二节点发送的共识提议中,所述共识提议中还包括所述第一交易或用于指示所述第一交易的指示信息。According to the method according to any one of claims 7-10, the trusted data and the pre-execution read-write set are located in the consensus proposal sent by the first node to the second node, the consensus proposal also includes the first transaction or instruction information used to instruct the first transaction.
  13. 一种区块链系统中的第一节点,所述区块链系统中还包括第二节点,所述第一节点包括:A first node in a blockchain system, the blockchain system also includes a second node, the first node includes:
    预执行进程,部署在所述第一节点的TEE中,配置为预执行第一交易,获得资源消费信息和基于所述资源消费信息生成的预执行读写集;以及配置为在所述TEE中基于所述资源消费信息生成可信数据;A pre-execution process, deployed in the TEE of the first node, configured to pre-execute the first transaction, obtain resource consumption information and a pre-execution read-write set generated based on the resource consumption information; and configured in the TEE Generate trusted data based on the resource consumption information;
    网络进程,配置为向所述第二节点发送所述可信数据和所述预执行读写集。A network process configured to send the trusted data and the pre-execution read-write set to the second node.
  14. 一种区块链系统中的第二节点,所述区块链系统中还包括第一节点,所述第二节点包括:A second node in a blockchain system, the blockchain system also includes a first node, and the second node includes:
    网络进程,配置为从所述第一节点接收可信数据和第一交易的预执行读写集,所述可信数据由所述第一节点在其TEE中基于第一交易的资源消费信息生成,所述资源消费信息和所述预执行读写及由所述第一节点在其TEE中对所述第一交易进行预执行以获得;A network process configured to receive trusted data and a pre-execution read-write set of the first transaction from the first node, the trusted data being generated by the first node based on the resource consumption information of the first transaction in its TEE. , the resource consumption information and the pre-execution reading and writing are obtained by the first node pre-executing the first transaction in its TEE;
    计算进程,配置为基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集;以及,配置为根据所述执行读写集和所述预执行读写集确定所述第一节点在预执行所述第一交易的过程中是否作恶,如果否则将所述执行读写集的执行写集作为所述第一交易的状态数据。a computing process configured to execute the first transaction based on the resource consumption information and obtain an execution read-write set of the first transaction; and configured to determine based on the execution read-write set and the pre-execution read-write set Whether the first node does evil in the process of pre-executing the first transaction, if not, use the execution write set of the execution read and write set as the status data of the first transaction.
  15. 一种区块链系统,包括第一节点和第二节点,其中:A blockchain system including a first node and a second node, wherein:
    所述第一节点用于在可信执行环境TEE中预执行第一交易,获得资源消费信息和基于所述资源消费信息生成的预执行读写集;在所述TEE中基于所述资源消费信息生成可信数据;并向所述第二节点发送所述可信数据和所述预执行读写集;The first node is used to pre-execute the first transaction in the trusted execution environment TEE, obtain resource consumption information and a pre-execution read and write set generated based on the resource consumption information; in the TEE based on the resource consumption information Generate trusted data; and send the trusted data and the pre-execution read-write set to the second node;
    所述第二节点用于基于所述资源消费信息执行所述第一交易,获得所述第一交易的执行读写集;根据所述执行读写集和所述预执行读写集确定所述第一节点在预执行所述第一交易的过程中是否作恶,如果否则将所述执行读写集的执行写集作为所述第一交易的状态数据。The second node is configured to execute the first transaction based on the resource consumption information and obtain the execution read-write set of the first transaction; determine the execution read-write set and the pre-execution read-write set. Whether the first node does evil in the process of pre-executing the first transaction, if not, use the execution write set of the execution read and write set as the status data of the first transaction.
  16. 根据权利要求15所述的区块链系统,所述第一交易用于调用智能合约;所述 第一节点用于在所述TEE中基于所述第一交易执行所述智能合约,获得所述资源消费信息。According to the blockchain system of claim 15, the first transaction is used to call a smart contract; the first node is used to execute the smart contract based on the first transaction in the TEE to obtain the Resource consumption information.
  17. 根据权利要求15所述的区块链系统,所述资源消费信息基于所述第一交易的数据量计算得到。According to the blockchain system of claim 15, the resource consumption information is calculated based on the data volume of the first transaction.
  18. 根据权利要求15所述的区块链系统,所述可信数据通过对所述资源消费信息进行加密而得到;所述第二节点还用于对所述可信数据进行解密以获得所述资源消费信息。According to the blockchain system of claim 15, the trusted data is obtained by encrypting the resource consumption information; the second node is also used to decrypt the trusted data to obtain the resource consumption information.
  19. 根据权利要求15所述的区块链系统,所述可信数据包括所述资源消费信息以及与所述资源消费信息对应的签名;所述第二节点还用于对所述签名进行验证。According to the blockchain system of claim 15, the trusted data includes the resource consumption information and a signature corresponding to the resource consumption information; the second node is also used to verify the signature.
  20. 根据权利要求15-19中任一项所述的区块链系统,所述第一交易是由所述第一节点发送至所述第二节点的共识提议所包括或指示的多个交易中的任一交易;所述第二节点还用于根据所述多个交易各自的预执行读写集将所述多个交易划分为M个交易分组,并确定M个所述交易分组各自对应的计算进程;According to the blockchain system of any one of claims 15-19, the first transaction is one of a plurality of transactions included or indicated in the consensus proposal sent by the first node to the second node. Any transaction; the second node is also configured to divide the multiple transactions into M transaction groups according to their respective pre-execution read and write sets, and determine the calculations corresponding to each of the M transaction groups. process;
    所述第二节点具体用于通过所述计算进程基于其对应的各个交易分组中的每个交易各自的资源消费信息,执行其对应的各个交易分组中的每个交易,获得其对应的各个交易分组中的每个交易各自的执行读写集。The second node is specifically configured to execute each transaction in each corresponding transaction group based on the respective resource consumption information of each transaction in each corresponding transaction group through the calculation process, and obtain each corresponding transaction. Each transaction in the group has its own set of execution reads and writes.
  21. 根据权利要求15-19中任一项所述的区块链系统,所述可信数据和所述预执行读写集位于所述第一节点向所述第二节点发送的共识提议中,所述共识提议中还包括所述第一交易或用于指示所述第一交易的指示信息。According to the blockchain system according to any one of claims 15-19, the trusted data and the pre-execution read and write set are located in the consensus proposal sent by the first node to the second node, so The consensus proposal also includes the first transaction or instruction information for instructing the first transaction.
PCT/CN2022/135280 2022-05-30 2022-11-30 Transaction execution method and node in blockchain system, and blockchain system WO2023231339A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210602801.X 2022-05-30
CN202210602801.XA CN114936093A (en) 2022-05-30 2022-05-30 Transaction execution method in blockchain system, node and blockchain system

Publications (1)

Publication Number Publication Date
WO2023231339A1 true WO2023231339A1 (en) 2023-12-07

Family

ID=82865735

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135280 WO2023231339A1 (en) 2022-05-30 2022-11-30 Transaction execution method and node in blockchain system, and blockchain system

Country Status (2)

Country Link
CN (1) CN114936093A (en)
WO (1) WO2023231339A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114936093A (en) * 2022-05-30 2022-08-23 蚂蚁区块链科技(上海)有限公司 Transaction execution method in blockchain system, node and blockchain system
CN117033146B (en) * 2023-10-10 2023-12-08 北京安天网络安全技术有限公司 Identification method, device, equipment and medium for appointed consensus contract execution process

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109951546A (en) * 2019-03-15 2019-06-28 百度在线网络技术(北京)有限公司 Transactions requests processing method, device, equipment and medium based on intelligent contract
CN111565204A (en) * 2020-07-16 2020-08-21 百度在线网络技术(北京)有限公司 Block chain operation method, device, equipment and storage medium
CN111770206A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for deploying intelligent contract, block chain node and storage medium
US20210232571A1 (en) * 2020-01-06 2021-07-29 Tata Consultancy Services Limited Method and system for processing transactions in a blockchain network
CN113743940A (en) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain, main node and slave node
CN113743950A (en) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 Method for performing transactions in a blockchain, blockchain node and blockchain
CN114936093A (en) * 2022-05-30 2022-08-23 蚂蚁区块链科技(上海)有限公司 Transaction execution method in blockchain system, node and blockchain system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109951546A (en) * 2019-03-15 2019-06-28 百度在线网络技术(北京)有限公司 Transactions requests processing method, device, equipment and medium based on intelligent contract
US20210232571A1 (en) * 2020-01-06 2021-07-29 Tata Consultancy Services Limited Method and system for processing transactions in a blockchain network
CN111565204A (en) * 2020-07-16 2020-08-21 百度在线网络技术(北京)有限公司 Block chain operation method, device, equipment and storage medium
CN111770206A (en) * 2020-08-31 2020-10-13 支付宝(杭州)信息技术有限公司 Method for deploying intelligent contract, block chain node and storage medium
CN113743940A (en) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain, main node and slave node
CN113743950A (en) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 Method for performing transactions in a blockchain, blockchain node and blockchain
CN114936093A (en) * 2022-05-30 2022-08-23 蚂蚁区块链科技(上海)有限公司 Transaction execution method in blockchain system, node and blockchain system

Also Published As

Publication number Publication date
CN114936093A (en) 2022-08-23

Similar Documents

Publication Publication Date Title
WO2023231339A1 (en) Transaction execution method and node in blockchain system, and blockchain system
WO2023231338A1 (en) State data submission method, node, and blockchain system
US9460185B2 (en) Storage device selection for database partition replicas
US10375167B2 (en) Low latency RDMA-based distributed storage
US9489443B1 (en) Scheduling of splits and moves of database partitions
US10706025B2 (en) Database system providing single-tenant and multi-tenant environments
US20190392047A1 (en) Multi-table partitions in a key-value database
US10152500B2 (en) Read mostly instances
US9372879B1 (en) Balanced append tree data structure
Esteves et al. Quality-of-service for consistency of data geo-replication in cloud computing
US11086841B1 (en) Streams on shared database objects
US10013449B1 (en) Validating and non-validating secondary indexes for a table in a non-relational data store
CN109948003B (en) Block chain system of isomorphic dual-mode main and auxiliary chains and block production method thereof
US11210277B2 (en) Distributing and processing streams over one or more networks for on-the-fly schema evolution
US9875270B1 (en) Locking item ranges for creating a secondary index from an online table
WO2023231336A1 (en) Method for executing transaction and blockchain node
US10635650B1 (en) Auto-partitioning secondary index for database tables
WO2023185059A1 (en) Consensus method and blockchain node
WO2019153880A1 (en) Method for downloading mirror file in cluster, node, and query server
US11132367B1 (en) Automatic creation of indexes for database tables
Fang et al. Integrating workload balancing and fault tolerance in distributed stream processing system
US9898614B1 (en) Implicit prioritization to rate-limit secondary index creation for an online table
Matri et al. Týr: blob storage meets built-in transactions
US9578120B1 (en) Messaging with key-value persistence
WO2023274409A1 (en) Method for executing transaction in blockchain system and blockchain node

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22944640

Country of ref document: EP

Kind code of ref document: A1