Efficient scheduling method for blockchain payment channel network transactions

By introducing encoder and decoder models into the blockchain payment channel network, and combining attention and masking mechanisms, the transaction order is optimized to solve the throughput and waiting time problems under the flexible and variable transaction amount, thereby improving network throughput and reducing waiting time.

CN116342131BActive Publication Date: 2026-05-29XIDIAN UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIDIAN UNIV
Filing Date
2023-01-17
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies have failed to effectively address throughput improvement and average transaction waiting time optimization in blockchain payment channel networks when transaction amounts are flexible and variable, especially since the transaction execution order in the buffer has not been properly scheduled.

Method used

This paper defines the transaction scheduling problem in a payment channel network. It utilizes encoder and decoder models combined with attention and masking mechanisms to optimize the transaction order through a self-iterative approach. Multiple constraints are set to maximize network throughput and reduce average waiting time. The encoder model is used to extract transaction features, and the decoder model is used to determine the transaction execution order. Periodic scheduling and conditional scheduling strategies are designed.

Benefits of technology

This improved network throughput under flexible transaction amounts while reducing the average transaction wait time, proving that the problem is NP-hard and solving it through an encoder-decoder model architecture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116342131B_ABST
    Figure CN116342131B_ABST
Patent Text Reader

Abstract

The application discloses a kind of high-efficiency scheduling methods of blockchain payment channel network transaction, comprising: defining payment channel network transaction scheduling problem, under the condition that transaction both sides node selects execution transaction scheduling strategy, execution node sets multiple constraint conditions with network throughput maximization as target, and the transaction scheduling optimization problem is modeled for the transaction scheduling problem in the buffer zone of both sides, to obtain transaction scheduling optimization problem;For the problem, the execution node utilizes the encoder model to extract the static features and dynamic features of each transaction in the current input sequence, to obtain the encoder output vector of each transaction, and the encoder output sequence is formed by merging;The execution node utilizes the decoder model based on attention mechanism and mask mechanism to make transaction sequence decision in a self-iterative manner to the current obtained encoder output sequence, and outputs the transaction sequence after continuous iteration to schedule both sides to complete transaction.The application can reasonably schedule the transactions in the buffer zone, improve the throughput and reduce the average waiting time of transactions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of blockchain, specifically relating to an efficient scheduling method for blockchain payment channel network transactions. Background Technology

[0002] Blockchain has been widely used in fields such as finance, healthcare, and connected vehicles due to its advantages such as decentralization, high transparency, and immutability.

[0003] In a payment channel, a transaction is executed and the channel capacity is updated if the transaction amount is not greater than the channel capacity; otherwise, the transaction is rejected. Figure 1 As shown, without changing the transaction order, the execution of transaction 1 concentrates the channel's funds on Bob's side, while transactions 2 and 3 cannot be executed due to insufficient channel capacity, resulting in a decrease in transaction throughput.

[0004] To improve the throughput of payment channel networks, existing methods introduce buffers to prevent transactions from being executed immediately. Instead, transactions are buffered for a period of time and executed only after certain conditions are met.

[0005] Sivaraman et al. first introduced buffers into payment channel networks. To maximize the network's long-term throughput, they modeled arriving transactions using a fluid model and split transactions using congestion control principles. The transmission of these split transaction units across nodes needs to consider congestion along the path (i.e., the direction and amount of other transactions in the path). By introducing buffers at each node, transaction units are queued in the buffer when the channel lacks funds to process them immediately. This scheme only buffers transactions if they cannot be executed upon arrival. Furthermore, this scheme focuses on adjusting the speed of transaction execution through buffers and does not investigate scheduling strategies for transactions within the buffers.

[0006] Varma et al. modeled the buffer using a doubly linked queue. Unlike Sivaraman et al., who used rate stability, they defined the concept of on-chain rebalancing based on positive recursion buffer stability, addressing the issue that rate stability cannot guarantee the existence of a steady-state distribution. They proposed a new algorithm to guarantee the buffer reaches a stable state. However, while they avoided network congestion by passively buffering transactions, they did not investigate the transaction scheduling problem within the buffer.

[0007] Papadis et al. introduced buffers and were the first to study a single-hop scheduling strategy for payment channel networks. For the case of fixed transaction amounts, they utilized transactions from the opposite buffer to balance the channel, deriving an optimal scheduling strategy and proving its optimality. For the case of flexible transaction amounts, this scheme extended the optimal scheduling strategy for fixed transaction amounts. When a transaction is not feasible, the execution order of the two parties is changed, allowing transactions in the opposite buffer to be executed first, thus ensuring the current channel capacity meets the conditions for transaction execution. However, when transaction amounts are flexible, this strategy loses its optimality. It only changes the execution order of the two parties but does not rationally schedule the order of transactions in their respective buffers. Therefore, the increase in network throughput is limited, and because transactions are only executed when the maximum buffer time is reached, the average waiting time for transactions in the buffer is long.

[0008] Luo et al. assigned different priorities to transactions based on their forwarding costs, with transactions with higher forwarding costs being executed first. To address the channel capacity contention problem caused by concurrent transactions, the sending node employed a multi-agent reinforcement learning algorithm to perceive the priorities of other transactions and adjust its own transaction priorities accordingly. While this method can improve the total revenue of intermediate nodes and short-term transaction throughput, it remains short-sighted. Under this method, transactions with larger amounts tend to have higher forwarding costs and therefore higher priority. The early execution of large-amount transactions leads to a rapid imbalance in the payment channel, exhausting the capacity on one side of the channel, which is detrimental to improving long-term transaction throughput.

[0009] Therefore, existing work improves transaction throughput in payment channel networks by adding transaction buffers to nodes. Specifically, when a transaction arrives at a node, it is not executed immediately but is instead held in a buffer for a period of time. Through appropriate waiting, the channel capacity may increase due to other transactions, thus satisfying the execution conditions of the current transaction. Based on this design, more transactions are successfully executed, thereby increasing network throughput. Although existing work improves the throughput of payment channel networks to some extent by introducing buffers, it does not consider the order in which transactions are executed within the buffer. This limits the increase in network throughput achieved by these methods, making them unsuitable for solving the transaction scheduling problem in payment channel networks.

[0010] Therefore, how to rationally schedule transactions in the buffer to improve throughput under flexible and variable transaction amounts while reducing the average transaction waiting time is an urgent problem to be solved in this field. Summary of the Invention

[0011] To address the aforementioned problems in existing technologies, this invention provides an efficient scheduling method for blockchain payment channel network transactions. The technical problem to be solved by this invention is achieved through the following technical solution:

[0012] A payment channel network transaction scheduling problem is defined. Given that both parties select a transaction scheduling strategy, the executing node aims to maximize network throughput. Multiple constraints are set to model the transaction scheduling problem within the buffers of both parties, resulting in a transaction scheduling optimization problem. The selected transaction scheduling strategy includes either a periodic scheduling strategy or a conditional scheduling strategy. The executing node includes any node from either party. At least one constraint is related to the average waiting time of the transaction.

[0013] To address the transaction scheduling optimization problem, the execution node uses an encoder model to extract the static and dynamic features of each transaction in the buffers of both parties in the current input sequence, obtains the encoder output vector corresponding to each transaction, and merges them to form the encoder output sequence.

[0014] The execution node utilizes a decoder model to make transaction order decisions on the currently obtained encoder output sequence in a self-iterative manner based on attention and masking mechanisms. After continuous iteration, it outputs a transaction sequence representing the transaction order in the buffers of both parties, so as to schedule the two parties to complete the transaction in the order of the transaction sequence. The encoder model and the decoder model are pre-trained based on reinforcement learning.

