Block chain transaction cancelling method and device and block chain transaction system

By receiving transaction cancellation requests in the blockchain network, deleting target transactions, storing transaction hashing and broadcasting transaction cancellation events, the problems of high transaction costs and Nonce waste in the prior art are solved, and more flexible and economical transactions are achieved. Cancel the process.

CN119402502AActive Publication Date: 2025-02-07HANGZHOU HIGH-TECH ZONE (BINJIANG) INSTITUTE OF BLOCKCHAIN & DATA SECURITY
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510002505.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-02
Publication Date
2025-02-07
Estimated Expiration
2045-01-02

AI Technical Summary

Technical Problem

The process of canceling transactions in existing blockchain networks is expensive and leads to waste of Nonce, limiting transaction flexibility.

Method used

By receiving a transaction cancellation request, the target node deletes the target transaction from the local transaction pool and stores the transaction hash to the cancel transaction cache pool, generates a transaction cancellation event and broadcasts it to other nodes in the blockchain, realizing successful cancellation of the transaction.

Benefits of technology

There is no need to initiate new transactions to cover the target transactions to be cancelled, which significantly reduces the cost of canceling transactions for users, avoids the waste of Nonce values, and improves the flexibility of cancellation of transactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119402502A_ABST
    Figure CN119402502A_ABST
Patent Text Reader

Abstract

The embodiment of the invention is suitable for the technical field of block chains, and provides a block chain transaction cancelling method and device and a block chain transaction system.The method comprises the steps that a transaction cancelling request is received, and the transaction cancelling request carries transaction hash of a to-be-cancelled target transaction; deleting the target transaction from a local transaction pool of a target node, wherein the target node is a node initiating the target transaction in the block chain; storing the transaction hash of the target transaction to a transaction cancelling cache pool of the target node; and generating a transaction cancel event for the target transaction, and broadcasting the transaction cancel event to other nodes in the block chain. Through adoption of the method, the target transaction to be cancelled can be deleted in the local transaction pool, and the transaction cancellation event generated for the target transaction is broadcasted to other nodes, so that the target transaction is cancelled, and the flexibility of block chain transaction cancellation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application belong to the field of blockchain technology, and in particular, relate to a blockchain transaction cancellation method, device, and blockchain transaction system. Background Art

[0002] Transactions initiated by users in the blockchain may need to be canceled. For example, when setting up a transaction, a user may want to cancel the transaction due to an incorrect estimate of the cost or an operational error. However, in the existing blockchain network, the process of canceling transactions has many flaws, mainly reflected in the high cancellation cost and the waste of non-repetitive random value Nonce that is used once.

[0003] Specifically, in the existing blockchain network, canceling a transaction usually requires the user to initiate a new transaction and use the newly initiated transaction to cover the transaction that needs to be canceled. However, the user needs to pay a higher cost to initiate a new transaction to cover the original transaction, which makes the process of canceling the transaction costly. In addition, each transaction consumes the Nonce of the user's account. Canceling a transaction by initiating a new transaction to cover the original transaction will occupy an additional Nonce. In smart contracts with frequent interactions, the waste of Nonce also limits the flexibility of future transactions. Summary of the invention

[0004] In view of this, the embodiments of the present application provide a blockchain transaction cancellation method, device and blockchain transaction system to improve the flexibility of canceling transaction operations.

[0005] A first aspect of an embodiment of the present application provides a blockchain transaction cancellation method, comprising: receiving a transaction cancellation request, wherein the transaction cancellation request carries a transaction hash of a target transaction to be canceled; Deleting the target transaction from the local transaction pool of the target node, where the target node is the node initiating the target transaction in the blockchain; Storing the transaction hash of the target transaction in the cancel transaction cache pool of the target node; A transaction cancellation event is generated for the target transaction, and the transaction cancellation event is broadcast to other nodes in the blockchain.

[0006] Optionally, receiving a transaction cancellation request includes: A transaction cancellation request for the initiated target transaction is received through a transaction cancellation interface of the target node, wherein the transaction cancellation interface is constructed based on a remote procedure call transmission protocol, and each node in the blockchain is configured with the transaction cancellation interface.

[0007] Optionally, deleting the target transaction from the local transaction pool of the target node includes: Extracting signature information from the transaction cancellation request, and verifying the transaction cancellation request according to the signature information; When the transaction cancellation request is verified, the target transaction corresponding to the transaction hash is deleted from the local transaction pool of the target node.

[0008] Optionally, storing the transaction hash of the target transaction in a canceled transaction cache pool of the target node includes: Determine the transaction cancellation time; Based on the transaction cancellation time, the transaction hash of the target transaction is stored in a local canceled transaction cache pool of the target node, and the canceled transaction cache pool is constructed using a key-value pair structure.

[0009] Optionally, after storing the transaction hash of the target transaction in the cancel transaction cache pool of the target node, the method further includes: The transaction hash of the canceled target transaction and the corresponding transaction cancellation time are persistently stored.

