A cross-chain asset extraction method, device and storage medium
Coordinating the blockchain cross-chain asset extraction operation through repeaters, the problem of asset extraction failure during concurrent operations of multiple users in the existing technology is solved, and a more stable and efficient asset extraction experience is achieved.
Patent Information
- Application Number
- CN202210107041.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2042-01-28
AI Technical Summary
The existing blockchain cross-chain asset extraction solution cannot effectively accumulate and count online wallet balances when multi-terminal and multi-user concurrent operations, resulting in failure of concurrent transactions, unstable asset extraction performance, and poor user experience.
Coordinate cross-chain asset extraction operations through repeaters to generate withdrawal and evidence storage transactions, and compare them with the total number of assets to be withdrawn based on the online wallet balance of the target blockchain to ensure the successful execution of the asset extraction transaction.
It improves the performance stability of cross-chain asset extraction, reduces the frequency of transaction failures, improves user experience, and ensures the smoothness of asset extraction operations.
Smart Images

Figure CN114493597B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular, relates to a cross-chain asset extraction method, device and storage medium. Background Art
[0002] With the development of blockchain technology, various blockchain systems have emerged one after another. In order to avoid information islands, cross-chain interactions between blockchains have gradually received attention. Cross-chain asset extraction, as an important part of blockchain cross-chain interaction, has naturally received a lot of attention. The current cross-chain asset extraction solution usually monitors the balance of the current online wallet through a centralized service. When the balance is less than the set value, it prompts that the assets in the cold wallet need to be transferred to the online wallet to ensure the balance of the online wallet. However, this method is very inconvenient. When multiple terminals and multiple users perform cross-chain asset extraction operations, the centralized service cannot accumulate and count the asset extraction operations of multiple users. Concurrent cross-chain asset extraction transactions in the same period are compared based on the same balance, rather than comparing the total amount of the extraction transaction with the online balance, which may result in only a few users successfully extracting cross-chain assets, while most users fail to extract assets. However, in the blockchain system, centralized services are mostly deployed based on smart contracts. Smart contracts obtain the balance of the current online wallet in the blockchain for cross-chain asset withdrawal transactions, but it is difficult to actively calculate the total amount of assets to be withdrawn for all cross-chain asset withdrawal transactions. As a result, when multiple terminals and multiple users perform cross-chain asset withdrawal operations concurrently, such as during the peak period of cross-chain asset withdrawal, the entire blockchain system may not respond in time and the service may not be smooth enough, resulting in a large number of asset withdrawal failures and unstable asset extraction performance. Even if remedial measures are taken afterwards, the asset withdrawal experience is still poor. Summary of the invention
[0003] In order to solve the above problems, the present invention provides a cross-chain asset extraction method, device and storage medium, which coordinates the cross-chain asset extraction operation through a repeater, making the asset extraction performance more stable, reducing the frequency of cross-chain asset extraction failures, and improving the user experience.
[0004] The present invention adopts the following technical solutions.
[0005] In a first aspect, the present invention provides a cross-chain asset extraction method, the method being applicable to a repeater, the method comprising:
[0006] Obtaining a first cross-chain asset extraction transaction in the first blockchain; the first cross-chain asset extraction transaction uses the second blockchain as a target chain;
[0007] Parsing the first cross-chain asset withdrawal transaction to obtain transaction information of the first cross-chain asset withdrawal transaction, and generating a first withdrawal evidence storage transaction according to the transaction information;
[0008] Query the online wallet balance in the second blockchain to determine whether the online wallet balance is sufficient;
[0009] If the balance of the online wallet is sufficient, the first withdrawal evidence transaction is sent to the second blockchain, where the first withdrawal evidence transaction is used to withdraw the second blockchain asset of the first amount in the second blockchain, and the transaction hash and asset quantity of the first withdrawal evidence transaction are recorded, and the status corresponding to the transaction hash of the first withdrawal evidence transaction is set to a pending status;
[0010] If the online wallet balance is insufficient, suspend the first withdrawal and deposit transaction, and suspend the generation of the withdrawal and deposit transaction;
[0011] Receiving the recharge log information of the second blockchain, restarting the first withdrawal and evidence storage transaction, and re-determining whether the online wallet balance in the second blockchain is sufficient;
[0012] After sending the first withdrawal evidence transaction to the second blockchain, determine whether the first withdrawal evidence transaction is successfully executed in the second blockchain according to the log of the second blockchain. If so, modify the status corresponding to the transaction hash of the first withdrawal evidence transaction to success in the repeater; otherwise, modify the status corresponding to the transaction hash of the first withdrawal evidence transaction to failure in the repeater.
[0013] Preferably, the method for determining whether the online wallet balance is sufficient comprises the following steps:
[0014] Obtain all withdrawal evidence transactions recorded in the repeater with the second blockchain as the target chain in a pending state and calculate the total amount of assets to be withdrawn;
[0015] The online wallet balance of the queried second blockchain is compared with the total amount of assets to be withdrawn. If the sum of the total amount of assets to be withdrawn and the first amount is less than the online wallet balance of the queried second blockchain, it is determined that the online wallet balance is sufficient; if the sum of the total amount of assets to be withdrawn and the first amount is greater than the online wallet balance of the queried second blockchain, it is determined that the online wallet balance is insufficient.
[0016] Preferably, the repeater obtains the first cross-chain asset extraction transaction by monitoring the transaction log of the first blockchain.
[0017] Preferably, the method of "determining whether the first withdrawal evidence transaction is successfully executed in the second blockchain based on the log of the second blockchain" is to monitor its log events when the second blockchain generates a block, query whether the generated block contains the transaction information of the first withdrawal evidence transaction, and if so, parse the transaction information of the first withdrawal evidence transaction to determine whether the first withdrawal evidence transaction is successfully executed.
[0018] Preferably, when the online wallet balance is insufficient, the first withdrawal evidence transaction is suspended, and the generation of the withdrawal evidence transaction is suspended, and the repeater sends an alarm message to the background to prompt that the online wallet balance is insufficient.
[0019] In a second aspect, a computer device is provided, comprising one or more processors;
[0020] a memory for storing one or more programs,
[0021] When the one or more programs are executed by the one or more processors, the one or more processors execute the method as described in the first aspect above.
[0022] According to a third aspect, a storage medium storing a computer program is provided, and when the program is executed by a processor, the method described in the first aspect is implemented.
[0023] The beneficial effect of the present invention is that by coordinating cross-chain asset extraction transactions through a repeater, it is avoided that during the high incidence period of cross-chain extraction, multiple concurrent cross-chain asset extraction transactions use the same online wallet balance as a reference object, thereby causing asset extraction failure. The repeater is used to compare the total number of assets to be extracted in all pending cross-chain asset extraction transactions and the first cross-chain asset extraction transaction with the online wallet balance of the target blockchain, thereby ensuring the successful execution of the cross-chain asset extraction transaction, making the cross-chain asset extraction more stable and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A flowchart of a cross-chain asset extraction method provided by an embodiment of the present invention;
[0025] Figure 2 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The present invention is further described in detail below in conjunction with specific embodiments and the accompanying drawings of the specification. Those of ordinary skill in the art will be able to implement the present invention based on these descriptions. In addition, the embodiments of the present invention involved in the following description are usually only embodiments of a part of the present invention, rather than all of the embodiments. Therefore, based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative work should fall within the scope of protection of the present invention. It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other. Unless otherwise specified, the methods briefly described in the embodiments of the present invention are methods mastered by those skilled in the art.
[0027] Figure 1 A flowchart of a cross-chain asset extraction method provided by one embodiment of the present invention.
[0028] like Figure 1 As shown, this embodiment provides a cross-chain asset extraction method, which is applicable to a repeater and includes:
[0029] Obtaining a first cross-chain asset extraction transaction in the first blockchain; the first cross-chain asset extraction transaction uses the second blockchain as a target chain;
[0030] Parsing the first cross-chain asset withdrawal transaction to obtain transaction information of the first cross-chain asset withdrawal transaction, and generating a first withdrawal evidence storage transaction according to the transaction information;
[0031] Query the online wallet balance in the second blockchain to determine whether the online wallet balance is sufficient;
[0032] If the balance of the online wallet is sufficient, the first withdrawal evidence transaction is sent to the second blockchain, where the first withdrawal evidence transaction is used to withdraw the second blockchain asset of the first amount in the second blockchain, and the transaction hash and asset quantity of the first withdrawal evidence transaction are recorded, and the status corresponding to the transaction hash of the first withdrawal evidence transaction is set to a pending status;
[0033] If the online wallet balance is insufficient, suspend the first withdrawal and deposit transaction, and suspend the generation of the withdrawal and deposit transaction;
[0034] Receiving the recharge log information of the second blockchain, restarting the first withdrawal and evidence storage transaction, and re-determining whether the online wallet balance in the second blockchain is sufficient;
[0035] After sending the first withdrawal evidence transaction to the second blockchain, determine whether the first withdrawal evidence transaction is successfully executed in the second blockchain according to the log of the second blockchain. If so, modify the status corresponding to the transaction hash of the first withdrawal evidence transaction to success in the repeater; otherwise, modify the status corresponding to the transaction hash of the first withdrawal evidence transaction to failure in the repeater.
[0036] Furthermore, the method for determining whether the online wallet balance is sufficient includes the following steps:
[0037] Obtain all withdrawal evidence transactions recorded in the repeater with the second blockchain as the target chain in a pending state and calculate the total amount of assets to be withdrawn;
[0038] The online wallet balance of the queried second blockchain is compared with the total amount of assets to be withdrawn. If the sum of the total amount of assets to be withdrawn and the first amount is less than the online wallet balance of the queried second blockchain, it is determined that the online wallet balance is sufficient; if the sum of the total amount of assets to be withdrawn and the first amount is greater than the online wallet balance of the queried second blockchain, it is determined that the online wallet balance is insufficient.
[0039] Furthermore, the repeater obtains the first cross-chain asset extraction transaction by monitoring the transaction log of the first blockchain.
[0040] Furthermore, the method of "determining whether the first withdrawal evidence transaction is successfully executed in the second blockchain based on the log of the second blockchain" is to monitor its log events when the second blockchain generates a block, query whether the generated block contains the transaction information of the first withdrawal evidence transaction, and if so, parse the transaction information of the first withdrawal evidence transaction to determine whether the first withdrawal evidence transaction is successfully executed.
[0041] Furthermore, when the online wallet balance is insufficient, the first withdrawal evidence transaction is suspended, and the generation of the withdrawal evidence transaction is suspended, and the repeater sends an alarm message to the background to prompt that the online wallet balance is insufficient.
[0042] For the sake of generality, this embodiment takes the extraction of assets from chain A to chain B as an example to illustrate the above method. In this embodiment, the asset of chain A is defined as assetA, the asset of chain B is defined as assetB, and the representation of assetA on chain B is B_assetA. The asset extraction process is as follows:
[0043] 1. User A initiates a cross-chain asset withdrawal transaction on chain A, which is exemplarily recorded as the first cross-chain asset withdrawal transaction. This transaction is used to withdraw 100 of chain A assets on chain B, i.e., to extract 100B_assetA. The repeater monitors the log of chain A, finds the first cross-chain asset withdrawal transaction, parses the asset type (B_assetA) and amount (100), and prepares to initiate the first withdrawal evidence transaction to chain B;
[0044] 2. The repeater queries whether the balance of the online wallet on the B chain can fully support the asset withdrawal operation of the first withdrawal evidence transaction. The judgment conditions are as follows: the amounts of the withdrawal evidence transactions previously initiated to the B chain that are still pending are accumulated to obtain sum_pending, and the current online wallet balance is balance, and the asset withdrawal amount of the current transaction is withdraw_amount. If withdraw_amount+sum_pending<=balance, then continue to initiate the first withdrawal evidence transaction to the B chain, otherwise all subsequent asset withdrawal operations will be suspended; for example, the current balance of wallet B_assetA on the B chain is 30,000, and the amount of the current pending withdrawal evidence transaction is accumulated to 29,999, then the online wallet balance is not enough to support the asset withdrawal operation of the first withdrawal evidence transaction, so all subsequent asset withdrawal operations need to be suspended.
[0045] 3. If the asset extraction operation is initiated normally to the B chain, the hash of the first asset extraction transaction (i.e. the transaction hash of the first asset extraction transaction) and the amount are recorded, and the status corresponding to the hash of the first asset extraction transaction is set to pending. When a new B chain block is generated, the success of the asset extraction is determined by monitoring the log events (it is not possible to simply determine whether the asset extraction is successful by querying a single transaction). If successful, the status corresponding to the hash of the transaction is updated to successful, and if failed, it is updated to fail.
[0046] 4. If the current online wallet balance is insufficient, the repeater will suspend all pending withdrawal transactions and send an alarm message in the background (email or other alarm channels).
[0047] 5. After the operator successfully recharges the online wallet through a transaction, the repeater will receive the recharge log information, and then restart the asset withdrawal transaction cached locally, and run the review conditions of step 2 again for each transaction. If the conditions are met, it will be initiated, otherwise it will be suspended.
[0048] The above embodiment coordinates cross-chain asset extraction transactions through a repeater to avoid the situation where multiple concurrent cross-chain asset extraction transactions use the same online wallet balance as a reference object during the high incidence period of cross-chain extraction, thereby causing asset extraction failure. The repeater is used to compare the total number of assets to be extracted from all pending cross-chain asset extraction transactions and the first cross-chain asset extraction transaction with the online wallet balance of the target blockchain, thereby ensuring the successful execution of the cross-chain asset extraction transaction, making the cross-chain asset extraction more stable and improving the user experience.
[0049] Figure 2 A schematic diagram of the structure of a device provided in one embodiment of the present invention.
[0050] like Figure 2 As shown, as another aspect, the present application also provides a computer device 500, including one or more central processing units (CPU) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 to the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0051] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A driver 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the driver 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0052] In particular, according to the embodiments disclosed in the present application, the method described in the above embodiment 1 can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program tangibly contained on a machine-readable medium, and the computer program includes a program code for executing the method described in any of the above embodiments. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 509, and / or installed from the removable medium 511.
[0053] As another aspect, the present application further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the apparatus of the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into the device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to execute the method described in the present application.
[0054] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be realized by a dedicated hardware-based system that performs a specified function or operation, or can be realized by a combination of dedicated hardware and computer instructions.
[0055] The units or modules involved in the embodiments described in the present application may be implemented by software or by hardware. The units or modules described may also be arranged in a processor. For example, each of the units may be a software program arranged in a computer or a mobile smart device, or may be a separately configured hardware device. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.
[0056] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the concept of the present application. For example, the above features are replaced with the technical features with similar functions disclosed in the present application (but not limited to) to form a technical solution.
Claims
1. A cross-chain asset extraction method, characterized in that: The method is applicable to a repeater, and the method comprises: Obtaining a first cross-chain asset extraction transaction in the first blockchain; the first cross-chain asset extraction transaction uses the second blockchain as a target chain; Parsing the first cross-chain asset withdrawal transaction to obtain transaction information of the first cross-chain asset withdrawal transaction, and generating a first withdrawal evidence storage transaction according to the transaction information; Query the online wallet balance in the second blockchain to determine whether the online wallet balance is sufficient; If the balance of the online wallet is sufficient, the first withdrawal evidence transaction is sent to the second blockchain, where the first withdrawal evidence transaction is used to withdraw the second blockchain asset of the first amount in the second blockchain, and the transaction hash and asset quantity of the first withdrawal evidence transaction are recorded, and the status corresponding to the transaction hash of the first withdrawal evidence transaction is set to a pending status; If the online wallet balance is insufficient, suspend the first withdrawal and deposit transaction, and suspend the generation of the withdrawal and deposit transaction; Receiving the recharge log information of the second blockchain, restarting the first withdrawal and evidence storage transaction, and re-determining whether the online wallet balance in the second blockchain is sufficient; After sending the first withdrawal evidence transaction to the second blockchain, judging whether the first withdrawal evidence transaction is successfully executed in the second blockchain according to the log of the second blockchain, if so, modifying the state corresponding to the transaction hash of the first withdrawal evidence transaction to success in the repeater, otherwise modifying the state corresponding to the transaction hash of the first withdrawal evidence transaction to failure in the repeater; The method for determining whether the online wallet balance is sufficient includes the following steps: Obtain all withdrawal evidence transactions recorded in the repeater with the second blockchain as the target chain in a pending state and calculate the total amount of assets to be withdrawn; The online wallet balance of the queried second blockchain is compared with the total amount of assets to be withdrawn. If the sum of the total amount of assets to be withdrawn and the first amount is less than the online wallet balance of the queried second blockchain, it is determined that the online wallet balance is sufficient; if the sum of the total amount of assets to be withdrawn and the first amount is greater than the online wallet balance of the queried second blockchain, it is determined that the online wallet balance is insufficient.
2. A cross-chain asset extraction method according to claim 1, characterized in that: The method of "determining whether the first withdrawal evidence transaction is successfully executed in the second blockchain based on the log of the second blockchain" is to monitor its log events when the second blockchain generates a block, query whether the generated block contains the transaction information of the first withdrawal evidence transaction, and if so, parse the transaction information of the first withdrawal evidence transaction to determine whether the first withdrawal evidence transaction is successfully executed.
3. A cross-chain asset extraction method according to claim 1, characterized in that: When the online wallet balance is insufficient, the first withdrawal evidence transaction is suspended, and the generation of the withdrawal evidence transaction is suspended, and the repeater sends an alarm message to the background to prompt that the online wallet balance is insufficient.
4. A cross-chain asset extraction method according to claim 1, characterized in that: The repeater obtains the first cross-chain asset extraction transaction by monitoring the transaction log of the first blockchain.
5. A computer device, characterized in that: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are caused to perform the method according to any one of claims 1 to 4.
6. A storage medium storing a computer program, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Cross-chain transaction method and system applied to alliance chain
CN113850599A
Cross-chain interaction method, apparatus and system
WO2021218459A1