Low-latency Federated Learning and Blockchain for Edge Association in Digital Twin empowered 6G Networks

Emerging technologies such as digital twins and 6th Generation mobile networks (6G) have accelerated the realization of edge intelligence in Industrial Internet of Things (IIoT). The integration of digital twin and 6G bridges the physical system with digital space and enables robust instant wireless connectivity. With increasing concerns on data privacy, federated learning has been regarded as a promising solution for deploying distributed data processing and learning in wireless networks. However, unreliable communication channels, limited resources, and lack of trust among users, hinder the effective application of federated learning in IIoT. In this paper, we introduce the Digital Twin Wireless Networks (DTWN) by incorporating digital twins into wireless networks, to migrate real-time data processing and computation to the edge plane. Then, we propose a blockchain empowered federated learning framework running in the DTWN for collaborative computing, which improves the reliability and security of the system, and enhances data privacy. Moreover, to balance the learning accuracy and time cost of the proposed scheme, we formulate an optimization problem for edge association by jointly considering digital twin association, training data batch size, and bandwidth allocation. We exploit multi-agent reinforcement learning to find an optimal solution to the problem. Numerical results on real-world dataset show that the proposed scheme yields improved efficiency and reduced cost compared to benchmark learning method.


I. INTRODUCTION
Recent advancements in digital twins and 6th Generation mobile networks (6G) have paved the way for Industrial Internet of Things (IIoT) [1]. A series of edge intelligence use cases such as intelligent transportation [2], [3] and smart city [4] are envisioned to provide high-quality services to users in the IIoT network. Data processing based on Artificial Intelligence (AI) algorithms lays the foundation for enabling the provision of intelligent services in the IIoT framework. Despite such enabling technologies and recent developments, the gap between the outcome of data analysis and the true reflection of the status of their physical systems remains a major hurdle in designing robust control algorithms for physical systems [5]. In this regard, the digital twin paradigm [6] emerges as one of the most promising technologies in 6G networks that can enable the near-instant wireless connectivity and extreme-reliable wireless communication [7]. Empowered by digital twin, the 6G networks can bridge the physical systems with the digital world in real-time for realizing robust edge intelligence in IIoT.
Digital twins represent real objects or subjects with their data, functions, and communication capabilities in the digital space [8]. To reduce latency and enhance reliability for edge computing applications, we incorporate digital twins into wireless networks and propose the Digital Twin Wireless Networks (DTWN). By mapping IoT devices to digital twins in edge servers, DTWN improve the efficiency of AI algorithms and mitigates the impact of unreliable communication between users and edge servers. Moreover, DTWN interact with the physical IIoT systems in real-time through data collection and analytics to keep the digital plane synchronised with the physical system. Thus, the running state analysis and optimization of user devices can be conducted directly in the DTWN, which reduces the system cost. We have noted few works that discuss integrating digital twins with physical systems to improve their performance for different applications. For instance, in [8], the authors proposed the Experimentable Digital Twins (EDTs) that can be used to realize complex control algorithms or mental models. In particular, the authors constructed a general digital twin for complex equipment and proposed a new method for health management using digital twins [9]. In this paper, we propose to integrate digital twins into edge networks to mitigate the resource gap between end users and Base Stations (BSs) for efficient edge computing.
Conventional centralized AI algorithms require data to be transmitted to the server, which incurs high data leakage risks. To enhance data security and protect user privacy, federated learning [10], [11] has emerged as a new paradigm for distributed machine learning. Different from conventional AI algorithms, federated learning based models require transmitting only the parameters from locally trained models to the server while the original data is stored with the user to alleviate security and privacy risks [12]. To this end, the distributed framework and the enhanced data privacy assurance offered by federated learning have attracted considerable attention and have been well studied for typical MEC applications [13] such as content caching [14] and vehicular data sharing recently [15]. Nonetheless the need of conducting the iterative training process on distributed entities each with possibly limited computing resources can adversely affect the efficiency of federated learning in edge networks. To address the issue, in [16], the authors proposed a control algorithm to determine the trade-off between local update and global aggregation under a given resource budget. In [17], the authors formulated resource consumption and learning performance into an optimization problem and provided the approximate optimal solution.
Moreover, the lack of mutual trust among users is another key factor that can hinder them from participating in the learning process to realize edge intelligence. To deal with this issue, blockchain has been widely explored to build a secure collaborative learning mechanism among untrusted users. For example, the authors in [18] proposed a three layer-based architecture to manage reliable and secure connections among entities, processes and critical resources for the smart grid. Meanwhile, the efficiency and intelligence of blockchain needs to be further improved. Several studies have explored the synergy between AI algorithms and blockchain to enhance the data security and system reliability aspects in edge intelligence enabled networks. In [19], the authors presented an edge intelligence and blockchain empowered framework to enhance the security of edge service management in an IoT scenario. Similarly, in [20], the authors integrated blockchain with Deep Reinforcement Learning (DRL) for content caching in vehicular networks. As conventional AI algorithms can suffer much data transmission load while also leading to higher data leakage risk, we propose to integrate blockchain with federated learning to achieve secure and efficient edge intelligence. In our proposed framework, the federated learning parameters are recorded in the blockchain instead of the parameter server thus considerably enhancing the security of parameters and improving the reliability of models from users.
In our proposed framework, DTWN mitigate the unreliability of learning parameter transmission caused by long communication distance and limited communication resource between end users and edge servers (BSs). However, some new challenges also arise for the maintenance of digital twins. First is the associations of digital twins to various servers. It consumes considerable amount of resources to maintain digital twins by synchronizing real-time data and building corresponding models. Due to the dynamic computing and communication resources available with edge servers, the association of digital twins to corresponding servers is a crucial factor in determining the performance of DTWN, which is a largely unexplored dimension in the context of edge networks. Moreover, due to the multiple communication rounds in federated learning, the limited bandwidth available with BSs requires to be optimally allocated to improve the communication efficiency of associated edge servers. In this paper, we first design the new DTWN model by incorporating digital twins into wireless networks to mitigate the unreliable and long distance communication between users and BSs, where the user data is synchronized to BSs to construct corresponding digital twins. Based on the DTWN, we propose a permissioned blockchain empowered federated learning framework for realizing robust edge intelligence. Data analysis can be executed on their digital twins in the BS plane directly instead of in the resource constrained end users. The security and privacy of digital twin data are also enhanced by . To improve the efficiency of the proposed architecture, we formulate an optimization problem for edge association and bandwidth allocation, and design a multi-agent reinforcement learning based algorithm to find the optimal solution to it. The main contributions of this paper are summarized as follows.
• We design a new digital twin wireless network model-DTWN, which uses digital twins to mitigate the unreliable and long distance communication between end users and edge servers. • We define the edge association problem for DTWN, and propose a permissioned blockchain empowered federated learning framework for edge computing in DTWN. • To improve the efficiency of the proposed scheme, we formulate an optimization problem by jointly considering edge association and communication resource allocation to minimize the time cost, and develop a multi-agent reinforcement learning based algorithm to find the optimal solution to the problem. The rest of the paper is organized as follows. In Section II, the blockchain and federated learning model for DTWN is provided. In Section III, we formulate a new edge association problem in DTWN to minimize the total system latency. A multi-agent reinforcement learning based algorithm is developed to find the optimal solution to the problem in Section IV. Numerical results are presented in Section V. Finally, Section VI concludes the paper.

