Automatic transaction method and device, equipment and storage medium

Through ant colony optimization algorithm and block sharding technology, transaction routing and processing methods are dynamically adjusted, which solves the problems of transaction volume changes and load imbalance in the blockchain system, improves system performance and scalability, and improves transaction throughput quantity and confirm efficiency.

CN119295214APending Publication Date: 2025-01-10SHENZHEN DINGDAN NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411357575.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

There are problems of dynamic changes in transaction volume and unbalanced block load in the blockchain automated trading system, resulting in bottlenecks in processing capacity, delay in transaction confirmation and consensus efficiency. Traditional static routing methods are difficult to adapt to complex and changeable transaction scenarios, resulting in resource utilization. Low rate.

Method used

The ant colony optimization algorithm is used to dynamically adjust the transaction routing strategy. According to the real-time load of the block, the block is dynamically divided into sub-blocks through block sharding technology for parallel processing, realizing balanced allocation and load balancing of transaction requests.

Benefits of technology

It significantly improves the overall performance and scalability of the blockchain network, avoids performance bottlenecks, improves transaction throughput and confirmation efficiency, intelligently senses load changes, and adaptively adjusts transaction routing strategies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119295214A_ABST
    Figure CN119295214A_ABST
Patent Text Reader

Abstract

The invention provides an automatic transaction method and device, equipment and a storage medium, and the method comprises the steps: carrying out the normalization processing of the routing weight of each block when a new transaction request arrives, obtaining the probability distribution of the transaction request to each block, taking the probability distribution as initial information, and carrying out the normalization processing of the routing weight of each block, an ant colony optimization algorithm is adopted to simulate searching of an optimal path between blocks, and a transaction routing strategy is dynamically adjusted, so that transaction requests are distributed in a balanced manner; whether the load of each block reaches a preset performance threshold is judged, the performance threshold is determined based on transaction processing delay and throughput, if the performance threshold is reached, the block is dynamically divided into a plurality of sub-blocks through a block fragmentation technology, the sub-blocks process transactions in parallel, and the load pressure of a single block is relieved. According to the automatic transaction method, the load change of the block chain network can be intelligently sensed, the transaction routing strategy is adaptively adjusted, and the overall performance and expandability of the system are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information technology, and in particular to an automated trading method, device, equipment and storage medium. Background Art

[0002] In the blockchain automated trading system, there are problems with dynamic changes in transaction volume and unbalanced block load. When the transaction volume of a block surges, the processing capacity of the block may reach a bottleneck, causing a series of chain reactions such as delayed transaction confirmation and decreased consensus efficiency. At the same time, the computing resources of other blocks may be relatively idle, resulting in low resource utilization of the entire blockchain network.

[0003] How to dynamically adjust the transaction routing strategy based on the real-time transaction volume distribution and block load, and evenly distribute transaction requests to each block for processing, is a technical problem that needs to be solved urgently. Traditional static routing methods are difficult to adapt to complex and changing transaction scenarios, and are prone to cause load imbalance between blocks and performance bottlenecks. Although a simple polling strategy can achieve load balancing, it does not take into account the actual processing capacity of the block, which may cause transaction backlogs in blocks with weaker computing power.

[0004] Therefore, designing a dynamic transaction routing mechanism based on the real-time load of the block has become a technical challenge that the blockchain automated trading system needs to overcome urgently. This routing mechanism needs to comprehensively consider factors such as the transaction volume, transaction complexity, and block speed of the block, and conduct a real-time evaluation of the load level of the block. At the same time, it must be able to intelligently adjust the routing strategy based on the evaluation results, and dynamically guide new transaction requests to the blocks with lighter loads for execution. Such a dynamic routing method can realize dynamic diversion and balanced processing of transactions between blocks according to changes in block load, thereby giving full play to the computing power of each block, avoiding performance bottlenecks, and thus improving the throughput and confirmation efficiency of the entire blockchain transaction system. Summary of the invention

[0005] The present invention provides an automated transaction method, device, equipment and storage medium to solve the problem of performance bottleneck caused by load imbalance between blocks, which leads to transaction backlogs in blocks with weaker computing power. It achieves the effect of intelligently sensing changes in blockchain network load and significantly improving the overall performance and scalability of the system.

[0006] In a first aspect, the present invention provides an automated trading method, which mainly includes:

[0007] When a new transaction request arrives, the routing weights of each block are normalized to obtain the probability distribution of the transaction request being assigned to each block. The probability distribution is used as the initial information, and the ant colony optimization algorithm is used to simulate the search for the optimal path between blocks, and the transaction routing strategy is dynamically adjusted to balance the distribution of transaction requests.

[0008] Determine whether the load of each block reaches a preset performance threshold, which is determined based on transaction processing delay and throughput. If the performance threshold is reached, the block is dynamically divided into multiple sub-blocks through block sharding technology. The sub-blocks process transactions in parallel to alleviate the load pressure of a single block.

[0009] In a second aspect, the present invention provides an automated trading device, comprising:

[0010] The adjustment unit is used to normalize the routing weights of each block when a new transaction request arrives, obtain the probability distribution of the transaction request being allocated to each block, use the probability distribution as initial information, use the ant colony optimization algorithm to simulate the search for the optimal path between blocks, and dynamically adjust the transaction routing strategy to balance the distribution of transaction requests;

