Cross-chain relay method, computer device and storage medium
By designing a confirmation mechanism in the blockchain cross-chain relay solution, the time delay problem caused by unexpected situations in cross-chain relay transactions is solved, and the low latency reliability of cross-chain services is achieved.
Patent Information
- Application Number
- CN202211384731.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-07
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-11-07
AI Technical Summary
When the existing blockchain cross-chain relay solution fails to send transactions due to unexpected circumstances, it requires manual intervention to process, resulting in serious time delays of cross-chain services, making it difficult to ensure low latency reliability.
A cross-chain relay method is designed. By establishing a confirmation mechanism between the first blockchain relay microservice node and the second blockchain relay microservice node, the second blockchain relay microservice sends confirmation information to the first blockchain relay microservice after sending a relay transaction. The first blockchain relay microservice monitors whether the confirmation information has been received and resends the relay information when no confirmation information is received.
It realizes that when relay transactions fail due to unexpected circumstances, relay transactions can be resent in time, ensuring the low latency reliability of cross-chain services and reducing the time delay of manual intervention.
Smart Images

Figure CN115714812B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and specifically to a cross-chain relay method, computer device and storage medium. Background Art
[0002] In the existing blockchain cross-chain relay solution, when the relay device fails to send a relay transaction due to unexpected situations such as software crashes, device power outages, software restarts and upgrades, manual intervention is required to handle such abnormal problems. Since the timeliness of manual intervention is uncontrollable, the time delay when the cross-chain encounters such abnormal problems is relatively serious, making it difficult to ensure the low-latency reliability of cross-chain services. Summary of the invention
[0003] In view of the above-mentioned defects or deficiencies in the prior art, it is desired to provide a cross-chain relay method, computer device and storage medium that ensure low-latency reliability of cross-chain services.
[0004] In a first aspect, the present invention provides a cross-chain relay method applicable to a first blockchain relay microservice node, the method comprising:
[0005] In response to monitoring the first cross-chain event information from the first blockchain to the second blockchain, generating first relay information according to the first cross-chain event information, and sending the first relay information to the second blockchain relay microservice node for:
[0006] Packaging and generating a first relay transaction according to the first relay information and sending it to the second blockchain, and recording that the first relay information has been relayed; and,
[0007] Sending first confirmation information to the first blockchain relay microservice node;
[0008] While sending the first relay information, recording the first relay information and waiting for confirmation;
[0009] In response to receiving the first confirmation information, modifying the first relay information waiting for confirmation to the first relay information having been confirmed;
[0010] In response to monitoring that the first confirmation information is not received within the predetermined time period, the first relay information is sent again to the second blockchain relay microservice node for:
[0011] Check whether the first relay information has been relayed:
[0012] If yes, a first confirmation message is sent to the first blockchain relay microservice node;
[0013] If not, a first relay transaction is generated based on the first relay information and sent to the second blockchain, and a record is made that the first relay information has been relayed; and,
[0014] Send a first confirmation message to the first blockchain relay microservice node.
[0015] In a second aspect, the present invention further provides a cross-chain relay method applicable to a second blockchain relay microservice node, the method comprising:
[0016] Receiving first relay information sent by the first blockchain relay microservice node; wherein the first relay information is generated by the first blockchain relay microservice node in response to monitoring the first cross-chain event information from the first blockchain to the second blockchain, according to the first cross-chain event information; the first blockchain relay microservice node is further configured to record the first relay information and wait for confirmation while sending the first relay information;
[0017] Packaging and generating a first relay transaction according to the first relay information and sending it to the second blockchain, and recording that the first relay information has been relayed;
[0018] Sending a first confirmation message to the first blockchain relay microservice node, so that after receiving the first confirmation message, the first blockchain relay microservice node modifies the first relay information waiting for confirmation to the first relay information having been confirmed;
[0019] In response to receiving the first relay information sent again, checking whether the first relay information has been relayed:
[0020] If yes, a first confirmation message is sent to the first blockchain relay microservice node;
[0021] If not, a first relay transaction is generated based on the first relay information and sent to the second blockchain, and a record is made that the first relay information has been relayed; and,
[0022] Send a first confirmation message to the first blockchain relay microservice node.
[0023] Among them, the first relay information sent again is sent by the first blockchain relay microservice node in response to monitoring that the first confirmation information is not received within a predetermined time period.
[0024] In a third aspect, the present invention further provides a computer device, comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors so that the one or more processors execute the methods provided according to various embodiments of the present invention.
[0025] In a fourth aspect, the present invention further provides a storage medium storing a computer program, wherein the computer program enables a computer to execute the methods provided according to the embodiments of the present invention.
[0026] The cross-chain relay method, computer device and storage medium provided by many embodiments of the present invention are designed with a confirmation mechanism between the first blockchain relay microservice and the second blockchain relay microservice. The second blockchain relay microservice sends a confirmation message to the first blockchain relay microservice after sending the relay transaction, and the first blockchain relay microservice monitors whether the confirmation message is received, and resends the relay message when the confirmation message is not received. This ensures that even if the relay transaction fails to be sent due to an unexpected situation, the relay transaction can be resent in time to complete the relay, thereby achieving the low-latency reliability of the cross-chain service. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0028] Figure 1 A flowchart of a cross-chain relay method provided by one embodiment of the present invention.
[0029] Figure 2 A flowchart of another cross-chain relay method provided by an embodiment of the present invention.
[0030] Figure 3 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.
[0032] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0033] Figure 1 A flowchart of a cross-chain relay method provided by one embodiment of the present invention.
[0034] like Figure 1 As shown, in this embodiment, the present invention provides a cross-chain relay method applicable to a first blockchain relay microservice node, the method comprising:
[0035] S11: In response to monitoring the first cross-chain event information from the first blockchain to the second blockchain, generating first relay information according to the first cross-chain event information, and sending the first relay information to the second blockchain relay microservice node for:
[0036] Packaging and generating a first relay transaction according to the first relay information and sending it to the second blockchain, and recording that the first relay information has been relayed; and,
[0037] Sending first confirmation information to the first blockchain relay microservice node;
[0038] S13: while sending the first relay information, record the first relay information and wait for confirmation;
[0039] S15: in response to receiving the first confirmation information, modifying the first relay information waiting for confirmation to the first relay information having been confirmed;
[0040] S17: In response to monitoring that the first confirmation information is not received within the predetermined time period, the first relay information is sent again to the second blockchain relay microservice node for:
[0041] Check whether the first relay information has been relayed:
[0042] If yes, a first confirmation message is sent to the first blockchain relay microservice node;
[0043] If not, a first relay transaction is generated based on the first relay information and sent to the second blockchain, and a record is made that the first relay information has been relayed; and,
[0044] Send a first confirmation message to the first blockchain relay microservice node.
[0045] It should be noted that the first blockchain relay microservice node and the second blockchain relay microservice node described in this application can be configured in different computer devices or in the same computer device, and can achieve the same technical effect.
[0046] The following takes the example of 100 yuan of digital RMB from blockchain A to blockchain B. Figure 1 The method shown is explained by way of example.
[0047] In step S11, the first blockchain relay microservice node a responds to the cross-chain event information M1 of 100 digital RMB crossing from blockchain A to blockchain B, generates relay information R1 according to the cross-chain event information M1, and sends the relay information R1 to the second blockchain relay microservice node b.
[0048] While sending the relay information R1, the first blockchain relay microservice node a also executes step S13 to record the first relay information R1 and wait for confirmation.
[0049] After receiving the relay information R1, the second blockchain relay microservice node b packages and generates a relay transaction tx1 according to the relay information R1, sends tx1 to blockchain B, records that the relay information R1 has been relayed, and sends confirmation information ack to the first blockchain relay microservice node a, recording the confirmation information that the relay information R1 has been returned.
[0050] Those skilled in the art should understand that if the second blockchain relay microservice node b fails to send tx1 due to unexpected circumstances such as software crash, device power outage, software restart and upgrade, it will not record that the relay information R1 has been relayed, nor will it send confirmation information ack.
[0051] The first blockchain relay microservice node a continuously monitors whether the confirmation information corresponding to each relay information waiting for confirmation is received:
[0052] If confirmation information ack corresponding to the relay information R1 is received, step S15 is executed to modify the relay information R1 waiting for confirmation to the relay information R1 has been confirmed (it can also be configured to delete the record of the relay information R1 waiting for confirmation and then record the relay information R1 has been confirmed, which can achieve the same technical effect);
[0053] If the confirmation information ack corresponding to the relay information R1 is not received within the predetermined time, step S17 is executed to send the relay information R1 to the second blockchain relay microservice node b again.
[0054] Preferably, step S17 further comprises recording that the relay information R1 has been sent again.
[0055] When the second blockchain relay microservice node b receives the relay information R1 sent again, the second blockchain relay microservice node b determines whether the relay information R1 has been relayed by querying whether there is a record that the relay information R1 has been relayed:
[0056] If yes, a confirmation message ack is sent to the first blockchain relay microservice node a;
[0057] If not, a relay transaction tx1 is generated based on the relay information R1, and tx1 is sent to blockchain B, recording that the relay information R1 has been relayed, and sending confirmation information ack to the first blockchain relay microservice node a, recording the confirmation information that the relay information R1 has been returned.
[0058] The above embodiment takes the cross-chain digital RMB as an example. Figure 1 The method shown is an exemplary description. In more embodiments, the method provided by the present invention can also be used in cross-chain scenarios of different applications to achieve the same technical effect.
[0059] The above embodiment designs a confirmation mechanism between the first blockchain relay microservice and the second blockchain relay microservice. The second blockchain relay microservice sends a confirmation message to the first blockchain relay microservice after sending the relay transaction. The first blockchain relay microservice monitors whether the confirmation message is received and resends the relay message when the confirmation message is not received. This ensures that even if the relay transaction fails to be sent due to an unexpected situation, the relay transaction can be resent in time to complete the relay, thereby achieving the low-latency reliability of cross-chain services.
[0060] Figure 2 A flowchart of another cross-chain relay method provided by an embodiment of the present invention. Figure 2 The method shown can be used with Figure 1 The method shown is executed.
[0061] like Figure 2 As shown, in this embodiment, the present invention also provides a cross-chain relay method applicable to a second blockchain relay microservice node, the method comprising:
[0062] S21: receiving first relay information sent by the first blockchain relay microservice node; wherein the first relay information is generated by the first blockchain relay microservice node in response to monitoring the first cross-chain event information from the first blockchain to the second blockchain, according to the first cross-chain event information; the first blockchain relay microservice node is further configured to record the first relay information and wait for confirmation while sending the first relay information;
[0063] S23: Packaging and generating a first relay transaction according to the first relay information and sending it to the second blockchain, and recording that the first relay information has been relayed;
[0064] S25: Sending the first confirmation information to the first blockchain relay microservice node, so that after receiving the first confirmation information, the first blockchain relay microservice node modifies the first relay information waiting for confirmation to the first relay information being confirmed;
[0065] S27: In response to receiving the first relay information sent again, checking whether the first relay information has been relayed:
[0066] If yes, execute step S25: send a first confirmation message to the first blockchain relay microservice node;
[0067] If no, then execute step S23: generate a first relay transaction according to the first relay information and send it to the second blockchain, and record that the first relay information has been relayed; and,
[0068] S25: Sending a first confirmation message to the first blockchain relay microservice node.
[0069] Among them, the first relay information sent again is sent by the first blockchain relay microservice node in response to monitoring that the first confirmation information is not received within a predetermined time period.
[0070] Figure 2 The cross-chain relay principle of the method shown can be referred to Figure 1 The method shown will not be repeated here.
[0071] Figure 3 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention.
[0072] like Figure 3 As shown, as another aspect, the present application also provides a computer device, including one or more central processing units (CPU) 301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 302 or the program loaded from the storage part 308 to the random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the device 300 are also stored. The CPU 301, the ROM 302, and the RAM 303 are connected to each other through a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0073] The following components are connected to the I / O interface 305: an input section 306 including a keyboard, a mouse, etc.; an output section 307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. A removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 310 as needed, so that a computer program read therefrom is installed into the storage section 308 as needed.
[0074] In particular, according to an embodiment of the present disclosure, the method described in any of the above embodiments can be implemented as a computer software program. For example, an embodiment of the present disclosure includes 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 any of the above methods. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 309, and / or installed from a removable medium 311.
[0075] As another aspect, the present application also 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.
[0076] 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.
[0077] 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 provided in a processor. For example, each unit may be a software program provided 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.
[0078] 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 relay method, characterized in that: The method is applicable to a first blockchain relay microservice node, and the method includes: In response to monitoring the first cross-chain event information from the first blockchain to the second blockchain, generating first relay information according to the first cross-chain event information, and sending the first relay information to the second blockchain relay microservice node for: Packaging and generating a first relay transaction according to the first relay information and sending it to the second blockchain, and recording that the first relay information has been relayed; and Sending first confirmation information to the first blockchain relay microservice node; While sending the first relay information, recording the first relay information and waiting for confirmation; In response to receiving the first confirmation information, modifying the first relay information waiting for confirmation to the first relay information having been confirmed; In response to monitoring that the first confirmation information is not received within a predetermined time period, the first relay information is sent again to the second blockchain relay microservice node for: Check whether the first relay information has been relayed: If yes, the first confirmation information is sent to the first blockchain relay microservice node; If not, the first relay transaction is generated based on the first relay information and sent to the second blockchain, and a record is made that the first relay information has been relayed; and, Send the first confirmation information to the first blockchain relay microservice node.
2. The method according to claim 1, characterized in that In response to monitoring that the first confirmation information is not received within a predetermined time period, sending the first relay information to the second blockchain relay microservice node again also includes: Record that the first relay information has been sent again.
3. A cross-chain relay method, characterized in that: The method is applicable to a second blockchain relay microservice node, and the method includes: Receiving first relay information sent by a first blockchain relay microservice node; wherein the first relay information is generated by the first blockchain relay microservice node in response to monitoring first cross-chain event information from the first blockchain to the second blockchain, according to the first cross-chain event information; the first blockchain relay microservice node is further configured to record the first relay information and wait for confirmation while sending the first relay information; Packaging and generating a first relay transaction according to the first relay information and sending it to the second blockchain, and recording that the first relay information has been relayed; Sending first confirmation information to the first blockchain relay microservice node, so that the first blockchain relay microservice node, after receiving the first confirmation information, modifies the first relay information waiting for confirmation to the first relay information having been confirmed; In response to receiving the first relay information sent again, checking whether the first relay information has been relayed: If yes, the first confirmation information is sent to the first blockchain relay microservice node; If not, the first relay transaction is generated based on the first relay information and sent to the second blockchain, and a record is made that the first relay information has been relayed; and, Sending the first confirmation information to the first blockchain relay microservice node; Among them, the first relay information sent again is sent by the first blockchain relay microservice node in response to monitoring that the first confirmation information is not received within a predetermined time period.
4. A computer device, characterized in that: The device comprises: 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 3.
5. 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 3 is implemented.
Citation Information
Patent Citations
Cross-chain relay platform-based cross-chain method and system
CN108269190A
Cross-chain security guarantee method, computer equipment and storage medium
CN115221552A