[0010] Optionally, it also includes: When the target node is started, traverse the transaction cancellation data in the persistent storage, wherein the transaction cancellation data uses information including the transaction cancellation time as a key; According to the transaction cancellation time, the transaction cancellation data within the target time range is loaded into the local canceled transaction cache pool of the target node.

[0011] Optionally, generating a transaction cancellation event for the target transaction, and broadcasting the transaction cancellation event to other nodes in the blockchain, includes: Generate a transaction cancellation event based on the transaction hash of the target transaction and the corresponding transaction cancellation time, and add the transaction cancellation event to a broadcast queue; The transaction cancellation event is broadcasted to other nodes in the blockchain through the broadcast queue, and the transaction cancellation event carries a transaction hash that uniquely identifies the target transaction.

[0012] Optionally, after generating a transaction cancellation event for the canceled target transaction and broadcasting the transaction cancellation event to other nodes in the blockchain, the method further includes: Receiving feedback information returned by other nodes in the blockchain regarding the transaction cancellation event; If the feedback information returned by other nodes all indicates that the target transaction has been cancelled, it is confirmed that the target transaction has been cancelled successfully.

[0013] A second aspect of an embodiment of the present application provides a blockchain transaction cancellation device, including: A receiving module, configured to receive a transaction cancellation request, wherein the transaction cancellation request carries a transaction hash of a target transaction to be canceled; A deletion module, used to delete the target transaction from the local transaction pool of the target node, where the target node is the node initiating the target transaction in the blockchain; A storage module, used for storing the transaction hash of the target transaction in a cancel transaction cache pool of the target node; A broadcast module is used to generate a transaction cancellation event for the target transaction and broadcast the transaction cancellation event to other nodes in the blockchain.

[0014] A third aspect of an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the computer device implements the method described in the first aspect above to cancel a target transaction.

[0015] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a computer, the method described in the first aspect above is implemented to cancel a target transaction.

[0016] A fifth aspect of an embodiment of the present application provides a computer program product, including a computer program. When the computer program is run, the method described in the first aspect is executed to cancel a target transaction.

[0017] Compared with the prior art, the embodiments of the present application have the following beneficial effects: In an embodiment of the present application, by receiving a transaction cancellation request, the target node can delete the target transaction corresponding to the transaction hash carried in the transaction cancellation request from the local transaction pool, and store the transaction hash of the target transaction in the cancellation transaction cache pool. Then, the target node can generate a transaction cancellation event for the target transaction, and broadcast the transaction cancellation event to other nodes in the blockchain, requesting other nodes to perform the same cancellation operation as the target node, thereby achieving successful cancellation of the target transaction. In an embodiment of the present application, a request to cancel the target transaction is broadcast to each node in the blockchain through a full network broadcast mechanism, thereby ensuring the consistency of the cancellation operation in the distributed network. The entire cancellation operation process does not require the initiation of a new transaction to cover the target transaction to be canceled, avoiding the cost of initiating a new transaction, and significantly reducing the cost of users canceling transactions. Since there is no need to initiate a new transaction, the waste of Nonce value is also avoided, which improves the flexibility of transaction cancellation. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0019] Figure 1 It is a schematic diagram of a blockchain transaction cancellation method provided in an embodiment of the present application; Figure 2 It is a comparative schematic diagram of a blockchain transaction cancellation method provided in an embodiment of the present application; Figure 3 It is a schematic diagram of a blockchain transaction cancellation device provided in an embodiment of the present application; Figure 4 It is a schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] In the following description, specific details such as specific system structures, technologies, etc. are proposed for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from hindering the description of the present application.

[0021] The technical solution of the present application is described below through specific embodiments.

[0022] Reference Figure 1 , showing a schematic diagram of a blockchain transaction cancellation method provided in an embodiment of the present application, which may specifically include the following steps: S101. Receive a transaction cancellation request, where the transaction cancellation request carries a transaction hash of a target transaction to be canceled.

[0023] It should be noted that this method can be applied to blockchain, that is, this method can be applied to cancel transactions that need to be canceled in the blockchain. The above cancellation operation can be specifically performed by the target node in the blockchain. The target node can be a node that receives the target transaction initiated by the user and receives the transaction cancellation request initiated by the user. The various operations performed by the above target node can be implemented based on a computer device. Therefore, the execution subject of the embodiment of the present application can be a target node or a computer device that implements the various functions of the target node. The target node or computer device can cancel the transaction initiated in the blockchain by executing the various steps of the method provided in the embodiment of the present application, thereby improving the flexibility of the transaction cancellation operation.

[0024] In the embodiment of the present application, a transaction cancellation request may be initiated by a user who wishes to cancel a certain transaction that has been initiated. The request may be used to request the target node to revoke or cancel the initiated transaction, such as the target transaction. The transaction cancellation request may carry the transaction hash (TransactionHash) of the target transaction to be canceled. The transaction hash can be used to uniquely identify a transaction.

[0025] In addition, in order to improve security, the transaction cancellation request may also carry the signature information of the user who initiated the request, and the signature information may be used to verify the legitimacy of the transaction request initiated by the user in subsequent steps. For example, by verifying the signature information, it can be confirmed whether the user who initiated the transaction request is the same user as the user who initiated the target transaction to be canceled.

[0026] The transaction cancellation request initiated by the user may be received by the target node. Typically, the target node receiving the transaction cancellation request may be the same node as the node that receives the initiated target transaction.

[0027] In a possible implementation of an embodiment of the present application, the target node can receive a transaction cancellation request for an initiated target transaction through a configured transaction cancellation interface. In one example, the transaction cancellation interface can be an interface constructed based on a remote procedure call (RPC) transmission protocol. Specifically, the transaction cancellation interface can be constructed based on the RPC protocol in JSON (JavaScript Object Notation) format, and each node in the blockchain can be configured with the above-mentioned type of transaction cancellation interface according to the same protocol. In this way, any node can receive the corresponding request through the above-mentioned transaction cancellation interface when facing a transaction cancellation request initiated by a user to cancel a transaction.

[0028] JSON-RPC is a lightweight RPC protocol that uses JSON format to transmit requests and responses. It supports method calls and parameter passing, and implements interaction between clients and servers through simple HTTP communication.

[0029] S102: Delete the target transaction from the local transaction pool of the target node, where the target node is the node that initiates the target transaction in the blockchain.

[0030] For the initiated target transaction, when the target node receives the transaction, it can add the transaction to the local transaction pool and broadcast the transaction to other nodes in the blockchain. Therefore, if the target transaction is not cancelled and not on the chain, the local transaction pool of the target node stores the relevant information of the target transaction.

[0031] When the target node receives a transaction cancellation request, it can delete the target transaction corresponding to the request from the local transaction pool.

[0032] In a possible implementation of the embodiment of the present application, when the target node receives a transaction cancellation request, the transaction hash carried in the request can be extracted. Since the transaction hash can uniquely identify a transaction, the target node can find the target transaction to be canceled in the local transaction pool according to the transaction hash and delete the target transaction.

[0033] In another possible implementation of the embodiment of the present application, the transaction cancellation request may also carry the user's signature information. The target node can verify the legitimacy of the received transaction cancellation request through the signature information, and then delete the corresponding target transaction from the local transaction pool after the verification is passed.

[0034] Specifically, upon receiving a transaction cancellation request, the target node can extract the signature information and transaction hash in the transaction cancellation request and verify the transaction cancellation request based on the signature information. For example, verify whether the user who initiated the transaction cancellation request is the same user as the user who initiated the target transaction, thereby confirming the legitimacy of the transaction cancellation request. When the transaction cancellation request is verified, the target node can delete the target transaction corresponding to the transaction hash from the local transaction pool.

[0035] S103: Store the transaction hash of the target transaction in the cancel transaction cache pool of the target node.

[0036] In an embodiment of the present application, for a target transaction that has been deleted from a local transaction pool, the target node may store its transaction hash in a canceled transaction cache pool, which may be used to record or store relevant information of canceled or to-be-cancelled transactions.

[0037] In a possible implementation of the embodiment of the present application, the cancel transaction cache pool can be constructed using a key-value pair structure. For example, a map structure can be used to construct the cancel transaction cache pool in memory. Map is a data structure often used to store key-value pairs, which is implemented based on a hash table. Its search, insertion, and deletion operations are highly efficient and are usually completed within O(1) time, so it is suitable for use as an efficient memory cache and can achieve fast query. Therefore, constructing a cancel transaction cache pool based on a map structure can provide a fast transaction status query capability.

[0038] In the embodiment of the present application, the transaction hash stored in the cancel transaction cache pool may have time information, and the time information may be the transaction cancellation time of the target transaction. Therefore, when storing the transaction hash of the target transaction in the cancel transaction cache pool of the target node, the target node may first determine the transaction cancellation time of the target transaction, which may be the time when the user initiates the transaction cancellation request, or the time when the target node receives the transaction request, or the time when the target node deletes the target transaction to be canceled from the local transaction pool, which is not limited in the embodiment of the present application.

[0039] After determining the transaction cancellation time, the target node may store the transaction hash of the target transaction in a local canceled transaction cache pool of the target node based on the transaction cancellation time.

[0040] In a possible implementation of the embodiment of the present application, in order to achieve data persistence and avoid data loss after node restart or crash, the target node can also perform persistent processing on the relevant information of the target transaction stored in the canceled transaction cache pool. Specifically, the target node can store the transaction hash of the canceled target transaction and the corresponding transaction cancellation time persistently.

[0041] In an embodiment of the present application, a key-value pair storage database may be used as persistent storage. In one example, a LevelDB database may be used as persistent storage. LevelDB is a high-performance embedded key-value pair storage database that uses a log structure merge tree (LSM Tree) as the underlying structure and supports fast random read and write operations and data persistence.

[0042] In a possible implementation of the embodiment of the present application, when a key-value pair storage database is used as persistent storage, the stored transaction cancellation data may be keyed by information including the transaction cancellation time. Exemplarily, the key design may include the transaction hash of the target transaction and the corresponding transaction cancellation time. For example, the key design is in the format of yyyy-mm-dd:transactionHash. Among them, yyyy-mm-dd is an example of the transaction cancellation time, indicating the year, month, day, and other information when the target transaction is cancelled.

[0043] In this way, by persistently storing the transaction hash of the canceled target transaction, both performance and reliability can be taken into account, ensuring that the record of the canceled transaction will not be lost even when an abnormality occurs in the system.

[0044] For example, when the target node starts, the transaction cancellation data in the persistent storage can be traversed, and the transaction cancellation data within the target time range can be loaded into the local transaction cancellation cache pool of the target node according to the transaction cancellation time, so that the transaction cancellation data that meets the time requirement can be loaded into the transaction cancellation cache pool again to provide fast query capabilities for transaction cancellation data and reduce query latency.

[0045] S104: Generate a transaction cancellation event for the target transaction, and broadcast the transaction cancellation event to other nodes in the blockchain.

[0046] In the embodiment of the present application, through the processing of the aforementioned S101-S104, the target node has deleted the target transaction to be canceled in the local transaction pool. In order to successfully cancel the target transaction, the target node also needs to broadcast the information of canceling the target transaction to other nodes in the blockchain to request other nodes to perform the same operation and completely cancel the target transaction.

[0047] In an embodiment of the present application, the target node may generate a transaction cancellation event for the target transaction, and broadcast the transaction cancellation event to other nodes in the blockchain.

[0048] In the embodiment of the present application, a structure may be defined to represent a transaction cancellation event, and the structure may include information such as a transaction hash, a transaction cancellation time, etc. In this way, a transaction cancellation event may be generated based on the transaction hash of the target transaction and the corresponding transaction cancellation time.

[0049] The transaction cancellation event can be added to the broadcast queue, and the transaction cancellation event can be broadcast to other nodes in the blockchain through the broadcast queue. Since the transaction cancellation event can carry the transaction hash that uniquely identifies the target transaction, when each node receives the transaction cancellation event broadcast by the target node, it can query the corresponding target transaction based on the transaction hash and perform the same cancellation operation as the target transaction. For example, when each node queries the target transaction, it can delete the target transaction from the local transaction pool of the node, and store the deleted target transaction's transaction hash together with the transaction cancellation time in the local cancellation transaction cache pool.

[0050] In a possible implementation manner of an embodiment of the present application, the target node broadcasts the transaction cancellation event to other nodes using the existing network protocol of the blockchain, for example, using the DevP2P protocol to broadcast the transaction cancellation event, which is not limited in the embodiment of the present application.

[0051] In an embodiment of the present application, after the target node broadcasts the transaction cancellation event to other nodes in the blockchain, it can also receive feedback information returned by other nodes regarding the transaction cancellation event. If the feedback information returned by other nodes all indicates that the target transaction has been canceled, that is, each node has deleted the corresponding target transaction in the local transaction pool, then the target node can confirm that the target transaction has been successfully canceled.

[0052] In an embodiment of the present application, by receiving a transaction cancellation request, the target node can delete the target transaction corresponding to the transaction hash carried in the transaction cancellation request from the local transaction pool, and store the transaction hash of the target transaction in the cancellation transaction cache pool. Then, the target node can generate a transaction cancellation event for the target transaction, and broadcast the transaction cancellation event to other nodes in the blockchain, requesting other nodes to perform the same cancellation operation as the target node, thereby achieving successful cancellation of the target transaction. The embodiment of the present application transmits the request to cancel the target transaction to each node in the blockchain in the form of a broadcast through the whole network broadcast mechanism, so as to ensure the consistency of the cancellation operation in the distributed network. The entire cancellation operation process does not require the initiation of a new transaction to cover the target transaction to be canceled, avoiding the cost of initiating a new transaction, and significantly reducing the cost of users canceling transactions. Since there is no need to initiate a new transaction, the waste of Nonce value is also avoided, and the flexibility of transaction cancellation is improved.

[0053] It should be noted that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0054] For ease of understanding, the following is an introduction to the blockchain transaction cancellation method provided in an embodiment of the present application in combination with a complete example, and a comparison with the method for canceling transactions in the prior art is combined to illustrate the beneficial effects of the blockchain transaction cancellation method provided in an embodiment of the present application.

[0055] like Figure 2 , which is a comparative schematic diagram of a blockchain transaction cancellation method provided in an embodiment of the present application. Figure 2 The difference between the process of using the blockchain transaction cancellation method provided in the embodiment of the present application to cancel the transaction and the process of using the prior art to cancel the blockchain transaction is compared. Figure 2 Part (a) is a schematic diagram of the execution process of canceling a blockchain transaction in the prior art. Figure 2 Part (b) is a schematic diagram of the execution process of the blockchain transaction cancellation method provided in the application embodiment.