[0011] The segmentation unit is used to determine whether the load of each block has reached a preset performance threshold. The performance threshold is determined based on transaction processing delay and throughput. If the performance threshold is reached, the block is dynamically divided into multiple sub-blocks through block sharding technology. The sub-blocks process transactions in parallel to alleviate the load pressure of a single block.

[0012] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0013] Memory, used to store computer programs;

[0014] The processor is used to implement the steps of the automated trading method described in any embodiment of the first aspect when executing the program stored in the memory.

[0015] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the automated trading method as described in any embodiment of the first aspect are implemented.

[0016] The technical solution provided by the embodiment of the present invention may have the following beneficial effects:

[0017] The present invention discloses an automated trading method. When a new transaction request arrives, the present invention uses an ant colony optimization algorithm to dynamically adjust the routing strategy to achieve balanced distribution of transaction requests. In addition, the present invention can also monitor load mutations in real time, and take targeted strategy adjustments according to the abnormal causes, such as increasing the routing weight of the corresponding block or temporarily increasing the number of blocks. When the block load reaches the performance threshold, the present invention dynamically divides the block into multiple parallel-processed sub-blocks through block sharding technology, effectively alleviating the load pressure of a single block. The method can intelligently perceive changes in blockchain network load, adaptively adjust transaction routing strategies, and significantly improve the overall performance and scalability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A flowchart of an automated trading method of the present invention;

[0019] Figure 2 A sub-flow chart of an automated trading method of the present invention;

[0020] Figure 3 is another sub-flow chart of an automated trading method of the present invention;

[0021] Figure 4 A schematic diagram of the structure of an automated trading device provided by an embodiment of the present invention;

[0022] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The technical scheme of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0024] like Figure 1 -3. An automated trading method in this embodiment may specifically include:

[0025] Step S101, when a new transaction request arrives, the routing weights of each block are normalized to obtain the probability distribution of the transaction request being assigned to each block. The probability distribution is used as initial information, and the ant colony optimization algorithm is used to simulate the search for the optimal path between blocks, and the transaction routing strategy is dynamically adjusted to balance the distribution of transaction requests.

[0026] Get the newly arrived transaction request and extract the relevant feature information of the transaction request. According to the preset block routing weight calculation rules, the routing weights of each block are normalized to obtain the probability distribution of the transaction request assigned to each block. The above probability distribution is used as the initial information of the ant colony optimization algorithm to construct the ant colony optimization model. It should be noted that the principle of the ant colony optimization algorithm can be determined by referring to existing materials, and the present invention does not make specific limitations on this. In the model, the blocks are abstracted as nodes of the graph, and the routing relationship between blocks is abstracted as the edge of the graph. The ant colony optimization algorithm is used to search for the optimal path in the above graph model. In the algorithm, the ants select the next block according to the routing probability between blocks, and dynamically adjust the routing strategy through the pheromone update mechanism. Through multiple iterative optimizations, the optimal routing path of the current transaction request is searched and the proportion of the transaction request assigned to each block is determined. According to the above optimal allocation ratio, the transaction request is distributed to the corresponding block for processing to achieve balanced distribution of transaction requests between blocks. After the transaction request is processed, the block routing weight is dynamically adjusted based on the feedback information of block processing efficiency, and the pheromone of the ant colony optimization algorithm is updated to optimize the routing strategy of subsequent transaction requests.

[0027] Specifically, when a new transaction request arrives, the system first extracts the characteristic information of the request, such as the transaction amount, transaction type, transaction time, etc. Then, according to the preset block routing weight calculation rules, the routing weight of each block is normalized. For example, assuming there are 3 blocks, their initial routing weights are 3, 5 and 2 respectively. After normalization, the probability distribution of the transaction request assigned to each block is 3, 5 and 2. Then, the probability distribution is used as the initial information of the ant colony optimization algorithm to construct the ant colony optimization model. In the model, blocks are abstracted as nodes of the graph, and the routing relationship between blocks is abstracted as edges of the graph. The weight of the edge is determined by the routing probability between blocks. The ant colony optimization algorithm searches for the optimal path in the graph model. The ants select the next block according to the routing probability between blocks, and dynamically adjust the routing strategy through the pheromone update mechanism. For example, when an ant passes through an edge, it will leave pheromone on the edge. The higher the pheromone concentration, the greater the probability that the subsequent ant will choose the edge. Through multiple iterations of optimization, the optimal routing path for the current transaction request is finally searched and the proportion of transaction requests allocated to each block is determined, such as 2, 6, and 2. According to the optimal allocation ratio, the system distributes the transaction request to the corresponding block for processing to achieve balanced distribution of transaction requests among blocks. After the transaction request is processed, the system dynamically adjusts the block routing weight according to the feedback information of the block processing efficiency, such as the transaction confirmation time and transaction throughput of the block, and updates the pheromone of the ant colony optimization algorithm to optimize the routing strategy of subsequent transaction requests. For example, if the processing efficiency of a block is improved by 20%, its routing weight can be increased accordingly, and the pheromone concentration connecting the edge of the block can be increased to guide more transaction requests to be allocated to the block. Through this dynamic adjustment and optimization, the system can adapt to changes in block performance, continuously improve the routing strategy of transaction requests, and improve the processing efficiency and throughput of the entire blockchain network.

[0028] In one embodiment, before step S101, steps S201-S203 are also included:

