Blockchain cross-chain method, device, storage medium and electronic equipment
By acquiring cross-chain status indicators of the blockchain network and adjusting the hash lock duration using a hash lock duration configuration model, the problem of hash lock duration configuration relying on human experience in cross-chain interoperability is solved, thereby improving the success rate and processing performance of cross-chain transactions.
Patent Information
- Application Number
- CN202111523370.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-13
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2041-12-13
AI Technical Summary
Cross-chain interoperability between different blockchains suffers from insufficient cross-chain processing performance. Existing hash lock duration configurations rely on human experience, which may lead to low cross-chain transaction processing performance.
By obtaining cross-chain status indicators of the blockchain network, adjusting the hash lock duration using the hash lock duration configuration model, generating hash lock duration configuration information based on the cross-chain status indicators, and optimizing the hash lock duration of cross-chain transactions.
It improves the success rate and processing performance of cross-chain transactions by dynamically adjusting the hash lock duration, thereby enhancing the efficiency and success rate of cross-chain transactions.
Smart Images

Figure CN114185990B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of blockchain technology, and more specifically, to a blockchain cross-chain method, apparatus, storage medium, and electronic device. Background Technology
[0002] Blockchain is a technology that enables the collective maintenance of a reliable database in a decentralized and trustless manner. During the development of blockchain technology, different types of blockchains have emerged. These different types of blockchains may exhibit technological heterogeneity, making it difficult for them to effectively exchange data and transfer value.
[0003] Among related technologies, hash locking can be used to achieve cross-chain interoperability between different blockchains. However, the cross-chain processing performance of this method still needs optimization. Summary of the Invention
[0004] The purpose of this disclosure is to provide a blockchain cross-chain method, apparatus, storage medium, and electronic device to solve the aforementioned related technical problems.
[0005] To achieve the above objectives, according to a first aspect of the present disclosure, a blockchain cross-chain method is provided, comprising:
[0006] In response to the first cross-chain transaction request, obtain the first hash lock duration configuration information, which is generated based on the cross-chain status indicators of the blockchain network;
[0007] The first hash lock duration is determined based on the first hash lock duration configuration information;
[0008] The first cross-chain transaction is executed based on the first hash lock duration.
[0009] Optionally, obtaining the first hash lock duration configuration information includes:
[0010] Obtain cross-chain status indicators of the blockchain network;
[0011] The cross-chain status indicator is input into the hash lock duration configuration model to obtain the first hash lock duration configuration information output by the hash lock duration configuration model;
[0012] The hash lock duration configuration model is trained based on hash lock duration samples, which include sample cross-chain status indicators and sample hash lock duration configuration information.
[0013] Optionally, it also includes:
[0014] Obtain cross-chain status indicators of the blockchain network according to a preset time window;
[0015] The cross-chain status indicator is input into the hash lock duration configuration model to obtain the hash lock duration configuration information for the current time window output by the hash lock duration configuration model.
[0016] The process of obtaining the first hash lock duration configuration information includes:
[0017] Obtain the hash lock duration configuration information corresponding to the current time window, and obtain the first hash lock duration configuration information;
[0018] The hash lock duration configuration model is trained based on hash lock duration samples, which include sample cross-chain status indicators and sample hash lock duration configuration information.
[0019] Optionally, the cross-chain status indicators and the sample cross-chain status indicators include one or more of the following: cross-chain transaction response time, hash-locked transaction pre-execution time, cross-chain transaction success rate, and cross-chain transaction throughput.
[0020] Optionally, it also includes:
[0021] Perform the following steps until the initial model converges to obtain the hash lock duration configuration model:
[0022] Input the sample cross-chain status index from the hash lock duration sample into the initial model to obtain the second hash lock duration configuration information output by the initial model;
[0023] The loss value is calculated based on the second hash lock duration configuration information and the sample hash lock duration configuration information in the hash lock duration sample.
[0024] The initial model is adjusted based on the loss value.
[0025] Optionally, the method is applied to a first blockchain gateway, which is configured relative to a first blockchain network, the first blockchain network being the blockchain network where the transaction initiator of the first cross-chain transaction request resides. The method further includes:
[0026] Forward the first cross-chain transaction request and the first hash lock duration configuration information to the second blockchain gateway;
[0027] The second blockchain gateway is configured relative to the second blockchain network, which is the blockchain network where the transaction recipient of the first cross-chain transaction request is located. The first hash lock duration configuration information is also used by the second blockchain gateway to determine the second hash lock duration, which is used by the second blockchain gateway to execute the first cross-chain transaction.
[0028] According to a second aspect of the present disclosure, a blockchain cross-chain device is provided, comprising:
[0029] The first acquisition module is used to respond to the first cross-chain transaction request and acquire the first hash lock duration configuration information, which is generated based on the cross-chain status indicators of the blockchain network.
[0030] The first determining module is used to determine the first hash locking duration based on the first hash locking duration configuration information;
[0031] The cross-chain transaction execution module is used to execute the first cross-chain transaction based on the first hash lock duration.
[0032] Optionally, the first acquisition module includes:
[0033] The first acquisition submodule is used to acquire cross-chain status indicators of the blockchain network;
[0034] The first input submodule is used to input the cross-chain status indicator into the hash lock duration configuration model to obtain the first hash lock duration configuration information output by the hash lock duration configuration model.
[0035] The hash lock duration configuration model is trained based on hash lock duration samples, which include sample cross-chain status indicators and sample hash lock duration configuration information.
[0036] Optionally, it also includes:
[0037] The second acquisition module is used to acquire cross-chain status indicators of the blockchain network according to a preset time window;
[0038] The input module is used to input the cross-chain status indicator into the hash lock duration configuration model to obtain the hash lock duration configuration information of the current time window output by the hash lock duration configuration model.
[0039] The first acquisition module includes:
[0040] The second acquisition submodule is used to acquire the hash lock duration configuration information corresponding to the current time window, and obtain the first hash lock duration configuration information;
[0041] The hash lock duration configuration model is trained based on hash lock duration samples, which include sample cross-chain status indicators and sample hash lock duration configuration information.
[0042] Optionally, the cross-chain status indicators and the sample cross-chain status indicators include one or more of the following: cross-chain transaction response time, hash-locked transaction pre-execution time, cross-chain transaction success rate, and cross-chain transaction throughput.
[0043] Optionally, it also includes a model training module for performing the following steps until the initial model converges to obtain the hash lock duration configuration model:
[0044] Input the sample cross-chain status index from the hash lock duration sample into the initial model to obtain the second hash lock duration configuration information output by the initial model;
[0045] The loss value is calculated based on the second hash lock duration configuration information and the sample hash lock duration configuration information in the hash lock duration sample.
[0046] The initial model is adjusted based on the loss value.
[0047] Optionally, the device is applied to a first blockchain gateway, which is configured relative to a first blockchain network, the first blockchain network being the blockchain network where the transaction initiator of the first cross-chain transaction request resides. The device further includes:
[0048] The forwarding module is used to forward the first cross-chain transaction request and the first hash lock duration configuration information to the second blockchain gateway;
[0049] The second blockchain gateway is configured relative to the second blockchain network, which is the blockchain network where the transaction recipient of the first cross-chain transaction request is located. The first hash lock duration configuration information is also used by the second blockchain gateway to determine the second hash lock duration, which is used by the second blockchain gateway to execute the first cross-chain transaction.
[0050] According to a third aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method described in any of the first aspects above.
[0051] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising:
[0052] A memory on which computer programs are stored;
[0053] A processor for executing the computer program in the memory to implement the steps of the method described in any of the first aspects above.
[0054] In the above technical solution, participants in a cross-chain transaction can obtain first hash lock duration configuration information generated based on the cross-chain status indicators of the blockchain network, and determine the first hash lock duration for this cross-chain transaction according to the first hash lock duration configuration information. In this way, participants in the cross-chain transaction can perform cross-chain transactions based on the first hash lock duration. Since the first hash lock duration configuration information is determined based on the cross-chain status indicators of the blockchain network, the above technical solution can effectively adjust the hash lock duration according to the cross-chain status of the blockchain network. For example, when the success rate of cross-chain transactions is low, the hash lock duration can be extended. In this way, cross-chain participants have more time to execute cross-chain transactions, thereby helping to improve the success rate of cross-chain transactions and optimizing the performance of cross-chain transaction processing.
[0055] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0056] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0057] Figure 1 This is a flowchart illustrating an exemplary embodiment of a blockchain cross-chain method.
[0058] Figure 2 This is a flowchart illustrating an exemplary embodiment of the present disclosure of a process for obtaining first hash lock duration configuration information.
[0059] Figure 3 This is a flowchart illustrating an exemplary embodiment of a blockchain cross-chain method.
[0060] Figure 4 This is a flowchart illustrating the training process of a hash lock duration configuration model as shown in an exemplary embodiment of this disclosure.
[0061] Figure 5 This is a flowchart illustrating an exemplary embodiment of a blockchain cross-chain method.
[0062] Figure 6 This is a flowchart illustrating a blockchain cross-chain process in an exemplary embodiment of this disclosure.
[0063] Figure 7 This is a block diagram of a blockchain cross-chain device shown in an exemplary embodiment of this disclosure.
[0064] Figure 8 This is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure. Detailed Implementation
[0065] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0066] Before introducing the blockchain cross-chain method, device, storage medium and electronic device disclosed herein, the application scenarios of this disclosure will be introduced first.
[0067] To achieve cross-chain interoperability between different blockchain networks, a hash-locking-based cross-chain method has been proposed in relevant scenarios. For example, in some implementations, the cross-chain initiator can generate a target random number and calculate its hash value to obtain a target hash value. Subsequently, the cross-chain initiator can construct a first smart contract based on the target hash value and a preset hash lock duration, and lock the asset A to be traded through the first smart contract. Here, the first smart contract can satisfy the following condition: within the hash lock duration, if another network member can provide the target random number, then asset A can be acquired.
[0068] The cross-chain initiator can also send the target hash value to the cross-chain receiver. The cross-chain receiver can also construct a second smart contract based on the target hash value and a preset hash lock duration, and lock the asset B to be traded through the second smart contract. Here, the second smart contract can satisfy the following condition: within the hash lock duration, if another network member can provide the target random number, then the asset B can be obtained.
[0069] In this way, the cross-chain initiator can provide the target random number to the second smart contract to obtain asset B. Since the cross-chain initiator provides the target random number to the second smart contract, the cross-chain receiver can also obtain the target random number. That is, the cross-chain receiver can provide the target random number to the first smart contract to obtain asset A, thereby completing the exchange transaction between asset A and asset B.
[0070] It's important to note that the hash lock duration has a significant impact on cross-chain transactions. A long hash lock duration can lead to prolonged resource locking, slowing down cross-chain transaction processing. Conversely, a short hash lock duration may prevent cross-chain participants from completing transactions in a timely manner due to network latency or other factors, causing the transaction response time to exceed the hash lock duration, resulting in transaction failure and triggering a rollback on the blockchain network. The applicant has found that hash lock durations in relevant scenarios are often preset based on human experience, potentially leading to excessively long or short durations and consequently, lower cross-chain transaction processing performance.
[0071] Therefore, this disclosure provides a blockchain cross-chain method. Figure 1 This is a flowchart illustrating a blockchain cross-chain method, as shown in this disclosure. Figure 1 As shown, the method includes:
[0072] In step 11, in response to the first cross-chain transaction request, the first hash lock duration configuration information is obtained, which is generated based on the cross-chain status indicators of the blockchain network.
[0073] In some implementation scenarios, the method can be applied to the cross-chain initiator. In this case, the first cross-chain transaction request can be generated by the cross-chain initiator in response to a user's operation. Thus, the cross-chain initiator can respond to the first cross-chain transaction request to obtain the first hash lock duration configuration information.
[0074] Figure 2 This is a flowchart illustrating the process of obtaining first hash lock duration configuration information. In one possible implementation, obtaining the first hash lock duration configuration information (step 11) includes:
[0075] S21, obtain cross-chain state indicators of the blockchain network.
[0076] S22, input the cross-chain status indicator into the hash lock duration configuration model to obtain the first hash lock duration configuration information output by the hash lock duration configuration model.
[0077] The hash lock duration configuration model is trained based on hash lock duration samples, which include sample cross-chain status indicators and sample hash lock duration configuration information. The cross-chain status indicators and the sample cross-chain status indicators may include one or more of the following: cross-chain transaction response time, hash lock transaction pre-execution time, cross-chain transaction success rate, and cross-chain transaction throughput.
[0078] In other words, the cross-chain initiator can respond to the first cross-chain transaction request and obtain the cross-chain status indicators of the blockchain network. After obtaining the cross-chain status indicators, the cross-chain initiator can input the cross-chain status indicators into the trained hash lock duration configuration model to obtain the first hash lock duration configuration information.
[0079] The first hash lock duration configuration information may include a hash lock duration adjustment strategy, such as "increasing the hash lock duration by a first target value" or "decreasing the hash lock duration by a second target value". Here, increasing the hash lock duration by a first target value may mean increasing the currently used hash lock duration by a first target value (e.g., 5 seconds), and decreasing the hash lock duration by a second target value may mean decreasing the currently used hash lock duration by a second target value (e.g., 10 seconds).
[0080] Thus, in step 12, the first hash lock duration is determined based on the first hash lock duration configuration information.
[0081] Continuing with the above example, if the currently used hash lock duration is A, and the first hash lock duration configuration information includes "increase the hash lock duration by 5 seconds," the cross-chain initiator can determine the new hash lock duration as A+5. Of course, in some implementation scenarios, the first hash lock duration configuration information may also include hash lock duration information. In this case, the cross-chain initiator can use the hash lock duration in the first hash lock duration configuration information as the first hash lock duration.
[0082] In step S13, the first cross-chain transaction is executed based on the first hash lock duration.
[0083] For methods of cross-chain transactions based on hash lock duration, please refer to the relevant technical documentation. For the sake of brevity, this disclosure will not elaborate on these methods.
[0084] By adopting the above technical solution, participants in cross-chain transactions can obtain first hash lock duration configuration information generated based on the cross-chain status indicators of the blockchain network, and determine the first hash lock duration for this cross-chain transaction according to the first hash lock duration configuration information. In this way, participants in the cross-chain transaction can conduct cross-chain transactions based on the first hash lock duration. Since the first hash lock duration configuration information is determined based on the cross-chain status indicators of the blockchain network, the above technical solution can effectively adjust the hash lock duration according to the cross-chain status of the blockchain network.
[0085] For example, when the success rate of cross-chain transactions is low, the hash lock duration can be extended. This allows cross-chain participants more time to execute cross-chain transactions, thereby helping to improve the success rate and optimizing cross-chain transaction processing performance.
[0086] Figure 3 This is a flowchart illustrating a blockchain cross-chain method, as shown in this disclosure. Figure 3 The method includes:
[0087] S31: Obtain cross-chain status indicators of the blockchain network according to a preset time window.
[0088] The preset time window can be set according to application requirements, such as one day, one hour, etc. The cross-chain status indicators and the sample cross-chain status indicators may include one or more of the following: cross-chain transaction response time, hash-locked transaction pre-execution time, cross-chain transaction success rate, and cross-chain transaction throughput.
[0089] S32, the cross-chain status indicator is input into the hash lock duration configuration model to obtain the hash lock duration configuration information for the current time window output by the hash lock duration configuration model. The hash lock duration configuration model is trained based on hash lock duration samples, which include sample cross-chain status indicators and sample hash lock duration configuration information.
[0090] The following provides an exemplary description of how the hash lock duration configuration model involved in the embodiments of this disclosure is obtained. Figure 4 This is a flowchart illustrating the training process of a hash lock duration configuration model. In one possible implementation, the following steps can be performed until the initial model converges to obtain the hash lock duration configuration model:
[0091] S41, input the sample cross-chain status index in the hash lock duration sample into the initial model to obtain the second hash lock duration configuration information output by the initial model;
[0092] S42, calculate the loss value based on the second hash lock duration configuration information and the sample hash lock duration configuration information in the hash lock duration sample;
[0093] S43, Adjust the initial model based on the loss value.
[0094] For example, an initial model can be constructed based on neural networks, least squares, etc. As an example, an initial model f(x) can be constructed here based on least squares:
[0095] f(x) = ω1x1 + ω2x2 + b
[0096] Where ω1 and ω2 are the initial model parameters, b is a constant term. β is the cross-chain transaction throughput, s is the cross-chain transaction success rate, q is the pre-execution time of hash-locked transactions, and t is the cross-chain transaction response time.
[0097] In some implementations, s can be obtained as follows: the total number of cross-chain transactions A and the number of successful cross-chain transactions B within the collection threshold duration ε. Furthermore, the threshold duration can be set based on application requirements. For example, in some implementations, the threshold duration ε can be 10 seconds.
[0098] The definition of the pre-execution time of a hash-locked transaction is provided in relevant technical documents and will not be elaborated upon here. Here, the pre-execution time q of a hash-locked transaction can be the largest among the pre-execution times of all hash-locked transactions in the cross-chain network. For example, if the cross-chain network includes blockchain network M, blockchain network N, and blockchain network O, where the pre-execution time t of the hash-locked transaction in blockchain network M is... m The pre-execution time of a hash-locked transaction in blockchain network N is t. n The pre-execution time of a hash-locked transaction in blockchain network O is t. o In this case, the pre-execution duration q of the hash-locked transaction can take the value t. m t n t o The largest of them.
[0099] When obtaining the cross-chain transaction response time t, the response time of each hash-locked transaction within a preset time period K can be recorded, thus determining the cross-chain transaction response time. Where n is the number of cross-chain transactions within a preset duration K, and t i The response time of the hash-locked transaction for the i-th cross-chain transaction.
[0100] In this way, the model parameters ω1 and ω2 in the initial model can be solved by gradient descent.
[0101] For example, a loss function J(w) can be defined. i ),
[0102]
[0103] Among them, y i f(x) is the sample hash lock duration configuration information in the hash lock duration sample, and f(x) is the second hash lock duration configuration information obtained by inputting the sample cross-chain state index in the hash lock duration sample into the initial model.
[0104] In this way, it can be based on the loss function J(w) i The value of ) adjusts the initial model. For example, in some implementation scenarios, dJ(W) can be defined as 0, and the partial derivatives of ω1 and ω2 can be calculated to obtain:
[0105]
[0106]
[0107] ω1 and ω2 are calculated using formulas (1) and (2), thus obtaining the hash lock duration configuration model. In some possible implementations, the value of f(x) can be normalized, and multiple value ranges and corresponding hash lock duration configuration information for each value range can be set.
[0108] As an example, when f(x)∈(0,0,15), the hash lock duration configuration information can be "increase the hash lock duration by 5 seconds"; when f(x)∈(0.15,0,35), the hash lock duration configuration information can be "increase the hash lock duration by 3 seconds"; when f(x)∈(0.35,0,55), the hash lock duration configuration information can be "maintain the current hash lock duration"; when f(x)∈(0.55,0,75), the hash lock duration configuration information can be "decrease the hash lock duration by 1 second"; when f(x)∈(0.75,0,85), the hash lock duration configuration information can be "decrease the hash lock duration by 3 seconds"; and when f(x)∈(0.85,1), the hash lock duration configuration information can be "decrease the hash lock duration by 5 seconds".
[0109] Furthermore, it is worth noting that the cross-chain transaction response time, hash-locked transaction pre-execution time, cross-chain transaction success rate, and cross-chain transaction throughput are exemplary descriptions of the cross-chain status indicators / sample cross-chain status indicators in this disclosure. In some implementation scenarios, the cross-chain status indicators / sample cross-chain status indicators may also include other parameters, such as the currently used hash-locking time, the timeout time of historical cross-chain transactions, etc. When constructing the initial model, the model can also be built based on one or more of the features included in the cross-chain status indicators, and this disclosure does not impose any restrictions on this.
[0110] After obtaining the hash lock duration configuration model, the cross-chain initiator can input the cross-chain status indicator into the hash lock duration configuration model to obtain the hash lock duration configuration information for the current time window output by the hash lock duration configuration model.
[0111] S33, in response to the first cross-chain transaction request, obtains the hash lock duration configuration information corresponding to the current time window, and obtains the first hash lock duration configuration information.
[0112] S34, determine the first hash lock duration according to the first hash lock duration configuration information.
[0113] S35, execute the first cross-chain transaction based on the first hash lock duration.
[0114] The aforementioned technical solution acquires cross-chain status indicators of the blockchain network according to a preset time window, and inputs these indicators into a hash lock duration configuration model to obtain the hash lock duration configuration information for the current time window output by the model. Thus, when a cross-chain transaction is required, the hash lock duration configuration information for the current time window can be directly obtained, and the hash lock duration used for the cross-chain transaction can be determined accordingly. In this way, there is no need to recalculate the hash lock duration configuration information when performing cross-chain transactions, thereby helping to improve the execution efficiency of cross-chain transactions.
[0115] It is worth noting that in some implementation scenarios, a third-party hash lock duration configuration server can also be deployed to calculate the hash lock duration configuration information. This hash lock duration configuration server can, for example, be controlled by an authoritative institution trusted by the cross-chain network. In this case, obtaining the first hash lock duration configuration information involved in this embodiment can also refer to sending a hash lock duration configuration request to the hash lock duration configuration server and receiving the hash lock duration configuration information returned by the hash lock duration configuration server.
[0116] Furthermore, it is worth noting that the above embodiments provide an exemplary description of the blockchain cross-chain method disclosed herein from the perspective of the cross-chain initiator. However, in some implementation scenarios, the blockchain cross-chain method provided herein can also be applied to blockchain gateways, cross-chain transaction recipients, and so on.
[0117] Figure 5 This is a flowchart illustrating a blockchain cross-chain method disclosed herein. The method is applied to a first blockchain gateway, which is configured relative to a first blockchain network, which is the blockchain network where the initiator of the first cross-chain transaction request resides. (Refer to...) Figure 5 The method includes:
[0118] S51, in response to the first cross-chain transaction request, obtain the first hash lock duration configuration information, which is generated based on the cross-chain status indicators of the blockchain network.
[0119] Reference Figure 6 The diagram illustrates a blockchain cross-chain process. For example, the transaction initiator can call the service interface of a first blockchain gateway to initiate the first cross-chain transaction request. Upon receiving the first cross-chain transaction request, the first blockchain gateway can obtain the first hash lock duration configuration information.
[0120] Here, the first blockchain gateway can obtain the first hash lock duration configuration information through the hash lock duration configuration model (please refer to the above-described embodiment of the hash lock duration configuration model for the method of obtaining the information). See also Figure 6 In some possible implementations, the first blockchain gateway may also send a hash lock duration configuration request to the configuration server to obtain the first hash lock duration configuration information fed back by the configuration server. The configuration server obtains cross-chain status indicators by detecting the first blockchain gateway and generates the first hash lock duration configuration information based on the obtained cross-chain status indicators (for the analysis method, please refer to the above-described embodiment of the hash lock duration configuration model).
[0121] S52, determine the first hash lock duration according to the first hash lock duration configuration information.
[0122] S53, execute the first cross-chain transaction based on the first hash lock duration.
[0123] Reference Figure 6 The first blockchain gateway may include, for example, a blockchain adaptation service. Thus, the first blockchain gateway can interact with the first blockchain network through the blockchain adaptation service. For example, with the permission of the transaction initiator, the first blockchain gateway can hash-lock the assets to be traded of the transaction initiator according to the first hash lock duration.
[0124] S54, forward the first cross-chain transaction request and the first hash lock duration configuration information to the second blockchain gateway.
[0125] In this configuration, the second blockchain gateway is positioned relative to a second blockchain network, which is the blockchain network where the transaction recipient of the first cross-chain transaction request resides. The first hash lock duration configuration information is also used by the second blockchain gateway to determine a second hash lock duration, which is used by the second blockchain gateway to execute the first cross-chain transaction. As a possible implementation, the second blockchain gateway may also, with the permission of the transaction recipient, hash-lock the transaction recipient's assets to be traded according to the second hash lock duration.
[0126] In this way, after both the transaction initiator's and the transaction recipient's assets are locked, the transaction initiator and the transaction recipient can conduct the first cross-chain transaction.
[0127] It should be noted that the second hash lock duration determined by the second blockchain gateway can be the same as or different from the first hash lock duration. Furthermore, as... Figure 6 As shown, in some implementation scenarios, the second blockchain gateway can also obtain the second hash lock duration configuration information on its own and determine the second hash lock duration based on the obtained second hash lock duration configuration information. This disclosure does not impose any restrictions on this.
[0128] By adopting the above technical solution, the first blockchain gateway can obtain the first hash lock duration configuration information generated based on the cross-chain status indicators of the blockchain network, and determine the first hash lock duration for this cross-chain transaction according to the first hash lock duration configuration information. In this way, the first blockchain gateway can perform cross-chain transactions based on the first hash lock duration. Since the first hash lock duration configuration information is determined based on the cross-chain status indicators of the blockchain network, the above technical solution can effectively adjust the hash lock duration according to the cross-chain status of the blockchain network. For example, when the success rate of cross-chain transactions is low, the hash lock duration can be extended. In this way, cross-chain participants have more time to execute cross-chain transactions, thereby helping to improve the success rate of cross-chain transactions and optimizing the performance of cross-chain transaction processing.
[0129] Based on the same inventive concept, this disclosure also provides a blockchain cross-chain device. Figure 7 This is a block diagram of a blockchain cross-chain device shown in this disclosure, with reference to... Figure 7 The device 700 includes:
[0130] The first acquisition module 701 is used to respond to the first cross-chain transaction request and acquire the first hash lock duration configuration information, which is generated based on the cross-chain status indicators of the blockchain network.
[0131] The first determining module 702 is used to determine the first hash locking duration based on the first hash locking duration configuration information;
[0132] The cross-chain transaction execution module 703 is used to execute the first cross-chain transaction based on the first hash lock duration.
[0133] In the above technical solution, participants in a cross-chain transaction can obtain first hash lock duration configuration information generated based on the cross-chain status indicators of the blockchain network, and determine the first hash lock duration for this cross-chain transaction according to the first hash lock duration configuration information. In this way, participants in the cross-chain transaction can perform cross-chain transactions based on the first hash lock duration. Since the first hash lock duration configuration information is determined based on the cross-chain status indicators of the blockchain network, the above technical solution can effectively adjust the hash lock duration according to the cross-chain status of the blockchain network. For example, when the success rate of cross-chain transactions is low, the hash lock duration can be extended. In this way, cross-chain participants have more time to execute cross-chain transactions, thereby helping to improve the success rate of cross-chain transactions and optimizing the performance of cross-chain transaction processing.
[0134] Optionally, the first acquisition module includes:
[0135] The first acquisition submodule is used to acquire cross-chain status indicators of the blockchain network;
[0136] The first input submodule is used to input the cross-chain status indicator into the hash lock duration configuration model to obtain the first hash lock duration configuration information output by the hash lock duration configuration model.
[0137] The hash lock duration configuration model is trained based on hash lock duration samples, which include sample cross-chain status indicators and sample hash lock duration configuration information.
[0138] Optionally, it also includes:
[0139] The second acquisition module is used to acquire cross-chain status indicators of the blockchain network according to a preset time window;
[0140] The input module is used to input the cross-chain status indicator into the hash lock duration configuration model to obtain the hash lock duration configuration information of the current time window output by the hash lock duration configuration model.
[0141] The first acquisition module includes:
[0142] The second acquisition submodule is used to acquire the hash lock duration configuration information corresponding to the current time window, and obtain the first hash lock duration configuration information;
[0143] The hash lock duration configuration model is trained based on hash lock duration samples, which include sample cross-chain status indicators and sample hash lock duration configuration information.
[0144] Optionally, the cross-chain status indicators and the sample cross-chain status indicators include one or more of the following: cross-chain transaction response time, hash-locked transaction pre-execution time, cross-chain transaction success rate, and cross-chain transaction throughput.
[0145] Optionally, it also includes a model training module for performing the following steps until the initial model converges to obtain the hash lock duration configuration model:
[0146] Input the sample cross-chain status index from the hash lock duration sample into the initial model to obtain the second hash lock duration configuration information output by the initial model;
[0147] The loss value is calculated based on the second hash lock duration configuration information and the sample hash lock duration configuration information in the hash lock duration sample.
[0148] The initial model is adjusted based on the loss value.
[0149] Optionally, the device is applied to a first blockchain gateway, which is configured relative to a first blockchain network, the first blockchain network being the blockchain network where the transaction initiator of the first cross-chain transaction request resides. The device further includes:
[0150] The forwarding module is used to forward the first cross-chain transaction request and the first hash lock duration configuration information to the second blockchain gateway;
[0151] The second blockchain gateway is configured relative to the second blockchain network, which is the blockchain network where the transaction recipient of the first cross-chain transaction request is located. The first hash lock duration configuration information is also used by the second blockchain gateway to determine the second hash lock duration, which is used by the second blockchain gateway to execute the first cross-chain transaction.
[0152] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0153] This disclosure also provides a non-transitory computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the blockchain cross-chain method provided in this disclosure.
[0154] This disclosure also provides an electronic device, including:
[0155] A memory on which computer programs are stored;
[0156] A processor for executing the computer program in the memory to implement the steps of the blockchain cross-chain method provided in this disclosure.
[0157] Figure 8 This is a block diagram illustrating an electronic device 800 according to an exemplary embodiment. For example... Figure 8 As shown, the electronic device 800 may include a processor 801 and a memory 802. The electronic device 800 may also include one or more of a multimedia component 803, an input / output (I / O) interface 804, and a communication component 805.
[0158] The processor 801 controls the overall operation of the electronic device 800 to complete all or part of the steps in the aforementioned blockchain cross-chain method. The memory 802 stores various types of data to support the operation of the electronic device 800. This data may include, for example, instructions for any application or method operating on the electronic device 800, and application-related data such as contact data, sent and received messages, images, audio, video, etc. The memory 802 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 803 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 802 or transmitted via communication component 805. The audio component also includes at least one speaker for outputting audio signals. I / O interface 804 provides an interface between processor 801 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. Communication component 805 is used for wired or wireless communication between the electronic device 800 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IoT, eMTC, or other 5G technologies, or combinations thereof, is not limited here. Therefore, the corresponding communication component 805 may include: a Wi-Fi module, a Bluetooth module, an NFC module, etc.
[0159] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the aforementioned blockchain cross-chain method.
[0160] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the blockchain cross-chain method described above. For example, the computer-readable storage medium may be the memory 802 including the program instructions described above, which may be executed by the processor 801 of the electronic device 800 to complete the blockchain cross-chain method described above.
[0161] In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable device, the computer program having a code portion for performing the above-described blockchain cross-chain method when executed by the programmable device.
[0162] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0163] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0164] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A blockchain cross-chain method, characterized in that, The method comprises: in response to a first cross-chain transaction request, obtaining first hash lock duration configuration information, wherein the first hash lock duration configuration information is generated based on a cross-chain state indicator of a blockchain network; determining a first hash lock duration according to the first hash lock duration configuration information; performing a first cross-chain transaction based on the first hash lock duration; the obtaining of the first hash lock duration configuration information comprises: obtaining a cross-chain state indicator of a blockchain network; inputting the cross-chain state indicator into a hash lock duration configuration model to obtain the first hash lock duration configuration information output by the hash lock duration configuration model; wherein the hash lock duration configuration model is trained based on hash lock duration samples, the hash lock duration samples comprise sample cross-chain state indicators and sample hash lock duration configuration information, and the cross-chain state indicator and the sample cross-chain state indicator comprise one or more of cross-chain transaction response duration, pre-execution duration of a hash lock transaction, cross-chain transaction success rate, and cross-chain transaction throughput.
2. The method of claim 1, wherein, Further comprising: obtaining a cross-chain state indicator of a blockchain network within a preset time window; inputting the cross-chain state indicator into a hash lock duration configuration model to obtain hash lock duration configuration information of the current time window output by the hash lock duration configuration model; the obtaining of the first hash lock duration configuration information comprises: obtaining hash lock duration configuration information corresponding to the current time window to obtain the first hash lock duration configuration information.
3. The method according to claim 1 or 2, characterized in that, Further comprising: performing the following steps until the initial model converges to obtain the hash lock duration configuration model: inputting the sample cross-chain state indicators in the hash lock duration samples into an initial model to obtain second hash lock duration configuration information output by the initial model; calculating a loss value according to the second hash lock duration configuration information and the sample hash lock duration configuration information in the hash lock duration samples; adjusting the initial model based on the loss value.
4. The method of claim 1, wherein, The method is applied to a first blockchain gateway, the first blockchain gateway is arranged relative to a first blockchain network, the first blockchain network is a blockchain network where a transaction initiator of the first cross-chain transaction request is located, and the method further comprises: forwarding the first cross-chain transaction request and the first hash lock duration configuration information to a second blockchain gateway; wherein the second blockchain gateway is arranged relative to a second blockchain network, the second blockchain network is a blockchain network where a transaction receiver of the first cross-chain transaction request is located, and the first hash lock duration configuration information is further used to determine a second hash lock duration by the second blockchain gateway, and the second hash lock duration is used to perform the first cross-chain transaction by the second blockchain gateway. 5.A blockchain cross-chain device, characterized in that, The method comprises: a first obtaining module, configured to obtain first hash lock duration configuration information in response to a first cross-chain transaction request, wherein the first hash lock duration configuration information is generated based on a cross-chain state indicator of a blockchain network; a first determining module, configured to determine a first hash lock duration according to the first hash lock duration configuration information; A cross-chain transaction execution module is configured to execute a first cross-chain transaction based on the first hash lock duration; The first obtaining module comprises: A first obtaining submodule is configured to obtain a cross-chain state indicator of a blockchain network; A first input submodule is configured to input the cross-chain state indicator into a hash lock duration configuration model to obtain the first hash lock duration configuration information output by the hash lock duration configuration model; The hash lock duration configuration model is trained based on hash lock duration samples, the hash lock duration samples comprise sample cross-chain state indicators and sample hash lock duration configuration information, and the cross-chain state indicators and the sample cross-chain state indicators comprise one or more of a cross-chain transaction response duration, a pre-execution duration of a hash lock transaction, a cross-chain transaction success rate, and a cross-chain transaction throughput.
6. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the steps of the method of any one of claims 1-4.
7. An electronic device, comprising: Comprise: A memory having a computer program stored thereon; A processor configured to execute the computer program in the memory to implement the steps of the method of any one of claims 1-4.
Citation Information
Patent Citations
Hash time locking method and system based on cloud cross-chain transfer protocol
CN113269545A
Cross-chain transaction method and system based on Hash locking and side chain technology, and storable medium
CN113627906A