[0015] In one embodiment of the present invention, the basis for selecting the transaction scheduling strategy to be executed by the nodes of both parties to the transaction is timeliness; wherein, when the timeliness requirement is low, the nodes of both parties to the transaction select to execute the periodic scheduling strategy; when the timeliness requirement is high, the nodes of both parties to the transaction select to execute the conditional scheduling strategy.

[0016] In one embodiment of the present invention, the execution node, with the goal of maximizing network throughput, sets multiple constraints to model the transaction scheduling problem within the buffers of both parties, resulting in a transaction scheduling optimization problem, including:

[0017] Measure network throughput using standardized throughput;

[0018] The first constraint is established by setting that each sequence can only execute one transaction and each transaction can only be executed once.

[0019] A second constraint is established: the transaction will only be executed if the capacity of the corresponding payment channel is greater than the transaction amount.

[0020] To establish a third constraint, once a transaction is successfully executed, the channel capacity in the direction of the transaction execution needs to be increased, while the channel capacity in the opposite direction needs to be decreased by the same amount.

[0021] If the direction and amount of transactions are the same, the transaction closer to the maximum buffer time will be executed first, in order to reduce the average waiting time of transactions in the buffer, thus constructing a fourth constraint.

[0022] With the goal of maximizing the standardized throughput, and with the first, second, third, and fourth constraints as constraints, the transaction scheduling problem within the buffers of both parties is represented as a linear 0 / 1 integer programming problem, and the transaction scheduling optimization problem is modeled.

[0023] In one embodiment of the present invention, the normalized throughput is expressed as:

[0024]

[0025] Where E represents the standardized throughput; P(A) represents buffer A; P(B) represents buffer B; m represents the total number of transactions in buffers A and B; t represents the time when a transaction is generated; and k represents the k-th transaction. Indicates whether the k-th transaction is executed in the t-th order; v k This represents the amount of the k-th transaction; and Given a binary decision variable, if This indicates that the t-th transaction of the k-th transaction is executed; otherwise...

[0026] The first constraint condition is expressed as:

[0027]

[0028] The second constraint is expressed as follows:

[0029]

[0030]

[0031] in, This represents the capacity of channel A at the time of transaction t. This represents the capacity of channel B at the time of transaction t.

[0032] The third constraint condition is expressed as follows:

[0033]

[0034]

[0035] The fourth constraint condition is expressed as follows:

[0036]

[0037] Among them, Tra k ={s k ,des k ,v k ,t k ,o k} represents the k-th transaction; s within it k Indicates the node that sent the transaction; des k Indicates the receiving node of the transaction; v k Indicates the amount of the transaction; t k Indicates the time when the transaction occurred; o k Indicates the maximum buffer time for a transaction; t s t l o s o l v s v l s s s l Let represent the cases where k takes values ​​of s and l, respectively, and let l represent the parameters corresponding to the s-th and l-th transactions.

[0038] In one embodiment of the present invention, regarding the transaction scheduling optimization problem, the execution node uses an encoder model to extract the static and dynamic features of each transaction in the bilateral buffers of the current input sequence, obtains the encoder output vector corresponding to each transaction, and merges them to form the encoder output sequence, including:

[0039] For the current input sequence, obtain the Tra for each transaction. k tuple sequence Among them, b k =(s k ,v k ,o k As a transaction Tra k Static characteristics; As a trading platform k The dynamic characteristics at the t-th decision step This represents the remaining amount of the transaction at the t-th decision step. and Let represent the capacity of the channels of node A and node B at the t-th decision step; the static features are sequentially passed through the embedding layer, attention layer, normalization layer and feedforward network layer of the encoder model to obtain a d-dimensional embedding vector as the static feature embedding vector; wherein, the encoder model is designed based on the Transformer architecture;

[0040] The dynamic features are extended to d dimensions by passing them only through the embedding layer of the encoder model, resulting in a dynamic feature embedding vector.

[0041] Trade Tra k The obtained static feature embedding vector and dynamic feature embedding vector are concatenated to obtain the transaction Tra. k The corresponding encoder output vector The encoder output sequence is obtained by merging the encoder output vectors corresponding to all transactions in the current input sequence.

[0042] In one embodiment of the present invention, the transaction Tra k In the process of obtaining the static feature embedding vector, the outputs of the embedding layer, attention layer, normalization layer, and feedforward network layer are as follows:

[0043]

[0044]

[0045]

[0046]

[0047] Trading Tra k The static feature embedding vector is:

[0048] Trading Tra k The dynamic feature embedding vector is:

[0049]

[0050] Correspondingly, trading Tra k The corresponding encoder output vector for:

[0051] Among them, γ, β, and each W with a subscript x p x These are the model parameters corresponding to the encoder; head i ∈ is the attention score; ∈ is a predefined constant.

[0052] In one embodiment of the present invention, the execution node utilizes a decoder model to iteratively determine the transaction order of the currently obtained encoder output sequence based on attention and masking mechanisms. After continuous iteration, it outputs a transaction sequence representing the transaction order within the buffers of both parties, including:

[0053] The execution node utilizes the decoder model to output a hidden state h containing previous knowledge at each decision step t. t The decoder model is constructed based on LSTM.

[0054] Using attention mechanisms, based on h t and the currently obtained encoder output sequence When determining the t-th decision step, h t Relevant scores for all transactions;

[0055] Under the rules of transaction selection constrained by the masking mechanism, the relevant scores of the obtained transactions are calculated using softmax to obtain the conditional probability P at the t-th decision step. θ (π t |·), and use this probability to select a transaction Tra k π is the sequence element π output of the current decision step in the transaction sequence. t ;

[0056] Using the obtained sequence elements and the encoder model, the embedding vector of the input sequence is recalculated to update the input of the decoder model to obtain new sequence elements. The iterative process corresponding to the multi-step decision is repeated, and based on all the obtained sequence elements, a transaction sequence corresponding to the input sequence and representing the transaction order in the buffers of both parties is output.

[0057] In one embodiment of the present invention, the use of an attention mechanism based on h t and the currently obtained encoder output sequence When determining the t-th decision step, h t The formula used in the process of assigning scores to all transactions includes:

[0058]

[0059] a t =softmax(n t )

[0060]

[0061]

[0062] Among them, W a , W c , These are the weight parameters that the decoder model needs to learn; n t a t c t It is an intermediate vector in the calculation process; When h is the t-th decision stept Relevant scores for all transactions.

[0063] In one embodiment of the present invention, the masking mechanism constrains the rules for transaction selection, including:

[0064] If the transaction If a transaction has been selected, then selecting that transaction is not allowed.

[0065] Transactions that do not meet the execution conditions due to the current channel capacity are not allowed to be selected;

[0066] When transaction amounts are equal and the transaction sending nodes are the same, if the transaction closer to the maximum buffer time has not yet been executed, then the transaction farther from the maximum buffer time is not allowed to be selected.

[0067] Termination is only permitted when all transactions fail to meet the execution conditions.

[0068] In one embodiment of the present invention, the method further includes:

[0069] We prove that the payment channel network transaction scheduling problem is an NP-hard problem.

[0070] The beneficial effects of this invention are:

[0071] In the solution provided by this invention, firstly, a payment channel network transaction scheduling problem is defined. Under the condition that the nodes of both parties select to execute the transaction scheduling strategy, the execution node sets multiple constraints with the goal of maximizing network throughput, and models the transaction scheduling problem in the buffers of both parties, thus obtaining a transaction scheduling optimization problem. Then, for the transaction scheduling optimization problem, the execution node uses an encoder model to extract the static and dynamic features of each transaction in the buffers of both parties in the current input sequence, obtains the encoder output vector corresponding to each transaction, and merges them to form the encoder output sequence. The execution node uses a decoder model, based on attention mechanism and masking mechanism, to make transaction order decisions on the currently obtained encoder output sequence in a self-iterative manner. After continuous iteration, it outputs a transaction sequence representing the transaction order in the buffers of both parties, so as to schedule the two parties to complete the transaction in the order of the transaction sequence.

[0072] The method of this invention introduces a buffer in the payment channel network, enabling the modeling of the transaction scheduling problem within the buffer by both parties. An encoder and decoder model are then used to solve the resulting transaction scheduling optimization problem, achieving reasonable scheduling of transactions within the buffer. Since the transaction scheduling optimization problem aims to maximize network throughput, and at least one of the constraints is related to the average transaction waiting time, it can improve throughput under flexible and variable transaction amounts while simultaneously reducing the average transaction waiting time.

[0073] Furthermore, this embodiment of the invention also proves that the transaction scheduling problem of the payment channel network is an NP-hard problem, and then selects the architecture combining the encoder model and decoder model of this embodiment of the invention to solve the problem.

[0074] The encoder and decoder models in this invention are based on a Seq2Seq architecture. Based on the encoder and decoder, this invention designs two scheduling strategies: periodic scheduling and selective scheduling. The encoder model processes transaction features, while the decoder model determines the execution order of transactions. Furthermore, in the encoder model, to reduce computational complexity, this invention distinguishes between static and dynamic features. Dynamic features only require one round of encoding throughout the decision-making process. In the decoder model, this invention introduces an attention mechanism to output the optimal ordered subset of transactions, i.e., the transaction sequence, in an autoregressive manner. Additionally, considering the difficulty in generating high-quality training samples, this invention defines corresponding states, actions, and value functions, and designs a reinforcement learning algorithm to train the decoder and encoder models. Attached Figure Description

[0075] Figure 1 This is a schematic diagram illustrating the execution of a transaction under a first-come, first-served (FIFO) model in existing technologies.

[0076] Figure 2 This is a flowchart illustrating the efficient scheduling method for blockchain payment channel network transactions provided in an embodiment of the present invention.

[0077] Figure 3 This diagram illustrates the principle of the efficient scheduling method for blockchain payment channel network transactions provided in this embodiment of the invention.

[0078] Figures 4(a) to 4(c) This is a comparison chart of network standardized throughput in the experiments of this embodiment of the invention.

[0079] Figure 5 This is a graph showing the average transaction waiting time results in the experiments of this embodiment of the invention;

[0080] Figures 6(a) to 6(c) This is a comparison chart of transaction success rates in experiments according to embodiments of the present invention;

[0081] Figure 7 This is a comparison chart of the success rates of transactions in different amount ranges during the experiments of this invention embodiment. Detailed Implementation

[0082] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0083] Existing work addresses this by introducing buffers to manage transactions; however, most of these methods rely on congestion control, temporarily delaying transaction execution in congested networks. The resulting throughput improvement is limited because these methods passively wait for transactions in the buffer, failing to consider the dynamic nature of the payment channel. While some works actively reorder transactions to ensure channel capacity accommodates other transactions, these methods either perform poorly with flexible transaction amounts and incur significant waiting times, or prioritize increasing node profits over improving transaction throughput. To address these issues, this invention aims to design a transaction scheduling method in a payment channel network to improve throughput under flexible transaction amounts while reducing average transaction waiting time.