[0056] Reference Figure 2 As shown in part (a) of , after a user initiates a transaction, for example Figure 2If you want to cancel the transaction 1 shown in part (a) of the transaction, the entire operation process may include the following steps: Step 1: The user initiates a transaction 1, involving Figure 2 The steps numbered 1.1-1.3 in part (a) of FIG.

[0057] 1.1, construct transaction 1: the user initiates an initial transaction through the account, such as transaction 1; 1.2, Sending Transaction 1: The blockchain node, such as the target node, receives Transaction 1 and adds Transaction 1 to the local transaction pool; 1.3, Broadcast Transaction 1: The target node broadcasts Transaction 1 to other nodes in the blockchain.

[0058] Step 2: The user initiates a request to cancel transaction 1, involving Figure 2 The steps numbered 1.4-1.6 in part (a) of FIG.

[0059] 1.4, Cancel Transaction 1: The user initiates a request to cancel Transaction 1 through the account; 1.5, Sending a higher-cost transaction 2: In order to cancel the initiated transaction 1, the target node needs to send a higher-cost transaction 2 and add transaction 2 to the local transaction pool; the Nonce value of transaction 2 is the same as that of transaction 1; 1.6, Broadcast Transaction 2: The target node broadcasts Transaction 2 to other nodes in the blockchain.

[0060] Step 3: Execute the operation of canceling transaction 1, involving Figure 2 The steps numbered 1.7-1.9 in part (a) of FIG.

[0061] 1.7, Transaction 2 is put on the chain: Since the fee of Transaction 2 is higher, the blockchain will perform the on-chain operation on Transaction 2, causing Transaction 1 to fail; 1.8, Query transaction: The target node can query the cancellation processing result of transaction 1; 1.9, return the transaction execution result information: After transaction 2 is successfully uploaded to the chain, it means that transaction 2 is executed successfully, that is, the cancellation operation of transaction 1 is successful, and transaction 1 is canceled.

[0062] So far, according to Figure 2 The execution process of canceling the transaction shown in part (a) is completed.

[0063] Reference Figure 2 As shown in part (b) of the present application, the blockchain transaction cancellation method provided in the present application embodiment is used to cancel a transaction initiated by a user, for example, to cancel Figure 2 For transaction 1 shown in part (b) of the above, the entire operation process may include the following steps: Step 1: The user initiates a transaction 1, involving Figure 2 The steps numbered 2.1-2.3 in part (b) of FIG.

[0064] 2.1, construct transaction 1: the user initiates an initial transaction through the account, such as transaction 1; 2.2, Sending Transaction 1: The blockchain node, such as the target node, receives Transaction 1 and adds Transaction 1 to the local transaction pool; 2.3, Broadcast Transaction 1: The target node broadcasts Transaction 1 to other nodes in the blockchain.

[0065] The above steps 2.1-2.3 are the same as the process of initiating a transaction in the prior art, for example Figure 2 The steps 1.1-1.3 in part (a) are the same.

[0066] Step 2: The user initiates a request to cancel transaction 1, involving Figure 2 The steps numbered 2.4-2.5 in part (b) of FIG.

[0067] 2.4-2.5, Initiate a request to cancel transaction 1: The user initiates a transaction cancellation request through the account, requesting to cancel the execution of transaction 1; The user can submit a request to cancel transaction 1 to the target node through the account, that is, the user initiates the transaction cancellation request in the above embodiments to the target node. The target node can receive the request through the configured transaction cancellation interface.

[0068] In the embodiment of the present application, each node in the blockchain can be configured with a transaction cancellation interface, which can be constructed based on the JSON-RPC protocol. The parameter definition of the transaction cancellation interface can be expressed as follows:

[0069] According to the above parameter design, the user can cancel a transaction by initiating the following request through the account, for example Figure 2 Transaction 1 in part (b): curl -X POST http: / / localhost:8545 -H "Content-Type: application / json" -d '{ "jsonrpc": "2.0", "method": "eth_cancelTransaction", "params": [ { "transactionHash": "0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234", "from": "0xAbcdef1234567890Abcdef1234567890Abcdef12", "signature": "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", } ], "id": 1 }' The above transaction cancellation request carries the transaction hash (TransactionHash) and signature information (Signature) of the transaction 1 to be canceled.

[0070] By comparison Figure 2 As can be seen from parts (a) and (b) in the figure, when a transaction is canceled using the method provided in the embodiment of the present application, there is no need to construct a new transaction with a higher fee.

[0071] Step 3: The target node executes the operation of canceling transaction 1, involving Figure 2 Step numbered 2.6 in part (b) of FIG.

[0072] 2.6, Delete Transaction 1 and Add Transaction Hash to the Cache Pool: After receiving the transaction cancellation request, the target node can delete the transaction 1 to be canceled from the local transaction pool and store the transaction hash of the transaction 1 to the canceled transaction cache pool.

