WO2023231336A1 - Method for executing transaction and blockchain node - Google Patents

Method for executing transaction and blockchain node Download PDF

Info

Publication number
WO2023231336A1
WO2023231336A1 PCT/CN2022/135262 CN2022135262W WO2023231336A1 WO 2023231336 A1 WO2023231336 A1 WO 2023231336A1 CN 2022135262 W CN2022135262 W CN 2022135262W WO 2023231336 A1 WO2023231336 A1 WO 2023231336A1
Authority
WO
WIPO (PCT)
Prior art keywords
execution
transactions
transaction
read
consensus
Prior art date
Application number
PCT/CN2022/135262
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 WO2023231336A1 publication Critical patent/WO2023231336A1/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/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • 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
    • 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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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/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 method and blockchain node for executing transactions in a blockchain.
  • 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 method for executing transactions in a blockchain.
  • the transaction execution speed is accelerated and the system efficiency of the blockchain is improved.
  • a first aspect of this specification provides a method for executing transactions in a blockchain.
  • the blockchain includes a first node and a second node.
  • the first node runs a first pre-execution process, a cache process and a third node.
  • a consensus process the method is executed by the first node, including:
  • the cache process sends the received multiple transactions to the first pre-execution process, and the latest world state of at least some variables in the blockchain is stored in the memory of the cache process;
  • the first pre-execution process pre-executes the multiple transactions, obtains the pre-execution read-write sets of the multiple transactions and the pre-execution sequences of the multiple transactions, and converts the pre-execution read-write sets of the multiple transactions and the pre-execution sequence is sent to the cache process, wherein the first pre-execution process receives the read request in the first transaction from the cache process when pre-executing the first transaction in the plurality of transactions.
  • the state of the variable
  • the cache process sends the pre-execution read-write sets of the multiple transactions and the pre-execution sequences of the multiple transactions to the first consensus process, and updates the pre-execution read-write set based on the multiple transactions.
  • the first consensus process generates a consensus proposal and sends the consensus proposal to the second node in the blockchain.
  • the consensus proposal includes the pre-execution read-write set of the multiple transactions and the multiple transactions.
  • the arrangement order corresponds to the pre-execution order.
  • a second aspect of this specification provides a method for executing transactions in a blockchain.
  • the blockchain includes a first node and a second node.
  • the second node runs a second consensus process and a second block management process. process and N computing processes, the method is executed by the second node, including:
  • the second consensus process receives a consensus proposal from the first node and sends the consensus proposal to the second block management process.
  • the consensus proposal includes the pre-execution read and write sets of the multiple transactions and all The arrangement order of the plurality of transactions, the arrangement order corresponding to the pre-execution order of the plurality of transactions;
  • the second block management process divides the multiple transactions into multiple transaction groups according to the pre-execution read and write set, allocates the multiple transaction groups to the N computing processes, and assigns the multiple transaction groups to the N computing processes.
  • the order of transactions is sent to the N calculation processes;
  • the N calculation processes respectively execute transactions in the transaction groups assigned to them according to the arrangement order.
  • the third aspect of this specification provides a first node in a blockchain, where a first pre-execution process, a cache process and a first consensus process run,
  • the cache process is used to send multiple received transactions to the first pre-execution process, and the latest world state of at least some variables in the blockchain is stored in the memory of the cache process;
  • the first pre-execution process is used to pre-execute the multiple transactions, obtain the pre-execution read and write sets of the multiple transactions and the pre-execution sequences of the multiple transactions, and obtain the pre-execution read and write sets of the multiple transactions.
  • the write set and the pre-execution sequence are sent to the cache process, wherein the first pre-execution process is also used to receive the first transaction from the cache process when pre-executing the first transaction in the plurality of transactions.
  • the cache process is used to send the pre-execution read-write set of the multiple transactions and the pre-execution order of the multiple transactions to the first consensus process, and update the pre-execution read-write set based on the multiple transactions.
  • the world state data currently stored in the memory of the cache process;
  • the first consensus process is used to generate a consensus proposal and send the consensus proposal to the second node in the blockchain.
  • the consensus proposal includes the pre-execution read-write set of the multiple transactions and the multiple transactions.
  • the arrangement order of transactions, the arrangement order corresponds to the pre-execution order.
  • the fourth aspect of this specification provides a second node in a blockchain, where a second consensus process, a second block management process and N calculation processes are run in the second node.
  • the second consensus process is configured to receive a consensus proposal from the first node and send the consensus proposal to the second block management process, where the consensus proposal includes a pre-execution read-write set of the multiple transactions. and the arrangement order of the plurality of transactions, the arrangement order corresponding to the pre-execution order of the plurality of transactions;
  • the second block management process is used to divide the multiple transactions into multiple transaction groups according to the pre-execution read and write set, allocate the multiple transaction groups to the N computing processes, and assign the The sequence of multiple transactions is sent to the N calculation processes;
  • the N calculation processes are used to execute transactions in the transaction groups assigned thereto respectively according to the arrangement sequence.
  • a fifth aspect of this specification provides a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed in a computer, the computer is caused to execute the method described in the first aspect or the second aspect.
  • a sixth aspect of this specification provides a computing device, including a memory and a processor.
  • the memory stores executable code.
  • the processor executes the executable code, it implements the first aspect or the second aspect. method.
  • Figure 1 shows a blockchain architecture diagram applied in the embodiment of this specification
  • Figure 2 is an architectural diagram of a blockchain node in the embodiment of this specification
  • Figure 3 is a flow chart of a method for executing transactions in the blockchain in the embodiment of this specification
  • Figure 4 is a schematic diagram of the consensus process in the PBFT consensus algorithm
  • Figure 5 is a flow chart of a method for executing transactions in the blockchain in the embodiment of this specification.
  • Figure 1 shows a blockchain architecture diagram applied in the embodiment of this specification.
  • the blockchain includes, for example, a total of 6 nodes including master node 1, slave node 2 to slave node 5.
  • the connections between nodes schematically represent P2P (Peer to Peer, point-to-point) connections.
  • P2P Peer to Peer, point-to-point
  • These nodes store the entire ledger, which stores the status of all blocks and all accounts.
  • each node in the blockchain generates the same state in the blockchain by executing the same transaction, and each node in the blockchain stores the same state database.
  • the master node 1 can be responsible for receiving transactions from the client and initiating a consensus proposal to each slave node.
  • the consensus proposal includes, for example, multiple transactions in the block to be formed (such as block B1) and the Information such as the order of multiple transactions. After the nodes in the blockchain successfully reach consensus on the consensus proposal, each node can execute the multiple transactions according to the order in the consensus proposal, thereby generating block B1.
  • FIG. 1 shows that the blockchain includes 6 nodes
  • the embodiments of this specification are not limited to this, and may include other numbers of nodes.
  • the nodes included in the blockchain can meet Byzantine Fault Tolerance (BFT) requirements.
  • BFT Byzantine Fault Tolerance
  • the mentioned Byzantine fault tolerance requirements can be understood as meaning that Byzantine nodes can exist within the blockchain, but the blockchain does not reflect Byzantine behavior externally.
  • some Byzantine fault-tolerant algorithms require the number of nodes to be greater than 3f+1, where f is the number of Byzantine nodes, such as the Practical Byzantine Fault Tolerance algorithm PBFT (Practical Byzantine Fault Tolerance).
  • Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain. Transactions usually include sending fields (From), receiving fields (To) and data fields (Data). Among them, when the transaction is a transfer transaction, the From field represents the account address that initiated the transaction (that is, initiated a transfer task to another account), the To field represents the account address that received the transaction (that is, received the transfer), and the Data field Include transfer amount.
  • the From field indicates the account address that initiated the transaction
  • the To field indicates the account address of the contract called by the exchange
  • the Data field includes the function name in the calling contract and the corresponding Data such as the incoming parameters of the function are used to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
  • Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system. Smart contracts can be defined in the form of code. Calling a smart contract in the blockchain is to initiate a transaction pointing to the smart contract address, allowing each node in the blockchain to run the smart contract code in a distributed manner. It should be noted that in addition to smart contracts that can be created by users, smart contracts can also be set by the system in the genesis block. This type of contract is generally called a creation contract. Generally, some blockchain data structures, parameters, properties and methods can be set in the genesis contract. In addition, accounts with system administrator rights can create system-level contracts or modify system-level contracts (referred to as system contracts). Among them, the system contract can be used to add data structures for different business data in the blockchain.
  • Bob sends a transaction containing information about creating a smart contract (i.e., deploying the contract) to the blockchain as shown in Figure 1.
  • the data field of the transaction includes the code of the contract to be created (such as bytecode or machine code), the to field of the transaction is empty to indicate that the transaction is used to deploy the contract.
  • the contract address "0x6f8ae93" of the contract is determined.
  • Each node adds the contract account corresponding to the contract address of the smart contract in the state database, allocates the state storage corresponding to the contract account, and stores The contract code is saved in the state storage of the contract, so the contract is created successfully.
  • each node in the blockchain can execute the transaction respectively, thereby executing the contract respectively, and update the status database based on the execution of the contract.
  • the first node in the blockchain (for example, master node 1 in Figure 1) can pre-execute multiple transactions, obtain the pre-execution read and write sets of each transaction, and communicate with other nodes through
  • the pre-execution read-write set is sent to other nodes in the blockchain (such as the slave node in Figure 1) through the consensus process between nodes.
  • Other nodes in the blockchain can group multiple transactions based on their pre-execution read and write sets, so that multiple transactions can be executed in parallel based on the grouping results.
  • the above process is usually carried out through a single process in the node, including client request processing, consensus network communication, transaction execution, data storage, etc.
  • the blockchain nodes of the process are limited by physical resources, network resources and other resources, resulting in scalability, expansibility, and throughput that cannot meet business needs.
  • the embodiments of this specification provide a solution for executing transactions in a blockchain.
  • Multiple processes provide services such as pre-execution services, caching services, consensus services, and block management services in blockchain nodes, thereby making the area Blockchain nodes have high scalability and high throughput.
  • FIG 2 is an architectural diagram of a blockchain node in the embodiment of this specification.
  • multiple processes can be run in the master node 1 and each slave node (such as the slave node 2 shown in Figure 2) in the blockchain shown in Figure 1 to provide a variety of services.
  • the master node 1 may include a cache process 12 for providing cache services, a pre-execution process 111 and a pre-execution process 112 for providing pre-execution services, a consensus process 13 for providing consensus services, The block management process 14 of the block management service, etc.
  • the pre-execution process 111 and the pre-execution process 112 are used to pre-execute the transactions received by the master node in parallel.
  • the master node 1 is not limited to including two pre-execution processes, but may include one pre-execution process or more than three pre-execution processes.
  • the master node 1 may also include an access process for providing access services, a network process for providing network services, a storage process for providing storage services, etc., which are not shown in Figure 2 .
  • the slave node 2 may include a cache process 21 for providing cache services, a consensus process 22 for providing consensus services, a block management process 23 for providing block management services, and a computing process 241 for providing transaction execution services. and calculation process 242, etc.
  • the calculation process 241 and the calculation process 242 are used to execute transactions in the consensus proposal in parallel. It can be understood that in the embodiment of this specification, the slave node 2 is not limited to including two computing processes, but may include one computing process or more than three computing processes.
  • a process is a running activity of a program with certain independent functions in an application on a data set. That is, a process is a process in a computer that is carried out by the CPU sequentially executing instructions in the application program. Each process is assigned its own memory address space when it is created, and this memory address space can only be accessed by the process itself. For example, pre-execution process 111 is allocated memory 113, pre-execution process 112 is allocated memory 114, cache process 12 is allocated memory 120, cache process 21 is allocated memory 210, calculation process 241 is allocated memory 243, calculation Process 242 is allocated memory 244.
  • the multiple processes in the master node 1 may be multiple processes in multiple computing devices (or virtual computing nodes), or may be multiple processes in a single computing device.
  • the multiple processes in each slave node may be multiple processes in multiple computing devices (or virtual computing nodes), or may be multiple processes in a single computing device.
  • the solutions provided by the embodiments of this specification are not limited to the master-slave architecture blockchain system.
  • Figure 3 is a flow chart of a method for executing transactions in a blockchain in an embodiment of this specification. This method can be executed by master node 1 in Figure 2.
  • step S301 the cache process 12 in the master node 1 sends multiple transactions to the pre-execution process 111.
  • the master node 1 may also include an access process, which can receive transactions from the user device and send the received transactions to the cache process 12. Therefore, the cache process 12 stores the transactions received from the access process into the memory 120 of the cache process 12 in a certain order.
  • the cache process 12 may store transactions in the order in which they are received, such as by storing the received transactions in order in a transaction queue stored in the memory 120 .
  • the master node 1 may also include a network process (not shown in Figure 2). After receiving multiple transactions, the cache process 12 may send the multiple transactions to the network process, so that the network process broadcasts the multiple transactions to other nodes in the blockchain.
  • the cache process 12 can regularly send a preset number of transactions in the transaction queue to the pre-execution process, so that each pre-execution process Parallel pre-execution of transactions in the transaction queue.
  • the caching process 12 can also send the order of the batch of transactions in the transaction queue to the pre-execution process, so that the pre-execution process can serially execute the batch of transactions according to the order of the batch of transactions in the transaction queue.
  • step S303 the pre-execution process 111 pre-executes multiple transactions and obtains pre-execution read and write sets for each transaction.
  • the pre-execution process 111 may first verify the signatures of each transaction, and after passing the verification, perform pre-execution of the multiple transactions.
  • the pre-execution process 111 serially executes multiple received transactions. For example, the pre-execution process 111 may serially execute multiple transactions in the order in which the multiple received transactions are arranged.
  • the memory 113 may store the first state set of the first part of variables in the blockchain, where the first part of variables includes variables defined in the blockchain account or contract.
  • the pre-execution process 111 reads or writes variables during the pre-execution transaction, it may update the locally cached first state set.
  • the pre-execution process obtains the respective pre-execution read and write sets of the multiple transactions and the pre-execution sequence of the multiple transactions.
  • the pre-execution read-write set of a transaction includes, for example, a pre-execution read set and a pre-execution write set.
  • the pre-execution read set includes key-value pairs of variables read in pre-execution of the transaction.
  • the pre-execution write set includes the transaction Key-value pairs for variables written in pre-execution.
  • the variables include, for example, external accounts in the blockchain, or variables defined in contract accounts.
  • the state database, the first state set, and the second state set store keys, values, and version numbers of the values for each variable.
  • a transaction's pre-execution read set may include keys and version numbers of variables read
  • a transaction's pre-execution write set may include keys, values, and version numbers of variables written.
  • Each time the pre-execution process 111 writes the value of a variable it increments the version number of the variable's value by 1.
  • the memory 120 of the cache process 12 stores a second state set of the second part of the variables in the blockchain.
  • the update of the second state set may refer to the description of subsequent steps in FIG. 3 .
  • each pre-execution process reads a variable during the pre-execution transaction, it first determines whether the value of the variable is included in the first state set. If not, it then determines whether the value of the variable is included in the second state set. If it is still not included, then The value of the variable is read from the state database, and the value of the read variable is stored in the first state set.
  • the multiple transactions include, for example, transaction Tx1.
  • transaction Tx1 includes a read operation on variable a and a write operation on variable b.
  • the pre-execution process 111 executes the read operation on variable a in transaction Tx1, it first determines the memory 113 of the pre-execution process 111.
  • the pre-execution of transaction Tx1 can be completed based on the value of variable a, and a pre-execution read-write set of transaction Tx1 is generated, for example, transaction Tx1
  • the pre-execution read set includes the key-value pair of variable a
  • the pre-execution write set includes the key-value pair of variable b.
  • the pre-execution process 111 updates the first state set in the memory 113 based on the write set of the transaction Tx1, and stores the value of the variable b written by the transaction Tx1 in the pre-execution in the first state set. .
  • the pre-execution process 111 may request the cache process 12 to read the value of variable a. After receiving the request, the cache process 12 determines whether the second state set in the memory 120 includes the value of variable a, and if so, sends the value of variable a to the pre-execution process 111 . After receiving the value of variable a, the pre-execution process 111 can store the value of variable a into the first state set, so that it can be used to execute other subsequent transactions that read variable a.
  • the cache process 12 notifies the pre-execution process 111, and the pre-execution process 111 reads the current value of variable a from the state database, where the state database stores the completed The world state corresponding to the block.
  • the master node 1 also includes a storage process.
  • the pre-execution process 11 can, for example, send a request to read the variable a to the storage process. After receiving the request, the storage process reads the value of the variable a in the state database and saves the variable. The value of a is returned to the pre-execution process 111.
  • the pre-execution process 111 After receiving the value of variable a from the storage process, the pre-execution process 111 similarly stores the value of variable a into the first state set.
  • the pre-execution process 111 stores the value of the variable a read from the outside of the memory 113 into the memory 113, so that when the pre-execution process 111 reads the variable a in the next execution transaction, it can directly read the variable from the local memory. The value of a, thereby increasing the speed of transaction execution.
  • the pre-execution process 111 After each transaction is executed, the pre-execution process 111 also generates a transaction receipt for each transaction.
  • step S305 the pre-execution process 111 sends the pre-execution read-write sets and pre-execution sequences of multiple transactions to the cache process 12.
  • the pre-execution process 111 After completing the pre-execution of multiple transactions as described above, the pre-execution process 111 sends the obtained pre-execution read-write sets and pre-execution sequences of the multiple transactions to the cache process 12 together. In addition, the pre-execution process 111 also sends the transaction receipt of each transaction to the cache process 12 for storage in the memory 120 .
  • step S307 the cache process 12 updates the local state based on the pre-execution read and write sets of multiple transactions.
  • the cache process 12 After the cache process 12 receives the pre-execution read-write sets and pre-execution sequences of multiple transactions, in the case where there is only one pre-execution process in the master node, since the pre-execution process reads a variable for the first time from the storage process Receive variable values for pre-execution of transactions, and serially pre-execute multiple transactions, and update the local first state set of the pre-execution process with the pre-execution of each transaction, and then update it through the pre-execution read and write sets of multiple transactions.
  • the second state set therefore, when the transaction sequence in the execution phase is set to be the same as the pre-execution sequence, the pre-execution read and write set of each transaction will be consistent with the execution read and write set.
  • the first state set updated by the set is also the latest world state in master node 1.
  • the cache process 12 can trust the pre-execution read-write sets of the multiple transactions, and can directly update the local second state set based on the pre-execution read-write sets. After the update, the second state set also becomes the latest world state in master node 1.
  • the two pre-execution processes may simultaneously execute the same variable during the process of parallel pre-execution transactions.
  • Performing a read or write operation may result in the pre-execution result of one of the transactions not being obtained based on the current latest world state in master node 1, resulting in inconsistency between the pre-execution read-write set of the transaction and the execution read-write set of the transaction.
  • the cache process 12 may sequentially detect the pre-execution read-write sets of each transaction. Specifically, for example, for transaction Tx1, the cache process 12 first determines whether the second state set includes variable a in the pre-execution read set of transaction Tx1. If not, it is similarly determined whether other variables in the pre-execution read set of transaction Tx1 are included in the second state set.
  • the second state set does not include all variables in the pre-execution read set of transaction Tx1, that is, the transaction previously submitted to the cache process 12 has not read or written the variables read by the transaction Tx1, then it can be determined that the variables of the transaction Tx1
  • the pre-execution read set does not conflict with the second state set.
  • the cache process 12 determines whether the value of variable a in the pre-execution read set is consistent with the value of variable a in the second state set. If they are consistent, it indicates that the variable read by the transaction Tx1
  • the value of a is the latest status of variable a during pre-execution.
  • the master node 1 determines that the value read for each variable in the pre-execution read set of transaction Tx1 is the latest state in the pre-execution process, it can be determined that there is no conflict between the pre-execution read set of transaction Tx1 and the second state set.
  • the second status set may be updated based on the pre-execution read and write sets of the multiple transactions.
  • the cache process 12 determines that the value of variable a in the pre-execution read set of transaction Tx1 is inconsistent with the value of variable a in the second state set, it means that the value of variable a read by transaction Tx1 is not the latest state in the pre-execution process, so , it can be determined that the pre-execution read set of transaction Tx1 conflicts with the second status set. In the event that a conflict is determined to exist, the cache process 12 may instruct the pre-execution process 111 to re-pre-execute the transaction Tx1 and other transactions pre-executed after the transaction Tx1.
  • the cache process 12 can store the pre-execution read-write sets of the multiple transactions in the memory 120, and process the multiple transactions in the transaction queue according to the pre-execution read-write sets.
  • the pre-execution sequence stores the identifiers of the multiple transactions to indicate the pre-execution sequence of the multiple transactions.
  • step S309 the cache process 12 sends the pre-execution read-write sets and pre-execution sequences of multiple transactions to the consensus process 13.
  • the consensus process 13 regularly calls the interface provided by the cache process 12 to request the cache process 12 to obtain a batch of transactions to be agreed upon for consensus.
  • the cache process 12 sends the pre-execution read and write sets of multiple transactions and the arrangement order of the multiple transactions to the consensus process 13.
  • the arrangement order is the pre-execution order of the multiple transactions.
  • the cache process 12 may send the pre-execution read-write set of each transaction in association with the hash value of each transaction.
  • the cache process 12 may also send multiple transaction data to the consensus process when the pre-execution read-write set of transactions stored in the memory 120 reaches a certain amount of data, or when the pre-execution read-write set of transactions stored in the memory 120 reaches a certain amount. Pre-execution read and write sets and their pre-execution order.
  • step S311 the consensus process 13 generates a consensus proposal and performs consensus with other nodes.
  • blockchain nodes can implement a block-granular consensus mechanism. For example, after a node (such as a unique node) generates a block, if the generated block is recognized by other nodes, the records of other nodes will be the same. block. For another example, a transaction-granularity consensus mechanism can be implemented between blockchain nodes.
  • the consensus mechanism is a mechanism for blockchain nodes to reach a consensus across the entire network on block information (or block data), which can ensure that the latest blocks are accurately added to the blockchain.
  • the current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) ) algorithm, etc.
  • the consensus success of the consensus proposal is usually determined after a preset number of nodes reach an agreement on the consensus data (ie, consensus proposal).
  • consensus proposal a preset number of nodes reach an agreement on the consensus data
  • f malicious nodes can be tolerated. That is to say, when 2f + 1 nodes among the N consensus nodes reach an agreement, the consensus can be determined to be successful.
  • FIG 4 is a schematic diagram of the consensus process in the PBFT consensus algorithm.
  • the consensus process can be divided into four stages: Request, Pre-Prepare, Prepare and Commit.
  • the user of the blockchain can send a transaction to the master node 1 through its user device as described above.
  • the master node 1 generates a consensus proposal.
  • the consensus proposal may include the pre-execution read-write set of multiple transactions received from the cache process 12 and the pre-execution of the multiple transactions.
  • Information such as order, where individual transactions in a consensus proposal can be identified by transaction hash values.
  • the consensus process 13 can send the consensus proposal generated above and the signature of the consensus proposal by the master node 1 to other consensus nodes (ie, the slave node 2 to the slave node 6) for use in generating blocks. Specifically, the consensus process 13 can send the consensus proposal and signature to the network process, and the network process sends it to other nodes.
  • the cache process 12 has broadcast each received transaction to each slave node in the form of broadcast. In this way, the consensus proposal sent by the master node 1 to each slave node does not include the transactions of each transaction. It reduces the amount of data required for consensus proposals, thereby reducing the amount of calculation required by each node to digitally sign the consensus node during the consensus process, and improving consensus efficiency.
  • each slave node in the preparation phase, can sign the consensus proposal and send it to each other node.
  • slave node 6 is a malicious node
  • the preparation phase is completed and the submission phase can be entered.
  • master node 1 receives the signatures of slave node 2-slave node 5
  • the preparation stage is determined.
  • the slave node 2 determines that the preparation phase is completed after receiving the signatures of the slave nodes 3 to 5 and the signature of the master node 1 in the preliminary phase and passing the verification.
  • each consensus node signs the consensus proposal in the submission phase and sends it to each other consensus node.
  • each consensus node can confirm that the submission phase is completed and the consensus success. For example, after master node 1 receives and verifies the signatures of the submission phase from slave node 2 to slave node 5, it determines that the submission phase is completed and the consensus is successful.
  • step S313 the consensus process 13 sends the consensus proposal to the block management process 14.
  • the consensus process 13 may send the consensus proposal to the block management process 14.
  • step S315 the block management process 14 generates and submits blocks.
  • the master node Since the master node trusts its own pre-execution without doing evil, and the pre-execution of transactions in the master node is based on the correct world state, if the master node re-executes the multiple transactions based on the world state in the state database, the obtained The execution read-write sets of the multiple transactions must be consistent with the pre-execution read-write sets of the multiple transactions. Therefore, the block management process 14 can directly regard the pre-execution read and write sets of the multiple transactions as the execution read and write sets to update the world state in the state database without re-executing the multiple transactions.
  • the block management process 14 can sequentially update the status of each account and each contract variable in the world state according to the write set and pre-execution sequence of the pre-execution read-write set of multiple transactions in the consensus proposal, and update the state tree according to the updated world state.
  • the value of each node in including the state root ((that is, the hash value of the root node of the state tree)).
  • the block management process 14 can also obtain the transaction bodies and transaction receipts of the multiple transactions from the cache process 13, and generate the transaction roots of the transaction trees of the multiple transactions (that is, the hash value of the root node of the transaction tree) and receipts respectively.
  • the receipt root of the tree that is, the hash value of the root node of the receipt tree).
  • the block management process 14 may generate a block (for example, block B1) including the plurality of transactions.
  • the block B1 may include a block body and a block header, where the block header may include a block number, transaction Root, status root, receipt root and other information, the block body can include the transaction body set and receipt set of each transaction.
  • the block management process 14 can submit the block to be stored in the block database of the master node 1 in Figure 2 .
  • block management process 14 may send the block to the storage process so that the storage process stores the block in a block database.
  • the block management process 14 can update the world state and generate and submit blocks immediately after receiving the consensus proposal from the consensus process 13. It can be understood that the block management process 14 can also update the world state and generate and submit blocks after receiving the consensus success information from the consensus process 13 .
  • Figure 5 is a flow chart of a method for executing transactions in the blockchain in the embodiment of this specification. This method can be executed by slave node 2 in Figure 2.
  • step S501 the consensus process 22 in the slave node 2 reaches consensus with other nodes in the blockchain.
  • slave node 2 can also include a receiving process and a network process (not shown in Figure 2).
  • Slave node 2 can receive transactions from user devices through the receiving process, and can receive transactions from other nodes through the network process. Transaction sent. After receiving the transaction, the receiving process and the network process send the transaction to the cache process 21, so that the cache process 21 can store the received transaction in the memory 210 in the form of a transaction queue. Similar to the master node 1, the cache process 21 can also send transactions in the transaction queue to the network process to broadcast to other nodes in the blockchain.
  • the network process in master node 1 sends the consensus proposal and the signature of master node 1 to the network processes of other nodes, so that the network process in slave node 2 can receive the consensus proposal and the signature of master node 1, and transfer the consensus
  • the proposal and the signature of master node 1 are sent to consensus process 22.
  • the consensus process 22 After receiving the consensus proposal and its signature, the consensus process 22 starts the consensus process.
  • the specific consensus process please refer to the description above with reference to Figure 4, and will not be described again here.
  • step S503 the consensus process 22 sends the consensus proposal to the block management process 23.
  • the consensus process 22 can send the consensus proposal to the block management process 23.
  • step S505 the block management process 23 groups multiple transactions according to the consensus proposal, and allocates the multiple groups to multiple computing processes.
  • the block management process 23 can group the multiple transactions according to the pre-execution read-write set in the consensus proposal, so that all transactions in each two groups will not access the same variables, so that each group can be executed in parallel, and each Multiple transactions in a group are arranged in their pre-execution order.
  • the block management process 23 may evenly distribute the multiple groups obtained by grouping to multiple computing processes. For example, in the case where the slave node 2 only includes the calculation process 241 and the calculation process 242, half of the number of components in the plurality of groups can be assigned to the calculation process 241, and the other half of the number of components can be assigned to the calculation process 242.
  • the embodiment of this specification is not limited to the grouping of multiple transactions by the block management process 23.
  • the consensus process 22 can also group multiple transactions according to the pre-execution read and write sets of multiple transactions. And send the consensus proposal and grouping results to the block management process 23.
  • step S507 the block management process 23 sends the group assigned to each process and the pre-execution read-write set of each transaction in the group to each process.
  • step S509 the calculation process executes the transaction and updates the status database.
  • the block management process 23 can assign one or more groups to the calculation process 241 .
  • the block management process 23 allocates multiple groups to the computing process 241
  • the computing process 241 can process multiple groups concurrently through multiple threads.
  • the calculation process 241 serially executes multiple transactions in a group according to the pre-execution order of the multiple transactions in the group.
  • the calculation process 241 includes a memory 243. Before starting to execute multiple groups of transactions, the calculation process 241 can determine all variables that need to be read based on the read sets of all transactions in the multiple groups. , and reads all variables in batches (for example, all at once) from the state database. After reading the states of all variables (ie, world state), process 241 can pair the values of all variables with key values. The form is stored in the third state set in the memory 243. The calculation process 241 may then execute transactions in each group based on the third set of states.
  • the calculation process 241 When the calculation process 241 performs the operation of reading variables according to the transaction, it reads the value of the variable from the third state set, and when it performs the operation of writing the variable according to the transaction, it updates the value of the variable in the third state set to the value of this write.
  • the entered value is used to generate the execution read-write set of the transaction.
  • the execution read-write set Similar to the pre-execution read-write set, the execution read-write set includes an execution read set and an execution write set.
  • the execution read set includes, for example, the key-value pairs of variables read during the transaction execution process
  • the execution write set includes, for example, the key-value pairs of variables written during the transaction execution process.
  • the calculation process 241 stores the parameters that need to be read from the state database into the local memory 243 in advance, so that the calculation process 241 can directly read the state from the memory during the execution of the transaction without the need for Reading state from storage greatly speeds up transaction execution.
  • the calculation process 241 can immediately update the state database according to the execution write set of each transaction of the group. world state without affecting the transaction execution of other groups. At the same time, the transaction execution speed is improved.
  • step S511 the block management process 23 generates and submits blocks.
  • the block management process 23 updates the values of each node in the state tree according to the updated world state, including the state root (i.e. the root of the state tree The hash value of the node)).
  • the block management process 23 can also obtain the transaction bodies and transaction receipts of multiple transactions from the cache process 21, and generate the transaction roots of the transaction trees of the multiple transactions (that is, the hash value of the root node of the transaction tree) and the receipt tree respectively.
  • the receipt root that is, the hash value of the root node of the receipt tree).
  • the block management process 23 may generate a block (for example, block B1) including the plurality of transactions.
  • the block B1 may include a block body and a block header, where the block header may include a block number, transaction Root, status root, receipt root and other information, the block body can include the transaction body set and receipt set of each transaction.
  • the block management process 23 can submit the block to be stored in the block database of the slave node 2 in FIG. 2 .
  • the advantages of the multi-process architecture can be used to further speed up the execution of transactions and improve the efficiency of the blockchain. system efficiency.
  • Embodiments of this specification also provide a first node in the blockchain, where a first pre-execution process, a cache process and a first consensus process are run, for executing the method shown in Figure 3.
  • the cache process is used to send multiple received transactions to the first pre-execution process, and the latest world state of at least some variables in the blockchain is stored in the memory of the cache process;
  • the first pre-execution process is used to pre-execute the multiple transactions, obtain the pre-execution read and write sets of the multiple transactions and the pre-execution sequences of the multiple transactions, and obtain the pre-execution read and write sets of the multiple transactions.
  • the write set and the pre-execution sequence are sent to the cache process, wherein the first pre-execution process is also used to receive the first transaction from the cache process when pre-executing the first transaction in the plurality of transactions.
  • the cache process is used to send the pre-execution read-write set of the multiple transactions and the pre-execution order of the multiple transactions to the first consensus process, and update the pre-execution read-write set based on the multiple transactions.
  • the world state data currently stored in the memory of the cache process;
  • the first consensus process is used to generate a consensus proposal and send the consensus proposal to the second node in the blockchain.
  • the consensus proposal includes the pre-execution read-write set of the multiple transactions and the multiple transactions.
  • the arrangement order of transactions, the arrangement order corresponds to the pre-execution order.
  • Embodiments of this specification also provide a second node in the blockchain.
  • the second node runs a second consensus process, a second block management process and N calculation processes for executing the method shown in Figure 5. .
  • the second consensus process is configured to receive a consensus proposal from the first node and send the consensus proposal to the second block management process, where the consensus proposal includes a pre-execution read-write set of the multiple transactions. and the arrangement order of the plurality of transactions, the arrangement order corresponding to the pre-execution order of the plurality of transactions;
  • the second block management process is used to divide the multiple transactions into multiple transaction groups according to the pre-execution read and write set, allocate the multiple transaction groups to the N computing processes, and assign the The sequence of multiple transactions is sent to the N calculation processes;
  • the N calculation processes are used to execute transactions in the transaction groups assigned thereto respectively according to the arrangement order.
  • PLD Programmable Logic Device
  • FPGA Field Programmable Gate Array
  • HDL Hardware Description Language
  • the controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers.
  • controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic.
  • the controller in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
  • the systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions.
  • a typical implementation device is a server system.
  • the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, or a personal digital assistant. , media player, navigation device, email device, game console, tablet, wearable device, or a combination of any of these devices.
  • the functions are divided into various modules and described separately.
  • the functions of each module can be implemented in the same or multiple software and/or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. .
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented.
  • the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
  • 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 method for executing a transaction in a blockchain, and a blockchain node. The method is executed by a first node, and comprises: a cache process sends a plurality of received transactions to a first pre-execution process; the first pre-execution process pre-executes the plurality of transactions to obtain a pre-execution read-write set of the plurality of transactions and a pre-execution sequence of the plurality of transactions, and sends the pre-execution read-write set and the pre-execution sequence of the plurality of transactions to the cache process; the cache process sends, to a first consensus process, the pre-execution read-write set of the plurality of transactions and the pre-execution sequence of the plurality of transactions, and updates, on the basis of the pre-execution read-write set of the plurality of transactions, the world state data currently stored in a memory of the cache process; the first consensus process generates a consensus proposal, and sends the consensus proposal to a second node.

