WO2022141711A1 - 区块链中交易异步执行方法、***及相关设备 - Google Patents

区块链中交易异步执行方法、***及相关设备 Download PDF

Info

Publication number
WO2022141711A1
WO2022141711A1 PCT/CN2021/073905 CN2021073905W WO2022141711A1 WO 2022141711 A1 WO2022141711 A1 WO 2022141711A1 CN 2021073905 W CN2021073905 W CN 2021073905W WO 2022141711 A1 WO2022141711 A1 WO 2022141711A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
block
transaction block
sent
layer
Prior art date
Application number
PCT/CN2021/073905
Other languages
English (en)
French (fr)
Inventor
邱炜伟
李伟
张珂杰
黄方蕾
郭威
Original Assignee
杭州趣链科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 杭州趣链科技有限公司 filed Critical 杭州趣链科技有限公司
Publication of WO2022141711A1 publication Critical patent/WO2022141711A1/zh

Links

Classifications

    • 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
    • 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/3827Use of message hashing

Definitions

  • the present application relates to the field of blockchain technology, and in particular, to a method, system and related equipment for asynchronously executing transactions in a blockchain.
  • sharding is used to break transactions into shards and distribute them across the network so that each network node does not have to download and save the entire blockchain state.
  • sharding technology can significantly increase transaction processing speed.
  • each sharding chain produces its own blocks, and then anchors to the main chain to realize the execution of the main chain block and the sharded block. Decoupling.
  • the block-producing module controls multiple sharding executors.
  • the general execution implementation scheme of this architecture will be constrained by the concept of blocks, that is, the block-producing module will package the transactions in the block according to the correlation. It is distributed to each shard executor, and after receiving all the execution results, a block is generated, and then the next block is executed.
  • the inventor found that the existing sharding method has at least the following problems: using the master-slave chain architecture, although the blocks generated on each sharding chain do not affect each other, this will lead to sharding.
  • the block generation on the chain and the final confirmation of its blocks are asynchronous, and the blocks on the shard chain are at risk of rollback.
  • the block-producing module controls multiple shard executors.
  • Embodiments of the present application provide a method, device, computer equipment and storage medium for asynchronously executing transactions in a blockchain, so as to improve the efficiency of current blockchain transactions.
  • the embodiments of the present application provide a method for asynchronously executing transactions in a blockchain, including the following steps performed by an upper-layer block generation module:
  • the transaction block included in the execution result is acquired as the second transaction block, and the buffer queue to be received has the same sequence number as the second transaction block.
  • the first transaction block of execute deletion processing
  • An acknowledgment character ACK of the execution result is delivered to the lower executor.
  • an embodiment of the present application provides a method for asynchronously executing transactions in a blockchain, including the following steps performed by a lower-layer executor:
  • a transaction block sent by the upper-layer block-producing module If a transaction block sent by the upper-layer block-producing module is received, a confirmation message containing an acknowledgment character ACK is returned to the upper-layer block-producing module, and the received transaction block is cached in the transaction block buffer queue;
  • an embodiment of the present application provides an asynchronous execution system for transactions in a blockchain.
  • the asynchronous execution system for transactions in a blockchain includes an upper-layer block generation module and at least two lower-layer executors.
  • the block module and the underlying executor implement the following steps:
  • the upper-layer block generating module sends the transaction block in the buffer queue to be sent to each lower-layer executor based on a preset trigger mechanism
  • Each of the lower-layer executors when receiving the transaction block sent by the upper-layer block-producing module, returns an acknowledgement message containing an acknowledgment character ACK to the upper-layer block-producing module, and buffers the received transaction block in the transaction block buffer queue;
  • the transaction block corresponding to the confirmation character ACK is regarded as the first transaction block, and all the blocks in the buffer queue to be sent are sent. moving the first transaction block to the to-be-received buffer queue;
  • Each of the lower-level executors executes the transaction blocks in the transaction block buffer queue
  • each of the lower-level executors After each transaction block is executed, each of the lower-level executors sends the execution result of the transaction block to the upper-level block generating module;
  • the upper-layer block generating module receives the execution result sent by the lower-layer executor, it acquires the transaction block included in the execution result as the second transaction block, and stores it in the to-be-received buffer queue with the second transaction block.
  • the first transaction block with the same sequence number in the transaction block is deleted;
  • the upper-layer block generating module transmits the confirmation character ACK of the execution result to the lower-layer executor
  • the lower-layer executor When the lower-layer executor receives the confirmation character ACK of the execution result sent by the upper-layer block generating module, it confirms that the execution of the transaction block corresponding to the confirmation character ACK of the execution result is completed, and removes the execution completion from the transaction block buffer queue. transaction block.
  • the embodiment of the present application also provides an asynchronous execution device for transactions in a blockchain, including an upper-layer block generation module, and the upper-layer block generation module includes:
  • the transaction block sending sub-module is used to send the transaction block in the buffer queue to be sent to each lower-level executor based on the preset trigger mechanism;
  • the cache update sub-module is configured to use the transaction block corresponding to the confirmation character ACK as the first transaction block when receiving the confirmation character ACK sent by the lower-level executor for the transaction block, and to send the buffer queue to be sent.
  • the first transaction block is moved to the to-be-received buffer queue;
  • the result receiving sub-module is configured to acquire the transaction block contained in the execution result as the second transaction block if the execution result sent by the lower-layer executor is received, and store it in the to-be-received buffer queue with the first transaction block.
  • the first transaction block of the second transaction block with the same sequence number is deleted;
  • the result confirmation sub-module is used to transmit the confirmation character ACK of the execution result to the lower-layer executor.
  • the embodiments of the present application also provide an asynchronous transaction execution device in a blockchain, including a lower-layer executor for execution, and the lower-layer executor for execution includes:
  • the transaction block receiving sub-module is used to return a confirmation message containing the confirmation character ACK to the upper-layer block-producing module if the transaction block sent by the upper-layer block-producing module is received, and buffer the received transaction block in the transaction block buffer queue ;
  • a transaction execution sub-module for executing the transaction blocks in the transaction block buffer queue
  • the result feedback sub-module is used to send the execution result for the transaction block to the upper-layer block generating module after each transaction block is executed;
  • the status update sub-module is used to confirm that the transaction block corresponding to the confirmation character ACK of the execution result has been executed after receiving the confirmation character ACK of the execution result sent by the upper block generating module, and remove it from the transaction block buffer queue The completed transaction block.
  • an embodiment of the present application further provides a computer device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor executes the
  • a computer device including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor executes the
  • an embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the above-mentioned blockchain is implemented The steps in the transaction to execute the method asynchronously.
  • the upper-layer block generation module sends the transaction block in the buffer queue to be sent to each lower-layer executor based on the preset trigger mechanism, and the lower-layer executor receives the transaction block sent by the upper-layer block generation module.
  • the layer block generation module returns a confirmation message containing the confirmation character ACK, and caches the received transaction block in the transaction block buffer queue, and then executes it.
  • the feedback information of the lower-layer executor changes the status of the transaction block, and the upper-layer block-producing module controls the block-producing logic. Multiple lower-layer executors independently execute the transaction block, which is beneficial to improve the efficiency of asynchronous transaction execution.
  • FIG. 1 is an exemplary system architecture diagram to which the present application can be applied;
  • FIG. 2 is a flowchart of an embodiment of the method for asynchronously executing transactions in the blockchain of the present application
  • FIG. 3 is a schematic structural diagram of an embodiment of an apparatus for asynchronously executing transactions in a blockchain according to the present application
  • FIG. 4 is a schematic structural diagram of an embodiment of a computer device according to the present application.
  • the system architecture 100 may include terminal devices 101 , 102 , and 103 , a network 104 and a server 105 .
  • the network 104 is a medium used to provide a communication link between the terminal devices 101 , 102 , 103 and the server 105 .
  • the network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
  • the user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages and the like.
  • the terminal devices 101, 102, 103 can be various electronic devices with display screens and support web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture E interface display perts Group Audio Layer). III, Motion Picture Expert Compression Standard Audio Layer 3), MP4 (Moving Picture The E interface shows the perts Group Audio Layer IV, the standard audio layer for video expert compression 4) Players, Laptops and Desktops, etc.
  • MP3 players Motion Picture Expert Compression Standard Audio Layer 3
  • MP4 Motion Picture The Compression Picture The E interface shows the perts Group Audio Layer IV, the standard audio layer for video expert compression 4
  • Players Laptops and Desktops, etc.
  • the server 105 may be a server that provides various services, such as a background server that provides support for the pages displayed on the terminal devices 101 , 102 , and 103 .
  • the method for asynchronously executing transactions in the blockchain provided by the embodiments of the present application is executed by the server, and correspondingly, the system and device for executing asynchronous transactions in the blockchain are set in the server.
  • terminal devices, networks and servers in FIG. 1 are merely illustrative. According to implementation requirements, there may be any number of terminal devices, networks, and servers, and the terminal devices 101 , 102 , and 103 in the embodiments of the present application may specifically correspond to application systems in actual production.
  • FIG. 2 shows a method for asynchronously executing transactions in a blockchain provided by an embodiment of the present application.
  • the method is applied to the server in FIG. 1 as an example for description.
  • the details are as follows:
  • the upper-layer block generation module sends the transaction block in the buffer queue to be sent to each lower-layer executor based on a preset trigger mechanism.
  • the preset trigger mechanism may specifically be triggered by judging the number of transaction blocks stored in the to-be-sent buffer queue, or may be other custom methods, which are not specifically limited here.
  • this embodiment performs fragmentation processing on transaction blocks, and stores the transaction blocks obtained after fragmentation processing in the buffer queue to be sent, so as to avoid the influence of the block number of the transaction block on subsequent distribution to multiple lower-layer executors , to realize the control of the block-producing logic by the upper-level block-producing module.
  • fragmentation processing on transaction blocks, and stores the transaction blocks obtained after fragmentation processing in the buffer queue to be sent, so as to avoid the influence of the block number of the transaction block on subsequent distribution to multiple lower-layer executors , to realize the control of the block-producing logic by the upper-level block-producing module.
  • the content to be maintained by the upper-layer block generating module includes but is not limited to: the buffer queue sendBuffer to be sent, the buffer queue receiveBuffer to be received, and block-related information blockInfos.
  • blockInfos This is a map structure that maintains the block number and the execution progress of each shard for the entire block. Its value is a BlockInfo structure, which includes: the transaction hash list, the shard identifiers participating in the execution, and the execution result of the shard.
  • the buffer queue sendBuffer to be sent is a map structure, the key is the identifier of the fragment, and the value is the batch queue of transactions to be sent for the entire fragment.
  • the receiveBuffer queue to be received is a map structure, the key is the identifier of the shard, and the value is the entire queue of block numbers to be received and executed.
  • each lower-level executor When each lower-level executor receives the transaction block sent by the upper-level block-generating module, it returns an acknowledgement message containing an acknowledgment character ACK to the upper-level block-generating module, and buffers the received transaction block in the transaction block buffer queue.
  • the lower-layer executor and the upper-layer block-producing module determine the distribution status of the message through a predetermined message handshake protocol, and when receiving the transaction block sent by the upper-layer block-producing module, return an acknowledgement containing the confirmation character ACK to the upper-layer block-producing module message, and then buffer the received transaction block to the transaction block buffer queue.
  • the transaction block buffer queue is a queue-type buffer.
  • the buffer queue receives transaction block events delivered by the upper-level block-producing module.
  • the lower-level executor includes a transaction result cache queue txBatchExecBuffer, which is a map structure and is responsible for caching the execution results of the lower-level executor, wherein the cached content includes all execution results after the latest checkpoint point given by the upper-level module. .
  • txBatchExecBuffer is a map structure and is responsible for caching the execution results of the lower-level executor, wherein the cached content includes all execution results after the latest checkpoint point given by the upper-level module.
  • each lower-level executor has an independent and independent ledger space for maintenance, and the transactions of each transaction group can be executed in the ledger space maintained by one shard. Independent ledger space, so each lower-level executor can independently execute transactions related to its own ledger space. , At the same time, since the lower-level executor does not directly participate in the block generation, and its execution behavior is completely controlled by the upper-level block generation module, the lower-level executor can continue to execute without idle, which is conducive to improving the efficiency of transaction execution.
  • the confirmation character ACK (Acknowledge character) is a type of transmission control character sent by the receiving station to the sending station in data communication, indicating that the sent data has been confirmed to be received without error.
  • the acknowledgment character ACK is preset with a fixed format and length, and the receiver replies to the sender.
  • each lower-level executor has an independent and independent ledger space for maintenance.
  • the transaction blocks stored in the transaction block buffer queue are executed.
  • the specific execution process please refer to the following embodiments. The description is not repeated here in order to avoid repetition.
  • each lower-level executor After each transaction block is executed, each lower-level executor sends the execution result of the transaction block to the upper-level block generating module.
  • the lower-layer executor after executing each transaction block, sends the execution result of the transaction block to the upper-layer block generation module, so that the upper-layer block generation module collects and stores the execution results of each lower-layer executor.
  • the lower-layer executor sends the execution result of the transaction block to the upper-layer block-producing module, but the upper-layer block-producing module fails to receive the execution result.
  • this implementation For example, the state of the transaction block is detected in a timed manner to ensure that each execution result is successfully received by the upper-layer block generating module.
  • the specific detection process refer to the description of the subsequent embodiments. To avoid repetition, it will not be repeated here.
  • the upper-layer block generation module receives the execution result sent by the lower-layer executor, it obtains the transaction block included in the execution result as the second transaction block, and treats the transaction block that has the same sequence number as the second transaction block in the receiving cache queue. For the first transaction block, delete processing is performed.
  • the upper-level block generation module When the upper-level block generation module receives the execution result sent by the lower-level executor, it obtains the transaction block sequence number contained in the execution result from the execution result, and matches the transaction block sequence number stored in the buffer queue to be received, The transaction corresponding to the sequence number of the transaction block included in the execution result is deleted, so as to avoid repeatedly sending the processed transaction block to the lower-level executor, which is beneficial to improve the execution efficiency.
  • the upper-layer block generating module transmits the confirmation character ACK of the execution result to the lower-layer executor.
  • the upper-layer block generation module sends the transaction block in the buffer queue to be sent to each lower-layer executor based on a preset trigger mechanism, and the lower-layer executor receives the transaction block sent by the upper-layer block generation module.
  • the layer block generation module returns a confirmation message containing the confirmation character ACK, and caches the received transaction block in the transaction block buffer queue, and then executes it.
  • the feedback information of the lower-layer executor changes the status of the transaction block, and the upper-layer block-producing module controls the block-producing logic. Multiple lower-layer executors independently execute the transaction block, which is beneficial to improve the efficiency of asynchronous transaction execution.
  • the method for asynchronously executing transactions in the blockchain further includes:
  • the initial transaction block is fragmented to obtain M transaction groups, where M is a positive integer not greater than the number of the lower-layer executors, and each transaction group includes at least one transaction block;
  • the consensus module sends the transaction block with successful consensus to the upper-layer block-producing module, and the upper-layer block-producing module receives the transaction block, and performs fragmentation processing on the transaction block according to the preset fragmentation method to obtain M transaction groups. , and distribute the transaction blocks in each transaction group to different buffer queues to be sent to realize the fragmented processing of the received transaction blocks.
  • the number M of transaction groups does not exceed the number of lower-level executors, ensuring that the transaction blocks in each transaction group can be quickly sent to the lower-level executors for processing when the preset trigger conditions are met, which is conducive to improving transaction performance. effectiveness.
  • the transaction group is distributed as a unit, that is, the transaction blocks of the same group are distributed to the to-be-sent buffer queue at the same time.
  • the upper-layer block generation module can ignore the block number restriction, and the consensus module generates
  • the transaction block is divided into multiple transaction blocks and grouped, and then directly distributed to the lower-level executors, so that the distribution and execution process is not restricted by the concept of blocks, so that subsequent execution can be performed through multiple lower-level executors.
  • the asynchronous parallel processing of the processor is beneficial to improve the efficiency of subsequent transaction execution.
  • step S201 based on a preset trigger mechanism, sending the transaction block in the buffer queue to be sent to each lower-layer executor includes:
  • the first quantity is compared with the preset trigger quantity threshold, and if the first quantity is greater than or equal to the preset trigger quantity threshold, the transaction block in the buffer queue to be sent is triggered to be sent to each lower-layer executor.
  • the buffer queue to be sent has a map structure
  • the key is the identifier of the queue
  • the value is the transaction block to be sent of the entire fragment.
  • the preset trigger number threshold can be set according to actual needs, for example, the trigger number threshold is preset as 10, which is not specifically limited here.
  • the transaction block in the buffer queue to be sent is triggered to be sent to each lower-layer executor, so as to ensure the transmission
  • the frequency and number of transaction blocks sent are controllable.
  • sending the transaction block in the buffer queue to be sent to each lower-level executor further includes:
  • the timing is started to obtain the timing duration
  • timing is greater than or equal to the preset trigger time interval, it will trigger to send the transaction block in the buffer queue to be sent to each lower-level executor, and reset the timing.
  • the preset trigger time interval can be set according to actual needs, for example, set to 500 milliseconds, and the specific value is not limited here.
  • the judgment of the preset trigger time interval is used as the preset trigger mechanism
  • the judgment of the preset trigger quantity threshold is used as the preset trigger mechanism
  • a timer is used to count the time after each transaction block is sent to the lower-level executor, and when the duration reaches a preset trigger time interval and the transaction block has not been sent to the lower-level executor, the buffer to be sent is triggered.
  • the transaction block in the queue is sent to each lower-level executor, and the timing is reset to avoid idleness caused by the lower-level executor not receiving the transaction block for a long time, which is beneficial to improve transaction efficiency.
  • the method for asynchronously executing transactions in the blockchain further includes:
  • the status of the transaction block in the buffer queue to be sent is periodically detected, and the first detection result is obtained;
  • the transaction block is used as the second transaction block;
  • the state of the transaction block in the buffer queue to be sent is detected by matching the sequence number of the transaction block that has been sent to the lower-level executor with the transaction block of the received confirmation character ACK.
  • the first detection result includes normal detection, and there is a transaction block that has been sent to the lower-layer executor and has not received an acknowledgement character ACK returned by the lower-layer executor.
  • the transaction block that has been sent to the lower-layer executor but has not received the confirmation character ACK returned by the lower-layer executor is regarded as the second transaction block, and
  • the second transaction block is sent to the lower-level executor, so as to avoid the abnormality caused by the loss of the transaction block data sent to the lower-level executor in the transaction block, and improve the security of transaction execution.
  • step S204 executing the transaction blocks in the transaction block buffer queue includes:
  • the first transaction block is obtained from the transaction block buffer queue for execution.
  • the transaction block is cached through the transaction block buffer queue, and before executing the transaction block, the number of transaction blocks stored in the transaction block buffer queue is read first. That is, when the number of transaction blocks stored in the transaction block buffer queue is not empty, the first transaction block is obtained from the transaction block buffer queue by means of stack popping for execution, so as to ensure the continuous and normal execution of the transaction block.
  • the transaction block buffer queue used in this embodiment is a queue-type buffer txBatchBuffer, and the transaction buffer queue receives and stores the transaction blocks transmitted by the upper-layer block generation module.
  • the transaction asynchronous execution method further includes:
  • the transaction block is regarded as the third transaction block;
  • the execution result corresponding to the third transaction block is resent to the upper-layer block producing module.
  • the transaction block buffer queue used in this embodiment is a queue-type buffer txBatchBuffer
  • the transaction buffer queue receives and stores the transaction blocks transmitted by the upper-layer block generating module, and stores the execution result of transaction execution. After each execution result is generated, try to send the execution result back to the upper-level module, and start the timer corresponding to the sequence number of the transaction block, so as to periodically detect the transaction block status in the transaction block buffer queue. If the timer expires Before receiving the confirmation character ACK from the upper-layer block-producing module, the execution result will be resent.
  • the execution result for the transaction block will be sent to the upper-layer block-producing module, but the transaction block for which the upper-layer block-producing module returns the confirmation character ACK is not received, Re-send the execution result to ensure the synchronization of the execution state and avoid exceptions caused by asynchrony, which is beneficial to improve the efficiency of transaction execution.
  • the method for asynchronously executing transactions in the blockchain further includes:
  • the upper-layer block generation module receives the block-cutting scene status sent by the consensus module, it will confirm the rollback target height according to the block-cutting scene status;
  • the upper-layer block generation module sends the block-cutting scene state and target height to each lower-layer executor
  • the lower-layer executor receives the block-cutting scene status and target height sent by the upper-layer block-producing module, it will clear the transaction block of the transaction block buffer queue;
  • the lower executor performs rollback processing based on the target height
  • the lower-level executor After the rollback is successful, the lower-level executor sends a rollback success message to the upper-level block producing module.
  • the upper-level block generation module receives the rollback success message returned by each lower-level executor, it rolls back the cached data to the target height, and updates the memory information according to the status after rollback.
  • a specific state value is preset in this embodiment.
  • the upper-layer block-producing module and the lower-layer executor will perform a rollback operation, and during the rollback operation, other times will be rejected to ensure that Quick response to block chopping scenarios.
  • the upper-layer block generating module determines the target height of the rollback, and sends it to each lower-layer executor, and the lower-layer executor executes the rollback process according to the target height , and return the rollback result to the upper-level block-producing module.
  • the rollback results include rollback success and rollback failure.
  • a transaction asynchronous execution system in a blockchain corresponding to an asynchronous transaction execution method in a blockchain provided by an embodiment of the present application, the asynchronous transaction execution system in the blockchain includes an upper-layer block generation module and at least two lower-layer executors, The upper block output module and the lower executor implement the following steps:
  • the upper-layer block generation module sends the transaction blocks in the buffer queue to be sent to each lower-layer executor;
  • each lower-level executor When each lower-level executor receives a transaction block sent by the upper-level block-producing module, it returns an acknowledgement message containing the confirmation character ACK to the upper-level block-producing module, and caches the received transaction block in the transaction block buffer queue;
  • the upper-layer block generation module When the upper-layer block generation module receives the confirmation character ACK for the transaction block sent by the lower-layer executor, it takes the transaction block corresponding to the confirmation character ACK as the first transaction block, and moves the first transaction block in the buffer queue to be sent to the waiting block. Receive buffer queue;
  • Each lower-level executor executes the transaction blocks in the transaction block buffer queue
  • each lower-level executor After each transaction block is executed, each lower-level executor sends the execution result of the transaction block to the upper-level block generation module;
  • the upper-layer block generation module receives the execution result sent by the lower-layer executor, it obtains the transaction block contained in the execution result as the second transaction block, and treats the first transaction block with the same sequence number as the second transaction block in the receiving cache queue. Transaction block, perform deletion processing;
  • the upper-layer block-producing module transmits the confirmation character ACK of the execution result to the lower-layer executor
  • the lower-layer executor When the lower-layer executor receives the confirmation character ACK of the execution result sent by the upper-layer block generating module, it confirms that the transaction block corresponding to the confirmation character ACK of the execution result is executed, and removes the executed transaction block from the transaction block buffer queue.
  • FIG. 3 shows a principle block diagram of an asynchronous transaction execution device in a blockchain that corresponds one-to-one with the asynchronous transaction execution method in the blockchain in the above-mentioned embodiment.
  • the transaction asynchronous execution device in the blockchain includes an upper-layer block generation module, which includes: a transaction block sending sub-module 31 , a cache updating sub-module 32 , a result receiving sub-module 33 and a result confirming sub-module module 34.
  • an upper-layer block generation module which includes: a transaction block sending sub-module 31 , a cache updating sub-module 32 , a result receiving sub-module 33 and a result confirming sub-module module 34.
  • the transaction block sending sub-module 31 is used to send the transaction block in the buffer queue to be sent to each lower-level executor based on a preset trigger mechanism;
  • the cache update sub-module 32 is configured to use the transaction block corresponding to the confirmation character ACK as the first transaction block when receiving the confirmation character ACK sent by the lower-level executor for the transaction block, and to send the first transaction in the buffer queue to be sent The block is moved to the to-be-received buffer queue;
  • the result receiving sub-module 33 is configured to acquire the transaction block included in the execution result if the execution result sent by the lower-level executor is received, as the second transaction block, and treat it in the receiving buffer queue, which has the same sequence as the second transaction block The first transaction block of the number, execute the deletion process;
  • the result confirmation sub-module 34 is used to transmit the confirmation character ACK of the execution result to the lower-level executor.
  • the device for asynchronously executing transactions in the blockchain further includes:
  • the transaction block receiving sub-module is used to receive the transaction block transmitted by the consensus module as the initial transaction block;
  • the transaction block sharding sub-module is used to shard the initial transaction block according to the preset sharding method to obtain M transaction groups, wherein M is a positive integer not greater than the number of the lower-level executors, and each transaction The group includes at least one transaction block;
  • the shard cache sub-module is used to distribute the transaction blocks in each transaction group to the to-be-sent cache queue.
  • the transaction block sending submodule 31 includes:
  • the quantity monitoring unit is used to monitor the number of transaction blocks in the buffer queue to be sent in real time, as the first quantity
  • a threshold acquisition unit used to acquire a preset trigger quantity threshold
  • a numerical comparison unit used to compare the first number with a preset trigger number threshold, and if the first number is greater than or equal to the preset trigger number threshold, triggering to send the transaction blocks in the buffer queue to be sent to each lower layer Actuator.
  • the transaction block sending submodule 31 further includes:
  • a time interval obtaining unit used to obtain a preset trigger time interval
  • the timing unit is used to start the timing every time the transaction block in the buffer queue to be sent is sent to each lower-level executor to obtain the timing duration;
  • the duration comparison unit is used to trigger sending the transaction block in the buffer queue to be sent to each lower executor if the timing duration is greater than or equal to the preset trigger time interval, and reset the timing duration.
  • the device for asynchronously executing transactions in the blockchain further includes:
  • the first detection submodule is used to periodically detect the status of the transaction blocks in the buffer queue to be sent, and obtain the first detection result
  • the second transaction block determination sub-module is configured to use the transaction block as the second transaction block if the first detection result is that there is a transaction block that has been sent to the lower-layer executor and has not received the confirmation character ACK returned by the lower-layer executor;
  • the second transaction block sending submodule is configured to send the second transaction block to the lower-layer executor.
  • the device for asynchronously executing transactions in the blockchain further includes:
  • the target height determination sub-module is used to confirm the rollback target height according to the status of the chopping scene if it receives the status of the chopping scene sent by the consensus module;
  • the target height sending sub-module is used to send the block cutting scene state and target height to each lower executor
  • the rollback result receiving sub-module is used to roll back the cached data to the target height when receiving the rollback success message returned by each lower-level executor, and update the memory information according to the status after rollback.
  • the transaction asynchronous execution device in the blockchain also includes a lower-level executor, and the lower-level executor includes: a transaction block receiving submodule 35 , a transaction execution submodule 36 , a result feedback submodule 37 and a state update submodule 38 .
  • the lower-level executor includes: a transaction block receiving submodule 35 , a transaction execution submodule 36 , a result feedback submodule 37 and a state update submodule 38 .
  • the transaction block receiving sub-module 35 is configured to return a confirmation message containing an acknowledgment character ACK to the upper-layer block-producing module if the transaction block sent by the upper-layer block-producing module is received, and buffer the received transaction block in the transaction block buffer queue;
  • the transaction execution sub-module 36 is used to execute the transaction blocks in the transaction block buffer queue
  • the result feedback sub-module 37 is used to send the execution result for the transaction block to the upper-layer block generating module after each transaction block is executed;
  • the status update sub-module 38 is used to confirm that the transaction block corresponding to the confirmation character ACK of the execution result has been executed after receiving the confirmation character ACK of the execution result sent by the upper block generating module, and remove the execution completed from the transaction block buffer queue. transaction block.
  • the transaction execution sub-module 36 includes:
  • a quantity reading unit used to read the number of transaction blocks in the transaction block buffer queue as the second quantity
  • the target selection unit is used to obtain the first transaction block from the transaction block buffer queue for execution if the second quantity is not 0.
  • the transaction asynchronous execution device further includes:
  • the second detection submodule is used to periodically detect the transaction block status in the transaction block buffer queue to obtain a second detection result
  • the third transaction block determination sub-module is used for, if the second detection result is that there is an execution result for the transaction block sent to the upper-layer block-producing module, and no transaction block for which the upper-layer block-producing module returns an acknowledgment character ACK is received, the transaction block as the third transaction block;
  • the execution result resending sub-module is used to resend the execution result corresponding to the third transaction block to the upper-layer block generating module.
  • the device for asynchronously executing transactions in the blockchain further includes:
  • the cache cleaning sub-module is used to clear the transaction block of the transaction block buffer queue if the block cutting scene status and target height sent by the upper block generation module are received;
  • the rollback processing submodule is used to perform rollback processing based on the target height
  • the rollback message feedback sub-module is used to send a rollback success message to the upper-level block producing module after the rollback is successful.
  • the device for asynchronously executing transactions in the blockchain can be implemented in whole or in part by software, hardware, and combinations thereof.
  • the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
  • FIG. 4 is a block diagram of a basic structure of a computer device according to this embodiment.
  • the computer device 4 includes a memory 41, a processor 42, and a network interface 43 that communicate with each other through a system bus. It should be pointed out that the figure only shows the computer device 4 having the components connected to the memory 41, the processor 42, and the network interface 43, but it should be understood that it is not required to implement all the components shown, and alternative implementations of more More or fewer components.
  • the computer device here is a device that can automatically perform numerical calculation and/or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, special-purpose Integrated circuit (Application Specific Integrated Circuit, ASIC), Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Signal Processor (Digital Signal Processor, DSP), embedded devices, etc.
  • ASIC Application Specific Integrated Circuit
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • DSP Digital Signal Processor
  • embedded devices etc.
  • the computer equipment may be a desktop computer, a notebook computer, a palmtop computer, a cloud server and other computing equipment.
  • the computer device can perform human-computer interaction with the user through a keyboard, a mouse, a remote control, a touch pad or a voice control device.
  • the memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or D interface display memory, etc.), random access memory (RAM) , Static Random Access Memory (SRAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Programmable Read Only Memory (PROM), Magnetic Memory, Magnetic Disk, Optical Disk, etc.
  • the memory 41 may be an internal storage unit of the computer device 4 , such as a hard disk or a memory of the computer device 4 .
  • the memory 41 may also be an external storage device of the computer device 4 , such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, flash card (Flash Card), etc.
  • the memory 41 may also include both the internal storage unit of the computer device 4 and its external storage device.
  • the memory 41 is generally used to store the operating system and various application software installed in the computer device 4 , such as program codes for controlling electronic files.
  • the memory 41 can also be used to temporarily store various types of data that have been output or will be output.
  • the processor 42 may be a central processing unit (Central Processing Unit) in some embodiments. Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip. This processor 42 is typically used to control the overall operation of the computer device 4 . In this embodiment, the processor 42 is configured to run the program code or process data stored in the memory 41 , for example, run the program code for controlling the electronic file.
  • CPU Central Processing Unit
  • controller microcontroller
  • microprocessor microprocessor
  • This processor 42 is typically used to control the overall operation of the computer device 4 .
  • the processor 42 is configured to run the program code or process data stored in the memory 41 , for example, run the program code for controlling the electronic file.
  • the network interface 43 may include a wireless network interface or a wired network interface, and the network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
  • the present application also provides another implementation manner, which is to provide a computer-readable storage medium, where an interface display program is stored in the computer-readable storage medium, and the interface display program can be executed by at least one processor, so that all The at least one processor executes the steps of the above-mentioned method for asynchronously executing transactions in the blockchain.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Retry When Errors Occur (AREA)

Abstract

本申请涉及区块链技术领域,公开了一种区块链中交易异步执行方法、***及相关设备,所述方法包括:基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器,在接收到所述下层执行器发送的针对交易块的确认字符ACK时,将所述确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的所述第一交易块移动到待接收缓存队列中,若接收到下层执行器发送的执行结果,则获取所述执行结果中包含的交易块,作为第二交易块,并对所述待接收缓存队列中,与所述第二交易块具有相同序列号的第一交易块,执行删除处理,向所述下层执行器传递执行结果的确认字符ACK。本申请提高了交易异步执行的效率。

Description

区块链中交易异步执行方法、***及相关设备
本申请要求于2020年12月31日提交中国专利局、申请号为202011640101.7,发明名称为“区块链中交易异步执行方法、***及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链技术领域,尤其涉及一种区块链中交易异步执行方法、***及相关设备。
背景技术
在区块链网络中,分片技术用于将交易分解为分片并将其分布到整个网络中,这样一来,每个网络节点都不必下载和保存整个区块链状态。通过并行化,分片技术可以显著提高交易处理速度。
目前的状态分片或执行分片的解决方案中,主要采用主从链的架构,各个分片链自己出块,然后向主链锚定,来实现主链区块和分片区块执行上的解耦。此外还有一些出块模块控制多个分片执行器的架构,这种架构一般的执行实现方案会受区块概念的约束,即由出块模块将打包好的区块中的交易按照相关性分发到各个分片执行器中,并收全所有的执行结果后出块,然后进行下一个区块的执行。
发明人在实现本申请的过程中发现,现有的分片方式至少存在如下问题:采用主从链的架构,虽然各个分片链上的出块是互不影响的,但是这样会导致分片链上的出块和其区块的最终确认是异步的,分片链上的区块是存在回滚风险的。采用出块模块控制多个分片执行器的架构,虽然能够通过多个分片执行器并行来加速一个区块的执行速度,但是因为各个分片上的交易数量,交易复杂度的不同,可能导致在一个区块执行的周期内,某些分片执行器闲置,某些分片则一直繁忙,互相间存在等待的现象,导致交易效率较低。
技术问题
本申请实施例提供一种区块链中交易异步执行方法、装置、计算机设备和存储介质,以提高当前区块链交易效率。
技术解决方案
为了解决上述技术问题,本申请实施例提供一种区块链中交易异步执行方法,包括上层出块模块执行的如下步骤:
基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器;
在接收到所述下层执行器发送的针对交易块的确认字符ACK时,将所述确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的所述第一交易块移动到待接收缓存队列中;
若接收到下层执行器发送的执行结果,则获取所述执行结果中包含的交易块,作为第二交易块,并对所述待接收缓存队列中,与所述第二交易块具有相同序列号的第一交易块,执行删除处理;
向所述下层执行器传递执行结果的确认字符ACK。
为了解决上述技术问题,本申请实施例提供一种区块链中交易异步执行方法,包括下层执行器执行的如下步骤:
若接收到上层出块模块发送的交易块,则向所述上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列;
对所述交易块缓冲队列中的交易块进行执行;
在每个交易块被执行完成后,向所述上层出块模块发送针对交易块的执行结果;
在接收到上层出块模块发送的执行结果的确认字符ACK时,确认所述执行结果的确认字符ACK对应的交易块执行完毕,从所述交易块缓冲队列中移除执行完毕的交易块。
为了解决上述技术问题,本申请实施例提供一种区块链中交易异步执行***,所述区块链中交易异步执行***包括一个上层出块模块和至少两个下层执行器,所述上层出块模块和所述下层执行器实现如下步骤:
所述上层出块模块基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器;
每个所述下层执行器在接收到上层出块模块发送的交易块时,向所述上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列;
所述上层出块模块在接收到所述下层执行器发送的针对交易块的确认字符ACK时,将所述确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的所述第一交易块移动到待接收缓存队列中;
每个所述下层执行器对所述交易块缓冲队列中的交易块进行执行;
每个所述下层执行器在每个交易块被执行完成后,向所述上层出块模块发送交易块的执行结果;
所述上层出块模块若接收到下层执行器发送的执行结果,则获取所述执行结果中包含的交易块,作为第二交易块,并对所述待接收缓存队列中,与所述第二交易块具有相同序列号的第一交易块,执行删除处理;
所述上层出块模块向所述下层执行器传递执行结果的确认字符ACK;
所述下层执行器在接收到上层出块模块发送的执行结果的确认字符ACK时,确认所述执行结果的确认字符ACK对应的交易块执行完毕,从所述交易块缓冲队列中移除执行完毕的交易块。
为了解决上述技术问题,本申请实施例还提供一种区块链中交易异步执行装置,包括上层出块模块,上层出块模块包括:
交易块发送子模块,用于基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器;
缓存更新子模块,用于在接收到所述下层执行器发送的针对交易块的确认字符ACK时,将所述确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的所述第一交易块移动到待接收缓存队列中;
结果接收子模块,用于若接收到下层执行器发送的执行结果,则获取所述执行结果中包含的交易块,作为第二交易块,并对所述待接收缓存队列中,与所述第二交易块具有相同序列号的第一交易块,执行删除处理;
结果确认子模块,用于向所述下层执行器传递执行结果的确认字符ACK。
为了解决上述技术问题,本申请实施例还提供一种区块链中交易异步执行装置,包括下层执行器执行,下层执行器执行包括:
交易块接收子模块,用于若接收到上层出块模块发送的交易块,则向所述上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列;
交易执行子模块,用于对所述交易块缓冲队列中的交易块进行执行;
结果反馈子模块,用于在每个交易块被执行完成后,向所述上层出块模块发送针对交易块的执行结果;
状态更新子模块,用于在接收到上层出块模块发送的执行结果的确认字符ACK时,确认所述执行结果的确认字符ACK对应的交易块执行完毕,从所述交易块缓冲队列中移除执行完毕的交易块。
为了解决上述技术问题,本申请实施例还提供一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现上述区块链中交易异步执行方法的步骤。
为了解决上述技术问题,本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,所述计算机可读指令被处理器执行时实现上述区块链中交易异步执行方法的步骤。
有益效果
本申请中,通过上层出块模块基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器,下层执行器在接收到上层出块模块发送的交易块时,向上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列,进而进行执行,并在执行完成后,与上层执行器进行反馈确认,上层出块模块根据下层执行器的反馈信息,对交易块状态进行变更,实现上层出块模块控制出块逻辑,多个下层执行器独立对交易块进行执行,有利于提高交易异步执行的效率。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请可以应用于其中的示例性***架构图;
图2是本申请的区块链中交易异步执行方法的一个实施例的流程图;
图3是根据本申请的区块链中交易异步执行装置的一个实施例的结构示意图;
图4是根据本申请的计算机设备的一个实施例的结构示意图。
具体实施方式
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同;本文中在申请的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本申请;本申请的说明书和权利要求书及上述附图说明中的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。本申请的说明书和权利要求书或上述附图中的术语“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。
在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本文所描述的实施例可以与其它实施例相结合。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
请参阅图1,如图1所示,***架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。
用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。
终端设备101、102、103可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、电子书阅读器、MP3播放器( Moving Picture E界面显示perts Group Audio Layer III,动态影像专家压缩标准音频层面3 )、MP4( Moving Picture E界面显示perts Group Audio Layer IV,动态影像专家压缩标准音频层面4 )播放器、膝上型便携计算机和台式计算机等等。
服务器105可以是提供各种服务的服务器,例如对终端设备101、102、103上显示的页面提供支持的后台服务器。
需要说明的是,本申请实施例所提供的区块链中交易异步执行方法由服务器执行,相应地,区块链中交易异步执行***和装置设置于服务器中。
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器,本申请实施例中的终端设备101、102、103具体可以对应的是实际生产中的应用***。
请参阅图2,图2示出本申请实施例提供的一种区块链中交易异步执行方法,以该方法应用在图1中的服务端为例进行说明,详述如下:
S201:上层出块模块基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器。
其中,预设的触发机制具体可以是通过待发送缓存队列中存储的交易块数量判断来触发,也可以是自定义的其他方式,此处不作具体限定。
通过待发送缓存队列中存储的交易块数量判断来触发的具体实现过程,可参考后续实施例的描述,为避免重复,此处不再赘述。
优选的,本实施例对交易块进行分片处理,在将分片处理后得到的交易块存储到待发送缓存队列中,避免交易块的区块号对后续分发到多个下层执行器的影响,实现上层出块模块对出块逻辑的控制。具体分片实现过程,也可参考后续实施例的描述。
本实施例中,上层出块模块需要维护的内容,也即,需要实时更新的内容,包括但不限于:待发送缓存队列sendBuffer、待接收缓存队列receiveBuffer和区块相关信息blockInfos。
其中,blockInfos:这是一个map结构,维护了区块号和各个分片对整个区块的执行进度。其value是一个BlockInfo结构,其中包括了:交易hash列表、参与执行的分片标识、以及分片的执行结果。
其中待发送缓存队列sendBuffer,是一个map结构,key为分片的标识,value为整个分片的待发送的交易batch队列。
待接收缓存队列receiveBuffer是一个map结构,key为分片的标识,value为整个待接收执行回复的区块号队列。
S202:每个下层执行器在接收到上层出块模块发送的交易块时,向上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列。
具体地,下层执行器与上层出块模块通过预定好的消息握手协议,确定消息的分发状态,在接收到上层出块模块发送的交易块时,向上层出块模块返回包含确认字符ACK的确认消息,进而将接收到的交易块缓存到交易块缓冲队列。
其中,交易块缓冲队列是一个队列类型的缓冲区。该缓冲队列接收上层出块模块传递的交易块事件。
可选地,下层执行器包括交易结果缓存队列txBatchExecBuffer,该缓冲队列是一个map结构,负责缓存下层执行器的执行结果,其中缓存的内容包括上层模块给出的最新的checkpoint点以后的所有执行结果。
需要说明的是,本实施例中,每个下层执行器具有独立的维护独立的账本空间,每个交易组的交易可以在一个分片维护的账本空间中完成执行,由于每个下层执行器维护独立的账本空间,因此每个下层执行器可以独立的执行自身账本空间相关的交易。,同时,由于下层执行器不直接参与出块,且其执行行为完全被上层出块模块控制,所以下层执行器是可以不闲置持续执行,有利于提高交易执行效率。
S203:上层出块模块在接收到下层执行器发送的针对交易块的确认字符ACK时,将确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的第一交易块移动到待接收缓存队列中。
其中,确认字符ACK(Acknowledge character)是在数据通信中,接收站发给发送站的一种传输类控制字符,表示发来的数据已确认接收无误。通常确认字符ACK预先设定固定的格式,长度大小,由接收方回复给发送方。
S204:每个下层执行器对交易块缓冲队列中的交易块进行执行。
具体地,每个下层执行器具有独立的维护独立的账本空间,在该下层执行器独立的账本空间中,对交易块缓冲队列中存储的交易块进行执行,具体执行过程可参考后续实施例的描述,为避免重复,此处不再赘述。
S205:每个下层执行器在每个交易块被执行完成后,向上层出块模块发送交易块的执行结果。
本实施例中,下层执行器在执行完每个交易块后,向上层出块模块发送交易块的执行结果,以使上层出块模块收集各个下层执行器的执行结果并进行存储。
需要说明的是,存在下层执行器向上层出块模块发送交易块的执行结果,但上层出块模块未能接收到该执行结果的情形,为避免该情形导致的交易执行结果数据异常,本实施例通过定时的方式,对交易块的状态进行检测,来确保每个执行结果均被上层出块模块成功接收,具体检测过程可参考后续实施例的描述,为避免重复,此处不再赘述。
S206:上层出块模块若接收到下层执行器发送的执行结果,则获取执行结果中包含的交易块,作为第二交易块,并对待接收缓存队列中,与第二交易块具有相同序列号的第一交易块,执行删除处理。
上层出块模块在接收到下层执行器发送的执行结果时,从该执行结果中,获取执行结果中包含的交易块序列号,并与待接收缓存队列中存储的交易块序列号进行匹配,将与执行结果中包含的交易块序列号对应的交易,执行删除处理,避免将已处理的交易块重复发送到下层执行器,有利于提高执行效率。
S207:上层出块模块向下层执行器传递执行结果的确认字符ACK。
S208:下层执行器在接收到上层出块模块发送的执行结果的确认字符ACK时,确认执行结果的确认字符ACK对应的交易块执行完毕,从交易块缓冲队列中移除执行完毕的交易块。
本实施例中,上层出块模块基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器,下层执行器在接收到上层出块模块发送的交易块时,向上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列,进而进行执行,并在执行完成后,与上层执行器进行反馈确认,上层出块模块根据下层执行器的反馈信息,对交易块状态进行变更,实现上层出块模块控制出块逻辑,多个下层执行器独立对交易块进行执行,有利于提高交易异步执行的效率。
在本实施例的一些可选的实现方式中,步骤S201之前,区块链中交易异步执行方法还包括:
接收共识模块传递的交易块,作为初始交易块;
按照预设分片方式,对初始交易块进行分片处理,得到M个交易组,其中,M为不大于所述下层执行器个数的正整数,每个交易组包括至少一个交易块;
将每个交易组中的交易块分发到待发送缓存队列中。
具体地,共识模将共识成功的交易块发送给上层出块模块,上层出块模块接收该交易块,并按照预设的分片方式,对该交易块进行分片处理,得到M个交易组,并将每个交易组中的交易块分发到不同的待发送缓存队列中实现对接收到的交易块的分片处理。
应理解,交易组的数量M为不超过下层执行器的数量,确保每个交易组中的交易块,在达到预设触发条件时,均可快速发送至下层执行器进行处理,有利于提高交易执行效率。
需要说明的是,在进行交易块分发到待发送缓存队列时,以交易组为单位进行分发,也即,将同一组的交易块同时分发到待发送缓存队列中。
本实施例中,通过对交易块分片处理,并将分片后的交易块存储到不同的待发送缓存队列中,实现上层出块模块可以无视区块号的限制,在接收到了共识模块产生的交易块时,将该交易块拆分为多个交易块并进行分组,再直接向下层执行器分发,从而使得分发和执行过程不受区块概念的限制,使得后续可以通过多个下层执行器进行异步并行处理,有利于提高后续交易执行效率。
在本实施例的一些可选的实现方式中,步骤S201中,基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器包括:
实时监听待发送缓存队列中的交易块的数量,作为第一数量;
获取预设的触发数量阈值;
对第一数量与预设的触发数量阈值进行比较,若第一数量大于或等于预设的触发数量阈值,则触发将待发送缓存队列中的交易块发送给每个下层执行器。
具体地,待发送缓存队列为map结构,key为队列的标识,value为整个分片的待发送的交易块,本实施例中的待发送缓存队列为多个,每个待发送缓存队列具有唯一的标识。
其中,预设的触发数量阈值可以根据实际需要进行设定,例如,将触发数量阈值预设为10个,此处不作具体限定。
本实施例中,通过持续对待发送缓存队列中的交易块的数量进行监听的方式,在达到预设发送条件时,触发将待发送缓存队列中的交易块发送给每个下层执行器,确保发送交易块发送的频率和数量可控。
在本实施例的一些可选的实现方式中,步骤S201中,基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器还包括:
获取预设的触发时间间隔;
在每次将待发送缓存队列中的交易块发送给每个下层执行器时,开启计时,得到计时时长;
若计时时长大于或等于预设的触发时间间隔,则触发将待发送缓存队列中的交易块发送给每个下层执行器,并重置计时时长。
其中,预设的触发时间间隔可根据实际需求进行设定,例如,设置为500毫秒,具体数值此处不作限定。
需要说明的是,本实施例中,采用预设的触发时间间隔的判断,作为预设的触发机制,与上一实施例中,采用预设的触发数量阈值的判断,作为预设的触发机制,可以任选其一来实现基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器的过程,也可以采用两者结合的方式,来实现基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器的过程。
本实施例中,通过计时器对每次发送交易块至下层执行器后的时长进行计时,在时长达到预设的触发时间间隔,还未向下层执行器发送交易块时,触发将待发送缓存队列中的交易块发送给每个下层执行器,并重置计时时长,避免下层执行器长时间未接收到交易块导致空闲,有利于提高交易效率。
在本实施例的一些可选的实现方式中,步骤S201之后,区块链中交易异步执行方法还包括:
定时对待发送缓存队列中的交易块状态进行检测,得到第一检测结果;
若第一检测结果为存在已发送给下层执行器,并且未接收到下层执行器返回确认字符ACK的交易块,则将交易块作为第二交易块;
将第二交易块发送给下层执行器。
其中,对待发送缓存队列中的交易块状态进行检测,是通过对已发送给下层执行器的交易块的序列号,与收到的确认字符ACK的交易块进行匹配的方式来实现。
其中,第一检测结果包括检测正常,和存在已发送给下层执行器,并且未接收到下层执行器返回确认字符ACK的交易块。
本实施例中,通过定时对待发送缓存队列中的交易块状态进行检测,将已发送给下层执行器,但未接收到下层执行器返回确认字符ACK的交易块,作为第二交易块,并将第二交易块发送给下层执行器,避免交易块为已发送给下层执行器的交易块数据的丢失导致的异常,提高交易执行的安全性。
在本实施例的一些可选的实现方式中,步骤S204中,对交易块缓冲队列中的交易块进行执行,包括:
读取交易块缓冲队列中的交易块的数量,作为第二数量;
若第二数量不为0,则从交易块缓冲队列中获取第一个交易块进行执行。
具体地,本实施例通过交易块缓冲队列对交易块进行缓存,在对交易块进行执行之前,先读取交易块缓冲队列中存储的交易块的数量,在存储的交易量数量大于0,也即,交易块缓冲队列中存储的交易块的数量不为空时,通过堆栈弹出的方式,从交易块缓冲队列中获取第一个交易块进行执行,确保交易块连续正常执行。
其中,本实施例采用的交易块缓冲队列为队列类型的缓冲区txBatchBuffer,该交易缓冲队列接收并存储上层出块模块传递的交易块。
本实施例中,通过先对交易块缓冲队列中的交易块的数量进行判断,在存储交易块不为空时再进行交易块的执行,避免执行异常,有利于提高执行效率。
在本实施例的一些可选的实现方式中,在步骤S205之后,交易异步执行方法还包括:
定时对交易块缓冲队列中的交易块状态进行检测,得到第二检测结果;
若第二检测结果为存在向上层出块模块发送针对交易块的执行结果,并且未接收到上层出块模块返回确认字符ACK的交易块,则将交易块作为第三交易块;
向上层出块模块重新发送第三交易块对应的执行结果。
具体地,本实施例采用的交易块缓冲队列为队列类型的缓冲区txBatchBuffer,该交易缓冲队列接收并存储上层出块模块传递的交易块,以及,存储交易执行的执行结果。在每次产生执行结果后,尝试将执行结果发回给上层模块,并启动这个交易块序列号对应的计时器,实现定时对交易块缓冲队列中的交易块状态进行检测,如果计时器到时前,没有收到上层出块模块的确认字符ACK,则重发这个执行结果。
需要说明的是,在一些场景中,可能存在上层下发的交易块中,包含了下层执行器已执行过的交易块序列号,则直接将这个序列号的执行结果返回给上层。
本实施例中,通过定时对交易块缓冲队列中的交易块状态进行检测,将向上层出块模块发送针对交易块的执行结果,但未接收到上层出块模块返回确认字符ACK的交易块,进行执行结果的重新发送,确保执行状态的同步,避免不同步导致的异常,有利于提高交易执行效率。
在本实施例的一些可选的实现方式中,区块链中交易异步执行方法还包括:
上层出块模块若接收到共识模块发送的砍块场景状态,则根据砍块场景状态,确认回滚的目标高度;
上层出块模块将砍块场景状态和目标高度发送给每个下层执行器;
下层执行器若接收到上层出块模块发送的砍块场景状态和目标高度,则清空交易块缓冲队列的交易块;
下层执行器基于目标高度执行回滚处理;
下层执行器在回滚成功后,向上层出块模块发送回滚成功消息。
上层出块模块在接收到每个下层执行器返回的回滚成功消息时,将缓存数据回滚至目标高度,并根据回滚后的状态,对内存信息进行更新。
需要说明的是,本实施例中预设有特定状态值,处于该特定状态值时,上层出块模块和下层执行器会执行回滚操作,并在回滚操作过程中,拒绝其他时间,确保对砍块场景的快速响应。
本实施例中,在接收到共识模块发送的砍块场景状态时,通过上层出块模块确定回滚的目标高度,并发送给每个下层执行器,下层执行器根据该目标高度执行回滚处理,并向上层出块模块返回回滚结果,回滚结果包括回滚成功和回滚失败,在上层出块模块接收到每个下层执行器均回滚成功的消息后,将自身存储的数据会滚至目标高度,并根据回滚后的状态,更新内存中的必要信息,实现对砍块场景的快速响应,避免交易执行的异常,确保交易的可靠性和安全性。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
本申请实施例提供的一种区块链中交易异步执行方法对应的区块链中交易异步执行***,该区块链中交易异步执行***包括一个上层出块模块和至少两个下层执行器,上层出块模块和下层执行器实现如下步骤:
上层出块模块基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器;
每个下层执行器在接收到上层出块模块发送的交易块时,向上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列;
上层出块模块在接收到下层执行器发送的针对交易块的确认字符ACK时,将确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的第一交易块移动到待接收缓存队列中;
每个下层执行器对交易块缓冲队列中的交易块进行执行;
每个下层执行器在每个交易块被执行完成后,向上层出块模块发送交易块的执行结果;
上层出块模块若接收到下层执行器发送的执行结果,则获取执行结果中包含的交易块,作为第二交易块,并对待接收缓存队列中,与第二交易块具有相同序列号的第一交易块,执行删除处理;
上层出块模块向下层执行器传递执行结果的确认字符ACK;
下层执行器在接收到上层出块模块发送的执行结果的确认字符ACK时,确认执行结果的确认字符ACK对应的交易块执行完毕,从交易块缓冲队列中移除执行完毕的交易块。
关于区块链中交易异步执行***的具体限定可以参见上文中对于区块链中交易异步执行方法的限定,在此不再赘述。
图3示出与上述实施例区块链中交易异步执行方法一一对应的区块链中交易异步执行装置的原理框图。
如图3所示,该区块链中交易异步执行装置包括上层出块模块,该上层出块模块包括:交易块发送子模块31、缓存更新子模块32、结果接收子模块33和结果确认子模块34。各功能模块详细说明如下:
交易块发送子模块31,用于基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器;
缓存更新子模块32,用于在接收到下层执行器发送的针对交易块的确认字符ACK时,将确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的第一交易块移动到待接收缓存队列中;
结果接收子模块33,用于若接收到下层执行器发送的执行结果,则获取执行结果中包含的交易块,作为第二交易块,并对待接收缓存队列中,与第二交易块具有相同序列号的第一交易块,执行删除处理;
结果确认子模块34,用于向下层执行器传递执行结果的确认字符ACK。
可选地,区块链中交易异步执行装置还包括:
交易块接收子模块,用于接收共识模块传递的交易块,作为初始交易块;
交易块分片子模块,用于按照预设分片方式,对初始交易块进行分片处理,得到M个交易组,其中,M为不大于所述下层执行器个数的正整数,每个交易组包括至少一个交易块;
分片缓存子模块,用于将每个交易组中的交易块分发到待发送缓存队列中。
可选地,交易块发送子模块31包括:
数量监听单元,用于实时监听待发送缓存队列中的交易块的数量,作为第一数量;
阈值获取单元,用于获取预设的触发数量阈值;
数值比较单元,用于对第一数量与预设的触发数量阈值进行比较,若第一数量大于或等于预设的触发数量阈值,则触发将待发送缓存队列中的交易块发送给每个下层执行器。
可选地,交易块发送子模块31还包括:
时间间隔获取单元,用于获取预设的触发时间间隔;
计时单元,用于在每次将待发送缓存队列中的交易块发送给每个下层执行器时,开启计时,得到计时时长;
时长比较单元,用于若计时时长大于或等于预设的触发时间间隔,则触发将待发送缓存队列中的交易块发送给每个下层执行器,并重置计时时长。
可选地,区块链中交易异步执行装置还包括:
第一检测子模块,用于定时对待发送缓存队列中的交易块状态进行检测,得到第一检测结果;
第二交易块确定子模块,用于若第一检测结果为存在已发送给下层执行器,并且未接收到下层执行器返回确认字符ACK的交易块,则将交易块作为第二交易块;
第二交易块发送子模块,用于将第二交易块发送给下层执行器。
可选地,区块链中交易异步执行装置还包括:
目标高度确定子模块,用于若接收到共识模块发送的砍块场景状态,则根据砍块场景状态,确认回滚的目标高度;
目标高度发送子模块,用于将砍块场景状态和目标高度发送给每个下层执行器;
回滚结果接收子模块,用于在接收到每个下层执行器返回的回滚成功消息时,将缓存数据回滚至目标高度,并根据回滚后的状态,对内存信息进行更新。
继续参阅图3,该区块链中交易异步执行装置还包括下层执行器,该下层执行器包括:交易块接收子模块35、交易执行子模块36、结果反馈子模块37和状态更新子模块38。各功能模块详细说明如下:
交易块接收子模块35,用于若接收到上层出块模块发送的交易块,则向上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列;
交易执行子模块36,用于对交易块缓冲队列中的交易块进行执行;
结果反馈子模块37,用于在每个交易块被执行完成后,向上层出块模块发送针对交易块的执行结果;
状态更新子模块38,用于在接收到上层出块模块发送的执行结果的确认字符ACK时,确认执行结果的确认字符ACK对应的交易块执行完毕,从交易块缓冲队列中移除执行完毕的交易块。
可选地,交易执行子模块36包括:
数量读取单元,用于读取交易块缓冲队列中的交易块的数量,作为第二数量;
目标选取单元,用于若第二数量不为0,则从交易块缓冲队列中获取第一个交易块进行执行。
可选地,交易异步执行装置还包括:
第二检测子模块,用于定时对交易块缓冲队列中的交易块状态进行检测,得到第二检测结果;
第三交易块确定子模块,用于若第二检测结果为存在向上层出块模块发送针对交易块的执行结果,并且未接收到上层出块模块返回确认字符ACK的交易块,则将交易块作为第三交易块;
执行结果重新发送子模块,用于向上层出块模块重新发送第三交易块对应的执行结果。
可选地,区块链中交易异步执行装置还包括:
缓存清理子模块,用于若接收到上层出块模块发送的砍块场景状态和目标高度,则清空交易块缓冲队列的交易块;
回滚处理子模块,用于基于目标高度执行回滚处理;
回滚消息反馈子模块,用于在回滚成功后,向上层出块模块发送回滚成功消息。
关于区块链中交易异步执行装置的具体限定可以参见上文中对于区块链中交易异步执行方法的限定,在此不再赘述。上述区块链中交易异步执行装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
为解决上述技术问题,本申请实施例还提供计算机设备。具体请参阅图4,图4为本实施例计算机设备基本结构框图。
所述计算机设备4包括通过***总线相互通信连接存储器41、处理器42、网络接口43。需要指出的是,图中仅示出了具有组件连接存储器41、处理器42、网络接口43的计算机设备4,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。其中,本技术领域技术人员可以理解,这里的计算机设备是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器 (Digital Signal Processor,DSP)、嵌入式设备等。
所述计算机设备可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述计算机设备可以与用户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互。
所述存储器41至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或D界面显示存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,所述存储器41可以是所述计算机设备4的内部存储单元,例如该计算机设备4的硬盘或内存。在另一些实施例中,所述存储器41也可以是所述计算机设备4的外部存储设备,例如该计算机设备4上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。当然,所述存储器41还可以既包括所述计算机设备4的内部存储单元也包括其外部存储设备。本实施例中,所述存储器41通常用于存储安装于所述计算机设备4的操作***和各类应用软件,例如电子文件的控制的程序代码等。此外,所述存储器41还可以用于暂时地存储已经输出或者将要输出的各类数据。
所述处理器42在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器42通常用于控制所述计算机设备4的总体操作。本实施例中,所述处理器42用于运行所述存储器41中存储的程序代码或者处理数据,例如运行电子文件的控制的程序代码。
所述网络接口43可包括无线网络接口或有线网络接口,该网络接口43通常用于在所述计算机设备4与其他电子设备之间建立通信连接。
本申请还提供了另一种实施方式,即提供一种计算机可读存储介质,所述计算机可读存储介质存储有界面显示程序,所述界面显示程序可被至少一个处理器执行,以使所述至少一个处理器执行如上述的区块链中交易异步执行方法的步骤。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
显然,以上所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例,附图中给出了本申请的较佳实施例,但并不限制本申请的专利范围。本申请可以以许多不同的形式来实现,相反地,提供这些实施例的目的是使对本申请的公开内容的理解更加透彻全面。尽管参照前述实施例对本申请进行了详细的说明,对于本领域的技术人员来而言,其依然可以对前述各具体实施方式所记载的技术方案进行修改,或者对其中部分技术特征进行等效替换。凡是利用本申请说明书及附图内容所做的等效结构,直接或间接运用在其他相关的技术领域,均同理在本申请专利保护范围之内。

Claims (15)

  1. 一种区块链中交易异步执行方法,其特征在于,所述区块链中交易异步执行方法包括上层出块模块执行的如下步骤:
    基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器;
    在接收到所述下层执行器发送的针对交易块的确认字符ACK时,将所述确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的所述第一交易块移动到待接收缓存队列中;
    若接收到下层执行器发送的执行结果,则获取所述执行结果中包含的交易块,作为第二交易块,并对所述待接收缓存队列中,与所述第二交易块具有相同序列号的第一交易块,执行删除处理;
    向所述下层执行器传递执行结果的确认字符ACK。
  2. 如权利要求1所述的区块链中交易异步执行方法,其特征在于,在所述基于预设的触发机制,将待发送缓存队列中的交易块发送给下层执行器之前,所述区块链中交易异步执行方法还包括:
    接收共识模块传递的交易块,作为初始交易块;
    按照预设分片方式,对所述初始交易块进行分片处理,得到M个交易组,其中,M为不大于所述下层执行器个数的正整数,每个所述交易组包括至少一个交易块;
    将每个所述交易组中的交易块分发到所述待发送缓存队列中。
  3. 如权利要求1所述的区块链中交易异步执行方法,其特征在于,所述基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器包括:
    实时监听所述待发送缓存队列中的交易块的数量,作为第一数量;
    获取预设的触发数量阈值;
    对所述第一数量与所述预设的触发数量阈值进行比较,若所述第一数量大于或等于所述预设的触发数量阈值,则触发将所述待发送缓存队列中的交易块发送给每个所述下层执行器。
  4. 如权利要求1所述的区块链中交易异步执行方法,其特征在于,所述基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器还包括:
    获取预设的触发时间间隔;
    在每次将所述待发送缓存队列中的交易块发送给每个所述下层执行器时,开启计时,得到计时时长;
    若所述计时时长大于或等于预设的触发时间间隔,则触发将所述待发送缓存队列中的交易块发送给每个所述下层执行器,并重置所述计时时长。
  5. 如权利要求1至4任一项所述的区块链中交易异步执行方法,其特征在于,在所述基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器之后,所述区块链中交易异步执行方法还包括:
    定时对所述待发送缓存队列中的交易块状态进行检测,得到第一检测结果;
    若所述第一检测结果为存在已发送给所述下层执行器,并且未接收到所述下层执行器返回确认字符ACK的交易块,则将所述交易块作为第二交易块;
    将所述第二交易块发送给所述下层执行器。
  6. 如权利要求1所述的区块链中交易异步执行方法,其特征在于,所述区块链中交易异步执行方法还包括:
    若接收到共识模块发送的砍块场景状态,则根据所述砍块场景状态,确认回滚的目标高度;
    将所述砍块场景状态和所述目标高度发送给每个所述下层执行器;
    在接收到每个所述下层执行器返回的回滚成功消息时,将缓存数据回滚至所述目标高度,并根据回滚后的状态,对内存信息进行更新。
  7. 一种区块链中交易异步执行方法,其特征在于,所述区块链中交易异步执行方法包括每个下层执行器执行的如下步骤:
    若接收到上层出块模块发送的交易块,则向所述上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列;
    对所述交易块缓冲队列中的交易块进行执行;
    在每个交易块被执行完成后,向所述上层出块模块发送针对交易块的执行结果;
    在接收到上层出块模块发送的执行结果的确认字符ACK时,确认所述执行结果的确认字符ACK对应的交易块执行完毕,从所述交易块缓冲队列中移除执行完毕的交易块。
  8. 如权利要求7所述的区块链中交易异步执行方法,其特征在于,所述对所述交易块缓冲队列中的交易块进行执行,包括:
    读取所述交易块缓冲队列中的交易块的数量,作为第二数量;
    若所述第二数量不为0,则从所述交易块缓冲队列中获取第一个交易块进行执行。
  9. 如权利要求7或8所述的区块链中交易异步执行方法,其特征在于,在所述在每个交易块被执行完成后,向所述上层出块模块发送针对交易块的执行结果之后,所述交易异步执行方法还包括:
    定时对所述交易块缓冲队列中的交易块状态进行检测,得到第二检测结果;
    若所述第二检测结果为存在向所述上层出块模块发送针对交易块的执行结果,并且未接收到所述上层出块模块返回确认字符ACK的交易块,则将所述交易块作为第三交易块;
    向所述上层出块模块重新发送所述第三交易块对应的执行结果。
  10. 如权利要求7所述的区块链中交易异步执行方法,其特征在于,所述区块链中交易异步执行方法还包括:
    若接收到上层出块模块发送的砍块场景状态和目标高度,则清空所述交易块缓冲队列的交易块;
    基于所述目标高度执行回滚处理;
    在回滚成功后,向所述上层出块模块发送回滚成功消息。
  11. 一种区块链中交易异步执行***,其特征在于,所述区块链中交易异步执行***包括一个上层出块模块和至少一个下层执行器,所述上层出块模块和所述下层执行器实现如下步骤:
    所述上层出块模块基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器;
    每个所述下层执行器在接收到上层出块模块发送的交易块时,向所述上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列;
    所述上层出块模块在接收到所述下层执行器发送的针对交易块的确认字符ACK时,将所述确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的所述第一交易块移动到待接收缓存队列中;
    每个所述下层执行器对所述交易块缓冲队列中的交易块进行执行;
    每个所述下层执行器在每个交易块被执行完成后,向所述上层出块模块发送交易块的执行结果;
    所述上层出块模块若接收到下层执行器发送的执行结果,则获取所述执行结果中包含的交易块,作为第二交易块,并对所述待接收缓存队列中,与所述第二交易块具有相同序列号的第一交易块,执行删除处理;
    所述上层出块模块向所述下层执行器传递执行结果的确认字符ACK;
    所述下层执行器在接收到上层出块模块发送的执行结果的确认字符ACK时,确认所述执行结果的确认字符ACK对应的交易块执行完毕,从所述交易块缓冲队列中移除执行完毕的交易块。
  12. 一种区块链中交易异步执行装置,其特征在于,所述区块链中交易异步执行装置包括上层出块模块,所述上层出块模块包括:
    交易块发送子模块,用于基于预设的触发机制,将待发送缓存队列中的交易块发送给每个下层执行器;
    缓存更新子模块,用于在接收到所述下层执行器发送的针对交易块的确认字符ACK时,将所述确认字符ACK对应的交易块作为第一交易块,并将待发送缓存队列中的所述第一交易块移动到待接收缓存队列中;
    结果接收子模块,用于若接收到下层执行器发送的执行结果,则获取所述执行结果中包含的交易块,作为第二交易块,并对所述待接收缓存队列中,与所述第二交易块具有相同序列号的第一交易块,执行删除处理;
    结果确认子模块,用于向所述下层执行器传递执行结果的确认字符ACK。
  13. 一种区块链中交易异步执行装置,其特征在于,所述区块链中交易异步执行装置包括下层执行器,所述下层执行器包括:
    交易块接收子模块,用于若接收到上层出块模块发送的交易块,则向所述上层出块模块返回包含确认字符ACK的确认消息,并将接收到的交易块缓存到交易块缓冲队列;
    交易执行子模块,用于对所述交易块缓冲队列中的交易块进行执行;
    结果反馈子模块,用于在每个交易块被执行完成后,向所述上层出块模块发送针对交易块的执行结果;
    状态更新子模块,用于在接收到上层出块模块发送的执行结果的确认字符ACK时,确认所述执行结果的确认字符ACK对应的交易块执行完毕,从所述交易块缓冲队列中移除执行完毕的交易块。
  14. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如权利要求1至6任一项所述的区块链中交易异步执行方法,或者,所述处理器执行所述计算机可读指令时实现如权利要求7至10任一项所述的区块链中交易异步执行方法。
  15. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现如权利要求1至6任一项所述的区块链中交易异步执行方法,或者,所述计算机可读指令被处理器执行时实现如权利要求7至10任一项所述的区块链中交易异步执行方法。
     
PCT/CN2021/073905 2020-12-31 2021-01-27 区块链中交易异步执行方法、***及相关设备 WO2022141711A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011640101.7 2020-12-31
CN202011640101.7A CN112883107B (zh) 2020-12-31 2020-12-31 区块链中交易异步执行方法、***及相关设备

Publications (1)

Publication Number Publication Date
WO2022141711A1 true WO2022141711A1 (zh) 2022-07-07

Family

ID=76046651

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/073905 WO2022141711A1 (zh) 2020-12-31 2021-01-27 区块链中交易异步执行方法、***及相关设备

Country Status (2)

Country Link
CN (1) CN112883107B (zh)
WO (1) WO2022141711A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113568981B (zh) * 2021-09-24 2022-01-07 腾讯科技(深圳)有限公司 一种交易数据处理方法、装置、设备以及介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180300382A1 (en) * 2017-04-12 2018-10-18 Vijay K. Madisetti Method and System for Tuning Blockchain Scalability for Fast and Low-Cost Payment and Transaction Processing
CN108804112A (zh) * 2018-05-22 2018-11-13 上海分布信息科技有限公司 一种区块链落账处理方法及***
CN108846749A (zh) * 2018-05-31 2018-11-20 杭州秘猿科技有限公司 一种基于区块链技术的分片化的交易执行***及方法
CN110868434A (zh) * 2018-08-27 2020-03-06 深圳金刚链计算技术有限公司 一种多层分片架构的区块链共识方法及***
CN111026511A (zh) * 2019-11-20 2020-04-17 中国科学院计算技术研究所 基于事务数据分区-链间融合的区块链并行***及方法
CN111680050A (zh) * 2020-05-25 2020-09-18 杭州趣链科技有限公司 一种联盟链数据的分片处理方法、设备和存储介质

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108427601A (zh) * 2017-02-13 2018-08-21 北京航空航天大学 一种私有链节点的集***易处理方法
CN108764906A (zh) * 2018-05-30 2018-11-06 深圳市元征科技股份有限公司 一种服务器及其区块链交易确认方法、装置、存储介质
CN108776897B (zh) * 2018-06-05 2020-04-21 腾讯科技(深圳)有限公司 数据处理方法、装置、服务器及计算机可读存储介质
CN109064328B (zh) * 2018-07-09 2022-04-15 夸克链科技(深圳)有限公司 一种区块链的共识方法
EP3598365A1 (en) * 2018-07-17 2020-01-22 Siemens Aktiengesellschaft Traffic shaping for transactions of a distributed database system
CN110543788B (zh) * 2019-09-11 2024-05-03 腾讯科技(深圳)有限公司 数据存储方法、装置、计算机可读存储介质和计算机设备
CN111383031B (zh) * 2020-05-29 2020-09-22 支付宝(杭州)信息技术有限公司 一种区块链中的智能合约执行方法、***和电子设备

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180300382A1 (en) * 2017-04-12 2018-10-18 Vijay K. Madisetti Method and System for Tuning Blockchain Scalability for Fast and Low-Cost Payment and Transaction Processing
CN108804112A (zh) * 2018-05-22 2018-11-13 上海分布信息科技有限公司 一种区块链落账处理方法及***
CN108846749A (zh) * 2018-05-31 2018-11-20 杭州秘猿科技有限公司 一种基于区块链技术的分片化的交易执行***及方法
CN110868434A (zh) * 2018-08-27 2020-03-06 深圳金刚链计算技术有限公司 一种多层分片架构的区块链共识方法及***
CN111026511A (zh) * 2019-11-20 2020-04-17 中国科学院计算技术研究所 基于事务数据分区-链间融合的区块链并行***及方法
CN111680050A (zh) * 2020-05-25 2020-09-18 杭州趣链科技有限公司 一种联盟链数据的分片处理方法、设备和存储介质

Also Published As

Publication number Publication date
CN112883107A (zh) 2021-06-01
CN112883107B (zh) 2022-05-17

Similar Documents

Publication Publication Date Title
WO2018076760A1 (zh) 基于区块链的交易事务处理方法、***、电子装置及存储介质
CN104168093B (zh) 一种文件传输方法及装置
CN110247984B (zh) 业务处理方法、装置及存储介质
CN115004673B (zh) 消息推送方法、装置、电子设备及计算机可读介质
CN110401711B (zh) 数据处理方法、装置、***及存储介质
CN112671760A (zh) 基于Socket的客户端跨平台网络通信方法及其相关设备
CN110502364A (zh) 一种OpenStack平台下大数据沙箱集群的跨云备份恢复方法
WO2022141711A1 (zh) 区块链中交易异步执行方法、***及相关设备
US9332071B2 (en) Data stage-in for network nodes
CN106550021B (zh) 推送消息的推送方法及装置
CN108241616B (zh) 消息推送方法和装置
US9686320B2 (en) Crisscross cancellation protocol
CN116366634A (zh) 一种文件下载方法、装置、终端、源服务器及介质
WO2022022442A1 (zh) 数据处理方法、装置、智能网卡和服务器
EP3293924B1 (en) Message processing method and device
CN114756356A (zh) 任务处理方法、工作节点设备、主节点设备及存储介质
CN112866133A (zh) 用于获取共用最大分段大小mss的方法及装置
CN110392104A (zh) 数据同步方法、***、服务器及存储介质
CN114760219B (zh) 多终端的通信方法、装置、电子设备及存储介质
WO2023173816A1 (zh) 一种数据处理方法、装置、设备、存储介质和程序产品
CN117692111A (zh) 数据传输方法、装置、电子设备和存储介质
CN118041998A (zh) 数据处理方法、装置、设备以及介质
CN115914380A (zh) 基于Zlib压缩算法的云计算资源管理器通信延迟优化方法
CN114584556A (zh) 文件传输方法和装置
CN117519753A (zh) 一种端设备的远程升级方法、装置、设备及存储介质

Legal Events

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

Ref document number: 21912491

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21912491

Country of ref document: EP

Kind code of ref document: A1