Transaction processing method in blockchain, and blockchain node
By verifying and storing transactions in slave nodes, the problem of transaction loss when converting from slave nodes to master nodes is solved, and the efficiency and stability of blockchain transaction processing is improved.
Patent Information
- Application Number
- PCT/CN2023/135057
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-31
- Filing Date
- 2023-11-29
- Publication Date
- 2024-12-05
AI Technical Summary
In the blockchain system, the slave node may cause transaction loss when the master node fails, and the client needs to resend transactions, which affects the transaction processing efficiency.
After receiving the transaction, the slave node verifies according to the stored instructions information, without pre-execution, and stores the transaction after verification is passed, so that when the master node fails, it can directly use the verified transaction to make consensus, avoiding transaction loss.
It improves transaction processing efficiency in blockchain, avoids transaction loss and client resend transactions, and ensures transaction stability and efficiency.
Smart Images

Figure CN2023135057_05122024_PF_FP_ABST
Abstract
Description
Transaction processing methods and blockchain nodes in blockchain
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on May 31, 2023, with application number 202310640782.4 and application name “Transaction Processing Method and Blockchain Node in Blockchain”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of this specification belong to the field of blockchain technology, and more particularly to a transaction processing method and blockchain node in a blockchain. Background Art
[0003] Blockchain is a novel application model for computer technologies, including distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. In a blockchain system, data blocks are linked sequentially in chronological order to form a chain-like data structure, cryptographically guaranteeing an unalterable and unforgeable distributed ledger. Due to its decentralized, tamper-proof, and autonomous nature, blockchain is gaining increasing attention and application.
[0004] Summary of the Invention
[0005] The purpose of the present invention is to provide a transaction processing method in a blockchain to improve the transaction processing efficiency in the blockchain.
[0006] A first aspect of this specification provides a transaction processing method in a blockchain, performed by a first node, where the first node is currently a slave node, the method comprising:
[0007] Acquire a first transaction and first information stored locally, where the first information is used to indicate disabling a pre-execution function;
[0008] verifying the first transaction according to the first information;
[0009] If the verification is successful, the first transaction is stored.
[0010] A second aspect of this specification provides a blockchain node, which is currently a slave node and includes:
[0011] an acquiring unit, configured to acquire a first transaction and first information stored locally, wherein the first information is used to indicate disabling of a pre-execution function;
[0012] a verification unit, configured to verify the first transaction based on the first information;
[0013] The storage unit is configured to store the first transaction if the verification is successful.
[0014] A third aspect of this specification provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute the method described in the first aspect.
[0015] A fourth aspect of this specification provides a blockchain node, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in the first aspect is implemented.
[0016] In the solution provided in the embodiments of this specification, the slave node stores the transaction in the transaction queue after the transaction is verified according to the instruction information stored in the slave node, so that when the slave node is converted from a slave node to a master node, it can obtain the verified transaction from the verified transaction queue for pre-execution without losing the transaction, avoiding the need for the client to resend the transaction, and improving the transaction processing efficiency in the blockchain. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] FIG1 is a diagram of a blockchain architecture in one embodiment;
[0019] FIG2 is a flow chart of a transaction processing method in a blockchain according to an embodiment of this specification;
[0020] FIG3 is a flow chart of a transaction processing method in a blockchain according to an embodiment of this specification;
[0021] FIG4 is a flow chart of a transaction processing method in a blockchain according to another embodiment of this specification;
[0022] FIG5 is a flow chart of a transaction processing method in a blockchain according to another embodiment of this specification;
[0023] FIG6 is an architectural diagram of a blockchain node in an embodiment of this specification. DETAILED DESCRIPTION
[0024] To help those skilled in the art better understand the technical solutions in this specification, the following will provide a clear and complete description of the technical solutions in the embodiments of this specification, in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. All other embodiments derived by those skilled in the art based on the embodiments in this specification without creative effort shall fall within the scope of protection of this specification.
[0025] Figure 1 illustrates a blockchain architecture diagram in one embodiment. In the blockchain architecture diagram shown in Figure 1 , the blockchain includes N nodes, with nodes 1 through 8 schematically illustrated. The lines between the nodes schematically represent P2P (peer-to-peer) connections, such as TCP connections, for transmitting data between nodes. These nodes can store the full ledger, i.e., the status of all blocks and all accounts. Each node in the blockchain can generate the same state in the blockchain by executing the same transactions, and each node in the blockchain can store the same state database.
[0026] A transaction in the blockchain field can refer to a task unit executed and recorded in the blockchain. A transaction typically includes a sender field (From), a receiver field (To), and a data field (Data). In the case of a transfer transaction, the From field indicates the address of the account initiating the transaction (i.e., initiating a transfer task to another account), the To field indicates the address of the account receiving the transaction (i.e., receiving the transfer), and the Data field includes the transfer amount.
[0027] Blockchains offer smart contract functionality. Smart contracts on blockchains are contracts that can be triggered and executed by transactions within the blockchain system. Smart contracts can be defined in code. Calling a smart contract on a blockchain involves initiating a transaction to the smart contract address, allowing each node in the blockchain to execute the smart contract code in a distributed manner.
[0028] In a contract deployment scenario, for example, Bob sends a transaction containing information about creating a smart contract (i.e., deploying a contract) to the blockchain shown in Figure 1. The transaction's data field includes the code for the contract to be created (such as bytecode or machine code), and the transaction's to field is empty, indicating that the transaction is for contract deployment. After the nodes reach consensus through a consensus mechanism, they determine the contract address "0x6f8ae93..." Each node adds a contract account corresponding to the smart contract's contract address to the state database, allocates state storage corresponding to the contract account, stores the contract code, and saves the hash value of the contract code in the contract's state storage, thus successfully creating the contract.
[0029] In the contract invocation scenario, for example, Bob sends a transaction to invoke a smart contract to the blockchain shown in Figure 1. The transaction's "from" field is the address of the account of the transaction initiator (Bob), the "to" field is the aforementioned "0x6f8ae93...", the address of the invoked smart contract, and the transaction's "data" field includes the method and parameters for invoking the smart contract. After consensus is reached on the blockchain, each node in the blockchain can execute the transaction, thereby executing the contract and updating the state database based on the contract's execution.
[0030] One of the decentralized features that distinguishes blockchain technology from traditional technologies is that it maintains ledgers on individual nodes, or distributed ledgers, rather than traditional centralized ledgers. For a blockchain system to be a decentralized, trustworthy, and impenetrable system with public, tamper-proof data records, it must ensure that distributed data records are secure, unambiguous, and irreversible in the shortest possible time. In various blockchain networks, consensus algorithms—the aforementioned consensus mechanisms—are often employed to ensure ledger consistency across all nodes. For example, blockchain nodes can implement block-level consensus mechanisms. For example, when a node (e.g., a unique node) generates a block, if the generated block is recognized by other nodes, the other nodes will record the same block. Another example is transaction-level consensus mechanisms. For example, when a node (e.g., a unique node) obtains a blockchain transaction, if the transaction is recognized by other nodes, each node that recognized the transaction can add the transaction to its own latest block, ultimately ensuring that all nodes generate the same latest block. A consensus mechanism is a network-wide consensus among blockchain nodes on block information (or block data), ensuring that the latest block is accurately added to the blockchain. Current mainstream consensus mechanisms include Proof of Work (POW), Proof of Stake (POS), Delegated Proof of Stake (DPOS), and Practical Byzantine Fault Tolerance (PBFT). Consensus on a consensus proposal is typically considered successful when a predetermined number of nodes reach agreement on the data to be agreed upon (i.e., the consensus proposal). Specifically, in the PBFT algorithm, for a set number of consensus nodes (3(f+1)+1>N≥3f+1), f malicious nodes can be tolerated. This means that consensus is considered successful when at least 2f+1 of the N consensus nodes reach agreement.
[0031] The blockchain shown in Figure 1 may include a master node and slave nodes. In a scenario where transactions are executed in parallel, the master node can pre-execute multiple transactions, obtaining pre-execution read / write sets for the multiple transactions. It can then send a consensus proposal including these multiple transactions and their pre-execution read / write sets to each slave node. After reaching consensus on the consensus proposal, each slave node can group the multiple transactions according to their pre-execution read / write sets and execute them in parallel based on the grouping results. In this scenario, after receiving transactions from clients, the slave nodes typically forward the received transactions to the master node, allowing the master node to pre-execute the transactions. However, if the master node fails and needs to be replaced, the slave node does not store the batch of transactions already received from the client, resulting in the loss of this batch of transactions. The client must re-send the batch of transactions to the blockchain, affecting business efficiency.
[0032] Embodiments of this specification provide a method for processing transactions in a blockchain, wherein, after receiving a transaction, a slave node verifies the received transaction based on its role-related information without pre-executing the transaction, and stores the transaction after verification. This allows the slave node to directly obtain the verified transaction locally for consensus on the transaction in the event of a master node failure, thereby improving transaction processing efficiency in the blockchain.
[0033] Figure 2 is a flow chart of a transaction processing method in a blockchain according to an embodiment of the present specification. The method can be executed by, for example, node 1 in the blockchain, where node 1 is currently a slave node.
[0034] As shown in Figure 2, first, in step S210, node 1 obtains information m1 and transaction Tx1, wherein information m1 is stored after node 1 is set as a slave node, and is used to indicate that the pre-execution function is turned off, that is, to instruct node 1 to verify the transaction after receiving it and not to perform pre-execution.
[0035] After node 1 determines that its identity is converted from a master node to a slave node, or when node 1 determines that its identity is a slave node during initial startup, it can store information m1 in a local preset location to instruct node 1 to verify the transaction after receiving it without pre-execution.
[0036] Node 1 can receive transaction Tx1 from a client. Different nodes in a blockchain can receive different transactions from multiple clients. After receiving transaction Tx1, node 1 can retrieve information related to transaction preprocessing from its local storage. If information m1 is stored locally, it can also retrieve this information from its local storage.
[0037] In step S220, after reading the information m1, node 1 verifies the transaction Tx1 according to the instructions of the information m1.
[0038] The verification of the transaction includes, for example, verification of the transaction signature, verification of the GAS balance of the transaction sending account, verification of the legitimacy of the transaction, etc. According to information m1, node 1 only verifies transaction Tx1 without performing pre-execution.
[0039] In step S230, if the verification is successful, node 1 stores transaction Tx1.
[0040] When Node 1 verifies transaction Tx1, it can store it in, for example, a verified transaction queue. While storing Tx1, Node 1 also sends it to the current master node so that the master node can pre-execute it.
[0041] When node 1 is converted from a master node to a slave node, node 1 also includes a pre-execution transaction queue stored when it was a master node. The pre-execution transaction queue stores verified and pre-executed transactions. Node 1 can send the transactions in the pre-execution transaction queue to the current master node so that the master node can re-pre-execute these transactions and reach consensus on these transactions.
[0042] FIG3 is a flow chart of a transaction processing method in a blockchain according to an embodiment of the present specification. This method corresponds to the method shown in FIG2 . This method may be implemented by, for example, a consensus service, a cache service, and a pre-execution service in node 1. Each service includes multiple executables (e.g., processes) for implementing the preset functions of the service, and the multiple processes included in each service may be executed in parallel.
[0043] As shown in FIG3 , in step S301 , the consensus service determines that node 1 is a slave node.
[0044] After being enabled, Node 1 can negotiate with other consensus nodes to determine itself as a slave node. Alternatively, if Node 1 fails while serving as a master node and is identified by other consensus nodes as a slave node, Node 1 can obtain information from other consensus nodes indicating its status as a slave node after recovery. After determining that it is a slave node, Node 1 can provide this information to the consensus service.
[0045] In step S303 , the cache service caches the transaction received from the user device.
[0046] Node 1 can be connected to a user device to receive a transaction (e.g., the transaction Tx1) from a client of the user device, and the cache service can cache the transaction Tx1. Specifically, the cache service can store the transaction Tx1 in an unverified transaction queue.
[0047] In step S305, the consensus service calls the disable interface provided by the cache service.
[0048] The disable interface is used to set instruction information, which is used to indicate to disable the pre-execution function, that is, only verify the received transaction without pre-execution.
[0049] In step S307, in response to the call to the disable interface, the cache service sets the value of the variable flag to a preset value for indicating that the pre-execution function is disabled.
[0050] In response to the consensus service's call to the disable interface, the cache service executes the disable interface and sets the variable flag in the cache service to a preset value (e.g., 1) for indicating that the pre-execution function is turned off, where the value of the variable flag before the setting is, for example, the default value, or in the case where node 1 is transformed from a master node to a slave node, the value of the variable flag before the setting is a preset value (e.g., 0) for indicating that the pre-execution function is turned on.
[0051] In step S309 , the pre-execution service requests a transaction from the cache service.
[0052] The pre-execution service may request a newly received transaction from the cache service to pre-process the transaction.
[0053] In step S311 , the cache service sends a transaction Tx1 and a preset value of the variable flag to the pre-execution service for indicating that the pre-execution operation is closed.
[0054] In response to the request from the pre-execution service, the cache service obtains several transactions from the cached transactions and sends the transactions and "flag=1" to the pre-execution service. The transactions include, for example, transaction Tx1. The following steps are described using transaction Tx1 as an example.
[0055] In step S313 , after receiving the transaction Tx1 and “flag=1”, the pre-execution service verifies the received transaction Tx1 according to “flag=1” without performing pre-execution.
[0056] In step S315 , if the pre-execution service verifies the transaction Tx1 successfully, it may send the verification result to the cache service.
[0057] In step S317, if the cache service determines that the verification is successful based on the received verification result, the transaction Tx1 is placed in the verified transaction queue.
[0058] In one embodiment, when slave node 1 determines that it has been converted from a master node to a slave node, since the pre-execution service in the slave node turns off the pre-execution function and only retains the verification function, the number of pre-execution service instances (such as the number of processes) can be reduced, thereby achieving the effect of dynamic scaling.
[0059] The slave node pre-processes the received transaction as shown in FIG2 or FIG3, and stores the transaction in the transaction queue according to the flag value after the transaction is verified. In this way, when the slave node is converted from a slave node to a master node, it can obtain the verified transaction from the verified transaction queue for pre-execution without losing the transaction, avoiding the need for the client to resend the transaction, and improving the transaction processing efficiency in the blockchain.
[0060] Figure 4 is a flow chart of a transaction processing method in a blockchain according to an embodiment of the present specification. The method can be executed by, for example, node 2 in the blockchain, where node 2 is currently the master node.
[0061] As shown in Figure 4, first, in step S410, node 2 obtains information m2 and transaction Tx2, wherein information m2 is stored after node 2 is set as the master node, and is used to indicate the start of the pre-execution function, that is, verifying the transaction after receiving it, and pre-executing the transaction after the verification is passed.
[0062] After node 2 determines that its identity has been converted from a slave node to a master node, or when node 2 determines that its identity is a master node during initial startup, it can store information m2 in a local preset location to instruct node 2 to enable the pre-execution function, that is, to verify and pre-execute the transaction after receiving the transaction.
[0063] Node 2 may receive transaction Tx2 from a client or other consensus node. Different nodes in the blockchain may receive different transactions from multiple clients. After receiving transaction Tx2, node 2 may retrieve information related to transaction preprocessing from its local storage. If information m2 is stored locally, this information may be retrieved from the local storage.
[0064] In step S420, after reading the information m2, node 2 verifies the transaction Tx2 according to the instructions of the information m2, and pre-executes the transaction Tx2 if the verification passes.
[0065] As described above, the transaction verification includes, for example, verification of the transaction signature, verification of the GAS balance of the transaction sending account, verification of the transaction legitimacy, etc. After node 2 verifies transaction Tx2, it pre-executes transaction Tx2. Specifically, node 2 can execute transaction Tx2 based on the state value read from the state database, obtaining a pre-execution read-write set for transaction Tx2. The pre-execution read-write set includes a pre-execution read set and a pre-execution write set. The pre-execution read set includes the variable keys or key-value pairs read by node 2 during the pre-execution of transaction Tx2, and the pre-execution write set includes the variable keys or key-value pairs updated by node 2 during the pre-execution of transaction Tx2.
[0066] In step S430 , node 2 stores transaction Tx2 and its pre-execution read-write set.
[0067] After completing pre-execution of transaction Tx2, node 2 can store transaction Tx2 and its pre-execution read-write set in the pre-execution transaction queue. Node 2 can then retrieve a batch of transactions and their read-write sets from the pre-execution transaction queue and generate a consensus proposal. This consensus proposal can include the batch of transactions and their read-write sets, and node 2 can send this consensus proposal to each slave node for consensus.
[0068] In the case where node 2 is converted from a slave node to a master node, node 2 also includes a verified transaction queue stored when it was a slave node. The transaction queue stores verified and non-pre-executed transactions. Node 2 can re-pre-execute transactions in the verified transaction queue and store these transactions and their pre-executed read-write sets in the pre-executed transaction queue.
[0069] FIG5 is a flow chart of a transaction processing method in a blockchain according to an embodiment of the present specification. This method corresponds to the method shown in FIG4 and may be implemented by, for example, a consensus service, a cache service, and a pre-execution service in node 2. Each service includes multiple executables (e.g., processes) for implementing the preset functions of the service, and the multiple processes included in each service may be executed in parallel.
[0070] As shown in FIG5 , in step S501 , the consensus service determines node 2 as the master node.
[0071] After being enabled, Node 2 can negotiate with other consensus nodes to determine itself as the master node. Alternatively, Node 2 may be designated as the new master node by multiple consensus nodes after the previous master node fails. After Node 2 determines itself as the master node, it can provide this information to the consensus service.
[0072] In step S503 , the cache service caches the received transaction.
[0073] Node 2 can connect to a user device to receive transactions (e.g., transaction Tx2) from the client of the user device, and the cache service can cache this transaction Tx2. Node 2, as a master node, can also receive transactions from each slave node that the slave node received from the client and cache these transactions.
[0074] In step S505, the consensus service calls the start interface (reset interface) provided by the cache service.
[0075] The reset interface is used to set instruction information, which is used to instruct node 2 to enable the pre-execution function, that is, to verify the received transaction and pre-execute it after the verification is passed.
[0076] In step S507 , the cache service sets the value of the variable flag to a preset value for indicating that the pre-execution function is enabled in response to the call to the reset interface.
[0077] In response to the consensus service's call to the reset interface, the cache service executes the reset interface and sets the variable flag in the cache service to a preset value (e.g., 0) for indicating that the pre-execution function is turned on, where the value of the variable flag before the setting is, for example, the default value, or in the case where node 2 is transformed from a slave node to a master node, the value of the variable flag before the setting is a preset value (e.g., 1) for indicating that the pre-execution function is turned off.
[0078] In step S509 , the pre-execution service requests a transaction from the cache service.
[0079] The pre-execution service may request a newly received transaction from the cache service to pre-process the transaction.
[0080] In step S511 , the cache service sends a transaction Tx2 and a preset value of the variable flag to the pre-execution service for indicating that the pre-execution operation is enabled.
[0081] In response to the request from the pre-execution service, the cache service obtains several transactions from the cached transactions and sends the transactions and "flag=0" to the pre-execution service. The transactions include, for example, transaction Tx2. The following steps are described using transaction Tx2 as an example.
[0082] In step S513, after receiving transaction Tx2 and "flag=0", the pre-execution service verifies the received transaction Tx2 according to "flag=0", and pre-executes transaction Tx2 after the verification passes, obtaining the pre-execution read-write set of transaction Tx2.
[0083] In step S515 , the pre-execution service sends the pre-execution read-write set of transaction Tx2 to the cache service.
[0084] In step S517 , the cache service places the transaction Tx2 and its pre-execution read-write set into the pre-execution transaction queue.
[0085] In the case where node 2 is converted from a slave node to a master node, node 2 also includes a verified transaction queue stored when it was a slave node. The transaction queue stores verified but not pre-executed transactions. The cache service in node 2 can send the transactions in the verified transaction queue together with "flag=0" to the pre-execution service, so that the pre-execution service can pre-execute these transactions and send the pre-execution read-write sets of these transactions to the cache service, so that the cache service can store these transactions and their pre-execution read-write sets in the pre-execution transaction queue.
[0086] In one embodiment, when slave node 2 determines that it has been converted from a slave node to a master node, since the pre-execution function of the pre-execution service in the slave node is enabled and the computing task is increased, the number of pre-execution service instances (such as the number of processes) can be increased, thereby achieving the effect of dynamic capacity.
[0087] The master node pre-processes the received transactions as shown in Figure 4 or Figure 5. When the master node is converted from a slave node to a master node, the verified transactions can be obtained from the verified transaction queue for pre-execution according to the value of the variable flag, without losing the transactions. This avoids the need for the client to resend the transactions, thereby improving the transaction processing efficiency in the blockchain.
[0088] FIG6 is an architecture diagram of a blockchain node in an embodiment of this specification. The blockchain node is currently a slave node and is used to execute the method shown in FIG2 , FIG3 , FIG4 or FIG5 , including:
[0089] An acquiring unit 61 is configured to acquire a first transaction and first information stored locally, where the first information is used to indicate that a pre-execution function is disabled;
[0090] a verification unit 62, configured to verify the first transaction based on the first information;
[0091] The storage unit 63 is configured to store the first transaction if the verification is successful.
[0092] The embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute the method shown in FIG. 2 , FIG. 3 , FIG. 4 , or FIG. 5 .
[0093] An embodiment of this specification also provides a blockchain node, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method shown in Figure 2, Figure 3, Figure 4 or Figure 5 is implemented.
[0094] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but 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. The most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
[0095] The controller can be implemented in any suitable manner. For example, the controller can take the form of 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, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered 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 devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
[0096] 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 exclude that with the future development of computer technology, the computer that implements the functions of the above embodiments may be, for example, a personal computer, a laptop computer, an in-vehicle 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.
[0097] 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-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "comprise", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements includes not only those elements, but also includes other elements that are not clearly listed, or also includes elements inherent to such process, method, product or equipment. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or equipment including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any particular order.
[0098] For the convenience of description, the above devices are described in terms of functions divided into various modules. Of course, when implementing one or more of the present specifications, the functions of each module can be implemented in the same or multiple software and / or hardware, or the module that implements the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0099] The present invention is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more blocks in the block diagram.
[0100] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0101] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0102] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0103] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0104] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage, graphene storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0105] Those skilled in the art will appreciate that one or more embodiments of this specification may be provided as a method, system, or computer program product. Thus, one or more embodiments of this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0106] One or more embodiments of this specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. One or more embodiments of this specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In distributed computing environments, program modules may be located in local and remote computer storage media, including storage devices.
[0107] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between the various embodiments can be referenced across them. Each embodiment focuses on the differences from the other embodiments. In particular, since the system embodiments are generally similar to the method embodiments, their description is relatively simple. For relevant parts, reference can be made to the description of the method embodiments. Throughout this specification, reference to the terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of this specification. In this specification, the schematic representations of these terms do not necessarily refer 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 integrate the different embodiments or examples, and features of different embodiments or examples, described in this specification, without conflict.
[0108] The foregoing is merely an example of one or more embodiments of this specification and is not intended to limit the one or more embodiments of this specification. It will be apparent to those skilled in the art that various modifications and variations may be made to one or more embodiments of this specification. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of this specification shall be included within the scope of the claims.
Claims
1. A transaction processing method in a blockchain, performed by a first node, the first node currently being a slave node, the method comprising: Acquire a first transaction and first information stored locally, where the first information is used to indicate that a pre-execution function is disabled; verifying the first transaction according to the first information; If the verification is successful, the first transaction is stored.
2. The method according to claim 1, further comprising: Send the first transaction to the current master node.
3. The method according to claim 1, further comprising: After determining that the first node is set as a slave node, setting the value of the first variable to a first preset value, where the first preset value is used to indicate turning off the pre-execution function; The obtaining of the first information comprises: The first preset value of the first variable is read as the first information.
4. The method according to claim 3, wherein the first node includes a pre-execution service, and the obtaining the first information stored locally includes: The pre-execution service reads the first preset value of the first variable.
5. The method according to claim 4, wherein the first node includes a cache service and a consensus service, and after determining that the first node is set as a slave node, setting the value of the first variable to a first preset value comprises: After determining that the first node is set as a slave node, the consensus service calls the first interface of the cache service, and the cache service sets the value of the first variable to the first preset value according to the call to the first interface.
6. The method according to claim 4, further comprising: After determining that the first node is set as a slave node, the number of instances of the pre-execution service is reduced.
7. The method according to claim 5, further comprising: After determining that the first node is set to be converted from a slave node to a master node, second information is stored, where the second information is used to indicate starting a pre-execution function.
8. The method according to claim 7, further comprising: obtaining the second information and the second transaction; Verifying the second transaction according to the second information, and pre-executing the second transaction after the verification is passed, to obtain a pre-execution read-write set of the second transaction; The second transaction and a pre-execution read-write set of the second transaction are stored.
9. The method according to claim 8, further comprising: After determining that the first node is set to be converted from a slave node to a master node, obtaining a locally stored verified third transaction; Pre-execute the third transaction to obtain a pre-execution read-write set of the third transaction; and store the third transaction and the pre-execution read-write set of the third transaction.
10. The method according to claim 8, wherein storing the second information comprises: After determining that the first node is set to be converted from a slave node to a master node, setting the value of the first variable to a second preset value, where the second preset value is used to indicate starting a pre-execution function; The obtaining of the second information comprises: The second preset value of the first variable is read as the second information.
11. The method according to claim 10, wherein setting the value of the first variable to a second preset value comprises: The consensus service calls the second interface of the cache service, and the cache service sets the value of the first variable to the second preset value according to the call to the second interface.
12. The method according to claim 7, further comprising: After determining that the first node is set to be converted from a slave node to a master node, the number of instances of the pre-execution service is increased.
13. A blockchain node, the blockchain node currently being a slave node, comprising: an acquisition unit, configured to acquire first information and a first transaction, wherein the first information is used to indicate closing of a pre-execution function; a verification unit, configured to verify the first transaction according to the first information; The storage unit is used to store the first transaction when the verification is passed.
14. A blockchain node, comprising a memory and a processor, wherein the memory stores an executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Block generation method and device and storage medium
CN111078696A
Method for executing transaction in block chain, block chain, master node and slave node
CN113743949A
Method for grouping multiple transactions and block chain node
CN114827165A
Transaction processing method in block chain and block chain node
CN116668001A
Systems and methods for pre-executing transaction validation for blockchain applications
US20200153605A1