[0029] Step S201, obtain the load indicator data such as the real-time transaction volume and block speed of the block, calculate the comprehensive load score of the block through the weighted average algorithm, and generate a block load distribution map.

[0030] Obtain the real-time load data of each node in the blockchain network, including indicators such as transaction volume and block speed, and transmit the data to the central server. Preprocess the obtained load indicator data, remove outliers, normalize the data, and convert indicators of different dimensions into unified dimensionless values. According to the importance of each load indicator, determine the corresponding weight coefficient, build a weighted average model, and calculate the comprehensive load score. Use the K-means clustering algorithm to cluster the comprehensive load scores of each block and divide them into different load levels such as high load, medium load, and low load. Through correlation analysis, judge the correlation between each load indicator and the comprehensive load score, and select the key indicators that contribute most to the comprehensive load. Based on the data of key load indicators, train the support vector machine regression model, obtain the prediction function of the load change trend, and predict the block load in the future. Visualize the block load clustering results and the prediction results to generate a block load distribution diagram, which intuitively reflects the overall load of the blockchain network and provides a decision-making basis for load balancing and performance optimization.

[0031] Specifically, in order to obtain the real-time load data of each node in the blockchain network, the monitoring agent can be deployed to regularly collect indicators such as the transaction volume and block speed of the node, and transmit the data to the central server through a secure channel. The collected data is cleaned, and the outliers beyond the normal range are identified and eliminated using methods such as box plots. The maximum and minimum normalization method is then used to map the data of different indicators to the [0, 1] interval to eliminate the impact of dimensional differences. According to expert experience and historical data analysis, the weight of the transaction volume is determined to be 4, the weight of the block speed is 3, and the weights of other indicators are all 1. A weighted average model is constructed to generate the comprehensive load score of each block. The comprehensive load score is clustered using the K-means algorithm, the number of clusters k is set to 3, and the cluster center is iteratively optimized until the clustering result is stable, and the blocks are divided into three load levels: high, medium, and low. By calculating the Pearson correlation coefficient, it is found that the correlation coefficient between the transaction volume and the comprehensive load score reaches 8, which is the most critical load indicator. The transaction volume is selected as the characteristic variable, the comprehensive load score is selected as the target variable, the support vector machine regression model is constructed, and the model hyperparameters are optimized by grid search. The mean absolute percentage error (MAPE) on the test set is controlled within 5%, and the load change trend in the next 7 days is predicted. Finally, visualization tools such as Echarts are used to generate block load distribution heat maps and future load change curves, providing intuitive decision support for operation and maintenance personnel, timely adjusting the operation strategy of the blockchain network, and ensuring the efficient and stable operation of the system.

[0032] Step S202: According to the block load distribution diagram, a clustering algorithm is used to divide the block into three load levels: high, medium, and low, and the routing weight of the block is set according to the load level corresponding to the block.

[0033] Obtain the real-time load data of each block in the blockchain network, build a block load distribution map, and reflect the load of the entire network. According to the block load distribution map, the K-means clustering algorithm is used to divide all blocks into three load levels: high-load blocks, medium-load blocks, and low-load blocks. Differentiated transaction routing weights are set for blocks of different load levels. If the block is a high-load block, its transaction routing weight is reduced; if the block is a medium-load block, its default transaction routing weight is maintained; if the block is a low-load block, its transaction routing weight is increased. When routing transactions between blockchain network nodes, the block load level and transaction routing weight are comprehensively considered, and transaction requests are preferentially routed to blocks with lower load and higher weight for processing. Continuously monitor the real-time load changes of the blockchain network, dynamically adjust the transaction routing weight of each block, and ensure dynamic optimization of load balancing and transaction processing efficiency. Through differentiated transaction routing weight settings and dynamic adjustment strategies, the reasonable distribution of transaction requests between high, medium, and low load blocks in the blockchain network is achieved to avoid overheating blocks from becoming performance bottlenecks. Continuously optimize clustering algorithms and transaction routing strategies, improve the accuracy of block load division and the intelligence of routing decisions, and provide continuous support for the efficient operation of blockchain networks.

[0034] Specifically, in order to obtain the real-time load data of each block in the blockchain network, it can be achieved by deploying a load monitoring agent. The monitoring agent collects key indicators such as CPU occupancy, memory usage, network throughput, etc. of each block every 5 seconds, and reports the collected data as load data to the centralized load data storage. The load data storage uses the time series database InfluxDB for storage, which can efficiently handle the writing and query of a large amount of time series data. Based on the load data stored in InfluxDB, a block load distribution diagram is constructed using visualization tools such as Grafana to intuitively display the load of the entire blockchain network. The block load distribution diagram is automatically refreshed every 10 seconds to ensure the real-time nature of the load data. After obtaining the block load distribution diagram, the K-means clustering algorithm is used to divide the load levels of all blocks. The K-means algorithm distributes data points to the nearest cluster center through iterative optimization to form three load levels of high, medium, and low. In the clustering process, the Euclidean distance is selected as the similarity metric, and the silhouette coefficient is used to evaluate the pros and cons of the clustering results. According to the clustering results, differentiated transaction routing weights are set for blocks with different load levels. The routing weight of high-load blocks is set to 6, the routing weight of medium-load blocks is set to 0, and the routing weight of low-load blocks is set to 4. When performing transaction routing, the block load level and transaction routing weight are comprehensively considered, and the target block is selected through a weighted random algorithm. The weighted random algorithm uses routing weight as the probability distribution. The higher the weight, the greater the probability of the block being selected, so that the transaction request is preferentially routed to the block with lower load and higher weight for processing. In order to adapt to the dynamic changes in the blockchain network load, K-means clustering is re-executed every 30 seconds, and the transaction routing weight of each block is adjusted accordingly. At the same time, an adaptive weight adjustment mechanism is introduced to dynamically fine-tune the routing weight according to the historical load change trend of the block to improve the accuracy of load balancing. In the future, more advanced clustering algorithms, such as density clustering and hierarchical clustering, can also be explored to further improve the accuracy of block load division. At the same time, combined with intelligent optimization technologies such as reinforcement learning, transaction routing strategies are continuously optimized to achieve smarter and more efficient load balancing, providing strong guarantees for the scalability and high performance of the blockchain network.