[0073] In the embodiment of the present application, when receiving a transaction cancellation request, the target node may first verify the legitimacy of the request. The legitimacy verification of the transaction cancellation request may be implemented through the signature information (Signature) carried in the request.

[0074] If the legitimacy verification of the transaction cancellation request passes, the target node can delete the transaction 1 to be canceled from the local transaction pool and store the transaction hash of the deleted transaction 1 in the cancellation transaction cache pool.

[0075] In the embodiment of the present application, when constructing a canceled transaction cache pool, a map structure can be used as a high-speed cache in memory to provide fast transaction status query capabilities. At the same time, in order to achieve data persistence and avoid data loss after node restart or crash, leveldb can be used as the underlying storage. Through this design, performance and reliability can be taken into account to ensure that the record of canceled transactions will not be lost even when an abnormality occurs in the system.

[0076] In one example, a map structure is used as a high-speed cache in memory. A map can be maintained in memory with transaction Hash as the key and transaction cancellation time as the value. In this way, the recently canceled transactions can be quickly processed and queried based on the transaction cancellation time.

[0077] In another example, for persistent storage, the LevelDB structure can be used, and the corresponding transaction cancellation data can be stored in groups according to date, and the key can be designed in the format of yyyy-mm-dd:transactionHash to ensure efficient query based on date. The value of the transaction cancellation data is stored as detailed information of the canceled transaction, including: transaction hash, transaction cancellation time, etc.

[0078] In a possible implementation of the embodiment of the present application, a storage and cleanup process for a transaction cancellation buffer pool and persistent storage is also provided.

[0079] Storage Logic When a transaction is canceled, it can be: ① Update the memory cache, that is, update the local transaction cancellation cache pool, and add the transaction hash transactionHash and transaction cancellation time of the canceled transaction to the map. For example, Figure 2 The transaction hash and transaction cancellation time of transaction 1 canceled in part (b) are stored in the map.

[0080] ② Write the transaction cancellation data into the persistent storage LevelDB. The key of the transaction cancellation data can be yyyy-mm-dd:transactionHash, and the value is the detailed information of the transaction cancellation.

[0081] Regular cleanup strategy You can perform the cleanup task according to a set period, such as once a day. The specific steps may include: ① Get the current date and calculate the date range that needs to be retained (such as "today" and "yesterday").

[0082] ② Traverse the keys in LevelDB and check whether the date part is within the reserved range: ③ If within the range, keep the corresponding transaction cancellation data.

[0083] ④ If it is not within the range, delete the corresponding key-value pair, that is, delete the transaction cancellation data that is not within the corresponding date range from the persistent storage.

[0084] ⑤ Clean up all deleted transactionHash in the memory cache.

[0085] Reload Data ① When the node starts, load the transaction cancellation data within the set time range (for example, the last two days) from the persistent storage LevelDB into the memory cache.

[0086] ② Traverse the keys in the persistent storage LevelDB and extract the data that matches the date range.

[0087] ③ Load this data into the map to reduce the time delay of the first query.

[0088] Step 4: The target node broadcasts the transaction cancellation event to other nodes to complete the cancellation of transaction 1, involving Figure 2 Part (b) in the figure is step 2.7.

[0089] 2.7. Broadcasting transaction cancellation events: The target node can generate a corresponding transaction cancellation event for canceling transaction 1 and broadcast it to other nodes in the blockchain.

[0090] In the embodiment of the present application, a structure may be defined to represent a transaction cancellation event, and the structure may include the following information: Transaction Hash: The unique identifier of the canceled transaction. For example, the transaction hash that identifies transaction 1.

[0091] Cancellation initiator (from): The account address that initiated the cancellation operation.

[0092] Transaction cancellation time (timestamp): the specific time when the transaction was canceled.

[0093] When a user requests to cancel a transaction through the transaction cancellation interface and the request is successfully verified, the target node can generate a transaction cancellation event and add it to the broadcast queue. Through the broadcast queue, the transaction cancellation event is broadcast to other nodes in the blockchain to notify other nodes that the transaction has been canceled.

[0094] In the embodiment of the present application, the existing P2P network protocol (such as DevP2P) of the blockchain can be used for broadcasting. After receiving the broadcasted transaction cancellation event, each other node can process the received event in each node and update the local transaction pool and the cancellation transaction cache pool.

[0095] Step 5: Query transaction status, involving Figure 2 The steps numbered 2.8-2.9 in part (b) of FIG.

[0096] 2.8-2.9, Transaction Status Query: The target node can check the blockchain status first. If the transaction has been on the chain, it means that the cancellation operation has failed, and the transaction buffer pool needs to be cleaned up and the "on the chain" status is returned. Otherwise, check the "Cancel Transaction Cache Pool". If the hash is found, the "Cancelled" status is returned. Confirm that the transaction has been canceled.

[0097] The embodiment of the present application provides a new transaction cancellation mechanism by introducing the node's "transaction cancellation interface", the network-wide "transaction cancellation event broadcast" and the "cancellation transaction cache pool". Users do not need to send new transactions with higher fees to cancel the original transactions, which not only reduces the cost of user transaction cancellation, but also avoids the consumption of Nonce values, thereby improving the flexibility of transaction cancellation.