II. BLOCKCHAIN AND FEDERATED LEARNING MODEL
FOR DIGITAL TWIN NETWORKS In this section, we first present our DTWN model. Then we describe the edge association problem in DTWN in Section II-A, which is followed by the federated learning model in Section II-B. Then we introduce our blockchain model in Section II-C and the wireless communication model in Section II-D.
We consider a blockchain and federated learning empowered digital twin network model as depicted in Fig. 1. The system consists of N end users such as IoT devices and mobile devices, M BSs, and a Macro Base Station (MBS). The BSs and the MBS are equipped with MEC servers. The end devices generate running data and synchronize their data with corresponding digital twins that run on the BSs. We use .., (x iDi , y iDi )} to denote the data of end user i, where D i is the data size, x i is the data collected by end users and y i is the label of x i . The digital twin of end user i in the BSs are denoted as DT i , which is composed of behavior model M i , static running data D i and realtime dynamic state s t , DT i = (M i , D i , s t ). D i and s t is the essential data required to run digital twin applications. Instead of synchronizing all raw data to digital twins, which incurs great communication load and data leakage risk, we use federated learning to learn model M from user data. In various application scenarios, the end users may communicate with other end users to exchange running information and share data, through e.g., Device to Device (D2D) communications. Thus, the digital twins also form a network based on the connections of end users. Based on the constructed DTWN, we can obtain the running states of physical devices and make further decisions to optimize and drive the running of devices by analyzing digital twins directly.
In our proposed digital twin network model, we use federated learning to execute the training and learning process collaboratively for edge intelligence. Moreover, since the end users lack mutual trust and the digital twins consist of private data, we use permissioned blockchain to enhance the system security and data privacy. The permissioned blockchain records the data from digital twins and manages the participating users through permission control. The blockchain is maintained by the BSs, which are also the clients of the federated learning model. The MBS runs as the server for the federated learning model. In each iteration of federated learning, the MBS distributes the machine learning model parameters to BSs for training. The BSs train the model based on data from digital twins and returns the model parameters to the MBS.