[0084] like Figure 2 As shown, the efficient scheduling method for blockchain payment channel network transactions provided in this embodiment of the invention may include the following steps S1 to S3, and please refer to [link to relevant documentation]. Figure 3 Use the diagram shown to understand the principle.

[0085] S1 defines the transaction scheduling problem in the payment channel network. Given that the nodes of both parties in the transaction have selected the execution strategy for the transaction scheduling, the execution node aims to maximize the network throughput. Multiple constraints are set to model the transaction scheduling problem within the buffer of both parties, resulting in the transaction scheduling optimization problem.

[0086] The selected transaction scheduling strategy includes either a periodic scheduling strategy or a conditional scheduling strategy; the execution node includes either node of the two parties to the transaction; and at least one constraint is related to the average waiting time of the transaction.

[0087] Specifically, in this embodiment of the invention, it is assumed that node A and node B establish a payment channel, with their initial channel capacities being C. A and C B It means that C A +C B =P, where P is a constant representing the total channel capacity. Since replenishing channel funds needs to be recorded on the blockchain, this operation is time-consuming and costly. Therefore, this embodiment of the invention assumes that the total amount of the channel, i.e., the total channel capacity, will not change, i.e., P remains constant, and the funds in the channel will only flow between A and B.

[0088] The execution of a transaction will cause a change in the channel's capacity, as can be represented by the following formula:

[0089] (C A C B )→(C A -v k C B +v k ), if s k =A

[0090] (C A C B )→(C A +v k C B -v k ), if s k =B

[0091] Among them, v k s represents the amount of the k-th transaction; k This indicates the sender of the transaction, i.e., the sending node.

[0092] To improve the throughput of the payment channel network, this embodiment of the invention introduces a buffer. The buffer exists on each node; when a transaction arrives at a node, it is not executed immediately but is placed in the buffer and waited for a period of time. By rationally scheduling the execution order of transactions in the buffer, the network throughput can be significantly improved. This embodiment of the invention uses P(A) and P(B) to describe the buffers of A and B respectively, which can be simplified as P... A and P B :

[0093] P A ={Tra i |s i =A}

[0094] P B ={Tra j |s j =B}

[0095] Where Tra represents a transaction; m A m represents the number of transactions in buffer A. B Let m represent the number of transactions in buffer B, and m represent the total number of transactions, where m = m A +m BIt should be noted that the transactions in any node's buffer refer to transactions where that node acts as the payer. Assuming a secure communication channel exists between the two nodes that have opened the payment channel, it is feasible to obtain the contents of each other's buffers by exchanging information. Each node can access not only the contents of its own buffer but also the contents of the other node's buffer. Because compliance with the protocol increases the number of successful transactions for both parties, and when one user engages in malicious behavior, the other user can initiate arbitration on the blockchain, which will be jointly judged by other nodes, and the malicious user will be punished. Therefore, this embodiment of the invention assumes that both parties to the transaction comply with the protocol specifications, i.e., users cannot forge transactions in the buffer or execute transactions outside the predetermined transaction order. Furthermore, similar to existing work, this embodiment of the invention assumes that the size of the buffer is unlimited.

[0096] In this embodiment of the invention, when Tra represents a transaction, specifically s represents the sender of the transaction, i.e., the sending node; des represents the receiver of the transaction, i.e., the receiving node; v represents the transaction amount; t represents the transaction creation time; and o represents the maximum buffer time of the transaction. It is important to note that the maximum buffer time of a transaction is different from the hash lock time. The maximum buffer time of a transaction refers to the maximum time a transaction is willing to wait in the buffer. If the transaction has not been executed after the maximum buffer time, it is considered to have failed. Given a series of transactions arriving in chronological order, Tra... k ={s k ,des k ,v k ,t k ,o k} represents the k-th transaction, and the rest are as described above.

[0097] Because transaction execution is affected by channel capacity and may impact the execution of other transactions, it is difficult to prioritize transactions to maximize throughput. This invention first formally defines the transaction scheduling problem in payment channel networks, named the Payment Channel Network Transaction Scheduling Problem (PSP).

[0098] Then, this embodiment of the invention designs two transaction scheduling strategies to schedule transaction order and maximize throughput. The following is a detailed description of these two transaction scheduling strategies.

[0099] 1. Periodic scheduling strategy

[0100] The periodic scheduling strategy is abbreviated as PCPS. Under this strategy, transactions are cached regardless of whether they can be executed, which leads to longer transaction waiting times.

[0101] Specifically, when a transaction arrives at a node, it is cached in a buffer regardless of whether the current channel capacity meets the conditions for transaction execution. When the number of transactions in the buffer exceeds a certain threshold or arrives at fixed intervals (checkpoints), the system first checks if the number of transactions in the buffer has exceeded the maximum buffer time. Transactions exceeding the maximum buffer time are removed from the buffer. The trained encoder-decoder model outputs the optimal sorted subset of transactions in the buffer, i.e., the transaction sequence. Then, both parties execute the transactions according to this transaction sequence and update the channel capacity. The remaining transactions in the buffer continue to wait for the next scheduling.

[0102] 2. Conditional Scheduling Strategy

[0103] Conditional scheduling strategy, abbreviated as PCCS, can reduce transaction wait time, but will slightly reduce throughput.

[0104] Specifically, when a transaction arrives at a node, it first checks whether the current channel capacity meets the conditions for transaction execution. If it does, the transaction is executed; otherwise, it is added to the buffer. The remaining parts are the same as the periodic scheduling strategy and will not be elaborated here.

[0105] As can be seen from the comparison, the only difference between the periodic scheduling strategy and the selective scheduling strategy is whether or not a transaction needs to be executed when the channel capacity meets the conditions for transaction execution. The current channel capacity meets the conditions for transaction execution, meaning the channel capacity is greater than or equal to the transaction amount.

[0106] Regarding how the nodes of both parties in a transaction select and execute the transaction scheduling strategy, one possible implementation is that the nodes of both parties select and execute the transaction scheduling strategy based on timeliness;

[0107] This is because, according to the inventors' observations based on embodiments of the present invention, caching these transactions helps increase network throughput, but it also increases transaction latency. Therefore, the choice needs to be made based on the timeliness of the application.

[0108] When timeliness requirements are low, both parties' nodes can choose to execute a periodic scheduling strategy; when timeliness requirements are high, both parties' nodes can choose to execute a conditional scheduling strategy.

[0109] Based on the above, in one optional implementation, the execution node sets multiple constraints with the goal of maximizing network throughput, and models the transaction scheduling problem within the buffers of both parties, resulting in a transaction scheduling optimization problem, including:

[0110] (1) Measure network throughput using standardized throughput;

[0111] This invention models the transaction scheduling problem in the buffer as a 0 / 1 integer programming problem. Given the initial amount of the channel... The goal of this invention, in relation to all transactions in the buffer, is to determine the execution order of transactions in the buffer to maximize network throughput. It should be noted that transactions in this invention have two order representations, where k represents the transaction generation order and t represents the transaction execution order. Specifically, let... It is a binary decision variable, if This indicates that the t-th transaction of the k-th transaction is executed; otherwise...

[0112] Standardized throughput, which is the proportion of successfully executed transactions to the total transaction amount, is expressed as:

[0113]

[0114] Where E represents the normalized throughput; P(A) represents buffer A; P(B) represents buffer B; m represents the total number of transactions in buffers A and B; t represents the time when a transaction is generated; and k represents the k-th transaction. Indicates whether the k-th transaction is executed in the t-th order; v k This represents the amount of the k-th transaction. It should be noted that t in the t-th executed transaction and the t-th decision step both indicate that the transaction was executed in the t-th order.

[0115] (2) Set the first constraint condition: each sequence can only execute one transaction and each transaction can only be executed once when making a decision.

[0116] The first constraint condition is expressed as follows:

[0117]

[0118]

[0119] (3) Set a second constraint condition: the transaction will only be executed if the capacity of the corresponding payment channel is greater than the transaction amount.

[0120] The second constraint is expressed as follows:

[0121]

[0122]

[0123] in, This represents the capacity of channel A at the time of transaction t. This represents the capacity of channel B at the time of transaction t.

[0124] (4) Set a third constraint condition: when a transaction is successfully executed, the channel capacity in the direction of the transaction execution needs to be increased, and the channel capacity in the opposite direction needs to be reduced by the same amount.

[0125] The third constraint is expressed as follows:

[0126]

[0127]

[0128] (5) If the direction and amount of the transactions are the same, the transaction that is closer to the maximum buffer time will be executed first, in order to reduce the average waiting time of the transactions in the buffer, and construct the fourth constraint condition.

[0129] The fourth constraint is expressed as:

[0130]

[0131] Among them, Tra k ={s k ,des k ,v k ,t k ,o k} represents the k-th transaction; s within it k Indicates the node that sent the transaction; des k Indicates the receiving node of the transaction; v k Indicates the amount of the transaction; t k Indicates the time when the transaction occurred; o k Indicates the maximum buffer time for a transaction; t s t l o s o l v s v l s s s l Let represent the cases where k takes the values ​​s and l, respectively, and let l represent the parameters corresponding to the s-th and l-th transactions.

[0132] (6) Taking the maximization of standardized throughput as the optimization objective, and using the first, second, third and fourth constraints as constraints, the transaction scheduling problem in the buffer of both parties is expressed as a linear 0 / 1 integer programming problem, and the transaction scheduling optimization problem is modeled.

[0133] As can be seen, in the process of modeling the transaction scheduling problem, this embodiment of the invention specifically sets maximizing the network's transaction throughput as the optimization objective under the constraint that the channel capacity needs to meet the transaction execution conditions. It prioritizes executing transactions closest to the maximum buffer time to reduce the average waiting time of transactions in the buffer, thus representing the problem as a linear 0 / 1 integer programming problem. Therefore, this embodiment of the invention models the transaction scheduling optimization problem by simultaneously considering maximizing standardized throughput and reducing the average waiting time of transactions in the buffer.

[0134] In one optional implementation, the efficient scheduling method for blockchain payment channel network transactions further includes:

[0135] We prove that the payment channel network transaction scheduling problem is an NP-hard problem.

[0136] In this embodiment of the invention, the defined PSP problem is proven to be an NP-hard problem by reducing the Bilevel Knapsack Problem (BKP).

[0137] Specifically, an example of proving the BKP problem is given a knapsack with capacity C and a set of items R = {r1, r2, ..., r...}. n}, where R represents a series of items, r n This represents the nth item, and each item is represented by (w k ,v k ) indicates that w k v represents the volume of an item. k Let L represent the value of each item. The goal of the BKP problem is to find a subset L ∈ R such that the sum of the values ​​of the items in the subset is maximized and the sum of their volumes does not exceed the capacity of the knapsack. Each item can only be selected once.

[0138]

[0139]

[0140]

[0141] Where, x i It is a binary variable, representing whether the i-th item belongs to subset L (if x ∈ L). i If x ∈ L, then x i =1 otherwise x i =0).

