Transaction screening method, computer device, and storage medium
By configuring a repair contract on the blockchain to receive and process transactions to be repaired, the problem of transaction fee losses caused by blockchain contract bugs is resolved, user experience is improved, and resource utilization of blockchain nodes is optimized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 蓝谷创服(北京)科技有限公司
- Filing Date
- 2021-12-02
- Publication Date
- 2026-04-10
AI Technical Summary
When a bug occurs in a blockchain contract, transactions that call that contract will fail to execute, resulting in lost transaction fees and a degraded user experience.
By configuring a repair contract on the blockchain, the system receives transactions to be repaired generated by the administrator. After successful execution, the contract name is added to the list of contracts to be repaired. The system also checks whether the transaction is in the list and deletes the corresponding transaction from the transaction pool to avoid execution failure.
It reduced transaction fee losses, improved user experience, and optimized the resource allocation of blockchain nodes by delaying the number of urgent bug fixes and reducing the number of blockchain node upgrades.
Smart Images

Figure CN114140237B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of blockchains, and particularly relates to a transaction screening method, a computer device and a storage medium. BACKGROUND
[0002] In the prior art, if a bug occurs in a contract of a blockchain, a transaction calling the contract will fail to be executed before the bug is repaired in an upgraded version of the blockchain, resulting in a loss of a service charge and poor user experience. SUMMARY
[0003] In view of the above defects or deficiencies in the prior art, it is desirable to provide a transaction screening method, a computer device and a storage medium for reducing the loss of a service charge and improving user experience.
[0004] In a first aspect, the present application provides a transaction screening method suitable for a blockchain node, a repair contract being configured on the blockchain, and the method comprising:
[0005] receiving a first to-be-repaired transaction generated by a first client of an administrator, wherein the first to-be-repaired transaction comprises a to-be-repaired contract name of a to-be-repaired contract;
[0006] executing the first to-be-repaired transaction by the repair contract, and when the execution is successful, adding the to-be-repaired contract name to a to-be-repaired contract list by the repair contract to update the to-be-repaired contract list;
[0007] obtaining a first transaction;
[0008] determining whether a first contract name of a contract called by the first transaction is in the to-be-repaired contract list:
[0009] Yes, then deleting the first transaction from a transaction pool.
[0010] In a second aspect, the present application further provides a device comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors to cause the one or more processors to perform the transaction screening method according to the embodiments of the present application.
[0011] In a third aspect, the present application further provides a storage medium storing a computer program, which causes a computer to execute the transaction screening method according to the embodiments of the present application.
[0012] The transaction screening method, the computer device and the storage medium provided by the embodiments of the present application receive a first to-be-repaired transaction generated by a first client of an administrator; execute the first to-be-repaired transaction through a repair contract, and when the execution is successful, add the name of the to-be-repaired contract to a to-be-repaired contract list through the repair contract to update the to-be-repaired contract list; obtain a first transaction; and determine whether a first contract name of a contract called by the first transaction is in the to-be-repaired contract list; if yes, delete the first transaction from a transaction pool, thereby reducing the loss of the commission and improving the user experience. BRIEF DESCRIPTION OF DRAWINGS
[0013] Other features, objects and advantages of the present application will become more apparent from the following detailed description of non-limiting embodiments thereof, read in conjunction with the accompanying drawings:
[0014] Figure 1 A flowchart of a transaction screening method provided by an embodiment of the present application.
[0015] Figure 2 A preferred embodiment of the method shown in Figure 1 A flowchart of step S11 in a preferred embodiment of the method shown in
[0016] Figure 3 A flowchart of a preferred embodiment of the method shown in Figure 1
[0017] A flowchart of a preferred embodiment of the method shown in Figure 4 Figure 3 A flowchart of a preferred embodiment of the method shown in
[0018] Figure 5 A flowchart of a preferred embodiment of the method shown in Figure 4
[0019] A structural schematic diagram of a device provided by an embodiment of the present application. Figure 6 DETAILED DESCRIPTION
[0020] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related application, and not to limit the application. In addition, it should be noted that, for the convenience of description, only the parts related to the application are shown in the drawings.
[0021] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict. The present application will be described in detail below with reference to the accompanying drawings and embodiments.
[0022] Figure 1 A flowchart of a transaction screening method provided by an embodiment of the present application.
[0023] As Figure 1 shown in the present embodiment, the present application provides a transaction screening method suitable for a blockchain node, a repair contract is configured on the blockchain, and the method comprises:
[0024] S11: receiving a first to-be-repaired transaction generated by a first client of an administrator; wherein the first to-be-repaired transaction comprises a to-be-repaired contract name of a to-be-repaired contract;
[0025] S12: executing the first to-be-repaired transaction through the repair contract, and when the execution is successful, adding the to-be-repaired contract name to a to-be-repaired contract list through the repair contract to update the to-be-repaired contract list;
[0026] S13: obtaining a first transaction;
[0027] S141: determining whether a first contract name of a contract called by the first transaction is in the to-be-repaired contract list:
[0028] Yes, then execute step S142: delete the first transaction from the transaction pool.
[0029] For example, the first to-be-repaired transaction comprises a to-be-repaired method body name of a to-be-repaired method body of the to-be-repaired contract, and S12 comprises "executing the first to-be-repaired transaction through the repair contract, and when the execution is successful, adding the to-be-repaired method body name to the to-be-repaired contract list through the repair contract to update the to-be-repaired contract list", and S141 comprises "determining whether a first method body name of a method of a contract called by the first transaction is in the to-be-repaired contract list";
[0030] Suppose the administrator finds that the PropRule method of the autonomy contract has a bug;
[0031] The client of the administrator generates a to-be-repaired transaction tx1, which comprises autonomy-PropRule;
[0032] The blockchain node executes step S11 and receives tx1;
[0033] The blockchain node executes step S12 and executes tx1 through the repair contract, and when the execution is successful, adds autonomy-PropRule to the to-be-repaired contract list through the repair contract to update the to-be-repaired contract list;
[0034] Suppose that at this time, autonomy-PropRule, execr-actionName1, and execr-actionName2 are in the to-be-repaired contract list;
[0035] The blockchain node performs step S13 to obtain a transaction tx2, which calls the autonomy method of the contract autonomy;
[0036] The blockchain node performs step S141 to determine whether the autonomy-PropRule is in the list of to-be-repaired contracts:
[0037] Since the autonomy-PropRule is in the list of to-be-repaired contracts, the blockchain node performs step S142 to delete tx2 from the transaction pool.
[0038] Those skilled in the art should understand that the above administrator can be an administrator set at initialization or an administrator elected by voting;
[0039] The above embodiments can reduce the transaction fee loss of transactions that call contracts that generate BUGs, and improve user experience. At the same time, the blockchain node does not need to execute the above transactions that call contracts that generate BUGs, and can allocate more computing power to execute other transactions, broadcast transactions, and other tasks.
[0040] If the generated BUG is an emergency BUG (hereinafter referred to as an emergency BUG), generally, an emergency repair and an emergency version upgrade will be performed for the emergency BUG, and one version upgrade takes a long time. In an extreme case, if emergency BUGs are found one after another, the blockchain will be in an upgrade state all the time. Through the method of the above embodiments, the repair of emergency BUGs can be delayed, and multiple emergency BUGs can be upgraded together, so that the blockchain node only needs to be upgraded once, reducing the number of node upgrades. The method of upgrading multiple emergency BUGs together can be configured according to actual needs, for example, after the first emergency BUG is found, it is observed whether there are other emergency BUGs in 100 blocks, and if so, all emergency BUGs are repaired to upgrade the blockchain at one time.
[0041] Figure 2 For Figure 1 A flowchart of step S11 in a preferred embodiment of the method shown.
[0042] As Figure 2 shown, in a preferred embodiment, step S11 includes:
[0043] S111: receiving a first to-be-repaired transaction generated by a first client of the administrator;
[0044] S112: when it is determined that the first to-be-repaired transaction is a first type of transaction that needs to trigger the repair contract to execute, placing the first to-be-repaired transaction in a transaction priority packaging queue;
[0045] The transactions in the transaction priority packaging queue will be packaged in priority.
[0046] The above embodiment configures the first type of transaction that needs to trigger the repair contract to execute with the priority packaging permission, so that the first type of transaction can be packaged in priority.
[0047] Generally, the transactions in the transaction priority packaging queue are queued and packaged in the order of first-in-first-out.
[0048] Figure 3 For Figure 1 A flow chart of a preferred embodiment of the method shown. As Figure 3 shown, in a preferred embodiment, the above method further comprises:
[0049] S15: receiving a first repaired transaction generated by a first client; wherein the first repaired transaction includes a repaired contract name of a repaired contract;
[0050] S16: placing the first repaired transaction in a transaction priority packaging queue when it is determined that the first repaired transaction is a first type of transaction that needs to trigger the repair contract to execute; wherein the transactions in the transaction priority packaging queue will be packaged in priority;
[0051] S17: executing the first repaired transaction through the repair contract, and when the execution is successful, deleting the repaired contract name from the to-be-repaired contract list through the repair contract to update the to-be-repaired contract list.
[0052] Suppose the administrator finds that the PropRule method of the autonomy contract has been repaired;
[0053] The client of the administrator generates a repaired transaction tx4, which includes autonomy-PropRule;
[0054] The blockchain node executes step S15 to receive tx4;
[0055] The blockchain node executes step S16 to place tx4 in the transaction priority packaging queue when it is determined that tx4 is a first type of transaction that needs to trigger the repair contract to execute;
[0056] The blockchain node executes step S17 to execute tx4 through the repair contract, and when the execution is successful, deletes autonomy-PropRule from the to-be-repaired contract list through the repair contract; At this time, the to-be-repaired contract list has execr-actionName1 and execr-actionName2.
[0057] Figure 4 For Figure 3 A flow chart of a preferred embodiment of the method shown. As Figure 4As shown, in a preferred embodiment, step S142 comprises:
[0058] S1421: storing the first transaction locally;
[0059] S1422: deleting the first transaction from the transaction pool;
[0060] The above method further comprises:
[0061] S18: re-storing the first transaction into the transaction pool upon monitoring that the first contract name is deleted from the list of contracts to be repaired.
[0062] The above embodiment enables the first transaction to be executed by the blockchain node as soon as possible when the first contract is repaired.
[0063] Figure 5 For Figure 4 A flow chart of a preferred implementation of the method. As shown, Figure 5 As shown, in a preferred embodiment, the above method further comprises:
[0064] S19: deleting the first transaction locally if the first contract name is not deleted from the list of contracts to be repaired when the duration of storing the first transaction locally reaches the first timeout duration.
[0065] The above embodiment releases the local memory.
[0066] Preferably, deleting the first transaction from the transaction pool comprises:
[0067] caching the first transaction hash of the first transaction into the list of unexecuted transactions of contracts to be repaired;
[0068] deleting the first transaction from the transaction pool;
[0069] The above method further comprises:
[0070] receiving a second transaction generated by a second client of the first user; wherein the second transaction comprises a third transaction hash, and the second transaction is generated by the second client upon monitoring that a second contract name of a contract called by the second transaction is deleted from the list of contracts to be repaired on the blockchain;
[0071] placing the second transaction into the transaction priority packaging queue when the third transaction hash is included in the list of unexecuted transactions of contracts to be repaired.
[0072] Since the blockchain node caches the transaction hash hash(tx2) in the list of unexecuted transactions of the to-be-repaired contract, it is assumed that tx2 is generated by the client of user A; since tx2 is deleted from the transaction pool, only user A knows hash(tx2); therefore, user A can generate tx3 (including hash(tx2)) after monitoring that the autonomy-PropRule is deleted from the list of to-be-repaired contracts; the blockchain node finds hash(tx2) in the list of unexecuted transactions of the to-be-repaired contract, and then executes tx3 in priority.
[0073] The above embodiment also has the following problems: user A can generate tx3 that is irrelevant to tx2, and tx3 can still obtain priority, or user A can even tell other users hash(tx2), and the irrelevant tx3 generated by other users can still obtain priority.
[0074] To solve the above problems, the blockchain node can use the following mechanism:
[0075] When caching hash(tx2), the other parameters in the payload of tx2 except the timestamp can also be hashed to obtain a first hash value; and when hash(tx2) is found in the list of unexecuted transactions of the to-be-repaired contract, the other parameters in the payload of tx3 except the timestamp are hashed to obtain a second hash value, and if the first hash value is the same as the second hash value, tx3 is placed in the transaction priority packaging queue.
[0076] Further, the above method further includes:
[0077] When the duration of caching the first transaction hash in the list of unexecuted transactions of the to-be-repaired contract reaches the second timeout duration, the first transaction hash is deleted from the list of unexecuted transactions of the to-be-repaired contract.
[0078] The above embodiment releases the list of unexecuted transactions of the to-be-repaired contract.
[0079] Preferably, the first to-be-repaired transaction is executed by the repair contract, and when the execution is successful, the name of the to-be-repaired contract is added to the list of to-be-repaired contracts by the repair contract to update the list of to-be-repaired contracts, including:
[0080] The first to-be-repaired transaction is executed by the repair contract, and when the execution is successful, the name of the to-be-repaired contract is recorded on the blockchain;
[0081] If the first report transaction is not received within the first duration, the name of the to-be-repaired contract is added to the list of to-be-repaired contracts by the repair contract to update the list of to-be-repaired contracts; wherein the first report transaction is generated by the client of another user when it is determined that the to-be-repaired contract does not need to be repaired;
[0082] If the first reported transaction is received within the first time period, and it is determined that the contract to be repaired does not need to be repaired, the administrator is punished according to the preconfigured punishment rule.
[0083] Suppose that there are two similar contracts in competition, and the administrator has a collusive relationship with the deployer of one contract, the administrator can generate a to-be-repaired transaction of the other contract to reduce the user experience of the user of the other contract, thereby creating an unfair competition relationship.
[0084] To solve the above problems, the method described in the above embodiment can be used.
[0085] The other client described above can be a client of the deployer of another contract, or a client of a general user, which is not specifically limited here.
[0086] The punishment rule described above can be configured according to actual needs. For example, the administrator has previously paid part of the deposit, and then part of the deposit of the administrator can be confiscated. At this time, the step of executing the first to-be-repaired transaction through the repair contract should also include checking whether the administrator has paid enough deposit. For another example, there are other administrators as substitutes for the administrator, and then the qualification of the administrator can be deprived, and a new administrator can be elected from the other administrators as substitutes, which can achieve the same technical effects.
[0087] Figure 6 A structural schematic diagram of a device provided by an embodiment of the application is shown.
[0088] As shown in Figure 6 As another aspect, the application also provides a device, which includes one or more central processing units (CPUs) 601, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or programs loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0089] The following components are connected to the I / O interface 605: an input part 606 including a keyboard, a mouse, etc.; an output part 607 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage part 608 including a hard disk, etc.; and a communication part 609 including a network interface card such as a LAN card, a modem, etc. The communication part 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as necessary. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 610 as necessary, so that a computer program read out therefrom is installed in the storage part 608 as necessary.
[0090] In particular, according to embodiments of the present disclosure, the method described in any of the above embodiments can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product having a computer program tangibly embodied on a machine-readable medium, the computer program including program code for executing any of the above methods. In such embodiments, the computer program can be downloaded and installed from a network via the communication part 609, and / or installed from the removable medium 611.
[0091] As still another aspect, the present application also provides a computer readable storage medium, which can be the computer readable storage medium included in the apparatus of the above embodiments; or can exist separately from the apparatus and not be assembled into the apparatus. The computer readable storage medium stores one or more programs for execution by one or more processors to perform the method described in the present application.
[0092] The flow diagrams and the block diagrams in the drawings are illustrations of possible architectures, functions, and operations for systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flow diagrams and the block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may
[0093] The units or modules described in the embodiments of the present application can be implemented in the form of software or in the form of hardware. The described units or modules can also be arranged in a processor, for example, each of the units can be a software program arranged in a computer or a mobile smart device, or can be a separately configured hardware device. In some cases, the names of these units or modules do not constitute a limitation on the units or modules themselves.
[0094] The above description is merely the preferred embodiments of the present application and the explanation of the applied technical principles. It should be understood by those skilled in the art that the scope of the application involved in the present application is not limited to the technical solutions formed by the specific combinations of the above technical features, and also covers other technical solutions formed by any combination of the above technical features or equivalent features without departing from the concept of the present application. For example, the above features are replaced with the technical features disclosed in the present application (but not limited to) having similar functions to form technical solutions.
Claims
1. A transaction screening method, characterized in that, A repair contract is configured on the blockchain, and the method is applicable to blockchain nodes. The method includes: The system receives a first transaction to be repaired generated by the administrator's first client; wherein the first transaction to be repaired includes the name of the contract to be repaired. The first transaction to be repaired is executed through the repair contract. Upon successful execution, the name of the transaction to be repaired is added to the list of transactions to be repaired through the repair contract to update the list of transactions to be repaired. Securing the first transaction; Determine if the first contract name of the contract invoked by the first exchange is in the list of contracts to be repaired: If yes, then the first transaction will be removed from the transaction pool.
2. The method according to claim 1, characterized in that, The first transaction to be repaired generated by the first client of the receiving administrator includes: Receive the first transaction to be repaired generated by the administrator's first client; When it is determined that the first transaction to be repaired is a first type of transaction that requires the execution of the repair contract, the first transaction to be repaired is placed in the transaction priority packaging queue; Transactions in the priority packaging queue will be packaged first.
3. The method according to claim 1, characterized in that, Also includes: Receive the first repaired transaction generated by the first client; wherein the first repaired transaction includes the name of the repaired contract; When it is determined that the first repaired transaction is a first type of transaction that needs to trigger the execution of the repair contract, the first repaired transaction is placed in the transaction priority packaging queue; wherein, transactions in the transaction priority packaging queue will be packaged with priority. The first repaired transaction is executed through the repair contract. Upon successful execution, the name of the repaired contract is removed from the list of contracts to be repaired to update the list of contracts to be repaired.
4. The method according to claim 3, characterized in that, Deleting the first transaction from the transaction pool includes: Store the first transaction locally; Remove the first transaction from the transaction pool; The method further includes: When the first contract name is detected to have been removed from the list of contracts to be repaired, the first transaction is re-stored into the transaction pool.
5. The method according to claim 4, characterized in that, Also includes: If the first contract name has not been deleted from the list of contracts to be repaired when the first transaction has been stored locally for a period of time exceeding the first timeout period, the first transaction will be deleted from local storage.
6. The method according to claim 3, characterized in that, Deleting the first transaction from the transaction pool includes: Cache the first transaction hash of the first transaction in the list of unexecuted transactions of the contract to be repaired; The second transaction is received from the second client of the first user; wherein the second transaction includes a third transaction hash, and the second transaction is generated by the second client after the name of the second contract executing the second transaction call is removed from the list of contracts to be repaired, as monitored on the blockchain; When the third transaction hash is included in the list of unexecuted transactions in the contract to be repaired, the second transaction is placed in the transaction priority packing queue.
7. The method according to claim 6, characterized in that, Also includes: When the first transaction hash is cached in the list of unexecuted transactions of the contract to be repaired for a period of time that reaches the second timeout period, the first transaction hash is deleted from the list of unexecuted transactions of the contract to be repaired.
8. The method according to any one of claims 1-7, characterized in that, The first transaction to be repaired includes the name of the method body to be repaired in the contract to be repaired; The step of adding the name of the contract to be repaired to the list of contracts to be repaired to update the list of contracts to be repaired includes: The repair contract adds the name of the method body to be repaired to the list of contracts to be repaired to update the list of contracts to be repaired. The determination of whether the first contract name of the contract invoked by the first exchange is included in the list of contracts to be repaired: Determine whether the first method body name of the contract method called by the first exchange is in the list of contracts to be repaired.
9. The method according to any one of claims 1-7, characterized in that, The step of executing the first transaction to be repaired through the repair contract, and upon successful execution, adding the name of the transaction to be repaired to the list of transactions to be repaired to update the list of transactions to be repaired through the repair contract, includes: The first transaction to be repaired is executed through the repair contract, and upon successful execution, the name of the contract to be repaired is recorded on the blockchain; If no first report transaction is received within the first time period, the name of the contract to be repaired is added to the list of contracts to be repaired through the repair contract to update the list of contracts to be repaired; wherein, the first report transaction is generated by other clients when they determine that the contract to be repaired does not need to be repaired; If the first reported transaction is received within the first time period, and it is determined that the contract to be repaired does not need to be repaired, then the administrator will be punished according to the pre-configured penalty rules.
10. A computer device, characterized in that, The device includes: One or more processors; Memory, used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors perform the method as described in any one of claims 1-9.
11. A storage medium storing a computer program, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-9.
Citation Information
Patent Citations
Intelligent contract bookkeeping method, computer device and readable storage medium
CN109064334A
Transaction information processing method and device for block chain, medium and electronic equipment
CN112926981A