[0035] Step S203, obtaining block transaction processing historical data, predicting the future transaction volume change range, duration and frequency through a neural network to determine the prediction result, and the transaction routing decision includes the prediction result.

[0036] Obtain the historical transaction data of each node in the blockchain network, including indicators such as transaction volume and transaction frequency, and construct a time series data set. Preprocess the historical transaction data, remove outliers and noise data, normalize the data, and convert the data into the input format of the neural network model. Determine the time span and granularity of the prediction according to business needs, select a suitable neural network model, such as the long short-term memory network (LSTM) or the gated recurrent unit network (GRU), and build a prediction model. Divide the preprocessed historical transaction data into a training set and a test set, use the training set data to train the neural network model, and use the test set data to evaluate the model, continuously adjust the model hyperparameters, and optimize the model performance. Apply the trained neural network model to the latest blockchain transaction data to predict the trend of transaction volume changes in the future, including indicators such as the magnitude of change, duration, and frequency. According to the prediction results, analyze the transaction volume and load of each blockchain node in the future, identify possible transaction peaks and bottlenecks, and provide a decision-making basis for routing strategy optimization. Dynamically adjust the routing strategy of the blockchain network, allocate transaction requests to nodes with lower predicted loads, balance network loads, improve transaction processing efficiency, and ensure the stable operation of the blockchain network.

[0037] Specifically, in order to obtain the historical transaction data of each node in the blockchain network, you can obtain it through the blockchain browser or the node's API interface. For example, the Bitcoin blockchain can obtain the transaction data of each block through the API provided by blockchain.info, and summarize indicators such as transaction volume and transaction frequency at a granularity of every 10 minutes to construct a time series data set. Use methods such as moving average and exponential smoothing to smooth and denoise the data, and use maximum and minimum value normalization to scale the data to a range of 0 to 1. Consider predicting the change in transaction volume in the next hour, and build an LSTM network model with 6 time steps at a granularity of 10 minutes. Divide the data of the past week into training sets and test sets, adjust the model's hyperparameters such as the number of hidden layers, the number of hidden units, and the learning rate, evaluate the model's mean square error and mean absolute percentage error on the test set, and optimize the model to a mean absolute percentage error of less than 5%. Apply the trained model to predict the trend of transaction volume changes in the next hour, for example, predict that Bitcoin transaction volume will rise by 10% in the next hour, and then fall back after 30 minutes. Based on this, the load changes of major transaction nodes are analyzed. When the transaction volume load of a node is predicted to exceed 80% of its processing capacity, the dynamic routing strategy is triggered to forward new transaction requests to other nodes with lower loads, thereby balancing the network load, improving transaction processing efficiency, and ensuring the stable operation of the blockchain network.

[0038] In one embodiment, the dynamically adjusting transaction routing strategy in step S101 includes steps S301-S302:

[0039] Step S301, monitor the load changes of each block in real time. When it is detected that the sudden change amplitude of the block load level exceeds the preset threshold and the duration of the sudden change exceeds the preset duration, it is determined that the load level is in an abnormal state, and the step of dynamically adjusting the transaction routing strategy is executed.

[0040] Obtain the real-time load level data of each block, compare the current load level with the historical load level for each block, and calculate the load level change amplitude; if the load level change amplitude exceeds the preset mutation amplitude threshold, start the mutation duration timer; continuously monitor the load level of the block, if the load level change amplitude always exceeds the mutation amplitude threshold within the preset mutation duration, then determine that the load level of the block is in an abnormal state; according to the load level mutation situation, determine the list of blocks that need to adjust the routing strategy; use a clustering algorithm to group the blocks that need to be adjusted, and divide the blocks with similar load level mutation amplitudes into the same group; for each group of blocks, learn and optimize the routing strategy adjustment plan through a reinforcement learning algorithm to obtain the optimal routing strategy parameters; send the optimized routing strategy parameters to the corresponding blocks, dynamically adjust the routing strategy, and achieve load level balance.

