CN116109416A - Block chain-based carbon transaction payment channel routing method and device - Google Patents
Block chain-based carbon transaction payment channel routing method and deviceInfo
- Publication number
- CN116109416A CN116109416A CN202310385995.7A CN202310385995A CN116109416A CN 116109416 A CN116109416 A CN 116109416A CN 202310385995 A CN202310385995 A CN 202310385995A CN 116109416 A CN116109416 A CN 116109416A
- Authority
- CN
- China
- Prior art keywords
- transaction
- node
- payment
- channel
- representing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Abstract
The invention provides a carbon transaction payment channel route selection method and device based on a blockchain, which are used for optimizing a payment channel network route based on an under-chain payment channel, wherein a directed acyclic graph is constructed for the payment channel network, attribute parameters of procedure cost, channel balance and tolerance time are added for each side, timeliness constraint, feasibility constraint and timeliness constraint are established, and a payment request is combined to find a candidate transaction path meeting the conditions. In each transaction path to be selected, node transaction procedure fees are set according to the balance of the two ends of each payment channel in proportion, the node credit is calculated by counting the correct behavior and the malicious behavior of each node, a distance length constant is added to each node, the weight of the corresponding side of each payment channel is calculated by combining the transaction procedure fees, the node credit and the distance length constant of each node, and finally the optimal transaction path is searched according to the weight of each side.
Description
Technical Field
The invention relates to the technical field of carbon quota transactions, in particular to a block chain-based carbon transaction payment channel routing method and device.
Background
The current research algorithm for the network route of the payment channel in the carbon transaction process can be divided into a single route and a multi-route. Wherein, the single route does not allow the transaction to be split, and is to search a route path meeting the requirement for transaction asset transfer. The method is mainly applied to scenes with smaller network scale and small transaction transfer quantity. However, if there is a transaction with a large amount in the single route, there is no path meeting the transaction amount, which may cause long-time blocking of the channel and cause a channel deadlock condition. The multipath route is to search at least one path for transaction, and if necessary, transaction amounts can be split for transaction on different paths, so that the problem of channel blockage can be effectively reduced. The multi-route splits the transaction, so that channel blocking can be reduced, the flow property of the network is improved, but the real-time requirement of the multipath routing path on the network state is higher, the node communication cost is high, and the problem of transaction atomicity is introduced, so that the routing efficiency is lower. Thus, a new payment routing method is needed.
Disclosure of Invention
In view of this, the embodiment of the invention provides a blockchain-based carbon transaction payment channel routing method and device, so as to eliminate or improve one or more defects existing in the prior art, and solve the problems of low success rate of payment channel routing path selection and easy channel congestion in the prior art.
One aspect of the present invention provides a blockchain-based carbon transaction payment channel routing method, comprising the steps of:
establishing a directed acyclic graph according to the topological structure of a payment channel network, wherein each node in the directed acyclic graph represents each payment node in the payment channel network, and edges among nodes in the directed acyclic graph represent payment channels among each payment node;
marking transaction procedure fees paid by a first end to a second end, channel balance of the first end, transaction procedure fees paid by the second end to the first end, channel balance of the second end, total balance of channels and tolerance time on each side of the directed acyclic graph;
obtaining a payment request, wherein the payment request comprises a payment initiator, a payment receiver, a transaction amount, a transaction initiation time and a transaction deadline;
establishing timeliness constraint, feasibility constraint and timeliness constraint, wherein on each transaction path, the timeliness constraint requires each payment channel to complete forwarding within corresponding tolerance time, the feasibility constraint requires the total balance of the channels of each payment channel to be more than or equal to the sum of payment amount and all transaction procedure fees after a current node, and the timeliness constraint requires each transaction path to add transaction transfer time to the transaction starting time and not exceed the transaction deadline;
Obtaining a eligible transaction path to be selected in the directed acyclic graph according to the payment request, the timeliness constraint, the feasibility constraint and the timeliness constraint; when no transaction path meeting the transaction amount exists, splitting the transaction amount into a plurality of transaction paths and screening corresponding transaction paths to be selected respectively.
Calculating procedure cost and current credit value corresponding to each node in each transaction path to be selected, obtaining distance length constant corresponding to each node in each transaction path to be selected, calculating weight of corresponding sides of each payment channel in each transaction path to be selected according to the procedure cost corresponding to each node, the current credit value and the distance length constant, constructing a non-negative weighted directed graph, and searching each transaction path to be selected by adopting a preset algorithm to obtain an optimal transaction path;
the procedure fee is collected by combining the proportion of the channel balance of the first end and the channel balance of the second end of the payment channel where each node is located, and the current credit value of each node is calculated according to the correct behavior quantity and the malicious behavior quantity.
In some embodiments, the tolerance time is set using a hash time lock tolerance time.
In some embodiments, the expression of the timeliness constraint is:
;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the tolerance time for node i to wait for node i+1 to provide the key, +.>A distance unit hop count value representing the distance from the receiver node L at node i;
the expression of the feasibility constraint is:
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the maximum transaction amount that node i can transfer to node j, a representing the transaction amount,representing the time of the transaction pathThe sum of transaction procedure fees of the front node and all the nodes after the front node;
the expression of the timeliness constraint is:
;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the transaction start time,/->Representing the transaction time required for payment channel e, +.>Representing the transaction deadline.
In some embodiments, the calculation formula of the procedure cost corresponding to each node in each alternative transaction path is as follows:
;
wherein, the liquid crystal display device comprises a liquid crystal display device,indicate direction->The node pays +.>Procedure cost of node->Representing the node to which the payment initiator corresponds, +.>Representation->Node direction->Payment amount of node->A proportionality parameter indicating the charge of a procedure according to said payment amount,/or->Representation->Channel balance of node->Representation->Channel balance of node->Is a proportion parameter of procedure charge collected according to balance difference values at two ends of the channel; / >Representing a fixed portion of the procedure cost.
In some embodiments, the node reputation is calculated as:
;
;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the influence factor at t iterations, < ->Is the rewarding factor when node i makes the right behaviour,/->Is when node->Penalty factor when malicious behavior is made, +.>Representing node->Make correct behavior ++>Representing nodesMaking malicious behavior->Representing node->Total number of participations in the transaction; />Representing node->Reputation value at the t-th iteration.
In some embodiments, the distance length constant value range is (0, 1) and is proportional to the transaction duration of each node in the corresponding payment channel.
In some embodiments, calculating the weight of the corresponding edge of each payment channel in each candidate transaction path according to the corresponding procedure cost of each node, the current reputation value and the distance length constant comprises:
the procedure cost of each node in a single transaction path to be selected is normalized, and the calculation formula is as follows:
wherein, the liquid crystal display device comprises a liquid crystal display device,indicate direction->The node pays +.>Procedure cost of node->Representing +.>L represents the number of nodes in a single candidate transaction path;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing edge e in a single alternate transaction path ij Weight of->Representing node->Is a node reputation of (1); />Andthe value range is (0, 1) for the fixed parameter; />Representing the distance length constant.
In some embodiments, the predetermined algorithm is a disco tesla algorithm.
In another aspect, the present invention also provides a blockchain-based carbon transaction payment channel routing device, including a processor and a memory, where the memory stores computer instructions, and the processor is configured to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the device implements the steps of the method.
In another aspect, the present invention also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the above method.
The invention has the advantages that:
according to the blockchain-based carbon transaction payment channel route selection method and device, optimization of payment channel network routes is performed based on the under-chain payment channels, a directed acyclic graph is constructed on the payment channel network, attribute parameters of procedure cost, channel balance and tolerance time are added to each side, timeliness constraint, feasibility constraint and timeliness constraint are established, and a payment request is combined to find a candidate transaction path meeting the conditions. In each transaction path to be selected, node transaction procedure fees are set according to the balance of the two ends of each payment channel in proportion, the node credit is calculated by counting the correct behavior and the malicious behavior of each node, a distance length constant is added to each node, the weight of the corresponding side of each payment channel is calculated by combining the transaction procedure fees, the node credit and the distance length constant of each node, and finally the optimal transaction path is searched according to the weight of each side.
Further, transaction procedure fees of each node are configured according to balances of nodes at two ends of each payment channel, so that balance of the two ends of each payment channel is guaranteed, and channel congestion caused by insufficient balances of the nodes in a transaction process can be effectively prevented.
Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objectives and other advantages of the invention may be realized and attained by the structure particularly pointed out in the written description and drawings.
It will be appreciated by those skilled in the art that the objects and advantages that can be achieved with the present invention are not limited to the above-described specific ones, and that the above and other objects that can be achieved with the present invention will be more clearly understood from the following detailed description.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate and together with the description serve to explain the invention. In the drawings:
FIG. 1 is a flowchart of a blockchain-based carbon transaction payment channel routing method according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the following embodiments and the accompanying drawings, in order to make the objects, technical solutions and advantages of the present invention more apparent. The exemplary embodiments of the present invention and the descriptions thereof are used herein to explain the present invention, but are not intended to limit the invention.
It should be noted here that, in order to avoid obscuring the present invention due to unnecessary details, only structures and/or processing steps closely related to the solution according to the present invention are shown in the drawings, while other details not greatly related to the present invention are omitted.
It should be emphasized that the term "comprises/comprising" when used herein is taken to specify the presence of stated features, elements, steps or components, but does not preclude the presence or addition of one or more other features, elements, steps or components.
It is also noted herein that the term "coupled" may refer to not only a direct connection, but also an indirect connection in which an intermediate is present, unless otherwise specified.
The blockchain is applied to carbon transaction, the current blockchain TPS cannot support the requirement of high-frequency carbon transaction, and the network of payment channels under the chain is one method for improving the performance of the blockchain. The invention comprehensively considers the transaction procedure cost, node credit and path length factors and comprehensively considers the optimal routing path to conduct transaction. In order to solve the problems of unbalanced channel resources and channel congestion, the invention charges according to different proportions according to the balance difference at the two ends of the channel, comprehensively considers the transaction procedure cost, and adjusts the balance at the two ends of the channel. And selecting a route path meeting the transaction amount, selecting an optimal route path comprehensively considered to conduct transaction if the route path meeting the transaction amount exists in the channel network, and splitting the transaction amount to select different route paths to conduct transaction if the route path meeting the transaction amount does not exist in the channel network. And further improves the transaction success rate of the payment network under the chain, and reduces channel congestion with less transaction procedure cost.
Specifically, the invention provides a blockchain-based carbon transaction payment channel routing method, as shown in fig. 1, comprising the following steps S101 to S106:
step S101: and establishing a directed acyclic graph according to the topological structure of the payment channel network, wherein each node in the directed acyclic graph represents each payment node in the payment channel network, and the edges between each node in the directed acyclic graph represent the payment channels between each payment node.
Step S102: the transaction fee paid by the first end to the second end on each side of the directed acyclic graph, the channel balance of the first end, the transaction fee paid by the second end to the first end, the channel balance of the second end, the total channel balance and the tolerance time are marked.
Step S103: acquiring a payment request, wherein the payment request comprises a payment initiator, a payment receiver, a transaction amount, a transaction starting time and a transaction ending time; when no transaction path meeting the transaction amount exists, splitting the transaction amount into a plurality of transaction paths and screening corresponding transaction paths to be selected respectively.
Step S104: and constructing timeliness constraint, feasibility constraint and timeliness constraint, wherein on each transaction path, the timeliness constraint requires each payment channel to complete forwarding within corresponding tolerance time, the feasibility constraint requires the total balance of the channels of each payment channel to be more than or equal to the sum of the payment amount and all transaction procedure fees after the current node, and the timeliness constraint requires that the transaction transfer time of each transaction path is added on the basis of the transaction starting time and does not exceed the transaction deadline.
Step S105: and obtaining the eligible transaction paths to be selected in the directed acyclic graph according to the payment request, the timeliness constraint, the feasibility constraint and the timeliness constraint.
Step S106: calculating procedure cost and current credit value corresponding to each node in each transaction path to be selected, obtaining distance length constant corresponding to each node in each transaction path to be selected, calculating weight of corresponding edges of each payment channel in each transaction path to be selected according to the procedure cost corresponding to each node, the current credit value and the distance length constant, constructing a non-negative weighted directed graph, and searching each transaction path to be selected by adopting a preset algorithm to obtain an optimal transaction path.
The procedure fee is collected by combining the proportion of the channel balance of the first end and the channel balance of the second end of the payment channel where each node is located, and the current credit value of each node is calculated according to the correct behavior quantity and the malicious behavior quantity.
The steps S101 to S106 of the invention can be executed by a blockchain agent or by a third party mechanism.
In steps S101 and S102, the payment channel network is represented as a directed acyclic graph, and transaction characteristics of the corresponding payment channel are recorded by the attribute of the label side. Wherein the transaction charges corresponding to each edge are direction-differentiated, e.g. for edge e ij Upper transaction commission f ij Refers toNode direction->The node transfers the transaction amount for the procedure charged. Channel balance refers to the maximum amount that can be transferred from one end to the other on the payment channel, e.g. for side e ij Channel balance b ij Representing from->Node direction->The maximum amount the node can transfer.
In steps S103, S104 and S105, the payment request is a demand for recording a transaction, and on the basis of the corresponding transaction demand, one or more candidate transaction paths meeting the conditions can be found out on the directed acyclic graph constructed based on the payment channel network by setting constraint conditions. In this embodiment, three conditions of timeliness constraint, feasibility constraint and timeliness constraint are set, and in other embodiments, other constraint conditions may be set according to specific requirements.
In some embodiments, the timeliness constraint is a limitation on the payment channel forwarding time to ensure timeliness of the payment behavior, and the tolerance time is set with a Hash Time Lock (HTLC) tolerance time. The hash-lock mode refers to a mechanism by which a user makes a guess for the original value of a hash value to pay for a prescribed period of time. In short, on the basis of intelligent contracts, both parties lock the asset first, and if the original value of the correct hash value is input in a limited time, the transaction can be completed. Under such a mechanism, a fast confirmation of micropayment, that is to say a fast confirmation of the lightning network, can be achieved.
After the user makes a transaction through a plurality of transaction nodes, the amount is temporarily locked, and to ensure that the receiver has received the amount of the transaction, an R value is returned and sequentially transmitted to the intermediate node, and the intermediate node is released when receiving R and needs to be received within the time range specified by the time lock in the node to be valid, so that the time lock tolerates timeIt is necessary to compare the value of the number of hops in units of distance of node i from the receiver node L, the farther from the receiver,/-, the>The greater the value should be.
In some embodiments, the expression for the timeliness constraint is:
;/>
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the tolerance time for node i to wait for node i+1 to provide the key, +.>A value representing the number of hops in units of distance from the receiver at node i.
Further, the feasibility constraint is that the channel balance of each node is larger than the sum of the payment amount, the transaction procedure cost of the node and the subsequent transaction procedure cost of all nodes on the payment path.
The expression for the feasibility constraint is:
;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the maximum transaction amount that node i can transfer to node j, a representing the transaction amount,representing the sum of transaction procedure fees for the current node and all nodes thereafter on the transaction path.
Further, timeliness constraint means that the time of finally completing the transaction is before the transaction deadline after the transaction is forwarded through the complete transaction path based on the transaction starting time.
The expression of the timeliness constraint is:
wherein, the liquid crystal display device comprises a liquid crystal display device,indicating transaction start time, ++>Representing the transaction time required for payment channel e, +.>Representing the transaction deadline.
In this embodiment, whether a route or a plurality of routes are adopted is determined according to the transaction amount, specifically, if a path satisfying the transaction amount exists in the channel network, an optimal route path in the single route is selected for transaction, and if a path satisfying the transaction amount does not exist in the channel network, the transaction amount is split, and corresponding route paths are selected for transaction respectively.
In step S106, on the basis of the single-path route or the multi-path route, the to-be-selected transaction path corresponding to each transaction amount is selected based on the constraint condition, and then the procedure cost, the current reputation value and the distance length parameter of each node on each path are combined to configure weights for each payment channel in each to-be-selected transaction path, and after the edges of each to-be-selected transaction path are weighted, the shortest and optimal path is searched for each single transaction amount to be used as the optimal transaction path of each single transaction amount.
In some embodiments, the calculation formula of the procedure cost corresponding to each node in each alternative transaction path is as follows:
wherein, the liquid crystal display device comprises a liquid crystal display device,indicate direction->The node pays +.>Procedure cost of node->Representing the node to which the payment initiator corresponds, +.>Representation->Node direction->Payment amount of node->A proportionality parameter indicating the charge of a procedure according to said payment amount,/or->Representation->Channel balance of node->Representation->Channel balance of node->Is a proportion parameter of procedure charge collected according to balance difference values at two ends of the channel; />Representing a fixed portion of the procedure cost.
In some embodiments, the node reputation is calculated as:
;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the influence factor at t iterations, < ->When node i makes the correct behaviorThe prize coefficient is used to determine the prize,is when node->Penalty factor when malicious behavior is made, +.>Representing node->Make correct behavior ++>Representing nodesMaking malicious behavior->Representing node->Total number of participations in the transaction; />Representing node->Reputation value at the t-th iteration.
In some embodiments, the distance length constant value range is (0, 1) and is proportional to the transaction duration of each node in the corresponding payment channel.
In some embodiments, calculating the weight of the corresponding edge of each payment channel in each candidate transaction path according to the corresponding procedure cost of each node, the current reputation value and the distance length constant comprises:
The procedure cost of each node in a single transaction path to be selected is normalized, and the calculation formula is as follows:
;
wherein, the liquid crystal display device comprises a liquid crystal display device,indicate direction->The node pays +.>Procedure cost of node->Representing +.>L represents the number of nodes in a single candidate transaction path;
;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing edge e in a single alternate transaction path ij Weight of->Representing node->Is a node reputation of (1); />Andthe value range is (0, 1) for the fixed parameter; />Representing the distance length constant.
In some embodiments, the predetermined algorithm is a disco tesla algorithm. The diels tesla algorithm can be divided into 5 steps: 1) And finding out an unprocessed point which starts from the starting point and can go forward with the least cost. 2) For the neighbors of the node it is checked if there is a shorter path to them and if so, its cost is updated. 3) The node is added to the processed queue and is subsequently not processed. 4) Steps 1-4 are repeated until all nodes in the graph except the endpoint have been checked. 5) A final path is obtained.
In another aspect, the present invention also provides a blockchain-based carbon transaction payment channel routing device, including a processor and a memory, where the memory stores computer instructions, and the processor is configured to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the device implements the steps of the method.
In another aspect, the present invention also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the above method.
The invention is illustrated below with reference to specific examples:
a system model is established for a payment channel network, the system model comprising a network model and a payment model.
The network model is as follows:
the topology of the payment channel network (payment channel network, PCN) is represented as the form g= (V, E) of a directed acyclic graph, V representing a set of nodes in the network, E being a set of payment channels. Each node v i E V denotes a user who owns a funds account and establishes an in-chain payment channel with at least one other node. Each edge e ij =(v i ,v j ) E represents a payment channel, where the representation is v i Is the sender node, v j Is a receiver node, each edge has the following properties:
setting each edge e ij =(v i ,v j ) E has transaction procedure fee f ij Is from v i To v j And transferring the transaction amount.
Setting each edge e ij =(v i ,v j ) E-channel redundancyForehead b ij Representing the ratio from v i Can be transferred to v j Is a maximum transaction amount of (c).
Setting each edge e ij =(v i ,v j ) E has a HTLC time lock tolerance time τ ij Represents v i Wait v j The secret R longest latency is provided.
Setting each edge e ij =(v i ,v j ) E channel total balance c ij Representing the sum of the channel balances of the two parties of the channel. Namely b ij +b ji =c ij =c ji . And the balance always has b ij ≤c ij 。
For simplicity, the channel total balance c is not considered in this embodiment ij Edge of 0, and channel balance b ij And the balance is equal to or more than 0, the condition of negative balance of the channel is not considered, and the two-way channel is considered by the payment channel.
The payment model is established as follows:
define a payment request r= (v) s ,v t ,a,s t ,d l ) Wherein v is s Is the initiator, i.e. sender, v of the payment request t Is the receiver, a is the transaction amount, does not contain the procedure charge to be paid in the transfer path, s t Is the start time of transaction initiation, d l Is the transaction deadline. de represents the transfer time in lane link e through the transaction that needs to be completed. P is the set in all paths in the PCN, P R Is v satisfying the payment request R s -v t Path set P e P R The representation is that v is satisfied s -v t One path of the payment request. Let the correlation path p be serialized to p=v 0 →v 1 →......→v L . Wherein v is 0 =v s ,v L =v t Wherein v is i E p represents the node in path p. Definition of the function F l,m Indicating that a payment is made from v in path p l To v m Sum of the procedure fees paid for transactions on the path, f i,i+1 Representing the charge of the transaction path in the path (i, i+1) through node i. Wherein 0.ltoreq.l<m≤L,F l,m The function is as follows:
; (1)
if the payment request is to be successfully completed, a certain constraint condition is also required:
timeliness constraint: if the payment request R is to be completed, a time lock tolerance time τ of HTLC in each payment channel is required i,i+1 And forwarding the next route inwards. Timeliness is achieved through time locking of the HTLC, and integrity of transactions of the intermediate payment channel can be guaranteed, wherein the concrete formula is as follows:
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the tolerance time for node i to wait for node i+1 to provide the key, +.>A value representing the number of hops in units of distance from the receiver at node i.
Feasibility constraints: if successful completion of the payment request R is desired, each lane in path p may be successfully traversed, a lane balance b is required i,i+1 At least the payment amount and the transit node v i The sum of all subsequent procedure costs is given by:
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the maximum transaction amount that node i can transfer to node j, a representing the transaction amount,representing a transaction pathAnd the sum of transaction procedure fees of the current node and all nodes after the current node on the path.
Timeliness constraint: if the payment request R is to be completed, the payment needs to be completed within the time specified by the payment request, and the transaction reaches the receiver. Then it is required to request the payment start time s t Plus the transaction transfer time at which the individual links in the path need to be completed does not exceed the transaction deadline d specified in the payment request l The specific formula is as follows:
; (4)
wherein, the liquid crystal display device comprises a liquid crystal display device,indicating transaction start time, ++>Representing the transaction time required for payment channel e, +.>Representing the transaction deadline.
In this embodiment, a multi-factor routing payment scheme is used, assuming that the initiator Alice initiates a transaction to the recipient Bob, using the payment channel link p=v 0 →v 1 →......→v L The middle is subjected to a plurality of node selections, in the embodiment, the path and the node selections are comprehensively considered to pay the route mainly in consideration of the channel procedure cost, the node historical reputation value and the nearest distance length, and the embodiment provides a Multi-factor payment scheme (Multi-factor payment scheme, MFPS) based route optimization algorithm.
First, calculation of transaction procedure cost:
an important factor in the path selection consideration is the cost of procedures in the transaction path that need to be given to the intermediate nodes, minimizing the cost of transaction procedures while satisfying timeliness, feasibility and timeliness constraints. The transaction procedure fee charging type considers three procedure fees, namely, the channel node charges according to the proportion of the transaction amount, the node charges the fee fixedly and charges according to different proportions of balance differences at two ends of the channel. The procedure cost to be delivered for a transaction path through a certain node i is as follows:
; (5)
Wherein, the liquid crystal display device comprises a liquid crystal display device,indicate direction->The node pays +.>Procedure cost of node->Representing the node to which the payment initiator corresponds, +.>Representation->Node direction->Payment amount of node->A proportionality parameter indicating the charge of a procedure according to said payment amount,/or->Representation->Channel balance of node->Representation->Channel balance of node->Is a proportion parameter of procedure charge collected according to balance difference values at two ends of the channel; />Representing a fixed portion of the procedure cost.
From the sender v throughout the transaction path s To receiving end v t The procedure cost of the required exchangeThe formula is as follows:
; (6)
the embodiment considers the channel congestion situation, namely the situation that balances at two ends of a channel are unbalanced. In the u, v node channel, when the channel is established, the balance is stored in both sides of the user, namely, both ends of the channel are balanced, but as the subsequent transaction occurs, the transaction direction is always that the node u carries out the transaction to the node v, and as a result, the fund of one v node in the channel is sufficient, the fund of the other u node is insufficient, and the balance at both ends is unbalanced. If there is a transaction that requires a transfer of funds from the u-v direction, but the funds at the channel node u cannot meet the monetary requirements of the transaction, the transaction will be jammed at the node until the time lock is set to a time when the transfer of funds has not been performed, and the transaction will be cancelled. The unbalanced balance at the two ends of the channel can cause the success rate of the transaction to be reduced, cause channel congestion, and the balance of the channel passing before the transaction is locked before the transaction is cancelled, thereby causing the dead lock phenomenon of the channel funds. In this embodiment, the procedure fee is collected according to different ratios of balance differences between the two ends of the channel, and if one end path with more balance is selected, the procedure fee is lower than the procedure fee collected by selecting the other end path. If two or more alternative paths exist, the procedure cost is taken as a consideration factor for selecting the paths, and under the condition that other conditions are the same, one path with relatively abundant channel balance at one end is preferably selected, so that the occurrence of unbalanced channel balance and channel congestion can be reduced.
Second, calculation of node reputation:
an important factor to be considered in transaction path selection is the reputation value of a node, and if the reputation value of a certain node is low, the probability of the node being wrongly made is high, so that a transaction cannot reach a transaction receiver within a time lock set time, and the transaction fails. Therefore, in order for a transaction to successfully reach a transaction receiver within a specified time, the selection of a channel where a node with a higher reputation value is located should be considered in the transaction path selection. The present embodiment considers that the reputation value of a node relates to the number of times a node engages in a transaction to make a correct/malicious action. Wherein the correct/malicious behaviour with respect to defining a node is as follows:
proper behavior refers to the transfer of transaction amounts and the transfer of secrets within a specified time lock.
Malicious acts refer to the transfer of privately amounts and undelivered secrets of amounts that fail to transact within a prescribed time lock range, as well as providing counterfeit secret transfers.
The node reputation is calculated as follows:
; (7)
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the influence factor at t iterations, < ->Is the bonus coefficient when node i is doing the correct behaviour,is when node->Penalty factor when malicious behavior is made, +. >Representing node->Make correct behavior ++>Representing nodesMaking malicious behavior->Representing node->Total number of participations in the transaction; />Representing node->Reputation value at the t-th iteration.
Is a sigmoid function with a value range of (0, 1), wherein I t Is an influencing factor, the penalty of malicious behavior is larger than the reward of correct behavior, so the general penalty coefficient is +.>Is more than rewarding->Much larger. In the case of initial state, I t Influence factor 0, reputation value R t 0.5.
Third, setting a distance length parameter:
considering the distance length problem, which is equivalent to the transaction time problem, each node transaction processing time has a tolerance time tau specified by a time lock i In the present embodiment, the minimum number of hops is considered, and the problem of comparing the processing time of each node is not considered. When constructing the weighted directed graph, a constant N E (0, 1) is added to the weight of each edge for quantifying the transmission and processing time of the payment channel.
The time to conduct transactions in the in-chain payment channel is largely considered the processing time through each node, ignoring the funds transfer time within the channel. Among the multiple alternative paths, the path with the least number of nodes is selected as much as possible under the condition of the same other conditions, namely, the shortest path is selected. And comprehensively considering node reputation, transaction procedure cost and distance length factors to construct a weighted directed graph.
The node credit and the transaction procedure cost are weight factors forming the edges, wherein the value of the node credit is a sigmoid function, and the value range is (0, 1).
Normalizing the transaction procedure cost by adopting max-min, wherein the following formula is adopted:
wherein, the liquid crystal display device comprises a liquid crystal display device,indicate direction->The node pays +.>Procedure cost of node->Representing +.>L represents the number of nodes in a single candidate transaction path;
each edge e ij Weight w of (2) ij The formula is as follows:
; (10)
wherein, the liquid crystal display device comprises a liquid crystal display device,representing edge e in a single alternate transaction path ij Weight of->Representing node->Is a node reputation of (1); />Andthe value range is (0, 1) for the fixed parameter; />Representing the distance length constant.
And (3) giving weight to each edge, constructing a non-negative weighted directed graph, and finding out the shortest path by using dijkstra algorithm, namely the optimal path comprehensively considering node reputation, transaction procedure cost and distance length.
Furthermore, simulation experiment results show that the route payment scheme provided by the embodiment is compared with the shortest path algorithm and the minimum transaction cost selection path algorithm, and the transaction success rate is obviously improved. The transaction amount provided by the invention is split, and the balance of the channel is balanced, so that the transaction success rate is improved. The average message cost and transaction cost of the scheme in the route payment are less, so that the multi-factor route selection payment scheme provided by the invention can realize higher transaction success rate with lower route cost.
Specifically, the whole transaction process of the embodiment implements a route initialization method, a transaction amount splitting algorithm, a payment routing algorithm and a receiving algorithm of a receiving party. The specific algorithm steps are as follows:
route initialization algorithm: the algorithm describes that when a payment request is initiated, a weighted directed graph is constructed for that particular payment request. Nodes traverse graph G (V, E), building weights for edges. Table T E (i, j) is a storage edge e ij Is a weight value of (a). If v i =v j T is then E (i, j) =0, if v i And v j Without a channel between them, give T E (i, j) infinite value. If v is present i And v j In the channel between v i Balance b of channel segment ij <a+Fp (i+1, L), if the feasibility constraint of the transaction is not satisfied, the edge is given a weight T E (i, j) ≡, and the rest of the cases calculate w (i, j) according to the formula (10) and assign to T E (i, j) a transaction weight table. When the nodes traverse all the nodes of the graph G, the cycle is finished, and T is output E (i, j). After the route initialization is completed, the whole graph is traversed by using a Breadth First algorithm (BFS) algorithm to find v s -v t Path set P between R (s,t)。
Transaction amount splitting algorithm: before forwarding the routing transaction, it should be determined whether there is a funds transfer in which the balance of the channel in one path satisfies the transaction requirements. If no such path exists, the transaction amount splitting is performed to perform transaction forwarding. Find about v s -v t And sorting the channel paths existing between the two paths according to the transferable funds from large to small, adding all the funds capable of being transferred, judging whether the funds required by the tradable transaction are reached, and returning null if the funds required by the tradable transaction are not reached, so that the tradable transaction is failed. If the funds required by the transaction are met, splitting the transaction from the path with the largest funds which can be transferred, thereby reducing the splitting transaction times as much as possible and initializing the route again. And (5) until the split amount meets the funds of the transaction, ending the circulation and returning to the split transaction set.
Payment routing algorithm: the algorithm is to find out the optimal path for forwarding transaction. First, P needs to be judged R If (S, T) is not null, defining s=Φ, Q as the set V of all vertices of the graph G, and if q+.Φ, performing a loop from T E From the starting point v in (s, t) s To v t The intermediate node with the smallest weight is selected, the node is removed from the node set Q, and the node is added to the set S. Pi is P R One path of S-t in (S, t), pi is the optimal path if all nodes in set S ⊇ pi. The transaction request R selects the path for transaction.
The receiving algorithm of the receiving party: when the receiving party receives the fund transfer, whether the transaction timeliness constraint is met or not is verified, if the receiving time is larger than the expiration time specified by the transaction, the receiving party is authorized to refuse to receive the transaction, then the intermediate node participating in the transaction releases the fund, and the fund generated by the transaction is transferred back to the original owner. If the timeliness constraint is satisfied, the recipient receives the transaction and sends a secret original to its last node v t-1 。
In the embodiment, based on the under-chain payment channel, PCN route optimization is performed, a multi-factor-based route selection payment scheme is provided, and the transaction procedure cost, node reputation and distance length factors are comprehensively considered for route selection. Considering the problem of unbalanced channel, the balance at two ends of the channel is seriously unbalanced, so that the channel congestion is easy to occur. The method and the device have the advantages that transaction procedure fees are charged according to the difference value of the two ends of the balance of the channel, and one end path with the balance of the channel is prioritized when a route is selected, so that the condition of channel congestion in a payment channel network is reduced. In order to improve the success rate of the transaction, when the balance in the payment channel cannot support the amount of the payment transaction, the transaction amount is split in a greedy manner, and the transaction amount is split in sequence according to the balance channel path which can be maximally transacted, so that the splitting times of the transaction amount are reduced. Simulation experiment results show that the scheme provided by the invention can realize higher transaction success rate with lower routing cost.
In summary, according to the blockchain-based carbon transaction payment channel routing method and device, the optimization of the payment channel network routing is performed based on the under-chain payment channel, the attribute parameters of procedure cost, channel balance and tolerance time are added to each side by constructing a directed acyclic graph on the payment channel network, timeliness constraint, feasibility constraint and timeliness constraint are established, and the payment request is combined to find the eligible transaction paths to be selected. In each transaction path to be selected, node transaction procedure fees are set according to the balance of the two ends of each payment channel in proportion, the node credit is calculated by counting the correct behavior and the malicious behavior of each node, a distance length constant is added to each node, the weight of the corresponding side of each payment channel is calculated by combining the transaction procedure fees, the node credit and the distance length constant of each node, and finally the optimal transaction path is searched according to the weight of each side.
Further, transaction procedure fees of each node are configured according to balances of nodes at two ends of each payment channel, so that balance of the two ends of each payment channel is guaranteed, and channel congestion caused by insufficient balances of the nodes in a transaction process can be effectively prevented.
The embodiments of the present invention also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the edge computing server deployment method described above. The computer readable storage medium may be a tangible storage medium such as Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, floppy disks, hard disk, a removable memory disk, a CD-ROM, or any other form of storage medium known in the art.
Those of ordinary skill in the art will appreciate that the various illustrative components, systems, and methods described in connection with the embodiments disclosed herein can be implemented as hardware, software, or a combination of both. The particular implementation is hardware or software dependent on the specific application of the solution and the design constraints. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, a plug-in, a function card, or the like. When implemented in software, the elements of the invention are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine readable medium or transmitted over transmission media or communication links by a data signal carried in a carrier wave.
It should be understood that the invention is not limited to the particular arrangements and instrumentality described above and shown in the drawings. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present invention are not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between steps, after appreciating the spirit of the present invention.
In this disclosure, features that are described and/or illustrated with respect to one embodiment may be used in the same way or in a similar way in one or more other embodiments and/or in combination with or instead of the features of the other embodiments.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, and various modifications and variations can be made to the embodiments of the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (10)
1. A blockchain-based carbon transaction payment channel routing method, the method comprising the steps of:
establishing a directed acyclic graph according to the topological structure of a payment channel network, wherein each node in the directed acyclic graph represents each payment node in the payment channel network, and edges among nodes in the directed acyclic graph represent payment channels among each payment node;
marking transaction procedure fees paid by a first end to a second end, channel balance of the first end, transaction procedure fees paid by the second end to the first end, channel balance of the second end, total balance of channels and tolerance time on each side of the directed acyclic graph;
obtaining a payment request, wherein the payment request comprises a payment initiator, a payment receiver, a transaction amount, a transaction initiation time and a transaction deadline;
establishing timeliness constraint, feasibility constraint and timeliness constraint, wherein on each transaction path, the timeliness constraint requires each payment channel to complete forwarding within corresponding tolerance time, the feasibility constraint requires the total balance of the channels of each payment channel to be more than or equal to the sum of payment amount and all transaction procedure fees after a current node, and the timeliness constraint requires each transaction path to add transaction transfer time to the transaction starting time and not exceed the transaction deadline;
Obtaining a eligible transaction path to be selected in the directed acyclic graph according to the payment request, the timeliness constraint, the feasibility constraint and the timeliness constraint; when no transaction path meeting the transaction amount exists, splitting the transaction amount into a plurality of transaction paths and screening corresponding transaction paths to be selected respectively;
calculating procedure cost and current credit value corresponding to each node in each transaction path to be selected according to each single transaction amount, obtaining distance length constant corresponding to each node in each transaction path to be selected, calculating weight of corresponding sides of each payment channel in each transaction path to be selected according to the procedure cost corresponding to each node, the current credit value and the distance length constant, constructing a non-negative weighted directed graph, and searching each transaction path to be selected by adopting a preset algorithm to obtain an optimal transaction path;
the procedure fee is collected by combining the proportion of the channel balance of the first end and the channel balance of the second end of the payment channel where each node is located, and the current credit value of each node is calculated according to the correct behavior quantity and the malicious behavior quantity.
2. The blockchain-based carbon transaction payment channel routing method of claim 1, wherein the tolerance time is set using a hash time lock tolerance time.
3. The blockchain-based carbon transaction payment channel routing method of claim 1, wherein the expression of the timeliness constraint is:
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the tolerance time for node i to wait for node i+1 to provide the key, +.>A distance unit hop count value representing the distance from the receiver node L at node i;
the expression of the feasibility constraint is:
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the maximum transaction amount that node i can transfer to node j, a representing the transaction amount,/->Representing the sum of transaction procedure fees of the current node and all nodes after the current node on the transaction path;
the expression of the timeliness constraint is:
;/>
4. The blockchain-based carbon transaction payment channel routing method of claim 1, wherein the calculation formula of the procedure cost corresponding to each node in each transaction path to be selected is:
wherein, the liquid crystal display device comprises a liquid crystal display device,indicate direction->The node pays +.>Procedure cost of node->Representing the node to which the payment initiator corresponds, +.>Representation->Node direction->Payment amount of node->A proportionality parameter indicating the charge of a procedure according to said payment amount,/or- >Representation->Channel balance of node->Representation->Channel balance of node->Is a proportion parameter of procedure charge collected according to balance difference values at two ends of the channel; />Representing a fixed portion of the procedure cost.
5. The blockchain-based carbon transaction payment channel routing method of claim 4, wherein the node reputation is calculated as:
;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing the influence factor at t iterations, < ->Is the rewarding factor when node i makes the right behaviour,/->Is when node->Penalty factor when malicious behavior is made, +.>Representing node->Make correct behavior ++>Representing node->Making malicious behavior->Representing node->Total number of participations in the transaction; />Representing node->Reputation value at the t-th iteration.
6. The blockchain-based carbon transaction payment channel routing method of claim 5, wherein the distance length constant value range is (0, 1) and is proportional to the transaction duration of each node in the corresponding payment channel.
7. The blockchain-based carbon transaction payment channel routing method of claim 6, wherein calculating the weight of the corresponding edge of each payment channel in each candidate transaction path according to the corresponding procedure cost of each node, the current reputation value and the distance length constant comprises:
The procedure cost of each node in a single transaction path to be selected is normalized, and the calculation formula is as follows:
wherein, the liquid crystal display device comprises a liquid crystal display device,indicate direction->The node pays +.>Procedure cost of node->Representing +.>L represents the number of nodes in a single candidate transaction path;
;
wherein, the liquid crystal display device comprises a liquid crystal display device,representing edge e in a single alternate transaction path ij Weight of->Representing node->Is a node reputation of (1); />And->The value range is (0, 1) for the fixed parameter; />Representing the distance length constant.
8. The blockchain-based carbon transaction payment channel routing method of claim 1, wherein the predetermined algorithm is a disco tesla algorithm.
9. A blockchain-based carbon transaction payment channel routing device comprising a processor and a memory, wherein the memory has stored therein computer instructions for executing the computer instructions stored in the memory, which when executed by the processor, implement the steps of the method of any of claims 1 to 8.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the steps of the method according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310385995.7A CN116109416A (en) | 2023-04-12 | 2023-04-12 | Block chain-based carbon transaction payment channel routing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310385995.7A CN116109416A (en) | 2023-04-12 | 2023-04-12 | Block chain-based carbon transaction payment channel routing method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116109416A true CN116109416A (en) | 2023-05-12 |
Family
ID=86265884
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310385995.7A Pending CN116109416A (en) | 2023-04-12 | 2023-04-12 | Block chain-based carbon transaction payment channel routing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116109416A (en) |
-
2023
- 2023-04-12 CN CN202310385995.7A patent/CN116109416A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Gao et al. | Truthful incentive mechanism for nondeterministic crowdsensing with vehicles | |
US11301602B2 (en) | Simulation-based testing of blockchain and other distributed ledger systems | |
Anderegg et al. | Ad hoc-VCG: a truthful and cost-efficient routing protocol for mobile ad hoc networks with selfish agents | |
Chai et al. | Proof-of-reputation based-consortium blockchain for trust resource sharing in internet of vehicles | |
CN109214818B (en) | Cross-chain transaction method and device | |
Di Stasi et al. | Routing payments on the lightning network | |
KR102096652B1 (en) | Apparatus and method for approving instant deposit of cryptocurrency | |
Asheralieva et al. | Reputation-based coalition formation for secure self-organized and scalable sharding in iot blockchains with mobile-edge computing | |
US20210326879A1 (en) | Blockchain protocol and a blockchain network | |
Shi et al. | MPCSToken: Smart contract enabled fault-tolerant incentivisation for mobile P2P crowd services | |
CN112202928A (en) | Credible unloading cooperative node selection system and method for sensing edge cloud block chain network | |
CN110097218B (en) | Unmanned commodity distribution method and system in time-varying environment | |
US11593898B2 (en) | Method for processing data and apparatuses for implementing the same | |
CN110851531B (en) | Cooperative edge computing method, block chain and cooperative edge computing system | |
CN110751469A (en) | Encrypted currency multichannel payment method based on intelligent contract | |
CN111130790A (en) | Block co-recognition method based on block chain node network | |
CN111126988A (en) | Block chain-based transfer method, device, equipment and computer medium | |
CN116109416A (en) | Block chain-based carbon transaction payment channel routing method and device | |
CN103824195A (en) | Excitation method based on three-round bargaining in opportunity network | |
CN114173301B (en) | Safe and efficient data sharing method for Internet of vehicles based on DAG block chain | |
WO2022148200A1 (en) | Hardware wallet digital currency selection method and hardware wallet | |
Nazih et al. | An evolutionary bargaining‐based approach for incentivized cooperation in opportunistic networks | |
WO2021011893A1 (en) | Relay system for blockchain | |
Okanami et al. | Load balancing with in-protocol/wallet-level account assignment in sharded blockchains | |
Lu et al. | A Sample Average Approximation Approach for the Stochastic Dial-A-Ride Problem on a Multigraph with User Satisfaction |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination |