An Optimization Method for Cross-Chain Atomic Swaps in Digital Currency
By performing machine learning and physical modeling on historical transaction data of the blockchain system, and combining adaptive delay prediction and path optimization algorithms, the timeout parameters are dynamically adjusted to solve the problem of insufficient exchange timing control precision caused by network latency uncertainty in cross-chain atomic swaps, thus achieving more efficient and reliable cross-chain transactions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-28
- Publication Date
- 2026-03-13
AI Technical Summary
In existing technologies, network latency uncertainty during cross-chain atomic swaps leads to insufficient precision in swap timing control, making it difficult to adapt to dynamic changes between different blockchain networks.
By collecting historical transaction data from multiple digital currency blockchain systems, a prediction model based on the CatBoost algorithm and a network propagation delay prediction equation are constructed. Combined with an adaptive delay prediction algorithm, a hierarchical deterministic wallet system and a hierarchical routing architecture are established. A secure multi-party computation protocol and a load balancing algorithm are used to make path optimization decisions and dynamically adjust timeout parameters, thereby achieving precise control over cross-chain asset exchange.
It significantly improves the timing control precision of cross-chain atomic swaps, reduces the impact of network latency fluctuations on transactions, and improves transaction success rate and system robustness.
Smart Images

Figure CN121010361B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of digital currency technology, and more specifically, relates to an optimized method for cross-chain atomic swaps of digital currencies. Background Technology
[0002] Cross-chain atomic swap technology for digital currencies, as a crucial means of achieving blockchain interoperability, traditionally employs a hash time-lock contract mechanism to ensure the security of asset exchanges between different blockchain networks. Atomicity is guaranteed by completing locking and unlocking operations within a predetermined time window. Current cross-chain swap systems are widely used in decentralized exchanges, cross-chain bridging services, and multi-chain wallet applications, providing users with direct asset transfer services without intermediaries. However, in existing technologies, due to the different block times, network congestion levels, and propagation delays of different blockchain networks, transaction confirmation times exhibit significant random fluctuations. This makes traditional fixed timeout settings difficult to adapt to dynamically changing network environments. In other words, existing technologies suffer from insufficient precision in controlling the exchange timing due to network latency uncertainties during cross-chain atomic swaps. Summary of the Invention
[0003] In view of this, the present invention provides an optimized method for cross-chain atomic swaps of digital currencies, which can solve the technical problem in the prior art where network latency uncertainty during cross-chain atomic swaps leads to insufficient precision in swap timing control.
[0004] This invention is implemented as follows: It provides an optimized method for cross-chain atomic swaps of digital currencies, comprising: collecting historical transaction data from multiple digital currency blockchain systems to extract original feature sets; performing feature engineering on the original feature sets to form enhanced feature sets; using the CatBoost algorithm to train models for each digital currency blockchain system, establishing prediction models for each system, and simultaneously constructing network propagation delay prediction equations based on transaction propagation and diffusion mechanisms, and establishing an adaptive delay prediction algorithm based on historical delay data; establishing a hierarchical deterministic wallet system, employing a secure multi-party computation protocol to achieve distributed key generation and management, reducing single-point-of-failure risks through a threshold signature mechanism, and utilizing hardware security modules to provide physical security for key storage, forming a key management architecture in a multi-chain environment; and constructing a hierarchical routing architecture to allocate cross-chain swap requests. Multiple parallel processing channels are used, and a load balancing algorithm is employed to optimize resource utilization. Combined with batch processing technology and pipelined processing mode, a multi-path concurrent processing mechanism is established. Path optimization decisions are made based on a multi-node path selection game model. The Nash equilibrium solution is obtained through a two-layer game. The cross-chain transaction characteristics are input into the prediction model to predict the lock transaction time and transfer transaction time. The time required by each digital currency blockchain system is calculated, and the transaction path with the shortest predicted time is selected as the optimal transaction path. Cross-chain transactions are sent according to the optimal transaction path. The hash time lock timeout is set based on the lock transaction prediction time and the user's predicted operation time. When the predicted transaction time exceeds the preset threshold, the timeout parameter is dynamically adjusted. When network latency is abnormal, the redundant path selection mechanism is used to switch to the redundant path. Transactions are sent sequentially according to the hash time lock process to complete the cross-chain asset exchange atomic swap process.
[0005] The multiple digital currency blockchain systems include blockchain nodes of currently known public blockchains or consortium blockchains represented by AntChain and Baidu HyperChain.
[0006] Historical latency data refers to the latency records of transaction propagation and confirmation processes in the blockchain network collected by the system over a past period. This includes the time it takes for a transaction to be initiated and included in a block, the latency of block propagation between network nodes, and latency fluctuations under different time periods and network conditions. This data is collected in real-time through a distributed crawler system, with a backtracking depth set to the most recent 180 days. It is used for statistical modeling of the adaptive latency prediction algorithm, dynamically predicting transmission latency under the current network condition using an exponentially weighted moving average method, providing data support for cross-chain transaction path optimization and timeout parameter settings.
[0007] Specifically, the original feature set includes transaction timestamp, transaction amount, transaction direction, transaction cost, transaction type, smart contract address, smart contract method, number of transactions in the transaction pool, number of transactions in the first 100 blocks, validator sequence in the first 100 blocks, number of validators in the first 100 blocks, block producer sequence in the first 100 blocks, number of block producers in the first 100 blocks, address of the user initiating the transaction, address of the user receiving the payment, IP address of the user initiating the transaction, and regional information.
[0008] Specifically, the feature engineering process involves converting transaction time into a 3-hour time period marker and a weekday / weekend marker, classifying transaction amounts into large, medium, small, and super-large markers, calculating the average block time and block time trend slope for the most recent 100 blocks, and statistically analyzing the account address transaction success rate and the number of transactions in the past 24 hours.
[0009] The specific steps for training the CatBoost algorithm model include dividing the dataset into a 70% training set, a 15% validation set, and a 15% test set, manually adjusting or using hyperparameter tuning tools to adjust hyperparameters, and measuring RMSE, MAE, and [other parameters]. The indicators are used to evaluate the model and to assess the business based on the proportion of transactions with an error within 10 seconds and the high-latency transaction recognition rate.
[0010] The CatBoost algorithm is specifically an improved version of the gradient boosting decision tree algorithm. It reduces the risk of overfitting and improves prediction accuracy by using ordered target statistics of classification features and a symmetric tree structure.
[0011] Specifically, the transaction propagation and diffusion mechanism is based on the physical process of transaction propagation in the blockchain network according to Fick's diffusion law, and is used to predict the propagation delay of transaction information between blockchain network nodes.
[0012] Specifically, the objectives of the game theory model are: the upper-level model aims to maximize the overall exchange efficiency of the system, while the lower-level model aims to optimize the resource utilization of individual nodes.
[0013] Specifically, the adaptive delay prediction algorithm predicts the transmission delay in real time under the current network condition by statistically modeling historical network delay data and dynamically adjusting the switching timeout parameters.
[0014] The hierarchical deterministic wallet is specifically based on the BIP32 standard wallet architecture, which derives subkeys from the master key to achieve hierarchical key management.
[0015] Specifically, the secure multi-party computation protocol is a cryptographic protocol in which multiple participants jointly compute the result of a function without disclosing their private information.
[0016] Specifically, the threshold signature mechanism is a cryptographic mechanism that requires a minimum number of signatures to be reached before a transaction signature can be completed.
[0017] Specifically, the hardware security module is a physical security device used for key generation, storage, and encryption operations.
[0018] The hierarchical routing architecture is specifically an architecture design that divides network routing into multiple layers for management, thereby improving routing efficiency and system scalability.
[0019] Specifically, the load balancing algorithm is an algorithm that distributes workloads across multiple computing resources to optimize resource utilization.
[0020] Specifically, the batch processing technology and the pipelined processing mode refer to the batch processing technology, which is a technique for packaging multiple processing requests into a batch for unified processing, and the pipelined processing mode, which is a processing mode for decomposing tasks into multiple stages for parallel execution.
[0021] This invention constructs an adaptive latency prediction algorithm based on a CatBoost algorithm and the transaction propagation mechanism to accurately predict transaction confirmation times in various cryptocurrency blockchain systems. This allows for dynamic adjustment of hash time lock timeout parameters based on the prediction results. By employing a two-layer game theory model for path optimization, the system can select the optimal transaction path while considering overall exchange efficiency and individual node resource utilization, significantly reducing the impact of network latency fluctuations on exchange success rates. In summary, this invention solves the technical problem mentioned in the background art where network latency uncertainty during cross-chain atomic swaps leads to insufficient precision in exchange timing control. Attached Figure Description
[0022] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0024] like Figure 1 The diagram shown is a flowchart of an optimized method for cross-chain atomic swaps of digital currency provided by this invention. This method includes the following steps:
[0025] S01. Collect historical transaction data from multiple digital currency blockchain systems, specifically including: extracting transaction timestamps, transaction amounts, transaction directions, transaction costs, transaction types, smart contract addresses, smart contract methods, transaction pool transaction counts, transaction counts in the top 100 blocks, validator sequence in the top 100 blocks, validator count in the top 100 blocks, block producer sequence in the top 100 blocks, block producer count in the top 100 blocks, initiating user address, receiving user address, initiating user IP address, and regional information as the original feature set;
[0026] S02. Perform feature engineering on the original feature set, specifically including: converting transaction time into 3-hour time period markers and weekday / weekend markers, dividing transaction amount into large, medium, small, and super large amount markers, calculating the average block time and block time trend slope of the most recent 100 blocks, and statistically analyzing the account address transaction success rate and the number of transactions in the past 24 hours to form an enhanced feature set;
[0027] S03. The CatBoost algorithm is used to train models for various cryptocurrency blockchain systems. Specifically, this includes dividing the dataset into a 70% training set, a 15% validation set, and a 15% test set; manually adjusting or using hyperparameter tuning tools to adjust hyperparameters; and evaluating performance through RMSE, MAE, and... The indicators are used to evaluate the model. The business is evaluated based on the proportion of transactions with time errors within 10 seconds and the high-latency transaction recognition rate. Predictive models for various digital currency blockchain systems are established. At the same time, a network propagation latency prediction equation is constructed based on the transaction propagation and diffusion mechanism. An adaptive latency prediction algorithm is established by combining historical latency data.
[0028] S04. Establish a layered deterministic wallet system, specifically including: adopting a secure multi-party computation protocol to realize distributed key generation and management, reducing the risk of single point of failure through a threshold signature mechanism, using hardware security modules to provide physical security for key storage, forming a key management architecture in a multi-chain environment, and solving the problem of balancing security and management in key generation, storage and distribution in a multi-chain environment.
[0029] S05. Construct a hierarchical routing architecture: Distribute cross-chain exchange requests to multiple parallel processing channels. Specifically, this includes: using load balancing algorithms to optimize resource utilization, combining batch processing technology and pipeline processing mode to establish a multi-path concurrent processing mechanism to improve system throughput and solve the scalability bottleneck problem faced by system throughput as transaction volume increases.
[0030] S06. Path optimization decision-making based on a multi-node path selection game model, specifically including: the upper-layer model aims to maximize the overall system exchange efficiency, while the lower-layer model aims to optimize the resource utilization of a single node. The Nash equilibrium solution is obtained through a two-layer game. Cross-chain transaction features are input into the prediction model to predict the lock-up transaction time and transfer transaction time. The time required by each digital currency blockchain system is calculated, the sum of the predicted transaction times of the cross-chain transaction path is calculated, and the transaction path with the shortest predicted time is selected as the optimal transaction path corresponding to the game equilibrium solution. This solves the network latency uncertainty problem that affects the atomic exchange timing control accuracy due to random latency fluctuations between different blockchain networks.
[0031] S07. Send cross-chain transactions according to the optimal transaction path, specifically including: setting the hash time lock timeout based on the predicted transaction time and the user's predicted operation time; dynamically adjusting the timeout parameter when the predicted transaction time exceeds the preset threshold; switching to the redundant path in combination with the redundant path selection mechanism when the network latency is abnormal; sending transactions sequentially according to the hash time lock process to complete the cross-chain asset exchange atomic swap process; achieving the effect of predicting transaction failure by advancing the average rollback time of the timeout unlock rollback transaction; and achieving the effect of multi-path transaction selection that improves transaction speed compared to the solution of only selecting the shortest path.
[0032] Among them, the secure multi-party computation protocol is a cryptographic protocol in which multiple participants jointly compute the result of a function without disclosing their private information. The threshold signature mechanism is a cryptographic mechanism that requires a minimum number of signatures to complete a transaction signature. The hardware security module is a physical security device used for key generation, storage, and encryption operations. The hierarchical routing architecture is an architecture design that divides network routing into multiple layers for management, improving routing efficiency and system scalability. The load balancing algorithm is an algorithm that distributes workloads across multiple computing resources to optimize resource utilization. Batch processing technology is a technique for packaging multiple processing requests into batches for unified processing. The pipelined processing mode is a processing mode that decomposes tasks into multiple stages for parallel execution. The hash time lock is a smart contract based on hash functions and time constraints to ensure the security of atomic swaps. The Nash equilibrium solution is a solution in game theory where all participants' strategies reach a stable state. The preset threshold is a pre-set judgment standard value for the system. The redundant path selection mechanism is a mechanism in which the system automatically selects an alternative transmission path when the main path is abnormal. The network latency uncertainty problem is a technical challenge where random latency fluctuations between different blockchain networks affect the accuracy of atomic swap timing control. The scalability bottleneck refers to the processing capacity limitations faced by the system's throughput as transaction volume increases. The effect of early transaction failure prediction is the technical benefit of identifying potentially failing transactions in advance through predictive models and quickly executing rollback operations. The multi-path transaction selection effect is the performance improvement achieved by selecting the optimal transaction path through time prediction compared to solutions that only consider path length.
[0033] In addition, the present invention is implemented by a computer to form a digital currency cross-chain atomic swap optimization system. The computer is equipped with a readable storage medium, which stores program instructions. When the program instructions are run in the computer, they are used to execute the above-mentioned method.
[0034] The specific implementation methods of the above steps are described in detail below.
[0035] The specific implementation of step S01 involves real-time data monitoring and historical data backtracking collection from multiple cryptocurrency blockchain networks via a distributed subscription system. First, a blockchain node connection pool is established, creating stable connections with various mainstream cryptocurrency blockchain systems through application programming interfaces (APIs), including publicly known public chains and consortium blockchains such as AntChain and Baidu HyperChain. Then, a data acquisition module is deployed, employing an event listening mechanism to capture transaction events on the blockchain in real time, while simultaneously extracting historical block data in batches using a block traversal algorithm. During data acquisition, the block structure needs to be parsed to extract basic information such as transaction hashes, block heights, and transaction indexes. Then, complete transaction metadata is obtained through a transaction details query interface. For smart contract transactions, the transaction input data needs to be decoded to identify contract method calls and parameter information. Geographic information acquisition is achieved through an IP address location service, using a GeoIP database to map IP addresses to geographic region identifiers. The entire acquisition process employs a multi-threaded concurrent processing architecture, setting the data acquisition frequency to scan a new block every 3 seconds, and the historical data backtracking depth to the most recent 180 days. The purpose of this step is to provide a comprehensive and high-quality raw data foundation for subsequent machine learning model training.
[0036] The specific implementation of step S02 involves preprocessing and enhancing the original data using feature engineering techniques. Time feature transformation employs a time window partitioning algorithm, dividing the 24 hours into eight 3-hour time periods: 0-3, 3-6, 6-9, 9-12, 12-15, 15-18, 18-21, and 21-24, each time period assigned a numerical code. Weekday / weekend marking is implemented using a date parsing function: Monday to Friday are marked as 1, and Saturday and Sunday as 0. Transaction amount grading uses a quantile statistical method, dividing transaction amounts into four levels based on historical data distribution: small transactions are defined as below the 25th quantile, medium transactions as 25%-75% quantile, large transactions as 75%-95% quantile, and very large transactions as above the 95th quantile. Average block time calculation uses a sliding window statistical algorithm, calculating the arithmetic mean of the block time intervals of the most recent 100 blocks as the current average block time. The block time trend slope is calculated using a linear regression algorithm, with block height as the independent variable and block time as the dependent variable, fitting a linear relationship to obtain the trend slope parameter. Account transaction success rate statistics are calculated using the ratio of historical successful transactions to the total historical transaction count, with the statistical time window set to the most recent 30 days. The purpose of this step is to transform the raw data into a more predictive feature representation, improving the training effect of the machine learning model.
[0037] The specific implementation of step S03 involves constructing a prediction model using the CatBoost gradient boosting tree algorithm. The CatBoost algorithm employs an ordered objective statistical method to process category features and reduces overfitting through a symmetric tree structure, exhibiting better generalization ability compared to traditional gradient boosting algorithms. Dataset partitioning uses stratified sampling to ensure uniform distribution of samples across the training, validation, and test sets. Hyperparameter tuning utilizes a Bayesian optimization algorithm, with key parameters including a learning rate set to 0.03-0.3, a tree depth set to 4-10 layers, and the number of iterations set to 500-2000. Model evaluation employs cross-validation, using 5-fold cross-validation to calculate the average performance index. Network propagation delay prediction is based on a mathematical model constructed from diffusion theory. This model analogizes the propagation of transaction information in the blockchain network to a physical diffusion phenomenon, predicting the arrival time of transaction information at each node by solving the diffusion equation. The adaptive delay prediction algorithm uses an exponentially weighted moving average method, dynamically adjusting prediction parameters based on the most recently observed network delay data, with a weight decay factor set to 0.7. The business evaluation thresholds are set at an accuracy rate of no less than 85% for transaction time errors within 10 seconds and a high-latency transaction identification rate of no less than 90%. The purpose of this step is to establish accurate transaction latency prediction capabilities, providing a time estimation basis for cross-chain path optimization.
[0038] The specific implementation of step S04 is based on a multi-chain key management system built on the hierarchical deterministic wallet standard. The system uses the BIP32 standard to generate the master key, generates a 256-bit random master seed using the elliptic curve digital signature algorithm, and then derives the master private key and main chain code using the HMAC-SHA512 hash function. The key derivation path uses a combination of hardened and non-hardened derivation, assigning an independent derivation path to each cryptocurrency blockchain system. The path format is m / 44' / coin_type' / account' / change / address_index. The secure multi-party computation protocol uses a secret sharing mechanism, dividing the master key into n secret shares. A threshold of t is set, requiring at least t shares to reconstruct the original key; a configuration parameter of n=5 and t=3 is recommended. The threshold signature uses a threshold version of the Schnorr signature algorithm, supporting a t-of-n signature strategy, and reconstructs the signature using Lagrange interpolation. The hardware security module uses cryptographic devices compliant with the FIPS 140-2 Level 3 standard, providing protection against tampering and physical attacks. Key generation uses a true random number generator. The key rotation strategy is set to update the master key every 30 days and the derived key every 7 days. This step aims to ensure the secure generation, storage, and use of keys in a multi-chain environment, preventing asset loss due to key leakage.
[0039] The specific implementation of step S05 involves constructing a multi-layered routing processing architecture to improve the system's concurrent processing capabilities. The architecture employs a three-layer design, including an access layer, a routing layer, and an execution layer. The access layer receives cross-chain exchange requests and uses a round-robin algorithm to distribute requests to multiple processing queues, each with a maximum capacity of 1000 requests. The routing layer implements load balancing, using a weighted least connections algorithm to allocate tasks based on the processing capacity and current load of each execution node. Weight calculation is based on a comprehensive score of node CPU utilization, memory utilization, and network bandwidth utilization. The execution layer adopts a pipelined processing model, decomposing cross-chain transactions into five stages: verification, path calculation, transaction construction, signing, and broadcasting. Each stage uses an independent processing thread pool. Batch processing technology packages multiple transactions from the same target chain for processing. The batch size is dynamically adjusted according to network congestion, normally set to 20-50 transactions per batch, and adjusted to 5-10 transactions per batch during congestion. The multi-path concurrency mechanism supports processing up to eight parallel paths simultaneously, with each path allocated an independent resource quota. System throughput monitoring employs a sliding window statistical method, triggering a capacity expansion mechanism when the average throughput falls below 80% of a set threshold within 5 minutes. The purpose of this step is to improve the system's processing capacity under high-concurrency scenarios through parallel processing and resource optimization.
[0040] The specific implementation of step S06 involves using a two-layer game theory model for optimal path selection. The upper-layer game theory model aims to maximize the overall system exchange efficiency, considering strategy variables such as total path length, predicted transaction time, and network congestion. The model is solved using a genetic algorithm with a population size of 100 individuals, 200 generations, a crossover probability of 0.8, and a mutation probability of 0.1. The lower-layer game theory model aims to optimize the resource utilization of individual nodes, using a particle swarm optimization algorithm with 50 particles, 100 iterations, and a linearly decreasing inertia weight from 0.9 to 0.4. The game equilibrium solution is obtained through iterative solving, with the upper and lower-layer models alternately optimizing until convergence. The convergence criterion is that the objective function improvement is less than 0.001% in 10 consecutive iterations. The path prediction time is calculated by adding the locking and transfer times of each cryptocurrency blockchain system to obtain the single-system processing time, and then summing the processing times of all involved systems to obtain the total path time. The time prediction uses the expected value output by a machine learning model, while considering the upper bound of the 95% confidence interval as a risk buffer. The path selection decision employs a multi-objective optimization method, balancing transaction costs and success rate while minimizing the prediction time. The aim of this step is to find the time-optimal transaction execution path in a complex multi-chain environment, addressing the uncertainty of network latency.
[0041] The specific implementation of step S07 is to execute the cross-chain atomic swap process based on the selected optimal path. The hash time lock timeout is set using a dynamic calculation method. The base timeout equals the sum of the predicted transaction time and the predicted user operation time, plus a 30% safety margin. When the predicted transaction time exceeds a preset threshold of 300 seconds, the dynamic adjustment mechanism increases the safety margin to 50%. Network latency anomaly detection uses a statistical control chart method. When the actual latency exceeds the historical average plus three times the standard deviation, it is considered an anomaly, triggering a redundant path switching mechanism. Redundant paths are selected from a pre-sorted list of candidate paths, ranked according to a comprehensive score of predicted time and success rate. The hash time lock is implemented using smart contract technology, with hash value verification and time lock constraint logic set in the contract. Transaction sending adopts an asynchronous concurrent mode, with transactions on each chain initiated simultaneously to reduce overall waiting time. Transaction status monitoring uses an event listening mechanism to track the confirmation status of each transaction in real time. The rollback transaction pre-construction technology pre-constructs rollback transactions while the main transaction is being sent. When a potential failure of the main transaction is detected, the rollback transaction is immediately broadcast to avoid waiting for timeouts. Success rate statistics show that this optimization method significantly improves transaction rollback time compared to traditional methods, and the multi-path selection strategy significantly improves transaction speed compared to the single shortest path strategy. The purpose of this step is to ensure the secure and reliable execution of cross-chain atomic swaps, maximizing transaction success rate and execution efficiency.
[0042] It should be noted that the digital currency blockchain system prediction model, the network propagation delay prediction equation, and the adaptive delay prediction algorithm constitute a complete transaction delay prediction system. The digital currency blockchain system prediction model is the core model, based on the CatBoost gradient boosting tree algorithm, which uses machine learning to predict the lock-up and transfer transaction times of various blockchain systems. It establishes a non-linear mapping relationship between transaction time and these features by training on a set of enhanced features from historical transaction data, such as transaction timestamps, transaction amounts, transaction types, smart contract information, and network congestion conditions. The network propagation delay prediction equation is a physical model based on Fick's diffusion law. It analogizes the propagation of transaction information between blockchain network nodes to a diffusion phenomenon. By solving partial differential equations, it predicts the network transmission time required for transaction information to propagate from the initiating node to various verification nodes. This equation takes network topology parameters such as network node density, transaction data size, and network bandwidth utilization as inputs and outputs transaction propagation delay, supplementing the machine learning model's characterization of network layer propagation characteristics from a physical mechanism perspective. The adaptive delay prediction algorithm uses an exponentially weighted moving average method to statistically model historical network delay data, integrates the current observed delay and the previous predicted delay in real time, and dynamically adjusts the prediction parameters to quickly respond to changes in network state. A weight decay factor of 0.7 is set to give higher weight to recent data. The collaborative mechanism of these three components is as follows: the digital currency blockchain system prediction model provides transaction processing time predictions based on historical data through machine learning; the network propagation delay prediction equation provides propagation time predictions based on network topology through physical modeling; and the adaptive delay prediction algorithm acts as a dynamic calibration layer, combining the prediction results of both with the real-time network state for online correction. This ultimately forms a multi-dimensional delay prediction capability that comprehensively considers transaction processing characteristics, network propagation mechanisms, and real-time state changes. This provides accurate and reliable time estimation basis for optimal path selection in step S06 and dynamic timeout parameter setting in step S07, solving the network delay uncertainty problem that affects the atomic exchange timing control accuracy due to random delay fluctuations between different blockchain networks.
[0043] It should be noted that the key technical ideas of this invention are mainly reflected in the following aspects. First, there is a machine learning-based transaction latency prediction technology. This technology uses the CatBoost algorithm to perform deep learning on massive historical transaction data and combines it with network propagation and diffusion theory to establish a prediction model. Compared with the traditional static timeout setting method, it can dynamically predict the transaction execution time based on the real-time network status, significantly improving the accuracy and adaptability of time estimation, thereby reducing transaction failures and resource waste caused by improper timeout settings. Second, there is a two-layer game theory path optimization algorithm. This algorithm models the cross-chain path selection problem as a multi-objective optimization game. The upper-layer model pursues the maximization of the overall system efficiency, while the lower-layer model optimizes the resource utilization of a single node. The optimal path selection strategy is obtained by solving through Nash equilibrium. Compared with the traditional heuristic path selection method, it can find the true global optimal solution in a complex multi-chain network environment, effectively balancing multiple performance indicators such as transaction time, cost, and success rate. The third is the adaptive timeout control mechanism. This mechanism combines latency prediction results and network status monitoring to dynamically adjust the timeout parameters of the hash time lock. It also achieves rapid fault recovery through pre-built rollback transactions and redundant path switching. Compared with the traditional solution with a fixed timeout, it can better cope with network latency fluctuations and abnormal situations, thus improving the robustness and reliability of the system.
[0044] The synergy of these key technologies forms a complete cross-chain atomic swap optimization solution. Machine learning prediction provides an accurate time estimation basis for game theory optimization, enabling path selection algorithms to make decisions based on reliable time data. The optimal path selection result of game theory optimization provides an execution plan for adaptive timeout control. The timeout control mechanism ensures the smooth completion of the entire exchange process through dynamic adjustment and fault recovery. These three elements form a closed-loop feedback system: the accuracy of the prediction model is verified and improved through actual transaction results, the path optimization strategy is adjusted according to the execution effect, and the timeout control parameters are optimized based on success rate statistics. Compared with the relatively independent architecture of existing technologies, this collaborative optimization scheme can achieve global performance optimization at the system level. It not only improves the execution efficiency of a single transaction, but more importantly, it establishes a mechanism for continuous learning and self-improvement, enabling the system to adapt to the ever-changing blockchain network environment and providing a more intelligent and reliable technical foundation for cross-chain digital currency exchange.
[0045] It should be noted that in traditional cross-chain exchange systems, users need to manage key pairs separately for each blockchain network, which not only increases the risk of key loss and leakage but also reduces the convenience of user operation. This invention establishes a hierarchical deterministic wallet system, employing a key derivation mechanism based on the BIP32 standard to generate multiple subkeys from a single master key to support the transaction signature requirements of different blockchain networks. Simultaneously, it combines a secure multi-party computation protocol to achieve distributed key generation and management, uses a threshold signature mechanism to ensure that even if some key fragments are lost, system security is not affected, and utilizes hardware security modules to provide physical-level key storage protection, forming a multi-chain key architecture that is both secure and easy to manage. With the rapid growth in cross-chain exchange demand, the traditional single-threaded processing mode cannot meet the processing needs of large-scale concurrent transactions, easily leading to problems such as transaction queuing and system response delays. This invention constructs a hierarchical routing architecture to intelligently distribute cross-chain exchange requests to multiple parallel processing channels, employing a load balancing algorithm to ensure a relatively balanced workload across each processing channel. By combining batch processing technology to package multiple small transactions for processing to reduce system overhead, and adopting a pipeline processing mode to decompose the transaction processing process into multiple stages for parallel execution, a multi-path concurrent processing mechanism was established, which significantly improved the overall throughput and concurrent processing capability of the system and effectively solved the scalability bottleneck problem.
[0046] Specifically, the principle of this invention is as follows: The fundamental principle that solves the core technical problem of insufficient accuracy in exchange timing control due to network latency uncertainty lies in establishing a complete latency prediction and adaptive adjustment mechanism. First, through in-depth mining of historical transaction data from multiple digital currency blockchain systems, key features including transaction timestamps, transaction amounts, and network congestion status are extracted, constructing a comprehensive feature set that reflects the dynamic characteristics of the network. Second, the CatBoost gradient boosting decision tree algorithm is used to train these features using machine learning. This algorithm effectively reduces the risk of overfitting through ordered target statistics of classification features and a symmetric tree structure, accurately capturing the complex nonlinear relationship between network latency and various influencing factors. Simultaneously, the physical model constructed based on the transaction propagation and diffusion mechanism can theoretically predict the propagation latency of transaction information between blockchain network nodes, providing a physical foundation for latency prediction. Regarding path selection, the two-layer game model achieves a balance between overall system efficiency and individual node interests through Nash equilibrium solutions. The upper-layer model pursues maximizing the overall system exchange efficiency, while the lower-layer model optimizes the resource utilization of individual nodes. The two interact and constrain each other through coupling terms, ensuring that the selected transaction path satisfies both global optimization requirements and guarantees reasonable returns for each participating node. Ultimately, the system dynamically sets the hash time lock timeout parameter based on the predicted transaction time. When the predicted time exceeds the preset threshold, the timeout parameter is automatically adjusted, and the system switches to a redundant path when there is a network anomaly. This enables proactive response and precise control over network latency uncertainties.
[0047] The following provides a specific embodiment of the present invention, and the specific implementation of each step in this embodiment is described in detail below.
[0048] In this embodiment, the specific implementation of step S01 is the same as described above, and will not be repeated in detail here.
[0049] The specific implementation of step S02 involves preprocessing and enhancing the original data using feature engineering techniques. The transaction amount is categorized using quantile statistics, and the categorization function is expressed as follows:
[0050] ;
[0051] In the formula, Based on transaction amount level; The value is 1, which is used as a reference for transaction amount levels. This is the original transaction amount, expressed in digital currency units. This represents the largest historical transaction amount, expressed in digital currency units.
[0052] The average block time is calculated using a sliding window statistical algorithm, and the calculation formula is as follows:
[0053] ;
[0054] In the formula, Average block generation time, in seconds; The average block time is taken as a reference, and the value is 10. ; The value is 100 to represent the window size. For the first The block creation time, in seconds; For reference time, the value is 1. .
[0055] The slope of the block generation time trend is calculated using a linear regression algorithm, and the regression equation is expressed as follows:
[0056] ;
[0057] In the formula, The slope of the block generation time trend, in seconds; The value is set to 0.1 as a reference for the trend slope. ; For the first Block height; The reference block height is set to 1. The average block height; This represents the average block generation time, in seconds.
[0058] The specific implementation of step S03 involves using the CatBoost gradient boosting tree algorithm to construct a prediction model, and simultaneously constructing a network propagation delay prediction equation based on the transaction propagation and diffusion mechanism, as described below:
[0059] ;
[0060] In the formula, The concentration of transaction information at a node, in units of [number of nodes]. node; For reference concentration, a value of 1 is used. node; Time, in seconds; For reference time, the value is 1. ; This is the diffusion coefficient, in units of... ; The reference diffusion coefficient is set to a value of [value missing]. ; The unit is the speed of transmission. ; For reference length, the value is 1000. ; For transaction source items, the unit is individuals. (node·second); As a reference source item, the value is 0.1. (node·second); For reference volume, the value is taken as... This value is used for valuation; is the Laplace operator, used to calculate the second spatial derivative; This is the gradient operator, used to calculate the first-order spatial derivative.
[0061] It's important to explain that the network propagation delay prediction equation essentially analogizes the propagation of transaction information in a blockchain network to diffusion in physics. It establishes a mapping between an abstract network topology and concrete physical space through mathematical modeling. The physical units such as "meter" and "cubic meter" are not actual physical dimensions, but rather virtual representations of the network topology. Specifically, the spatial distance in the equation corresponds to the hop count or transmission delay between nodes in the blockchain network, the volume V corresponds to the effective coverage of the network (a comprehensive measure of the number and distribution range of nodes), and the concentration... The diffusion coefficient corresponds to the proportion of nodes that have received transaction information at a certain network location. The information propagation capability and speed are determined by network bandwidth and node connection density. Corresponding to the directional transmission rate through the backbone node, the reference length The corresponding distance mapping in the network is 5 to 10 hops, and the reference volume is... The normalization constant, derived from historical network data through backfitting, is used to unify the dimensions. The diffusion term on the right-hand side of the equation describes the natural diffusion of information from known nodes to unknown nodes, similar to heat conduction. The convection term describes the directional and rapid propagation of information along the main path. The source term describes the continuous generating effect of the transaction initiating node as an information source, and dividing by volume reflects the sparser propagation density in a larger network. The entire equation, through the mathematical framework of partial differential equations, transforms the complex network propagation process into a computable physical model. The specific values of all parameters are as follows: , , These are all optimal reference values determined through statistical analysis and model calibration of historical transaction propagation data collected from actual blockchain networks. This enables the virtual physical model to accurately predict the time it takes for transaction information to reach each node in the real network. Compared with traditional static delay estimation methods, it can dynamically reflect the impact of network state changes on propagation delay.
[0062] The mapping approach is as follows: the blockchain network topology is mapped to a virtual physical space, the distribution and connection relationships of nodes in the network are mapped to points in three-dimensional space, the network distance (hop count, latency) between nodes is mapped to spatial distance (meters), and the scale of the network is mapped to spatial volume (cubic meters). (Transaction information concentration, unit: nodes / node) refers to the proportion of nodes that have received the transaction information at a certain location (a node or group of nodes) in the network. Analogous to "mass concentration" in physical diffusion, high concentration = more nodes know about the transaction; low concentration = fewer nodes know about the transaction. V (cubic meters) actually refers to the effective coverage area of the blockchain network, which can be understood as the space occupied if all nodes were unfolded in three-dimensional space according to the network topology. It is a normalized reference value used to standardize dimensions. For the diffusion term... Similar to heat conduction, information naturally diffuses from nodes with "high concentration" to nodes with "low concentration"; in blockchain, this corresponds to: nodes that have received a transaction will broadcast it to neighboring nodes that have not yet received it. (Diffusion coefficient): Reflects the propagation capability of a network. The larger the network bandwidth and the denser the node connections, the larger the diffusion coefficient. (Laplace operator): Calculates the spatial second derivative of concentration, characterizing the concentration gradient change. For the convection term... Similar to the directional flow of fluids, blockchain corresponds to the existence of "backbone nodes" (such as mining pools and exchange nodes) in the network, where information spreads rapidly and directionally along the main path. (Propagation speed): Reflects the transmission speed of the network backbone; negative sign: indicates that information flows from a high-concentration area to a low-concentration area. For source items... This signifies the continuous generation of new substances; in blockchain, the transaction is initially generated by the initiating node, which is the "source". (Transaction Source Term): The strength of the transaction initiation; divided by the volume V: the larger the volume, the lower the source strength per unit volume, which is consistent with reality—the same transaction propagates more sparsely in a larger network. The corresponding relationship is shown in Table 1 below:
[0063] Table 1. Concept Correspondence Table
[0064]
[0065] The adaptive delay prediction algorithm uses an exponentially weighted moving average method, and the prediction formula is expressed as follows:
[0066] ;
[0067] In the formula, The predicted delay time is in seconds; The value is 1, which is used as a reference for the predicted delay time. ; This is the weight decay factor, with a value of 0.7; This is the current observation delay time, in seconds; The reference delay time is set to 1. ; This represents the delay time from the previous prediction, in seconds.
[0068] The specific implementation of step S04 is the same as described above, and will not be repeated in detail here.
[0069] The specific implementation of step S05 involves constructing a multi-layered routing processing architecture. The load balancing algorithm uses the weighted least connections method, and the weight calculation formula is expressed as follows:
[0070] ;
[0071] In the formula, Node weights; The reference node weight is set to 1. CPU utilization, in percentage (%) The CPU utilization rate is set at 50% for reference. This represents memory usage, expressed as a percentage (%). The reference memory usage rate is set at 60%. Network bandwidth utilization, expressed as % For reference, the network bandwidth utilization rate is set at 70%.
[0072] The formula for dynamically adjusting batch size is expressed as follows:
[0073] ;
[0074] In the formula, This refers to the batch size, expressed in units of items. For reference batch size, the value is 20. The base batch size, with a value of 50; To reference the base batch size, a value of 50 is used; To indicate the degree of network congestion; The value is set to 1 to indicate the degree of network congestion.
[0075] The specific implementation of step S06 is based on a multi-node path selection game model for path optimization decision-making. The objective function of the upper-level model is expressed as follows:
[0076] ;
[0077] In the formula, This represents the objective function value of the upper-level model. For reference system efficiency, the value is set to 1; The total transaction time for the path is in seconds; This represents the path length, in hops. The reference path length is set to 5 hops. The degree of network congestion; The value is set to 1 to indicate the level of congestion. , , These are the weighting coefficients; , , The reference weighting coefficients are set to 0.35, 0.45, and 0.20, respectively.
[0078] The objective function of the lower-level model is expressed as follows:
[0079] ;
[0080] In the formula, The objective function value of the lower-level model; The reference node utility value is set to 1. The processing capacity of a node is expressed in units of 'pen'. minute; For reference processing capacity, the value is set to 100 records. minute; Current load factor, in percentages (%) The reference load rate is set at 50%. The expected rate of return is expressed in %; The reference rate of return is set at 5%. , , These are the weighting coefficients; , , The reference weighting coefficients are set to 0.55, 0.30, and 0.15, respectively.
[0081] The upper-level model and the lower-level model influence each other through coupling terms, which are described as follows:
[0082] ;
[0083] In the formula, For coupling terms; As a reference coupling term, its value is 1; This is the coupling strength coefficient; The reference coupling strength coefficient is set to 0.10.
[0084] The formulas for calculating the time required by various cryptocurrency blockchain systems are as follows: In the formula, The time required for the digital currency blockchain system X, in seconds; The time for locking transactions in the digital currency blockchain system X is measured in seconds. The transaction time for digital currency blockchain system X is measured in seconds.
[0085] The formula for calculating the sum of transaction times in cross-chain transaction path prediction is as follows: In the formula, The total predicted time for cross-chain transaction paths, in seconds; , , These represent the time required for digital currency blockchain systems A, B, and X, respectively, in seconds.
[0086] The specific implementation of step S07 is to perform a cross-chain atomic swap process based on the selected optimal path. The formula for setting the hash time lock timeout is as follows: In the formula, This is the timeout period for the hash time lock, in seconds. Predict the operation time for the user, in seconds.
[0087] The dynamic timeout adjustment mechanism is described as follows:
[0088] ;
[0089] In the formula, This is the adjusted hash time lock timeout, in seconds. For reference, the adjusted timeout period is set to 130 seconds. The reference hash time lock timeout period is set to 100 seconds. The unit for predicting transaction time is seconds; The reference prediction time is set to 100 seconds; The preset threshold is 300 seconds. The reference threshold is set at 300 seconds. The high threshold is set to 600 seconds. The reference high threshold is set to 600 seconds.
[0090] The objective function of the upper-level model adopts a polynomial combination form, achieving a comprehensive evaluation of the overall system efficiency through a weighted combination of logarithmic, exponential, and linear terms. The logarithmic term is expressed as... This reflects the non-linear impact of transaction time on system efficiency; as transaction time increases, the rate of decline in system efficiency gradually slows down. The exponential term is expressed as... This reflects the exponential decay of efficiency due to path length. The linear term is expressed as... This reflects the direct impact of network congestion. The function design considers the multi-dimensional performance requirements of cross-chain transactions, achieving a better balance between transaction time, path cost, and network resource utilization compared to single-metric optimization methods.
[0091] The objective function of the lower-level model uses a combination of radical terms, square terms, and trigonometric function terms. The radical terms are expressed as follows: This reflects the positive promoting effect of node processing capacity on utility, with diminishing marginal utility. The squared term is expressed as... This reflects the nonlinear negative impact of load factor on node utility; utility drops sharply when the load factor approaches saturation. The trigonometric function term is expressed as... This function reflects the cyclical impact of returns on node utility. Its design fully considers the multiple factors nodes take into account when participating in cross-chain transactions, and compared to a simple linear utility function, it can more accurately characterize the actual behavioral strategies of nodes.
[0092] The two-layer game theory model achieves a unified approach to upper-level system optimization and lower-level node optimization through Nash equilibrium solution. The optimization results of the upper-level model provide decision constraints for the lower-level model, while the equilibrium solution of the lower-level model provides the execution basis for the upper-level model. The introduction of coupling terms enables the two-layer model to form a dynamically interconnected system, avoiding the global suboptimal problem that may result from independent decisions at each layer in traditional hierarchical optimization. Compared with single-layer optimization models, it can find a more stable optimal solution in complex multi-agent environments.
[0093] The adaptive delay prediction algorithm employs an exponentially weighted moving average method, using time-series modeling of historical delay data to predict future network states. The weight decay factor assigns higher weights to recent data, enabling rapid response to changes in network state. Compared to fixed delay estimation methods, this algorithm adjusts prediction results based on dynamic network changes, improving the accuracy and real-time performance of delay prediction and providing a reliable data foundation for dynamic timeout control.
[0094] It should be noted that the variables involved in this invention are explained in detail in Tables 2 and 3 below.
[0095] Table 2. Variable Explanation Table (Part 1)
[0096]
[0097] Table 3. Variable Explanation Table (Part Two)
[0098]
[0099] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. An optimization method for digital currency cross-chain atomic swap, characterized in that, The application relates to a cross-chain asset exchange method and system. The application comprises the following steps: collecting historical transaction data of multiple digital currency blockchain systems and extracting an original feature set; performing feature engineering processing on the original feature set to form an enhanced feature set; using a CatBoost algorithm to train models of the digital currency blockchain systems, establishing a prediction model of each digital currency blockchain system, and constructing a network propagation time delay prediction equation based on a transaction propagation diffusion mechanism, combining historical delay data to establish an adaptive delay prediction algorithm; establishing a hierarchical deterministic wallet system, using a secure multi-party computation protocol to realize distributed generation and management of keys, reducing single-point failure risk through a threshold signature mechanism, and using a hardware security module to provide physical security protection for key storage, thereby forming a key management architecture in a multi-chain environment; The application comprises the following steps: constructing a hierarchical routing architecture, distributing cross-chain exchange requests to multiple parallel processing channels, using a load balancing algorithm to optimize resource utilization, combining batch processing technology and a pipeline processing mode to establish a multi-path concurrent processing mechanism; based on a multi-node path selection game model, making path optimization decisions, obtaining a Nash equilibrium solution through double-layer game solving, inputting cross-chain transaction features into the prediction model to predict transaction time and transfer transaction time, calculating the time required by each digital currency blockchain system, and selecting the transaction path with the shortest predicted time as the optimal transaction path; according to the optimal transaction path, sending cross-chain transactions, setting the hash time lock timeout time based on the predicted transaction time and the user predicted operation time, dynamically adjusting the timeout parameter when the predicted transaction time exceeds the preset threshold, switching to a redundant path when the network delay is abnormal, and sending transactions in sequence according to the hash time lock process to complete the cross-chain asset exchange atomic exchange process. The network propagation time delay prediction equation is expressed as follows: The original feature set specifically comprises transaction timestamps, transaction amounts, transaction directions, transaction costs, transaction types, smart contract addresses, smart contract methods, transaction pool transaction numbers, transaction numbers of 100 previous blocks, sequence numbers of 100 previous block validators, sequence numbers of 100 previous block blockers, transaction initiator user addresses, payee user addresses, transaction initiator user IP addresses, and region information. ; wherein is the concentration of transaction information at a node, is the reference concentration, is the time, is the reference time, is the diffusion coefficient, is the reference diffusion coefficient, is the propagation speed, is the reference length, is the transaction source term, is the reference source term, is the reference volume, is the Laplacian operator, is the gradient operator.
2. The method of claim 1, wherein, The feature engineering processing steps specifically comprise converting transaction times into 3-hour time period labels and weekday / weekend labels, dividing transaction amounts into large, medium, small and super large labels, calculating the average block time and block time trend slope of the last 100 blocks, and calculating the transaction success rate of an account address and the number of transactions in the past 24 hours.
3. The method of claim 2, wherein, The batch processing technology and the pipeline processing mode specifically comprise the following: the batch processing technology is a technology way of packaging multiple processing requests into batches for unified processing; and the pipeline processing mode is a processing mode of decomposing tasks into multiple stages for parallel execution.
4. The method of claim 3, wherein, The step of training the CatBoost algorithm model, specifically dividing the data set into 70% training set, 15% validation set and 15% test set, manually adjusting or using a parameter adjustment tool to adjust the hyperparameters, and evaluating the model through RMSE, MAE and The model evaluation is carried out according to the proportion of transaction time error within 10 seconds and the high delay transaction recognition rate, and the business evaluation is carried out.
5. The method of claim 4, wherein, The transaction propagation diffusion mechanism specifically comprises a physical process of transaction propagation in a blockchain network based on the Fick diffusion law, and is used for predicting the propagation time delay of transaction information between blockchain network nodes.
6. The method of claim 5, wherein, 7. The method of claim 6, wherein, The game model aims at maximizing the overall exchange efficiency of the system as a whole, and the lower model aims at optimizing the resource utilization of a single node.
8. The method of claim 7, wherein, The adaptive delay prediction algorithm is specifically used for statistically modeling historical network delay data, predicting the transmission delay under the current network state in real time, and dynamically adjusting the exchange timeout parameter.
9. The method of claim 8, wherein, The hierarchical deterministic wallet is specifically a wallet architecture based on the BIP32 standard, which derives a sub-key from a master key to realize hierarchical management of the key.
10. The method of claim 9, wherein, The secure multi-party computation protocol is specifically a cryptographic protocol in which multiple participants jointly compute the function result without revealing their private information.
Citation Information
Patent Citations
Block chain performance optimization method and device
CN117950748A
Block chain multi-node secure communication method of industrial internet
CN119520119A
Electronic seal management and control method and system
CN120528598A