Blockchain network transaction method, device, storage medium and electronic device
By obtaining historical transaction data in the blockchain network and using the environment prediction model to predict the transaction success rate, the problem of cross-chain transaction failure is solved, the transaction success rate is improved and the system performance damage is reduced.
Patent Information
- Application Number
- CN202011314898.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-20
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-11-20
AI Technical Summary
Blockchain networks may experience transaction failures during cross-chain transactions, causing transaction rollback and reducing the performance of the entire cross-chain system.
By obtaining the target historical transaction status data of the target node, input it into the environment prediction model to obtain the transaction success rate, and decide whether to execute the transaction operation based on the relationship between the success rate and the success rate threshold.
It increases the probability of transaction success and reduces the impact of transaction failure on network performance.
Smart Images

Figure CN112488831B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and in particular, to a blockchain network transaction method, device, storage medium and electronic device. Background Art
[0002] Blockchain is a technology that can collectively maintain a reliable database in a decentralized and trustless manner. It can store transactions that occur over a period of time in blocks, and connect the blocks in chronological order using cryptographic algorithms to form a data structure similar to a chain. Since blockchain technology has the characteristics of distributed ledger, decentralization, and non-tamperability, it has high application prospects in many aspects.
[0003] In related scenarios, when blockchain nodes conduct cross-chain transactions, transaction failures may occur, resulting in transaction rollbacks, thereby reducing the performance of the entire cross-chain system. Summary of the invention
[0004] The purpose of the present disclosure is to provide a blockchain network transaction method, device, storage medium and electronic device to solve the above-mentioned related technical problems.
[0005] In order to achieve the above-mentioned purpose, according to a first aspect of an embodiment of the present disclosure, a blockchain network transaction method is provided, comprising:
[0006] In response to the target node obtaining the transaction request, obtaining status data corresponding to the target historical transaction of the target node, wherein the target historical transaction is a historical transaction generated by the target node within a preset time period before the current moment, or the target historical transaction is a preset number of historical transactions that were most recently generated by the target node before the transaction request was obtained;
[0007] Inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model, wherein the training samples of the environment prediction model are obtained based on the state data of historical transactions generated in the blockchain network, and each of the training samples is marked with a type label;
[0008] Determining a target transaction success rate of the transaction request according to a proportion of training samples marked with the target type label and having a successful transaction status in all training samples marked with the target type label;
[0009] Whether to execute the transaction operation corresponding to the transaction request is determined according to the relationship between the target transaction success rate and the success rate threshold.
[0010] Optionally, the state data includes transaction state data of the target historical transaction, and the environment prediction model includes a transaction state prediction model, and accordingly:
[0011] The step of inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model includes:
[0012] The transaction status data of all the target historical transactions are used as an input of the transaction status prediction model, and input into the transaction status prediction model to obtain a first target type label representing the transaction status type output by the transaction status prediction model, wherein the training samples of the transaction status prediction model correspond to the historical transaction time periods of the blockchain network one by one, and the transaction status data corresponding to all historical transactions of the same blockchain node within a historical time period are used as a training sample;
[0013] The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises:
[0014] A first transaction success rate of the transaction request is determined according to the proportion of training samples marked with the first target type label and having a successful transaction status in all training samples marked with the first target type label, and the target transaction success rate includes the first transaction success rate.
[0015] Optionally, the state data includes system state data, which is used to characterize the system state at the time when the target historical transaction occurs, and the environment prediction model includes a system state clustering model. Accordingly:
[0016] The step of inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model includes:
[0017] The system state data of all the target historical transactions are input into the system state clustering model in a manner of taking the system state data of one target historical transaction as an input quantity, and a second target type label representing the system state type of each target historical transaction output by the system state clustering model is obtained. The training sample of the system state clustering model is the system state data corresponding to each historical transaction of the blockchain network. During the training process, the system state clustering model clusters all the training samples into multiple clusters, and the second target type label is the target cluster to which the system state data representing the target historical transaction belongs;
[0018] The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises:
[0019] A second transaction success rate of the transaction request is determined based on the proportion of training samples marked with the second target type label and having a successful transaction status in all training samples marked with the second target type label, and the target transaction success rate includes the second transaction success rate.
[0020] Optionally, determining the second transaction success rate of the transaction request according to the proportion of training samples marked with the second target type label and having a successful transaction status in all training samples marked with the second target type label includes:
[0021] For each of the second target type labels, determining a first proportion of training samples marked with the second target type label in all training samples;
[0022] For each of the second target type tags, determining a second proportion of system status data belonging to the second target type tag among the status data corresponding to all the target historical transactions;
[0023] Determine the weight of the second target type tag corresponding to the system status data of each target historical transaction according to the first proportion and the second proportion of each second target type tag;
[0024] The weight of the second target type tag corresponding to the system status data of each target historical transaction and the target ratio corresponding to the second target type tag marked with the system status data are weighted summed to obtain the second transaction success rate;
[0025] The target ratio is the ratio of the training samples marked with the second target type label and whose transaction status is a successful status to all the training samples marked with the second target type label.
[0026] Optionally, the state data includes system state data of the target historical transaction, and the environment prediction model includes a system state prediction model, and accordingly:
[0027] The step of inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model includes:
[0028] The system state data of all the target historical transactions are used as an input of the system state prediction model, and input into the system state prediction model to obtain a third target type label representing the system state type output by the system state prediction model, wherein the training samples of the system state prediction model correspond to the historical transaction time periods of the blockchain network one by one, and the system state data corresponding to all historical transactions of the same blockchain node within a historical time period are used as a training sample;
[0029] The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises:
[0030] A third transaction success rate of the transaction request is determined according to the proportion of training samples marked with the third target type label and having a successful transaction status in all training samples marked with the third target type label, and the target transaction success rate includes the third transaction success rate.
[0031] Optionally, the state data includes transaction state data of the target historical transaction, and the environment prediction model includes a transaction state clustering model, and accordingly:
[0032] The step of inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model includes:
[0033] The transaction status data of all the target historical transactions are input into the transaction status clustering model in a manner of taking the transaction status data of one target historical transaction as an input quantity, so as to obtain a fourth target type label output by the transaction status clustering model, which characterizes the transaction status type of each target historical transaction. The training sample of the transaction status clustering model is the transaction status data corresponding to each historical transaction of the blockchain network. During the training process, the transaction status clustering model clusters all the training samples into a plurality of clusters, and the fourth target type label is the target cluster to which the transaction status data characterizing the target historical transaction belongs.
[0034] The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises:
[0035] A fourth transaction success rate of the transaction request is determined according to the proportion of training samples marked with the fourth target type label and having a successful transaction status in all training samples marked with the fourth target type label, and the target transaction success rate includes the fourth transaction success rate.
[0036] Optionally, the state data includes transaction state data of the target historical transaction and system state data, the system state data is used to characterize the system state at the time when the target historical transaction occurs, and the environment prediction model includes a transaction state prediction model, a system state clustering model, a transaction state clustering model and a system state prediction model; accordingly:
[0037] The target transaction success rate includes:
[0038] a first transaction success rate obtained based on the transaction status data and the transaction status prediction model;
[0039] a second transaction success rate obtained based on the system state data and the system state clustering model;
[0040] a third transaction success rate obtained based on the system state data and the system state prediction model;
[0041] a fourth transaction success rate obtained based on the transaction status data and the transaction status clustering model;
[0042] The determining whether to execute the transaction operation corresponding to the transaction request according to the relationship between the target transaction success rate and the success rate threshold includes:
[0043] Taking a weighted sum of the first transaction success rate, the second transaction success rate, the third transaction success rate, and the third transaction success rate to obtain a sum value;
[0044] When the sum is greater than the success rate threshold, executing the transaction operation corresponding to the transaction request;
[0045] When the sum is less than or equal to the success rate threshold, the transaction request is cancelled.
[0046] Optionally, the transaction status data includes one or more of the number of concurrent transactions, transaction response time, transaction throughput, transaction timeout setting time, block time setting information, block size setting information, the last transaction result identifier, and the current transaction result identifier.
[0047] Optionally, the system status data includes one or more of central processing unit CPU occupancy, network bandwidth occupancy, memory occupancy, disk usage, CPU occupancy change rate, network bandwidth occupancy change rate, memory occupancy change rate, and disk usage change rate.
[0048] Optionally, the target number of clusters of the system state clustering model or the transaction state clustering model is obtained in the following manner:
[0049] Set multiple candidate cluster numbers;
[0050] For each candidate cluster number, clustering the data to be clustered according to the candidate cluster number until the cluster centers converge;
[0051] Calculate the inter-class distance values of a plurality of clustering categories corresponding to each candidate cluster number and the intra-class distance value of each data in each of the clustering categories;
[0052] The candidate cluster number corresponding to the maximum value of the difference between the inter-class distance value and the intra-class distance value is used as the target cluster number.
[0053] Optionally, the transaction request is a cross-chain transaction request, and accordingly, the target historical transaction is a historical cross-chain transaction generated by the target node within a preset time period before the current moment, or the target historical transaction is a preset number of historical cross-chain transactions generated by the target node before obtaining the transaction request, and the training samples of the environmental prediction model are obtained based on the status data of historical cross-chain transactions generated in the blockchain network.
[0054] According to a second aspect of an embodiment of the present disclosure, a blockchain network transaction device is provided, comprising:
[0055] A first acquisition module is used to acquire, in response to a target node acquiring a transaction request, state data corresponding to a target historical transaction of the target node, wherein the target historical transaction is a historical transaction generated by the target node within a preset time period before a current moment, or the target historical transaction is a preset number of historical transactions that were most recently generated by the target node before the target node acquired the transaction request;
[0056] A first input module is used to input the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model, wherein the training samples of the environment prediction model are obtained based on the state data of historical transactions generated in the blockchain network, and each of the training samples is marked with a type label;
[0057] A first determination module is used to determine a target transaction success rate of the transaction request according to a proportion of training samples marked with the target type label and having a successful transaction status in all training samples marked with the target type label;
[0058] The second determination module is used to determine whether to execute the transaction operation corresponding to the transaction request according to the relationship between the target transaction success rate and the success rate threshold.
[0059] According to a third aspect of an embodiment of the present disclosure, there is provided a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the method described in any one of the first aspects are implemented.
[0060] According to a fourth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0061] a memory having a computer program stored thereon;
[0062] A processor is used to execute the computer program in the memory to implement the steps of any one of the methods described in the first aspect above.
[0063] In the above technical solution, the target node in the blockchain network can obtain the status data corresponding to the target historical transaction of the target node when obtaining the transaction request. In this way, the target type label corresponding to the status data can be obtained by inputting the status data into the environmental prediction model, and the target transaction success rate of the transaction request can be determined according to the proportion of training samples marked with the target type label and the transaction status is a successful state in all training samples marked with the target type label. In other words, the above technical solution can predict the success rate of the transaction before the transaction is carried out, and then the transaction with a low success rate can be revoked. Therefore, the use of the above technical solution can increase the probability of successful transactions and reduce the impact of transaction failures on network performance.
[0064] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0066] Figure 1 It is a flowchart of a blockchain network transaction method shown in an exemplary embodiment of the present disclosure.
[0067] Figure 2It is a flowchart of a blockchain network transaction method shown in an exemplary embodiment of the present disclosure.
[0068] Figure 3 It is a flowchart of a blockchain network transaction method shown in an exemplary embodiment of the present disclosure.
[0069] Figure 4 It is a flowchart of a blockchain network transaction method shown in an exemplary embodiment of the present disclosure.
[0070] Figure 5 It is a flowchart of a blockchain network transaction method shown in an exemplary embodiment of the present disclosure.
[0071] Figure 6 It is a flow chart for determining the number of clusters of a clustering model shown in an exemplary embodiment of the present disclosure.
[0072] Figure 7 It is a block diagram of a blockchain network transaction device shown in an exemplary embodiment of the present disclosure.
[0073] Figure 8 It is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0074] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0075] Before introducing the blockchain network transaction method, device, storage medium and electronic device of the present invention, the application scenarios of the various embodiments provided by the present invention are first introduced. The various embodiments provided by the present invention can be applied to transaction scenarios of blockchain nodes, and these transactions can be transactions in the same blockchain network or cross-chain transactions between nodes belonging to different blockchain networks.
[0076] In related scenarios, when blockchain nodes conduct cross-chain transactions, transaction failures may occur, resulting in transaction rollbacks, thereby reducing the performance of the entire cross-chain system.
[0077] To this end, the present invention provides a blockchain network transaction method. Figure 1 is a flowchart of a blockchain network transaction method shown in an exemplary embodiment of the present disclosure, the method comprising:
[0078] In step S11, in response to the target node obtaining the transaction request, the status data corresponding to the target historical transaction of the target node is obtained.
[0079] Specifically, the blockchain network transaction method can be applied to a transaction recipient, that is, the target node can be used as a transaction recipient. After receiving the transaction request, the target node can obtain the status data corresponding to the target historical transaction of the target node.
[0080] Regarding the target historical transactions, the target historical transactions may be historical transactions generated by the target node within a preset time period before the current moment, and the preset time period may be, for example, one hour, one day, etc. In some embodiments, the target historical transactions may also be a preset number of historical transactions that were most recently generated by the target node before the transaction request was obtained, such as the most recently generated 10 transactions, 15 transactions, etc.
[0081] In S12, the state data is input into an environment prediction model to obtain a target type label of the state data output by the environment prediction model.
[0082] The training samples of the environmental prediction model can be obtained based on the status data of historical transactions generated in the blockchain network, for example. It should be understood that the composition structure of the training samples can be consistent with the status data input to the environmental prediction model. For example, if the status data input to the environmental prediction model is the status data corresponding to the 10 most recent historical transactions, when training the environmental status model, the historical transactions in the blockchain network can be arranged in chronological order, and the status data corresponding to the 10 adjacent historical transactions can be used as a training sample.
[0083] In addition, each training sample may be marked with a type label. Thus, by comparing the type label with the prediction label output by the environment prediction model, the loss value of the environment prediction model may be determined, so that the model parameters may be adjusted according to the loss value, thereby achieving the effect of training the model.
[0084] In this way, the state data can be input into the environment prediction model to obtain the target type label of the state data output by the environment prediction model.
[0085] In step S13, the target transaction success rate of the transaction request is determined according to the proportion of the training samples marked with the target type label and whose transaction status is a success status in all the training samples marked with the target type label.
[0086] It should be understood that since the training samples are obtained based on the status data corresponding to the historical transactions, each training sample may correspond to a real transaction result, such as a successful transaction or a failed transaction. Therefore, after obtaining the target type label corresponding to the target historical transaction through the environmental prediction model, the transaction success rate corresponding to the transaction request may be determined based on the historical data. For example, the proportion of training samples marked with the target type label and whose transaction status is a successful state in all training samples marked with the target type label is used as the target transaction success rate of the transaction request.
[0087] In step S14, whether to execute the transaction operation corresponding to the transaction request is determined according to the relationship between the target transaction success rate and the success rate threshold.
[0088] For example, in some implementation scenarios, the target transaction success rate is greater than the success rate threshold, in which case the transaction can be executed. In other implementation scenarios, the target transaction success rate may also be less than the success rate threshold, in which case the transaction request can be revoked / rejected. In addition, the success rate threshold can be set according to application requirements, such as 60%, 80%, etc.
[0089] In the above technical solution, the target node in the blockchain network can obtain the status data corresponding to the target historical transaction of the target node when obtaining the transaction request. In this way, the target type label corresponding to the status data can be obtained by inputting the status data into the environmental prediction model, and the target transaction success rate of the transaction request can be determined according to the proportion of training samples marked with the target type label and the transaction status is a successful state in all training samples marked with the target type label. In other words, the above technical solution can predict the success rate of the transaction before the transaction is carried out, and then the transaction with a low success rate can be revoked. Therefore, the use of the above technical solution can increase the probability of successful transactions and reduce the impact of transaction failures on network performance.
[0090] It is worth noting that the above embodiment describes the method by taking the method applied to the transaction recipient as an example, but in some implementation scenarios, the method can also be applied to the transaction initiator, relayer, etc. At the same time, the transaction initiator and recipient can be in the same blockchain network or belong to different blockchain networks.
[0091] For example, in one possible implementation, the transaction request is a cross-chain transaction request, and accordingly, the target historical transaction is a historical cross-chain transaction generated by the target node within a preset time period before the current moment, or the target historical transaction is a preset number of historical cross-chain transactions generated by the target node before obtaining the transaction request, and the training samples of the environmental prediction model are obtained based on the status data of historical cross-chain transactions generated in the blockchain network. In other words, the above technical solution can predict the success rate of cross-chain transactions, thereby reducing the impact of the phenomenon of cross-chain transaction failure on system performance.
[0092] In addition, in some implementation scenarios, the status data may also include the status data of the target historical transactions corresponding to each transaction party. For example, when the method is executed on the transaction recipient, the transaction recipient can not only determine the target transaction success rate based on the status data corresponding to the target historical transactions of its own node, but also obtain the status data corresponding to the target historical transactions of the transaction initiator, and determine another target transaction success rate through the blockchain network transaction method provided by the present disclosure. In this way, the final success rate of the transaction can be determined by combining the target transaction success rates of the respective transaction parties, and then determine the execution strategy of the transaction. Of course, in some implementation scenarios, the transaction parties may also include the relay parties of the transaction, which is not limited by the present disclosure.
[0093] In a possible implementation, the state data includes transaction state data of the target historical transaction, and the environment prediction model includes a transaction state prediction model. Figure 2 A flowchart of a blockchain network transaction method is shown, wherein the method Figure 1 On the basis of, inputting the state data into the environment prediction model to obtain the target type label of the state data output by the environment prediction model includes:
[0094] S121, taking the transaction status data of all the target historical transactions as an input of the transaction status prediction model, inputting the transaction status prediction model, and obtaining a first target type label representing the transaction status type output by the transaction status prediction model.
[0095] Among them, the transaction status data can represent the transaction status corresponding to each of the target historical exchanges, which may include one or more of the number of concurrent transactions, transaction response time, transaction throughput, transaction timeout setting time, block time setting information, block size setting information, the last transaction result identifier (such as a success identifier or a failure identifier) and the current transaction result identifier (such as a success identifier or a failure identifier).
[0096] The training samples of the transaction status prediction model correspond one-to-one to the historical transaction time periods of the blockchain network, and the transaction status data corresponding to all historical transactions of the same blockchain node within a historical time period is used as a training sample.
[0097] For example, the transaction status prediction model can be constructed based on LSTM (Long Short-Term Memory). The time step of the LSTM can be determined based on the transaction status of the blockchain network. For example, a time of t seconds can be selected, and the average number of transactions generated within t seconds can be calculated as the time step NT of the LSTM. In this way, a training sample can be determined based on the time step NT and the transaction status data corresponding to the historical transactions of the blockchain node.
[0098] For example, the training sample may be determined based on transaction status data corresponding to multiple historical transactions of the same node. The transaction status data includes the transaction concurrency number T c , transaction response time T r , transaction throughput T tps , Transaction timeout setting time T o , block time setting information B t , Block size setting information B s , the last transaction result identifier next and the current transaction result identifier current as an example, if the node includes 100 transaction status data corresponding to 100 historical exchanges, and the time step TN is 20, then the training sample [5, 20, 8] can be obtained. Among them, 20 is the time step, 5 is the number of samples, and 8 is the number of sample features ({T c ,T r , T tps , T o , B t , B s , next, current}), corresponding to the transaction status data.
[0099] Of course, in some implementation scenarios, the same data set may generate different training samples based on the difference in the selection of the starting time point. For example, for transaction status data 1-11 arranged in time sequence, when the time step is 10, transaction status data 1-10 can be used as a training sample, or transaction status data 2-11 can be used as a training sample.
[0100] In some implementations, the LSTM may include, for example, NT*32*64*128*256 neurons. For the LSTM unit of the hidden layer, corresponding weights may also be set for the LSTM unit.
[0101] For example, we can calculate the hidden state scores at the tth time point and all previous time points,
[0102] e t =W T h t
[0103] Among them, the time point corresponds to the transaction, W T =(h1,h2...,h t ,...,h NT ) T , t∈{1,2,…,NT}, NT is the total number of time points, W T is the state at all time points, h t is the state at time point t.
[0104] Furthermore, the hidden state score at each time point can be normalized based on the softmax function, and the attention value allocated to the hidden state at the t-th time point relative to the hidden state at the s-th time point is obtained as follows:
[0105]
[0106] Among them, e ts for e t The tth element in , s∈{1,2,…,NT}. In this way, the hidden layer output at the tth time point under the self-attention mechanism can be determined as
[0107]
[0108] After constructing the LSTM, the determined training sample data can be input into the LSTM to obtain the prediction result of the LSTM. Continuing with the above example, if the training sample input into the transaction status prediction model is transaction status data 1-10, the type label of transaction status data 11 can be used as the type label of the training sample. In this way, the correctness of the prediction result of the transaction status prediction model can be determined by comparing the prediction label output by the transaction status model and the type label of the training sample, and then the relevant network parameters of the LSTM can be updated until the model converges and the training is completed.
[0109] Still refer to Figure 1 and Figure 2 In this case, determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and the transaction status being a success status in all the training samples marked with the target type label includes:
[0110] S131, determining a first transaction success rate of the transaction request according to the proportion of training samples marked with the first target type label and having a successful transaction status in all training samples marked with the first target type label, wherein the target transaction success rate includes the first transaction success rate.
[0111] For example, if the first target type label output by the transaction status prediction model is A, and in the training samples of the transaction status prediction model, there are 10,000 samples with label A, of which 7,000 are samples with successful transactions, then it can be determined that the transaction success rate corresponding to the first target type label A is 70%, that is, the first transaction success rate corresponding to the transaction request is 70%.
[0112] In this case, whether to execute the transaction operation corresponding to the transaction request can be determined based on the relationship between the first transaction success rate and the success rate threshold. For specific strategies, please refer to the embodiment description of step S14, which will not be elaborated in this disclosure.
[0113] In the above technical solution, the success rate of the transaction corresponding to the transaction request can be predicted based on the transaction status data of the target historical transaction, thereby reducing the frequency of transaction failure.
[0114] Regarding the type label of the training sample, in some embodiments, it can be determined based on clustering. For example, all training samples can be clustered by a clustering model to obtain multiple clusters, and accordingly, the type label of the training sample can correspond to any one of the multiple clusters.
[0115] In some other embodiments, the state data includes system state data, which is used to characterize the system state at the time when the target historical transaction occurs, and the environmental prediction model includes a system state clustering model. In this case, the success rate of the transaction can also be determined based on the clustering model. For example, referring to Figure 3 A flowchart of a blockchain network transaction method is shown, wherein the method Figure 1 On the basis of, inputting the state data into the environment prediction model to obtain the target type label of the state data output by the environment prediction model includes:
[0116] S122, inputting the system status data of all the target historical transactions into the system status clustering model in a manner of taking one piece of system status data of the target historical transaction as an input quantity, and obtaining a second target type label output by the system status clustering model that represents the system status type of each of the target historical transactions.
[0117] The system status data may include, for example, one or more of the CPU occupancy rate, network bandwidth occupancy rate, memory occupancy rate, disk usage rate, CPU occupancy change rate, network bandwidth occupancy change rate, memory occupancy change rate, and disk usage change rate. The CPU occupancy change rate, network bandwidth occupancy change rate, memory occupancy change rate, and disk usage change rate may be determined, for example, based on the CPU occupancy rate, network bandwidth occupancy rate, memory occupancy rate, and disk usage rate at the corresponding moments of adjacent exchanges. In some scenarios, the average CPU occupancy change rate, average network bandwidth occupancy change rate, average memory occupancy change rate, and average disk usage change rate within the threshold time may also be selected.
[0118] The training samples of the system state clustering model are the system state data corresponding to each historical transaction of the blockchain network. During the training process, the system state clustering model clusters all training samples into multiple clusters, and the second target type label is the target cluster to which the system state data representing the target historical transaction belongs.
[0119] For example, for all training samples, the number of clusters K can be set, and K clusters can be finally obtained by selecting cluster centers and updating cluster centers. In this way, each cluster can be used as a second target type label.
[0120] In this way, the system status data of all the target historical transactions can be input into the system status clustering model in a manner where the system status data of one target historical transaction is taken as an input quantity, and the second target type label representing the system status type of each target historical transaction output by the system status clustering model is obtained.
[0121] For example, the target historical transactions may be 10 (i.e., system status data 1-10), then the above steps may refer to inputting system status data 1, system status data 2...system status data 10 as an input quantity into the system status clustering model to obtain a second target type label corresponding to each system status data in system status data 1-10.
[0122] In this case, determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label includes:
[0123] S132, determining a second transaction success rate of the transaction request according to the proportion of training samples marked with the second target type label and having a successful transaction status in all training samples marked with the second target type label, wherein the target transaction success rate includes the second transaction success rate.
[0124] For example, if the second target type label output by the transaction status prediction model is B, and in the training samples of the system status prediction model, there are 10,000 samples with label B, of which 1,500 are samples of successful transactions, then it can be determined that the transaction success rate corresponding to the first target type label B is 15%, that is, the second transaction success rate corresponding to the transaction request is 15%.
[0125] In this case, whether to execute the transaction operation corresponding to the transaction request can be determined based on the relationship between the second transaction success rate and the success rate threshold. For specific strategies, please refer to the embodiment description of step S14, which will not be elaborated in this disclosure.
[0126] In the above technical solution, the success rate of the transaction corresponding to the transaction request can be predicted based on the system status data of the target historical transaction, thereby reducing the frequency of transaction failure.
[0127] In a possible implementation manner, determining the second transaction success rate (S132) of the transaction request according to the proportion of the training samples marked with the second target type label and having a successful transaction status in all the training samples marked with the second target type label includes:
[0128] For each of the second target type labels, a first proportion of training samples marked with the second target type label in all training samples is determined.
[0129] For example, the number of target historical transactions is 10, among which the number of target historical transactions with the second target type label of system status data being A is 3, the number of target historical transactions with the second target type label of system status data being B is 4, and the number of target historical transactions with the second target type label of system status data being C is 3.
[0130] When determining the second transaction success rate, for the second target type label A, the ratio of the number of samples with the second target type label A in all training samples to the number of all training samples can be used as the first proportion. Similarly, the first proportion corresponding to the second target type label B and the second target type label C can also be determined.
[0131] In addition, for each of the second target type tags, a second proportion of the system status data belonging to the second target type tag is determined among the status data corresponding to all the target historical transactions.
[0132] Continuing with the above example, for the second target type tag A, the ratio of the number of status data of the second type tag A of the system status data in the target historical transactions to the total number of system status data in the target historical transactions can also be used as the second proportion of the second target type tag A. Continuing with the above example, it can be seen that the second proportion of the second target type tag A is 30%. Similarly, it can be determined that the second proportion of the second target type tag B is 40%, and the second proportion of the second target type tag C is 30%.
[0133] Of course, in some implementations, the second proportion F2 may also be determined by the following formula:
[0134]
[0135] Among them, F 2A is the second proportion of the second target type label A, x is the total number of status data corresponding to the target historical transactions, x A The number of system status data of the second target type tag A.
[0136] In this way, the weight corresponding to the system status data of each target historical transaction can be determined according to the first proportion and the second proportion of each second target type tag. For example, the weight corresponding to each system status data can be calculated by the following formula:
[0137]
[0138] Among them, F t =F t1 ×F t2 , F t1 is the first proportion of the second target type label corresponding to the system state data t, F t2 is the second proportion of the second target type label corresponding to the system state data t. t is the weight corresponding to the system state data t, and NT is the time step, which in this case is the number of system state data input to the system state clustering model.
[0139] After determining the weight of the system status data for each target historical transaction, refer to the following formula:
[0140]
[0141] The weight corresponding to the system status data of each target historical transaction and the target proportion corresponding to the second target type label of the system status data can be weighted summed to obtain the second transaction success rate. The target proportion is the proportion of training samples marked with the second target type label and with a successful transaction status to all training samples marked with the second target type label. t is the second transaction success rate, P w1 is the target ratio, for different state data, P w1 Can be different.
[0142] By adopting the above technical solution, the success rate of the transaction corresponding to the transaction request can be predicted based on the system status data of the target historical transaction, thereby reducing the frequency of transaction failure.
[0143] In addition, in some implementation scenarios, a system status prediction model can also be established based on the system status data of historical transactions, so that the success rate of the transaction can be predicted based on the system status data corresponding to the target historical transaction and the system status prediction model.
[0144] Figure 4 is a flowchart of a blockchain network transaction method shown in an exemplary embodiment of the present disclosure, wherein the method Figure 1 On the basis of, the state data includes the system state data of the target historical transaction, the environment prediction model includes a system state prediction model, and the state data is input into the environment prediction model to obtain the target type label of the state data output by the environment prediction model, including:
[0145] S123, taking the system status data of all the target historical transactions as an input quantity of the system status prediction model, inputting the system status prediction model, and obtaining a third target type label representing the system status type output by the system status prediction model.
[0146] For system status data and LSTM construction, please refer to Figure 2 as well as Figure 3 For the sake of brevity of the description, the present disclosure does not limit the embodiments of the related contents.
[0147] Regarding training samples, the training samples of the system status prediction model correspond one-to-one to the historical transaction time periods of the blockchain network, and the system status data corresponding to all historical transactions of the same blockchain node within a historical time period is used as a training sample.
[0148] After constructing the system state prediction model based on LSTM, the determined training sample data can be input into the LSTM to obtain the prediction result of the LSTM. For example, for system state data 1-11, if the training sample input into the system state prediction model is system state data 1-10, the type label of system state data 11 can be used as the type label of the training sample. In this way, the correctness of the prediction result of the system state prediction model can be determined by comparing the prediction label output by the system state model and the type label of the training sample, and then the relevant network parameters of the LSTM can be updated until the model converges and the training is completed.
[0149] The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises:
[0150] S133, determining a third transaction success rate of the transaction request according to the proportion of training samples marked with the third target type label and having a successful transaction status in all training samples marked with the third target type label. The target transaction success rate includes the third transaction success rate.
[0151] In this case, whether to execute the transaction operation corresponding to the transaction request can be determined based on the relationship between the third transaction success rate and the success rate threshold. For specific strategies, please refer to the embodiment description of step S14, which will not be elaborated in this disclosure.
[0152] The above technical solution can predict the results of transactions based on system status data and a system status prediction model constructed based on the system status data, thereby reducing the occurrence rate of transaction failures.
[0153] Figure 5 is a flowchart of a blockchain network transaction method shown in an exemplary embodiment of the present disclosure, wherein the method Figure 1 On the basis of, the state data includes transaction state data of the target historical transaction, the environment prediction model includes a transaction state clustering model, and the state data is input into the environment prediction model to obtain the target type label of the state data output by the environment prediction model, including:
[0154] S124, inputting the transaction status data of all the target historical transactions into the transaction status clustering model in a manner of taking one target historical transaction transaction status data as an input quantity, and obtaining a fourth target type label output by the transaction status clustering model that characterizes the transaction status type of each target historical transaction.
[0155] The training samples of the transaction status clustering model are the transaction status data corresponding to each historical transaction of the blockchain network. During the training process, the transaction status clustering model clusters all training samples into multiple clusters, and the fourth target type label is the target cluster to which the transaction status data representing the target historical transaction belongs.
[0156] For transaction status data and clustering methods, please refer to Figure 2 and Figure 3 The present disclosure will not go into details here.
[0157] The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises:
[0158] S134, determining a fourth transaction success rate of the transaction request according to the proportion of training samples marked with the fourth target type label and having a successful transaction status in all training samples marked with the fourth target type label, wherein the target transaction success rate includes the fourth transaction success rate.
[0159] In this case, whether to execute the transaction operation corresponding to the transaction request can be determined based on the relationship between the fourth transaction success rate and the success rate threshold. For specific strategies, please refer to the embodiment description of step S14, which will not be elaborated in this disclosure.
[0160] The above technical solution can predict the results of transactions based on transaction status data and a transaction status prediction model constructed based on the transaction status data, thereby reducing the occurrence rate of transaction failures.
[0161] It is worth noting that, in the above embodiments, the transaction success rate is predicted by using the transaction status data and the system status data respectively, but those skilled in the art should know that in specific implementation, Figure 2 and 3 For example, the first transaction success rate P can be obtained through the transaction status data and the transaction status prediction model. w2 , and obtain the second transaction success rate P through system status data and system status clustering model w1 In this way, by setting weights for the first transaction success rate and the second transaction success rate, the final transaction success rate can be obtained as the target transaction success rate. For example, the target transaction success rate P can be:
[0162] P=αP w2 +(1-α)P w1
[0163] Among them, α can be set according to application requirements, and this disclosure does not limit this. Figure 4 and Figure 5 The method shown predicts the success rate of the transaction to be conducted by combining the third transaction success rate and the fourth transaction success rate.
[0164] In addition, regarding the training samples in the above embodiments, in some possible scenarios, the various models described in the above embodiments can also be continuously trained based on the input data. For example, for the state data input to the model this time, when the state data is input next time and the transaction success rate is calculated, the state data input this time can also be regarded as the training samples in the above embodiments, and the present disclosure does not limit this.
[0165] In a possible implementation, it is also possible to combine Figures 2 to 5 The method shown is used to comprehensively predict the success rate of the transaction. In this case, the state data includes the transaction state data of the target historical transaction and the system state data. The system state data is used to characterize the system state at the time when the target historical transaction occurs. The environment prediction model includes a transaction state prediction model, a system state clustering model, a transaction state clustering model and a system state prediction model; accordingly:
[0166] The target transaction success rate includes:
[0167] a first transaction success rate obtained based on the transaction status data and the transaction status prediction model; a second transaction success rate obtained based on the system status data and the system status clustering model; a third transaction success rate obtained based on the system status data and the system status prediction model; a fourth transaction success rate obtained based on the transaction status data and the transaction status clustering model; and determining whether to execute the transaction operation corresponding to the transaction request according to the relationship between the target transaction success rate and the success rate threshold, including:
[0168] Taking a weighted sum of the first transaction success rate, the second transaction success rate, the third transaction success rate, and the third transaction success rate to obtain a sum value;
[0169] When the sum is greater than the success rate threshold, executing the transaction operation corresponding to the transaction request;
[0170] When the sum is less than or equal to the success rate threshold, the transaction request is cancelled.
[0171] For the various models and calculation methods of the success rates of various transactions in this embodiment, please refer to Figures 2 to 5For the sake of brevity, this disclosure will not elaborate on this.
[0172] In addition, in some implementation scenarios, corresponding threshold data may be set for the first transaction success rate to the fourth transaction success rate, and the transaction strategy may be determined by comparing each transaction success rate with the corresponding threshold data, for example, conducting a transaction, canceling a transaction, etc.
[0173] The above embodiments predict the transaction success rate through transaction status data, system status data and four models respectively, which helps to improve the accuracy of the prediction results.
[0174] It is also worth noting that, regarding the calculation method of the first transaction success rate, the third transaction success rate and the fourth transaction success rate in the above embodiment, referring to the above embodiment description of step S132, in some embodiments, the first transaction success rate, the third transaction success rate and the fourth transaction success rate can also be calculated based on the same inventive concept, which is not elaborated in the present disclosure.
[0175] Figure 6 is a flow chart of a method for determining the number of clusters of a clustering model shown in an exemplary embodiment of the present disclosure, such as Figure 6 As shown, the target cluster number of the system state clustering model or the transaction state clustering model is obtained in the following manner, and the method includes:
[0176] In S61, a plurality of candidate cluster numbers are set.
[0177] For example, the candidate cluster number range [k, K] may be determined to obtain the number of cycles Kk.
[0178] In S62, for each candidate cluster number, the data to be clustered is clustered according to the candidate cluster number until the cluster centers converge.
[0179] For example, for a cluster sample set D = {x1, x2, x3, ..., xi, ..., xn} including n trading system status data, the number of cluster centers can be defined as k, so that k samples can be randomly selected as cluster centers. The selected cluster centers can be, for example, (μ1, μ2, μ3, ..., μ k ).
[0180] After selecting the cluster centers, the distances from each cluster sample to each cluster center can be calculated, for example: d ij =||x i -μ j || 2 Among them, d ij For sample x i Relative cluster center μ jThus, for the cluster center μ j , j = 1, 2, 3, ..., k, the cluster centers can be recalculated:
[0181]
[0182] In this way, by iterating the above cluster center update process, the converged cluster center can be finally obtained, and the clustering cluster division result C = {C1, C2, ..., C k}.
[0183] In S63, the inter-class distance values of the plurality of cluster categories corresponding to each candidate cluster number and the intra-class distance value of each data in each cluster category are calculated.
[0184] Using the above example, corresponding to the number of clusters k, the intra-class distance can be:
[0185]
[0186] Among them, d is the inter-class distance value corresponding to the cluster number k, which is equal to the maximum value of the sum of the average distance from the i-th sample of the j-th class to all samples in the class and the distance between the i-th sample and the cluster center of the j-th cluster. is the mth sample of the jth class, is the i-th sample of the j-th class, μ j is the cluster center of the j-th cluster, n j is the number of samples in the jth cluster, j = 1, 2, 3, ..., k.
[0187] In addition, corresponding to the number of clusters k, the inter-class spacing can be:
[0188]
[0189] Among them, D is the inter-class distance value corresponding to the cluster number k, which is equal to the minimum value of the sum of the average distance from the i-th sample of the j-th class to the samples in other classes and the cluster center distance. is the mth sample of the kth class, is the i-th sample of the j-th class, μ k is the cluster center of the k-th cluster, n k is the number of samples in the k-th cluster, j=1,2,3,...,k.
[0190] In S64, the candidate cluster number corresponding to the maximum value of the difference between the inter-class distance value and the intra-class distance value is used as the target cluster number.
[0191] For example, for the candidate cluster number k, the difference d between the inter-class spacing value corresponding to the candidate cluster number of this class and the intra-class spacing value corresponding to the candidate cluster number of this class can be calculated. k :
[0192] d k =Dd
[0193] In this way, for the candidate cluster numbers k, k+1,…,K, we can get the difference list d=[d k ,d k+1 ,...,d K ], so that the candidate cluster number corresponding to the maximum value of the difference between the inter-class spacing value and the intra-class spacing value can be used as the target cluster number. Of course, in some embodiments, the candidate cluster number corresponding to the minimum value of the difference between the intra-class spacing value and the inter-class spacing value can also be used as the target cluster number, and the present disclosure does not limit this. After determining the target cluster number, the pending data (such as system status data, transaction status data) can be clustered according to the target cluster number to obtain the type label corresponding to each data to be clustered.
[0194] The above technical solution can determine a target cluster number with better clustering effect from multiple candidate cluster numbers by setting multiple candidate cluster numbers and calculating the inter-class distance and intra-class distance corresponding to each cluster number. In this way, clustering the target cluster number can improve the accuracy of the clustering result.
[0195] Based on the same inventive concept, the present disclosure also provides a blockchain network transaction device, referring to Figure 7 A block diagram of a blockchain network transaction device is shown, wherein the device 700 includes:
[0196] The first acquisition module 701 is used for acquiring, in response to the target node acquiring the transaction request, the state data corresponding to the target historical transaction of the target node, wherein the target historical transaction is the historical transaction generated by the target node within a preset time period before the current moment, or the target historical transaction is the preset number of historical transactions most recently generated by the target node before acquiring the transaction request;
[0197] A first input module 702 is used to input the state data into the environment prediction model to obtain a target type label of the state data output by the environment prediction model, wherein the training samples of the environment prediction model are obtained based on the state data of historical transactions generated in the blockchain network, and each training sample is marked with a type label;
[0198] A first determination module 703 is used to determine a target transaction success rate of the transaction request according to the proportion of training samples marked with the target type label and having a successful transaction status in all training samples marked with the target type label;
[0199] The second determination module 704 is used to determine whether to execute the transaction operation corresponding to the transaction request according to the relationship between the target transaction success rate and the success rate threshold.
[0200] In the above technical solution, the target node in the blockchain network can obtain the status data corresponding to the target historical transaction of the target node when obtaining the transaction request. In this way, the target type label corresponding to the status data can be obtained by inputting the status data into the environmental prediction model, and the target transaction success rate of the transaction request can be determined according to the proportion of training samples marked with the target type label and the transaction status is a successful state in all training samples marked with the target type label. In other words, the above technical solution can predict the success rate of the transaction before the transaction is carried out, and then the transaction with a low success rate can be revoked. Therefore, the use of the above technical solution can increase the probability of successful transactions and reduce the impact of transaction failures on network performance.
[0201] Optionally, the state data includes transaction state data of the target historical transaction, and the environment prediction model includes a transaction state prediction model, and accordingly:
[0202] The first input module 702 includes:
[0203] A first input submodule is used to use the transaction status data of all the target historical transactions as an input of the transaction status prediction model, input the transaction status prediction model, and obtain a first target type label representing the transaction status type output by the transaction status prediction model. The training samples of the transaction status prediction model correspond to the historical transaction time periods of the blockchain network one by one. The transaction status data corresponding to all historical transactions of the same blockchain node within a historical time period are used as a training sample;
[0204] The first determining module 703 includes:
[0205] A first determination submodule is used to determine a first transaction success rate of the transaction request based on the proportion of training samples marked with the first target type label and with a successful transaction status in all training samples marked with the first target type label, wherein the target transaction success rate includes the first transaction success rate.
[0206] Optionally, the state data includes system state data, which is used to characterize the system state at the time when the target historical transaction occurs, and the environment prediction model includes a system state clustering model. Accordingly:
[0207] The first input module 702 includes:
[0208] A second input submodule is used to input the system state data of all the target historical transactions into the system state clustering model in a manner of taking the system state data of one target historical transaction as an input quantity, and obtain a second target type label output by the system state clustering model that characterizes the system state type of each target historical transaction. The training sample of the system state clustering model is the system state data corresponding to each historical transaction of the blockchain network. During the training process, the system state clustering model clusters all the training samples into multiple clusters, and the second target type label is the target cluster to which the system state data characterizing the target historical transaction belongs;
[0209] The first determining module 703 includes:
[0210] A second determination submodule is used to determine a second transaction success rate of the transaction request based on the proportion of training samples marked with the second target type label and with a successful transaction status in all training samples marked with the second target type label, wherein the target transaction success rate includes the second transaction success rate.
[0211] Optionally, the second determining submodule includes:
[0212] A first determining subunit is used to determine, for each of the second target type labels, a first proportion of training samples marked with the second target type label in all training samples;
[0213] A second determining subunit is used to determine, for each of the second target type tags, a second proportion of system status data belonging to the second target type tag among the status data corresponding to all the target historical transactions;
[0214] A third determining subunit is used to determine the weight corresponding to the system status data of each of the target historical transactions according to the first proportion and the second proportion of each of the second target type tags;
[0215] a calculation subunit, configured to perform weighted summation on the weight corresponding to the system status data of each target historical transaction and the target ratio corresponding to the second target type tag of the system status data to obtain the second transaction success rate;
[0216] The target ratio is the ratio of the training samples marked with the second target type label and whose transaction status is a successful status to all the training samples marked with the second target type label.
[0217] Optionally, the state data includes system state data of the target historical transaction, and the environment prediction model includes a system state prediction model, and accordingly:
[0218] The first input module 702 includes:
[0219] A third input submodule is used to use the system state data of all the target historical transactions as an input of the system state prediction model, input the system state prediction model, and obtain a third target type label representing the system state type output by the system state prediction model, wherein the training samples of the system state prediction model correspond to the historical transaction time periods of the blockchain network one by one, and the system state data corresponding to all historical transactions of the same blockchain node within a historical time period are used as a training sample;
[0220] The first determining module 703 includes:
[0221] A third determination submodule is used to determine a third transaction success rate of the transaction request based on the proportion of training samples marked with the third target type label and with a successful transaction status in all training samples marked with the third target type label, wherein the target transaction success rate includes the third transaction success rate.
[0222] Optionally, the state data includes transaction state data of the target historical transaction, and the environment prediction model includes a transaction state clustering model, and accordingly:
[0223] The first input module 702 includes:
[0224] The fourth input submodule is used to input the transaction status data of all the target historical transactions into the transaction status clustering model in a manner of taking the transaction status data of one target historical transaction as an input quantity, so as to obtain the fourth target type label output by the transaction status clustering model, which characterizes the transaction status type of each target historical transaction. The training sample of the transaction status clustering model is the transaction status data corresponding to each historical transaction of the blockchain network. During the training process, the transaction status clustering model clusters all the training samples into multiple clusters, and the fourth target type label is the target cluster to which the transaction status data characterizing the target historical transaction belongs.
[0225] The first determining module 703 includes:
[0226] A fourth determination submodule is used to determine a fourth transaction success rate of the transaction request based on the proportion of training samples marked with the fourth target type label and with a successful transaction status in all training samples marked with the fourth target type label, wherein the target transaction success rate includes the fourth transaction success rate.
[0227] Optionally, the state data includes transaction state data of the target historical transaction and system state data, the system state data is used to characterize the system state at the time when the target historical transaction occurs, and the environment prediction model includes a transaction state prediction model, a system state clustering model, a transaction state clustering model and a system state prediction model; accordingly:
[0228] The target transaction success rate includes:
[0229] a first transaction success rate obtained based on the transaction status data and the transaction status prediction model;
[0230] a second transaction success rate obtained based on the system state data and the system state clustering model;
[0231] a third transaction success rate obtained based on the system state data and the system state prediction model;
[0232] a fourth transaction success rate obtained based on the transaction status data and the transaction status clustering model;
[0233] The second determining module includes:
[0234] a first calculation submodule, configured to perform a weighted summation of the first transaction success rate, the second transaction success rate, the third transaction success rate, and the third transaction success rate to obtain a sum value;
[0235] A first execution submodule, configured to execute the transaction operation corresponding to the transaction request when the sum value is greater than the success rate threshold;
[0236] The second execution submodule is configured to cancel the transaction request when the sum is less than or equal to the success rate threshold.
[0237] Optionally, the transaction status data includes one or more of the number of concurrent transactions, transaction response time, transaction throughput, transaction timeout setting time, block time setting information, block size setting information, the last transaction result identifier, and the current transaction result identifier.
[0238] Optionally, the system status data includes one or more of central processing unit CPU occupancy, network bandwidth occupancy, memory occupancy, disk usage, CPU occupancy change rate, network bandwidth occupancy change rate, memory occupancy change rate, and disk usage change rate.
[0239] Optionally, the device further includes: an execution module, configured to determine a target number of clusters of the system state clustering model or the transaction state clustering model, the execution module including:
[0240] Setting submodule, used to set the number of multiple candidate clusters;
[0241] A clustering submodule, for clustering the data to be clustered according to each candidate cluster number until the cluster centers converge;
[0242] A second calculation submodule is used to calculate the inter-class spacing values of multiple cluster categories corresponding to each candidate cluster number and the intra-class spacing value of each data in each cluster category;
[0243] The third execution submodule is used to use the candidate cluster number corresponding to the maximum value of the difference between the inter-class distance value and the intra-class distance value as the target cluster number.
[0244] Optionally, the transaction request is a cross-chain transaction request, and accordingly, the target historical transaction is a historical cross-chain transaction generated by the target node within a preset time period before the current moment, or the target historical transaction is a preset number of historical cross-chain transactions generated by the target node before obtaining the transaction request, and the training samples of the environmental prediction model are obtained based on the status data of historical cross-chain transactions generated in the blockchain network.
[0245] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0246] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the blockchain network transaction method provided by the present disclosure.
[0247] The present disclosure also provides an electronic device, comprising:
[0248] a memory having a computer program stored thereon;
[0249] A processor is used to execute the computer program in the memory to implement the steps of the blockchain network transaction method provided by the present disclosure.
[0250] Figure 8is a block diagram of an electronic device 800 according to an exemplary embodiment, and the electronic device 800 can be used as a blockchain node, for example. Figure 8 As shown, the electronic device 800 may include: a processor 801 and a memory 802. The electronic device 800 may also include one or more of a multimedia component 803, an input / output (I / O) interface 804, and a communication component 805.
[0251] Among them, the processor 801 is used to control the overall operation of the electronic device 800 to complete all or part of the steps in the above-mentioned blockchain network transaction method. The memory 802 is used to store various types of data to support the operation of the electronic device 800, which may include, for example, instructions for any application or method for operating on the electronic device 800, and application-related data, such as block data, certificates, pictures, videos, etc. The memory 802 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk. The multimedia component 803 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 802 or sent through the communication component 805. The audio component may include at least one speaker for outputting audio signals. The I / O interface 804 provides an interface between the processor 801 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 805 is used for wired or wireless communication between the electronic device 800 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 805 may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0252] In an exemplary embodiment, the electronic device 800 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned blockchain network transaction method.
[0253] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned blockchain network transaction method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 802 including program instructions, and the above-mentioned program instructions can be executed by the processor 801 of the electronic device 800 to complete the above-mentioned blockchain network transaction method.
[0254] In another exemplary embodiment, a computer program product is also provided, which includes a computer program that can be executed by a programmable device, and the computer program has a code portion for executing the above-mentioned blockchain network transaction method when executed by the programmable device.
[0255] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.
[0256] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0257] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A blockchain network transaction method, characterized in that: include: In response to the target node obtaining the transaction request, obtaining status data corresponding to the target historical transaction of the target node, wherein the target historical transaction is a historical transaction generated by the target node within a preset time period before the current moment, or the target historical transaction is a preset number of historical transactions that were most recently generated by the target node before the transaction request was obtained; Inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model, wherein the training samples of the environment prediction model are obtained based on the state data of historical transactions generated in the blockchain network, and each of the training samples is marked with a type label; Determining a target transaction success rate of the transaction request according to a proportion of training samples marked with the target type label and having a successful transaction status in all training samples marked with the target type label; Determining whether to execute the transaction operation corresponding to the transaction request according to the relationship between the target transaction success rate and the success rate threshold; Wherein, the state data includes one or more of the transaction state data of the target historical transaction and the system state data of the target historical transaction; The transaction status data includes one or more of the number of concurrent transactions, transaction response time, transaction throughput, transaction timeout setting time, block time setting information, block size setting information, last transaction result identifier, and current transaction result identifier; The system status data includes one or more of the CPU occupancy rate, network bandwidth occupancy rate, memory occupancy rate, disk usage rate, CPU occupancy change rate, network bandwidth occupancy change rate, memory occupancy change rate, and disk usage change rate.
2. The method according to claim 1, characterized in that The state data includes transaction state data of the target historical transaction, and the environment prediction model includes a transaction state prediction model. Accordingly: The step of inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model includes: The transaction status data of all the target historical transactions are used as an input of the transaction status prediction model, and input into the transaction status prediction model to obtain a first target type label representing the transaction status type output by the transaction status prediction model, wherein the training samples of the transaction status prediction model correspond to the historical transaction time periods of the blockchain network one by one, and the transaction status data corresponding to all historical transactions of the same blockchain node within a historical time period are used as a training sample; The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises: A first transaction success rate of the transaction request is determined according to the proportion of training samples marked with the first target type label and having a successful transaction status in all training samples marked with the first target type label, and the target transaction success rate includes the first transaction success rate.
3. The method according to claim 1, characterized in that The state data includes system state data, which is used to characterize the system state at the time when the target historical transaction occurs. The environment prediction model includes a system state clustering model. Accordingly: The step of inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model includes: The system state data of all the target historical transactions are input into the system state clustering model in a manner of taking the system state data of one target historical transaction as an input quantity, and a second target type label representing the system state type of each target historical transaction output by the system state clustering model is obtained. The training sample of the system state clustering model is the system state data corresponding to each historical transaction of the blockchain network. During the training process, the system state clustering model clusters all the training samples into multiple clusters, and the second target type label is the target cluster to which the system state data representing the target historical transaction belongs; The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises: A second transaction success rate of the transaction request is determined based on the proportion of training samples marked with the second target type label and having a successful transaction status in all training samples marked with the second target type label, and the target transaction success rate includes the second transaction success rate.
4. The method according to claim 3, characterized in that The determining the second transaction success rate of the transaction request according to the proportion of the training samples marked with the second target type label and having a successful transaction status in all the training samples marked with the second target type label comprises: For each of the second target type labels, determining a first proportion of training samples marked with the second target type label in all training samples; For each of the second target type tags, determining a second proportion of system status data belonging to the second target type tag among the status data corresponding to all the target historical transactions; Determine the weight corresponding to the system status data of each of the target historical transactions according to the first proportion and the second proportion of each of the second target type tags; The weight corresponding to the system status data of each target historical transaction and the target ratio corresponding to the second target type label of the system status data are weighted summed to obtain the second transaction success rate; The target ratio is the ratio of the training samples marked with the second target type label and whose transaction status is a successful status to all the training samples marked with the second target type label.
5. The method according to claim 1, characterized in that The state data includes the system state data of the target historical transaction, and the environment prediction model includes a system state prediction model. Accordingly: The step of inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model includes: The system state data of all the target historical transactions are used as an input of the system state prediction model, and input into the system state prediction model to obtain a third target type label representing the system state type output by the system state prediction model, wherein the training samples of the system state prediction model correspond to the historical transaction time periods of the blockchain network one by one, and the system state data corresponding to all historical transactions of the same blockchain node within a historical time period are used as a training sample; The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises: A third transaction success rate of the transaction request is determined according to the proportion of training samples marked with the third target type label and having a successful transaction status in all training samples marked with the third target type label, and the target transaction success rate includes the third transaction success rate.
6. The method according to claim 1, characterized in that The state data includes transaction state data of the target historical transaction, and the environment prediction model includes a transaction state clustering model. Accordingly: The step of inputting the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model includes: The transaction status data of all the target historical transactions are input into the transaction status clustering model in a manner of taking the transaction status data of one target historical transaction as an input quantity, so as to obtain a fourth target type label output by the transaction status clustering model, which characterizes the transaction status type of each target historical transaction. The training sample of the transaction status clustering model is the transaction status data corresponding to each historical transaction of the blockchain network. During the training process, the transaction status clustering model clusters all the training samples into a plurality of clusters, and the fourth target type label is the target cluster to which the transaction status data characterizing the target historical transaction belongs. The determining the target transaction success rate of the transaction request according to the proportion of the training samples marked with the target type label and having a successful transaction status in all the training samples marked with the target type label comprises: A fourth transaction success rate of the transaction request is determined according to the proportion of training samples marked with the fourth target type label and having a successful transaction status in all training samples marked with the fourth target type label, and the target transaction success rate includes the fourth transaction success rate.
7. The method according to claim 1, characterized in that The state data includes transaction state data of the target historical transaction and system state data, the system state data is used to characterize the system state at the time when the target historical transaction occurs, and the environment prediction model includes a transaction state prediction model, a system state clustering model, a transaction state clustering model and a system state prediction model; accordingly: The target transaction success rate includes: a first transaction success rate obtained based on the transaction status data and the transaction status prediction model; a second transaction success rate obtained based on the system state data and the system state clustering model; a third transaction success rate obtained based on the system state data and the system state prediction model; a fourth transaction success rate obtained based on the transaction status data and the transaction status clustering model; The determining whether to execute the transaction operation corresponding to the transaction request according to the relationship between the target transaction success rate and the success rate threshold includes: Taking a weighted sum of the first transaction success rate, the second transaction success rate, the third transaction success rate, and the third transaction success rate to obtain a sum value; When the sum is greater than the success rate threshold, executing the transaction operation corresponding to the transaction request; When the sum is less than or equal to the success rate threshold, the transaction request is cancelled.
8. The method according to claim 3 or 6, characterized in that: The target number of clusters of the system state clustering model or the transaction state clustering model is obtained by: Set multiple candidate cluster numbers; For each candidate cluster number, clustering the data to be clustered according to the candidate cluster number until the cluster centers converge; Calculate the inter-class distance values of a plurality of clustering categories corresponding to each candidate cluster number and the intra-class distance value of each data in each of the clustering categories; The candidate cluster number corresponding to the maximum value of the difference between the inter-class distance value and the intra-class distance value is used as the target cluster number.
9. The method according to any one of claims 1 to 7, characterized in that: The transaction request is a cross-chain transaction request. Accordingly, the target historical transaction is a historical cross-chain transaction generated by the target node within a preset time period before the current moment, or the target historical transaction is a preset number of historical cross-chain transactions generated by the target node before obtaining the transaction request. The training samples of the environmental prediction model are obtained based on the status data of the historical cross-chain transactions generated in the blockchain network.
10. A blockchain network transaction device, characterized in that: include: A first acquisition module is used to acquire, in response to a target node acquiring a transaction request, state data corresponding to a target historical transaction of the target node, wherein the target historical transaction is a historical transaction generated by the target node within a preset time period before a current moment, or the target historical transaction is a preset number of historical transactions that were most recently generated by the target node before the target node acquired the transaction request; A first input module is used to input the state data into an environment prediction model to obtain a target type label of the state data output by the environment prediction model, wherein the training samples of the environment prediction model are obtained based on the state data of historical transactions generated in the blockchain network, and each of the training samples is marked with a type label; A first determination module is used to determine a target transaction success rate of the transaction request according to a proportion of training samples marked with the target type label and having a successful transaction status in all training samples marked with the target type label; A second determination module, configured to determine whether to execute the transaction operation corresponding to the transaction request according to a relationship between the target transaction success rate and a success rate threshold; Wherein, the state data includes one or more of the transaction state data of the target historical transaction and the system state data of the target historical transaction; The transaction status data includes one or more of the number of concurrent transactions, transaction response time, transaction throughput, transaction timeout setting time, block time setting information, block size setting information, last transaction result identifier, and current transaction result identifier; The system status data includes one or more of the CPU occupancy rate, network bandwidth occupancy rate, memory occupancy rate, disk usage rate, CPU occupancy change rate, network bandwidth occupancy change rate, memory occupancy change rate, and disk usage change rate.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 9 are implemented.
12. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Cross-chain relay platform-based cross-chain method and system
CN108269190A
Quantitative transaction prediction method, device and equipment
CN109345050A
A fund transaction method and device based on a block chain
CN109447791A
Method, apparatus and storage medium for optimizing transaction timeout threshold
CN109543988A
Transaction prediction method and device
CN110310153A