Description

执行交易的方法和区块链节点Methods and blockchain nodes for executing transactions
本申请要求于2022年5月30日提交中国国家知识产权局、申请号为2022106027905、申请名称为“执行交易的方法和区块链节点”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on May 30, 2022, with application number 2022106027905 and the application title "Method for executing transactions and blockchain node", the entire content of which is incorporated by reference. in this application.
技术领域Technical field
本说明书实施例属于区块链技术领域,尤其涉及一种在区块链中执行交易的方法和区块链节点。The embodiments of this specification belong to the field of blockchain technology, and particularly relate to a method and blockchain node for executing transactions in a blockchain.
背景技术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 method for executing transactions in a blockchain. By using multiple processes to provide various services in the blockchain, the transaction execution speed is accelerated and the system efficiency of the blockchain is improved.
本说明书第一方面提供一种在区块链中执行交易的方法,所述区块链包括第一节点和第二节点,所述第一节点中运行有第一预执行进程、缓存进程和第一共识进程,所述方法由所述第一节点执行,包括:A first aspect of this specification provides a method for executing transactions in a blockchain. The blockchain includes a first node and a second node. The first node runs a first pre-execution process, a cache process and a third node. A consensus process, the method is executed by the first node, including:
所述缓存进程将接收的多个交易发送给所述第一预执行进程,所述缓存进程的内存中存储有区块链中至少部分变量的最新世界状态;The cache process sends the received multiple transactions to the first pre-execution process, and the latest world state of at least some variables in the blockchain is stored in the memory of the cache process;
所述第一预执行进程预执行所述多个交易,得到所述多个交易的预执行读写集和所述多个交易的预执行顺序,将所述多个交易的预执行读写集和预执行顺序发送给所述缓存进程,其中,所述第一预执行进程在预执行所述多个交易中的第一交易时,从所述缓存进程接收所述第一交易中请求读取的变量的状态;The first pre-execution process pre-executes the multiple transactions, obtains the pre-execution read-write sets of the multiple transactions and the pre-execution sequences of the multiple transactions, and converts the pre-execution read-write sets of the multiple transactions and the pre-execution sequence is sent to the cache process, wherein the first pre-execution process receives the read request in the first transaction from the cache process when pre-executing the first transaction in the plurality of transactions. The state of the variable;
所述缓存进程将所述多个交易的预执行读写集和所述多个交易的预执行顺序发送给所述第一共识进程,基于所述多个交易的预执行读写集更新所述缓存进程的内存中当前存储的世界状态数据;The cache process sends the pre-execution read-write sets of the multiple transactions and the pre-execution sequences of the multiple transactions to the first consensus process, and updates the pre-execution read-write set based on the multiple transactions. Cache the world state data currently stored in the memory of the process;
所述第一共识进程生成共识提议,将所述共识提议发送给所述区块链中的第二节点,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述预执行顺序。The first consensus process generates a consensus proposal and sends the consensus proposal to the second node in the blockchain. The consensus proposal includes the pre-execution read-write set of the multiple transactions and the multiple transactions. The arrangement order corresponds to the pre-execution order.
本说明书第二方面提供一种在区块链中执行交易的方法,所述区块链包括第一节点和第二节点,所述第二节点中运行有第二共识进程、第二区块管理进程和N个计算进程,所述方法由所述第二节点执行,包括:A second aspect of this specification provides a method for executing transactions in a blockchain. The blockchain includes a first node and a second node. The second node runs a second consensus process and a second block management process. process and N computing processes, the method is executed by the second node, including:
所述第二共识进程从所述第一节点接收共识提议,将所述共识提议发送给所述第二区块管理进程,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述多个交易的预执行顺序;The second consensus process receives a consensus proposal from the first node and sends the consensus proposal to the second block management process. The consensus proposal includes the pre-execution read and write sets of the multiple transactions and all The arrangement order of the plurality of transactions, the arrangement order corresponding to the pre-execution order of the plurality of transactions;
所述第二区块管理进程根据所述预执行读写集将所述多个交易分成多个交易组,将所 述多个交易组分配给所述N个计算进程,并将所述多个交易的排列顺序发送给所述N个计算进程;The second block management process divides the multiple transactions into multiple transaction groups according to the pre-execution read and write set, allocates the multiple transaction groups to the N computing processes, and assigns the multiple transaction groups to the N computing processes. The order of transactions is sent to the N calculation processes;
所述N个计算进程分别根据所述排列顺序执行分配给其的交易组中的交易。The N calculation processes respectively execute transactions in the transaction groups assigned to them according to the arrangement order.
本说明书第三方面提供一种区块链中的第一节点,所述第一节点中运行有第一预执行进程、缓存进程和第一共识进程,The third aspect of this specification provides a first node in a blockchain, where a first pre-execution process, a cache process and a first consensus process run,
所述缓存进程用于将接收的多个交易发送给所述第一预执行进程,所述缓存进程的内存中存储有区块链中至少部分变量的最新世界状态;The cache process is used to send multiple received transactions to the first pre-execution process, and the latest world state of at least some variables in the blockchain is stored in the memory of the cache process;
所述第一预执行进程用于预执行所述多个交易,得到所述多个交易的预执行读写集和所述多个交易的预执行顺序,将所述多个交易的预执行读写集和预执行顺序发送给所述缓存进程,其中,所述第一预执行进程还用于在预执行所述多个交易中的第一交易时,从所述缓存进程接收所述第一交易中请求读取的变量的状态;The first pre-execution process is used to pre-execute the multiple transactions, obtain the pre-execution read and write sets of the multiple transactions and the pre-execution sequences of the multiple transactions, and obtain the pre-execution read and write sets of the multiple transactions. The write set and the pre-execution sequence are sent to the cache process, wherein the first pre-execution process is also used to receive the first transaction from the cache process when pre-executing the first transaction in the plurality of transactions. The status of the variable requested to be read in the transaction;
所述缓存进程用于将所述多个交易的预执行读写集和所述多个交易的预执行顺序发送给所述第一共识进程,基于所述多个交易的预执行读写集更新所述缓存进程的内存中当前存储的世界状态数据;The cache process is used to send the pre-execution read-write set of the multiple transactions and the pre-execution order of the multiple transactions to the first consensus process, and update the pre-execution read-write set based on the multiple transactions. The world state data currently stored in the memory of the cache process;
所述第一共识进程用于生成共识提议,将所述共识提议发送给所述区块链中的第二节点,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述预执行顺序。The first consensus process is used to generate a consensus proposal and send the consensus proposal to the second node in the blockchain. The consensus proposal includes the pre-execution read-write set of the multiple transactions and the multiple transactions. The arrangement order of transactions, the arrangement order corresponds to the pre-execution order.
本说明书第四方面提供一种区块链中的第二节点,所述第二节点中运行有第二共识进程、第二区块管理进程和N个计算进程,The fourth aspect of this specification provides a second node in a blockchain, where a second consensus process, a second block management process and N calculation processes are run in the second node.
所述第二共识进程用于从所述第一节点接收共识提议,将所述共识提议发送给所述第二区块管理进程,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述多个交易的预执行顺序;The second consensus process is configured to receive a consensus proposal from the first node and send the consensus proposal to the second block management process, where the consensus proposal includes a pre-execution read-write set of the multiple transactions. and the arrangement order of the plurality of transactions, the arrangement order corresponding to the pre-execution order of the plurality of transactions;
所述第二区块管理进程用于根据所述预执行读写集将所述多个交易分成多个交易组,将所述多个交易组分配给所述N个计算进程,并将所述多个交易的排列顺序发送给所述N个计算进程;The second block management process is used to divide the multiple transactions into multiple transaction groups according to the pre-execution read and write set, allocate the multiple transaction groups to the N computing processes, and assign the The sequence of multiple transactions is sent to the N calculation processes;
所述N个计算进程用于分别根据所述排列顺序执行分配给其的交易组中的交易。The N calculation processes are used to execute transactions in the transaction groups assigned thereto respectively according to the arrangement sequence.
本说明书第五方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行第一方面或第二方面所述的方法。A fifth aspect of this specification provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method described in the first aspect or the second aspect.
本说明书第六方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现第一方面或第二方面所述的方法。A sixth aspect of this specification provides a computing device, including a memory and a processor. The memory stores executable code. When the processor executes the executable code, it implements the first aspect or the second aspect. method.
附图说明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 shows a blockchain architecture diagram applied in the embodiment of this specification;
图2为本说明书实施例中的区块链节点的架构图;Figure 2 is an architectural diagram of a blockchain node in the embodiment of this specification;
图3为本说明书实施例中的在区块链中执行交易的方法流程图;Figure 3 is a flow chart of a method for executing transactions in the blockchain in the embodiment of this specification;
图4为PBFT共识算法中的共识过程示意图;Figure 4 is a schematic diagram of the consensus process in the PBFT consensus algorithm;
图5为本说明书实施例中的在区块链中执行交易的方法流程图。Figure 5 is a flow chart of a method for executing transactions in the blockchain 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中,区块链中例如包含主节点1、从节点2~从节点5共6个节点。节点之间的连线示意性的表示P2P(Peer to Peer,点对点)连接。这些节点上都存储全量的账本,即存储全部区块和全部账户的状态。其中,区块链中的每个节点通过执行相同的交易而产生区块链中的相同的状态,区块链中的每个节点存储相同的状态数据库。所不同的是,主节点1可负责从客户端接收交易,并向各个从节点发起共识提议,该共识提议中例如包括将要成块的区块(例如区块B1)中的多个交易及该多个交易的排列顺序等信息。在区块链中的节点对共识提议共识成功之后,各个节点可根据共识提议中的排列顺序执行该多个交易,从而生成区块B1。Figure 1 shows a blockchain architecture diagram applied in the embodiment of this specification. As shown in Figure 1, the blockchain includes, for example, a total of 6 nodes including master node 1, slave node 2 to slave node 5. The connections between nodes schematically represent P2P (Peer to Peer, point-to-point) connections. These nodes store the entire ledger, which stores the status of all blocks and all accounts. Among them, each node in the blockchain generates the same state in the blockchain by executing the same transaction, and each node in the blockchain stores the same state database. The difference is that the master node 1 can be responsible for receiving transactions from the client and initiating a consensus proposal to each slave node. The consensus proposal includes, for example, multiple transactions in the block to be formed (such as block B1) and the Information such as the order of multiple transactions. After the nodes in the blockchain successfully reach consensus on the consensus proposal, each node can execute the multiple transactions according to the order in the consensus proposal, thereby generating block B1.
可以理解,图1所示的区块链仅仅是示例性的,本说明书实施例不限于应用于图1所示的区块链,例如还可以应用于非主从结构的区块链系统中。It can be understood that the blockchain shown in Figure 1 is only exemplary, and the embodiments of this specification are not limited to application to the blockchain shown in Figure 1. For example, they can also be applied to a blockchain system with a non-master-slave structure.
另外,图1中虽然示出了区块链中包括6个节点,本说明书实施例不限于此,而是可以包括其他数目的节点。具体是,区块链中包含的节点可以满足拜占庭容错(Byzantine Fault Tolerance,BFT)要求。所述的拜占庭容错要求可以理解为在区块链内部可以存在拜占庭节点,而区块链对外不体现拜占庭行为。一般的,一些拜占庭容错算法中要求节点个数大于3f+1,f为拜占庭节点个数,例如实用拜占庭容错算法PBFT(Practical Byzantine Fault Tolerance)。In addition, although FIG. 1 shows that the blockchain includes 6 nodes, the embodiments of this specification are not limited to this, and may include other numbers of nodes. Specifically, the nodes included in the blockchain can meet Byzantine Fault Tolerance (BFT) requirements. The mentioned Byzantine fault tolerance requirements can be understood as meaning that Byzantine nodes can exist within the blockchain, but the blockchain does not reflect Byzantine behavior externally. Generally, some Byzantine fault-tolerant algorithms require the number of nodes to be greater than 3f+1, where f is the number of Byzantine nodes, such as the Practical Byzantine Fault Tolerance algorithm PBFT (Practical Byzantine Fault Tolerance).
区块链领域中的交易可以指在区块链中执行并记录在区块链中的任务单元。交易中通常包括发送字段(From)、接收字段(To)和数据字段(Data)。其中,在交易为转账交易的情况中,From字段表示发起该交易(即发起对另一个账户的转账任务)的账户地址,To字段表示接收该交易(即接收转账)的账户地址,Data字段中包括转账金额。在交易调用区块链中的智能合约的情况中,From字段表示发起该交易的账户地址,To字段表示交易所调用的合约的账户地址,Data字段中包括调用合约中的函数名、及对该函数的传入参数等数据,以用于在交易执行时从区块链中获取该函数的代码并执行该函数的代码。Transactions in the blockchain field can refer to task units that are executed and recorded in the blockchain. Transactions usually include sending fields (From), receiving fields (To) and data fields (Data). Among them, when the transaction is a transfer transaction, the From field represents the account address that initiated the transaction (that is, initiated a transfer task to another account), the To field represents the account address that received the transaction (that is, received the transfer), and the Data field Include transfer amount. In the case of a transaction calling a smart contract in the blockchain, the From field indicates the account address that initiated the transaction, the To field indicates the account address of the contract called by the exchange, and the Data field includes the function name in the calling contract and the corresponding Data such as the incoming parameters of the function are used to obtain the code of the function from the blockchain and execute the code of the function when the transaction is executed.
区块链中可提供智能合约的功能。区块链上的智能合约是在区块链系统上可以被交易触发执行的合约。智能合约可以通过代码的形式定义。在区块链中调用智能合约,是发起一笔指向智能合约地址的交易,使得区块链中每个节点分布式地运行智能合约代码。需要说明的是,除了可以由用户创建智能合约,也可以在创世块中由系统设置智能合约。这类合约一般称为创世合约。一般的,创世合约中可以设置一些区块链的数据结构、参数、属性和方法。此外,具有系统管理员权限的账户可以创建系统级的合约,或者修改系统级的合约(简称为系统合约)。其中,所述系统合约可用于在区块链中增加不同业务的数据的数据结构。The functions of smart contracts can be provided in the blockchain. Smart contracts on the blockchain are contracts that can be triggered and executed by transactions on the blockchain system. Smart contracts can be defined in the form of code. Calling a smart contract in the blockchain is to initiate a transaction pointing to the smart contract address, allowing each node in the blockchain to run the smart contract code in a distributed manner. It should be noted that in addition to smart contracts that can be created by users, smart contracts can also be set by the system in the genesis block. This type of contract is generally called a creation contract. Generally, some blockchain data structures, parameters, properties and methods can be set in the genesis contract. In addition, accounts with system administrator rights can create system-level contracts or modify system-level contracts (referred to as system contracts). Among them, the system contract can be used to add data structures for different business data in the blockchain.
在部署合约的场景中,例如,Bob将一个包含创建智能合约信息(即部署合约)的交易发送到如图1所示的区块链中,该交易的data字段包括待创建的合约的代码(如字节码或者机器码),交易的to字段为空,以表示该交易用于部署合约。节点间通过共识机制达成一致后,确定合约的合约地址“0x6f8ae93…”,各个节点在状态数据库中添加与该智能合约的合约地址对应的合约账户,分配与该合约账户对应的状态存储,并将合约代 码保存在该合约的状态存储中,从而合约创建成功。In the scenario of deploying a contract, for example, Bob sends a transaction containing information about creating a smart contract (i.e., deploying the contract) to the blockchain as shown in Figure 1. The data field of the transaction includes the code of the contract to be created ( Such as bytecode or machine code), the to field of the transaction is empty to indicate that the transaction is used to deploy the contract. After the nodes reach an agreement through the consensus mechanism, the contract address "0x6f8ae93..." of the contract is determined. Each node adds the contract account corresponding to the contract address of the smart contract in the state database, allocates the state storage corresponding to the contract account, and stores The contract code is saved in the state storage of the contract, so the contract is created successfully.
在调用合约的场景中,例如,Bob将一个用于调用智能合约的交易发送到如图1所示的区块链中,该交易的from字段是交易发起方(即Bob)的账户的地址,to字段中的“0x6f8ae93…”代表了被调用的智能合约的地址,交易的data字段包括调用智能合约的方法和参数。在区块链中对该交易进行共识之后,区块链中的各个节点可分别执行该交易,从而分别执行该合约,基于该合约的执行更新状态数据库。In the scenario of calling a contract, for example, Bob sends a transaction for calling a smart contract to the blockchain as shown in Figure 1. The from field of the transaction is the address of the account of the transaction initiator (Bob). "0x6f8ae93..." in the to field represents the address of the smart contract being called, and the data field of the transaction includes the method and parameters for calling the smart contract. After consensus is reached on the transaction in the blockchain, each node in the blockchain can execute the transaction respectively, thereby executing the contract respectively, and update the status database based on the execution of the contract.
在相关技术中,为了提高区块链中的每秒执行交易(TPS)指标,需要加快交易的执行速度。为此,区块链节点中可通过并行执行交易来加快交易的执行速度。通常,对于转账交易,区块链节点首先根据交易访问的账户将多个交易划分为多个交易组,各个交易组之间不访问相同的账户,从而可并行执行各个交易组。然而,当交易中调用智能合约时,在执行该交易之前不能预知该交易中访问的变量,从而无法对多个交易进行有效的分组,也就无法并行执行交易。在一种实施方式中,可由区块链中的第一节点(例如图1中的主节点1)对多个交易进行预执行,得到各个交易的预执行读写集,并通过与其他节点之间的共识过程将该预执行读写集发送给区块链中的其他节点(例如图1中的从节点)。区块链中的其他节点可根据多个交易的预执行读写集对多个交易进行分组,从而可根据分组结果并行执行该多个交易。In related technologies, in order to improve the transactions per second (TPS) indicator in the blockchain, it is necessary to speed up the execution of transactions. To this end, transactions can be executed faster in blockchain nodes by executing them in parallel. Usually, for transfer transactions, the blockchain node first divides multiple transactions into multiple transaction groups according to the accounts accessed by the transactions. Each transaction group does not access the same account, so that each transaction group can be executed in parallel. However, when a smart contract is called in a transaction, the variables accessed in the transaction cannot be predicted before the transaction is executed, so multiple transactions cannot be effectively grouped, and transactions cannot be executed in parallel. In one implementation, the first node in the blockchain (for example, master node 1 in Figure 1) can pre-execute multiple transactions, obtain the pre-execution read and write sets of each transaction, and communicate with other nodes through The pre-execution read-write set is sent to other nodes in the blockchain (such as the slave node in Figure 1) through the consensus process between nodes. Other nodes in the blockchain can group multiple transactions based on their pre-execution read and write sets, so that multiple transactions can be executed in parallel based on the grouping results.
然而,在目前的区块链中,节点中通常通过单个进程进行上述过程,包括客户端请求的处理、共识网络通信、交易执行、数据存储等,随着区块链业务的不断发展,运行单进程的区块链节点受到物理资源、网络资源等资源的限制,从而导致可伸缩性、可扩展性、吞吐量不能符合业务的需求。However, in the current blockchain, the above process is usually carried out through a single process in the node, including client request processing, consensus network communication, transaction execution, data storage, etc. With the continuous development of blockchain business, running single processes The blockchain nodes of the process are limited by physical resources, network resources and other resources, resulting in scalability, expansibility, and throughput that cannot meet business needs.
本说明书实施例提供一种在区块链中执行交易的方案,通过由多个进程分别提供区块链节点中的预执行服务、缓存服务、共识服务、区块管理服务等服务,从而使得区块链节点具有高可伸缩性、高吞吐量。The embodiments of this specification provide a solution for executing transactions in a blockchain. Multiple processes provide services such as pre-execution services, caching services, consensus services, and block management services in blockchain nodes, thereby making the area Blockchain nodes have high scalability and high throughput.
图2为本说明书实施例中的区块链节点的架构图。如图2所示,图1所示区块链中的主节点1和各个从节点(例如图2中示出的从节点2)中均可运行多个进程以提供多种服务。具体是,主节点1中可包括用于提供缓存服务的缓存进程12、用于提供预执行服务的预执行进程111和预执行进程112、用于提供共识服务的共识进程13、用于提供区块管理服务的区块管理进程14等。所述预执行进程111和预执行进程112用于并行进行对主节点接收的交易的预执行。可以理解,本说明书实施例中,主节点1中不限于包括两个预执行进程,而是可包括一个预执行进程或者三个以上的预执行进程。此外,主节点1中还可以包括用于提供接入服务的接入进程、用于提供网络服务的网络进程、用于提供存储服务的存储进程等,图2中未示出。Figure 2 is an architectural diagram of a blockchain node in the embodiment of this specification. As shown in Figure 2, multiple processes can be run in the master node 1 and each slave node (such as the slave node 2 shown in Figure 2) in the blockchain shown in Figure 1 to provide a variety of services. Specifically, the master node 1 may include a cache process 12 for providing cache services, a pre-execution process 111 and a pre-execution process 112 for providing pre-execution services, a consensus process 13 for providing consensus services, The block management process 14 of the block management service, etc. The pre-execution process 111 and the pre-execution process 112 are used to pre-execute the transactions received by the master node in parallel. It can be understood that in the embodiment of this specification, the master node 1 is not limited to including two pre-execution processes, but may include one pre-execution process or more than three pre-execution processes. In addition, the master node 1 may also include an access process for providing access services, a network process for providing network services, a storage process for providing storage services, etc., which are not shown in Figure 2 .
从节点2中可包括用于提供缓存服务的缓存进程21、用于提供共识服务的共识进程22、用于提供区块管理服务的区块管理进程23、用于提供交易执行服务的计算进程241和计算进程242等。所述计算进程241和计算进程242用于并行进行对共识提议中的交易的执行。可以理解,本说明书实施例中,从节点2中不限于包括两个计算进程,而是可包括一个计算进程或者三个以上的计算进程。The slave node 2 may include a cache process 21 for providing cache services, a consensus process 22 for providing consensus services, a block management process 23 for providing block management services, and a computing process 241 for providing transaction execution services. and calculation process 242, etc. The calculation process 241 and the calculation process 242 are used to execute transactions in the consensus proposal in parallel. It can be understood that in the embodiment of this specification, the slave node 2 is not limited to including two computing processes, but may include one computing process or more than three computing processes.
其中进程是应用中具有一定独立功能的程序关于一个数据集合的一次运行活动,即进程是计算机中通过由CPU顺序执行应用程序中的指令而进行的一个过程。每个进程在创 建时被分配自己的内存地址空间,该内存地址空间只能被进程自身访问。例如,预执行进程111被分配了内存113,预执行进程112被分配了内存114,缓存进程12被分配了内存120,缓存进程21被分配了内存210,计算进程241被分配了内存243,计算进程242被分配了内存244。A process is a running activity of a program with certain independent functions in an application on a data set. That is, a process is a process in a computer that is carried out by the CPU sequentially executing instructions in the application program. Each process is assigned its own memory address space when it is created, and this memory address space can only be accessed by the process itself. For example, pre-execution process 111 is allocated memory 113, pre-execution process 112 is allocated memory 114, cache process 12 is allocated memory 120, cache process 21 is allocated memory 210, calculation process 241 is allocated memory 243, calculation Process 242 is allocated memory 244.
其中,主节点1中的多个进程可以为多个计算设备(或虚拟计算节点)中的多个进程,也可以为单个计算设备中的多个进程。类似地,各个从节点中的多个进程可以为多个计算设备(或虚拟计算节点)中的多个进程,也可以为单个计算设备中的多个进程。此外需要说明的是本说明书实施例提供的方案并不局限于主从架构的区块链系统。The multiple processes in the master node 1 may be multiple processes in multiple computing devices (or virtual computing nodes), or may be multiple processes in a single computing device. Similarly, the multiple processes in each slave node may be multiple processes in multiple computing devices (or virtual computing nodes), or may be multiple processes in a single computing device. 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.
图3为本说明书实施例中的在区块链中执行交易的方法流程图。该方法可由图2中的主节点1执行。Figure 3 is a flow chart of a method for executing transactions in a blockchain in an embodiment of this specification. This method can be executed by master node 1 in Figure 2.
如图3所示,首先,在步骤S301,主节点1中的缓存进程12向预执行进程111发送多个交易。As shown in Figure 3, first, in step S301, the cache process 12 in the master node 1 sends multiple transactions to the pre-execution process 111.
如上文所示,主节点1中除了包括图2中所示的各个进程以外,还可以包括接入进程,该接入进程可从用户设备接收交易,并将接收的交易发送给缓存进程12,从而缓存进程12将从接入进程接收的交易按一定的顺序存储到缓存进程12的内存120中。例如,缓存进程12可按照接收交易的时间顺序存储交易,例如将接收的交易顺序存储到内存120中存储的交易队列中。As shown above, in addition to the various processes shown in Figure 2, the master node 1 may also include an access process, which can receive transactions from the user device and send the received transactions to the cache process 12. Therefore, the cache process 12 stores the transactions received from the access process into the memory 120 of the cache process 12 in a certain order. For example, the cache process 12 may store transactions in the order in which they are received, such as by storing the received transactions in order in a transaction queue stored in the memory 120 .
主节点1中还可以包括网络进程(图2中未示出),缓存进程12在接收到多个交易之后,可将该多个交易发送给网络进程,从而网络进程将该多个交易广播给区块链中的其他节点。The master node 1 may also include a network process (not shown in Figure 2). After receiving multiple transactions, the cache process 12 may send the multiple transactions to the network process, so that the network process broadcasts the multiple transactions to other nodes in the blockchain.
同时,对于每个预执行进程(包括预执行进程111和预执行进程112),缓存进程12可定期将交易队列中的预设数目的一批交易发送给该预执行进程,以使得各个预执行并行预执行交易队列中的交易。其中,缓存进程12可以将该批交易在交易队列中的排列顺序也发送给预执行进程,从而预执行进程可根据该交易队列中的排列顺序串行执行该批交易。At the same time, for each pre-execution process (including pre-execution process 111 and pre-execution process 112), the cache process 12 can regularly send a preset number of transactions in the transaction queue to the pre-execution process, so that each pre-execution process Parallel pre-execution of transactions in the transaction queue. The caching process 12 can also send the order of the batch of transactions in the transaction queue to the pre-execution process, so that the pre-execution process can serially execute the batch of transactions according to the order of the batch of transactions in the transaction queue.
在步骤S303,预执行进程111预执行多个交易,得到各个交易的预执行读写集。In step S303, the pre-execution process 111 pre-executes multiple transactions and obtains pre-execution read and write sets for each transaction.
预执行进程111在从缓存进程12接收到多个交易之后,可首先对各个交易的签名进行验证,在验证通过之后,进行对所述多个交易的预执行。预执行进程111串行执行接收到的多个交易,例如,预执行进程111可按照接收到的多个交易的排列顺序串行执行多个交易。After receiving multiple transactions from the cache process 12, the pre-execution process 111 may first verify the signatures of each transaction, and after passing the verification, perform pre-execution of the multiple transactions. The pre-execution process 111 serially executes multiple received transactions. For example, the pre-execution process 111 may serially execute multiple transactions in the order in which the multiple received transactions are arranged.
在本说明书实施例中,内存113中可存储区块链中的第一部分变量的第一状态集,该第一部分变量包括区块链账户或者合约中定义的变量。预执行进程111在预执行交易的过程中读取或写入变量时,可更新本地缓存的第一状态集。预执行进程在预执行多个交易之后,得到多个交易各自的预执行读写集和多个交易的预执行顺序。交易的预执行读写集中例如包括预执行读集和预执行写集,所述预执行读集包括该交易在预执行中读取的变量的键值对,所述预执行写集包括该交易在预执行中写入的变量的键值对。所述变量例如包括区块链中的外部账户、或者为合约账户中定义的变量。在一种实施方式中,状态数据库、第一状态集和第二状态集中存储各个变量的键、值和值的版本号。从而,交易的预执行读集中可包括读取的变量的键和版本号,交易的预执行写集中可包括写入的变量的键、值、 和值的版本号。预执行进程111在每次写入一个变量的值时,将该变量的值的版本号加1。In the embodiment of this specification, the memory 113 may store the first state set of the first part of variables in the blockchain, where the first part of variables includes variables defined in the blockchain account or contract. When the pre-execution process 111 reads or writes variables during the pre-execution transaction, it may update the locally cached first state set. After pre-executing multiple transactions, the pre-execution process obtains the respective pre-execution read and write sets of the multiple transactions and the pre-execution sequence of the multiple transactions. The pre-execution read-write set of a transaction includes, for example, a pre-execution read set and a pre-execution write set. The pre-execution read set includes key-value pairs of variables read in pre-execution of the transaction. The pre-execution write set includes the transaction Key-value pairs for variables written in pre-execution. The variables include, for example, external accounts in the blockchain, or variables defined in contract accounts. In one implementation, the state database, the first state set, and the second state set store keys, values, and version numbers of the values for each variable. Thus, a transaction's pre-execution read set may include keys and version numbers of variables read, and a transaction's pre-execution write set may include keys, values, and version numbers of variables written. Each time the pre-execution process 111 writes the value of a variable, it increments the version number of the variable's value by 1.
缓存进程12的内存120中存储有区块链中的第二部分变量的第二状态集,该第二状态集的更新可参考图3中后续步骤的描述。各个预执行进程在预执行交易的过程中读取变量时,首先确定第一状态集中是否包括该变量的值,如果没有,再确定第二状态集中是否包括该变量的值,如果还是没有,则从状态数据库读取该变量的值,并将该读取的变量的值存储到第一状态集中。The memory 120 of the cache process 12 stores a second state set of the second part of the variables in the blockchain. The update of the second state set may refer to the description of subsequent steps in FIG. 3 . When each pre-execution process reads a variable during the pre-execution transaction, it first determines whether the value of the variable is included in the first state set. If not, it then determines whether the value of the variable is included in the second state set. If it is still not included, then The value of the variable is read from the state database, and the value of the read variable is stored in the first state set.
具体是,该多个交易中例如包括交易Tx1。假设交易Tx1中包括对变量a的读取操作,对变量b的写入操作,预执行进程111在执行交易Tx1中的对变量a的读取操作时,首先确定预执行进程111的内存113中是否存储了变量a的值,在内存113中存储变量a的值的情况中,可以基于该变量a的值完成对交易Tx1的预执行,生成交易Tx1的预执行读写集,例如,交易Tx1的预执行读集中包括变量a的键值对,预执行写集中包括变量b的键值对。在生成交易Tx1的预执行读写集中,预执行进程111基于交易Tx1的写集更新内存113中的第一状态集,在第一状态集中存储交易Tx1在预执行中写入的变量b的值。Specifically, the multiple transactions include, for example, transaction Tx1. Assume that transaction Tx1 includes a read operation on variable a and a write operation on variable b. When the pre-execution process 111 executes the read operation on variable a in transaction Tx1, it first determines the memory 113 of the pre-execution process 111. Whether the value of variable a is stored, in the case where the value of variable a is stored in the memory 113, the pre-execution of transaction Tx1 can be completed based on the value of variable a, and a pre-execution read-write set of transaction Tx1 is generated, for example, transaction Tx1 The pre-execution read set includes the key-value pair of variable a, and the pre-execution write set includes the key-value pair of variable b. In the pre-execution read-write set that generates the transaction Tx1, the pre-execution process 111 updates the first state set in the memory 113 based on the write set of the transaction Tx1, and stores the value of the variable b written by the transaction Tx1 in the pre-execution in the first state set. .
在另一种情况中,预执行进程111在确定内存113中的第一状态集中不包括变量a的值的情况中,可向缓存进程12请求读取变量a的值。缓存进程12在接收到该请求之后,确定内存120中的第二状态集中是否包括变量a的值,如果包括,则将该变量a的值发送给预执行进程111。预执行进程111可在接收到变量a的值之后,将该变量a的值存储到第一状态集中,从而可用于执行后续的读取变量a的其他交易。如果第二状态集中不包括变量a的值,则缓存进程12通知预执行进程111,预执行进程111从而从状态数据库中读取当前变量a的值,其中,状态数据库中存储有已执行完成的区块对应的世界状态。主节点1中例如还包括存储进程,预执行进程11例如可向存储进程发送读取变量a的请求,存储进程在接收到该请求之后,在状态数据库中读取变量a的值,并将变量a的值返回给预执行进程111。预执行进程111在从存储进程接收到变量a的值之后,类似地,将变量a的值存储到第一状态集中。预执行进程111通过将从内存113的外部读取的变量a的值存储到内存113中,使得预执行进程111在下次执行交易中读取变量a时,可直接从本地内存中读取到变量a的值,从而提高了交易执行速度。In another case, when the pre-execution process 111 determines that the first state set in the memory 113 does not include the value of variable a, it may request the cache process 12 to read the value of variable a. After receiving the request, the cache process 12 determines whether the second state set in the memory 120 includes the value of variable a, and if so, sends the value of variable a to the pre-execution process 111 . After receiving the value of variable a, the pre-execution process 111 can store the value of variable a into the first state set, so that it can be used to execute other subsequent transactions that read variable a. If the second state set does not include the value of variable a, the cache process 12 notifies the pre-execution process 111, and the pre-execution process 111 reads the current value of variable a from the state database, where the state database stores the completed The world state corresponding to the block. For example, the master node 1 also includes a storage process. The pre-execution process 11 can, for example, send a request to read the variable a to the storage process. After receiving the request, the storage process reads the value of the variable a in the state database and saves the variable. The value of a is returned to the pre-execution process 111. After receiving the value of variable a from the storage process, the pre-execution process 111 similarly stores the value of variable a into the first state set. The pre-execution process 111 stores the value of the variable a read from the outside of the memory 113 into the memory 113, so that when the pre-execution process 111 reads the variable a in the next execution transaction, it can directly read the variable from the local memory. The value of a, thereby increasing the speed of transaction execution.
预执行进程111在执行完成每个交易之后,还生成各个交易的交易收据。After each transaction is executed, the pre-execution process 111 also generates a transaction receipt for each transaction.
在步骤S305,预执行进程111将多个交易的预执行读写集和预执行顺序发送给缓存进程12。In step S305, the pre-execution process 111 sends the pre-execution read-write sets and pre-execution sequences of multiple transactions to the cache process 12.
预执行进程111在如上所述完成对多个交易的预执行之后,将得到的多个交易的预执行读写集和预执行顺序一起发送给缓存进程12。另外,预执行进程111还将各个交易的交易收据发送给缓存进程12,以存储到内存120中。After completing the pre-execution of multiple transactions as described above, the pre-execution process 111 sends the obtained pre-execution read-write sets and pre-execution sequences of the multiple transactions to the cache process 12 together. In addition, the pre-execution process 111 also sends the transaction receipt of each transaction to the cache process 12 for storage in the memory 120 .
在步骤S307,缓存进程12基于多个交易的预执行读写集更新本地状态。In step S307, the cache process 12 updates the local state based on the pre-execution read and write sets of multiple transactions.
缓存进程12在接收到多个交易的预执行读写集和预执行顺序之后,在主节点中只有一个预执行进程的情况中,由于预执行进程在首次读取一个变量时都是从存储进程接收变量值进行交易的预执行,并串行预执行多个交易,并随着各个交易的预执行更新预执行进程本地的第一状态集,再通过多个交易的预执行读写集来更新第二状态集,因此,在将执行阶段的交易排列顺序设定为与该预执行顺序相同时,将使得各个交易的预执行读写集与执行读写集一致,因此,基于预执行读写集更新的第一状态集也即为主节点1中的最新世 界状态。缓存进程12可信任该多个交易的预执行读写集,并可直接基于该预执行读写集更新本地的第二状态集。在更新之后,第二状态集也成为主节点1中的最新世界状态。After the cache process 12 receives the pre-execution read-write sets and pre-execution sequences of multiple transactions, in the case where there is only one pre-execution process in the master node, since the pre-execution process reads a variable for the first time from the storage process Receive variable values for pre-execution of transactions, and serially pre-execute multiple transactions, and update the local first state set of the pre-execution process with the pre-execution of each transaction, and then update it through the pre-execution read and write sets of multiple transactions. The second state set, therefore, when the transaction sequence in the execution phase is set to be the same as the pre-execution sequence, the pre-execution read and write set of each transaction will be consistent with the execution read and write set. Therefore, based on the pre-execution read and write The first state set updated by the set is also the latest world state in master node 1. The cache process 12 can trust the pre-execution read-write sets of the multiple transactions, and can directly update the local second state set based on the pre-execution read-write sets. After the update, the second state set also becomes the latest world state in master node 1.
在主节点中有多个预执行进程(例如图2中的预执行进程111和预执行进程112)的情况中,两个预执行进程在并行预执行交易的过程中有可能同时对相同的变量进行读或写操作,从而可能导致其中一个交易的预执行结果不是基于主节点1中当前最新世界状态得到的,从而导致交易的预执行读写集与交易的执行读写集的不一致。In the case where there are multiple pre-execution processes in the master node (such as the pre-execution process 111 and the pre-execution process 112 in Figure 2), the two pre-execution processes may simultaneously execute the same variable during the process of parallel pre-execution transactions. Performing a read or write operation may result in the pre-execution result of one of the transactions not being obtained based on the current latest world state in master node 1, resulting in inconsistency between the pre-execution read-write set of the transaction and the execution read-write set of the transaction.
为此,缓存进程12在从预执行进程111接收到多个交易的预执行读写集之后,可顺序对每个交易的预执行读写集进行检测。具体是,例如对于交易Tx1,缓存进程12首先确定第二状态集中是否包括交易Tx1的预执行读集中的变量a。如果没有,再类似地确定第二状态集中是否包括交易Tx1的预执行读集中的其他变量。如果第二状态集中不包括交易Tx1的预执行读集中的全部变量,也就是说,之前提交到缓存进程12的交易还未对该交易Tx1读取的变量进行读写,则可确定交易Tx1的预执行读集与第二状态集没有冲突。To this end, after receiving the pre-execution read-write sets of multiple transactions from the pre-execution process 111, the cache process 12 may sequentially detect the pre-execution read-write sets of each transaction. Specifically, for example, for transaction Tx1, the cache process 12 first determines whether the second state set includes variable a in the pre-execution read set of transaction Tx1. If not, it is similarly determined whether other variables in the pre-execution read set of transaction Tx1 are included in the second state set. If the second state set does not include all variables in the pre-execution read set of transaction Tx1, that is, the transaction previously submitted to the cache process 12 has not read or written the variables read by the transaction Tx1, then it can be determined that the variables of the transaction Tx1 The pre-execution read set does not conflict with the second state set.
如果缓存进程12确定第二状态集中包括变量a的值,则确定预执行读集中的变量a的值与第二状态集中的变量a的值是否一致,如果一致,说明该交易Tx1读取的变量a的值为预执行过程中变量a的最新状态。当主节点1对于交易Tx1预执行读集中的每个变量都确定所读取的值为预执行过程中的最新状态之后,可确定该交易Tx1的预执行读集与第二状态集不存在冲突。在顺序确定多个交易的预执行读集与第二状态集都不存在冲突的情况中,可基于该多个交易的预执行读写集更新第二状态集。If the cache process 12 determines that the second state set includes the value of variable a, it determines whether the value of variable a in the pre-execution read set is consistent with the value of variable a in the second state set. If they are consistent, it indicates that the variable read by the transaction Tx1 The value of a is the latest status of variable a during pre-execution. When the master node 1 determines that the value read for each variable in the pre-execution read set of transaction Tx1 is the latest state in the pre-execution process, it can be determined that there is no conflict between the pre-execution read set of transaction Tx1 and the second state set. In the case where it is determined sequentially that there is no conflict between the pre-execution read sets of multiple transactions and the second status set, the second status set may be updated based on the pre-execution read and write sets of the multiple transactions.
如果缓存进程12确定交易Tx1的预执行读集中的变量a的值与第二状态集中的变量a的值不一致,说明该交易Tx1读取的变量a的值不是预执行过程中的最新状态,因此,可确定交易Tx1的预执行读集与第二状态集存在冲突。在确定存在冲突的情况中,缓存进程12可指示预执行进程111对交易Tx1及在交易Tx1之后预执行的其他交易重新进行预执行。If the cache process 12 determines that the value of variable a in the pre-execution read set of transaction Tx1 is inconsistent with the value of variable a in the second state set, it means that the value of variable a read by transaction Tx1 is not the latest state in the pre-execution process, so , it can be determined that the pre-execution read set of transaction Tx1 conflicts with the second status set. In the event that a conflict is determined to exist, the cache process 12 may instruct the pre-execution process 111 to re-pre-execute the transaction Tx1 and other transactions pre-executed after the transaction Tx1.
另外,缓存进程12在接收到多个交易的预执行读写集和预执行顺序之后,可在内存120中存储该多个交易的预执行读写集,并在交易队列中按照该多个交易的预执行顺序存储该多个交易的标识,以指示该多个交易的预执行顺序。In addition, after receiving the pre-execution read-write sets and pre-execution sequences of multiple transactions, the cache process 12 can store the pre-execution read-write sets of the multiple transactions in the memory 120, and process the multiple transactions in the transaction queue according to the pre-execution read-write sets. The pre-execution sequence stores the identifiers of the multiple transactions to indicate the pre-execution sequence of the multiple transactions.
在步骤S309,缓存进程12向共识进程13发送多个交易的预执行读写集和预执行顺序。In step S309, the cache process 12 sends the pre-execution read-write sets and pre-execution sequences of multiple transactions to the consensus process 13.
共识进程13定期调用缓存进程12提供的接口向缓存进程12请求获取待共识的一批交易进行共识。缓存进程12响应于该请求向共识进程13发送多个交易的预执行读写集及该多个交易的排列顺序,该排列顺序即为该多个交易的预执行顺序。其中,缓存进程12可与各个交易的哈希值关联地发送各个交易的预执行读写集。缓存进程12也可以在内存120中存储的交易的预执行读写集达到一定数据量时、或者在内存120中存储的交易的预执行读写集达到一定数量时向共识进程发送多个交易的预执行读写集及其预执行顺序。The consensus process 13 regularly calls the interface provided by the cache process 12 to request the cache process 12 to obtain a batch of transactions to be agreed upon for consensus. In response to the request, the cache process 12 sends the pre-execution read and write sets of multiple transactions and the arrangement order of the multiple transactions to the consensus process 13. The arrangement order is the pre-execution order of the multiple transactions. Wherein, the cache process 12 may send the pre-execution read-write set of each transaction in association with the hash value of each transaction. The cache process 12 may also send multiple transaction data to the consensus process when the pre-execution read-write set of transactions stored in the memory 120 reaches a certain amount of data, or when the pre-execution read-write set of transactions stored in the memory 120 reaches a certain amount. Pre-execution read and write sets and their pre-execution order.
在步骤S311,共识进程13生成共识提议,进行与其他节点的共识。In step S311, the consensus process 13 generates a consensus proposal and performs consensus with other nodes.
不同类型的区块链网络中,为了在各个记录账本的节点中保持账本的一致,通常采用共识算法来保证,即共识机制。例如,区块链节点之间可以实现区块粒度的共识机制,比如在节点(例如某个独特的节点)产生一个区块后,如果产生的这个区块得到其它节点的认可,其它节点记录相同的区块。再例如,区块链节点之间可以实现交易粒度的共识机 制,比如在节点(例如某个独特的节点)获取一笔区块链交易后,如果这笔区块链交易得到其他节点的认可,认可该区块链交易的各个节点可以分别将该区块链交易添加至自身维护的最新区块中,并且最终能够确保各个节点产生相同的最新区块。共识机制是区块链节点就区块信息(或称区块数据)达成全网一致共识的机制,可以保证最新区块被准确添加至区块链。当前主流的共识机制包括:工作量证明(Proof of Work,POW)、股权证明(Proof of Stake,POS)、委任权益证明(Delegated Proof of Stake,DPOS)、实用拜占庭容错(Practical Byzantine Fault Tolerance,PBFT)算法等。其中,在各种共识算法中,通常在预设数目的节点对待共识的数据(即共识提议)达成一致之后,从而确定对该共识提议的共识成功。具体是,在PBFT算法中,对于N≥3f+1个共识节点,可容忍f个恶意节点,也就是说,当N个共识节点中2f+1个节点达成一致时,可确定共识成功。In different types of blockchain networks, in order to maintain the consistency of the ledger in each node that records the ledger, a consensus algorithm is usually used to ensure it, that is, a consensus mechanism. For example, blockchain nodes can implement a block-granular consensus mechanism. For example, after a node (such as a unique node) generates a block, if the generated block is recognized by other nodes, the records of other nodes will be the same. block. For another example, a transaction-granularity consensus mechanism can be implemented between blockchain nodes. For example, after a node (such as a unique node) obtains a blockchain transaction, if the blockchain transaction is recognized by other nodes, Each node that recognizes the blockchain transaction can add the blockchain transaction to the latest block maintained by itself, and ultimately ensure that each node generates the same latest block. The consensus mechanism is a mechanism for blockchain nodes to reach a consensus across the entire network on block information (or block data), which can ensure that the latest blocks are accurately added to the blockchain. The current mainstream consensus mechanisms include: Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), Practical Byzantine Fault Tolerance (PBFT) ) algorithm, etc. Among various consensus algorithms, the consensus success of the consensus proposal is usually determined after a preset number of nodes reach an agreement on the consensus data (ie, consensus proposal). Specifically, in the PBFT algorithm, for N ≥ 3f + 1 consensus nodes, f malicious nodes can be tolerated. That is to say, when 2f + 1 nodes among the N consensus nodes reach an agreement, the consensus can be determined to be successful.
图4为PBFT共识算法中的共识过程示意图。如图4所示,根据PBFT共识算法,可将共识过程划分为请求(Request)、预备(Pre-Prepare)、准备(Prepare)和提交(Commit)四个阶段。对于图1所示的区块链,根据PBFT算法,在主节点1、从节点2-从节点6中可容忍f=1个恶意节点,因此该6个节点中需要5个节点达成一致时,才能确定共识成功。具体是,在请求阶段,区块链的用户可如上文所述通过其用户设备向主节点1发送交易。在预备阶段,主节点1生成共识提议,具体是,在本说明书实施例中,该共识提议中可包括从缓存进程12接收的多个交易的预执行读写集和该多个交易的预执行顺序等信息,其中共识提议中的各个交易可以交易哈希值标识。Figure 4 is a schematic diagram of the consensus process in the PBFT consensus algorithm. As shown in Figure 4, according to the PBFT consensus algorithm, the consensus process can be divided into four stages: Request, Pre-Prepare, Prepare and Commit. For the blockchain shown in Figure 1, according to the PBFT algorithm, f=1 malicious node can be tolerated among master node 1, slave node 2-slave node 6, so when 5 of the 6 nodes need to reach consensus, Only then can the consensus be confirmed to be successful. Specifically, during the request phase, the user of the blockchain can send a transaction to the master node 1 through its user device as described above. In the preliminary stage, the master node 1 generates a consensus proposal. Specifically, in the embodiment of this specification, the consensus proposal may include the pre-execution read-write set of multiple transactions received from the cache process 12 and the pre-execution of the multiple transactions. Information such as order, where individual transactions in a consensus proposal can be identified by transaction hash values.
共识进程13可将上述生成的共识提议及主节点1对该共识提议的签名发送给其他共识节点(即从节点2-从节点6),以用于生成区块。具体是,共识进程13可将共识提议及签名发送给网络进程,由网络进程发送给其他节点。另外,如上文所述,缓存进程12已经通过广播的形式将接收到的各个交易广播给各个从节点,通过这种方式,主节点1发送给各个从节点的共识提议中不包括各个交易的交易体,减少了共识提议的数据量,从而减少了共识过程中各个节点对共识节点进行数字签名需要的计算量,提高了共识效率。The consensus process 13 can send the consensus proposal generated above and the signature of the consensus proposal by the master node 1 to other consensus nodes (ie, the slave node 2 to the slave node 6) for use in generating blocks. Specifically, the consensus process 13 can send the consensus proposal and signature to the network process, and the network process sends it to other nodes. In addition, as mentioned above, the cache process 12 has broadcast each received transaction to each slave node in the form of broadcast. In this way, the consensus proposal sent by the master node 1 to each slave node does not include the transactions of each transaction. It reduces the amount of data required for consensus proposals, thereby reducing the amount of calculation required by each node to digitally sign the consensus node during the consensus process, and improving consensus efficiency.
仍参考图4,在准备阶段,各个从节点可对共识提议进行签名并发送给其他各个节点。假设从节点6为恶意节点,主节点1、从节点2-从节点5在分别接收到2f=2个其他共识节点的对共识提议的签名之后,可确定准备阶段完成,可进入提交阶段。例如,如图4中所示,主节点1在接收到从节点2-从节点5的签名之后,验证从节点2-从节点5的签名都是正确的对共识提议的签名,则确定准备阶段完成,从节点2在接收到从节点3-从节点5的签名和预备阶段主节点1的签名并验证通过之后,确定准备阶段完成。在提交阶段,各个共识节点对共识提议进行提交阶段的签名并发送给其他各个共识节点,各个共识节点在接收到2f=4个其他共识节点的提交阶段的签名之后,可确定提交阶段完成,共识成功。例如,主节点1在接收到从节点2-从节点5的提交阶段的签名并验证之后,确定提交阶段完成,共识成功。Still referring to Figure 4, in the preparation phase, each slave node can sign the consensus proposal and send it to each other node. Assuming that slave node 6 is a malicious node, after master node 1, slave node 2-slave node 5 respectively receive the signatures of the consensus proposal from 2f = 2 other consensus nodes, it can be determined that the preparation phase is completed and the submission phase can be entered. For example, as shown in Figure 4, after master node 1 receives the signatures of slave node 2-slave node 5, it verifies that the signatures of slave node 2-slave node 5 are correct signatures for the consensus proposal, then the preparation stage is determined. Completed, the slave node 2 determines that the preparation phase is completed after receiving the signatures of the slave nodes 3 to 5 and the signature of the master node 1 in the preliminary phase and passing the verification. In the submission phase, each consensus node signs the consensus proposal in the submission phase and sends it to each other consensus node. After receiving the signatures of 2f = 4 other consensus nodes in the submission phase, each consensus node can confirm that the submission phase is completed and the consensus success. For example, after master node 1 receives and verifies the signatures of the submission phase from slave node 2 to slave node 5, it determines that the submission phase is completed and the consensus is successful.
在步骤S313,共识进程13将共识提议发送给区块管理进程14。In step S313, the consensus process 13 sends the consensus proposal to the block management process 14.
共识进程13在生成共识提议之后,可将共识提议发送给区块管理进程14。After generating the consensus proposal, the consensus process 13 may send the consensus proposal to the block management process 14.
在步骤S315,区块管理进程14生成并提交区块。In step S315, the block management process 14 generates and submits blocks.
由于主节点信任自身的预执行没有作恶,并且主节点中对交易的预执行是根据正确的世界状态进行的,如果主节点再次依据状态数据库中的世界状态重新执行该多个交易, 所得到的该多个交易的执行读写集与该多个交易的预执行读写集必然是一致的。因此,区块管理进程14可以直接将该多个交易的预执行读写集视为执行读写集,用来更新状态数据库中的世界状态,而不需要重新执行一次该多个交易。Since the master node trusts its own pre-execution without doing evil, and the pre-execution of transactions in the master node is based on the correct world state, if the master node re-executes the multiple transactions based on the world state in the state database, the obtained The execution read-write sets of the multiple transactions must be consistent with the pre-execution read-write sets of the multiple transactions. Therefore, the block management process 14 can directly regard the pre-execution read and write sets of the multiple transactions as the execution read and write sets to update the world state in the state database without re-executing the multiple transactions.
从而,区块管理进程14可根据共识提议中多个交易的预执行读写集中的写集和预执行顺序顺序更新世界状态中各个账户和各个合约变量的状态,根据更新的世界状态更新状态树中各个节点的值,包括状态根((即状态树的根节点的哈希值))。区块管理进程14还可以从缓存进程13获取该多个交易各自的交易体和交易收据,并分别生成多个交易的交易树的交易根(即交易树的根节点的哈希值)和收据树的收据根(即收据树的根节点的哈希值)。Therefore, the block management process 14 can sequentially update the status of each account and each contract variable in the world state according to the write set and pre-execution sequence of the pre-execution read-write set of multiple transactions in the consensus proposal, and update the state tree according to the updated world state. The value of each node in , including the state root ((that is, the hash value of the root node of the state tree)). The block management process 14 can also obtain the transaction bodies and transaction receipts of the multiple transactions from the cache process 13, and generate the transaction roots of the transaction trees of the multiple transactions (that is, the hash value of the root node of the transaction tree) and receipts respectively. The receipt root of the tree (that is, the hash value of the root node of the receipt tree).
然后,区块管理进程14可生成包括所述多个交易的区块(例如区块B1),该区块B1可包括区块体和区块头,其中,区块头中可以包括区块号、交易根、状态根、收据根等信息,区块体可以包括各个交易的交易体集合和收据集合。区块管理进程14在生成区块之后,可提交该区块,以存储到图2中主节点1的区块数据库。例如,区块管理进程14可将该区块发送给存储进程,以使得存储进程在区块数据库中存储该区块。Then, the block management process 14 may generate a block (for example, block B1) including the plurality of transactions. The block B1 may include a block body and a block header, where the block header may include a block number, transaction Root, status root, receipt root and other information, the block body can include the transaction body set and receipt set of each transaction. After generating the block, the block management process 14 can submit the block to be stored in the block database of the master node 1 in Figure 2 . For example, block management process 14 may send the block to the storage process so that the storage process stores the block in a block database.
其中,由于主节点信任自身的预执行读写集,因此,区块管理进程14可以在从共识进程13接收到共识提议之后立即进行对世界状态的更新和对区块的生成、提交操作。可以理解,区块管理进程14也可以在从共识进程13接收到共识成功的信息之后进行对世界状态的更新和对区块的生成、提交操作。Among them, since the master node trusts its own pre-execution read-write set, the block management process 14 can update the world state and generate and submit blocks immediately after receiving the consensus proposal from the consensus process 13. It can be understood that the block management process 14 can also update the world state and generate and submit blocks after receiving the consensus success information from the consensus process 13 .
图5为本说明书实施例中的在区块链中执行交易的方法流程图。该方法可由图2中的从节点2执行。Figure 5 is a flow chart of a method for executing transactions in the blockchain in the embodiment of this specification. This method can be executed by slave node 2 in Figure 2.
如图5所示,首先,在步骤S501,从节点2中的共识进程22与区块链中的其他节点进行共识。As shown in Figure 5, first, in step S501, the consensus process 22 in the slave node 2 reaches consensus with other nodes in the blockchain.
与主节点1类似的,从节点2中也可以包括接收进程和网络进程(图2中未示出),从节点2可通过接收进程从用户设备接收到交易,可通过网络进程接收到其他节点发送的交易。接收进程和网络进程在接收到交易之后将交易发送给缓存进程21,从而缓存进程21可在内存210以交易队列的形式存储接收的交易。与主节点1类似的,缓存进程21也可以将交易队列中的交易发送给网络进程,以广播给区块链中的其他节点。Similar to master node 1, slave node 2 can also include a receiving process and a network process (not shown in Figure 2). Slave node 2 can receive transactions from user devices through the receiving process, and can receive transactions from other nodes through the network process. Transaction sent. After receiving the transaction, the receiving process and the network process send the transaction to the cache process 21, so that the cache process 21 can store the received transaction in the memory 210 in the form of a transaction queue. Similar to the master node 1, the cache process 21 can also send transactions in the transaction queue to the network process to broadcast to other nodes in the blockchain.
主节点1中的网络进程将共识提议及主节点1的签名发送给其他各个节点的网络进程,从而从节点2中的网络进程可接收到该共识提议及主节点1的签名,并将该共识提议及主节点1的签名发送给共识进程22。共识进程22在接收到共识提议及其签名之后,开始进行共识过程。具体共识过程可参考上文参考图4的描述,在此不再赘述。The network process in master node 1 sends the consensus proposal and the signature of master node 1 to the network processes of other nodes, so that the network process in slave node 2 can receive the consensus proposal and the signature of master node 1, and transfer the consensus The proposal and the signature of master node 1 are sent to consensus process 22. After receiving the consensus proposal and its signature, the consensus process 22 starts the consensus process. For the specific consensus process, please refer to the description above with reference to Figure 4, and will not be described again here.
在步骤S503,共识进程22将共识提议发送给区块管理进程23。In step S503, the consensus process 22 sends the consensus proposal to the block management process 23.
共识进程22在接收到共识提议之后,在对主节点的签名验证通过之后,就可以将该共识提议发送给区块管理进程23。After receiving the consensus proposal and passing the signature verification of the master node, the consensus process 22 can send the consensus proposal to the block management process 23.
在步骤S505,区块管理进程23根据共识提议对多个交易进行分组,将多个组分配给多个计算进程。In step S505, the block management process 23 groups multiple transactions according to the consensus proposal, and allocates the multiple groups to multiple computing processes.
区块管理进程23可根据共识提议中的预执行读写集对该多个交易进行分组,使得每两个分组中的全部交易不会访问相同的变量,从而使得各个分组可以并行执行,每个组中的多个交易按照其预执行顺序进行排列。在完成分组之后,区块管理进程23可将分组得 到的多个组均匀分给多个计算进程。例如在从节点2中仅包括计算进程241和计算进程242的情况中,可以将多个组中的一半数量的组分给计算进程241,将另一半数量的组分给计算进程242。The block management process 23 can group the multiple transactions according to the pre-execution read-write set in the consensus proposal, so that all transactions in each two groups will not access the same variables, so that each group can be executed in parallel, and each Multiple transactions in a group are arranged in their pre-execution order. After completing the grouping, the block management process 23 may evenly distribute the multiple groups obtained by grouping to multiple computing processes. For example, in the case where the slave node 2 only includes the calculation process 241 and the calculation process 242, half of the number of components in the plurality of groups can be assigned to the calculation process 241, and the other half of the number of components can be assigned to the calculation process 242.
可以理解,本说明书实施例中不限于由区块管理进程23进行对多个交易的分组,例如,也可以由共识进程22根据多个交易的预执行读写集对对多个交易进行分组,并将共识提议和分组结果发送给区块管理进程23。It can be understood that the embodiment of this specification is not limited to the grouping of multiple transactions by the block management process 23. For example, the consensus process 22 can also group multiple transactions according to the pre-execution read and write sets of multiple transactions. And send the consensus proposal and grouping results to the block management process 23.
在步骤S507,区块管理进程23将分配给各个进程的组和组内各个交易的预执行读写集发送给各个进程。In step S507, the block management process 23 sends the group assigned to each process and the pre-execution read-write set of each transaction in the group to each process.
在步骤S509,计算进程执行交易,更新状态数据库。In step S509, the calculation process executes the transaction and updates the status database.
以计算进程241为例,区块管理进程23可以对计算进程241分配一个或多个组。在区块管理进程23对计算进程241分配多个组的情况中,计算进程241中可通过多个线程并发处理多个组。同时,计算进程241按照一个组中多个交易的预执行顺序串行执行一个组中的多个交易。Taking the calculation process 241 as an example, the block management process 23 can assign one or more groups to the calculation process 241 . In the case where the block management process 23 allocates multiple groups to the computing process 241, the computing process 241 can process multiple groups concurrently through multiple threads. At the same time, the calculation process 241 serially executes multiple transactions in a group according to the pre-execution order of the multiple transactions in the group.
具体是,如图2所示,计算进程241中包括内存243,计算进程241在开始执行多个组的交易之前,可根据多个组中的全部交易的读集,确定需要读取的全部变量,并从状态数据库进行对该全部变量的批量地(例如一次性地)读取,在读取到全部变量的状态(即世界状态)之后,进程241可以将该全部变量的值以键值对的形式存储到内存243中的第三状态集中。然后,计算进程241可基于第三状态集执行各个组中的交易。计算进程241在根据交易执行读取变量的操作时,从第三状态集中读取变量的值,在根据交易执行写入变量的操作时,将第三状态集中该变量的值更新为此次写入的值,并据此生成交易的执行读写集。与预执行读写集类似地,执行读写集中包括执行读集和执行写集。执行读集中例如包括交易在执行过程中读取的变量的键值对,执行写集中例如包括交易在执行过程中写入的变量的键值对。通过批量预读的方式,计算进程241预先将需要从状态数据库读取的参数存储到本地的内存243中,从而计算进程241在执行交易的过程中可直接从内存中读取状态,而不需要从存储中读取状态,大大加快了交易执行速度。Specifically, as shown in Figure 2, the calculation process 241 includes a memory 243. Before starting to execute multiple groups of transactions, the calculation process 241 can determine all variables that need to be read based on the read sets of all transactions in the multiple groups. , and reads all variables in batches (for example, all at once) from the state database. After reading the states of all variables (ie, world state), process 241 can pair the values of all variables with key values. The form is stored in the third state set in the memory 243. The calculation process 241 may then execute transactions in each group based on the third set of states. When the calculation process 241 performs the operation of reading variables according to the transaction, it reads the value of the variable from the third state set, and when it performs the operation of writing the variable according to the transaction, it updates the value of the variable in the third state set to the value of this write. The entered value is used to generate the execution read-write set of the transaction. Similar to the pre-execution read-write set, the execution read-write set includes an execution read set and an execution write set. The execution read set includes, for example, the key-value pairs of variables read during the transaction execution process, and the execution write set includes, for example, the key-value pairs of variables written during the transaction execution process. Through batch pre-reading, the calculation process 241 stores the parameters that need to be read from the state database into the local memory 243 in advance, so that the calculation process 241 can directly read the state from the memory during the execution of the transaction without the need for Reading state from storage greatly speeds up transaction execution.
由于各个组彼此不访问相同的变量,即不存在冲突交易,因此,计算进程241在完成对一个组中的全部交易的执行之后,可立即根据该组的各个交易的执行写集更新状态数据库中的世界状态,而不会影响其他组的交易执行。同时提高了交易执行速度。Since each group does not access the same variables, that is, there is no conflicting transaction, therefore, after completing the execution of all transactions in a group, the calculation process 241 can immediately update the state database according to the execution write set of each transaction of the group. world state without affecting the transaction execution of other groups. At the same time, the transaction execution speed is improved.
在步骤S511,区块管理进程23生成并提交区块。In step S511, the block management process 23 generates and submits blocks.
区块管理进程23在确定各个计算进程都完成对分配给其的组的交易执行和状态更新之后,根据更新的世界状态更新状态树中各个节点的值,包括状态根((即状态树的根节点的哈希值))。区块管理进程23还可以从缓存进程21获取多个交易各自的交易体和交易收据,并分别生成多个交易的交易树的交易根(即交易树的根节点的哈希值)和收据树的收据根(即收据树的根节点的哈希值)。After determining that each computing process has completed transaction execution and status updates for the groups assigned to it, the block management process 23 updates the values of each node in the state tree according to the updated world state, including the state root (i.e. the root of the state tree The hash value of the node)). The block management process 23 can also obtain the transaction bodies and transaction receipts of multiple transactions from the cache process 21, and generate the transaction roots of the transaction trees of the multiple transactions (that is, the hash value of the root node of the transaction tree) and the receipt tree respectively. The receipt root (that is, the hash value of the root node of the receipt tree).
然后,区块管理进程23可生成包括所述多个交易的区块(例如区块B1),该区块B1可包括区块体和区块头,其中,区块头中可以包括区块号、交易根、状态根、收据根等信息,区块体可以包括各个交易的交易体集合和收据集合。区块管理进程23在生成区块之后,可提交该区块,以存储到图2中从节点2的区块数据库。Then, the block management process 23 may generate a block (for example, block B1) including the plurality of transactions. The block B1 may include a block body and a block header, where the block header may include a block number, transaction Root, status root, receipt root and other information, the block body can include the transaction body set and receipt set of each transaction. After generating the block, the block management process 23 can submit the block to be stored in the block database of the slave node 2 in FIG. 2 .
通过上述过程,在实现了区块链中各个节点的存储一致性的同时,利用区块链节点 中多进程的架构,可使用多进程架构的优势进一步加快交易的执行速度,提高了区块链的系统效率。Through the above process, while achieving the storage consistency of each node in the blockchain, using the multi-process architecture in the blockchain node, the advantages of the multi-process architecture can be used to further speed up the execution of transactions and improve the efficiency of the blockchain. system efficiency.
本说明书实施例还提供一种区块链中的第一节点,所述第一节点中运行有第一预执行进程、缓存进程和第一共识进程,用于执行图3所示方法。Embodiments of this specification also provide a first node in the blockchain, where a first pre-execution process, a cache process and a first consensus process are run, for executing the method shown in Figure 3.
所述缓存进程用于将接收的多个交易发送给所述第一预执行进程,所述缓存进程的内存中存储有区块链中至少部分变量的最新世界状态;The cache process is used to send multiple received transactions to the first pre-execution process, and the latest world state of at least some variables in the blockchain is stored in the memory of the cache process;
所述第一预执行进程用于预执行所述多个交易,得到所述多个交易的预执行读写集和所述多个交易的预执行顺序,将所述多个交易的预执行读写集和预执行顺序发送给所述缓存进程,其中,所述第一预执行进程还用于在预执行所述多个交易中的第一交易时,从所述缓存进程接收所述第一交易中请求读取的变量的状态;The first pre-execution process is used to pre-execute the multiple transactions, obtain the pre-execution read and write sets of the multiple transactions and the pre-execution sequences of the multiple transactions, and obtain the pre-execution read and write sets of the multiple transactions. The write set and the pre-execution sequence are sent to the cache process, wherein the first pre-execution process is also used to receive the first transaction from the cache process when pre-executing the first transaction in the plurality of transactions. The status of the variable requested to be read in the transaction;
所述缓存进程用于将所述多个交易的预执行读写集和所述多个交易的预执行顺序发送给所述第一共识进程,基于所述多个交易的预执行读写集更新所述缓存进程的内存中当前存储的世界状态数据;The cache process is used to send the pre-execution read-write set of the multiple transactions and the pre-execution order of the multiple transactions to the first consensus process, and update the pre-execution read-write set based on the multiple transactions. The world state data currently stored in the memory of the cache process;
所述第一共识进程用于生成共识提议,将所述共识提议发送给所述区块链中的第二节点,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述预执行顺序。The first consensus process is used to generate a consensus proposal and send the consensus proposal to the second node in the blockchain. The consensus proposal includes the pre-execution read-write set of the multiple transactions and the multiple transactions. The arrangement order of transactions, the arrangement order corresponds to the pre-execution order.
本说明书实施例还提供一种区块链中的第二节点,所述第二节点中运行有第二共识进程、第二区块管理进程和N个计算进程,用于执行图5所示方法。Embodiments of this specification also provide a second node in the blockchain. The second node runs a second consensus process, a second block management process and N calculation processes for executing the method shown in Figure 5. .
所述第二共识进程用于从所述第一节点接收共识提议,将所述共识提议发送给所述第二区块管理进程,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述多个交易的预执行顺序;The second consensus process is configured to receive a consensus proposal from the first node and send the consensus proposal to the second block management process, where the consensus proposal includes a pre-execution read-write set of the multiple transactions. and the arrangement order of the plurality of transactions, the arrangement order corresponding to the pre-execution order of the plurality of transactions;
所述第二区块管理进程用于根据所述预执行读写集将所述多个交易分成多个交易组,将所述多个交易组分配给所述N个计算进程,并将所述多个交易的排列顺序发送给所述N个计算进程;The second block management process is used to divide the multiple transactions into multiple transaction groups according to the pre-execution read and write set, allocate the multiple transaction groups to the N computing processes, and assign the The sequence of multiple transactions is sent to the N calculation processes;
所述N个计算进程用于分别根据所述排列顺序执行分配给其的交易组中的交易。The N calculation processes are used to execute transactions in the transaction groups assigned thereto respectively according to the arrangement order.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、 JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, improvements in a technology could be clearly distinguished as hardware improvements (for example, improvements in circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements in method processes). However, with the development of technology, many improvements in today's method processes can be regarded as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement of a method flow cannot be implemented using hardware entity modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic functions are determined by the user programming the device. Designers can program themselves to "integrate" a digital system on a PLD, instead of asking chip manufacturers to design and produce dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing, and before compilation The original code must also be written in a specific programming language, which is called Hardware Description Language (HDL), and HDL is not just one kind, but there are many, such as ABEL (Advanced Boolean Expression Language) , AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., are currently the most commonly used The two are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that by simply logically programming the method flow using the above-mentioned hardware description languages and programming it into the integrated circuit, the hardware circuit that implements the logical method flow can be easily obtained.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为服务器系统。当然,本申请不排除随着未来计算机技术的发展,实现上述实施例功能的计算机例如可以为个人计算机、膝上型计算机、车载人机交互设备、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not rule out that with the development of computer technology in the future, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, or a personal digital assistant. , media player, navigation device, email device, game console, tablet, wearable device, or a combination of any of these devices.
虽然本说明书一个或多个实施例提供了如实施例或流程图所述的方法操作步骤,但基于常规或者无创造性的手段可以包括更多或者更少的操作步骤。实施例中列举的步骤顺序仅仅为众多步骤执行顺序中的一种方式,不代表唯一的执行顺序。在实际中的装置或终端产品执行时,可以按照实施例或者附图所示的方法顺序执行或者并行执行(例如并行处理器或者多线程处理的环境,甚至为分布式数据处理环境)。术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、产品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、产品或者设备所固有的要素。在没有更多限制的情况下,并不排除在包括所述要素的过程、方法、产品或者设备中还存在另外的相同或等同要素。例如若使用到第一,第二等词语用来表示名称,而并不表示任何特定的顺序。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.
为了描述的方便,描述以上装置时以功能分为各种模块分别描述。当然,在实施本说明书一个或多个时可以把各模块的功能在同一个或多个软件和/或硬件中实现,也可以将实现同一功能的模块由多个子模块或子单元的组合实现等。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。For the convenience of description, when describing the above device, the functions are divided into various modules and described separately. Of course, when implementing one or more of this specification, the functions of each module can be implemented in the same or multiple software and/or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. . The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated. to another system, or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
本发明是参照根据本发明实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。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. To 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 (13)

  1. 一种在区块链中执行交易的方法,所述区块链包括第一节点和第二节点,所述第一节点中运行有第一预执行进程、缓存进程和第一共识进程,所述方法由所述第一节点执行,包括:A method of executing transactions in a blockchain. The blockchain includes a first node and a second node. The first node runs a first pre-execution process, a cache process and a first consensus process. The method is executed by the first node and includes:
    所述缓存进程将接收的多个交易发送给所述第一预执行进程,所述缓存进程的内存中存储有区块链中至少部分变量的当前状态;The cache process sends the received multiple transactions to the first pre-execution process, and the memory of the cache process stores the current status of at least some variables in the blockchain;
    所述第一预执行进程预执行所述多个交易,得到所述多个交易的预执行读写集和所述多个交易的预执行顺序,将所述多个交易的预执行读写集和预执行顺序发送给所述缓存进程,其中,所述第一预执行进程在预执行所述多个交易中的第一交易时,从所述缓存进程接收所述第一交易中请求读取的变量的状态;The first pre-execution process pre-executes the multiple transactions, obtains the pre-execution read-write sets of the multiple transactions and the pre-execution sequences of the multiple transactions, and converts the pre-execution read-write sets of the multiple transactions and the pre-execution sequence is sent to the cache process, wherein the first pre-execution process receives the read request in the first transaction from the cache process when pre-executing the first transaction in the plurality of transactions. The state of the variable;
    所述缓存进程将所述多个交易的预执行读写集和所述多个交易的预执行顺序发送给所述第一共识进程,基于所述多个交易的预执行读写集更新所述缓存进程的内存中存储的状态数据;The cache process sends the pre-execution read-write sets of the multiple transactions and the pre-execution sequences of the multiple transactions to the first consensus process, and updates the pre-execution read-write set based on the multiple transactions. Cache state data stored in the process's memory;
    所述第一共识进程生成共识提议,将所述共识提议发送给所述区块链中的第二节点,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述预执行顺序。The first consensus process generates a consensus proposal and sends the consensus proposal to the second node in the blockchain. The consensus proposal includes the pre-execution read-write set of the multiple transactions and the multiple transactions. The arrangement order corresponds to the pre-execution order.
  2. 根据权利要求1所述的方法,所述第一预执行进程预执行所述多个交易包括:所述第一预执行进程在预执行所述第一交易时,在确定所述第一预执行进程的内存中未存储所述第一交易请求读取的变量的状态时,从所述缓存进程接收所述第一交易中请求读取的变量的状态,基于所述第一交易的预执行读写集更新所述第一预执行进程的内存中存储的状态数据。The method of claim 1, wherein the first pre-execution process pre-executes the plurality of transactions including: when pre-executing the first transaction, the first pre-execution process determines that the first pre-execution process When the state of the variable requested to be read in the first transaction is not stored in the memory of the process, the state of the variable requested to be read in the first transaction is received from the cache process, and the pre-execution read based on the first transaction is The write set updates the state data stored in the memory of the first pre-execution process.
  3. 根据权利要求2所述的方法,所述第一预执行进程预执行所述多个交易包括:所述第一预执行进程在预执行所述多个交易中的第二交易时,基于所述第一预执行进程的内存中存储的状态数据预执行所述第二交易。The method of claim 2, wherein the first pre-execution process pre-executes the plurality of transactions including: when the first pre-execution process pre-executes a second transaction in the plurality of transactions, based on the The state data stored in the memory of the first pre-execution process pre-executes the second transaction.
  4. 根据权利要求1所述的方法,所述第一节点中还运行有第二预执行进程,所述方法还包括:所述缓存进程根据所述缓存进程的内存中当前存储的状态数据对所述多个交易的预执行读写集中的读集进行验证,在验证通过时,在所述缓存进程的内存中存储所述多个交易的预执行读写集和所述多个交易的预执行顺序,基于所述多个交易的预执行读写集更新所述缓存进程的内存中当前存储的状态数据。The method of claim 1, wherein a second pre-execution process is also running in the first node, and the method further includes: the cache process caches the cache process based on the status data currently stored in the memory of the cache process. The read sets in the pre-execution read and write sets of multiple transactions are verified. When the verification passes, the pre-execution read and write sets of the multiple transactions and the pre-execution sequence of the multiple transactions are stored in the memory of the cache process. , updating the state data currently stored in the memory of the cache process based on the pre-execution read and write sets of the multiple transactions.
  5. 根据权利要求1所述的方法,所述第一预执行进程预执行所述多个交易包括:所述第一预执行进程在预执行所述多个交易中的第三交易时,在确定所述第一预执行进程的内存中未存储所述第三交易请求读取的变量的状态、且所述存储进程的内存中未存储所述第三交易请求读取的变量的状态时,从状态数据库中读取所述第三交易请求读取的变量的状态。The method of claim 1, wherein the first pre-execution process pre-executes the plurality of transactions including: when the first pre-execution process pre-executes a third transaction among the plurality of transactions, the first pre-execution process determines that the When the state of the variable read by the third transaction request is not stored in the memory of the first pre-execution process, and the state of the variable read by the third transaction request is not stored in the memory of the storage process, from the state Read the status of the variable read by the third transaction request from the database.
  6. 根据权利要求1所述的方法,所述第一节点中还运行有第一区块管理进程,所述方法还包括:所述第一共识进程将所述共识提议发送给所述第一区块管理进程,所述第一区块管理进程根据所述多个交易的预执行读写集及所述多个交易的排列顺序更新状态数据库,生成并存储区块。According to the method of claim 1, a first block management process is also run in the first node, and the method further includes: the first consensus process sending the consensus proposal to the first block Management process, the first block management process updates the status database according to the pre-execution read and write sets of the multiple transactions and the arrangement order of the multiple transactions, and generates and stores blocks.
  7. 一种在区块链中执行交易的方法,所述区块链包括第一节点和第二节点,所述第 二节点中运行有第二共识进程、第二区块管理进程和N个计算进程,所述方法由所述第二节点执行,包括:A method of executing transactions in a blockchain. The blockchain includes a first node and a second node. The second node runs a second consensus process, a second block management process and N calculation processes. , the method is executed by the second node, including:
    所述第二共识进程从所述第一节点接收共识提议,将所述共识提议发送给所述第二区块管理进程,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述多个交易的预执行顺序;The second consensus process receives a consensus proposal from the first node and sends the consensus proposal to the second block management process. The consensus proposal includes the pre-execution read and write sets of the multiple transactions and all The arrangement order of the plurality of transactions, the arrangement order corresponding to the pre-execution order of the plurality of transactions;
    所述第二区块管理进程根据所述预执行读写集将所述多个交易分成多个交易组,将所述多个交易组分配给所述N个计算进程,并将所述多个交易的排列顺序发送给所述N个计算进程;The second block management process divides the multiple transactions into multiple transaction groups according to the pre-execution read and write set, allocates the multiple transaction groups to the N computing processes, and assigns the multiple transaction groups to the N computing processes. The order of transactions is sent to the N calculation processes;
    所述N个计算进程分别根据所述排列顺序执行分配给其的交易组中的交易。The N calculation processes respectively execute transactions in the transaction groups assigned to them according to the arrangement order.
  8. 根据权利要求7所述的方法,所述N个计算进程分别根据所述排列顺序执行分配给其的交易组中的交易包括:所述N个计算进程中的第一计算进程根据分配给其的交易组中包括的全部交易的预执行读集从状态数据库中读取状态数据,将所述读取的状态数据存储到所述第一计算进程的内存中。The method according to claim 7, wherein the N computing processes respectively execute transactions in the transaction group assigned to them according to the arrangement order, including: the first computing process among the N computing processes performs transactions according to the transaction group assigned to it. The pre-execution read set of all transactions included in the transaction group reads status data from the status database, and stores the read status data into the memory of the first computing process.
  9. 根据权利要求8所述的方法,还包括:所述第二区块管理进程将分配给各个计算进程的交易的预执行读写集发送给各个计算进程;The method according to claim 8, further comprising: the second block management process sending the pre-execution read and write sets of transactions assigned to each computing process to each computing process;
    所述N个计算进程分别根据所述排列顺序执行分配给其的交易组中的交易包括:所述第一计算进程在执行分配给其的交易组中的第一交易之后,得到所述第一交易的执行读写集,比较所述第一交易的执行读写集与所述第一交易的预执行读写集是否一致,在一致的情况中,根据所述第一交易的执行读写集更新所述第一计算进程的内存中当前存储的状态数据。The N calculation processes respectively executing the transactions in the transaction group assigned to them according to the arrangement order include: the first calculation process obtains the first transaction after executing the first transaction in the transaction group assigned to it. The execution read-write set of the transaction is compared to see whether the execution read-write set of the first transaction is consistent with the pre-execution read-write set of the first transaction. If they are consistent, the execution read-write set of the first transaction is compared. Update state data currently stored in the memory of the first computing process.
  10. 根据权利要求9所述的方法,还包括:所述第一计算进程在执行完成分配给其的全部交易之后,根据分配给其的全部交易的执行写集更新状态数据库中的世界状态。The method according to claim 9, further comprising: after the first computing process completes execution of all transactions assigned to it, update the world state in the state database according to the execution write set of all transactions assigned to it.
  11. 一种区块链中的第一节点,所述第一节点中运行有第一预执行进程、缓存进程和第一共识进程,A first node in a blockchain, where a first pre-execution process, a cache process and a first consensus process run,
    所述缓存进程用于将接收的多个交易发送给所述第一预执行进程,所述缓存进程的内存中存储有区块链中至少部分变量的当前状态;The cache process is used to send multiple received transactions to the first pre-execution process, and the memory of the cache process stores the current status of at least some variables in the blockchain;
    所述第一预执行进程用于预执行所述多个交易,得到所述多个交易的预执行读写集和所述多个交易的预执行顺序,将所述多个交易的预执行读写集和预执行顺序发送给所述缓存进程,其中,所述第一预执行进程还用于在预执行所述多个交易中的第一交易时,从所述缓存进程接收所述第一交易中请求读取的变量的状态;The first pre-execution process is used to pre-execute the multiple transactions, obtain the pre-execution read and write sets of the multiple transactions and the pre-execution sequences of the multiple transactions, and obtain the pre-execution read and write sets of the multiple transactions. The write set and the pre-execution sequence are sent to the cache process, wherein the first pre-execution process is also used to receive the first transaction from the cache process when pre-executing the first transaction in the plurality of transactions. The status of the variable requested to be read in the transaction;
    所述缓存进程用于将所述多个交易的预执行读写集和所述多个交易的预执行顺序发送给所述第一共识进程,基于所述多个交易的预执行读写集更新所述缓存进程的内存中存储的状态数据;The cache process is used to send the pre-execution read-write set of the multiple transactions and the pre-execution order of the multiple transactions to the first consensus process, and update the pre-execution read-write set based on the multiple transactions. The state data stored in the memory of the cache process;
    所述第一共识进程用于生成共识提议,将所述共识提议发送给所述区块链中的第二节点,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述预执行顺序。The first consensus process is used to generate a consensus proposal and send the consensus proposal to the second node in the blockchain. The consensus proposal includes the pre-execution read-write set of the multiple transactions and the multiple transactions. The arrangement order of transactions, the arrangement order corresponds to the pre-execution order.
  12. 一种区块链中的第二节点,所述第二节点中运行有第二共识进程、第二区块管理进程和N个计算进程,A second node in a blockchain, where a second consensus process, a second block management process and N calculation processes run,
    所述第二共识进程用于从所述第一节点接收共识提议,将所述共识提议发送给所述第 二区块管理进程,所述共识提议包括所述多个交易的预执行读写集及所述多个交易的排列顺序,所述排列顺序对应于所述多个交易的预执行顺序;The second consensus process is configured to receive a consensus proposal from the first node and send the consensus proposal to the second block management process, where the consensus proposal includes a pre-execution read-write set of the multiple transactions. and the arrangement order of the plurality of transactions, the arrangement order corresponding to the pre-execution order of the plurality of transactions;
    所述第二区块管理进程用于根据所述预执行读写集将所述多个交易分成多个交易组,将所述多个交易组分配给所述N个计算进程,并将所述多个交易的排列顺序发送给所述N个计算进程;The second block management process is used to divide the multiple transactions into multiple transaction groups according to the pre-execution read and write set, allocate the multiple transaction groups to the N computing processes, and assign the The sequence of multiple transactions is sent to the N calculation processes;
    所述N个计算进程用于分别根据所述排列顺序执行分配给其的交易组中的交易。The N calculation processes are used to execute transactions in the transaction groups assigned thereto respectively according to the arrangement sequence.
  13. 一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行权利要求1-10中任一项的所述的方法。A computer-readable storage medium on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to perform the method described in any one of claims 1-10.