[0142] The BKP problem is a special case of the PSP problem. Specifically, when all transactions in the PSP problem are sent from A to B, the objective of this embodiment is to select a subset of transactions from the set of transactions, maximizing the total amount of transactions in the subset without exceeding the initial capacity of channel A. This embodiment assumes that each item in the BKP problem corresponds to a transaction in the PSP problem, the item's volume and value correspond to the transaction amount, and the knapsack capacity corresponds to the initial capacity of channel A. This maps the PSP problem to the BKP problem. That is, if X is the optimal solution to the BKP problem, it is also necessarily the optimal solution to the PSP problem, and vice versa.

[0143] Therefore, the PSP problem when all transaction senders are from the same node can be reduced by the BKP problem. Since the BKP problem is NP-complete, the PSP problem when all transaction senders are from the same node is also NP-complete, meaning the PSP problem is NP-hard.

[0144] Since the PSP is NP-hard and has a huge search space, it is difficult to solve the PSP using traditional optimization methods.

[0145] To solve the PSP in polynomial time, this invention presents a neural network solver, including an encoder model and a decoder model (i.e., Figure 3 The neural network model (including an encoder and a decoder) outputs the optimal sorted subset of the problem, i.e., the transaction sequence, in a self-iterative manner. In this embodiment, the encoder model distinguishes between static and dynamic features, which reduces computational complexity. Then, the decoder model utilizes an attention mechanism to improve the quality of the subset and a masking mechanism to ensure the feasibility of the subset. Furthermore, considering the difficulty of training the solver by generating a large number of optimal samples, this embodiment uses reinforcement learning, training the neural network solver through operations such as gradient and weight updates. The following steps S2 and S3 will be described in detail.

[0146] S2, for the transaction scheduling optimization problem, the execution node uses the encoder model to extract the static and dynamic features of each transaction in the buffer of both parties in the current input sequence, obtains the encoder output vector corresponding to each transaction, and merges them to form the encoder output sequence;

[0147] In one optional implementation, S2 may include the following steps:

[0148] S21, for the current input sequence, obtain the Tra for each transaction. k tuple sequence

[0149] Specifically, this embodiment of the invention designs an encoder model to extract features from all transactions. Since the features of the input transactions change as the decision-making process progresses, the embedding vector of the input sequence needs to be recalculated and the decoder model updated after each decision step.

[0150] To reduce computational complexity, this embodiment of the invention distinguishes transaction features into static features and dynamic features. Formally, this is represented by a sequence of tuples. Indicates each transaction Tra k , where b k and d k t represents the transaction Tra k Its static and dynamic characteristics.

[0151] Specifically, b k =(s k ,v k ,o k As a transaction Tra k Static characteristics, s k v k o k Representing the transaction Tra k The sending node, transaction amount, and maximum buffer time; As a trading platform k The dynamic characteristics at the t-th decision step, where This represents the remaining amount of the transaction at the t-th decision step. If the transaction is selected at decision step t-1, then ); and This represents the capacity of the channels of node A and node B at the t-th decision step, as described above. This represents the capacity of channel A at the time of transaction t. This represents the capacity of channel B at the time of transaction t.

[0152] Traditional pointer networks use RNNs as encoders. RNNs excel at extracting temporal information from input sequences and are sensitive to the order of the input sequence. However, in the scenario of this invention, there is no meaningful order information between input transactions; any random permutation of a transaction set has the same information as the original input. Therefore, this invention adopts the Transformer architecture to design an encoder model that does not use positional encoding, thus ensuring that the resulting node embedding vectors are invariant to the input order. Specifically, the encoder model of this invention includes an embedding layer, an attention layer, a normalization layer, and a feedforward network layer. The embedding layer can be a fully connected layer. The input to the encoder model is the transaction Tra. kIt has all the features, but the processing methods are different for static features and dynamic features.

[0153] S22, the static features are sequentially passed through the embedding layer, attention layer, normalization layer and feedforward network layer of the encoder model to obtain a d-dimensional embedding vector as the static feature embedding vector.

[0154] The encoder model is designed based on the Transformer architecture.

[0155] Specifically, trading Tra k In the process of obtaining the static feature embedding vector, the outputs of the embedding layer, attention layer, normalization layer, and feedforward network layer are as follows:

[0156]

[0157]

[0158]

[0159]

[0160]

[0161] Among them, γ, β, and each W with a subscript x p x These are the model parameters corresponding to the encoder; head i ∈ is the attention score; ∈ is a predefined constant.

[0162] S23, the dynamic features are extended to d dimensions by passing only through the embedding layer of the encoder model to obtain the dynamic feature embedding vector;

[0163] Specifically, trading Tra k The dynamic feature embedding vector is:

[0164]

[0165] Among them, W x p x These are the model parameters corresponding to the encoder.

[0166] Furthermore, S22 and S23 can be performed simultaneously or in any order.

[0167] S24, will trade Tra k The obtained static feature embedding vector and dynamic feature embedding vector are concatenated to obtain the transaction Tra. k The corresponding encoder output vector The encoder output sequence is obtained by merging the encoder output vectors corresponding to all transactions in the current input sequence.

[0168] Among them, the transaction Tra k The corresponding encoder output vector for: It is understandable that the encoder output sequence can be represented as

[0169] It is important to note that since static features do not change throughout the entire sequence decision process, the embedding vector of static features only needs to be calculated at the initial stage.

[0170] S3, the execution node uses the decoder model, based on the attention mechanism and masking mechanism, to make transaction order decisions on the currently obtained encoder output sequence in a self-iterative manner. After continuous iteration, it outputs a transaction sequence that represents the transaction order in the buffers of both parties, so as to schedule the two parties to complete the transaction in the order of the transaction sequence.

[0171] The encoder and decoder models were pre-trained based on reinforcement learning. The corresponding training process will be explained later.

[0172] In one optional implementation, S3 may include the following steps:

[0173] S31, the execution node uses the decoder model to output the hidden state h containing previous knowledge at each decision step t. t ;

[0174] In each decoding step t, which is also the decision step t, this embodiment of the invention uses the conditional probability P. θ (π t |·) Selects transactions in a self-iterative manner, P θ (π t |·) is calculated from the output of the encoder model and the context of the decoder model.

[0175] The decoder model is built upon LSTM. At each decision step t, the LSTM unit outputs the hidden state h containing previous knowledge. t Regarding h t For the concept and acquisition process, please refer to the relevant technical explanations; they will not be described in detail here.

[0176] S32, utilizing an attention mechanism, based on h t and the currently obtained encoder output sequence When determining the t-th decision step, h t Relevant scores for all transactions;

[0177] The decoder model in this embodiment of the invention utilizes an attention mechanism, based on h t and encoder output sequence Calculate the transaction selected in the current decision step.

[0178] The attention mechanism helps the decoder model assign different weights to different elements of the input. It can inform the input element et at the current decision step t. k With the context h of the decoder model t The relationship between them.

[0179] The formulas used in the S32 calculation process include:

[0180]

[0181] a t =softmax(n t )

[0182]

[0183]

[0184] Among them, W a , W c , These are the weight parameters that the decoder model needs to learn; n t a t c t It is an intermediate vector in the calculation process; When h is the t-th decision step t Relevant scores for all transactions.

[0185] S33, under the rules of transaction selection constrained by the masking mechanism, the relevant scores of the obtained transactions are calculated using softmax to obtain the conditional probability P at the t-th decision step. θ (π t |·), and use this probability to select a transaction Tra k The sequence element π is the output of the current decision step in the transaction sequence. t ;

[0186] Specifically, the conditional probability can be calculated from the relevant scores using softmax:

[0187]

[0188] Where X represents all transactions in the input model; π t Represents the sequence elements output at the current decision step t; π0,...,π t-1This represents the sequence element output by the corresponding decision step in the previous step.

[0189] Since not all transactions are allowed to be selected at decision step t, this corresponds to the constraint in the PSP problem of this invention, where invalid transactions lead to infeasible solutions. To ensure the feasibility of the solution, this invention uses a mask method to constrain transaction selection. This method sets the log-conditional probability of infeasible transactions to -∞. Specifically, this invention uses a masking mechanism to constrain the rules for transaction selection. The rules for constraining transaction selection using the masking mechanism include:

[0190] ①If the transaction If a transaction has been selected, then selecting that transaction is not allowed.

[0191] ② Transactions whose current channel capacity does not meet the execution conditions are not allowed to be selected (i.e., the current channel capacity is less than the transaction amount);

[0192] ③ When the transaction amounts are equal and the transaction sending nodes are the same, if the transaction closer to the maximum buffer time has not yet been executed, then the transaction farther from the maximum buffer time is not allowed to be selected.

[0193] ④ Termination is only permitted when all transactions fail to meet the execution conditions.

[0194] The conditional probability P at decision step t was obtained through the decoder model. θ (π t |·), This embodiment of the invention utilizes this probability to select the transaction Tra k As a sequence element π t .

[0195] S34. Using the obtained sequence elements and encoder model, recalculate the embedding vector of the input sequence to update the input of the decoder model to obtain new sequence elements. Repeat the iterative process corresponding to the multi-step decision and output the transaction sequence corresponding to the input sequence, representing the transaction order in the buffers of both parties, based on all the obtained sequence elements.

[0196] Specifically, the decoder model will take the currently obtained sequence element π t The input sequence is passed to the encoder model, which updates the dynamic features of the transactions in the current input sequence, resulting in a new encoder output sequence. The decoder model then uses this new encoder output sequence to make another decision, thus obtaining another sequence element. This iterative process of multi-step decision-making is repeated to continuously obtain sequence elements. From all the obtained sequence elements, a transaction sequence T = {π1, π2, ..., π} corresponding to the input sequence is obtained. n}

