CN114942847A - Method for executing transaction and block link point - Google Patents

Method for executing transaction and block link point Download PDF

Info

Publication number
CN114942847A
CN114942847A CN202210602790.5A CN202210602790A CN114942847A CN 114942847 A CN114942847 A CN 114942847A CN 202210602790 A CN202210602790 A CN 202210602790A CN 114942847 A CN114942847 A CN 114942847A
Authority
CN
China
Prior art keywords
execution
transactions
transaction
read
consensus
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202210602790.5A
Other languages
Chinese (zh)
Inventor
林鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ant Blockchain Technology Shanghai Co Ltd
Original Assignee
Ant Blockchain Technology Shanghai Co Ltd
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 Ant Blockchain Technology Shanghai Co Ltd filed Critical Ant Blockchain Technology Shanghai Co Ltd
Priority to CN202210602790.5A priority Critical patent/CN114942847A/en
Publication of CN114942847A publication Critical patent/CN114942847A/en
Priority to PCT/CN2022/135262 priority patent/WO2023231336A1/en
Pending legal-status Critical Current

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

Abstract

A method of performing a transaction in a blockchain and blockchain nodes, the method performed by the first node, comprising: the cache process sends the received multiple transactions to a first pre-execution process; the first pre-execution process pre-executes the multiple transactions to obtain pre-execution read-write sets of the multiple transactions and pre-execution sequences of the multiple transactions, and sends the pre-execution read-write sets and the pre-execution sequences of the multiple transactions to the cache process; the cache process sends the pre-execution read-write sets of the multiple transactions and the pre-execution sequence of the multiple transactions to the first consensus process, and updates the world state data currently stored in the memory of the cache process based on the pre-execution read-write sets of the multiple transactions; the first consensus process generates a consensus proposal and sends the consensus proposal to a second node.

Description

