A Blockchain-Based Green Consensus Method and System for Energy Recovery in Federated Learning
By adopting a decentralized consensus method on the blockchain and using mining energy for federated learning tasks, the hidden dangers and high energy consumption of centralized platforms are solved, achieving green consensus and efficient training, and improving system robustness and privacy protection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-21
- Publication Date
- 2026-04-03
AI Technical Summary
Existing blockchain consensus mechanisms for federated learning suffer from single points of failure and vulnerabilities in centralized platforms, low training efficiency, and high energy consumption during the blockchain mining process, which contradicts the trend of sustainable development.
It adopts a fully decentralized blockchain consensus method, uses blockchain mining energy for federated learning tasks, trains models through alliance collaboration and rewards them with smart contracts, protects user privacy, and achieves green consensus.
It improves the robustness and sustainability of blockchain systems, protects user privacy, optimizes federated learning efficiency, and promotes the efficient training and application of artificial intelligence models.
Smart Images

Figure CN115269723B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data security, specifically relating to a blockchain-based green consensus method and system for energy recycling oriented towards federated learning. Background Technology
[0002] Blockchain, as a disruptive decentralized paradigm, possesses characteristics such as tamper-proofness, trustlessness, traceability, and full auditability, making it a key supporting technology for building the future value internet and trust internet. In blockchain systems, the consensus protocol is the core that determines its scalability, security, and consistency. Proof-of-Work, as a representative consensus protocol, is widely used in various blockchains, where miners compete for the right to record transactions and block rewards by solving cryptographic puzzles through brute-force attacks (i.e., mining). However, this process consumes significant computing and electrical resources, violating current trends in sustainable and environmentally friendly technological development. Due to the high energy consumption and carbon emissions of blockchain mining, developing new energy-recovering blockchain consensus mechanisms and building green blockchain systems are of great significance for promoting energy conservation and emission reduction and achieving dual-carbon goals.
[0003] In recent years, with the rise of machine learning and artificial intelligence, some scholars have begun to explore using blockchain computing power to train machine learning models, particularly federated learning models. On the one hand, training a high-quality machine learning model requires a large amount of training data, while a single blockchain node generally lacks sufficient local training samples for model training. On the other hand, training a high-quality federated learning model typically consumes significant computing power and time, while its verification process is relatively much easier. Therefore, the energy wasted in blockchain mining can be recycled to train valuable federated learning models, and the trained model can be used as proof of consensus. However, current blockchain consensus mechanisms for federated learning generally rely on centralized platforms for distributing federated learning tasks and rewards, and on existing mining pool structures for training federated learning tasks. This presents risks of single points of failure and malicious actions by centralized platforms, and also results in low training efficiency. Summary of the Invention
[0004] To address the problems existing in the prior art, this invention provides a blockchain green consensus method and system for energy recovery oriented towards federated learning. Its purpose is to develop a new blockchain consensus mechanism for energy recovery, which uses the energy wasted in blockchain consensus mining in a completely decentralized manner to perform federated learning tasks while protecting user privacy, thereby training valuable artificial intelligence models and achieving the sustainability of the blockchain system.
[0005] To solve the above-mentioned technical problems, the present invention is achieved through the following technical solution:
[0006] A blockchain-based green consensus approach for energy recycling oriented towards federated learning includes:
[0007] The blockchain network receives federated learning tasks published by task publishers, and the federated learning tasks are divided into training and testing phases.
[0008] Each consensus node in the blockchain network verifies the federated learning task and generates a sequence of incomplete tasks based on the verification results.
[0009] Each participant node in the blockchain network selects the highest-priority unfinished task from the sequence of unfinished tasks.
[0010] Several alliances were formed by selecting all participating nodes that had the same unfinished task, with the goal of maximizing overall benefits.
[0011] Each consortium collaboratively trains the selected unfinished tasks through federated learning to obtain the model and generate the corresponding model transactions;
[0012] Each consortium publishes its corresponding model transactions to the blockchain network until the selected unfinished tasks enter the testing phase, at which point the model is uploaded to the off-chain data warehouse.
[0013] Each consensus node in the blockchain network selects the optimal task and retrieves the model corresponding to each alliance's model transaction from the off-chain data warehouse. The optimal task is the task with the most valid models among all incomplete tasks that have entered the testing phase.
[0014] Each consensus node in the blockchain network independently runs the model sorting smart contract and the block reward smart contract, which sort the models related to the best task and distribute the rewards, while updating the completion status of the best task.
[0015] Furthermore, the federated learning task includes a task ID, an initial model specified for the task, a task reward, a task hosting fee, model performance evaluation metrics, a block height for releasing the test dataset, a hash pointer to the test dataset specified for the task, a task publication timestamp, and a task publisher signature.
[0016] Furthermore, each consensus node in the blockchain network verifies the federated learning task and generates a sequence of incomplete tasks based on the verification results, including:
[0017] Each consensus node in the blockchain network verifies whether the publisher of the federated learning task has a preset amount of deposit to pay for task hosting fees and task rewards, and verifies whether the difference between the current block height and the preset block height of the release test dataset is greater than a preset minimum value.
[0018] If there is a preset amount of deposit that is greater than the preset minimum value, then the federated learning task will be added sequentially to the sequence of incomplete tasks.
[0019] Furthermore, the overall benefit is the sum of the benefits of all alliances that selected the same unfinished task, where the benefit of each alliance j is:
[0020]
[0021] in, The adjustment parameter is greater than zero; The attenuation coefficient is used to control the attenuation rate. Cost parameters that are greater than zero; This represents the number of participant nodes that have joined consortium j; This indicates that there is only one member in the alliance j, meaning that the member chooses to train alone to complete the task. This represents the average degree of non-independent identical distribution of the local training samples of all members in consortium j; This is the relative accuracy loss function; are binary variables, where This indicates that node m is a member of federation j; otherwise... ; This represents the size of the local training data for node m; This indicates the highest priority unfinished task; Indicates task The number of global communication iteration rounds; Indicates task The maximum number of local training iterations.
[0022] Furthermore, the process involves selecting all participating nodes with the same unfinished task to form several alliances with the goal of maximizing overall benefits, including:
[0023] All participating nodes that have selected the same unfinished task choose to send a request to join the alliance to a specific alliance or empty set that maximizes the overall benefit;
[0024] If a participant node sends a join request to an empty set, that participant node will automatically form a federation containing only itself. If a participant node does not send a join request to any federation, it will remain in the current federation.
[0025] Currently, each alliance ranks all participating nodes that have received applications to join the alliance according to their alliance benefits from highest to lowest, and accepts the application of the top-ranked participating node while rejecting the applications of other participating nodes.
[0026] Perform alliance split and merge operations to update the current alliance structure;
[0027] Repeat the above steps until no participating node sends a join request to a federation or empty set.
[0028] Furthermore, each consortium collaboratively trains a model on selected unfinished tasks through federated learning to obtain a model and generate corresponding model transactions, including:
[0029] All participating nodes in each alliance obtain the initial model specified for the selected unfinished task from the blockchain network, and train the initial model specified for the selected unfinished task using local training data to obtain the corresponding updated local model.
[0030] All participating nodes in each alliance transmit the corresponding updated local model to the alliance coordinating node, which is one of the participating nodes in each alliance.
[0031] Each alliance's coordinating node performs a weighted aggregation operation on the updated local models received from all participating nodes within the alliance to obtain an updated global model, and adds user-level differential privacy perturbations to obtain a perturbed global model.
[0032] All participating nodes in each alliance will conduct a new round of model training based on the global model of the perturbation fed back by the alliance coordinating node, until the federated learning training is completed.
[0033] Furthermore, the model transaction includes a model pointer, participation fee, aggregated public key of all members in the consortium, timestamp of the transaction, and multi-signature of all members in the consortium.
[0034] Furthermore, the model pointer is the hash value of the globally trained model.
[0035] Furthermore, each consensus node in the blockchain network selects the optimal task and retrieves the model corresponding to each consortium's model transaction from the off-chain data warehouse, including:
[0036] Each consensus node verifies all related model transactions for each unfinished task currently entering the testing phase, and obtains the task with the most valid models among all unfinished tasks currently entering the testing phase;
[0037] If, during the current testing phase, multiple incomplete tasks have the same maximum number of valid models, the task that was released first will be selected as the optimal task based on its release timestamp.
[0038] For each validated model transaction in the optimal task, each consensus node downloads the corresponding trained model from the off-chain data warehouse according to the model pointer in the model transaction, and at the same time downloads the corresponding test dataset from the off-chain data warehouse according to the hash pointer of the test dataset specified in the corresponding federated learning task.
[0039] Furthermore, each consensus node in the blockchain network independently runs a model ranking smart contract to rank the models relevant to the optimal task, including:
[0040] For each verified model transaction in the optimal task, each consensus node calculates the model performance index and generates a model ranking vector in descending order of index superiority. For models that have not completed testing, their index values are set to the unevaluated field.
[0041] Each consensus node obtains a consensus ranking vector for the optimal task by running a consensus protocol;
[0042] Each consensus node in the blockchain network independently runs a block reward smart contract to distribute rewards to the optimal task-related model, including:
[0043] Each consensus node distributes a task completion reward from the custodian address to the best-performing consortium in the consensus ranking vector.
[0044] Each consensus node confiscates the task participation fee from alliances whose performance in the consensus sorting vector is below a preset threshold, and issues a task hosting fee from the hosting address to all consensus nodes that have performed honestly.
[0045] Each consensus node refunds the task participation fee from the custodian address to the consortium whose performance in the consensus sorting vector exceeds a preset threshold.
[0046] Each consensus node awards points to honest consensus nodes, members of the best-performing alliance, and members of alliances whose performance exceeds a preset threshold.
[0047] Each consensus node removes the optimal task from the sequence of unfinished tasks.
[0048] Each consensus node obtains the final reward, final penalty, and sequence of unfinished tasks for all participants by running the consensus protocol.
[0049] Furthermore, the consensus protocol is an integral-based Algorand Byzantine consensus protocol, in which the weight of each blockchain node is determined by its integral value.
[0050] A blockchain-based green consensus system for energy recovery oriented towards federated learning, comprising consensus nodes and participant nodes on a blockchain network;
[0051] The consensus node is used to verify the federated learning tasks published on the blockchain network and generate a sequence of incomplete tasks based on the verification results; select the optimal task, obtain the model corresponding to the model transaction of each consortium from the off-chain data warehouse; run the model sorting smart contract and the block reward smart contract to sort the models related to the optimal task and distribute the rewards respectively, and update the completion status of the optimal task.
[0052] The participating nodes are used to select the highest priority unfinished task in the sequence of unfinished tasks; to form several alliances with the goal of maximizing overall benefits by having all other participating nodes that have selected the same unfinished task; to collaboratively train the selected unfinished task through federated learning within the alliances to obtain a model and generate the corresponding model transaction; to publish the corresponding model transaction of the alliance to the blockchain network until the selected unfinished task enters the testing phase, and then to upload the model to the off-chain data warehouse.
[0053] Compared with the prior art, the present invention has at least the following beneficial effects:
[0054] This invention provides an energy-recovery-based green consensus method for blockchain federated learning. Compared with existing mainstream blockchain consensus methods, this invention designs a fully decentralized, green blockchain consensus method for federated learning. By recovering the energy wasted during blockchain mining to train valuable federated learning models, it achieves computational power recovery in the blockchain consensus process, improves the robustness and sustainability of the blockchain system, protects user privacy data, and prevents privacy leaks. This solves the problems of high energy consumption and low value in existing proof-of-work-based blockchain consensus methods. As an alternative to existing proof-of-work consensus algorithms, this invention proposes to achieve efficient operation of the entire process of AI model training tasks, including outsourcing, training, and reward distribution, in a completely decentralized manner by completely removing the centralized platform. This prevents single points of failure and maximizes the utilization of existing computing power infrastructure, further promoting the deployment and application of AI as a service. This invention considers the impact of the differentiated training data sample size and sample distribution of participants in different federated learning tasks, thereby realizing a distributed adaptive federation structure partitioning for blockchain nodes for different federated learning tasks to optimize the federated learning process and learning efficiency within the federation. During the federated learning process within each consortium, the model training method of this invention possesses user-level differential privacy, which can prevent the leakage of all data records of any blockchain node in the consortium during the federated learning process, thereby enhancing the system's privacy protection capabilities. In a fully distributed and autonomous blockchain system, this invention designs a precise and efficient points-based incentive mechanism for selfish blockchain nodes, thereby promoting the participation of blockchain nodes, building a healthy consensus system, and improving consensus efficiency to optimize the consensus process.
[0055] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the specific embodiments of the present invention, the drawings used in the description of the specific embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0057] Figure 1 A diagram of entity interaction relationships in a blockchain-based green consensus for energy recovery oriented towards federated learning;
[0058] Figure 2 A model diagram of a blockchain-based green consensus system for energy recovery oriented towards federated learning;
[0059] Figure 3 A flowchart of a blockchain-based green consensus process for energy recycling oriented towards federated learning;
[0060] Figure 4 A diagram illustrating the two stages of each federated learning task;
[0061] Figure 5 A flowchart of the federated learning process based on user-level differential privacy within each consortium;
[0062] Figure 6 This is a schematic diagram of the structure of a block in the proposed blockchain. Detailed Implementation
[0063] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0064] This invention provides a blockchain-based green consensus method for energy recycling oriented towards federated learning, such as... Figure 1 As shown, it specifically includes the following entities:
[0065] 1) Federated Learning Task Publishers. Each node in the blockchain network can act as a task publisher, publishing required federated learning tasks (such as semantic analysis and biomedical image recognition) to the blockchain network. Each federated learning task has a specific completion deadline and performance requirements, as well as corresponding task rewards. The sets of published tasks and incomplete tasks in the blockchain are denoted as follows: and .
[0066] 2) Federated Learning Model Trainers. Based on pooled mining in proof-of-work blockchains, a group of model trainers in this invention can form a federation structure, exhibiting characteristics of cooperation within the federation and competition between federations. A series of federations are formed in the blockchain network, and their set is defined as... Each alliance Coordinating nodes of the corresponding alliance Management, a group of participant nodes (denoted as...) For an incomplete task Collaboratively train a qualified federated learning model, and with Compete with other alliances to obtain mission rewards.
[0067] 3) Blockchain consensus nodes. A consensus node committee consists of a group of consensus nodes, denoted as... The consensus nodes are responsible for transaction verification and new block construction. They collectively maintain an ordered queue of incomplete tasks, represented as... The consensus nodes perform model evaluation and ranking operations on the federated learning models trained by different consortia that have been published. This is done before the block height increases.
[0068] In the blockchain network of this invention, a node can simultaneously perform all three roles or two of them. The set of all nodes in the blockchain network is denoted as […]. More specifically, the system model diagram is as follows: Figure 2 As shown, the main process includes: First, the blockchain network receives federated learning tasks with rewards from task publishers, while consensus nodes collectively maintain a sequence of incomplete tasks on the blockchain; then, each participating node selects an incomplete task according to task priority, dynamically forming an optimized consortium structure; next, all members in each consortium collaboratively train the requested federated learning model using local data, and each consortium uses the collaboratively trained model as proof of work; next, consensus nodes in the blockchain network perform model verification and ranking on the best incomplete task currently in the testing phase; finally, consensus nodes run a consensus protocol, and the federated learning model with the highest performance is delivered to its publisher, with the consortium that produced the model receiving a block reward.
[0069] As a specific embodiment of the present invention, such as Figure 3 As shown, this invention provides a blockchain-based green consensus method for energy recycling oriented towards federated learning, specifically including the following steps:
[0070] Step 1: Initialize the blockchain network.
[0071] Specifically, the blockchain registry (Certificate Authority, CA) first selects a bilinear pair. ,in , ,and It is a prime number. q multiplication group and The generators are respectively and Two hash functions and Selected as a random oracle. Given security parameters as input. Bilinear pair generator Output system parameters Among them, parameters and All of them are recorded in the blockchain genesis block.
[0072] Based on this publicly available information, each participant pass Set your private key in the blockchain network, and through... Generate its own public key, where, This indicates random sampling. Each node n The wallet address can be calculated as Each blockchain node n Will The data is stored in its local tamper-proof device. A blockchain node can generate a set of public and private keys and a corresponding wallet address at once, and use different public and private keys to sign different transactions to prevent identity crosslinking. It can also periodically generate a new set of public and private keys and wallet addresses.
[0073] Step 2: The blockchain network receives federated learning tasks published by task publishers.
[0074] Task publishers generate specific machine learning problems (such as sentiment analysis and image classification) along with corresponding task requirements and rewards. Specifically, each task publisher... r A message containing a machine learning task can be sent to the blockchain network at any time. The task transaction (taskTX) has the following specific transaction format:
[0075] enter:
[0076] --Task t Task rewards and task management fee ;
[0077] --Initial Federated Learning Model ;
[0078] --Performance Evaluation Metrics Used to evaluate model performance (e.g., accuracy);
[0079] --Release test dataset block height (Measured by block height);
[0080] --Test Dataset The hash pointer.
[0081] Output: Task publishing transaction taskTX:
[0082]
[0083] In the formula, It is a unique transaction identifier, i.e., a transaction. The hash value; It is the timestamp of the transaction generation; Task publisher r Digital signatures for transactions; small-amount task hosting fees The reward will be used to reward consensus nodes Packaged into blocks, and prevents malicious publishers from sending multiple meaningless tasks that could lead to a denial-of-service attack.
[0084] like Figure 4 As shown, each federated learning task is divided into a training phase and a testing phase. To prevent malicious trainers from using the published test dataset to train the model, if the model transaction information is generated during the task testing phase (i.e., the current block height is greater than the block height of the published test dataset), the model transaction is considered invalid.
[0085] Task publishing transaction It also includes a payment transaction, where the task poster will distribute the task rewards. and task management fee Transferred to a publicly supervised hosting address The payment transaction format is as follows:
[0086] Input: Task identifier and user identifier .
[0087] Output: Payment transaction payTX:
[0088]
[0089] In the formula, This is the identifier (i.e., hash value) of the payment transaction. If the task publisher releases the test dataset at block height... The task was not released in a timely manner afterward. t The test dataset will lose these cryptocurrencies.
[0090] Step 3: Each consensus node in the blockchain network verifies the federated learning task and generates a sequence of incomplete tasks based on the verification results.
[0091] In a preferred embodiment, this step specifically includes:
[0092] Step 3.1: Each consensus node in the blockchain network verifies the publisher of the federated learning task. r Is there a pre-set (sufficient) amount of savings available to pay task rewards? and task management fee ;
[0093] Step 3.2: Each consensus node in the blockchain network verifies the current block height. i Block height compared to the preset release test dataset Is the difference greater than the preset minimum value?
[0094] Step 3.3: If there is a preset amount of deposit that is greater than the preset minimum value (i.e., verification is successful), then the federated learning task is added sequentially to the incomplete task sequence; otherwise, the task release transaction corresponding to the federated learning task is an invalid transaction and is discarded.
[0095] This invention further implements a soft handover mechanism, if the task sequence is not completed. If empty, roll back to the traditional Proof-of-Work consensus protocol.
[0096] Step 4: Each participant node in the blockchain network selects the highest priority unfinished task from the sequence of unfinished tasks.
[0097] Generally, task rewards reflect the importance and urgency of machine learning tasks. Here, since the nodes in a blockchain network are selfish and rational, it is reasonable to assume that the priority of each incomplete task t during the task testing phase is determined by the corresponding task reward. The decision is made at the current block height. In other words, model trainers (i.e., blockchain participant nodes) are more likely to consider federated learning tasks with higher rewards and longer training times. For each participant node m, its priority for each incomplete federated task t can be expressed as: .in, The adjustment parameter is greater than zero, so that the task reward and the available training time are on the same order of magnitude. These are the private preference parameters for participant node m. This indicates that participant node m only cares about the task reward. This indicates that participant node m only cares about longer training times. i represents the current block height. This indicates the block height of the test dataset published in the federated learning task t. This indicates the remaining time of the model required to train the task. Each participant node sorts all currently incomplete tasks by priority and selects the highest-priority incomplete task from the sequence. For multiple tasks with the same priority, their priorities are sorted by their release timestamps, meaning earlier-arriving tasks receive a higher ranking.
[0098] Step 5: Form several alliances by selecting all participating nodes that have selected the same unfinished task, with the goal of maximizing overall benefits.
[0099] In a preferred implementation, the overall benefit is specifically the sum of the benefits of all alliances that selected the same unfinished task. The benefit of each alliance j can be expressed as the difference between alliance satisfaction and alliance cost. For alliance j, alliance satisfaction can be expressed as an exponentially decaying function:
[0100]
[0101] in, The adjustment parameter is greater than zero; The attenuation coefficient is used to control the attenuation rate. The expected model accuracy loss of consortium j is related to factors such as the degree of non-independent and identically distributed nature of the data and the size of the training data sample, and can be expressed as follows:
[0102]
[0103] in, This represents the number of participant nodes in consortium j; This indicates that there is only one member in the alliance j, meaning that the member chooses to train alone to complete the task. This represents the average degree of non-independent identical distribution of the local training samples of all members in consortium j; This is the relative accuracy loss function; are binary variables, where This indicates that node m is a member of federation j; otherwise... . This represents the size of the local training data for node m; This indicates the unfinished task with the highest current reward. Indicates task The number of global communication iteration rounds; Indicates task The maximum number of local training iterations.
[0104] Federation costs are measured by communication costs at different federation sizes, and can be expressed as follows:
[0105]
[0106] in, Cost parameters that are greater than zero.
[0107] Therefore, the benefit of each alliance j can be expressed as:
[0108]
[0109] Preferably, several alliances are formed by selecting all participating nodes with the same unfinished task to maximize overall benefits. This process includes the following steps:
[0110] Step 5.1: Select all participating nodes with the same incomplete task to send a join request to a specific alliance or empty set that maximizes overall benefits;
[0111] Step 5.2: If a participant node sends a join request to the empty set, the participant node will automatically form a federation containing only itself. If a participant node does not send a join request to any federation, it will remain in the current federation.
[0112] Step 5.3: Each alliance sorts all participating nodes that have received alliance joining applications according to the benefits of joining the alliance, and accepts the alliance joining application of the top-ranked participating node while rejecting the alliance joining applications of other participating nodes.
[0113] Step 5.4: Perform alliance split and merge operations to update the current alliance structure;
[0114] Step 5.5: Repeat the above operation until no participant node sends a join request to a federation or empty set.
[0115] Step 6: Each consortium collaboratively trains the selected unfinished tasks through federated learning to obtain the model and generate the corresponding model transactions, as detailed below:
[0116] All participating nodes in each alliance obtain the initial model specified for the selected unfinished task from the blockchain network, and train the initial model specified for the selected unfinished task using local training data to obtain the corresponding updated local model.
[0117] All participating nodes in each alliance transmit the corresponding updated local model to the alliance coordinating node, which is one of the participating nodes in each alliance.
[0118] Each alliance's coordinating node performs a weighted aggregation operation on the updated local models received from all participating nodes within the alliance to obtain an updated global model, and adds user-level differential privacy perturbations to obtain a perturbed global model.
[0119] All participating nodes in each alliance will conduct a new round of model training based on the global model of the perturbation fed back by the alliance coordinating node, until the federated learning training is completed.
[0120] In a preferred embodiment, more specifically, this step includes the following steps:
[0121] Step 6.1: Initialize the alliance configuration;
[0122] make To participate in the training federal learning mission A collection of trainees. All model trainers dynamically form a stable alliance structure in a distributed manner according to the alliance formation method in step 5. For each alliance Each model trainer in the consortium collaboratively trains a federated learning model using local private data. Furthermore, within each consortium... In the meantime, the network latency experience is less than a preset threshold. A member is randomly selected from all members to serve as the alliance coordinating node. .
[0123] Step 6.2: Training a federated learning model with user-level differential privacy within the consortium;
[0124] like Figure 5 As shown, in this invention, each alliance member (i.e., participant node) computes the intermediate gradient of the current global model on its local dataset (i.e., local model update) and uploads it to the alliance coordinating node for periodic global aggregation (i.e., global model update). Let... Training mission for federal learning The number of communication rounds in the process.
[0125] Initially, the Alliance Each participant node in the process initializes its local model parameters to match those of the transaction. Downloaded initial model parameters .
[0126] In the k Individual wheel communication ( It includes a parallel local model training step on the participant node side and a global aggregation and perturbation addition step on the alliance coordination node side.
[0127] Step 6.2.1: Local model training on the participant node side;
[0128] After receiving the global model from the previous round After that, each participant node Using learning rate Mini-batch stochastic gradient descent algorithm is used to train a local model on its local dataset. ,Right now,
[0129]
[0130] In the formula, Represents the loss function The gradient on mini-batch samples. Then, the participant nodes. m The local model update is calculated using the following formula:
[0131]
[0132] And upload To the Alliance Coordination Node .
[0133] Step 6.2.2: Global aggregation and perturbation addition on the alliance coordination node side;
[0134] Alliance Coordination Node Aggregate the received updated local models into a global model. Furthermore, to ensure user-level privacy protection under federated learning, the consortium coordinating node applies a random function. User-level differential privacy (UDP) noise is added to the sum of scaled local model updates. Compared to traditional record-level differential privacy, this invention designs a user-level differential privacy mechanism. This approach protects all data samples used by participants during the federated learning training process, rather than protecting individual data samples from each participant. Furthermore, any adversary observing the published final model cannot, with high probability, infer the participation of any particular participant node or the usage of any particular data sample during model training, thus providing stronger user privacy protection.
[0135] More specifically, the UDP function is designed using a Gaussian mechanism. This is achieved by perturbing the sum of all updates while ensuring low model utility loss. To achieve bounded sensitivity to local updates, the alliance coordination node... Update and scale each local model to:
[0136]
[0137] Therefore, it can be guaranteed And the sensitivity upper limit for the summation operation of all scaling updates is . A ,choose .
[0138] Alliance Coordination Node Scaling Gaussian noise with zero mean to the sensitivity. A ,Right now Added to the sum of scaling updates to prevent user privacy leaks, i.e.
[0139]
[0140] In the formula, the parameter Control the scale of the Gaussian noise. Then, the alliance coordinates the nodes. Perturbation of the global model Send to all participating nodes in the alliance.
[0141] To analyze the query sensitivity of the proposed UDP mechanism, an estimator is defined in each communication round. Then the query function Sensitivity can be expressed as:
[0142]
[0143] In this invention, ,like Then the sensitivity function It is bounded and satisfies Additionally, given the number of communication rounds... and sampling rate , and ,like Then the proposed method satisfies -UDP.
[0144] Step 6.3: Repeat the above training process until the required global model accuracy or the number of communication rounds reaches its maximum value.
[0145] Step 7: Each consortium publishes its corresponding model transaction to the blockchain network until the selected incomplete task enters the testing phase, at which point the model is uploaded to the off-chain data warehouse.
[0146] As a preferred implementation, once the alliance The federated learning model process is completed, and the consortium coordinates the nodes. Generate a model transaction and the trained final federated learning model Included within it, the specific format is as follows.
[0147] enter:
[0148] --Hash pointer to the trained model ,Right now ;
[0149] --Participation Fee ;
[0150] --The aggregate public key of the model trainers (i.e., participant nodes) in the consortium ;
[0151] --Multiple signatures of model trainers in the consortium .
[0152] Output: Federated learning model transaction modelTX:
[0153]
[0154] In the formula, It is a transaction identifier.
[0155] In this invention, each consortium only submits the hash pointer of the trained federated learning model at this stage (i.e., This is to prevent copying by competitors. Once the test dataset is released, all participating consortia upload their trained models to an off-chain data warehouse. Furthermore, the model transaction (modelTX) includes a participation fee. This is used to prevent Sybil attacks by malicious trainers or malicious consortia during or after the training of federated learning models. Participation fee. The participation fee is distributed equally among all members within each consortium. For trainers whose model performance exceeds a certain threshold in the consensus model ranking, the participation fee... It will be refunded.
[0156] Similarly, a payment transaction is involved in a federated learning model transaction, namely...
[0157]
[0158] For the alliance The aggregate public key of the participating nodes in the data is:
[0159]
[0160] definition For the alliance Each member Its signature is In the alliance In this process, multi-signatures are generated by aggregating the signatures of all members.
[0161]
[0162] If the inspection is passed If so, the multi-signature is verified as correct.
[0163] Once task The training phase has ended (i.e., the current block height). The task publisher will submit the hash value previously published to the off-chain repository. The identified test dataset Afterwards, all consortia participating in the training for this task will be assigned hash values previously published to the off-chain repository. The identified federated learning model is uploaded to an off-chain repository.
[0164] Step 8: Each consensus node in the blockchain network selects the optimal task and retrieves the model corresponding to the model transaction information of each consortium from the off-chain data warehouse. The optimal task is the task with the most valid models among all the incomplete tasks that have entered the testing phase.
[0165] In a preferred embodiment, this step specifically includes:
[0166] Step 8.1: Each consensus node verifies all related model transactions for each unfinished task currently entering the testing phase, and obtains the task with the most valid models among all unfinished tasks currently entering the testing phase, which is the optimal task.
[0167] The specific verification process includes:
[0168] Step 8.1.1: Each consensus node independently adds the task release transaction taskTX, all model transactions modelTX, and payment transactions payTX related to each task to be completed to the local memory pool;
[0169] Step 8.1.2: For each consortium participating in task training Each consensus node independently verifies the collateralized deposits of the consortium. Is it no less than its participation fee? And check the block height when the model transaction is published. Is it not greater than the block height for releasing test data? ;
[0170] Preferably, for all valid tasks to be completed and entering the testing phase, each consensus node These tasks are independently ranked in descending order of priority. For each consensus node, the more trained models associated with each pending federated learning task, the greater the chance the consensus node will receive more participation fees, and the higher the priority of that task. Therefore, it is reasonable to assume that consensus nodes tend to choose the task with the most effective models among all the incomplete tasks currently in the testing phase as the optimal task. .
[0171] If multiple incomplete tasks currently in the testing phase have the same maximum number of valid models, the task that was released first will be selected as the optimal task based on the corresponding task release timestamp.
[0172] Step 8.2, Once the optimal task is completed... It ends its training phase and enters the testing phase (i.e. For each validated model transaction related to the optimal task, each consensus node downloads the corresponding trained model from the off-chain data warehouse based on the model hash pointer mID in the model transaction modelTX. Simultaneously, it downloads the corresponding test dataset from the off-chain data warehouse based on the hash pointer dID of the test dataset specified in the corresponding federated learning task transaction taskTX. .in, Indicates the duration of the testing phase (measured by block height).
[0173] Step 9: Each consensus node in the blockchain network independently runs the model sorting smart contract and the block reward smart contract to sort and distribute rewards for the models related to the best task, while updating the completion status of the best task.
[0174] As a preferred implementation, each consensus node runs a model ranking smart contract to rank all models related to the optimal task. The specific process is as follows:
[0175] For each downloaded and validated model The performance metrics of each consensus node's computation model on the test dataset. And generate a model ranking vector based on the descending order of the indicators. This refers to an ordered list of model-score pairs. Due to network latency, some pairs failed to be available during the testing phase. Models that have completed testing have their metric values set to a special "unevaluated" field. Consensus nodes generate a consensus model ranking vector using the consensus protocol. .
[0176] As a preferred implementation, each consensus node runs a block reward smart contract to distribute rewards, as follows:
[0177] Each consensus node starts from the hosting address To Consensus Ordering Vector The best performing league Distribute a task completion reward ;
[0178] Each consensus node establishes a consensus sorting vector. All alliances with medium performance below the preset threshold Confiscated task participation fee and from the hosting address To all consensus nodes that demonstrate honesty Distribute the task hosting fee, which is then equally allocated to all honest consensus nodes. ;
[0179] Each consensus node starts from the hosting address To Consensus Ordering Vector All alliances with performance above the preset threshold Refund of task participation fee ;
[0180] In addition to economic rewards, points can also incentivize blockchain nodes. A blockchain node's points reflect its honest and active participation. Points are awarded to honest consensus nodes, top-performing members of the consortium, and members of consortiums whose performance exceeds preset thresholds, with point values increasing by Δ1, Δ2, and Δ3 respectively.
[0181] Each consensus node will assign the optimal task. Delete from the unfinished task sequence;
[0182] Each consensus node obtains the final reward, final penalty, and sequence of unfinished tasks for all participants by running the consensus protocol.
[0183] Preferably, consensus nodes independently run the Algorand Byzantine consensus protocol based on points to complete the construction and on-chain operation of new blocks.
[0184] In the traditional Algorand Byzantine consensus protocol, node weights are set to their account balances, thus limiting its application to cryptocurrencies and similar fields. In this invention, each node's weight is determined by its accumulated points. Therefore, this invention is applicable to non-cryptocurrency applications and encourages node participation and honest engagement.
[0185] As a preferred implementation, the specific process of the integral-based Algorand Byzantine consensus protocol includes:
[0186] ① Consensus node committee formed;
[0187] Specifically, the members of the consensus node committee are randomly selected based on node weights using a cryptographic lottery method implemented with a Verifiable Random Function (VRF). More specifically, digital signatures and hash functions are used to implement the VRF. In the initial phase... Each node By inspection
[0188]
[0189] To independently verify whether it is a committee In the formula, The block height is i The public random seed at time, which is contained in the previous height is i-1 In the block. It is a node n The current integral value. This represents the total credit of a blockchain node. Indicates height and The number of public keys involved in the consensus process. Signatures. Represents a node n The credentials, by revealing their To prove its existence It plays the role of a consensus node. It is a random 256-character string, composed of... and The only certainty is that for anyone who doesn't know... The value of the node is indistinguishable from a random value. The symbol "." indicates that the hash value is converted to a decimal in (0,1].
[0190] ② Candidate block construction and propagation;
[0191] Specifically, sets All members are responsible for constructing candidate blocks and propagating them across the network for verification. Consensus Nodes All unfinished federated learning tasks awaiting consensus All relevant valid transactions are arranged in timestamp order and compressed into a Merkle tree format, then a candidate block is constructed. Block structure as Figure 6 As shown.
[0192] ③ Multi-stage cross-validation;
[0193] Specifically, the committee All members at block height i Each consensus phase s The middle was replaced to prevent it from being tracked by adversaries. At high altitude i of During the consensus phase, for nodes If the inequality If established, it is a committee. Members.
[0194] To mitigate block propagation delays, the committee The consensus nodes in the system vote independently on the hash value of candidate blocks, rather than voting on the entire block proposal. All consensus nodes are running -Graded Consensus (GC) protocols determine the corresponding values -grade pairs .in, This represents the number of malicious blockchain nodes. Each consensus node... Sign the voting message The gossiping protocol is used to transmit the message to other consensus nodes for mutual verification.
[0195]
[0196] In the formula, It is a candidate block for its vote.
[0197] For each consensus node If and only if At that time, it sends a voting message. Provided to other consensus nodes. Additionally, it sets the value-level pair to... .like Then set Otherwise, set .in, Represents consensus nodes v In the stage s Received messages from other different consensus nodes msg The quantity.
[0198] Committee Each consensus node in the process executes the improved Binary Byzantine Agreement (BBA*) protocol to determine the final consensus blocks and model ordering. Wherein, if If the initial input is 0, then the initial input is 0; otherwise, it is 1. If the result of the BBA* algorithm is... Then the network is The voted candidate blocks reach consensus. Otherwise, the consensus block is set to an empty block.
[0199] ④ Consensus block confirmation and addition;
[0200] Specifically, after reaching a consensus, the newly constructed candidate blocks The block will be confirmed by the blockchain and added sequentially to the blockchain. This block is linearly linked to the previous block at height [height missing] via a hash pointer. The block. For example... Figure 6 As shown, the new block metadata in Includes identifiers that have completed the federated learning task, consensus model ranking, and random seeds in the VRF. and a script This script aggregates the signature voting information of all consensus nodes during the multi-stage voting process of model ordering and consensus building. The script for each block... Consensus is reached through a consensus process, which allows new blockchain nodes to catch up with the block verification process by processing these votes. Furthermore, It can serve as a certificate, allowing any blockchain node to prove the security of the block and effectively verify the model ranking and score update process.
[0201] This invention discloses a blockchain-based green consensus system for energy recovery oriented towards federated learning, including consensus nodes and participant nodes on a blockchain network;
[0202] The consensus node is used to verify the federated learning tasks published on the blockchain network and generate a sequence of incomplete tasks based on the verification results; select the optimal task, obtain the model corresponding to the model transaction of each consortium from the off-chain data warehouse; run the model sorting smart contract and the block reward smart contract to sort the models related to the optimal task and distribute the rewards respectively, and update the completion status of the optimal task.
[0203] The participating nodes are used to select the highest priority unfinished task in the sequence of unfinished tasks; to form several alliances with the goal of maximizing overall benefits by having all other participating nodes that have selected the same unfinished task; to collaboratively train the selected unfinished task through federated learning within the alliances to obtain a model and generate the corresponding model transaction; to publish the corresponding model transaction of the alliance to the blockchain network until the selected unfinished task enters the testing phase, and then to upload the model to the off-chain data warehouse.
[0204] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of protection of the claims.
Claims
1. A blockchain-based green consensus method for energy recovery oriented towards federated learning, characterized in that, include: The blockchain network receives federated learning tasks published by task publishers, and the federated learning tasks are divided into training and testing phases. Each consensus node in the blockchain network verifies the federated learning task and generates a sequence of incomplete tasks based on the verification results. Each participant node in the blockchain network selects the highest-priority unfinished task from the sequence of unfinished tasks. Several alliances were formed by selecting all participating nodes that had the same unfinished task, with the goal of maximizing overall benefits. Each consortium collaboratively trains the selected unfinished tasks through federated learning to obtain the model and generate the corresponding model transactions; Each consortium publishes its corresponding model transactions to the blockchain network until the selected unfinished tasks enter the testing phase, at which point the model is uploaded to the off-chain data warehouse. Each consensus node in the blockchain network selects the optimal task and retrieves the model corresponding to each alliance's model transaction from the off-chain data warehouse. The optimal task is the task with the most valid models among all incomplete tasks that have entered the testing phase. Each consensus node in the blockchain network independently runs the model sorting smart contract and the block reward smart contract, which sort the models related to the best task and distribute the rewards, while updating the completion status of the best task.
2. The blockchain-based green consensus method for energy recovery oriented towards federated learning as described in claim 1, characterized in that, Each consensus node in the blockchain network verifies the federated learning task and generates a sequence of incomplete tasks based on the verification results, including: Each consensus node in the blockchain network verifies whether the publisher of the federated learning task has a preset amount of deposit to pay for task hosting fees and task rewards, and verifies whether the difference between the current block height and the preset block height of the release test dataset is greater than a preset minimum value. If there is a preset amount of deposit that is greater than the preset minimum value, then the federated learning task will be added sequentially to the sequence of incomplete tasks.
3. A blockchain-based green consensus method for energy recovery oriented towards federated learning, as described in claim 1, is characterized in that... The overall benefit is the sum of the benefits of all alliances that selected the same incomplete task, where the benefit of each alliance j is: in, The adjustment parameter is greater than zero; The attenuation coefficient is used to control the attenuation rate. Cost parameters that are greater than zero; This represents the number of participant nodes that have joined consortium j; This indicates that there is only one member in the alliance j, meaning that the member chooses to train alone to complete the task. This represents the average degree of non-independent identical distribution of the local training samples of all members in consortium j; This is the relative accuracy loss function; are binary variables, where This indicates that node m is a member of federation j; otherwise... ; This represents the size of the local training data for node m; This indicates the highest priority unfinished task; Indicates task The number of global communication iteration rounds; Indicates task The maximum number of local training iterations.
4. A blockchain-based green consensus method for energy recovery oriented towards federated learning, as described in claim 3, is characterized in that... The process involves selecting all participating nodes with the same unfinished task to form several alliances with the goal of maximizing overall efficiency, including: All participating nodes that have selected the same unfinished task choose to send a request to join the alliance to a specific alliance or empty set that maximizes the overall benefit; If a participant node sends a join request to an empty set, that participant node will automatically form a federation containing only itself. If a participant node does not send a join request to any federation, it will remain in the current federation. Currently, each alliance ranks all participating nodes that have received applications to join the alliance according to their alliance benefits from highest to lowest, and accepts the application of the top-ranked participating node while rejecting the applications of other participating nodes. Perform alliance split and merge operations to update the current alliance structure; Repeat the above steps until no participating node sends a join request to a federation or empty set.
5. A blockchain-based green consensus method for energy recovery oriented towards federated learning as described in claim 1, characterized in that, Each consortium collaboratively trains a model on selected unfinished tasks through federated learning to obtain a model and generate corresponding model transactions, including: All participating nodes in each alliance obtain the initial model specified for the selected unfinished task from the blockchain network, and train the initial model specified for the selected unfinished task using local training data to obtain the corresponding updated local model. All participating nodes in each alliance transmit the corresponding updated local model to the alliance coordinating node, which is one of the participating nodes in each alliance. Each alliance's coordinating node performs a weighted aggregation operation on the updated local models received from all participating nodes within the alliance to obtain an updated global model, and adds user-level differential privacy perturbations to obtain a perturbed global model. All participating nodes in each alliance will conduct a new round of model training based on the global model of the perturbation fed back by the alliance coordinating node, until the federated learning training is completed.
6. A blockchain-based green consensus method for energy recovery oriented towards federated learning, as described in claim 1, is characterized in that... The model transaction includes the model pointer, participation fee, aggregated public key of all members in the consortium, timestamp of the transaction, and multi-signature of all members in the consortium.
7. A blockchain-based green consensus method for energy recovery oriented towards federated learning, as described in claim 1, is characterized in that... Each consensus node in the blockchain network selects the optimal task and retrieves the model corresponding to each consortium's model transaction from the off-chain data warehouse, including: Each consensus node verifies all related model transactions for each unfinished task currently entering the testing phase, and obtains the task with the most valid models among all unfinished tasks currently entering the testing phase; If, during the current testing phase, multiple incomplete tasks have the same maximum number of valid models, the task that was released first will be selected as the optimal task based on its release timestamp. For each validated model transaction in the optimal task, each consensus node downloads the corresponding trained model from the off-chain data warehouse according to the model pointer in the model transaction, and at the same time downloads the corresponding test dataset from the off-chain data warehouse according to the hash pointer of the test dataset specified in the corresponding federated learning task.
8. A blockchain-based green consensus method for energy recovery oriented towards federated learning, as described in claim 1, is characterized in that... Each consensus node in the blockchain network independently runs a model ranking smart contract to rank the models relevant to the optimal task, including: For each verified model transaction in the optimal task, each consensus node calculates the model performance index and generates a model ranking vector in descending order of index superiority. For models that have not completed testing, their index values are set to the unevaluated field. Each consensus node obtains a consensus ranking vector for the optimal task by running a consensus protocol; Each consensus node in the blockchain network independently runs a block reward smart contract to distribute rewards to the optimal task-related model, including: Each consensus node distributes a task completion reward from the custodian address to the best-performing consortium in the consensus ranking vector. Each consensus node confiscates the task participation fee from alliances whose performance in the consensus sorting vector is below a preset threshold, and issues a task hosting fee from the hosting address to all consensus nodes that have performed honestly. Each consensus node refunds the task participation fee from the custodian address to the consortium whose performance in the consensus sorting vector exceeds a preset threshold. Each consensus node awards points to honest consensus nodes, members of the best-performing alliance, and members of alliances whose performance exceeds a preset threshold. Each consensus node removes the optimal task from the sequence of unfinished tasks. Each consensus node obtains the final reward, final penalty, and sequence of unfinished tasks for all participants by running the consensus protocol.
9. A blockchain-based green consensus method for energy recovery oriented towards federated learning, as described in claim 8, is characterized in that... The consensus protocol is the Algorand Byzantine consensus protocol based on integrals, in which the weight value of each blockchain node is determined by its integral value.
10. A blockchain-based green consensus system for energy recovery oriented towards federated learning, characterized in that, This includes consensus nodes and participant nodes on the blockchain network; The consensus node is used to verify the federated learning tasks published on the blockchain network and generate a sequence of incomplete tasks based on the verification results; select the optimal task, obtain the model corresponding to the model transaction of each consortium from the off-chain data warehouse; run the model sorting smart contract and the block reward smart contract to sort the models related to the optimal task and distribute the rewards respectively, and update the completion status of the optimal task. The participating nodes are used to select the highest priority unfinished task in the sequence of unfinished tasks; to form several alliances with the goal of maximizing overall benefits by having all other participating nodes that have selected the same unfinished task; to collaboratively train the selected unfinished task through federated learning within the alliances to obtain a model and generate the corresponding model transaction; to publish the corresponding model transaction of the alliance to the blockchain network until the selected unfinished task enters the testing phase, and then to upload the model to the off-chain data warehouse.