Chain network cooperative distributed consensus method based on DAG block chain
By dynamically adjusting node computing resources and optimizing the routing and bandwidth allocation of the communication layer in the DAG blockchain system, the problem of low computing efficiency of transaction selection strategies and consensus delays in the prior art is solved, and higher system throughput and lower transaction on-chain delay are achieved.
Patent Information
- Application Number
- CN202510048444.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-01-13
AI Technical Summary
The existing research based on DAG blockchain has problems of inefficiency in transaction selection strategies and consensus delay calculations, and ignores the limitations of the underlying communication network, resulting in low system throughput and extended transactions on-chain under the case of limited communication resources and computing resources.
A collaborative distributed consensus method for chain networks based on DAG blockchain is proposed, which dynamically adjusts the allocation strategy of node computing resources and optimizes message transmission routing and bandwidth allocation at the communication layer to achieve the optimal average on-chain delay.
Under the constraints of meeting the business latency and system resource upper limit, the throughput of the DAG blockchain system is significantly improved and the average transaction rolling delay is reduced, thereby improving the overall performance of the system.
Smart Images

Figure CN119892340A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the fields of data management and evidence storage technology and mobile network application technology, and specifically relates to a chain network collaborative distributed consensus method based on DAG blockchain. Background Art
[0002] As a decentralized, transparent and secure distributed ledger technology, blockchain has been widely used in finance, supply chain, Internet of Things and other fields. However, with the continuous increase in business traffic, the existing global consensus mechanism has become inefficient under the pressure of handling large-scale business, limiting the scalability of the system. At the same time, the existing blockchain consensus methods, such as PoW or PoS, are essentially competing for computing power or rights, and there is a problem of excessive consumption of computing resources. In addition, the existing blockchain consensus methods have an inherent linear chain structure arranged in an unchangeable time order, which leads to increased delays in transaction confirmation on the chain, decreased system throughput and network congestion in the system.
[0003] In order to improve the scalability of blockchain systems and reduce the average latency of transactions on the chain, in recent years, distributed ledger technology with directed acyclic graph (DAG) as the basic data structure has been proposed. This DAG blockchain architecture has the advantages of higher transaction throughput, lower resource consumption, and zero transaction fees, which can better overcome the performance limitations of traditional blockchains. The principle of DAG blockchain is to add new transactions by topological sorting. Without using resource-intensive computing to reach consensus, a node can issue a new transaction as long as it approves and verifies two or more previous transactions through the transaction selection algorithm. In the DAG blockchain, each transaction has a cumulative weight, which indicates the number of times the transaction has been approved and verified. Generally speaking, the cumulative weight is an indicator of the credibility of the transaction. The credibility of the transaction is positively correlated with the cumulative weight. When the cumulative weight of a transaction reaches the confirmation threshold, it is considered that the transaction has been confirmed in the DAG and the transaction is officially on the chain.
[0004] "The Tangle", 2018. Version 1.4.3 analyzes the mathematical foundation of IOTA, and for the first time proposes to use directed acyclic graphs (DAGs) to store transactions, and analyzes the working principle, latency performance, and performance of DAG blockchains under possible attack scenarios. The paper "Z.Chen, X.Chen and Y.Li, "Performance and Security Analysis ofDistributed Ledger Under the Internet of Things Environments With NetworkInstability," in IEEE Internet of Things Journal, 2023" analyzes the performance and security of DAG blockchains in the Internet of Things with unstable networks, and also analyzes the latency of transaction propagation in the underlying network under different transaction generation rates, different node average uplink bandwidths, and the number of neighbor nodes. The paper "W. Yang, L. Shi, H. Liang and W. Zhang, "Trusted Mobile Edge Computing: DAG Blockchain-Aided Trust Management and Resource Allocation," in IEEE Transactions on Wireless Communications, May" proposes to implement the execution of computationally intensive and delay-sensitive tasks in IoT applications, and proposes to jointly optimize bandwidth and computing resources based on the DAG blockchain structure to minimize system latency. The paper "J. Xie, K. Zhang, Y. Lu and Y. Zhang, "Resource-Efficient DAG Blockchain with Sharding for 6G Networks," in IEEE Network, 2022" proposes a blockchain scaling scheme that combines directed acyclic graphs and sharding, and proposes a computationally efficient consensus algorithm that uses the computing power of nodes to improve resource utilization efficiency. However, the following problems still exist in the above research work:
[0005] (1) Most of the existing research on the DAG blockchain architecture uses random selection, reputation-based, or generation time-based strategies to select a fixed number of other transactions for approval and verification. There is little consideration of combining the computing resources of the nodes to make selection strategies based on contribution value or proof of work, which can further improve the performance of the DAG blockchain and reduce the average transaction latency.
[0006] (1) The existing DAG blockchain architecture mainly focuses on the transaction selection strategy and consensus delay calculation problem of the consensus layer, while ignoring the limitations of the underlying communication network. Most of the existing research assumes that the network environment is stable and reliable and that communication resources are sufficient. In real blockchain system scenarios, factors such as the topology of the communication network, the routing selection of communication between devices, and the bandwidth allocation of the transmission channel have a significant impact on the performance of the blockchain system.
[0007] Therefore, the existing technology lacks an effective DAG blockchain consensus solution that takes into account the optimization of the underlying network, so as to improve the throughput of the DAG blockchain system and reduce the average transaction latency under limited communication resources and computing resources. Summary of the invention
[0008] To solve the above technical problems, the present invention provides a chain network collaborative distributed consensus method based on DAG blockchain, which dynamically adjusts the allocation strategy of node computing resources according to the needs of real-time business, as well as the routing and bandwidth allocation of message transmission mapped from the upper-layer consensus process to the communication layer, while meeting constraints such as business delay and system resource upper limit, to achieve the optimal average chain delay.
[0009] The technical solution adopted by the present invention is: a chain network collaborative distributed consensus method based on DAG blockchain, the specific steps are as follows:
[0010] S1. Divide the DAG blockchain system into a consensus layer and a communication layer;
[0011] The consensus layer is the DAG blockchain network, including all nodes in the network. The communication layer is the underlying communication network that supports node diffusion transactions in the consensus phase. Nodes are mapped to terminal devices in the communication layer. The underlying communication network includes: terminal devices and physical links between devices.
[0012] Among them, it is assumed that the blockchain system contains N nodes, and the nodes in the communication layer are mapped to network terminal devices, that is, the corresponding communication layer contains N terminal devices; and in the communication layer, the underlying network topology composed of network terminal devices and physical links is predetermined.
[0013] S2, divide the system time into continuous fixed time slots, the length of a time slot is T s , and a time slot is divided into two parts, the first part is the calculation time slot T cal , the latter part is the diffusion time slot T tr ;
[0014] The computing time slot completes the computing and verification tasks. Each node in the network acts as an MEC server and uses its own computing resources to provide computing services for the computing-intensive tasks offloaded by users to itself. At the same time, it acts as a verification node to complete the approval and verification of transactions generated by other nodes. After the calculation is completed, the node forms a new transaction in this round. A transaction consists of three parts: task calculation results, other verified transaction information, and the node's own signature.
[0015] The diffusion slot completes the transaction diffusion task. Each node uses the bandwidth allocated by the system to diffuse its own transactions to other nodes in the network based on the calculated routing information.
[0016] S3. Based on step S2, at the consensus layer, construct a computing resource allocation strategy for each node;
[0017] S4. Based on step S2, at the communication layer, construct a routing and bandwidth allocation strategy for each node;
[0018] S5. Construct a DAG blockchain consensus delay calculation model, namely the cumulative weight growth model;
[0019] S6. Based on the model constructed in step S5, a resource allocation model for the chain-network fusion scenario is constructed. The fixed branch method is used to solve the computing resource allocation strategy and the routing and bandwidth allocation strategy constructed in steps S3 and S4, and the optimal resource allocation strategy is output through iteration.
[0020] Furthermore, the step S3 is specifically as follows:
[0021] Assume that the total number of computing resources, i.e., CPU resources, owned by each node in the network is f. For computing-intensive tasks that users offload, the size of the designed computing-intensive tasks is D. The nodes allocate their own computing resources, and part of the computing resources f cal The computing resources f are used to calculate the computing-intensive tasks offloaded by users, that is, the user computing tasks themselves. ver Used to approve and verify transactions generated by other nodes.
[0022] Among them, f cal +f ver ≤f. The time required for the calculation task is T cal =D / f cal , set the size of a transaction to B, and calculate the time slot T cal During this period, the total number of transactions approved and verified by the node using the computing resources allocated to verify transactions is denoted as n ver =f ver ·T cal / B.
[0023] Then, a transaction verification selection method is designed. The verification queue priority is set according to the number of other transactions k verified by one transaction. The queue of transactions to be verified is organized in order of priority. When the transaction is broadcast to other nodes, it enters the queue of transactions to be verified at the corresponding node. Each node calculates the time slot length T according to the current round. cal As well as the allocation of computing resources, it calculates the number k of other transactions that can be verified in this round, and selects the k transactions with the highest priority from its own queue of pending transactions for approval and verification. The number k of other transactions verified by transaction a is positively correlated with the probability that transaction a is selected for direct verification by other consensus nodes.
[0024] Furthermore, the step S4 is specifically as follows:
[0025] At the communication layer, the underlying network topology is abstracted into an undirected graph G(V,E). Let C represent the upper limit of the bandwidth that each physical link can carry.
[0026] Wherein, V represents the point set of the undirected graph, that is, the set of all nodes in the network, and E represents the edge set of the undirected graph, that is, the set of physical links between terminal devices; e u,v ∈E indicates that there is a one-hop direct physical link between any device nodes u and v. Since the graph is an undirected graph, e u,v =e v,u .
[0027] For each transaction generated by each node in the network, determine the route for the transaction to spread to other nodes in the network, and allocate bandwidth to it on the physical links it passes through. Set the source node that generates the transaction as x. For the source node x that generates transaction a, the communication layer finds a spanning tree in the network topology with x as the root node, and obtains the path from the source node x to any node y. The communication layer allocates bandwidth to each physical link e in the spanning tree. The routing information is expressed as
[0028] in, Indicates that the routing information of node x passes through physical link e. Set C x Represents the bandwidth allocated by the communication layer to node x.
[0029] Then each node uses its own diffusion time slot length T in the current round. tr , routing and bandwidth allocation, calculate the number of other nodes n within the diffusion range of its own transaction, and the diffusion number n of transaction a is positively correlated with the number of transactions a selected by other consensus nodes for direct verification.
[0030] During the consensus process, the size of each transaction is B and the bandwidth of node x is C x , then the one-hop transmission delay is expressed as T one-hop=B / C x , in the transaction diffusion task time slot T tr The maximum number of communication hops in the transmission link is expressed as Then for node x, the number of nodes that diffuse its own transactions to other nodes within the transaction diffusion task time slot is
[0031] Where N represents the number of nodes in the network, h x,i (g x ) represents the hop count function between node x and node i. When the hop count is less than the maximum communication hop count, h x,i (g x )=1.
[0032] Furthermore, the step S5 is specifically as follows:
[0033] At the consensus layer, a DAG blockchain consensus delay calculation model is constructed. In the DAG blockchain system, the initial weight of a transaction a is 1 when it is generated. Transaction a can be directly verified by other transactions. When these transactions are directly verified by subsequent new transactions, transaction a is said to be indirectly verified. The cumulative weight is the sum of the weights of a transaction after being directly or indirectly verified. The growth process of the cumulative weight of a transaction a is modeled as two stages: the adaptation stage and the linear growth stage. The delay expression of a transaction on the chain is as follows:
[0034] T d =T a +T l
[0035] Among them, T a represents the delay of the cumulative weight in the adaptation phase, T l Indicates the delay in the linear growth stage of cumulative weight. The number of other transactions k verified by transaction a and the number of diffusion nodes n are negatively correlated with the final on-chain delay of transaction a.
[0036] The consensus delay calculation method in the DAG blockchain consensus delay calculation model is as follows:
[0037] (1) Consensus delay calculation based on transaction verification of other transactions k;
[0038] During the computing time slot, a node allocates part of its own computing resources to approve and verify transactions generated by other nodes and then diffused to itself. In this case, there is a priority queue of transactions to be verified at each node, and the queue is prioritized according to the number of other transactions verified by each transaction.
[0039] Among them, the more other transactions an exchange approves for verification, the higher the transaction is in the queue after being spread to other nodes, and the higher the probability of being selected for verification, which reduces its on-chain latency.
[0040] (2) Consensus delay calculation based on the number of transaction diffusion nodes n;
[0041] In the diffusion time slot, the node uses the bandwidth allocated by the system to diffuse the transactions it generates to other nodes based on the calculated routing information. The more nodes it can diffuse to, the more times the transaction can be directly verified during the consensus phase, which ultimately reduces the latency of the transaction being uploaded to the chain.
[0042] The cumulative weight growth model of a new transaction is expressed as follows: In the adaptation stage, the weight is Increase.
[0043] Where t represents time, W(t) represents the expected cumulative weight of a transaction over time, and h represents the average disclosure time of a transaction, that is, the duration of a time slot T s ; F ver represents the verification factor; represents the diffusion factor.
[0044] After the adaptation phase, it enters the linear growth phase, and the cumulative weight grows linearly at a rate of λ, which is expressed as follows:
[0045]
[0046] Among them, T a represents the duration of the adaptation phase, then we can get T a The expression is as follows:
[0047]
[0048] The value of the cumulative weight at the end of the adaptation phase is expressed as follows:
[0049]
[0050] The cumulative weight expression at different times is as follows:
[0051]
[0052] Assuming the cumulative weight threshold for a transaction to be officially on-chain is w, the time in the linear growth stage is T l The expression is as follows:
[0053]
[0054] Furthermore, the step S6 is specifically as follows:
[0055] S61. Construct a resource allocation model in the chain-network fusion scenario and determine the objective function;
[0056] Based on steps S3 and S4, a resource allocation model for the chain-network fusion scenario is constructed. By dynamically adjusting the computing resource allocation of each node in the network and designing the routing and bandwidth allocation strategy of the communication layer, the goal is to minimize the average on-chain latency of transactions generated by each node. The objective function expression is as follows:
[0057]
[0058] f i,ver +f i,cal ≤f i
[0059] T i,cal +T i,tr ≤T s
[0060] T i,cal ≤T cal,m
[0061] Where C=[C1,C2,…,C N ] represents the bandwidth allocation in the system, f=[f 1, f2,…,f N ] represents the computing resource allocation of each node, R = [R1, R2, …, R N ] represents the routing information of each node, and the decision variable of the objective function is the node computing resource allocation f i,ver , f i,cal and routing and bandwidth allocation R i , C i , f i,cal represents the computing resources allocated to node i for computing-intensive tasks, and f i,ver Indicates the computing resources allocated by node i for verifying other exchanges; C i represents the bandwidth allocated by the system to node i in the communication layer, R i Represents the routing information of node i in the communication layer. The first constraint condition indicates that the bandwidth resources allocated on any physical link shall not exceed the bandwidth upper limit of the physical link. The second constraint condition is that the sum of computing resources used for computing and verification by any node shall not exceed the computing resource upper limit of the node. The third constraint condition is that the computing time slot of any node shall not exceed the time slot length T in the diffusion time slot. s ,The fourth constraint is that the length of the computation time slot must not exceed the ,tolerance upper limit.
[0062] S62, modeling the routing and bandwidth allocation strategy problem of the communication layer as a multi-item network flow problem, and using a multi-agent reinforcement learning MARL method to solve the routing and bandwidth allocation strategy;
[0063] The computing resource allocation results of each node are known, that is, the computing resource amount f allocated to each node for computing tasks is known i,cal , then the calculation time slot length T of each node is calculated i,cal , and then get the diffusion time slot length T of each node i,tr , and the amount of computing resources allocated to each node to verify other transactions f i,ver , replace the computing resource related variables with the constant M, and change C i and R i As decision variables, the routing and bandwidth allocation strategy problem expression is as follows:
[0064]
[0065] t i ≤T i,tr
[0066] That is, under the condition of known computing resource allocation and the premise of determining the diffusion time slot of each node, the routing and bandwidth allocation strategy of each node is dynamically adjusted to minimize the average link delay. Multi-agent reinforcement learning is used to solve this problem. Three key parts are defined in the MARL model: state space, action space and reward function, as follows:
[0067] 1) State space;
[0068] The state space contains all possible network configurations or conditions. Each state represents a specific arrangement of network elements, including: the routing information combination of each node, the traffic load status of the link, and the bandwidth allocation status of each link. Define the transaction generated by node i as a i , the number of transactions flowing through link j is n j , the set of transactions flowing on link j can be expressed as l j ={a i ,…,a k}, define L = {l1,l2,…,l E} represents the status information of each communication link; define f i,j ={C i,j ,t i,j} is the state information of the transaction generated by node i at link j, C i,j represents the bandwidth allocated to node i by link j, t i,j Indicates transaction a i The total communication delay from the source node to the link j is i,j >T i,tr , that is, the communication delay is greater than the diffusion time slot length of node i, then C i,j =0, F = {f 1,1 ,f 1,2,…,f N,j} represents the state information of each node on each link. Let the state space be S, and the state s at round t t ∈S is represented by s t ={L,F}.
[0069] 2) Action space;
[0070] Routing selection requires that each node be used as a source node and a spanning tree be generated as a communication path to other nodes. Based on the above state space considerations, the action space of the current round needs to give the routing information of each node in the next round of the DAG blockchain system, that is, the spanning tree with each node as the root node. The routing information of node i is defined as in Then it means that the routing information of node i passes through physical link e, R={R1,…,R N} represents the routing status information of each node, then the action space expression of round t is as follows:
[0071] a t ={R}
[0072] 3) Reward function;
[0073] At round t, the reinforcement learning agent is in state s t Select an action and get an immediate reward r from the environment t , then update to state s t+1 .
[0074] In the routing and bandwidth allocation strategy problem, the average uplink delay is used to represent the performance of the routing algorithm under the same network topology and link bandwidth constraints. At the same time, the diffusion slot length of each node and the bandwidth limit of each physical link are used as constraints. The reward function of round t is defined as r t (s t ,a t )=T, where F in T i,tr The routing and bandwidth allocation scheme is determined by the communication layer solution. The physical link bandwidth constraint expression of the system is as follows:
[0075]
[0076] The diffusion time slot length constraint expression of each node is as follows:
[0077] t i ≤T i,tr
[0078] When the routing and bandwidth allocation strategies meet the two constraints, the average on-chain delay is used as a single-step reward to guide the reinforcement learning model to update parameters; when the routing and bandwidth allocation strategies do not meet the two constraints, the reward is set to 0 to make the model realize the irrationality of the decision.
[0079] S63. In the computing resource allocation of the consensus layer, the gradient descent method and Ipopt solver are used to solve the computing resource allocation strategy;
[0080] Given the routing and bandwidth allocation strategy, that is, the bandwidth C allocated by the system to each node i And the spanning tree with each node as the root as the node routing information R i , replace the routing and bandwidth allocation related variables with constant A, and change f i,ver and f i,cal As decision variables, the expression of computing resource allocation strategy problem is as follows:
[0081]
[0082] stf i,ver +f i,cal ≤f i
[0083] T i,cal +T i,tr ≤T s
[0084] T i,cal ≤T cal,m
[0085] That is, when the routing and bandwidth allocation are known, the computing resource allocation strategy of each node is dynamically adjusted, which is expressed as f = {f 1,cal ,f 2,cal ,…,f N,cal}, where f i,cal Represents the computing resources allocated to node i for computing tasks. The optimization goal is to minimize the average link latency. The problem is solved using the gradient descent method and the Ipopt solver. The solution steps are as follows:
[0086] 1) Select the initial point, select each node to allocate the least computing resources for the computing task to meet the constraint that the computing time slot does not exceed the upper limit of tolerance, and set the learning rate, that is, the step size for each parameter update;
[0087] 2) Calculate the gradient of the objective function at the current parameter point. In the problem of computing resource allocation strategy, the objective function is a multivariable function involving the computing resource allocation of each node. The gradient expression is as follows:
[0088]
[0089] 3) Update parameters. Update parameters according to gradient and learning rate. The update formula is as follows:
[0090]
[0091] Among them, α represents the learning rate, which determines the step size of each update.
[0092] 4) Check convergence and determine whether the current parameters meet the convergence conditions. It is intended to use the maximum number of iterations and set the threshold of the gradient norm. If the convergence conditions are not met, repeat steps 2)-4) and update the parameters until the convergence conditions are met;
[0093] 5) Take the parameters at the final convergence as output and generate the computing resources f corresponding to each node under this solution i,ver and f i,cal Assignment results.
[0094] S64. Based on steps S61-S63, the optimal resource allocation strategy is output through iteration to achieve the optimal average on-chain delay of the DAG blockchain system.
[0095] Beneficial effects of the present invention: The method of the present invention first divides the blockchain system into a consensus layer and a communication layer. The consensus layer adopts a DAG blockchain architecture, and the communication layer is used as the underlying network to support the nodes in the consensus stage to propagate transaction information. Then, a scheme based on multi-agent and reinforcement learning technology is proposed. According to the real-time business requirements and the real-time usage status of the communication network resources, the computing resource division of the consensus layer nodes, the communication layer routing, and the bandwidth resources are dynamically jointly optimized to achieve the optimal average on-chain delay of the DAG blockchain system while meeting the constraints such as business delay and system resource upper limit. The method of the present invention dynamically adjusts the computing resources of the nodes, allocates part of the computing resources to approve and verify other transactions on the premise of meeting the business computing delay requirements, improves the priority of its own transactions, reduces the average on-chain delay of transactions, and improves the overall performance of the DAG blockchain system, and not only considers the computing resource allocation problem of the nodes in the network, but also considers the optimization of the underlying communication network that supports the message transmission in the consensus process. Based on the underlying communication network topology and node communication requirements, the multi-agent reinforcement learning technology is applied to learn the routing and bandwidth allocation scheme, so that the average on-chain delay of transactions can be reduced as much as possible, and the performance challenges of scalability and delay brought by large-scale blockchain application systems can be met. BRIEF DESCRIPTION OF THE DRAWINGS
[0096] Figure 1 This is a flow chart of a chain network collaborative distributed consensus method based on DAG blockchain of the present invention.
[0097] Figure 2 This is a schematic diagram of a DAG blockchain system scenario in an embodiment of the present invention. DETAILED DESCRIPTION
[0098] The method of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0099] like Figure 1 As shown in the figure, a flow chart of a chain network collaborative distributed consensus method based on a DAG blockchain of the present invention is shown in the figure, and the specific steps are as follows:
[0100] S1. Divide the DAG blockchain system into a consensus layer and a communication layer;
[0101] This embodiment proposes a mobile edge computing (MEC) scenario driven by the DAG blockchain architecture. The applied blockchain system scenario is as follows: Figure 2 As shown in the figure, the blockchain system has to face large-scale computing-intensive business flows, requiring each verification node in the system to first calculate the task as a MEC server, and after the calculation is completed, the result is stored as a new transaction in the DAG blockchain.
[0102] The consensus layer is the DAG blockchain network, including all nodes in the network. The communication layer is the underlying communication network that supports node diffusion transactions in the consensus phase. Nodes are mapped to terminal devices in the communication layer. The underlying communication network includes: terminal devices and physical links between devices.
[0103] Among them, it is assumed that the blockchain system contains N nodes, and the nodes in the communication layer are mapped to network terminal devices, that is, the corresponding communication layer contains N terminal devices; and in the communication layer, the underlying network topology composed of network terminal devices and physical links is predetermined.
[0104] S2, divide the system time into continuous fixed time slots, the length of a time slot is T s , and a time slot is divided into two parts, the first part is the calculation time slot T cal , the latter part is the diffusion time slot T tr ;
[0105] The computing time slot completes the computing and verification tasks. Each node in the network acts as an MEC server and uses its own computing resources to provide computing services for the computing-intensive tasks offloaded by users to itself. At the same time, it acts as a verification node to complete the approval and verification of transactions generated by other nodes. After the calculation is completed, the node forms a new transaction in this round. A transaction consists of three parts: task calculation results, other verified transaction information, and the node's own signature.
[0106] The diffusion slot completes the transaction diffusion task. Each node uses the bandwidth allocated by the system to diffuse its own transactions to other nodes in the network based on the calculated routing information.
[0107] This embodiment also considers multiple factors that affect the performance of the DAG blockchain system, as follows:
[0108] First, during the computing time slot, each node must complete the approval and verification of other transactions while completing the computing task. Both tasks require the consumption of the node's own computing resources. When the node's computing resources are limited, the computing resources of the computing task and the verification task need to be allocated. In the existing DAG blockchain, each transaction only needs to verify two other transactions. However, when a transaction approves and verifies multiple other transactions, it can increase its priority for being selected for verification, thereby reducing its own on-chain latency, improving the performance of the blockchain system, and reducing the average on-chain latency.
[0109] Secondly, some existing DAG blockchain solutions pay less attention to the optimization of the underlying communication network, and usually assume that the underlying communication network is stable and reliable, and that communication resources are sufficient. In real blockchain system scenarios, as a communication network that supports message transmission in the consensus network, its topology, routing selection for communication between devices, and bandwidth allocation of transmission channels have a significant impact on the performance of the blockchain system.
[0110] S3. Based on step S2, at the consensus layer, construct a computing resource allocation strategy for each node;
[0111] S4. Based on step S2, at the communication layer, construct a routing and bandwidth allocation strategy for each node;
[0112] S5. Construct a DAG blockchain consensus delay calculation model, namely the cumulative weight growth model;
[0113] S6. Based on the model constructed in step S5, a resource allocation model for the chain-network fusion scenario is constructed. The fixed branch method is used to solve the computing resource allocation strategy and the routing and bandwidth allocation strategy constructed in steps S3 and S4, and the optimal resource allocation strategy is output through iteration.
[0114] In this embodiment, step S3 is specifically as follows:
[0115] Assume that the total number of computing resources, i.e., CPU resources, owned by each node in the network is f. For computing-intensive tasks that users offload, the size of the designed computing-intensive tasks is D. The nodes allocate their own computing resources, and part of the computing resources f cal The computing resources f are used to calculate the computing-intensive tasks offloaded by users, that is, the user computing tasks themselves. ver Used to approve and verify transactions generated by other nodes.
[0116] Among them, f cal +f ver≤f. The time required for the calculation task is T cal =D / f cal , set the size of a transaction to B, and calculate the time slot T cal During this period, the total number of transactions approved and verified by the node using the computing resources allocated to verify transactions is denoted as n ver =f ver ·T cal / B.
[0117] Then, a transaction verification selection method is designed. The verification queue priority is set according to the number of other transactions k verified by one transaction. The queue of transactions to be verified is organized in order of priority. When the transaction is broadcast to other nodes, it enters the queue of transactions to be verified at the corresponding node. Each node calculates the time slot length T according to the current round. cal As well as the allocation of computing resources, it calculates the number k of other transactions that can be verified in this round, and selects the k transactions with the highest priority from its own queue of pending transactions for approval and verification. The number k of other transactions verified by transaction a is positively correlated with the probability that transaction a is selected for direct verification by other consensus nodes.
[0118] In this embodiment, step S4 is specifically as follows:
[0119] At the communication layer, the underlying network topology is abstracted into an undirected graph G(V,E). Let C represent the upper limit of the bandwidth that each physical link can carry.
[0120] Wherein, V represents the point set of the undirected graph, that is, the set of all nodes in the network, and E represents the edge set of the undirected graph, that is, the set of physical links between terminal devices; e u,v ∈E indicates that there is a one-hop direct physical link between any device nodes u and v. Since the graph is an undirected graph, e u,v =e v,u .
[0121] Due to the need for consensus, for each transaction generated by each node in the network, it is necessary to determine the route for the transaction to spread to other nodes in the network and allocate bandwidth to it on the physical links it passes through. The source node that generates the transaction is set to x. For the source node x that generates transaction a, the communication layer finds a spanning tree in the network topology with x as the root node, and obtains the path from the source node x to any node y. The communication layer allocates bandwidth to each physical link e in the spanning tree. The routing information is expressed as
[0122] in, Indicates that the routing information of node x passes through physical link e. Set C x Represents the bandwidth allocated by the communication layer to node x.
[0123] Then each node uses its own diffusion time slot length T in the current round. tr , routing and bandwidth allocation, calculate the number of other nodes n within the diffusion range of its own transaction, and the diffusion number n of transaction a is positively correlated with the number of transactions a selected by other consensus nodes for direct verification.
[0124] During the consensus process, the size of each transaction is B and the bandwidth of node x is C x , then the one-hop transmission delay is expressed as T one-hop =B / C x , in the transaction diffusion task time slot T tr The maximum number of communication hops in the transmission link is expressed as Then for node x, the number of nodes that diffuse its own transactions to other nodes within the transaction diffusion task time slot is
[0125] Where N represents the number of nodes in the network, h x,i (g x ) represents the hop count function between node x and node i. When the hop count is less than the maximum communication hop count, h x,i (g x )=1.
[0126] In this embodiment, step S5 is specifically as follows:
[0127] At the consensus layer, a DAG blockchain consensus delay calculation model is constructed. Transaction on-chain delay refers to the time required for a transaction in the DAG blockchain system to be generated and its cumulative weight to increase to the threshold.
[0128] In the DAG blockchain system, the initial weight of a transaction a is 1 when it is generated. Transaction a can be directly verified by other transactions. When these transactions are directly verified by subsequent new transactions, transaction a is said to be indirectly verified. The cumulative weight refers to the sum of the weights of a transaction after being directly or indirectly verified. The growth process of the cumulative weight of a transaction a can be modeled into two stages, the adaptation stage and the linear growth stage. In the adaptation stage, since transaction a is a newly generated transaction and can only be directly verified by transactions generated by other nodes, the cumulative weight grows slowly. As new transactions are continuously generated, the cumulative weight of transaction a will enter the linear growth stage. During this period, transaction a is continuously indirectly verified, causing its cumulative weight to grow rapidly.
[0129] The final latency expression for a transaction to be put on the chain is as follows:
[0130] T d =T a +T l
[0131] Among them, T a represents the delay of the cumulative weight in the adaptation phase, T l Indicates the delay in the linear growth stage of cumulative weight. The number of other transactions k verified by transaction a and the number of diffusion nodes n are negatively correlated with the final on-chain delay of transaction a.
[0132] The latency of a transaction on the chain mainly depends on the number of other transactions verified in the calculation time slot and the number of nodes diffused in the diffusion time slot. The consensus latency calculation method in the DAG blockchain consensus latency calculation model is as follows:
[0133] (1) Consensus delay calculation based on transaction verification of other transactions k;
[0134] During the computing time slot, a node allocates part of its own computing resources to approve and verify transactions generated by other nodes and then diffused to itself. In this case, there is a priority queue of transactions to be verified at each node, and the queue is prioritized according to the number of other transactions verified by each transaction.
[0135] Among them, the more other transactions an exchange approves for verification, the higher the transaction is in the queue after being spread to other nodes, and the higher the probability of being selected for verification, which reduces its on-chain latency.
[0136] (2) Consensus delay calculation based on the number of transaction diffusion nodes n;
[0137] In the diffusion time slot, the node uses the bandwidth allocated by the system to diffuse the transactions it generates to other nodes based on the calculated routing information. The more nodes it can diffuse to, the more times the transaction can be directly verified during the consensus phase, thereby reducing the final transaction chain latency.
[0138] The cumulative weight growth model of a new transaction is expressed as follows: In the adaptation stage, the weight is Increase.
[0139] Where t represents time, W(t) represents the expected cumulative weight of a transaction over time, and h represents the average disclosure time of a transaction, which can be understood as the duration of a time slot in this embodiment. s ; F ver Represents the verification factor. When the transaction approves the verification of other transactions n ver The more it is, the greater the contribution of the transaction to the DAG blockchain. When the transaction is spread to other nodes, the higher the priority of being selected for verification, thereby increasing the value of this factor. To avoid the value of this factor being too large, it is normalized. Represents the diffusion factor. The more nodes in the network receive the transaction, the more times the transaction is directly verified, and the faster the weight grows.
[0140] After the adaptation phase, it enters the linear growth phase, and the cumulative weight grows linearly at a rate of λ, which is expressed as follows:
[0141]
[0142] Among them, T a represents the duration of the adaptation phase, then we can get T a The expression is as follows:
[0143]
[0144] The value of the cumulative weight at the end of the adaptation phase is expressed as follows:
[0145]
[0146] The cumulative weight expression at different times is as follows:
[0147]
[0148] Assuming the cumulative weight threshold for a transaction to be officially on-chain is w, the time in the linear growth stage is T l The expression is as follows:
[0149]
[0150] In this embodiment, step S6 is specifically as follows:
[0151] S61. Construct a resource allocation model in the chain-network fusion scenario and determine the objective function;
[0152] Based on steps S3 and S4, a resource allocation model for the chain-network fusion scenario is constructed. By dynamically adjusting the computing resource allocation of each node in the network and designing the routing and bandwidth allocation strategy of the communication layer, the transaction delay is minimized as much as possible, with the goal of minimizing the average on-chain delay of transactions generated by each node. The objective function expression is as follows:
[0153]
[0154] f i,ver +f i,cal ≤f i
[0155] T i,cal +T i,tr ≤T s
[0156] T i,cal ≤T cal,m
[0157] Where C=[C1,C2,…,C N ] represents the bandwidth allocation in the system, f=[f 1, f2,…,f N ] represents the computing resource allocation of each node, R = [R1, R2, …, R N ] represents the routing information of each node, and the decision variable of the objective function is the node computing resource allocation f i,ver , f i,cal and routing and bandwidth allocation R i , C i , f i,cal represents the computing resources allocated to node i for computing-intensive tasks, and f i,ver Indicates the computing resources allocated by node i for verifying other exchanges; C i represents the bandwidth allocated by the system to node i in the communication layer, R i Represents the routing information of node i in the communication layer. The first constraint condition indicates that the bandwidth resources allocated on any physical link shall not exceed the bandwidth upper limit of the physical link. The second constraint condition is that the sum of computing resources used for computing and verification by any node shall not exceed the computing resource upper limit of the node. The third constraint condition is that the computing time slot of any node shall not exceed the time slot length T in the diffusion time slot. s ,The fourth constraint is that the length of the computation time slot must not exceed the ,tolerance upper limit.
[0158] In order to solve the optimization problem proposed above, this embodiment adopts a fixed branch method to decompose the optimization problem into two sub-problems: routing and bandwidth allocation determination and computing resource allocation. In order to optimize the average uplink delay of the entire system, this embodiment iterates the two sub-problems until the optimal solution is output. The routing and bandwidth allocation strategy problem of the communication layer is modeled as a multi-item network flow problem, and the multi-agent reinforcement learning (MARL) method is used to learn the routing and bandwidth allocation strategy; in computing resource allocation, the gradient descent method and Ipopt solver are used to solve the computing resource allocation strategy.
[0159] S62, modeling the routing and bandwidth allocation strategy problem of the communication layer as a multi-item network flow problem, and using a multi-agent reinforcement learning MARL method to solve the routing and bandwidth allocation strategy;
[0160] The computing resource allocation results of each node are known, that is, the computing resource amount f allocated to each node for computing tasks is known i,cal , then the calculation time slot length T of each node is calculated i,cal , and then get the diffusion time slot length T of each node i,tr, and the amount of computing resources allocated to each node to verify other transactions f i,ver , replace the computing resource related variables with the constant M, and change C i and R i As decision variables, the routing and bandwidth allocation strategy problem expression is as follows:
[0161]
[0162] t i ≤T i,tr
[0163] That is, under the condition of known computing resource allocation and the premise of determining the diffusion time slot of each node, the routing and bandwidth allocation strategy of each node is dynamically adjusted to minimize the average link delay. Multi-agent reinforcement learning is used to solve this problem. Three key parts are defined in the MARL model: state space, action space and reward function, as follows:
[0164] 1) State space;
[0165] The state space contains all possible network configurations or conditions. Each state represents a specific arrangement of network elements, including: the routing information combination of each node, the traffic load status of the link, and the bandwidth allocation status of each link. Define the transaction generated by node i as a i , the number of transactions flowing through link j is n j , the set of transactions flowing on link j can be expressed as l j ={a i ,…,a k}, define L = {l1,l2,…,l E} represents the status information of each communication link; define f i,j ={C i,j ,t i,j} is the state information of the transaction generated by node i at link j, C i,j represents the bandwidth allocated to node i by link j, t i,j Indicates transaction a i The total communication delay from the source node to the link j is i,j >T i,tr , that is, the communication delay is greater than the diffusion time slot length of node i, then C i,j =0, F = {f 1,1 ,f 1,2 ,…,f N,j} represents the state information of each node on each link. Let the state space be S, and the state s at round t t ∈S is represented by s t ={L,F}.
[0166] 2) Action space;
[0167] Routing selection requires that each node be used as a source node and a spanning tree be generated as a communication path to other nodes. Based on the above state space considerations, the action space of the current round needs to give the routing information of each node in the next round of the DAG blockchain system, that is, the spanning tree with each node as the root node. The routing information of node i is defined as in Then it means that the routing information of node i passes through physical link e, R={R1,…,R N} represents the routing status information of each node, then the action space expression of round t is as follows:
[0168] a t ={R}
[0169] 3) Reward function;
[0170] At round t, the reinforcement learning agent is in state s t Select an action and get an immediate reward r from the environment t , then update to state s t+1 .
[0171] The optimization goal of the DAG blockchain system to dynamically adjust the routing and bandwidth allocation strategy is to minimize the average transaction latency of the system while meeting the bandwidth limit requirements of each link, so as to achieve the best system performance under limited communication resources. In the routing and bandwidth allocation strategy problem, the average latency is used to represent the performance of the routing selection algorithm under the same network topology and link bandwidth constraints. At the same time, the diffusion time slot length of each node and the bandwidth limit of each physical link are used as constraints. The reward function of round t is defined as r t (s t ,a t )=T, where F in T i,tr The routing and bandwidth allocation scheme is determined by the communication layer solution. The physical link bandwidth constraint expression of the system is as follows:
[0172]
[0173] The diffusion time slot length constraint expression of each node is as follows:
[0174] t i ≤T i,tr
[0175] When the routing and bandwidth allocation strategies meet the two constraints, the average on-chain delay is used as a single-step reward to guide the reinforcement learning model to update parameters; when the routing and bandwidth allocation strategies do not meet the two constraints, the reward is set to 0 to make the model realize the irrationality of the decision, thereby prompting it to iterate to a better routing and bandwidth allocation strategy.
[0176] S63. In the computing resource allocation of the consensus layer, the gradient descent method and Ipopt solver are used to solve the computing resource allocation strategy;
[0177] Given the routing and bandwidth allocation strategy, that is, the bandwidth C allocated by the system to each node i And the spanning tree with each node as the root as the node routing information R i , replace the routing and bandwidth allocation related variables with constant A, and change f i,ver and f i,cal As decision variables, the expression of computing resource allocation strategy problem is as follows:
[0178]
[0179] stf i,ver +f i,cal ≤f i
[0180] T i,cal +T i,tr ≤T s
[0181] T i,cal ≤T cal,m
[0182] That is, when the routing and bandwidth allocation are known, the computing resource allocation strategy of each node is dynamically adjusted, which is expressed as f = {f 1,cal ,f 2,cal ,…,f N,cal}, where f i,cal Represents the computing resources allocated to node i for computing tasks. The optimization goal is to minimize the average link latency. The problem is solved using the gradient descent method and the Ipopt solver. The solution steps are as follows:
[0183] 1) Select the initial point, select each node to allocate the least computing resources for the computing task to meet the constraint that the computing time slot does not exceed the upper limit of tolerance, and set the learning rate, that is, the step size for each parameter update;
[0184] 2) Calculate the gradient of the objective function at the current parameter point. In the problem of computing resource allocation strategy, the objective function is a multivariable function involving the computing resource allocation of each node. The gradient expression is as follows:
[0185]
[0186] 3) Update parameters. Update parameters according to gradient and learning rate. The update formula is as follows:
[0187]
[0188] Among them, α represents the learning rate, which determines the step size of each update.
[0189] 4) Check convergence and determine whether the current parameters meet the convergence conditions. It is intended to use the maximum number of iterations and set the threshold of the gradient norm. If the convergence conditions are not met, repeat steps 2)-4) and update the parameters until the convergence conditions are met;
[0190] 5) Take the parameters at the final convergence as output and generate the computing resources f corresponding to each node under this solution i,ver and f i,cal Assignment results.
[0191] S64. Based on steps S61-S63, the optimal resource allocation strategy is output through iteration to achieve the optimal average on-chain delay of the DAG blockchain system.
[0192] In summary, the method of the present invention dynamically adjusts the computing resources of the nodes. On the premise of meeting the business computing delay requirements, part of the computing resources are allocated to approve and verify other transactions, improve the priority of its own transactions, reduce the average transaction on-chain delay, and improve the overall performance of the DAG blockchain system. It not only considers the computing resource allocation problem of nodes in the network, but also considers the optimization of the underlying communication network that supports message transmission in the consensus process. Based on the underlying communication network topology and node communication requirements, multi-agent reinforcement learning technology is used to learn routing and bandwidth allocation schemes, so as to reduce the average transaction on-chain delay as much as possible, and can cope with the scalability and latency performance challenges brought by large-scale blockchain application systems.
[0193] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the scope of protection of the present invention is not limited to such specific statements and embodiments. For those skilled in the art, the present invention may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of the claims of the present invention.
Claims
1. A chain network collaborative distributed consensus method based on DAG blockchain, the specific steps are as follows: S1. Divide the DAG blockchain system into a consensus layer and a communication layer; The consensus layer is the DAG blockchain network, including all nodes in the network. The communication layer is the underlying communication network that supports node diffusion transactions in the consensus phase. Nodes are mapped to terminal devices in the communication layer. The underlying communication network includes: Terminal devices and physical links between devices; It is assumed that the blockchain system contains N nodes, and the nodes are mapped to network terminal devices in the communication layer, that is, the corresponding communication layer contains N terminal devices; and in the communication layer, the underlying network topology composed of network terminal devices and physical links is predetermined; S2, divide the system time into continuous fixed time slots, the length of a time slot is T s , and a time slot is divided into two parts, the first part is the calculation time slot T cal , the latter part is the diffusion time slot T tr ; The computing time slot completes the computing and verification tasks. Each node in the network, as an MEC server, uses its own computing resources to provide computing services for the computing-intensive tasks that users offload to itself, and at the same time, as a verification node, completes the approval and verification of transactions generated by other nodes. After the calculation is completed, the node forms a new transaction in this round. A transaction consists of three parts: task calculation results, other verified transaction information, and the node's own signature; The diffusion time slot completes the transaction diffusion task. Each node uses the bandwidth allocated by the system to diffuse its own transactions to other nodes in the network based on the calculated routing information. S3. Based on step S2, at the consensus layer, construct a computing resource allocation strategy for each node; S4. Based on step S2, at the communication layer, construct a routing and bandwidth allocation strategy for each node; S5. Construct a DAG blockchain consensus delay calculation model, namely the cumulative weight growth model; S6. Based on the model constructed in step S5, a resource allocation model for the chain-network fusion scenario is constructed. The fixed branch method is used to solve the computing resource allocation strategy and the routing and bandwidth allocation strategy constructed in steps S3 and S4, and the optimal resource allocation strategy is output through iteration.
2. According to claim 1, a chain network collaborative distributed consensus method based on DAG blockchain is characterized in that: The step S3 is specifically as follows: Assume that the total number of computing resources, i.e., CPU resources, owned by each node in the network is f. For the computing-intensive tasks offloaded by users, the size of the computing-intensive tasks is designed to be D. The nodes allocate their own computing resources, and a part of the computing resources f cal The computing resources f are used to calculate the computing-intensive tasks offloaded by users, that is, the user computing tasks themselves. ver Used to approve and verify transactions generated by other nodes; Among them, f cal +f ver ≤f; the time required for the calculation task is T cal =D / f cal , set the size of a transaction to B, and calculate the time slot T cal During this period, the total number of transactions approved and verified by the node using the computing resources allocated to verify transactions is denoted as n ver =f ver ·T cal / B; Then, a transaction verification selection method is designed. The verification queue priority is set according to the number k of other transactions verified by one transaction. The queue of transactions to be verified is organized in order of priority. When the transaction is broadcast to other nodes, it enters the queue of transactions to be verified at the corresponding node. Each node calculates the time slot length T according to the current round. cal As well as the allocation of computing resources, it calculates the number k of other transactions that can be verified in this round, and selects the k transactions with the highest priority from its own queue of pending transactions for approval and verification. The number k of other transactions verified by transaction a is positively correlated with the probability that transaction a is selected for direct verification by other consensus nodes.
3. According to a DAG blockchain-based chain network collaborative distributed consensus method according to claim 1, it is characterized in that: The step S4 is specifically as follows: At the communication layer, the underlying network topology is abstracted into an undirected graph G(V,E); C is set to represent the upper limit of the bandwidth that each physical link can carry; Wherein, V represents the point set of the undirected graph, that is, the set of all nodes in the network, and E represents the edge set of the undirected graph, that is, the set of physical links between terminal devices; e u,v ∈E indicates that there is a one-hop direct physical link between any device nodes u and v. Since the graph is an undirected graph, e u,v =e v,u ; For each transaction generated by each node in the network, determine the route for the transaction to spread to other nodes in the network, and allocate bandwidth to it on the physical links it passes through. Set the source node that generates the transaction as x. For the source node x that generates transaction a, the communication layer finds a spanning tree in the network topology with x as the root node, and obtains the path from the source node x to any node y. The communication layer allocates bandwidth to each physical link e in the spanning tree. The routing information is expressed as in, Indicates that the routing information of node x passes through physical link e; set C x Indicates the bandwidth allocated by the communication layer to node x; Then each node uses its own diffusion time slot length T in the current round. tr , routing and bandwidth allocation, calculate the number of other nodes n within the diffusion range of its own transaction, the diffusion number n of transaction a is positively correlated with the number of transactions a selected by other consensus nodes for direct verification; During the consensus process, the size of each transaction is B and the bandwidth of node x is C x , then the one-hop transmission delay is expressed as T one-hop =B / C x , in the transaction diffusion task time slot T tr The maximum number of communication hops in the transmission link is expressed as Then for node x, the number of nodes that diffuse its own transactions to other nodes within the transaction diffusion task time slot is Where N represents the number of nodes in the network, h x,i (g x ) represents the hop count function between node x and node i. When the hop count is less than the maximum communication hop count, h x,i (g x )=1.
4. According to claim 1, a chain network collaborative distributed consensus method based on DAG blockchain is characterized in that: The step S5 is specifically as follows: At the consensus layer, a DAG blockchain consensus delay calculation model is constructed. In the DAG blockchain system, the initial weight of a transaction a is 1 when it is generated. Transaction a can be directly verified by other transactions. When these transactions are directly verified by subsequent new transactions, transaction a is said to be indirectly verified. The cumulative weight is the sum of the weights of a transaction after being directly or indirectly verified. The growth process of the cumulative weight of a transaction a is modeled as two stages: the adaptation stage and the linear growth stage. The delay expression of a transaction on the chain is as follows: T d =T a +T l Among them, T a represents the delay of the cumulative weight in the adaptation phase, T l Indicates the delay in the linear growth stage of cumulative weight; the number of transactions k verified by transaction a and the number of diffusion nodes n are negatively correlated with the final on-chain delay of transaction a; The consensus delay calculation method in the DAG blockchain consensus delay calculation model is as follows: (1) Consensus delay calculation based on transaction verification of other transactions k; In the computing time slot, a node allocates part of its own computing resources to approve and verify transactions generated by other nodes and then diffused to itself. Then, there is a priority queue of transactions to be verified at each node, and the queue is prioritized according to the number of other transactions verified by each transaction; The more other transactions an exchange approves for verification, the higher the probability that the transaction will be selected for verification after being spread to other nodes, which reduces the latency of the transaction being uploaded to the chain. (2) Consensus delay calculation based on the number of transaction diffusion nodes n; In the diffusion time slot, the node uses the bandwidth allocated by the system to diffuse the transactions it generates to other nodes based on the calculated routing information. The more nodes it can diffuse to, the more times the transaction can be directly verified during the consensus phase, which ultimately reduces the latency of the transaction being uploaded to the chain. The cumulative weight growth model of a new transaction is expressed as follows: In the adaptation stage, the weight is Increase; Where t represents time, W(t) represents the expected cumulative weight of a transaction over time, and h represents the average disclosure time of a transaction, that is, the duration of a time slot T. s ; F ver represents the verification factor; represents the diffusion factor; After the adaptation phase, it enters the linear growth phase, and the cumulative weight grows linearly at a rate of λ, which is expressed as follows: Among them, T a represents the duration of the adaptation phase, then we can get T a The expression is as follows: The value of the cumulative weight at the end of the adaptation phase is expressed as follows: The cumulative weight expression at different times is as follows: Assuming the cumulative weight threshold for a transaction to be officially on-chain is w, the time in the linear growth stage is T l The expression is as follows:
5. According to a DAG blockchain-based chain network collaborative distributed consensus method according to claim 1, it is characterized in that: The step S6 is specifically as follows: S61. Construct a resource allocation model in the chain-network fusion scenario and determine the objective function; Based on steps S3 and S4, a resource allocation model for the chain-network fusion scenario is constructed. By dynamically adjusting the computing resource allocation of each node in the network and designing the routing and bandwidth allocation strategy of the communication layer, the goal is to minimize the average on-chain latency of transactions generated by each node. The objective function expression is as follows: f i,ver +f i,cal ≤f i T i,cal +T i,tr ≤T s T i,cal ≤T cal,m Where C=[C1,C2,…,C N ] represents the bandwidth allocation in the system, f=[f 1, f2,…,f N ] represents the computing resource allocation of each node, R = [R1, R2, …, R N ] represents the routing information of each node, and the decision variable of the objective function is the node computing resource allocation f i,ver , f i,cal and routing and bandwidth allocation R i , C i , f i,cal represents the computing resources allocated to node i for computing-intensive tasks, and f i,ver Indicates the computing resources allocated by node i for verifying other exchanges; C i represents the bandwidth allocated by the system to node i in the communication layer, R i represents the routing information of node i in the communication layer; the first constraint condition indicates that the bandwidth resources allocated on any physical link shall not exceed the bandwidth upper limit of the physical link; the second constraint condition is that the sum of computing resources used for computing and verification by any node shall not exceed the computing resource upper limit owned by the node; the third constraint condition is that the computing time slot of any node shall not exceed the time slot length T in the diffusion time slot s ,The fourth constraint is that the length of the computation time slot must not exceed the upper ,limit of tolerance; S62, modeling the routing and bandwidth allocation strategy problem of the communication layer as a multi-item network flow problem, and using a multi-agent reinforcement learning MARL method to solve the routing and bandwidth allocation strategy; The computing resource allocation results of each node are known, that is, the computing resource amount f allocated to each node for computing tasks is known i,cal , then the calculation time slot length T of each node is calculated i,cal , and then get the diffusion time slot length T of each node i,tr , and the amount of computing resources allocated to each node to verify other transactions f i,ver , replace the computing resource related variables with the constant M, and change C i and R i As decision variables, the routing and bandwidth allocation strategy problem expression is as follows: t i ≤T i,tr That is, under the condition of known computing resource allocation, under the premise of determining the diffusion time slot of each node, the routing and bandwidth allocation strategy of each node is dynamically adjusted to minimize the average link delay; multi-agent reinforcement learning is used to solve this problem, and three key parts are defined in the MARL model, namely: state space, action space and reward function, as follows: 1) State space; The state space contains all possible network configurations or conditions. Each state represents a specific arrangement of network elements, including: the routing information combination of each node, the traffic load status of the link, and the bandwidth allocation status of each link. The transaction generated by node i is defined as a i , the number of transactions flowing through link j is n j , the set of transactions flowing on link j can be expressed as l j ={a i ,…,a k }, define L = {l1,l2,…,l E } represents the status information of each communication link; define f i,j ={C i,j ,t i,j } is the state information of the transaction generated by node i at link j, C i,j represents the bandwidth allocated to node i by link j, t i,j Indicates transaction a i The total communication delay from the source node to the link j is i,j >T i,tr , that is, the communication delay is greater than the diffusion time slot length of node i, then C i,j =0, F = {f 1,1 ,f 1,2 ,…,f N,j } represents the state information of each node on each link; the state space is denoted as S, and the state s at round t t ∈S is represented by s t ={L,F}; 2) Action space; Routing selection requires that each node be used as a source node to generate a spanning tree as a communication path to other nodes; based on the above state space considerations, the action space of the current round needs to give the routing information of each node in the next round of the DAG blockchain system, that is, the spanning tree with each node as the root node; the routing information of node i is defined as e∈E, where Then it means that the routing information of node i passes through physical link e, R={R1,…,R N } represents the routing status information of each node, then the action space expression of round t is as follows: a t ={R} 3) Reward function; At round t, the reinforcement learning agent is in state s t Select an action and get an immediate reward r from the environment t , then update to state s t+1 ; In the routing and bandwidth allocation strategy problem, the average uplink delay is used to represent the performance of the routing algorithm under the same network topology and link bandwidth constraints. At the same time, the diffusion time slot length of each node and the bandwidth limit of each physical link are used as constraints. The reward function of round t is defined as r t (s t ,a t )=T, where F in T i,tr The routing and bandwidth allocation scheme is determined by the communication layer solution; the physical link bandwidth constraint expression of the system is as follows: The diffusion slot length constraint expression of each node is as follows: t i ≤T i,tr When the routing and bandwidth allocation strategies meet the two constraints, the average on-chain delay is used as a single-step reward to guide the reinforcement learning model to update parameters; when the routing and bandwidth allocation strategies do not meet the two constraints, the reward is set to 0 to make the model realize the irrationality of the decision; S63. In the computing resource allocation of the consensus layer, the gradient descent method and Ipopt solver are used to solve the computing resource allocation strategy; Given the routing and bandwidth allocation strategy, that is, the bandwidth C allocated by the system to each node i And the spanning tree with each node as the root as the node routing information R i , replace the routing and bandwidth allocation related variables with constant A, and change f i,ver and f i,cal As decision variables, the expression of computing resource allocation strategy problem is as follows: s.t.f i,ver +f i,cal ≤f i T i,cal +T i,tr ≤T s T i,cal ≤T cal,m That is, when the routing and bandwidth allocation are known, the computing resource allocation strategy of each node is dynamically adjusted, which is expressed as f = {f 1,cal ,f 2,cal ,…,f N,cal }, where f i,cal represents the computing resources allocated to node i for computing tasks. The optimization goal is to minimize the average link delay. The problem is solved using the gradient descent method and the Ipopt solver. The specific solution steps are as follows: 1) Select the initial point, select each node to allocate the least computing resources for the computing task to meet the constraint that the computing time slot does not exceed the upper limit of tolerance, and set the learning rate, that is, the step size for each parameter update; 2) Calculate the gradient of the objective function at the current parameter point. In the problem of computing resource allocation strategy, the objective function is a multivariable function involving the computing resource allocation of each node. The gradient expression is as follows: 3) Update parameters. Update parameters according to gradient and learning rate. The update formula is as follows: f new =f old -α▽f(f old ) Among them, α represents the learning rate, which determines the step size of each update; 4) Check convergence and determine whether the current parameters meet the convergence conditions. It is intended to use the maximum number of iterations and set the threshold of the gradient norm. If the convergence conditions are not met, repeat steps 2)-4) and update the parameters until the convergence conditions are met; 5) Take the parameters at the final convergence as output and generate the computing resources f corresponding to each node under this solution i,ver and f i,cal Distribution results; S64. Based on steps S61-S63, the optimal resource allocation strategy is output through iteration to achieve the optimal average on-chain delay of the DAG blockchain system.
Citation Information
Patent Citations
Collaborative computing unloading and resource allocation method and application
CN111132175A
Chain network collaborative distributed consensus fragmentation method based on reinforcement learning technology
CN117041003A
MARL-based block chain Internet of Things cooperative resource allocation optimization method
CN118540740A