[0041] Specifically, first, the real-time load level data of each block is collected through the network equipment, and the data is collected every 5 minutes. For each block, the current collected load level is compared with the historical load level, and the load level change amplitude is calculated using the relative change rate formula. If the calculated load level change amplitude exceeds the preset 20% mutation amplitude threshold, it is detected that the block load level mutation amplitude exceeds the preset threshold, and the mutation duration timer is started. The subsequent load level collected by the block is continuously monitored. If the load level change amplitude always exceeds the 20% mutation amplitude threshold within the preset 30-minute mutation duration, it is determined that the block has a load level mutation. According to the load level mutation of each block, the block that has mutated is added to the list of blocks that need to adjust the routing strategy. It should be noted that the preset duration can be freely set by the personnel in this field. The smaller the preset duration, the higher the detection frequency, and the larger the preset duration, the lower the detection frequency. The K-means clustering algorithm is used to group the blocks that need to be adjusted, and the load level mutation amplitude is used as the feature vector. By calculating the Euclidean distance between the mutation amplitudes of each block, the blocks with similar distances are divided into the same group. For each group of blocks, the deep reinforcement learning algorithm is used to learn and optimize the routing strategy adjustment plan with load balancing as the optimization goal. Through continuous trial and error and strategy iteration, the optimal combination of routing strategy parameters, such as routing weight and traffic distribution ratio, is found. The optimized routing strategy parameters are sent to the routing devices in the corresponding blocks through the network, and the routing strategy is dynamically adjusted to share the traffic of the mutation block to other blocks with lower loads, so as to achieve load balancing of the entire network.

[0042] Step S302, when the routing strategy adjustment is triggered, the cause of the abnormality is determined based on the number of blocks with sudden changes in load levels, location distribution, and correlation with the arrival time of transaction requests, and targeted strategy adjustments are taken, such as increasing the routing weight of the corresponding block, or temporarily increasing the number of blocks.

[0043] Monitor the system load level and obtain information about blocks with sudden load changes, including the number and location of blocks. Obtain the arrival time of transaction requests and analyze the time correlation between transaction requests and blocks with sudden load changes.

[0044] According to the block mutation and transaction request correlation, the cause of the load abnormality is determined, such as transaction request concentration, block failure, etc. If the abnormal cause is load imbalance caused by transaction request concentration, the routing strategy is dynamically adjusted to increase the routing weight of the corresponding block. By increasing the routing weight, more transaction requests are directed to blocks with lower loads to achieve load balancing. If the abnormal cause is excessive load caused by block failure, the number of blocks is temporarily increased to share the load of the faulty block. According to the changes in the load level, the number of blocks and routing weight are dynamically adjusted to ensure the stability of system performance and transaction processing efficiency.

[0045] Specifically, the system collects load data every second, and when it detects that the load level of a block exceeds a threshold (such as 80%), it triggers a load mutation alarm. The system records the number and location coordinates of the mutation block, such as block A (number 123, position 1, 3), block B (number 456, position 2, 5), etc. The arrival time of the transaction request is obtained through the request log, and the transaction hash value and timestamp are extracted, such as transaction X (hash value 0x1234, timestamp 2023-06-0112:00:01). The time of the transaction request is associated with the time of the load mutation, and the least squares method is used to fit the change curve of the transaction request volume and load level over time. The correlation of the two time series is calculated by the Pearson correlation coefficient. If the correlation coefficient is greater than 8, the transaction request is considered to be the main cause of the load mutation. If the concentration of transaction requests leads to uneven load, the system will modify the configuration file of the load balancer to increase the routing weight of the mutation block by 20%, reduce the weight of the adjacent block by 10%, and guide new transaction requests to be allocated to the block with lower load first. If a block failure causes excessive load, the system calls the API interface of the block management service, passes in the number and location of the failed block, and requests to add a new block. After the new block is started, it automatically synchronizes the status of the failed block and takes over 50% of its transaction requests. The system evaluates the change in load level every 5 minutes. When the load of the mutant block returns to below the threshold and remains stable for 10 minutes, the adjustment of the routing weight and the number of blocks is triggered. The weight is modified to the default value through the API interface of the load balancer; the newly added block is released through the API interface of the block management service. The entire process is controlled through closed-loop feedback to achieve automatic expansion and contraction of the blockchain network and load balancing adjustment, ensuring the performance and stability of the system.

[0046] In one embodiment, the targeted strategy adjustment in step S302 includes the steps of: determining the block load change rate and block distribution characteristics according to the predicted future transaction volume changes, and adjusting the block routing weight.

[0047] By analyzing historical transaction data, a transaction volume prediction model is established to predict the transaction volume change trend of each block in the future. According to the transaction volume prediction results and combined with the current load of the block, the load change rate of each block is calculated. The multi-dimensional features of the block are extracted, including block size, number of transactions, account distribution, etc., to construct the block feature vector. The clustering algorithm is used to cluster the blocks, and the blocks with similar load change rates and similar feature vectors are divided into the same category. Differentiated routing weight adjustment strategies are designed for blocks of different categories. For blocks with high load change rates and heavy loads, their routing weights are reduced; for blocks with low load change rates and light loads, their routing weights are increased. In the process of block routing, the real-time load of the block is dynamically obtained, and the dynamic adjustment of the routing weight is triggered in real time according to the load change and the preset adjustment threshold. The adjustment results of the block routing weight are evaluated, and the effectiveness of the weight adjustment strategy is verified by comparing the block load distribution before and after the adjustment, and the adjustment strategy is optimized and iterated according to the evaluation results.