PCT/CN2022/135262 2022-05-30 2022-11-30 Method for executing transaction and blockchain node WO2023231336A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210602790.5A CN114942847A (en) 2022-05-30 2022-05-30 Method for executing transaction and block link point
CN202210602790.5 2022-05-30

Publications (1)

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

Family

ID=82909983

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135262 WO2023231336A1 (en) 2022-05-30 2022-11-30 Method for executing transaction and blockchain node

Country Status (2)

Country Link
CN (1) CN114942847A (en)
WO (1) WO2023231336A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114942847A (en) * 2022-05-30 2022-08-26 蚂蚁区块链科技(上海)有限公司 Method for executing transaction and block link point
CN115577044A (en) * 2022-09-30 2023-01-06 蚂蚁区块链科技(上海)有限公司 Transaction execution method in blockchain system, consensus node and blockchain system
CN115658808A (en) * 2022-09-30 2023-01-31 蚂蚁区块链科技(上海)有限公司 Method for converting type of consensus node and consensus node
CN116308772B (en) * 2022-12-16 2023-10-13 蚂蚁区块链科技(上海)有限公司 Transaction distribution method, node and blockchain system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113743942A (en) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 Transaction execution method, block chain, main node and main storage device
CN113743941A (en) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain, block chain and main node
CN114827165A (en) * 2022-05-30 2022-07-29 蚂蚁区块链科技(上海)有限公司 Method and block link point for grouping multiple transactions
CN114936256A (en) * 2022-05-30 2022-08-23 蚂蚁区块链科技(上海)有限公司 Method for executing transaction in block chain and block chain link point
CN114942847A (en) * 2022-05-30 2022-08-26 蚂蚁区块链科技(上海)有限公司 Method for executing transaction and block link point

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113743942A (en) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 Transaction execution method, block chain, main node and main storage device
CN113743941A (en) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain, block chain and main node
CN114827165A (en) * 2022-05-30 2022-07-29 蚂蚁区块链科技(上海)有限公司 Method and block link point for grouping multiple transactions
CN114936256A (en) * 2022-05-30 2022-08-23 蚂蚁区块链科技(上海)有限公司 Method for executing transaction in block chain and block chain link point
CN114942847A (en) * 2022-05-30 2022-08-26 蚂蚁区块链科技(上海)有限公司 Method for executing transaction and block link point