A. Edge Association in DTWN
The end devices or users are mapped to the digital twins in BSs in DTWN. The maintenance of digital twins consumes a large amount of computing and communication resources for synchronizing real-time data and building corresponding models. However, the computation and communication resources in wireless networks are very limited, which should be optimally used to improve the resource utility. Thus, to associate various IoT devices with different BSs according to their computation capabilities and states of the communication channel, is a key problem in DTWN. As depicted in Fig. 1, The digital twins of IoT devices are constructed and maintained by their associated BSs. The training data and the computation tasks for training are distributed to various BSs based on the association between digital twins and the BSs. We provide the formal definition of the edge association in Definition 1.
Definition 1 (Edge Association): Consider a DTWN with N IoT users and M BSs. For any user u i , i ∈ N , the goal of edge association is to choose the target BS j ∈ M to construct the digital twin DT i of user i. The association A BS can associate with multiple digital twins, while a digital twin can only be associated with at most one BS. That is, M j=1 Φ(i, j) = D i . We perform edge association according to the datasets D i of IoT users, the computation capability of BSs f j , and the transmission rate R i,j between u i and BS j , denoted as The objective of the edge association problem is to improve the utility of resources and the efficiency of running digital twins in the DTWN.

B. Federated Learning Model
The goal of federated learning is to train a global machine learning model M based on the data from various digital twins DT i without transmitting the original training data. The learning process involves finding the parameter w for global model M that minimizes the global loss function f (w, x, y), denoted as The client BSs train their local models based on their own data. Each client minimizes the loss function on its local data through gradient descent based methods such as gradient descent and stochastic gradient descent, with a predefined learning rate. The clients then transmit the local gradients or the local models to the server MBS to update the global model, through algorithms such as federated averaging (FedAvg) [10] and Federated SGD (FedSGD). We denote the aggregation of the global model as: In the training process, the BSs train the local models based on the digital twins DT i that they maintained according to Eq. 2. A BS may contain several digital twins constructed from the end users under its coverage. Different from conventional federated learning, the BSs in our proposed scheme first aggregate their local models from multiple digital twins instead of sending the original local models to the MBS, which can reduce the transmission load. As BS m has K i digital twins, the aggregation at BS i is where D DTi is the training data of digital twin DT i and w DTi is the trained model of DT i . BS m then sends G m to the MBS, and the MBS updates the global model as The local models of digital twins are transmitted to the MBS through wireless links. The MBS collects the model parameters from all participating BSs and updates the global model. In this process, since all BSs transmit their parameters in the same period and the wireless bandwidth is limited, the communication efficiency is of vital importance for the learning phase to converge.

C. Blockchain Model
To enhance the security and reliability of digital twins from untrusted end users, the BSs act as the blockchain nodes and maintain the running of the permissioned blockchain. The digital twins are stored in the blockchain and their data is updated as the state of the corresponding user changes. Moreover, the local models of the BS are also stored in the blockchain, which can be verified by other BSs to ensure the quality of local models. Thus, there are three types of records, namely, digital twin model records, digital twin data records, and training model records.
The overall blockchain scheme for federated learning is shown in Fig. 2. The BSs first train the local training models on their own data, and then upload the trained models to the MBS. The trained models are also recorded as blockchain transactions, and broadcasted to other BSs for verification. Other BSs collect the transactions and pack them into blocks. The consensus process is executed to verify the transactions in blocks. Our consensus process is executed based on Delegated where S ini is an initial value, K i is the number of digital twins associated to BS i.
The coins of each BS are then adjusted according to their performance in the training process. If the trained model of a BS passes the verification of other BSs and the MBS, coins will be awarded to the BS. Otherwise, the BS will get no pay for its training work. A number of BSs are elected as the block producers by all BSs. In the voting process, all the BSs vote for the candidate BSs by using their own training coins. The elected BSs take turns to pack the transactions in a time interval T into a block B, and broadcast block B to other producers for verification.
In our federated learning scheme, we leverage blockchain to verify the local models before embedding them into the global model. Due to high resource consuming for block verification, the interval T should be set to multiple times of the local training period, that is, the BSs execute multiple local training iterations before transmitting local models to the MBS for global aggregation.

D. Communication Model
We use the Orthogonal Frequency Division Multiple Access (OFDMA) for wireless transmission in our system. To upload trained local models, all BSs share C sub-channels to transmit their parameters. The achievable uplink data rate from BS i to the MBS is: where C is the total number of subchannels, τ i,c is the time fraction allocated to BS i on subchannel c, W U is the bandwidth of each subchannel which is a constant value. The transmission power is P U i,c and the uplink channel gain on subchannel c is h U i,c . r −α i,m is the path loss fading of the channel between BS i and the MBS, r i,m is the distance between BS i and the MBS, and α is the path loss exponent. N 0 is the noise power and j∈N P U j,c h U j,c r −α i,m is the interference caused by other BSs using the same subchannel. In the download phase, the MBS broadcasts the global model with the rate where P D i,c is the downlink power of BS i and h D i,c is the channel gain between BS i and the MBS, is the downlink inference.

III. EDGE ASSOCIATION IN DTWN: PROBLEM FORMULATION
In this section, we first analyze the delay performance of the proposed model, and then formulates the optimization problem for edge association in DTWN to minimize the total system time cost under the given learning accuracy requirement. Now we start to derive the formulation of edge association problem. We consider that the gradient ∇f (w) of f (w) is L-Lipschitz smooth, that is where L is a positive constant and ||w t+1 −w t || is the norm of w t+1 −w t . We consider that the loss function f (w) is strongly convex, that is (10) Many loss functions for federated learning can satisfy the above assumptions, for example, the logic loss functions. If (9) and (10) are satisfied, the upper bound of global iterations can be obtained as [21] T where θ L is the local accuracy ||∇f (wt+1)|| ||∇f (wt)|| ≤ θ L , θ G is the global accuracy, and 0 ≤ θ L , θ G ≤ 1. As in [17], we consider θ L as a fixed value, so that the upper bound T (θ L , θ G ) can be simplified to T (θ G ) = 1 1−θ G . Denote the time of one local training iteration by T cmp , then the computation time in one global iteration is log(1/θ)T cmp , and the upper bound of total learning time is T (θ G )T glob .
The time cost in our proposed scheme mainly consists of 1) Local training on digital twins: The time cost for the local training of BS i is decided by the computing capability and the data size of its digital twins. The time cost is where f C is the number of CPU cycles required to train one sample of data, f C i is the CPU frequency of BS i, b j is the training batchsize of digital twin DT j . 2) Model aggregation on BSs: The BSs aggregate its local models from various digital twins according to Eq. (4). The computing time for local aggregation is where |w j | is the size of local models and f C b is the number of CPU cycles required to aggregate one unit of data. Since all the clients share the same global model, |w 1 | = |w 2 | = ... = |w j | = |w g |. Thus the time cost for local aggregation is 3) Transmission of model parameters: The local models aggregated by BS i are then broadcasted to other BSs as transactions. The time cost is related to the number of blockchain nodes and the transmission efficiency. Since other BSs also help to transmit the transaction in the broadcast process, the time function is related to log 2 M , where M is the size of the BS network. The required time cost is where ξ is a factor of transmission time cost that can be obtained from historical running records of the transmission process.

4) Block Validation:
The block producer BS collects the transactions and packs them into a block. The block is then broadcasted to other producer BSs, and validated by them. Thus, the time cost is where M p is the number of block producers, S B is the size of a block.
Note that in the aggregation phase, the size of model parameters |w g | is small and the computing capability f i is high. Thus, compared to other phases, the time for aggregation is very small that can be neglected. Based on the above analysis, the time cost for one iteration is denoted as In the 6G network, the growth of the user scale, the ultra-low latency requirement of communication, and the dynamic network status make it an important issue to reduce the time cost of model training in various applications. Since accuracy and latency are two main metrics to evaluate the decision making abilities of digital twins in our proposed scheme, we consider the edge association problem to find the trade-off between learning accuracy and time cost of the learning process. Due to the dynamic computing and communication capabilities of various BSs, the edge association of digital twins, that is, how to allocate the digital twins of different end users to various BSs for training, is a key issue to be solved for minimizing the total time cost. Moreover, increasing the training batch size b n of each digital twin DT n can improve the learning accuracy. However, it will also increase the learning time cost to execute more computation. In addition, how to allocate the bandwidth resources to improve the communication efficiency, should also be considered. In our edge association problem, we should carefully design these policies to minimize the total time cost of the proposed scheme. Thus, we formulate the optimization problem as minimizing the time cost of federated learning under a given learning accuracy. To solve the problem, the association of digital twins, the batchsize of their training data, the bandwidth allocation should be jointly considered according to the computing capability f C i and the channel state h i,c . The optimization problem can be formulated as min Ki,bn,τi,c Constraint (18b) ensures that the sum of the number of associated digital twins does not exceed the size of total dataset. Constraint (18c) guarantees that each subchannel can only be allocated to at most one BS. Constraint (18d) ensures the range of training batch size for each digital twin. Problem (18) is a combinational problem. Since there are several products of variables in the objective function, and the time cost of each BS is also affected by the resource states of other BSs, it is challenging to solve problem (18).

IV. MULTI-AGENT DRL FOR EDGE ASSOCIATION
Since the system states are only determined by network states in the current iteration and the allocation policies in the last iteration, we regard the problem as a Markov Decision Process (MDP) and use multi-agent DRL [22] based algorithm to solve it.

A. Multi-agent DRL Framework
The proposed multi-agent reinforcement learning framework is shown in Fig. 3. In our proposed system, each BS is regarded as a DRL agent. The environment consists of BSs and digital twins of end users. Our multi-agent DRL framework consists of multiple agents, a common environment, system state S, action A and the reward function R, which are described below. where each dimension is a state vector that contains the states for all agents. • Action space: The actions of BS i in our system consist of the digital twin allocation K i , the training data batchsizes for its digital twins b i , and the bandwidth allocation τ i . Thus, the actions are denoted as a i (t) = (K i , b i , τ i ). BS agent i makes new action decisions a i (t) at the beginning of iteration t based on system state s(t). The system action is a(t) = (a 1 , ..., a i , ..., a m ).
• Reward: We define the reward function of BS i according to its time cost T i based on Eq. (17), as The reward vector of all agents is R = (R 1 , ..., R m ). According to Eq. (18), the total time cost T is decided by the maximum time cost of agents max{T 1 , T 2 , ..., T m }. Thus each DRL agent shares the same reward function in our scheme. In the training process, the BS agents adjust their actions to maximize the reward function, that is, to minimize the system time cost in each iteration.
The learning process of BS i is to find the best policy that maps its states to its actions, denoted as a i = π i (s), where a i is the action to be taken by BS i for the whole system state s. The objective is to maximize the expected reward, that is where γ is the discount rate, 0 ≤ γ ≤ 1. In the conventional DRL framework, it is hard for an agent to obtain the states of others. In our DTWN, the states of digital twins and BSs are recorded in the blockchain. A BS can retrieve records from blockchain to obtain the system states and actions of other agents in the training process.

B. Multi-agent DRL algorithm for edge association
Since the network states variable such as h and f C are continuous values, the state and action spaces are large. We adopt Deep Deterministic Policy Gradient (DDPG) algorithm to address the formulated MDP problem. The DDPG algorithm uses policy-based Actor-Critic (AC) to select and evaluate the actions, and uses Deep Q Networks (DQNs) to approximate value functions in actor and critic networks. The multiple agents share the same reward function and train their policy network cooperatively to minimize the time cost.
In the training phase, each BS agent generates the training sample s, a i , R i , s , where s is the state of DTWN in the next time slot. We leverage DQN with the tuples randomly sampled from replay memory to train the actor network π(s t |θπ) and critic network Q(s t , a i |θ Q ), with parameters θ π and θ Q . There are two sets of actor and critic networks-the primary networks and the target networks. The target networks have the same structure as the primary networks and are used to generate target values for training primary networks.
Each agent i has a actor DNN π(s t |θ π ) to determine its action a i based on current state s t , as where N is the random noise generated by the Ornstein-Uhlenbeck process [23], θ πi is the explored edge association policy. The parameters of the primary actor DNN are updated as where α π is the learning rate of the actor DNN. We train the primary critic network of agent i by taking steps in the opposite gradient direction of the loss function as where α Qi is the learning rate of the primary critic DNN, and y t is the target value generated by target networks, (a 1 , ..., a i ) are the actions of all DRL agents.
The target networks represent the old version of the primary networks. The parameters of the target action DNN θ T π and the target critic DNN θ T Q are trained in a different way. Agent i updates its target action DNN θ T πi and critic DNN θ T Qi as where β is the update rate. The proposed multi-agent reinforcement learning algorithm for edge association problem is summarized as Algorithm 1. Each agent first initializes its primary and target critic-actor DNNs, and initializes the edge association policy. Then, the primary actor DNN of agent i generates action a i based on current state and policy according to Eq. (21). The observed reward R i (e) and next state s t+1 are calculated, and the tuple (s t , a, R i (e), s t+1 ) is stored into the replay memory as training samples. The primary actor DNN and critic DNN are then updated based on Eq. (22) and Eq. (23). The target networks are updated according to Eq. (24). Initialize primary and target actor-critic networks; Initialize replay memory; 3: end for 4: for each BS i ≤ M do 5: for episode e ≤ E do 6: Initialize DTWN environment setup; 7: for each time slot t do 8: Observe current state s and execute action a i according to Eq. (21); 9: Compute reward R i (t), and transit to the next state s t+1 based on actions (a 1 , a 2 , ..., a n ) 10: Store (s t , a i (t), R i (t), s t+1 ) into replay memory 11: Update primary actor and critic networks according to Eq. (22)  The computation cost training process of the DRL can be performed offline for large number of episodes based on the dynamic system states. The trained DRL models are deployed online to optimally allocate the resources to minimize the time cost of federated learning under given learning accuracy. The actions in our multi-agent DRL for edge association are composed of digital twin association policies K, batchsize of training data b, and the bandwidth allocation policies τ . Due to the large action and state space, we adopt the actor DNN to generate actions. The complexity of our proposed learning algorithm mainly lies in the training process of actor DNN θ π and critic DNN θ Q . Consider the DNN in our algorithm has L hidden layers, and the average number of neurons in each layer is L a . Thus the time complexity for training a DNN is O(L 2 a ). The total complexity for training the multi-agent DRL model with M agents is O((M · L 2 a ) · E). Since the training at each agent is executed in parallel, the time complexity is O(L 2 a · E), which is related to the DNN size and the number of episodes.

V. NUMERICAL RESULTS
We conduct our experiment on a real-world dataset CI-FAR10 [24]. The CIFAR10 dataset consists of 60,000 images in 10 classes, including 50,000 training images and 10,000 test images. Learning on the image dataset simulates the real edge computing scenarios such as traffic flow monitoring and image recognition of smart cameras. We consider a wireless network with 1 MBS, 5 BSs, and 100 end users. The users are randomly distributed in the coverage area of BSs, as shown in Fig. 4. The CIFAR10 dataset is shuffled and assigned to the end users randomly. Thus the training data of federated learning is Independent and Identically Distributed (IID) in our experiment. The Convolutional Neural Network (CNN) [25] is adopted as the machine learning model for federated learning. The CNN model has two 5 × 5 convolution layers (with 32 channels and 64 channels, respectively) and 2 × 2 max-pooling layers, followed by a fully connected layer with 512 units. The maximum CPU frequencies of five BSs are 2.6GHz, 1.8GHz, 3.6GHz, 2.4GHz, and 2.4GHz, respectively. The transmission power of RSUs and the MBS is 34dBm and 42dBm, respectively. The bandwidth of the subchannel is set as 30MHz. N 0 is set to -174 dBm. The latency performance with respect to training rounds is shown in Fig. 5 for our proposed algorithm and the conventional learning algorithms with random edge association and with average edge association. Our proposed algorithm significantly reduces the system time cost compared with the benchmark algorithms. The multi-agent reinforcement learning algorithm optimizes digital twin association, and optimally allocates communication resources, which improves the running efficiency and reduces the system latency for our scheme. Fig.  6 depicts the learning performance of the proposed algorithm, compared with the learning algorithm with full training data and the learning algorithm with random edge association. From the results we can see that our proposed algorithm achieves a comparable convergence performance compared to fully trained federated learning, where all training data of users is utilized in each training process. The learning loss of our proposed algorithm is improved through the optimization process compared with the conventional algorithm with random edge association.  , where R i,t is the total reward of agent i in episode t, and M is the number of agents. The cumulative average time cost of our proposed multi-agent deep reinforcement learning are depicted in Fig. 7 for different values of the discount factor γ. The cost of different γ converges as the number of iterations increases, which denotes that the training process of the DRL model has maximized the cumulative reward and has minimized the system time cost. The curve with γ = 0.9 achieves the best performance, which has a higher convergence rate and smaller system time cost. The time cost for running our reinforcement learning based optimization algorithm is shown in Fig. 8. We can see that the training of our proposed optimization algorithm costs much more time than the test phase. The reason is that the training of deep reinforcement learning model is a process of iterative exploration. The agents take much time to interact with the environment to learn optimal policies. Although there are some fluctuations in the result curves, the overall time cost for training or testing in each iteration is comparable. The time is consumed mainly by the training process of the deep neural networks in reinforcement learning. From Fig. 8 we can also see that a larger discount factor γ slightly leads to a larger time cost in each iteration. The reason is that a larger discount factor incurs more computation in the policy training process, thus leading to a larger time cost. In this paper, we proposed the new DTWN model based on federated learning and blockchain, and improved the running efficiency of the proposed scheme. We first presented the DTWN model in a wireless edge network consisting of end users and BSs. We further developed a blockchain empowered federated learning scheme in DTWN for realizing edge intelligence. To improve the efficiency of the proposed scheme and better allocate the limited resources, we formulated an optimization problem for given learning accuracy. Specifically, we formulated the problem of edge association between digital twins and BSs and derived an optimal solution to the problem by exploiting the multi-agent reinforcement learning. Numerical results based on the real-world dataset demonstrated that the proposed scheme effectively reduces the learning latency and achieves good learning convergence.