[0197] The following provides supplementary explanations of the model training process for the encoder and decoder models.

[0198] In traditional supervised machine learning, network parameters can be trained using the cross-entropy between output probabilities and training samples as a loss function. However, this supervised learning method is unsuitable for solving the PSP (Problem Solving) problem because the PSP is an NP-hard problem, and generating a large number of optimal solutions as training samples requires a significant amount of time, making this method impractical. Unlike supervised learning, reinforcement learning does not rely on optimal solutions; it learns better policies by learning rewards and penalties. Therefore, this embodiment of the invention uses reinforcement learning to train network parameters. The states, actions, rewards, and training of the reinforcement learning algorithm will be described below.

[0199] 1) State (S): The state includes all transactions in the buffer and the capacity of the channel at decision step t.

[0200] 2) Action (A): In this embodiment of the invention, the action is defined as the transaction selected at the current decision step t.

[0201] 3) Reward (R): In this embodiment of the invention, the reward is set as a negative number of the defined network normalized throughput.

[0202] 4) Training: The training objective of this embodiment is to find training parameters θ that maximize the expected reward, i.e.:

[0203]

[0204] in, It indicates the expectation of a reward.

[0205] Given the system state S (all transactions in the buffer and the initial amount of the channel), it can be written as:

[0206]

[0207] Where J(θ|S) represents the expected reward given system state S and model parameters θ; R(π|S) represents the reward obtained by taking action π in system state S; π~p θ (·|S) represents the action following the probability distribution p. θ Sampling is performed in (·|S).

[0208] During training, training samples can be obtained from a distribution P, which randomly generates the initial system state S for each sample. The overall training objective involves Monte Carlo sampling from distribution P:

[0209] J(θ)=E S~P[J(θ|S)]

[0210] Where J(θ) represents the expected reward when the model parameter is θ; E S~P [J(θ|S)] represents the initial state S of the system generated by sampling from distribution P, and the expected reward of these samples.

[0211] This invention employs policy gradient descent and stochastic gradient descent to train model parameters. The gradient can be represented using the advantage actor-critic algorithm as follows:

[0212]

[0213] Here, b(S) is a baseline function used to estimate the expected reward in state S to reduce the variance of the training samples. θ (π|S) represents the probability of taking action π in state S when the model parameters are θ; the gradient function can be approximated by Monte Carlo sampling as follows:

[0214]

[0215] Where B is the number of samples, and the sample sizes are S1, S2, ..., S... B ~P, π i ~p θ (·|S i This invention utilizes the neural network (also called an Actor network, i.e., the entire neural network model obtained by combining an encoder model and a decoder model) proposed above to calculate p. θ (·|S i Then, an auxiliary neural network (also called a Critic network) is constructed to compute b(S). The Critic network first obtains the embedding vector of the input transaction using the same encoder model as the Actor network, and then uses two fully connected ReLU layers to decode and output an estimate of b(S).

[0216] This invention employs the advantage actor-critic (A2C) algorithm to train the Actor network and Critic network. First, B samples are sampled from P, and then the model parameters θ and... The process involves iterative updates, where in each iteration, the Actor network is used to obtain the log-conditional probability of each system state S. in This represents the action of the nth sample at the (t+1)th decision step. Let R represent the state of the nth sample at the t-th decision step, and calculate the corresponding reward R using a Critic network. and in S represents the state of the nth sample. t+1 The value of the following S represents the state of the nth sample. t The value of the Actor network is then calculated. Finally, the gradient of the Actor network is calculated as follows:

[0217]

[0218] The gradient of the Critic network is calculated from the mean squared error:

[0219]

[0220] Finally, the Adam optimizer is used to update the model parameters. The algorithm terminates when it reaches the predefined maximum number of iterations.

[0221] For an understanding of the above training process, please refer to the existing reinforcement learning network training process; it will not be explained in detail here.

[0222] In the solution provided by this invention, a payment channel network transaction scheduling problem is first defined. Under the condition that the nodes of both parties select the execution transaction scheduling strategy, the execution node sets multiple constraints with the goal of maximizing network throughput, and models the transaction scheduling problem in the buffers of both parties, thus obtaining the transaction scheduling optimization problem. Then, for the transaction scheduling optimization problem, the execution node uses an encoder model to extract the static and dynamic features of each transaction in the buffers of both parties in the current input sequence, obtains the encoder output vector corresponding to each transaction, and merges them to form the encoder output sequence. The execution node uses a decoder model, based on attention mechanism and masking mechanism, to make transaction order decisions on the currently obtained encoder output sequence in a self-iterative manner. After continuous iteration, it outputs a transaction sequence representing the transaction order in the buffers of both parties, so as to schedule the two parties to complete the transaction in the order of the transaction sequence.

[0223] The method of this invention introduces a buffer in the payment channel network, enabling the modeling of the transaction scheduling problem within the buffer by both parties. An encoder and decoder model are then used to solve the resulting transaction scheduling optimization problem, achieving reasonable scheduling of transactions within the buffer. Since the transaction scheduling optimization problem aims to maximize network throughput, and at least one of the constraints is related to the average transaction waiting time, it can improve throughput under flexible and variable transaction amounts while simultaneously reducing the average transaction waiting time.

[0224] Furthermore, this embodiment of the invention also proves that the transaction scheduling problem of the payment channel network is an NP-hard problem, and then selects the architecture combining the encoder model and decoder model of this embodiment of the invention to solve the problem. The encoder model and decoder model of this embodiment of the invention are based on the Seq2Seq architecture design, and based on the encoder and decoder, this embodiment of the invention designs two scheduling strategies: periodic scheduling and selective scheduling. The encoder model is used to process the features of transactions, and the decoder model is used to determine the execution order of transactions. In the encoder model, to reduce computational complexity, this embodiment of the invention distinguishes between static features and dynamic features. Dynamic features only need to undergo one round of encoding in the entire decision-making process. In the decoder model, this embodiment of the invention introduces an attention mechanism to output the optimal ordered subset of transactions, i.e., the transaction sequence, in an autoregressive manner. In addition, considering the difficulty in generating high-quality training samples, this embodiment of the invention defines corresponding states, actions, and value functions, and designs a reinforcement learning algorithm to train the decoder model and encoder model.

[0225] To test and highlight the advantages of the proposed solution in this invention, experiments are conducted on multiple indicators of the proposed solution, and the experimental results are compared with the best and most advanced technologies in existing work. In this part of the experiment, a payment channel is set between node A and node B, with a total capacity of 100. The initial channel capacity is randomly assigned to A and B. The arrival of transactions between the two parties follows a Poisson distribution with a Poisson parameter of 1. The specific experimental details are as follows.

[0226] (1) Comparison scheme: For comparison purposes, the following scheme was used in this experiment:

[0227] FCFS: FCFS is the most widely used scheduling strategy in payment channel networks. It is easy to understand and implement. FCFS processes transactions in the order they arrive, executing a transaction only if the corresponding channel balance is greater than the transaction amount.

[0228] PMDE: PMDE is the most advanced scheduling strategy in payment channel networks. It uses a buffer to cache transactions. It uses transactions in the opposite direction to satisfy the required execution conditions.

[0229] (2) Comparison indicators: The following indicators were used for testing in this experiment:

[0230] Normalized throughput: Normalized throughput is defined as the sum of all transactions generated that are successfully completed.

[0231] Success rate: Success rate is defined as the number of completed transactions exceeding the number of generated transactions.

[0232] Average waiting time: Average waiting time is defined as the time it takes for a transaction to arrive at the node before it begins execution.

[0233] ① Network Throughput: To evaluate the performance of the scheduling method of this embodiment under any transaction amount, three experiments were conducted, assuming that the transaction amount follows: (1) a uniform distribution from 0 to 100; (2) a Gaussian distribution with a mean of 50 and a variance of 25; and (3) an empirical distribution randomly sampled from a real credit card transaction dataset. Figure 4 shows the changes in network throughput of the two scheduling strategies, PCPS and PCCS, under the three distributions as the transaction scheduling time interval (checkpoint) increases. Figures 4(a), 4(b), and 4(c) correspond to the three distributions mentioned above, respectively. It can be seen that the PCPS and PCCS scheduling strategies of this embodiment can achieve the best network throughput under the three distributions, which demonstrates the superiority of the scheduling strategy of this embodiment. When the transaction amount follows a uniform distribution from 0 to 100, compared with PMDE, the scheduling strategy of this embodiment improves by 60%. This is because PMDE is difficult to achieve good results for transactions with large amounts, but under the strategy of this embodiment, transactions of various amounts can be effectively scheduled, which will be explained by experiments later. Furthermore, under all three distributions, the PCPS scheduling strategy is slightly better than the PCCS scheduling strategy. This is because under PCPS, regardless of whether a currently arriving transaction can be executed, it will be buffered in the buffer and await unified scheduling. Under PCCS, however, a transaction is only buffered in the buffer if it cannot be executed immediately. In other words, buffering transactions that can be executed immediately increases network throughput. Additionally, this embodiment of the invention found that as the checkpoint increases moderately, the standard network throughput also improves; however, when the checkpoint is too large, the standard network throughput decreases. This is because as the checkpoint increases, the cumulative number of transactions in the buffer increases with each scheduling, making it more likely to find other transactions that allow the channel capacity to meet the current transaction's execution conditions. However, when the checkpoint is too large, a longer waiting time is required before scheduling transactions in the buffer, and many transactions exceed the maximum buffer time and are discarded while waiting for scheduling, which reduces network throughput.

[0234] ② Average Transaction Waiting Time: Next, this embodiment of the invention evaluated the impact of the proposed scheduling strategy on the average waiting time of transactions in the buffer. In this embodiment, the transaction amount follows a uniform distribution from 0 to 100, with other settings remaining the same as in previous experiments. The checkpoint size was varied, and the average waiting time required for a transaction to be successfully executed from its creation was tested under different scheduling strategies. The results are as follows: Figure 5As shown, under the First-Come, First-Served (FCFS) strategy, the average transaction waiting time is 0 because there is no buffer under the FCFS strategy, and transactions are executed immediately. Furthermore, it can be seen that the average transaction waiting time under the scheduling strategies PCPS and PCCS of this embodiment is lower than that under PMDE. This is because under PMDE, most transactions are only executed when the maximum buffer time is reached, resulting in an excessively long average transaction waiting time. Under the scheduling strategies of this embodiment, through a periodic scanning mechanism, transactions may be executed without waiting for the maximum buffer time. As expected in this embodiment, the average transaction waiting time under PCCS is lower than that under PCPS because under the PCCS scheduling strategy, some transactions do not need to wait in the buffer but can be executed immediately, which significantly reduces the average transaction waiting time. Moreover, this embodiment found that as the checkpoint increases, the average transaction waiting time also increases. This is because the size of the checkpoint determines the frequency of periodic buffer scanning in this embodiment; transactions with larger checkpoints require a longer waiting time before being scheduled.

[0235] ③ Transaction Success Rate: This section evaluates the impact of the scheduling strategy in this embodiment of the invention on the transaction success rate. The results are shown in Figure 6. Figures 6(a) to 6(c) These correspond to the three distributions mentioned above. It can be seen that when the transaction amount follows a uniform distribution between 0 and 100, the FCFS and PMDE transaction success rates are low. When the transaction amount follows an empirical distribution sampled from a real credit card dataset, the FCFS and PMDE transaction success rates improve. The PCPS and PCCS scheduling strategies of this embodiment maintain the highest transaction success rates under all three distributions. This is because when the transaction amount follows an empirical distribution sampled from a real credit card dataset, most transactions are small. When the transaction amount follows a uniform distribution between 0 and 100, the proportion of large-amount transactions increases. As mentioned earlier, the FCFS and PMDE strategies are effective for the successful execution of small-amount transactions, but ineffective for the successful execution of large-amount transactions. Figure 7 This also confirms the conclusions of the embodiments of the present invention. To evaluate the impact of the scheduling strategy on transactions of different amounts, the embodiments of the present invention divide transactions into five intervals based on transaction amount: [0, 20], (20-40], (40-60], (60-80], and (80-100]. The embodiments of the present invention set the transaction amount to follow a uniform distribution between 0 and 100, with a checkpoint of 40 seconds in the PCPS and PCCS strategies, generating one transaction every 2 seconds, and the experiment running for a total of 2000 seconds. Figure 7This demonstrates the probability of successful transaction execution across different timeframes. It can be seen that the buffer increases the probability of successful execution for large-amount transactions, and the solution in this embodiment further enhances this probability. For smaller transactions, the strategy in this embodiment only slightly increases their probability of successful execution, because even without the buffer, small-amount transactions have a high probability of successful execution. It is important to note that the transaction amount here depends on the relative size of the transaction itself and the channel capacity.

Claims

1. A highly efficient scheduling method for blockchain payment channel network transactions, characterized in that, include: A payment channel network transaction scheduling problem is defined. Given that both parties select a transaction scheduling strategy, the executing node aims to maximize network throughput. Multiple constraints are set to model the transaction scheduling problem within the buffers of both parties, resulting in a transaction scheduling optimization problem. The selected transaction scheduling strategy includes either a periodic scheduling strategy or a conditional scheduling strategy. The executing node includes any node from either party. At least one constraint is related to the average waiting time of the transaction. To address the transaction scheduling optimization problem, the execution node uses an encoder model to extract the static and dynamic features of each transaction in the buffers of both parties in the current input sequence, obtains the encoder output vector corresponding to each transaction, and merges them to form the encoder output sequence. The execution node utilizes a decoder model, based on attention and masking mechanisms, to iteratively determine the transaction order of the currently obtained encoder output sequence. After continuous iteration, it outputs a transaction sequence representing the transaction order within the buffers of both parties, so as to schedule the two parties to complete the transaction in the order of the transaction sequence. The encoder model and the decoder model are pre-trained based on reinforcement learning. The execution node utilizes the decoder model, based on attention and masking mechanisms, to iteratively determine the transaction order of the currently obtained encoder output sequence, and after continuous iteration, outputs a transaction sequence representing the transaction order within the buffers of both parties, including: The execution node utilizes the decoder model at each decision step. Output the hidden state containing previous knowledge. The decoder model is constructed based on LSTM. Utilizing attention mechanisms, based on and the currently obtained encoder output sequence Determine the first At each decision-making step Relevant scores for all transactions; It is a transaction The corresponding encoder output vector; Under the rules of transaction selection constrained by the masking mechanism, the relevant scores of the obtained transactions are calculated using softmax to obtain the first... The conditional probability at each decision step And use that probability to select a transaction. Sequence element as the output of the current decision step in the transaction sequence ; Using the obtained sequence elements and the encoder model, the embedding vector of the input sequence is recalculated to update the input of the decoder model to obtain new sequence elements. The iterative process corresponding to the multi-step decision is repeated, and based on all the obtained sequence elements, a transaction sequence corresponding to the input sequence and representing the transaction order in the buffers of both parties is output.

2. The efficient scheduling method for blockchain payment channel network transactions according to claim 1, characterized in that, The basis for selecting the transaction scheduling strategy to be executed by both parties in the transaction is timeliness; when the timeliness requirement is low, both parties in the transaction choose to execute the periodic scheduling strategy; when the timeliness requirement is high, both parties in the transaction choose to execute the conditional scheduling strategy.

3. The efficient scheduling method for blockchain payment channel network transactions according to claim 1 or 2, characterized in that, The execution node aims to maximize network throughput and sets multiple constraints to model the transaction scheduling problem within the buffers of both parties, resulting in a transaction scheduling optimization problem, including: Measure network throughput using standardized throughput; The first constraint is established by setting that each sequence can only execute one transaction and each transaction can only be executed once. A second constraint is established: the transaction will only be executed if the capacity of the corresponding payment channel is greater than the transaction amount. To establish a third constraint, once a transaction is successfully executed, the channel capacity in the direction of the transaction execution needs to be increased, while the channel capacity in the opposite direction needs to be decreased by the same amount. If the direction and amount of transactions are the same, the transaction closer to the maximum buffer time will be executed first, in order to reduce the average waiting time of transactions in the buffer, thus constructing a fourth constraint. With the goal of maximizing the standardized throughput, and with the first, second, third, and fourth constraints as constraints, the transaction scheduling problem within the buffers of both parties is represented as a linear 0 / 1 integer programming problem, and the transaction scheduling optimization problem is modeled.

4. The efficient scheduling method for blockchain payment channel network transactions according to claim 3, characterized in that, The standardized throughput is expressed as: in, This represents the standardized throughput; express Buffer; express Buffer; express Buffer and Total number of transactions in the buffer zone; Indicates the time when the transaction occurred; Indicates the first One transaction; Indicates the first Is this transaction the first One execution; Indicates the first The amount of the transaction; and Given a binary decision variable, if Then it means the first The first transaction One execution, otherwise ; The first constraint condition is expressed as: The second constraint is expressed as follows: in, Indicates the first Node when the transaction is executed Channel capacity; Indicates the first Node when the transaction is executed Channel capacity; The third constraint condition is expressed as follows: The fourth constraint condition is expressed as follows: in, Indicates the first This transaction; within Indicates the node that sent the transaction; Indicates the node receiving the transaction; Indicates the amount of the transaction; Indicates the time when the transaction occurred; Indicates the maximum buffer time for a transaction; , , , , , , , , , They are respectively Pick and The situation indicates the first and The parameters corresponding to this transaction.

5. The efficient scheduling method for blockchain payment channel network transactions according to claim 4, characterized in that, Regarding the transaction scheduling optimization problem, the execution node uses an encoder model to extract the static and dynamic features of each transaction in the buffers of both parties in the current input sequence, obtains the encoder output vector corresponding to each transaction, and merges them to form the encoder output sequence, including: For the current input sequence, obtain each transaction. tuple sequence ;in, As a transaction Static characteristics; As a transaction In the Dynamic characteristics at each decision step Indicates the first The remaining amount of the transaction at each decision step. and Indicates the first t Each decision-making step node and nodes The channel capacity; the static features are sequentially passed through the embedding layer, attention layer, normalization layer, and feedforward network layer of the encoder model to obtain a... The dimensional embedding vector is used as the static feature embedding vector; wherein, the encoder model is designed based on the Transformer architecture; The dynamic features are extended by passing them only through the embedding layer of the encoder model. Dimension, to obtain dynamic feature embedding vector; The transaction The obtained static feature embedding vector and dynamic feature embedding vector are concatenated to obtain the transaction. The corresponding encoder output vector The encoder output sequence is obtained by merging the encoder output vectors corresponding to all transactions in the current input sequence.

6. The efficient scheduling method for blockchain payment channel network transactions according to claim 5, characterized in that, trade In the process of obtaining the static feature embedding vector, the outputs of the embedding layer, attention layer, normalization layer, and feedforward network layer are as follows: trade The static feature embedding vector is: trade The dynamic feature embedding vector is: Correspondingly, transactions The corresponding encoder output vector for: ; in, , and each with subscript , These are the model parameters corresponding to the encoder; It is the attention score; It is a preset constant.

7. The efficient scheduling method for blockchain payment channel network transactions according to claim 6, characterized in that, The use of attention mechanism, based on and the currently obtained encoder output sequence Determine the first At each decision-making step The formula used in the process of scoring all transactions is... include: in, , , , These are the weight parameters that the decoder model needs to learn; , , It is an intermediate vector in the calculation process; It is the first Each decision step Relevant scores for all transactions.

8. The efficient scheduling method for blockchain payment channel network transactions according to claim 7, characterized in that, The masking mechanism constrains the rules for transaction selection, including: If the transaction =0 means that the transaction has been selected, and therefore the selected transaction cannot be selected again; Transactions that do not meet the execution conditions due to the current channel capacity are not allowed to be selected; When transaction amounts are equal and the transaction sending nodes are the same, if the transaction closer to the maximum buffer time has not yet been executed, then the transaction farther from the maximum buffer time is not allowed to be selected. Termination is only permitted when all transactions fail to meet the execution conditions.

9. The efficient scheduling method for blockchain payment channel network transactions according to claim 8, characterized in that, The method further includes: We prove that the payment channel network transaction scheduling problem is an NP-hard problem.