[0048] Specifically, by analyzing historical transaction data, using time series prediction models such as ARIMA or LSTM neural networks, the transaction volume change trend of each block in the next week is predicted. For example, the prediction results show that the transaction volume of block A will increase by 20%, and the transaction volume of block B will decrease by 10%. Combined with the current load of the block, the load change rate of block A is calculated to be +15%, and the load change rate of block B is -5%. The multi-dimensional features of the block are extracted, including block size, number of transactions, account distribution, etc. The principal component analysis method is used to reduce the dimension of the high-dimensional features and construct the block feature vector. The K-means clustering algorithm is used to cluster the blocks. The optimal number of clusters is determined to be 3 through the elbow method, and the blocks with similar load change rates and similar feature vectors are divided into the same category. Differentiated routing weight adjustment strategies are designed for blocks of different categories. For blocks with higher load change rates and heavier loads, such as category 1, their routing weights are reduced by 20%; for blocks with lower load change rates and lighter loads, such as category 3, their routing weights are increased by 10%. During the block routing process, the real-time load of the block is dynamically obtained every 5 minutes. When the load change exceeds the preset ±10% threshold, the dynamic adjustment of the routing weight is triggered. The adjustment results of the block routing weight are evaluated. By calculating the standard deviation of the block load before and after the adjustment, it is found that the standard deviation after adjustment is reduced by 30%, indicating that the weight adjustment strategy effectively balances the block load distribution. The threshold setting can be further optimized in the future to achieve better load balancing effect.

[0049] In one embodiment, the dynamically adjusting transaction routing strategy in step S101 further includes the following steps: when executing the step of dynamically adjusting the transaction routing strategy, if the predicted future transaction volume changes are highly matched with the current mutation situation, and the predicted change trend reaches the load threshold of the block, then determining the adjustment range of the routing weight according to the prediction result.

[0050] Obtain the current transaction volume mutation situation and the predicted future transaction volume change trend data. Calculate the matching degree between the current mutation situation and the predicted change trend through the similarity algorithm. If the matching degree exceeds the preset threshold, execute the next step; otherwise, maintain the current routing weight unchanged. According to the predicted transaction volume change trend, use the time series analysis method to estimate the block load change in the future period. If the estimated block load change exceeds the preset threshold, it is determined that additional adjustment of the routing weight is required; otherwise, maintain the current adjustment plan unchanged. According to the estimated block load change range and the current routing weight adjustment range, the final routing weight additional adjustment range is determined through the weighted average algorithm. The calculated additional adjustment range is superimposed with the current routing weight adjustment range to obtain the final routing weight adjustment range. According to the final determined adjustment range, update the routing weight configuration, and monitor the adjusted block load in real time to ensure that the load is maintained at a reasonable level.

[0051] Specifically, the current transaction volume mutation and the forecast data of transaction volume change trend in the next week are obtained through the big data analysis platform. The cosine similarity algorithm is used to calculate the similarity between the current transaction volume mutation vector and the predicted transaction volume change vector. If the similarity exceeds the threshold of 8, the next step is executed; otherwise, the current routing weight configuration is maintained unchanged. According to the predicted transaction volume change trend data in the next week, the ARIMA time series model is used to estimate the block load changes in the next 3 days. If the estimated block load change exceeds the threshold of 20%, the additional adjustment mechanism of the routing weight is triggered; otherwise, the current routing weight adjustment scheme is maintained unchanged. Combined with the estimated block load change range and the current routing weight adjustment range, the final routing weight additional adjustment range is determined by the weighted average algorithm, where the weight of the estimated load change range is 6 and the weight of the current adjustment range is 4. The calculated additional adjustment range is superimposed with the current routing weight adjustment range to obtain the final routing weight adjustment range. For example, if the estimated block load change is 30% and the current routing weight adjustment is 10%, the final additional adjustment is 6×30%+4×10%=22%, and the final adjustment after superposition is 10%+22%=32%. According to the final adjustment of 32%, update the routing weight configuration, and collect block load data in real time through the monitoring system, compare the load changes before and after the adjustment, and ensure that the adjusted block load is maintained at a reasonable level. If the load still exceeds the threshold after adjustment, repeat the above process for re-tuning until the load returns to normal.

[0052] Step S102, determine whether the load of each block reaches a preset performance threshold, which is determined based on transaction processing delay and throughput. If the performance threshold is reached, the block is dynamically divided into multiple sub-blocks through block sharding technology. The sub-blocks process transactions in parallel to alleviate the load pressure of a single block.

[0053] In one embodiment, step S102 includes the steps of: determining the number of shards according to the block load; dynamically dividing the block using a hash algorithm to generate multiple sub-blocks, each sub-block containing part of the transaction; and for each sub-block, using a parallel processing mechanism to simultaneously verify and execute transactions on multiple nodes.

[0054] In one embodiment, the sub-block parallel processing transaction in step S102 includes the following steps: in the process of parallel processing of sub-blocks, dynamically adjusting the computing resource allocation of each sub-block through a load balancing algorithm; after the sub-block processing is completed, summarizing and verifying the processing results, generating a new block, and updating the consensus status in the blockchain network; according to the effects of block sharding and parallel processing, dynamically adjusting the performance threshold and sharding rules to adapt to the load changes of the blockchain network.

[0055] Monitor the transaction processing delay and throughput indicators of each block in real time, compare the monitoring data with the preset performance threshold, and determine whether the threshold condition is met. If the transaction processing delay and throughput of a block reach the preset threshold, the block sharding mechanism is triggered, and the number and size of the split blocks are determined according to the load of the block and the preset sharding rules. The block is dynamically divided into multiple sub-blocks through the block sharding algorithm, and each sub-block contains part of the transaction data to ensure that the data volume and computational complexity of the sub-blocks are relatively balanced. The divided sub-blocks are processed in parallel, and multi-threading or distributed computing and other technologies are used to improve the concurrency and efficiency of transaction processing and alleviate the load pressure of a single block. In the process of parallel processing of sub-blocks, the computing resource allocation of each sub-block is dynamically adjusted through the load balancing algorithm to ensure that the processing progress of each sub-block is relatively consistent and avoid processing bottlenecks. It should be noted that the principle of the load balancing algorithm can be determined by referring to existing materials, and the present invention does not make specific limitations on this. After the sub-block processing is completed, the processing results are summarized and verified, a new block is generated, and the consensus status in the blockchain network is updated to ensure data consistency and integrity. According to the effects of block sharding and parallel processing, the performance threshold and sharding rules are dynamically adjusted to adapt to the load changes of the blockchain network, and adaptive performance optimization and load balancing are achieved.

[0056] Specifically, the blockchain network monitors the transaction processing delay and throughput indicators of each block in real time. When the transaction processing delay of a block exceeds 500 milliseconds or the throughput is less than 1000TPS, the block sharding mechanism is triggered. The block is dynamically divided into 4 sub-blocks using a hash algorithm, and each sub-block contains 25% of the transaction data. It should be noted that the principle of the hash algorithm can be determined by referring to existing materials, and the present invention does not make specific limitations on this. Multi-threaded parallel processing is used for sub-blocks, and 2 CPU cores are allocated to each sub-block. The resource allocation is dynamically adjusted through the polling algorithm to ensure consistent processing progress. After the sub-block processing is completed, the results are summarized and verified through the Merkle tree algorithm, a new block is generated, and the consensus status is updated. According to the real-time performance indicators, the system dynamically adjusts the threshold to 300 milliseconds of delay and 1500TPS of throughput, and the number of shards is adjusted to 8, continuously optimizing performance and load balancing.

[0057] See also Figure 4 The embodiment of the present invention further provides an automated trading device 400 , which includes an adjustment unit 401 and a segmentation unit 402 .

[0058] The adjustment unit 401 is used to normalize the routing weights of each block when a new transaction request arrives, obtain the probability distribution of the transaction request being allocated to each block, use the probability distribution as initial information, adopt the ant colony optimization algorithm to simulate the search for the optimal path between blocks, and dynamically adjust the transaction routing strategy to balance the distribution of transaction requests.

[0059] In one embodiment, when a new transaction request arrives, the step of normalizing the routing weights of each block to obtain the probability distribution of the transaction request being assigned to each block, using the probability distribution as initial information, using the ant colony optimization algorithm to simulate finding the optimal path between blocks, and dynamically adjusting the transaction routing strategy to balance the transaction request distribution, further includes:

[0060] Obtain load indicator data such as real-time transaction volume and block speed of the block, calculate the comprehensive load score of the block through the weighted average algorithm, and generate a block load distribution map;

[0061] According to the block load distribution diagram, a clustering algorithm is used to divide the blocks into three load levels: high, medium, and low, and differentiated transaction routing weights are set for blocks of different load levels;

[0062] Obtain historical data on block transaction processing, use neural networks to predict future transaction volume changes, duration, and frequency, and use the prediction results as a reference for routing decisions.

[0063] In one embodiment, the dynamically adjusting the transaction routing strategy includes:

[0064] Monitor the load changes of each block in real time. When it is detected that the magnitude of the sudden change in the block load level exceeds a preset threshold and the duration of the sudden change exceeds a preset duration, it is determined that the load level has suddenly changed, and the step of dynamically adjusting the transaction routing strategy is executed;

[0065] When executing the step of dynamically adjusting the transaction routing strategy, the cause of the abnormality is determined based on the number of blocks with sudden changes in load levels, their location distribution, and their correlation with the arrival time of the transaction request, and targeted strategy adjustments are taken.

[0066] In one embodiment, the dynamically adjusting the transaction routing strategy further includes:

[0067] When executing the step of dynamically adjusting the transaction routing strategy, if the predicted future transaction volume changes are highly matched with the current mutation situation, and the predicted change trend reaches the load threshold of the block, the adjustment range of the routing weight is determined according to the prediction result.

[0068] In one embodiment, the targeted policy adjustment includes:

[0069] Determine the block load change rate and block distribution characteristics based on the predicted future transaction volume changes, and adjust the block routing weight.

[0070] The segmentation unit 402 is used to determine whether the load of each block reaches a preset performance threshold, which is determined based on transaction processing delay and throughput. If the performance threshold is reached, the block is dynamically segmented into multiple sub-blocks through block sharding technology. The sub-blocks process transactions in parallel to alleviate the load pressure of a single block.

[0071] In one embodiment, the determination of whether the load of each block reaches a preset performance threshold, the performance threshold being determined based on transaction processing delay and throughput. If the performance threshold is reached, the block is dynamically divided into multiple sub-blocks through block sharding technology, and the sub-blocks process transactions in parallel to alleviate the load pressure of a single block, including:

[0072] The number of shards is determined according to the block load; a hash algorithm is used to dynamically divide the block to generate multiple sub-blocks, each of which contains part of the transactions; for each sub-block, a parallel processing mechanism is used to simultaneously verify and execute transactions on multiple nodes.

[0073] In one embodiment, the sub-blocks process transactions in parallel, including:

[0074] In the process of parallel processing of sub-blocks, the computing resource allocation of each sub-block is dynamically adjusted through the load balancing algorithm;

[0075] After the sub-block processing is completed, the processing results are summarized and verified, a new block is generated, and the consensus status in the blockchain network is updated;

[0076] According to the effects of block sharding and parallel processing, the performance threshold and sharding rules are dynamically adjusted to adapt to the load changes of the blockchain network.

[0077] like Figure 5 As shown, an embodiment of the present invention provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0078] Memory 113, used for storing computer programs;

[0079] In one embodiment of the present invention, the processor 111 is used to implement the automated trading method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113.

[0080] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the automated trading method provided in any of the aforementioned method embodiments are implemented.

[0081] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. An automated trading method, characterized in that: The method comprises: When a new transaction request arrives, the routing weights of each block are normalized to obtain the probability distribution of the transaction request being assigned to each block. The probability distribution is used as the initial information, and the ant colony optimization algorithm is used to simulate the search for the optimal path between blocks, and the transaction routing strategy is dynamically adjusted to balance the distribution of transaction requests. Determine whether the load of each block reaches a preset performance threshold, which is determined based on transaction processing delay and throughput. If the performance threshold is reached, the block is dynamically divided into multiple sub-blocks through block sharding technology. The sub-blocks process transactions in parallel to alleviate the load pressure of a single block.

2. The method according to claim 1, characterized in that: When a new transaction request arrives, the routing weights of each block are normalized to obtain the probability distribution of the transaction request being assigned to each block. The probability distribution is used as initial information, and the ant colony optimization algorithm is used to simulate the search for the optimal path between blocks, and the transaction routing strategy is dynamically adjusted to balance the transaction request distribution. The process also includes: Obtain load indicator data such as real-time transaction volume and block speed of the block, calculate the comprehensive load score of the block through the weighted average algorithm, and generate a block load distribution map; According to the block load distribution diagram, a clustering algorithm is used to divide the blocks into three load levels: high, medium and low, and the routing weight of the blocks is set according to the load level corresponding to the blocks; Obtain block transaction processing historical data, predict future transaction volume change amplitude, duration and frequency through a neural network to determine a prediction result, and the transaction routing decision includes the prediction result.

3. The method according to claim 1, characterized in that The dynamically adjusting transaction routing strategy includes: Monitor the load changes of each block in real time. When it is detected that the magnitude of the sudden change in the block load level exceeds a preset threshold and the duration of the sudden change exceeds a preset duration, it is determined that the load level is in an abnormal state, and the step of dynamically adjusting the transaction routing strategy is executed; When executing the step of dynamically adjusting the transaction routing strategy, the cause of the abnormality is determined based on the number of blocks with sudden changes in load levels, their location distribution, and their correlation with the arrival time of the transaction request, and targeted strategy adjustments are taken.

4. The method according to claim 3, characterized in that The dynamically adjusting transaction routing strategy also includes: When executing the step of dynamically adjusting the transaction routing strategy, if the predicted future transaction volume changes are highly matched with the current mutation situation, and the predicted change trend reaches the load threshold of the block, the adjustment range of the routing weight is determined according to the prediction result.

5. The method according to claim 3, characterized in that: The targeted strategy adjustments include: Determine the block load change rate and block distribution characteristics based on the predicted future transaction volume changes, and adjust the block routing weight.

6. The method according to claim 1, characterized in that The determination of whether the load of each block reaches a preset performance threshold, the performance threshold is determined based on transaction processing delay and throughput. If the performance threshold is reached, the block is dynamically divided into multiple sub-blocks through block sharding technology. The sub-blocks process transactions in parallel to alleviate the load pressure of a single block, including: The number of shards is determined according to the block load; a hash algorithm is used to dynamically divide the block to generate multiple sub-blocks, each of which contains part of the transactions; for each sub-block, a parallel processing mechanism is used to simultaneously verify and execute transactions on multiple nodes.

7. The method according to claim 1, characterized in that The sub-blocks process transactions in parallel, including: In the process of parallel processing of sub-blocks, the computing resource allocation of each sub-block is dynamically adjusted through the load balancing algorithm; After the sub-block processing is completed, the processing results are summarized and verified, a new block is generated, and the consensus status in the blockchain network is updated; According to the effects of block sharding and parallel processing, the performance threshold and sharding rules are dynamically adjusted to adapt to the load changes of the blockchain network.

8. An automated trading device, characterized in that: include: The adjustment unit is used to normalize the routing weights of each block when a new transaction request arrives, obtain the probability distribution of the transaction request being allocated to each block, use the probability distribution as initial information, use the ant colony optimization algorithm to simulate the search for the optimal path between blocks, and dynamically adjust the transaction routing strategy to balance the distribution of transaction requests; The segmentation unit is used to determine whether the load of each block has reached a preset performance threshold. The performance threshold is determined based on transaction processing delay and throughput. If the performance threshold is reached, the block is dynamically divided into multiple sub-blocks through block sharding technology. The sub-blocks process transactions in parallel to alleviate the load pressure of a single block.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the steps of the method described in any one of claims 1 to 7 when executing a program stored in a memory.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Block chain multi-level fragment load balancing method and system based on predictive subgraph

    CN120499185A