[0098] Reference Figure 3 , shows a schematic diagram of a blockchain transaction cancellation device provided in an embodiment of the present application, which may specifically include a receiving module 301, a deletion module 302, a storage module 303 and a broadcasting module 304, wherein: The receiving module 301 is used to receive a transaction cancellation request, wherein the transaction cancellation request carries a transaction hash of a target transaction to be canceled; A deletion module 302 is used to delete the target transaction from the local transaction pool of the target node, where the target node is the node initiating the target transaction in the blockchain; The storage module 303 is used to store the transaction hash of the target transaction in the cancel transaction cache pool of the target node; The broadcast module 304 is used to generate a transaction cancellation event for the target transaction, and broadcast the transaction cancellation event to other nodes in the blockchain.

[0099] In a possible implementation of the embodiment of the present application, the receiving module 301 may be specifically used for: A transaction cancellation request for the initiated target transaction is received through a transaction cancellation interface of the target node, wherein the transaction cancellation interface is constructed based on a remote procedure call transmission protocol, and each node in the blockchain is configured with the transaction cancellation interface.

[0100] In a possible implementation of the embodiment of the present application, the deletion module 302 may be specifically used to: Extracting signature information from the transaction cancellation request, and verifying the transaction cancellation request according to the signature information; When the transaction cancellation request is verified, the target transaction corresponding to the transaction hash is deleted from the local transaction pool of the target node.

[0101] In a possible implementation of the embodiment of the present application, the storage module 303 may be specifically used for: Determine the transaction cancellation time; Based on the transaction cancellation time, the transaction hash of the target transaction is stored in a local canceled transaction cache pool of the target node, and the canceled transaction cache pool is constructed using a key-value pair structure.

[0102] In a possible implementation of the embodiment of the present application, the storage module 303 may also be used for: The transaction hash of the canceled target transaction and the corresponding transaction cancellation time are persistently stored.

[0103] In a possible implementation manner of the embodiment of the present application, the device may further include a loading module, and the loading module may be specifically used to: When the target node is started, traverse the transaction cancellation data in the persistent storage, wherein the transaction cancellation data uses information including the transaction cancellation time as a key; According to the transaction cancellation time, the transaction cancellation data within the target time range is loaded into the local canceled transaction cache pool of the target node.

[0104] In a possible implementation of the embodiment of the present application, the broadcast module 304 may be specifically used for: Generate a transaction cancellation event based on the transaction hash of the target transaction and the corresponding transaction cancellation time, and add the transaction cancellation event to a broadcast queue; The transaction cancellation event is broadcasted to other nodes in the blockchain through the broadcast queue, and the transaction cancellation event carries a transaction hash that uniquely identifies the target transaction.

[0105] In a possible implementation manner of the embodiment of the present application, the device may further include a confirmation module, and the confirmation module may be specifically used to: Receiving feedback information returned by other nodes in the blockchain regarding the transaction cancellation event; If the feedback information returned by other nodes all indicates that the target transaction has been cancelled, it is confirmed that the target transaction has been cancelled successfully.

[0106] The embodiment of the present application provides a blockchain transaction cancellation device, which can be a computer device in the aforementioned embodiments or one or more units, modules, etc. in a computer device capable of implementing related functions. By using the device, each step in the aforementioned method embodiments can be implemented.

[0107] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment part.

[0108] Reference Figure 4 , shows a schematic diagram of a computer device provided by an embodiment of the present application. Figure 4 As shown, the computer device 400 in the embodiment of the present application includes: a processor 410, a memory 420, and a computer program 421 stored in the memory 420 and executable on the processor 410. When the processor 410 executes the computer program 421, the steps in each embodiment of the above-mentioned blockchain transaction cancellation method are implemented, such as Figure 1 Alternatively, when the processor 410 executes the computer program 421, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 3 Functions of modules 301 to 304 are shown.

[0109] Exemplarily, the computer program 421 may be divided into one or more modules / units, which are stored in the memory 420 and executed by the processor 410 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which may be used to describe the execution process of the computer program 421 in the computer device 400. For example, the computer program 421 may be divided into a receiving module, a deleting module, a storage module, and a broadcasting module, and the specific functions of each module are as follows: A receiving module, configured to receive a transaction cancellation request, wherein the transaction cancellation request carries a transaction hash of a target transaction to be canceled; A deletion module, used to delete the target transaction from the local transaction pool of the target node, where the target node is the node initiating the target transaction in the blockchain; A storage module, used for storing the transaction hash of the target transaction in a cancel transaction cache pool of the target node; A broadcast module is used to generate a transaction cancellation event for the target transaction and broadcast the transaction cancellation event to other nodes in the blockchain.