Method and block link point for performing transactions
Technical Field
The embodiments of the present disclosure relate to the field of blockchain technologies, and in particular, to a method for performing transactions in a blockchain and a blockchain node.
Background
The Blockchain (Blockchain) is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. In the block chain system, data blocks are combined into a chain data structure in a sequential connection mode according to a time sequence, and a distributed account book which is not falsifiable and counterfeitable is ensured in a cryptographic mode. Because the blockchain has the characteristics of decentralization, information non-tampering, autonomy and the like, the blockchain is also paid more and more attention and is applied by people.
Disclosure of Invention
The invention aims to provide a method for executing transaction in a block chain, which accelerates the execution speed of transaction and improves the system efficiency of the block chain by using a plurality of processes to respectively provide each service in the block chain.
A first aspect of the present specification provides a method of performing a transaction in a blockchain, the blockchain including a first node and a second node, the first node having a first pre-execution process, a caching process and a first consensus process running therein, the method being performed by the first node and including:
the cache process sends the received multiple transactions to the first pre-execution process, and the latest world state of at least part of variables in the block chain is stored in a memory of the cache process;
the first pre-execution process pre-executes the multiple transactions, obtains pre-execution read-write sets of the multiple transactions and pre-execution sequences of the multiple transactions, and sends the pre-execution read-write sets and the pre-execution sequences of the multiple transactions to the cache process, wherein when a first transaction in the multiple transactions is pre-executed, the first pre-execution process receives the state of a variable requested to be read in the first transaction from the cache process;
the cache process sends the pre-execution read-write sets of the multiple transactions and the pre-execution sequence of the multiple transactions to the first consensus process, and updates the world state data currently stored in the memory of the cache process based on the pre-execution read-write sets of the multiple transactions;
the first consensus process generates a consensus offer that includes a pre-execution read-write set of the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to the pre-execution sequence, and sends the consensus offer to a second node in the blockchain.
A second aspect of the specification provides a method of performing a transaction in a blockchain, the blockchain comprising a first node and a second node, the second node having a second consensus process, a second blockmanagement process and N computing processes running therein, the method being performed by the second node and comprising:
the second consensus process receiving a consensus offer from the first node, sending the consensus offer to the second block management process, the consensus offer comprising a set of pre-executed reads for the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to a pre-executed sequence of the plurality of transactions;
the second block management process divides the transactions into a plurality of transaction groups according to the pre-execution read-write set, distributes the transaction groups to the N computing processes, and sends the arrangement sequence of the transactions to the N computing processes;
and the N computing processes respectively execute the transactions in the transaction group distributed to the N computing processes according to the arrangement sequence.
A third aspect of the present specification provides a first node in a blockchain, the first node having a first pre-execution process, a caching process and a first consensus process running therein,
the cache process is used for sending the received multiple transactions to the first pre-execution process, and the latest world state of at least part of variables in the block chain is stored in a memory of the cache process;
the first pre-execution process is used for pre-executing the multiple transactions, obtaining pre-execution read-write sets of the multiple transactions and pre-execution sequences of the multiple transactions, and sending the pre-execution read-write sets and the pre-execution sequences of the multiple transactions to the cache process, wherein the first pre-execution process is also used for receiving the state of a variable requested to be read in the first transaction from the cache process when the first transaction in the multiple transactions is pre-executed;
the cache process is used for sending the pre-execution read-write sets of the multiple transactions and the pre-execution sequence of the multiple transactions to the first consensus process, and updating currently stored world state data in a memory of the cache process based on the pre-execution read-write sets of the multiple transactions;
the first consensus process is configured to generate a consensus proposal, and send the consensus proposal to a second node in the blockchain, where the consensus proposal includes a pre-execution read-write set of the transactions and a rank order of the transactions, and the rank order corresponds to the pre-execution order.
A fourth aspect of the present specification provides a second node in a blockchain, the second node having a second consensus process, a second blockmanagement process and N computing processes running therein,
the second consensus process is configured to receive a consensus offer from the first node, send the consensus offer to the second block management process, the consensus offer including a set of pre-executed reads for the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to a pre-executed sequence of the plurality of transactions;
the second block management process is used for dividing the transactions into a plurality of transaction groups according to the pre-execution read-write set, distributing the transaction groups to the N computing processes, and sending the arrangement sequence of the transactions to the N computing processes;
the N computing processes are used for executing the transactions in the transaction group distributed to the N computing processes according to the arrangement sequence.
A fifth aspect of the present specification provides a computer readable storage medium having stored thereon a computer program which, when executed on a computer, causes the computer to perform the method of the first or second aspect.
A sixth aspect of the present specification provides a computing device comprising a memory having stored therein executable code and a processor that, when executing the executable code, implements the method of the first or second aspect.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments described in the present disclosure, and it is obvious for a person skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1 is a block chain architecture diagram applied in the embodiments of the present description;
FIG. 2 is an architecture diagram of a block link point in an embodiment of the present disclosure;
FIG. 3 is a flow diagram of a method of performing transactions in a blockchain in an embodiment of the present description;
FIG. 4 is a schematic diagram of the consensus process in the PBFT consensus algorithm;
fig. 5 is a flowchart of a method for performing a transaction in a blockchain in an embodiment of the present description.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step should fall within the scope of protection of the present specification.
Fig. 1 shows a block chain architecture diagram applied in the embodiment of the present specification. As shown in fig. 1, the block chain includes, for example, 6 nodes including a master node 1, a slave node 2, and a slave node 5. The lines between the nodes schematically represent P2P (Peer-to-Peer) connections. All the nodes store the full-amount accounts, namely the states of all the blocks and all the accounts. Wherein each node in the blockchain generates the same state in the blockchain by performing the same transaction, each node in the blockchain storing the same state database. In contrast, the master node 1 may be responsible for receiving the transactions from the clients and initiating consensus proposals to the respective slave nodes, which include information such as the multiple transactions in the block to be blocked (e.g., block B1) and the order of the multiple transactions. After the node in the blockchain successfully agrees on the consensus proposal, the nodes may perform the transactions according to the rank order in the consensus proposal, thereby generating block B1.
It is to be understood that the blockchain shown in fig. 1 is merely exemplary, and the embodiments of the present disclosure are not limited to being applied to the blockchain shown in fig. 1, and may also be applied to a blockchain system with a non-master-slave structure, for example.
In addition, although fig. 1 shows that the blockchain includes 6 nodes, the embodiments of the present specification are not limited thereto, and may include other numbers of nodes. Specifically, the nodes included in the block chain can meet the Byzantine Fault Tolerance (BFT) requirement. The byzantine fault tolerance requirement can be understood as that byzantine nodes can exist in a block chain, and the block chain does not show the byzantine behavior to the outside. 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-tolerant algorithm pbft (practical Byzantine Fault tolerance).
A transaction in the blockchain domain may refer to a unit of task that is performed in the blockchain and recorded in the blockchain. The transaction typically includes a send field (From), a receive field (To), and a Data field (Data). Where the transaction is a transfer transaction, the From field indicates the account address From which the transaction was initiated (i.e. the transfer task To another account was initiated), the To field indicates the account address From which the transaction was received (i.e. the transfer was received), and the Data field includes the transfer amount. In the case of a transaction calling an intelligent contract in a blockchain, a From field represents an account address for initiating the transaction, a To field represents an account address of the contract called by the transaction, and a Data field includes Data such as a function name in the calling contract and incoming parameters To the function, so as To obtain code of the function From the blockchain and execute the code of the function when the transaction is executed.
The block chain may provide the functionality of an intelligent contract. An intelligent contract on a blockchain is a contract that can be executed on a blockchain system triggered by a transaction. An intelligent contract may be defined in the form of code. Calling the intelligent contract in the block chain is to initiate a transaction pointing to the intelligent contract address, so that each node in the block chain runs the intelligent contract code in a distributed mode. It should be noted that, in addition to the creation of the smart contracts by the users, the smart contracts may also be set by the system in the creation block. Such contracts are generally referred to as foundational contracts. In general, the data structure, parameters, attributes, and methods of some blockchains may be set in a startup contract. Further, an account with system administrator privileges may create a contract at the system level, or modify a contract at the system level (simply referred to as a system contract). Wherein the system contract is usable to add data structures for data of different services in a blockchain.
In the scenario of contract deployment, for example, Bob sends a transaction containing information to create an intelligent contract (i.e., a deployment contract) into the blockchain as shown in fig. 1, the data field of the transaction includes the code (e.g., bytecode or machine code) of the contract to be created, and the to field of the transaction is null to indicate that the transaction is for contract deployment. After the agreement is achieved among the nodes through a consensus mechanism, a contract address '0 x6f8ae93 …' of the contract is determined, each node adds a contract account corresponding to the contract address of the intelligent contract in a state database, allocates a state storage corresponding to the contract account, and stores a contract code in the state storage of the contract, so that the contract creation is successful.
In the scenario of invoking a contract, for example, Bob sends a transaction for invoking a smart contract into the blockchain as shown in fig. 1, where the from field of the transaction is the address of the account of the transaction initiator (i.e., Bob), and "0 x6f8ae93 …" in the to field represents the address of the invoked smart contract, and the data field of the transaction includes the method and parameters for invoking the smart contract. After the transaction is identified in the blockchain, each node in the blockchain can execute the transaction respectively, so that the contract is executed respectively, and the state database is updated based on the execution of the contract.
In the related art, in order to increase a per second execution Transaction (TPS) index in a blockchain, it is necessary to increase the execution speed of a transaction. For this reason, the execution speed of the transaction can be increased by executing the transaction in parallel in the blockchain node. Generally, for transfer transactions, the block link points first divide the transactions into transaction groups according to the account accessed by the transaction, and the same account is not accessed between each transaction group, so that each transaction group can be executed in parallel. However, when a smart contract is invoked in a transaction, the variables accessed in the transaction cannot be predicted prior to execution of the transaction, so that multiple transactions cannot be effectively grouped, and thus transactions cannot be executed in parallel. In one embodiment, a first node (e.g., the master node 1 in fig. 1) in the blockchain may perform pre-execution on multiple transactions, obtain pre-execution read-write sets of the respective transactions, and send the pre-execution read-write sets to other nodes (e.g., slave nodes in fig. 1) in the blockchain through a consensus process with other nodes. Other nodes in the block chain can group the multiple transactions according to the pre-execution read-write sets of the multiple transactions, so that the multiple transactions can be executed in parallel according to the grouping result.
However, in the current blockchain, the above processes, including processing of client requests, consensus network communication, transaction execution, data storage, etc., are usually performed in a node through a single process, and as blockchain services are continuously developed, the blockchain nodes running the single process are limited by resources, such as physical resources and network resources, so that scalability, and throughput cannot meet the requirements of the services.
The embodiment of the specification provides a scheme for executing transactions in a blockchain, and services such as pre-execution service, caching service, consensus service, block management service and the like in blockchain nodes are respectively provided by a plurality of processes, so that the blockchain nodes have high scalability and high throughput.
Fig. 2 is an architecture diagram of a block link point in an embodiment of the present specification. As shown in fig. 2, a plurality of processes can be run in each of the master node 1 and the slave nodes (e.g., the slave node 2 shown in fig. 2) in the block chain shown in fig. 1 to provide a plurality of services. Specifically, the master node 1 may include a cache process 12 for providing a cache service, a pre-execution process 111 and a pre-execution process 112 for providing a pre-execution service, a consensus process 13 for providing a consensus service, a block management process 14 for providing a block management service, and the like. The pre-execution process 111 and the pre-execution process 112 are used to pre-execute transactions received by the master node in parallel. It is to be understood that, in the embodiment of the present specification, the master node 1 is not limited to include two pre-execution processes, but may include one pre-execution process or three or more pre-execution processes. In addition, an access process for providing an access service, a network process for providing a network service, a storage process for providing a storage service, and the like may be further included in the master node 1, which are not shown in fig. 2.
The slave node 2 may include a cache process 21 for providing a cache service, a consensus process 22 for providing a consensus service, a block management process 23 for providing a block management service, a calculation process 241 and a calculation process 242 for providing a transaction execution service, and the like. The computing process 241 and the computing process 242 are used to perform the execution of the transaction in the consensus proposal in parallel. It is to be understood that, in the embodiment of the present specification, the slave node 2 is not limited to include two computing processes, but may include one computing process or three or more computing processes.
The process is a running activity of a program with certain independent functions in an application with respect to a data set, namely the process is a process performed by a computer through sequential execution of instructions in the application program by a CPU. Each process is allocated its own memory address space at the time of creation, and the 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, computing process 241 is allocated memory 243, and computing process 242 is allocated memory 244.
The plurality of processes in the master node 1 may be a plurality of processes in a plurality of computing devices (or virtual computing nodes), or may be a plurality of 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. It should be noted that the solution provided by the embodiments of the present disclosure is not limited to the master-slave architecture blockchain system.
Fig. 3 is a flowchart of a method for performing a transaction in a blockchain in an embodiment of the present description. The method may be performed by the master node 1 in fig. 2.
As shown in fig. 3, first, in step S301, the cache process 12 in the master node 1 transmits a plurality of transactions to the pre-execution process 111.
As indicated above, the master node 1 may include, in addition to the processes shown in fig. 2, an access process that may receive transactions from the user equipment and send the received transactions to the cache process 12, so that the cache process 12 stores the transactions received from the access process in the memory 120 of the cache process 12 in a certain order. For example, the caching process 12 may store transactions in chronological order of receipt of the transactions, such as by storing the order of receipt of the transactions in a transaction queue stored in the memory 120.
A network process (not shown in fig. 2) may also be included in the master node 1, and the cache process 12 may send multiple transactions to the network process after receiving the multiple transactions, so that the network process broadcasts the multiple transactions to other nodes in the blockchain.
Meanwhile, for each pre-execution process (including the pre-execution process 111 and the pre-execution process 112), the cache process 12 may periodically send a preset number of batches of transactions in the transaction queue to the pre-execution process, so that the respective pre-executions are parallel to the transactions in the transaction queue. The cache process 12 may also send the order of the batch transaction in the transaction queue to the pre-execution process, so that the pre-execution process may execute the batch transaction serially according to the order of the batch transaction in the transaction queue.
In step S303, the pre-execution process 111 pre-executes a plurality of transactions to obtain a pre-execution read-write set of each transaction.
The pre-execution process 111 may first verify the signature of each transaction after receiving the plurality of transactions from the caching process 12, and perform pre-execution of the plurality of transactions after the verification is passed. The pre-execution process 111 serially executes the received plurality of transactions, e.g., the pre-execution process 111 may serially execute the plurality of transactions in the order in which the received plurality of transactions are arranged.
In the embodiment of the present specification, the memory 113 may store a first state set of a first part of variables in the blockchain, where the first part of variables includes variables defined in the blockchain account or the contract. The pre-execution process 111 may update the first state set of the local cache when a variable is read or written during the pre-execution transaction. The pre-execution process obtains a pre-execution read-write set of each of the plurality of transactions and a pre-execution sequence of the plurality of transactions after pre-executing the plurality of transactions. The set of pre-execution reads and writes for a transaction includes, for example, a set of pre-execution reads and a set of pre-execution writes, the set of pre-execution reads including key-value pairs of variables read in pre-execution for the transaction, and the set of pre-execution writes including key-value pairs of variables written in pre-execution for the transaction. The variable includes, for example, an external account in a blockchain, or a variable defined in a contract account. In one embodiment, the state database, the first state set, and the second state set store keys, values, and version numbers of values for respective variables. Thus, the key and version number of the variable being read may be included in the pre-executed read set of the transaction, and the key, value, and version number of the value of the variable being written may be included in the pre-executed write set of the transaction. The pre-execution process 111 adds 1 to the version number of the value of a variable each time the value of the variable is written.
The memory 120 of the caching process 12 stores a second state set of a second part of variables in the block chain, and the updating of the second state set can be described with reference to the subsequent steps in fig. 3. When each pre-execution process reads a variable in the process of pre-executing a transaction, firstly, whether the value of the variable is included in the first state set is determined, if not, whether the value of the variable is included in the second state set is determined, if not, the value of the variable is read from the state database, and the read value of the variable is stored in the first state set.
Specifically, the plurality of transactions include, for example, transaction Tx 1. Assuming that the transaction Tx1 includes a read operation on the variable a and a write operation on the variable b, when executing the read operation on the variable a in the transaction Tx1, the pre-execution process 111 first determines whether the value of the variable a is stored in the memory 113 of the pre-execution process 111, and in the case of storing the value of the variable a in the memory 113, may complete pre-execution on the transaction Tx1 based on the value of the variable a, and generate a pre-execution read-write set of the transaction Tx1, for example, the pre-execution read set of the transaction Tx1 includes the key-value pair of the variable a, and the pre-execution write set includes the key-value pair of the variable b. In generating the pre-execution read-write set of transaction Tx1, the pre-execution process 111 updates a first set of states in memory 113 based on the write set of transaction Tx1, storing in the first set of states the value of variable b that transaction Tx1 writes in pre-execution.
In another case, the pre-execution process 111 may request the cache process 12 to read the value of the variable a in the event that it is determined that the value of the variable a is not included in the first state set in the memory 113. After receiving the request, the caching process 12 determines whether the value of the variable a is included in the second state set in the memory 120, and if so, sends the value of the variable a to the pre-execution process 111. The pre-execution process 111 may, upon receiving the value of the variable a, store the value of the variable a into a first state set, so that it may be used to perform subsequent further transactions that read the variable a. If the value of the variable a is not included in the second state set, the caching process 12 notifies the pre-execution process 111, and the pre-execution process 111 reads the value of the current variable a from the state database, where the world state corresponding to the executed block is stored in the state database. The main node 1 further includes a storage process, for example, and the pre-execution process 11 may send a request for reading the variable a to the storage process, and after receiving the request, the storage process reads the value of the variable a in the state database and returns the value of the variable a to the pre-execution process 111. The pre-execution process 111, after receiving the value of the variable a from the storage process, similarly stores the value of the variable a into the first state set. The pre-execution process 111 stores the variable a value read from the outside of the memory 113 into the memory 113, so that the pre-execution process 111 can directly read the variable a value from the local memory when reading the variable a in the next transaction execution, thereby improving the transaction execution speed.
The pre-execution process 111, after execution completes each transaction, also generates a transaction receipt for the respective transaction.
In step S305, the pre-execution process 111 sends the pre-execution read-write set and the pre-execution order of the multiple transactions to the cache process 12.
After completing the pre-execution of the multiple transactions as described above, the pre-execution process 111 sends the obtained pre-execution read-write set and pre-execution order of the multiple transactions together to the caching process 12. In addition, the pre-execution process 111 also sends transaction receipts for each transaction to the caching process 12 for storage in the memory 120.
In step S307, the caching process 12 updates the local state based on the pre-execution read-write set of the plurality of transactions.
After receiving the pre-execution read-write set and the pre-execution sequence of the multiple transactions, the cache process 12, in the case that there is only one pre-execution process in the master node, because the pre-execution processes receive the variable values from the storage process for the pre-execution of the transactions when reading one variable for the first time, pre-execute the multiple transactions in series, update the local first state set of the pre-execution process along with the pre-execution of each transaction, and update the second state set through the pre-execution read-write sets of the multiple transactions, when setting the transaction arrangement sequence of the execution phase to be the same as the pre-execution sequence, make the pre-execution read-write set of each transaction consistent with the execution read-write set, and therefore, the first state set updated based on the pre-execution read-write set is also the latest world state in the master node 1. The caching process 12 can trust the pre-execution read-write set for the multiple transactions and can update the local second state set directly based on the pre-execution read-write set. After the update, the second state set also becomes the latest world state in the master node 1.
In the case where there are multiple pre-executed processes (e.g., pre-executed process 111 and pre-executed process 112 in fig. 2) in the master node, it is possible for two pre-executed processes to read or write the same variable at the same time during the parallel pre-executed transaction, which may result in the pre-executed result of one of the transactions not being based on the current latest world state in the master node 1, and thus lead to inconsistency between the pre-executed read-write set of the transaction and the executed read-write set of the transaction.
To this end, the caching process 12 may sequentially detect the set of pre-execution reads and writes for each transaction after receiving the set of pre-execution reads and writes for a plurality of transactions from the pre-execution process 111. Specifically, for transaction Tx1, for example, the caching process 12 first determines whether variable a in the pre-execution read set of transaction Tx1 is included in the second state set. 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 all of the variables in the pre-execution read set of transaction Tx1 are not included in the second state set, that is, the variables read by the transaction Tx1 have not been read or written by a transaction previously committed to the caching process 12, then it may be determined that the pre-execution read set of transaction Tx1 does not conflict with the second state set.
If the caching process 12 determines that the value of the variable a is included in the second state set, it is determined whether the value of the variable a in the pre-execution read set is consistent with the value of the variable a in the second state set, and if so, it indicates that the value of the variable a read by the transaction Tx1 is the latest state of the variable a in the pre-execution process. After the master node 1 determines that the value read is the most recent state in the pre-execution process for each variable in the transaction Tx1 pre-execution read, it may be determined that there is no conflict between the pre-execution read for the transaction Tx1 and the second set of states. In the event that it is sequentially determined that none of the pre-execution read sets of the plurality of transactions and the second state set conflict, the second state set may be updated based on the pre-execution read sets of the plurality of transactions.
If the caching process 12 determines that the value of the variable a in the pre-execution read set of the transaction Tx1 does not match the value of the variable a in the second state set, it indicates that the value of the variable a read by the transaction Tx1 is not the most recent state in the pre-execution process, and therefore, it may be determined that the pre-execution read set of the transaction Tx1 conflicts with the second state 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 that were pre-executed after the transaction Tx 1.
In addition, after receiving the pre-execution read-write set and the pre-execution order of the multiple transactions, the cache process 12 may store the pre-execution read-write set of the multiple transactions in the memory 120, and store the identifiers of the multiple transactions in the transaction queue according to the pre-execution order of the multiple transactions, so as to indicate the pre-execution order of the multiple transactions.
In step S309, the caching process 12 sends the pre-execution read-write set and the pre-execution order of the multiple transactions to the consensus process 13.
The consensus process 13 periodically calls an interface provided by the caching process 12 to request the caching process 12 to obtain a batch of transactions to be agreed for consensus. The cache process 12 sends a pre-execution read-write set of multiple transactions and a ranking order of the multiple transactions to the consensus process 13 in response to the request, where the ranking order is the pre-execution order of the multiple transactions. Wherein the caching process 12 can send the set of pre-executed reads and writes for each transaction in association with the hash value for each transaction. The caching process 12 may also send the pre-execution read-write sets of multiple transactions and the pre-execution order thereof to the consensus process when the pre-execution read-write sets of the transactions stored in the memory 120 reach a certain amount of data, or when the pre-execution read-write sets of the transactions stored in the memory 120 reach a certain amount of data.
In step S311, the consensus process 13 generates a consensus proposal to perform consensus with other nodes.
In different types of blockchain networks, in order to keep the ledger consistent among the nodes recording the ledger, a consensus algorithm is generally adopted to ensure, that is, a consensus mechanism. For example, a common mechanism of block granularity can be implemented between block nodes, such as after a node (e.g., a unique node) generates a block, if the generated block is recognized by other nodes, other nodes record the same block. For another example, a common recognition mechanism of transaction granularity may be implemented between the blockchain nodes, such as after a node (e.g., a unique node) acquires a blockchain transaction, if the blockchain transaction is recognized by other nodes, each node that recognizes the blockchain transaction may add the blockchain transaction to the latest blockchain maintained by itself, and finally, each node can be ensured to generate the same latest blockchain. The consensus mechanism is a mechanism for the blockchain node to achieve a global consensus on the block information (or called blockdata), which can ensure that the latest block is accurately added to the blockchain. The current mainstream consensus mechanisms include: proof of Work (POW), Proof of stock (POS), Proof of commission rights (DPOS), Practical Byzantine Fault Tolerance (PBFT) algorithm, etc. In various consensus algorithms, after a predetermined number of nodes agree on data to be agreed (i.e., a consensus proposal), it is determined that the consensus proposal is successful. Specifically, in the PBFT algorithm, f malicious nodes can be tolerated for N ≧ 3f +1 consensus nodes, that is, when 2f +1 nodes among the N consensus nodes agree, it can be determined that consensus is successful.
FIG. 4 is a schematic diagram of the consensus process in the PBFT consensus algorithm. As shown in fig. 4, according to the PBFT consensus algorithm, the consensus process can be divided into four phases of Request (Request), Prepare (Pre-Prepare), Prepare (Prepare), and Commit (Commit). For the block chain shown in fig. 1, according to the PBFT algorithm, if f is 1 malicious node, among the master node 1, the slave node 2, and the slave node 6, can be tolerated, so that it is determined that the consensus is successful when 5 nodes of the 6 nodes are required to reach an agreement. In particular, during the request phase, the user of the blockchain may send a transaction to the host node 1 through his user device as described above. In a preliminary stage, the master node 1 generates a consensus proposal, and in particular, in this embodiment of the present specification, the consensus proposal may include information such as a pre-execution readwrite set of multiple transactions and a pre-execution sequence of the multiple transactions received from the caching process 12, where each transaction in the consensus proposal may be identified by a transaction hash value.
The consensus process 13 may send the generated consensus proposal and the signature of the consensus proposal by the master node 1 to other consensus nodes (i.e. slave node 2-slave node 6) for generating blocks. Specifically, the consensus process 13 may send the consensus proposal and the signature to the network process, which sends the consensus proposal and the signature to other nodes. In addition, as described above, the caching process 12 has broadcast the received transactions to the slave nodes in a broadcast manner, and in this way, the host node 1 sends the consensus proposal to the slave nodes without including the transaction body of each transaction, so that the data amount of the consensus proposal is reduced, the calculation amount required by each node for digitally signing the consensus node in the consensus process is reduced, and the consensus efficiency is improved.
Still referring to fig. 4, during the preparation phase, various slave nodes may sign consensus offers and send to other various nodes. Assuming that the slave node 6 is a malicious node, the master node 1 and the slave nodes 2 to 5 may determine that the preparation phase is completed and may enter the commit phase after receiving the signatures of the consensus proposals for 2f ═ 2 other consensus nodes, respectively. For example, as shown in fig. 4, the master node 1 verifies that the signatures of the slave node 2 and the slave node 5 are both correct signatures for the consensus proposal after receiving the signatures of the slave node 2 and the slave node 5, and determines that the preparation phase is completed, and the slave node 2 determines that the preparation phase is completed after receiving the signatures of the slave node 3 and the slave node 5 and verifying the signatures of the master node 1. In the submission stage, each consensus node signs the consensus offer in the submission stage and sends the consensus offer to other consensus nodes, and after receiving the signatures of the submission stages of the other consensus nodes, each consensus node can determine that the submission stage is completed and the consensus is successful. For example, the master node 1 determines that the commit phase is completed and the consensus is successful after receiving the signatures of the commit phases of the slave nodes 2-5 and verifying them.
In step S313, the consensus process 13 sends a consensus proposal to the block management process 14.
The consensus process 13, after generating the consensus proposal, may send the consensus proposal to the block management process 14.
In step S315, the block management process 14 generates and submits a block.
Since the master node trusts that the pre-execution of the master node is not malicious and the pre-execution of the transaction in the master node is performed according to the correct world state, if the master node re-executes the multiple transactions according to the world state in the state database again, the resulting execution read-write sets of the multiple transactions and the pre-execution read-write sets of the multiple transactions are necessarily consistent. Therefore, the block management process 14 can directly regard the pre-execution read-write set of the multiple transactions as the execution read-write set for updating the world state in the state database without re-executing the multiple transactions once.
Thus, the block management process 14 can sequentially update the states of the respective accounts and the respective contract variables in the world state according to the write set and the pre-execution order in the pre-execution read-write set of the plurality of transactions in the consensus proposition, and update the values of the respective nodes in the state tree, including the state root ((i.e., the hash value of the root node of the state tree)), according to the updated world state. The block management process 14 may also obtain the transaction body and the transaction receipt of each of the plurality of transactions from the cache process 13 and generate a transaction root of a transaction tree (i.e., the hash value of the root node of the transaction tree) and a receipt root of the receipt tree (i.e., the hash value of the root node of the receipt tree) for the plurality of transactions, respectively.
Tile management process 14 may then generate a tile (e.g., tile B1) comprising the plurality of transactions, which tile B1 may comprise a tile block and a tile header, wherein the tile header may comprise information such as a tile number, a transaction root, a status root, a receipt root, etc., and the tile block may comprise a set of transaction blocks and a set of receipts for each transaction. After the chunk management process 14 generates the chunk, it may commit the chunk for storage in the chunk database of master node 1 in fig. 2. For example, block management process 14 may send the block to a storage process, such that the storage process stores the block in a block database.
Since the master node trusts its pre-executed 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 is understood that the block management process 14 may also perform the operations of updating the world state and generating and submitting the blocks after receiving the information that the consensus is successful from the consensus process 13.
Fig. 5 is a flowchart of a method for performing a transaction in a blockchain in an embodiment of the present description. The method may be performed by the slave node 2 in fig. 2.
As shown in fig. 5, first, in step S501, the consensus process 22 in the slave node 2 performs consensus with other nodes in the blockchain.
Similar to the master node 1, the slave node 2 may also include a receiving process through which the slave node 2 may receive transactions from the user equipment and a network process (not shown in fig. 2) through which transactions sent by other nodes may be received. The receiving process and the network process send the transaction to the caching process 21 after receiving the transaction so that the caching process 21 can store the received transaction in the form of a transaction queue in the memory 210. Similar to the master node 1, the cache process 21 may also send the transactions in the transaction queue to a network process for broadcast to other nodes in the blockchain.
The network process in the master node 1 sends the consensus proposal and the signature of the master node 1 to the network processes of the other respective nodes so that the network process in the slave node 2 can receive the consensus proposal and the signature of the master node 1 and send the consensus proposal and the signature of the master node 1 to the consensus process 22. The consensus process 22 begins the consensus process after receiving the consensus proposal and its signature. For a specific consensus process, reference may be made to the description above with reference to fig. 4, which is not repeated herein.
In step S503, the consensus process 22 sends a consensus proposal to the block management process 23.
After receiving the consensus proposal, the consensus proposal 22 may send it to the block management process 23 after signature verification to the primary node is passed.
In step S505, the block management process 23 groups the transactions according to consensus proposals, and assigns the groups to the computing processes.
The block management process 23 may group the multiple transactions according to the set of pre-executed reads and writes in the consensus proposition such that all transactions in every two groups do not access the same variable, thereby allowing the groups to execute in parallel, with the multiple transactions in each group being arranged in their pre-execution order. After grouping is completed, the tile management process 23 may evenly distribute the grouped groups to the computing processes. For example, in the case where only the computing process 241 and the computing process 242 are included in the slave node 2, half of the number of components in the plurality of groups may be given to the computing process 241 and the other half of the number of components may be given to the computing process 242.
It is to be understood that the grouping of multiple transactions by the block management process 23 is not limited in this embodiment, for example, the consensus process 22 may group multiple transactions according to a set of pre-executed reads and writes of multiple transactions, and send the consensus proposal and the grouping result to the block management process 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 within the group to each process.
In step S509, the computing process executes the transaction, updating the state database.
Taking the computing process 241 as an example, the tile management process 23 may assign one or more groups to the computing process 241. In the case where the tile management process 23 assigns a plurality of groups to the calculation process 241, the plurality of groups can be concurrently processed by a plurality of threads in the calculation process 241. Meanwhile, the computing process 241 serially executes the plurality of transactions in one group in a pre-execution order of the plurality of transactions in one group.
Specifically, as shown in fig. 2, the calculation process 241 includes a memory 243, before the calculation process 241 starts executing the transactions of the plurality of groups, the calculation process 241 may determine all variables that need to be read according to the read sets of all transactions in the plurality of groups, and perform batch (for example, one-time) reading on all the variables from the state database, and after the states (i.e., world states) of all the variables are read, the process 241 may store the values of all the variables in the form of key-value pairs in a third state set in the memory 243. The computing process 241 may then perform the transactions in the various groups based on the third set of states. The calculation process 241 reads the value of the variable from the third state set when performing an operation of reading the variable according to the transaction, updates the value of the variable in the third state set to the value written this time when performing an operation of writing the variable according to the transaction, and generates an execution read/write set of the transaction based on this. 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, key-value pairs trading variables read during execution, and the execution write set includes, for example, key-value pairs trading variables written during execution. By means of batch pre-reading, the parameter that needs to be read from the status database is stored in the local memory 243 by the computing process 241 in advance, so that the computing process 241 can directly read the status from the memory in the transaction executing process without reading the status from the memory, thereby greatly increasing the transaction executing speed.
Since the groups do not access the same variables as each other, i.e., there are no conflicting transactions, the computing process 241, upon completing execution of all transactions in a group, can immediately update the world state in the state database according to the execution set of the individual transactions of the group without affecting the execution of the transactions of the other groups. And meanwhile, the transaction execution speed is improved.
In step S511, the block management process 23 generates and submits a block.
The tile management process 23 updates the values of the various nodes in the state tree, including the state root ((i.e., the hash value of the root node of the state tree)), according to the updated world state after determining that each computing process completed performing transactions and updating the state for the group assigned thereto. The block management process 23 may also obtain the transaction body and the transaction receipt of each of the plurality of transactions from the cache process 21 and generate a transaction root of a transaction tree (i.e., a hash value of a root node of the transaction tree) and a receipt root of the receipt tree (i.e., a hash value of a root node of the receipt tree) for the plurality of transactions, respectively.
Tile management process 23 may then generate a tile (e.g., tile B1) comprising the plurality of transactions, which tile B1 may comprise a tile block and a tile header, wherein the tile header may comprise information such as a tile number, a transaction root, a status root, a receipt root, etc., and the tile block may comprise a set of transaction blocks and a set of receipts for each transaction. After the block management process 23 generates a block, the block may be committed for storage in the block database of slave node 2 in fig. 2.
Through the process, the storage consistency of each node in the block chain is realized, and meanwhile, the multi-process architecture in the block chain nodes is utilized, so that the execution speed of transaction can be further accelerated by using the advantages of the multi-process architecture, and the system efficiency of the block chain is improved.
An embodiment of the present specification further provides a first node in a block chain, where a first pre-execution process, a cache process, and a first common process are run in the first node, and are used to execute the method shown in fig. 3.
The cache process is used for sending the received multiple transactions to the first pre-execution process, and the latest world state of at least part of variables in the block chain is stored in a memory of the cache process;
the first pre-execution process is used for pre-executing the multiple transactions, obtaining pre-execution read-write sets of the multiple transactions and pre-execution sequences of the multiple transactions, and sending the pre-execution read-write sets and the pre-execution sequences of the multiple transactions to the cache process, wherein the first pre-execution process is also used for receiving the state of a variable requested to be read in the first transaction from the cache process when the first transaction in the multiple transactions is pre-executed;
the cache process is used for sending the pre-execution read-write sets of the multiple transactions and the pre-execution sequence of the multiple transactions to the first consensus process, and updating currently stored world state data in a memory of the cache process based on the pre-execution read-write sets of the multiple transactions;
the first consensus process is configured to generate a consensus offer, the consensus offer being sent to a second node in the blockchain, the consensus offer including a pre-execution read-write set of the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to the pre-execution sequence.
An embodiment of the present specification further provides a second node in the block chain, where a second consensus process, a second block management process, and N computation processes are run in the second node, and are used to execute the method shown in fig. 5.
The second consensus process is configured to receive a consensus offer from the first node, send the consensus offer to the second block management process, the consensus offer including a set of pre-executed reads for the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to a pre-executed sequence of the plurality of transactions;
the second block management process is used for dividing the transactions into a plurality of transaction groups according to the pre-execution read-write set, distributing the transaction groups to the N computing processes, and sending the arrangement sequence of the transactions to the N computing processes;
the N computing processes are used for executing the transactions in the transaction group distributed to the N computing processes according to the arrangement sequence.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain a corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
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 (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller in purely computer readable program code means, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be conceived to be both a software module implementing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a server system. Of course, this application does not exclude that with future developments in computer technology, the computer implementing the functionality of the above described embodiments may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device or a combination of any of these devices.
Although one or more embodiments of the present description provide method operational steps as described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive approaches. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an actual apparatus or end product executes, it may execute sequentially or in parallel (e.g., parallel processors or multi-threaded environments, or even distributed data processing environments) according to the method shown in the embodiment or the figures. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, article, or apparatus that comprises the recited elements is not excluded. For example, if the terms first, second, etc. are used to denote names, they do not denote any particular order.
For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. Of course, when implementing one or more of the present description, the functions of each module may be implemented in one or more software and/or hardware, or a module implementing the same function may be implemented by a combination of multiple sub-modules or sub-units, etc. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
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 flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams 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 apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
As will be appreciated by one skilled in the art, 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 combining software and hardware aspects. Furthermore, one or more embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
One or more embodiments of the 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 particular tasks or implement particular abstract data types. One or more embodiments of the present specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment. In the description of the specification, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the specification. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
The above description is merely exemplary of one or more embodiments of the present disclosure and is not intended to limit the scope of one or more embodiments of the present disclosure. Various modifications and alterations to one or more embodiments described herein will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of the present specification should be included in the scope of the claims.

Claims (13)

1. A method of performing a transaction in a blockchain, the blockchain including a first node and a second node, the first node having a first pre-execution process, a caching process, and a first consensus process running therein, the method performed by the first node comprising:
the cache process sends the received multiple transactions to the first pre-execution process, and the current state of at least part of variables in the block chain is stored in a memory of the cache process;
the first pre-execution process pre-executes the multiple transactions to obtain pre-execution read-write sets of the multiple transactions and pre-execution sequences of the multiple transactions, and sends the pre-execution read-write sets and the pre-execution sequences of the multiple transactions to the cache process, wherein when a first transaction in the multiple transactions is pre-executed, the first pre-execution process receives the state of a variable requested to be read in the first transaction from the cache process;
the cache process sends the pre-execution read-write sets of the multiple transactions and the pre-execution sequence of the multiple transactions to the first consensus process, and updates state data stored in a memory of the cache process based on the pre-execution read-write sets of the multiple transactions;
the first consensus process generates a consensus offer that is sent to a second node in the blockchain, the consensus offer including a pre-execution read-write set of the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to the pre-execution sequence.
2. The method of claim 1, the first pre-execution process pre-executing the plurality of transactions comprising: when the first pre-execution process pre-executes the first transaction and when the state of the variable requested to be read by the first transaction is determined not to be stored in the memory of the first pre-execution process, the state of the variable requested to be read in the first transaction is received from the cache process, and the state data stored in the memory of the first pre-execution process is updated based on the pre-execution read-write set of the first transaction.
3. The method of claim 2, the first pre-execution process pre-executing the plurality of transactions comprising: when the first pre-execution process pre-executes a second transaction in the plurality of transactions, pre-executing the second transaction based on state data stored in a memory of the first pre-execution process.
4. The method of claim 1, the first node having a second pre-executed process running therein, the method further comprising: and the cache process verifies the read sets in the pre-execution read-write sets of the multiple transactions according to the state data currently stored in the memory of the cache process, stores the pre-execution read-write sets of the multiple transactions and the pre-execution sequence of the multiple transactions in the memory of the cache process when the verification is passed, and updates the state data currently stored in the memory of the cache process based on the pre-execution read-write sets of the multiple transactions.
5. The method of claim 1, the first pre-execution process pre-executing the plurality of transactions comprising: when the first pre-execution process pre-executes a third transaction in the multiple transactions, 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, the state of the variable read by the third transaction request is read from a state database.
6. The method of claim 1, the first node further having a first block management process running therein, the method further comprising: and the first block management process updates a state database according to the pre-execution read-write sets of the transactions and the arrangement sequence of the transactions, and generates and stores a block.
7. A method of performing a transaction in a blockchain, the blockchain including a first node and a second node having a second consensus process, a second blockmanagement process, and N computing processes running therein, the method performed by the second node, comprising:
the second consensus process receiving a consensus offer from the first node, sending the consensus offer to the second block management process, the consensus offer comprising a set of pre-executed reads for the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to a pre-executed sequence of the plurality of transactions;
the second block management process divides the plurality of transactions into a plurality of transaction groups according to the pre-execution read-write set, allocates the plurality of transaction groups to the N computing processes, and sends the arrangement sequence of the plurality of transactions to the N computing processes;
and the N computing processes respectively execute the transactions in the transaction group distributed to the N computing processes according to the arrangement sequence.
8. The method of claim 7, the N computing processes respectively executing transactions in their assigned transaction groups according to the rank order comprising: and a first computing process in the N computing processes reads the state data from the state database according to the pre-execution reading sets of all transactions in the transaction group allocated to the first computing process, and stores the read state data into the memory of the first computing process.
9. The method of claim 8, further comprising: the second block management process sends the pre-execution read-write sets of the transactions distributed to the computing processes;
the N computing processes respectively executing the transactions in the transaction group assigned thereto according to the ranking order include: the first computing process obtains an execution read-write set of the first transaction after executing the first transaction in the transaction group allocated to the first computing process, compares whether the execution read-write set of the first transaction is consistent with a pre-execution read-write set of the first transaction, and updates state data currently stored in a memory of the first computing process according to the execution read-write set of the first transaction in the case of consistency.
10. The method of claim 9, further comprising: the first computing process, after executing all transactions assigned thereto, updates the world state in the state database according to the execution write set of all transactions assigned thereto.
11. A first node in a blockchain, in which a first pre-execution process, a caching process and a first consensus process run,
the cache process is used for sending the received multiple transactions to the first pre-execution process, and the current state of at least part of variables in the block chain is stored in a memory of the cache process;
the first pre-execution process is used for pre-executing the multiple transactions, obtaining pre-execution read-write sets of the multiple transactions and pre-execution sequences of the multiple transactions, and sending the pre-execution read-write sets and the pre-execution sequences of the multiple transactions to the cache process, wherein the first pre-execution process is also used for receiving the state of a variable requested to be read in the first transaction from the cache process when the first transaction in the multiple transactions is pre-executed;
the cache process is used for sending the pre-execution read-write sets of the multiple transactions and the pre-execution sequence of the multiple transactions to the first consensus process, and updating state data stored in a memory of the cache process based on the pre-execution read-write sets of the multiple transactions;
the first consensus process is configured to generate a consensus offer, the consensus offer being sent to a second node in the blockchain, the consensus offer including a pre-execution read-write set of the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to the pre-execution sequence.
12. A second node in the block chain, in which a second consensus process, a second block management process and N calculation processes are running,
the second consensus process is configured to receive a consensus offer from the first node, send the consensus offer to the second block management process, the consensus offer including a set of pre-executed reads for the plurality of transactions and an ordered sequence of the plurality of transactions, the ordered sequence corresponding to a pre-executed sequence of the plurality of transactions;
the second block management process is used for dividing the transactions into a plurality of transaction groups according to the pre-execution read-write set, distributing the transaction groups to the N computing processes, and sending the arrangement sequence of the transactions to the N computing processes;
the N computing processes are used for executing the transactions in the transaction group distributed to the N computing processes according to the ranking sequence.
13. A computer-readable storage medium, on which a computer program is stored which, when executed in a computer, causes the computer to carry out the method of any one of claims 1-10.
CN202210602790.5A 2022-05-30 2022-05-30 Method for executing transaction and block link point Pending CN114942847A (en)

Priority Applications (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
PCT/CN2022/135262 WO2023231336A1 (en) 2022-05-30 2022-11-30 Method for executing transaction and blockchain node

Applications Claiming Priority (1)

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

Publications (1)

Publication Number Publication Date
CN114942847A true CN114942847A (en) 2022-08-26

Family

ID=82909983

Family Applications (1)

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

Country Status (2)

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

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116308772A (en) * 2022-12-16 2023-06-23 蚂蚁区块链科技(上海)有限公司 Transaction distribution method, node and blockchain system
WO2023231336A1 (en) * 2022-05-30 2023-12-07 蚂蚁区块链科技(上海)有限公司 Method for executing transaction and blockchain node
WO2024066011A1 (en) * 2022-09-30 2024-04-04 蚂蚁区块链科技(上海)有限公司 Consensus node type conversion method and consensus node
WO2024066019A1 (en) * 2022-09-30 2024-04-04 蚂蚁区块链科技(上海)有限公司 Transaction execution method in blockchain system, consensus node, and blockchain system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113743942B (en) * 2021-11-04 2023-06-02 支付宝(杭州)信息技术有限公司 Transaction execution method, blockchain, master node and master storage device
CN113743941B (en) * 2021-11-04 2022-08-26 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain, block chain and main node
CN114942847A (en) * 2022-05-30 2022-08-26 蚂蚁区块链科技(上海)有限公司 Method for executing transaction and block link point
CN114827165B (en) * 2022-05-30 2024-01-23 蚂蚁区块链科技(上海)有限公司 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

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023231336A1 (en) * 2022-05-30 2023-12-07 蚂蚁区块链科技(上海)有限公司 Method for executing transaction and blockchain node
WO2024066011A1 (en) * 2022-09-30 2024-04-04 蚂蚁区块链科技(上海)有限公司 Consensus node type conversion method and consensus node
WO2024066019A1 (en) * 2022-09-30 2024-04-04 蚂蚁区块链科技(上海)有限公司 Transaction execution method in blockchain system, consensus node, and blockchain system
CN116308772A (en) * 2022-12-16 2023-06-23 蚂蚁区块链科技(上海)有限公司 Transaction distribution method, node and blockchain system
CN116308772B (en) * 2022-12-16 2023-10-13 蚂蚁区块链科技(上海)有限公司 Transaction distribution method, node and blockchain system

Also Published As

Publication number Publication date
WO2023231336A1 (en) 2023-12-07

Similar Documents

Publication Publication Date Title
CN114942847A (en) Method for executing transaction and block link point
CN114827165B (en) Method and block link point for grouping multiple transactions
CN113743941B (en) Method for executing transaction in block chain, block chain and main node
CN113743940B (en) Method for executing transaction in block chain, main node and slave node
CN113743950B (en) Method, node and blockchain system for performing transactions in blockchain system
CN113168652B (en) Block chain transaction processing system and method
CN114936256A (en) Method for executing transaction in block chain and block chain link point
WO2023231335A1 (en) Method for executing transaction in blockchain, and master node of blockchain
WO2023231337A1 (en) Method for executing transaction in blockchain, and master node and slave node of blockchain
WO2023160083A1 (en) Method for executing transactions, blockchain, master node, and slave node
WO2024001024A1 (en) Method for executing transaction in blockchain system, and blockchain system and nodes
CN114710507A (en) Consensus method and block link point
CN113743942A (en) Transaction execution method, block chain, main node and main storage device
CN114547203A (en) Method for executing transaction, block chain, main node and slave node
CN113744062B (en) Method for performing transactions in a blockchain, blockchain node and blockchain
CN113744063B (en) Method and device for executing transaction in block chain
WO2021045829A1 (en) Byzantine consensus without centralized ordering
CN113994324B (en) Block chain system with efficient world state data structure
WO2024001032A1 (en) Method for executing transaction in blockchain system, and blockchain system and nodes
CN113454597A (en) Block chain transaction processing system and method
CN113744061B (en) Method for performing transactions in a blockchain system, and slave node
CN115098483A (en) Pre-execution cache data cleaning method and block link point
CN115640356A (en) Transaction execution method in blockchain system, consensus node and blockchain system
CN116997895A (en) Reducing transaction aborts in an execution ordering validation blockchain model
CN115398397A (en) Block chain transaction processing system and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination