Payment Channel Network Routing Method and System for Lightweight Nodes
By clustering the payment channel network and optimizing the routing method, the storage and computing overhead of lightweight nodes is solved, the scalability and throughput of the network are improved, channel congestion is avoided, and efficient payment routing is achieved.
Patent Information
- Application Number
- CN202510335781.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-03-20
AI Technical Summary
The existing payment channel network routing method has excessive overhead for lightweight node storage and computing, and channel congestion leads to reduced network throughput.
The payment channel network is divided into several clusters. Each node only stores the topological information of its cluster. The Yen’s algorithm is used to calculate multiple shortest circuits, and the payment amount is determined by minimizing the channel congestion level, eliminating unnecessary storage and calculation loads.
Reduces node storage and computing overhead, improves network scalability and throughput, avoids channel congestion, and improves payment success rate.
Smart Images

Figure CN120128521B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to online payment technology, and specifically relates to a payment channel network routing method and system for lightweight nodes. Background Art
[0002] Currently, the payment channel network is the most promising and already practically implemented solution to solve the scalability problem of blockchain technology. A payment channel allows two users to transfer a transaction on the blockchain to be executed off-chain. Any transaction between two users connected by a payment channel does not need to be submitted to the chain for global consensus. The payment channel only needs to change the balance status of the two end users to complete the transaction between the two end users. Only the transactions for creating and closing the payment channel need to be submitted to the chain. Therefore, the payment channel can significantly reduce the number of transactions on the blockchain, thereby solving the scalability problem of blockchain technology.
[0003] Currently, if there is no direct payment channel between the payer and the payee, their transactions need to rely on the forwarding of several intermediary users in the payment channel network, and this process is called payment routing. In the payment channel network, users discover the payment route through their routing tables. Since the payment channel network is a decentralized network, whether the intermediary users assist in forwarding the payment is entirely determined by the intermediary nodes themselves. To incentivize the intermediary nodes to forward the payment, the payer in the payment channel network usually pays a certain forwarding fee to the intermediary nodes. Therefore, when the balance of each channel on the payment path can cover the payment amount and the forwarding fees charged by the subsequent intermediary users, the payment between the payer and the payee without a direct payment channel will be successful. If the balance in one direction of the payment channel is exhausted, the channel will not be able to initiate or forward more payments in that direction.
[0004] There are two major problems in the current payment channel network routing: (1) The scalability of the payment channel network is often overlooked. Since the payment channel network is a decentralized network and the routing adopts the source routing strategy, it means that the payment routing needs to be calculated by the payer himself. Most existing routing protocols require nodes to store and maintain the whole network topology in their routing tables to implement source routing. This approach brings a relatively large storage overhead to nodes, especially lightweight nodes such as Internet of Things devices. Moreover, the larger the routing table, the greater the computational overhead required for the node to find a suitable payment route. And because the nodes in the payment channel network need to maintain the latest topology information through the Gossip protocol and blockchain query, the larger the routing table, the more information needs to be maintained, and thus more communication overhead is required. (2) Designing a high-throughput routing method for lightweight nodes is a major challenge. A successful payment will change the balance distribution state of the channel. The balance in the payment transmission direction of the channel increases, and the balance in the opposite direction of the payment transmission decreases. If a channel is frequently used in a certain direction, its balance will be quickly exhausted and fall into a congestion state, and finally the payments being transmitted and to be transmitted in this direction will end in failure. Therefore, channel congestion affects the throughput of the payment channel network. Summary of the Invention
[0005] In view of the above deficiencies in the prior art, the payment channel network routing method and system for lightweight nodes provided by the present invention solve the problem of large communication overhead of the existing routing method.
[0006] In order to achieve the above invention purpose, the technical solution adopted by the present invention is as follows:
[0007] In the first aspect, a payment channel network routing method for lightweight nodes is provided, which includes:
[0008] S1. Initialize the payment channel network, divide it into several clusters through a clustering algorithm, and after the division, each node stores the cluster network composed of the topology of its own cluster and the connection relationship between clusters;
[0009] S2. When a payment request is initiated, the payer node detects the topology of the relay cluster connecting its own cluster and the cluster where the payee node is located. When the payee node and the payer node are not in the same cluster, detect the topology of the cluster where the payer node is located;
[0010] S3. According to the payment channel network topology response mechanism, the payer node obtains the channel information of the relay cluster between its own cluster and the cluster where the payee node is located and the channel balance of the node that receives the topology detection request;
[0011] S4. The payer node calculates multiple shortest paths from the payer node to the payee node using Yen's algorithm according to its routing table and the detected topology, and forms a path set is a set of reverse paths of multiple shortest paths;
[0012] S5. Determine whether there is a minimum value based on the channel balance. and The payment amount transmitted on multiple shortest paths when the channel congestion level is the maximum after transmitting the payment or sub-payment.
[0013] S6. When there are no payment amounts transmitted on multiple shortest paths, the payment fails and the algorithm terminates. When there are payment amounts transmitted on multiple shortest paths, if there is a path among the multiple shortest paths that meets the real payment channel network constraints, the payment is made; otherwise, the payment fails and the algorithm terminates.
[0014] Furthermore, the method of dividing the payment channel network into several clusters includes:
[0015] S11. At the initial moment of the payment channel network, each node forms a separate cluster, and each node acts as a cluster information proxy (CIP) for its cluster.
[0016] S12, the node determines whether it is the CIP of the cluster, if so, it initializes the queue If not, stop the clustering algorithm;
[0017] S13: The node sends the topology of its cluster to all nodes in its cluster to update the routing table, and also sends the topology of its cluster to neighboring clusters.
[0018] S14, receiving topology information from all neighboring clusters, and calculating the change in the routing table size after merging it with each neighboring cluster, and adding it to the priority queue Q when the change is greater than zero;
[0019] S15, determine whether Q is empty, if so, end the clustering algorithm, otherwise move to the neighboring cluster c corresponding to the maximum change in Q l The CIP sends a merge message;
[0020] S16, when receiving the neighboring cluster c l Create a merge message, send a rejection merge message to other neighboring clusters in Q, and merge its cluster with the neighboring cluster c l Merge, select the CIP of the merged cluster, and each node in the cluster returns to step S12;
[0021] S17, when no neighbor cluster c is received l The cluster in Q that sends the merge creation message waits until receiving a merge rejection message from another cluster in Q, then deletes the cluster in Q that sends the merge rejection message, and then returns to step S15.
[0022] The beneficial effects of the above technical solution are as follows: In this solution, the payment channel network is divided into several clusters. Each node in a cluster only needs to store the channel information of its own cluster, avoiding the traditional single node storing the channel information of the entire network, significantly reducing the storage overhead required for nodes to store channel information and the communication overhead required for nodes to maintain channel information.
[0023] Furthermore, the expression for calculating the change amount of the routing table size assuming its merger with each adjacent cluster is:
[0024]
[0025] where, ΔS is the change amount of the routing table size after the merger of cluster C(v i ) and cluster C(v j ); C(v i ) and C(v j ) are the clusters where nodes v i and v j are located respectively; c’ is the cluster after the merger of cluster C(v i ) and cluster C(v j ); |L| and |L’| are the total numbers of directed edges in cluster C(v i ) and cluster c’ respectively; |V c′ | are the numbers of nodes in cluster C(v i ), cluster C(v j ), and cluster c’ respectively; |E c′ | are the numbers of directed edges owned by the nodes in cluster C(v i ), cluster C(v j ), and cluster c’ respectively.
[0026] Furthermore, step S2 further includes:
[0027] S21. The payment node calculates its payment success rate r suc , and determines whether the payment node and the receiving node are in the same cluster. If so, it proceeds to step S22; otherwise, it proceeds to step S25;
[0028] S22. The payment node generates a random number rand that follows a uniform distribution on [0, 1];
[0029] S23. Determine whether the conditions rand ≤ min(2(1 - r suc ), 1), the number of detected adjacent clusters is less than the upper limit, and there exists an undetected adjacent cluster are satisfied. If so, it proceeds to step S24; otherwise, it proceeds to step S3;
[0030] S24. Randomly select an unprobed neighboring cluster to send a topology request, probe its topology, increment the number of probed clusters by one, and then return to step S22;
[0031] S25. The payment node searches for the shortest path cnt from its own cluster to the cluster where the receiving node is located in the cluster network recorded in its routing table, sends a topology request to probe the topology of each cluster on the shortest path, and sets cnt + 1;
[0032] S26. The payment node generates a random number rand that follows a uniform distribution on [0, 1];
[0033] S27. Determine whether the conditions rand ≤ min(2(1 - r suc ), 1), there exists an unprobed path from the cluster where the payment node is located to the cluster where the receiving node is located, and cnt does not reach the upper limit are satisfied. If so, return to step S25; otherwise, proceed to step S3.
[0034] The beneficial effects of the above technical solution are as follows: This solution can dynamically adjust the number of probes according to the payment success rate of the payment node to achieve a trade - off between throughput and scalability.
[0035] Furthermore, the relay clusters are the neighboring clusters of the cluster where the payment node is located and all the clusters on the shortest path cnt; step S3 further includes:
[0036] S31. When the payment node sends a topology - probing request to the relay cluster c k , the topology - probing request is attached with the previous cluster c k and the next cluster c k―1 of the cluster c k+1 ;
[0037] S32. Initialize V1 to represent the set of points in the relay cluster c k that have channels with the nodes of the cluster c k―1 , and V2 to represent the set of points in the relay cluster c k that have channels with the nodes of the cluster c k+1 ;
[0038] S33. Construct a virtual node u1 and establish directed edges with all the points in the point set V1; construct a virtual node u2 and establish directed edges with all the points in the point set V2; initialize an empty point set V3;
[0039] S34. Take the topology recorded in the routing table of the node v k in the relay cluster c r that receives the topology - probing request, along with the virtual nodes and directed edges added in step S32, as the set A;
[0040] S35. Perform breadth - first search algorithms with u1 and u2 as roots respectively according to set A to obtain BFS trees Tree1 and Tree2;
[0041] S36. Node v r Select any unvisited node v in relay cluster c. If the parent nodes of node v on BFS trees Tree1 and Tree2 are inconsistent, continue to step S38; otherwise, go to step S37; k
[0042] S37. Delete the parent node of node v in set A and perform breadth - first search algorithm with v as the root. If node v can search to u1 or u2, enter step S38; otherwise, add v to point set V3 and enter step S38;
[0043] S38. Determine whether all nodes in relay cluster c k have been traversed. If so, enter step S39; otherwise, return to step S36;
[0044] S39. Node v r Respond by returning all its channel balance information and the topological information in its routing table that does not contain nodes in point set V3 to payer v s .
[0045] The beneficial effects of the above - mentioned technical solution are as follows: In topological detection, the response message packet returned by the node receiving the topological request message contains the topological information of its cluster and the information of all its channel balances. Since some channels cannot appear in any payment route from the payment node to the receiving node, in order to further reduce the storage overhead of the payer, some directed edges that do not appear between the payment node and the receiving node are removed, thereby reducing the storage overhead for the payer after topological detection.
[0046] Furthermore, when minimizing and the maximum value of channel congestion degree of all directed edges after transmitting a payment or a sub - payment, the expression of the solution model of multiple shortest paths is:
[0047] minT y
[0048] s.t.T y ≥0.5,
[0049]
[0050] where T y is and The maximum channel congestion degree after all directed edges transmit payments or sub - payments; R is the payment of the payer node; t(e,R) is the channel congestion degree of the directed edge e after transmitting the payment R or a sub - payment of the payment R; b e is the channel balance in the direction of the directed edge e, is the amount of the sub - payment transmitted on the shortest path; x1, x2, x i and x k are the amounts of the sub - payments transmitted on the 1st, 2nd, ith, and kth shortest paths; Γ e is the ratio of the sum of the total forwarding proportion cost required for each sub - payment of R to be forwarded at the directed edge e and the corresponding sub - payment amount to the sub - payment amount; Θ e is the total basic forwarding cost required for each sub - payment at the directed edge e; is a vector where each element is continuous in [0,1], z1, z2, z i and z k are the 1st, 2nd, ith, and kth elements in z respectively; amt is the transaction amount that the payer node hopes to conduct with the payee node; ∈ is the minimum transaction amount of the payment channel network; is the transpose.
[0051] Furthermore, the expressions of t(e,R) and Γ e are as follows:
[0052]
[0053]
[0054]
[0055]
[0056] where, w e is the channel capacity of the payment channel corresponding to the directed edge e; α(·) is a judgment function, p1, p2, and p k are the 1st, 2nd, and kth shortest paths in the path set respectively; γ(·) is the sum of the proportion values of the forwarding proportion costs charged for the directed edge e and its subsequent directed edges on the path p; p i and p h are the ith and hth directed edges on the shortest path p respectively, is the proportion value of the forwarding proportion cost charged for the ith directed edge on the shortest path p; θ(e,p) is the total basic forwarding cost paid for a payment at the directed edge e; is the basic forwarding cost charged for the ith directed edge on the shortest path p; l(p) is the length or total number of hops of the shortest path p; h is the hop number indicator, p h = e; is a directed edge opposite to the direction of the directed edge e; is the ratio of the sum of the total forwarding proportion fees required for forwarding each sub-payment of R at the directed edge to the corresponding sub-payment amount, to the sub-payment amount; is the total basic forwarding fee required for each sub-payment at the directed edge ;
[0057] The beneficial effects of the above technical solution are: by simplifying the complex mixed integer nonlinear programming problem of payment channel network channel congestion control into a linear programming problem that is easy to solve, it fits the characteristics of resource constraints of lightweight nodes in the payment channel network and reduces the computational overhead in the node routing discovery process.
[0058] Furthermore, the method for determining whether the paths in multiple shortest paths meet the constraints of the real payment channel network includes:
[0059] S61. The payment node calculates coefficients a1 and a2:
[0060] S62. The payment node traverses each component of the sub-payment amount x transmitted on the shortest path in the path set . If a certain component x i <∈, it is set to 0, otherwise x i =x i (1 + a1 / a2);
[0061] S63. Initialize intermediate parameters δ, Q' and y: δ = 0, y = sign(x), where sign(·) is the sign function. If x i = 0, then y i = 0, otherwise y i = 1;
[0062] S64. For each directed edge e in all the shortest paths in the path set , if then Q' = Q' ∪ {e}, and let the coefficient
[0063] S65. For each sub-payment x that uses the directed edge e i , update δ = δ + x i (1 ― a3), and then correct each sub-payment x that uses the directed edge i = a3x i ;
[0064] S66. If δ is 0, then according to the path set For all sub - payment amounts x transmitted on the shortest paths, send sub - payments along the shortest paths; if δ < ∈, the payment fails and the algorithm terminates; if δ ≥ ∈, proceed to step S67;
[0065] S67. The payment node selects at most edge - disjoint widest paths from the path set to form a path set P, and calculates the maximum transferable amount Y of the path set P, where [] is floor function;
[0066] S68. If Y ≥ δ, then for any path p in P i , the payment node modifies x i = δ / |P|, and then sends sub - payments along the paths in P according to the sub - payment amount x transmitted on the paths; if Y < δ, the payment node considers the payment to fail and terminates the algorithm.
[0067] The beneficial effects of the above technical solution are as follows: This solution performs rounding operations on the solution of the linear programming problem in linear time. On the premise of low computational overhead, it modifies the solution of the linear programming problem to conform to the channel constraints of the actual payment channel network payment transmission, and at the same time ensures that the solution that originally conforms to the channel constraints of the actual payment channel network payment transmission still guarantees its optimality after the rounding operation, which helps to improve the throughput of the payment channel network.
[0068] Furthermore, before step S5, it also includes that the payment node calculates the channel balance of the reverse edge of the directed edge it owns and the response node according to the channel balance, and at the same time sets the balances of other channels in the detected cluster to half of their channel capacities.
[0069] Second solution, this solution also provides a system applied to a payment channel network routing method for lightweight nodes, which includes:
[0070] A clustering module, used to initialize the payment channel network, divide it into several clusters through a clustering algorithm, and after the division, each node stores the cluster network composed of the topology of its own cluster and the connection relationship between clusters; A payment channel network topology request module, used to detect the topology of the relay cluster connecting its own cluster and the receiving node's cluster when initiating a payment request. When the receiving node and the payment node are not in the same cluster, detect the topology of the payment node's cluster;
[0071] A payment channel network topology request response module, used to obtain the channel information of the relay cluster between its own cluster and the receiving node's cluster and the channel balance of the response node by the payment node according to the payment channel network topology response mechanism.
[0072] The shortest path generation module is used for the payment node to calculate multiple shortest paths from the payment node to the receiving node according to its routing table and the detected topology by using Yen's algorithm, and form a path set is a set of reverse paths of multiple shortest paths;
[0073] The channel congestion control module is used to determine whether there is a minimum and the payment amounts transmitted on multiple shortest paths when the maximum channel congestion degree after transmitting payments or sub-payments for all directed edges is minimized;
[0074] The rounding module is used to terminate the algorithm with payment failure when there is no payment amount transmitted on multiple shortest paths; when there is a payment amount transmitted on multiple shortest paths, if there is a path among the multiple shortest paths that satisfies the real payment channel network constraint conditions, the payment is made, otherwise the payment fails and the algorithm is terminated.
[0075] The beneficial effects of the present invention are as follows:
[0076] (1) High scalability: In this solution, the payment channel network is divided into several clusters. Each node does not store the topology of the entire network, but stores the payment channel network topology and the cluster network of its own cluster to reduce the average size of the routing table of each node. During topology detection, some directed edges that do not appear between the payment node and the receiving node can be excluded, reducing the storage overhead for the payer after topology detection. In addition, the present invention dynamically challenges the detection times in order to achieve a relatively small detection overhead.
[0077] (2) High network throughput: This solution considers channel congestion control. By minimizing the maximum channel congestion, it is possible to prevent the network from falling into extreme congestion, thereby improving the overall network throughput. Description of the Drawings
[0078] Figure 1 is a flowchart of a routing method for a payment channel network for lightweight nodes.
[0079] Figure 2 is a detailed implementation flowchart of a method for dividing a payment channel network into several clusters.
[0080] Figure 3 is a flowchart of the technical solution adopted when the technical details of step S2 are implemented.
[0081] Figure 4 is a flowchart of the technical solution adopted when the technical details of step S3 are implemented.
[0082] Figure 5 is a flowchart of a method for determining whether a path among multiple shortest paths satisfies the real payment channel network constraint conditions.
[0083] Figure 6 It is a principle block diagram of a payment channel network routing system for lightweight nodes.
[0084] Figure 7 It is a comparison chart of the average routing table size of this solution and three existing routing methods when there is no workload.
[0085] Figure 8 It is a comparison chart of the average routing table size of this solution and three existing routing methods when there is workload.
[0086] Figure 9 It is a comparison chart of the number of probe messages of this solution and three existing routing methods.
[0087] Figure 10 It is a comparison chart of the payment success rate of this solution and three existing routing methods.
[0088] Figure 11 It is a comparison chart of the amount of successful payments of this solution and three existing routing methods. Specific implementation manners
[0089] The following describes the specific implementation manners of the present invention to facilitate those skilled in the art of this technology to understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation manners. For those of ordinary skill in the art of this technology, as long as various changes are within the spirit and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions created using the concept of the present invention are within the scope of protection.
[0090] In this solution, the nodes in the payment channel network model the network as a directed graph G=(V, E), where V is the set of nodes and E is the set of directed edges. The node v i ∈V represents a user in the payment channel network, and the directed edge e=(v i , v j )∈E represents the payment direction from the node v i to the node v j in the payment channel between the nodes v i and v j in the payment channel network. The edge represents the reverse direction of e.
[0091] In the present invention, it is defined that the directed edge e=(v i , v j ) is owned by the node v i because the node v i manages the forwarding fee in this payment direction. Use to represent the payment direction (v i , v j) the balance, represents the point v i and the point v j the capacity of the payment channel between them. The sum of the total capacities of the channels owned by the point v i is the point v i the basic fee charged for forwarding the payment to the point v j is the proportional value corresponding to the proportional fee charged is
[0092] In this solution, the cluster network (the connection relationship of the clusters) is modeled as a directed graph G C =(C, L), a cluster c i ∈C contains one or multiple points in V. The directed edge l=(c i , c j )∈L represents where the point v m belongs to the cluster c i , v n belongs to the cluster c j . represents the set of nodes in the cluster c i , represents the set of directed edges of all nodes belonging to the cluster c i . The routing table of the node v i stores the cluster network L and the directed edges owned by all nodes in the cluster C(v ) where the point v i is located, i the capacity, the basic fee in the forwarding fee, and the proportional value of the proportional fee and the channel label information.
[0093] The routing table of the node v i is the size of If the directed edge is the set of directed edges owned by all nodes in the cluster C(v i ) where the point v i is located; C(v m ) = C(v i ) but C(v n ) ≠ C(v i ), then the directed edge e is labeled as C(v n ), and if C(v m [[ID=8S]]) = C(v n ) = C(v i ), then the directed edge e is labeled as C(v i ).
[0094] refer to Figure 1 , Figure 1 A flowchart of a payment channel network routing method for lightweight nodes is shown; Figure 1 As shown, the method S includes steps S1 to S6.
[0095] In step S1, the payment channel network is initialized and divided into several clusters using a clustering algorithm. After the division is completed, each node stores the cluster network consisting of the topology of its cluster and the connection relationship between clusters;
[0096] like Figure 2 As shown, in one embodiment of the present invention, the method of dividing the payment channel network into a plurality of clusters by a clustering algorithm includes:
[0097] S11. At the initial moment of the payment channel network, each node forms a separate cluster, and each node acts as a cluster information proxy (CIP) for its cluster.
[0098] S12, the node determines whether it is the CIP of the cluster, if so, it initializes the queue If not, stop the clustering algorithm;
[0099] S13: The node sends the topology of its cluster to all nodes in its cluster to update the routing table, and also sends the topology of its cluster to neighboring clusters.
[0100] S14, receiving topology information from all neighboring clusters, and calculating the change in the routing table size after merging it with each neighboring cluster, and adding it to the priority queue Q when the change is greater than zero;
[0101] The expression for calculating the change in the routing table size after merging it with each neighboring cluster is:
[0102]
[0103] Where ΔS is the cluster C(v i ) and cluster C(v j ) The change in the size of the routing table after merging; C(v i ) and C(v j ) are nodes v i and v j The cluster where c' is located; c' is the cluster C(v i ) and cluster C(v j ) after the merger; |L| and |L'| are respectively clusters C(v i ) and the total number of directed edges in cluster c'; |V c′ | are clusters C(v i ), cluster C(v j ), the number of nodes in cluster c'; |E c′ |are respectively the number of directed edges owned by the nodes in cluster C(v i ), cluster C(v j ), and cluster c'.
[0104] S15. Determine whether Q is empty. If so, end the clustering algorithm; otherwise, send a create merge message to the CIP of the neighboring cluster c l corresponding to the largest change amount in Q;
[0105] S16. When receiving a create merge message from the neighboring cluster c l , send a reject merge message to other neighboring clusters in Q, and merge its own cluster with the neighboring cluster c l . Select the CIP of the merged cluster, and each node in the cluster returns to step S12;
[0106] S17. When not receiving a create merge message from the neighboring cluster c l , wait until receiving a reject merge message from other clusters in Q, then delete the cluster that sent the reject merge message in Q, and then return to step S15.
[0107] In the initialization stage of the payment channel network, when a non-CIP node receives a create merge message (Merge_Request message) and a reject merge message (Merge_NAK message), it forwards these messages to the CIP of the cluster where the node is located. Since the sending and forwarding of any message in the network initialization stage do not require the participation of the payment channel, but are directly transmitted point-to-point through the blockchain network, this stage does not involve routing. When a cluster stops aggregating with other clusters, the nodes in the cluster use the Gossip protocol to learn about the cluster network of the payment channel network. When there is no more aggregation in the whole network, the cluster network learned by the nodes through the Gossip protocol no longer changes, the cluster network converges, and the network initialization stage ends. When the network initialization stage of the payment channel network ends, the payment channel network enters the payment processing stage, and then the payments in steps S2 to S6 can be executed.
[0108] In step S2, when initiating a payment request, the payer node probes the topology of the relay cluster connecting its own cluster and the cluster where the payee node is located. When the payee node and the payer node are not in the same cluster, probe the topology of the cluster where the payer node is located; as Figure 3 shown, the detailed implementation process of step S2 is as follows:
[0109] S21. The payer node calculates its payment success rate r suc , and determines whether the payer node and the payee node are in the same cluster. If so, enter step S22; otherwise, enter step S25;
[0110] S22. The payment node generates a random number rand that follows a uniform distribution on [0, 1];
[0111] S23. Determine whether rand ≤ min(2(1 - r suc ), 1), and the number of detected neighboring clusters is less than the upper limit, and there exists an undetected neighboring cluster. If so, proceed to step S24; otherwise, proceed to step S3;
[0112] S24. Randomly select an undetected neighboring cluster to send a topology request, detect its topology, increment the number of detected clusters by one, and then return to step S22;
[0113] S25. The payment node searches for the shortest path cnt from its own cluster to the cluster where the receiving node is located in the cluster network recorded in its routing table, sends a topology request to detect the topology of each cluster on the shortest path, and sets cnt + 1;
[0114] S26. The payment node generates a random number rand that follows a uniform distribution on [0, 1];
[0115] S27. Determine whether rand ≤ min(2(1 - r suc ), 1), and there exists an undetected path from the cluster where the payment node is located to the cluster where the receiving node is located, and cnt has not reached the upper limit. If so, return to step S25; otherwise, proceed to step S3.
[0116] In steps S24 and S25, the payment node searches for paths in the cluster network G C where the nodes on these paths are not users in the payment channel network but clusters formed after the initialization stage of the payment channel network. These clusters serve as relay clusters, connecting the cluster C(v s ) where the payment node is located and the cluster C(v t ) where the receiving node is located. These clusters can use Yen's algorithm to calculate the K s shortest paths between the cluster C(v t ) and the cluster C(v prb ).
[0117] In step S3, according to the payment channel network topology response mechanism, the payment node obtains the channel information of the relay clusters between its own cluster and the cluster where the receiving node is located and the channel balances of the nodes that received the topology detection request;
[0118] When the payment node detects the topology where the receiving node is located, it sends the topology request to the payment node, and when the payer detects the topology of the relay cluster, it can send the topology request to a node in any relay cluster. The receiving node v t receives the payment node v sAfter the topological request, it can directly respond by returning all its channel balances and all channel information of its cluster. Payment node v s When detecting a certain relay cluster c k on a certain path, the previous cluster c k of this cluster c k―1 and the next cluster c k+1 on this path need to be attached to the topological request. For the nodes v k in c r after receiving the topological request, execute the payment channel network topology response mechanism proposed in this scheme, as Figure 4 shown.
[0119] As Figure 4 shown, the relay clusters are the adjacent clusters of the cluster where the payment node is located and all the clusters on the shortest path cnt; Step S3 further includes:
[0120] S31. When the payment node sends a probing topological request to the relay cluster c k , the previous cluster c k and the next cluster c k―1 of the cluster c k+1 are attached to the probing topological request;
[0121] S32. Initialize V1 to represent the set of points in the relay cluster c k that have channels with the nodes of the cluster c k―1 , and V2 to represent the set of points in the relay cluster c k that have channels with the nodes of the cluster c k+1 ;
[0122] S33. Construct a virtual node u1 and establish directed edges with all points in the point set V1; construct a virtual node u2 and establish directed edges with all points in the point set V2; initialize an empty point set V3;
[0123] S34. Take the topology recorded in the routing table of the node v k in the relay cluster c r that receives the probing topological request, and the virtual nodes and directed edges added in step S32 as a set A;
[0124] S35. According to the set A, execute the breadth-first search algorithm with u1 and u2 as the roots respectively to obtain the BFS tree Tree1 and the BFS tree Tree2;
[0125] S36. The node v r selects any unvisited node v in the relay cluster c k . If the parent nodes of the node v on the BFS tree Tree1 and the BFS tree Tree2 are inconsistent, continue to step S38, otherwise enter step S37;
[0126] S37. Delete the parent node of node v in set A, and perform a breadth-first search algorithm with v as the root. If node v can search to u1 or u2, proceed to step S38; otherwise, add v to point set V3 and proceed to step S38;
[0127] S38. Determine whether all nodes in relay cluster c k have been traversed. If so, proceed to step S39; otherwise, return to step S36;
[0128] S39. Node v r responds with all its channel balance information and the topological information in its routing table that does not include the nodes in point set V3 to payer v s .
[0129] In step S4, the paying node calculates multiple shortest paths from the paying node to the receiving node using Yen's algorithm based on its routing table and the detected topology, forming a path set which is a set of reverse paths of the multiple shortest paths.
[0130] Since the channel information returned by the responding node includes the channel capacity, the paying node can calculate the channel balance of the reverse edge of the directed edge it has with the responding node based on the channel balance, and at the same time set the balance of other channels in the detected cluster to half of their channel capacity.
[0131] In step S5, based on the channel balance, determine whether there is a minimization and of the maximum channel congestion degree of all directed edges after transmitting payments or sub - payments for the payment amounts transmitted on multiple shortest paths;
[0132] In implementation, this solution preferably minimizes and The expression of the solution model for multiple shortest paths that minimizes the maximum channel congestion degree of all directed edges after transmitting payments or sub - payments is:
[0133] minT y
[0134] s.t.T y ≥0.5,
[0135]
[0136] where T y is and The maximum channel congestion degree after all directed edges transfer payments or sub - payments; R is the payment of the payer node; t(e, R) is the channel congestion degree of directed edge e after transferring payment R or a sub - payment of payment R; b e is the channel balance in the direction of directed edge e, is the amount of sub - payment transferred on the shortest path; x1, x2, x i and x k are the amounts of sub - payments transferred on the 1st, 2nd, i - th and k - th shortest paths; Γ e is the ratio of the sum of the total forwarding proportion fees required for each sub - payment of R when forwarded at directed edge e and the corresponding sub - payment amount to the sub - payment amount; Θ e is the total basic forwarding fee required for each sub - payment at directed edge e; is a vector with elements continuous in [0, 1], z1, z2, z i and z k are the 1st, 2nd, i - th and k - th elements in z respectively; amt is the transaction amount that the payer node hopes to conduct with the payee node; ∈ is the minimum transaction amount of the payment channel network; is the transpose.
[0137] Among them, the expressions of t(e, R) and Γ e are as follows:
[0138]
[0139]
[0140]
[0141] Among them, w e is the channel capacity of the payment channel corresponding to directed edge e; α(·) is a judgment function, p1, p2 and p k are the 1st, 2nd and k - th shortest paths in the path set respectively; γ(·) is the sum of the proportion values of the forwarding proportion fees charged for directed edge e and its subsequent directed edges on path p; p i and p h are the i - th and h - th directed edges on the shortest path p respectively, is the proportion value of the forwarding proportion fee charged for the i - th directed edge on the shortest path p; θ(e, p) is the total basic forwarding fee paid for a payment at directed edge e; is the basic forwarding fee charged for the i - th directed edge on the shortest path p; l(p) is the length or total number of hops of the shortest path p; h is the hop number indicator, p h = e; is the directed edge opposite to the direction of directed edge e; is for each sub - payment of R at the directed edge The ratio of the sum of the total forwarding proportional fees and the corresponding sub - payment amounts required for forwarding at is the total forwarding basic fee required for each sub - payment on the directed edge
[0142] In step S6, when there is no payment amount transmitted on multiple shortest paths, the payment fails and the algorithm terminates; when there is a payment amount transmitted on multiple shortest paths, if there is a path that satisfies the constraints of the real payment channel network among the multiple shortest paths, the payment is made, otherwise the payment fails and the algorithm terminates.
[0143] As Figure 5 shown, in an embodiment of the present invention, the method for determining whether there is a path that satisfies the constraints of the real payment channel network among multiple shortest paths includes:
[0144] S61. The payment node calculates coefficients a1 and a2:
[0145] S62. The payment node traverses each component of the sub - payment amount x transmitted on the shortest path in the path set . If a certain component x i <∈, it is set to 0, otherwise x is corrected i =x i (1 + a1 / a2);
[0146] S63. Initialize intermediate parameters δ, Q' and y: δ = 0, y = sign(x), where sign(·) is the sign function. If x i = 0, then y i = 0, otherwise y i = 1;
[0147] S64. For each directed edge e in each of all the shortest paths in the path set , if then Q' = Q' ∪ {e}, and let the coefficient
[0148] S65. For each sub - payment x that uses the directed edge e i , update δ = δ + x i (1 - a3), and then correct each sub - payment x that uses the directed edge i = a3x i ;
[0149] S66. If δ is 0, then according to the path set For all sub - payment amounts x transmitted on the shortest paths, send sub - payments along the shortest paths; if δ < ∈, the payment fails and the algorithm terminates; if δ ≥ ∈, go to step S67;
[0150] S67. The payment node selects at most edge - disjoint widest paths from the path set to form a path set P, and calculates the maximum transferable amount Y of the path set P, where
[0151] is the floor function; i S68. If Y ≥ δ, then for any path p in P i , the payment node modifies x
[0152] = δ / |P|, and then sends sub - payments along the paths according to the sub - payment amount x transmitted on the paths in P; if Y < δ, the payment node considers the payment to fail and terminates the algorithm. Figure 6 As shown in
[0153] The present solution also provides a payment channel network routing system for lightweight nodes, which includes:
[0154] A clustering module, used to initialize the payment channel network, divide it into several clusters through a clustering algorithm, and after the division, each node stores the cluster network composed of the topology of its own cluster and the connection relationship between clusters;
[0155] A payment channel network topology request module, used to probe the topology of the relay cluster connecting its own cluster and the receiving node's cluster when initiating a payment request. When the receiving node and the payment node are not in the same cluster, probe the topology of the payment node's cluster;
[0156] A payment channel network topology request response module, used to obtain the channel information of the relay cluster between its own cluster and the receiving node's cluster and the channel balance of the response node by the payment node according to the payment channel network topology response mechanism; A shortest - path generation module, used for the payment node to calculate multiple shortest paths from the payment node to the receiving node using Yen's algorithm according to its routing table and the probed topology, and form a path set
[0157] where and is the set of reverse paths of multiple shortest paths;
[0158] The rounding module is used to fail the payment and terminate the algorithm when there are no payment amounts transmitted along multiple shortest paths. When there are payment amounts transmitted along multiple shortest paths, if there is a path among the multiple shortest paths that meets the real payment channel network constraints, the payment is made; otherwise, the payment fails and the algorithm is terminated.
[0159] The following is a detailed description of the payment channel network routing effect of this solution in combination with specific implementation:
[0160] The proposed payment channel network routing method for lightweight nodes (denoted by CRP in this scheme) is deployed in the routing module of payment channel network nodes that support atomic multipath payments (such as IoT nodes, smartphones, and other devices), assisting nodes in managing routing information and calculating payment routes.
[0161] During the initialization phase of the payment channel network, each node in the network forms a separate cluster, using itself as the CIP for its cluster and executing a clustering algorithm. When a node's cluster ceases to aggregate with neighboring clusters, it uses the Gossip protocol to obtain the cluster network and update its locally stored cluster network information. If the node's stored cluster network information remains unchanged, it considers the payment channel network to have entered the payment execution phase and can initiate, forward, or receive payments.
[0162] When node v s Initiate payment R(v s ,v t ,amt,C(v t ), node v s Execute the payment channel network topology request module, the payment channel network topology request module detection times upper limit parameter K prb The default setting is 4.
[0163] When receiving a topology request sent by the payment channel network topology request module from another node, the node receiving the topology request executes the payment channel network topology request response module and sends a corresponding topology response.
[0164] When node v s After receiving the corresponding topology responses for all topology requests sent by it, node v s According to the received topology response and node v s The routing information in the local routing table is used to calculate v using Yen's algorithm. s to v t K r Shortest path. Upper limit parameter K of candidate payment path set size r The default setting is 2.
[0165] Node v s According to the received topology response and node vs The routing information, payment information in the local routing table, and the candidate payment path set calculated in the previous step are used to construct and solve the linear programming P1 (a solution model for multiple shortest paths when minimizing and the maximum channel congestion degree of all directed edges after transmitting payments or sub - payments). The minimum transaction amount parameter ε of the linear programming P1 refers to the Lightning Network standard and can be set to 1. CRP defaults to setting it to 1×10 ―8 .
[0166] Node v s executes a rounding module, determines the transmission amount of each candidate payment path according to the output of the rounding module, and creates a sub - payment for Payment R(v s ,v t ,amt,C(v t )) and transmits it along the corresponding payment path.
[0167] Use Python and the OMNET++ simulator to implement each module of the present invention, simulate the payment execution of the payment channel network, and evaluate performance indicators such as the average routing table size, the number of probe messages, the payment success rate, and the payment success amount of the technical solution of the present invention. Among them, the average routing table size is the arithmetic mean of the routing table sizes of all nodes, the number of probe messages is the total number of probe messages sent by all nodes, the payment success rate is the ratio of the number of successfully executed payments to the total number of initiated payments, and the payment success amount is the sum of the amounts of all successfully executed payments.
[0168] The payment channel network topology adopts a BA scale - free network with 100, 200, 300, 400, 500, and 600 nodes respectively (a new node is connected to 4 existing nodes). The ratios of the capacities, base fees, and proportional fees of each channel in the payment channel network are randomly sampled from the largest payment channel network in reality, the Lightning Network. The initial balance in each channel direction is half of its channel capacity. When simulating payment execution, each node initiates 1 payment per second with another random node in the network, and the payment amount is randomly sampled from real bank card payment data for 500 seconds.
[0169] Under the same payment channel network topology and parameter settings as above, compare and explain the routing method CRP of the present solution and the existing routing methods Flare, Flash, and Auto - Tune from several aspects such as the average routing table size when there is no workload, the average routing table size when there is a workload, the number of probe messages, the payment success rate, and the payment success amount. The comparison results are respectively referred to Figures 7 to 11 .
[0170] In Figure 7 andFigure 8 Among them, the routing methods Auto-Tune and Flash have almost the same performance, and the curves overlap. By comparing the several curves in the figure, it can be seen that under the same number of nodes in the payment channel network, whether there is no workload or there is a workload, the average routing table size of the routing method CRP of this solution is the smallest. It can be seen that this solution can significantly reduce the average routing table size of each node by clustering.
[0171] As Figure 9 shown, among the four routing methods, this solution is only lower than the routing method Flash in terms of the number of probe messages. It can be seen that by introducing the payment success rate of the payment node, this solution can dynamically adjust the number of probes and achieve a compromise between throughput and scalability to a certain extent.
[0172] As Figure 10 and Figure 11 shown, among the four routing methods, the curves of this solution are all at the top. That is, under the same number of nodes in the payment channel network, the payment success rate and the number of successful payments of this solution are significantly higher than those of other existing methods, indicating that this solution can avoid the network from falling into extreme congestion by minimizing the maximum channel congestion, thereby improving the overall network throughput and greatly increasing the payment success rate and the amount of successful payments.
Claims
1. A payment channel network routing method for lightweight nodes, characterized in that: Including steps: S1. Initialize the payment channel network and divide it into several clusters using a clustering algorithm. After the division is completed, each node stores the topology of its cluster and the connection relationship between clusters to form a cluster network; S2. When initiating a payment request, the paying node detects the topology of the relay cluster connecting its cluster and the receiving node's cluster. If the receiving node and the paying node are in different clusters, the paying node's cluster is detected. S3. Based on the payment channel network topology response mechanism, the paying node obtains the channel information of the relay cluster between its cluster and the receiving node's cluster, as well as the channel balance of the node that received the topology detection request. S4. The payment node uses Yen's algorithm to calculate multiple shortest paths from the payment node to the payment node based on its routing table and the detected topology, forming a path set , is a set of multiple shortest reverse paths; S5. Determine whether there is a minimum value based on the channel balance. and The payment amount transmitted on multiple shortest paths when the channel congestion level is the maximum after transmitting the payment or sub-payment. S6. When there are no payment amounts transmitted on multiple shortest paths, the payment fails and the algorithm terminates. When there are payment amounts transmitted on multiple shortest paths, if there is a path among the multiple shortest paths that meets the real payment channel network constraints, the payment is made; otherwise, the payment fails and the algorithm terminates.
2. The payment channel network routing method according to claim 1, characterized in that: Methods for dividing the payment channel network into clusters include: S11. At the initial moment of the payment channel network, each node forms a separate cluster, and each node acts as a cluster information proxy (CIP) for its cluster. S12, the node determines whether it is the CIP of the cluster, if so, it initializes the queue Q= ; If not, stop the clustering algorithm; S13: The node sends the topology of its cluster to all nodes in its cluster to update the routing table, and also sends the topology of its cluster to neighboring clusters. S14, receiving topology information from all neighboring clusters, and calculating the change in the size of the routing table after merging it with each neighboring cluster, and adding it to the priority queue Q when the change is greater than zero; S15, determine whether Q is empty, if so, end the clustering algorithm, otherwise move to the neighboring cluster c corresponding to the maximum change in Q l The CIP sends a merge message; S16, when receiving the neighboring cluster c l Create a merge message, send a rejection merge message to other neighboring clusters in Q, and merge its cluster with the neighboring cluster c l Merge, select the CIP of the merged cluster, and each node in the cluster returns to step S12; S17, when no neighbor cluster c is received l The cluster in Q that sends the merge creation message waits until receiving a merge rejection message from another cluster in Q, then deletes the cluster in Q that sends the merge rejection message, and then returns to step S15.
3. The payment channel network routing method according to claim 2, characterized in that: The expression for calculating the change in the routing table size after merging it with each neighboring cluster is: in, Cluster and clusters The change in routing table size after merging; and Node and The cluster in which it is located; Cluster and clusters The merged clusters; and Cluster and clusters The total number of directed edges in ; 、 、 Cluster ,cluster ,cluster The number of nodes in ; 、 、 Cluster ,cluster ,cluster The number of directed edges that the nodes in have.
4. The payment channel network routing method according to claim 1, characterized in that: The step S2 further comprises: S21. The payment node calculates its payment success rate , and determine whether the payment node and the payment node are in the same cluster. If so, proceed to step S22, otherwise proceed to step S25; S22, payment node generation compliance Uniformly distributed random numbers ; S23. Judgment , and the number of detected neighboring clusters is less than the upper limit, and the condition that there are undetected neighboring clusters is met, if so, proceed to step S24, otherwise proceed to step S3; S24. Randomly select an undetected neighboring cluster and send a topology request to detect its topology. The number of detected clusters is increased by one, and then the process returns to step S22. S25. The paying node searches for a shortest path cnt from its cluster to the receiving node's cluster in the cluster network recorded in its routing table, sends a topology request to detect the topology of each cluster on the shortest path, and sets cnt+1. S26, payment node generation compliance Uniformly distributed random numbers ; S27, Judgment , and whether there is an undetected path from the cluster where the payment node is located to the cluster where the payment node is located, and whether the condition that cnt has not reached the upper limit is met, if so, return to step S25, otherwise go to step S3.
5. The payment channel network routing method according to claim 4, characterized in that: The relay clusters are the neighboring clusters of the payment node and all clusters on the shortest path cnt; step S3 further includes: S31, the payment node is sending a message to the relay cluster When sending a topology detection request, the topology detection request is accompanied by a cluster The previous cluster With the latter cluster ; S32, Initialization Represents a relay cluster Center and Cluster The set of points where the nodes have channels, Represents a relay cluster Center and Cluster The set of points whose nodes have channels; S33. Build a virtual node , and the point set Establish directed edges for all points in; build virtual nodes and point set Establish directed edges for all points in; initialize an empty point set ; S34, relay cluster The node that receives the topology detection request The topology recorded in the routing table and the virtual nodes and directed edges added in step S32 are taken as set A; S35. According to set A, and Perform breadth-first search algorithm for the root and get BFS tree and BFS tree ; S36, Node Select a relay cluster Any untraversed node in , if the node In the BFS tree and BFS tree If the parent node is inconsistent, the process proceeds to step S38; otherwise, the process proceeds to step S37. S37. Delete nodes in set A The parent node of Perform a breadth-first search algorithm for the root. If the node Can be searched or , then go to step S38, otherwise Join the dot set , proceed to step S38; S38. Determine the relay cluster Whether all nodes in have been traversed, if so, go to step S39, otherwise return to step S36; S39, Node All its channel balance information and its routing table do not contain the point set The topology information of the nodes in the response is returned to the payer .
6. The payment channel network routing method according to claim 1, characterized in that: minimize and The expression of the solution model for multiple shortest paths when the channel congestion level of all directed edges after transmitting payment or sub-payment is the maximum is: in, for and The maximum channel congestion level of all directed edges after transmitting a payment or subpayment; Payment for payment nodes; For directed edges Payment in transfer or pay The channel congestion level after the sub-payment; For directed edges Channel balance in direction, The amount of the subpayment for the shortest route transmission; The amount of subpayments transmitted on the 1st, 2nd, i and kth shortest paths; for Each sub-payment is on the directed edge The ratio of the sum of the total forwarding fee and the corresponding sub-payment amount to be paid when forwarding to the sub-payment amount; Pay for each child on the directed edge The total forwarding base fee to be paid by the place; For each element in Continuous vectors, They are the 1st, 2nd, i and kth elements in ; The transaction amount that the paying node wishes to conduct with the receiving node; The minimum transaction amount for the payment channel network; is transposed.
7. The payment channel network routing method according to claim 6, characterized in that: and The expression is: , in, is the channel capacity of the payment channel corresponding to the directed edge e; is the judgment function, 、 and Path sets The 1st, 2nd and kth shortest paths in ; is the sum of the proportional values of the forwarding proportional fees charged by the directed edge e and its subsequent directed edges on the path p; and The shortest path The i-th and h-th directed edges, For the shortest path Previous The proportional value of the forwarding fee charged for each directed edge; For a payment on a directed edge Total forwarding base fees paid by the For the shortest path Previous The basic forwarding fee charged for each directed edge; For the shortest path The length or total number of hops; h is the hop count indicator, ; is a directed edge in the opposite direction of directed edge e; for Each sub-payment is on the directed edge The ratio of the sum of the total forwarding fee and the corresponding sub-payment amount to be paid when forwarding to the sub-payment amount; Pay for each child on the directed edge The total forwarding base fee to be paid.
8. The payment channel network routing method according to claim 7, characterized in that: Methods for determining whether a path among multiple shortest paths satisfies the constraints of the real payment channel network include: S61, Payment node calculation coefficient and : , ; S62. Payment node traversal path set The amount of the sub-payment transmitted on the shortest path For each component in , then set it to Otherwise, correct ; S63. Initialize intermediate parameters 、 and : , , ,in is a symbolic function, if ,but ,otherwise ; S64. For path set For each directed edge in all shortest paths ,like ,but }, let the coefficient ; S65, for each stroke, a directed edge is used Sub-payment ,renew , then modify each sub-payment that uses a directed edge ; S66, if for , then according to the path set The amount of all sub-payments transmitted on the shortest path , send subpayments along the shortest path; if , then the payment fails and the algorithm is terminated; if , proceed to step S67; S67, payment node from the path set Most selected The widest road with no overlapping edges forms a path set , calculate the path set Maximum transferable amount , To round down; S68, if , then for Any path in , payment node correction , then follow Subpayment amount transmitted in the middle path , send subpayments along the path; if , the payment node considers the payment failed and terminates the algorithm.
9. The lightweight node-oriented payment channel network routing method according to claim 1, characterized in that: Before step S5, the payment node also includes calculating the channel balance of the reverse edge of the directed edge between it and the response node based on the channel balance, and simultaneously setting the balance of other channels in the detected cluster to half of their channel capacity.
10. A system for the lightweight node-oriented payment channel network routing method according to any one of claims 1 to 9, characterized in that: include: The clustering module is used to initialize the payment channel network and divide it into several clusters using a clustering algorithm. After the division is completed, each node stores the topology of its cluster and the connection relationship between clusters to form a cluster network; The payment channel network topology request module is used to detect the topology of the relay cluster connecting its cluster and the receiving node's cluster when initiating a payment request. If the receiving node and the paying node are in different clusters, the module also detects the topology of the paying node's cluster. The payment channel network topology request response module is used to enable the paying node to obtain the channel information of the relay cluster between its cluster and the receiving node's cluster and the channel balance of the responding node according to the payment channel network topology response mechanism; The shortest path generation module is used by the payment node to calculate multiple shortest paths from the payment node to the payment node based on its routing table and the detected topology, using Yen's algorithm to form a path set , is a set of multiple shortest reverse paths; The channel congestion control module is used to determine whether there is a minimum and The payment amount transmitted on multiple shortest paths when the channel congestion level is the maximum after transmitting the payment or sub-payment. The rounding module is used to fail the payment and terminate the algorithm when there are no payment amounts transmitted along multiple shortest paths. When there are payment amounts transmitted along multiple shortest paths, if there is a path among the multiple shortest paths that meets the real payment channel network constraints, the payment is made; otherwise, the payment fails and the algorithm is terminated.
Citation Information
Patent Citations
Payment management method of blockchain payment channel network
CN111311221A
Under-chain payment channel route balancing method
CN113225254A