[0110] The computer device 400 may be a device capable of implementing the functions of each step in the above-mentioned method embodiments, and the computer device 400 may be a desktop computer, a cloud server, etc. The computer device 400 may include, but is not limited to, a processor 410 and a memory 420. Those skilled in the art will understand that Figure 4 This is only an example of the computer device 400 and does not constitute a limitation of the computer device 400. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device 400 may also include input and output devices, network access devices, buses, etc.

[0111] The processor 410 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0112] The memory 420 may be an internal storage unit of the computer device 400, such as a hard disk or memory of the computer device 400. The memory 420 may also be an external storage device of the computer device 400, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 400. Further, the memory 420 may also include both an internal storage unit of the computer device 400 and an external storage device. The memory 420 is used to store the computer program 421 and other programs and data required by the computer device 400. The memory 420 may also be used to temporarily store data that has been output or is to be output.

[0113] An embodiment of the present application also discloses a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method described in the above embodiments is implemented to cancel the target transaction.

[0114] The embodiments of the present application further disclose a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a computer, the method described in the above embodiments is implemented to cancel a target transaction.

[0115] The embodiment of the present application also discloses a computer program product, including a computer program. When the computer program is executed on a computer, the computer is caused to execute the method described in the above-mentioned embodiments to cancel the target transaction.

[0116] The embodiments of the present application also disclose a blockchain transaction system, which may include multiple blockchain nodes. Any node may execute the methods described in the aforementioned embodiments to cancel the target transaction initiated by the node.

[0117] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application is described in detail with reference to the above-mentioned embodiments, a person skilled in the art should understand that the technical solutions described in the above-mentioned embodiments can still be modified, or some of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A blockchain transaction cancellation method, characterized in that: include: receiving a transaction cancellation request, wherein the transaction cancellation request carries a transaction hash of a target transaction to be canceled; Deleting the target transaction from the local transaction pool of the target node, where the target node is the node initiating the target transaction in the blockchain; Storing the transaction hash of the target transaction in the cancel transaction cache pool of the target node; A transaction cancellation event is generated for the target transaction, and the transaction cancellation event is broadcast to other nodes in the blockchain.

2. The method according to claim 1, characterized in that The receiving of the transaction cancellation request comprises: A transaction cancellation request for the initiated target transaction is received through a transaction cancellation interface of the target node, wherein the transaction cancellation interface is constructed based on a remote procedure call transmission protocol, and each node in the blockchain is configured with the transaction cancellation interface.

3. The method according to claim 1 or 2, characterized in that: The deleting the target transaction from the local transaction pool of the target node includes: Extracting signature information from the transaction cancellation request, and verifying the transaction cancellation request according to the signature information; When the transaction cancellation request is verified, the target transaction corresponding to the transaction hash is deleted from the local transaction pool of the target node.

4. The method according to claim 3, characterized in that The storing the transaction hash of the target transaction into the canceled transaction cache pool of the target node includes: Determine the transaction cancellation time; Based on the transaction cancellation time, the transaction hash of the target transaction is stored in a local canceled transaction cache pool of the target node, and the canceled transaction cache pool is constructed using a key-value pair structure.

5. The method according to claim 4, characterized in that After storing the transaction hash of the target transaction in the cancel transaction cache pool of the target node, the method further includes: The transaction hash of the canceled target transaction and the corresponding transaction cancellation time are persistently stored.

6. The method according to claim 5, characterized in that Also includes: When the target node is started, traverse the transaction cancellation data in the persistent storage, wherein the transaction cancellation data uses information including the transaction cancellation time as a key; According to the transaction cancellation time, the transaction cancellation data within the target time range is loaded into the local canceled transaction cache pool of the target node.

7. The method according to any one of claims 1 or 2 or 4 to 6, characterized in that: The generating a transaction cancellation event for the target transaction and broadcasting the transaction cancellation event to other nodes in the blockchain includes: Generate a transaction cancellation event based on the transaction hash of the target transaction and the corresponding transaction cancellation time, and add the transaction cancellation event to a broadcast queue; The transaction cancellation event is broadcasted to other nodes in the blockchain through the broadcast queue, and the transaction cancellation event carries a transaction hash that uniquely identifies the target transaction.

8. The method according to claim 7, characterized in that After generating a transaction cancellation event for the canceled target transaction and broadcasting the transaction cancellation event to other nodes in the blockchain, the method further includes: Receiving feedback information returned by other nodes in the blockchain regarding the transaction cancellation event; If the feedback information returned by other nodes all indicates that the target transaction has been cancelled, it is confirmed that the target transaction has been cancelled successfully.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the computer device is caused to implement the method according to any one of claims 1 to 8.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed, the method according to any one of claims 1 to 8 is executed.

Citation Information

Patent Citations

  • Transaction quick confirmation method based on licensing chain

    CN107481011A

  • Computer-implemented system and method for managing a large distributed memory pool in a blockchain network

    CN110945548A

  • Block chain transaction deletion method and system

    CN113592639A

  • Block chain data deletion method and device, equipment and storage medium

    CN113627938A

  • Block chain transaction processing method and device and computer readable storage medium

    CN113986922A