Also Published As

Publication number Publication date
CN114942847A (en) 2022-08-26

Similar Documents

Publication Publication Date Title
WO2023231336A1 (en) Method for executing transaction and blockchain node
CN108027803B (en) Distributed lock-free RDMA-based memory allocation and de-allocation
US10375167B2 (en) Low latency RDMA-based distributed storage
US10713210B2 (en) Distributed self-directed lock-free RDMA-based B-tree key-value manager
WO2023231345A1 (en) Method for grouping a plurality of transactions, and blockchain node
WO2024001024A1 (en) Method for executing transaction in blockchain system, and blockchain system and nodes
CN113168652B (en) Block chain transaction processing system and method
WO2023160083A1 (en) Method for executing transactions, blockchain, master node, and slave node
CN113743940B (en) Method for executing transaction in block chain, main node and slave node
WO2023231335A1 (en) Method for executing transaction in blockchain, and master node of blockchain
WO2023160085A1 (en) Method for executing transaction, blockchain, master node, and slave node
WO2023231337A1 (en) Method for executing transaction in blockchain, and master node and slave node of blockchain
WO2023185059A1 (en) Consensus method and blockchain node
CN114936256A (en) Method for executing transaction in block chain and block chain link point
WO2023231339A1 (en) Transaction execution method and node in blockchain system, and blockchain system
JP2020532803A (en) Asynchronous updates of metadata tracks in response to cache hits generated via synchronous ingress and out, systems, computer programs and storage controls
WO2024001032A1 (en) Method for executing transaction in blockchain system, and blockchain system and nodes
WO2024001025A1 (en) Pre-execution cache data cleaning method and blockchain node
CN113744062A (en) Method for performing transactions in a blockchain, blockchain node and blockchain
US10289329B2 (en) Burst buffer dynamic logical volume sizing in high performance computing environment
JP2023505544A (en) Controlling transaction requests between applications and servers
CN116707891A (en) Replay attack checking method and block link point
CN115398397A (en) Block chain transaction processing system and method
WO2018188416A1 (en) Data search method and apparatus, and related devices
US10310889B1 (en) Data statistics service

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: 22944637

Country of ref document: EP

Kind code of ref document: A1