## 4 Proposed Frameworks with the Utilization of Competing Miners
### Blockchained EC with Hierarchical Competing Miners  
EC typically involves the following two phases: (i) first, the device offloads its data to the closest edge server (i.e., offloading phase); (ii) the edge server performs the computing  
Figure 6: Time spent for the mining tasks on the edge server in the EC-enabled blockchain versus the number of mining tasks for different numbers (K) of competing miners. task for the offloaded data (i.e., computing phase). The practical and critical issue of EC is that the offloading phase is exposed to eavesdropping and is even vulnerable to some malicious secrecy attacks. To resolve this issue and strengthen the security during the offloading phase of EC, in this article, we suggest applying the blockchain to the offloading phase of the EC. In particular, we employ multiple competing miners hierarchically. This novel framework is called blockchain EC and is depicted in Figure 7.  
As shown in Figure 7, blockchain EC works as follows: First, the data acquired by each device are sent to other devices in the same network to start the mining task. In each device, we employ multiple competing miners (rather than a single miner) for better support. When the competing miners on each device finish the mining task, they send the mined block to the device for identification. Afterwards, the devices in the network compete again with each other. Through this competition, the block mined first is identified and is finally added to the blockchain. Overall, in blockchain EC, the competition occurs first over the miners on each device and then over the devices in the network, consequently forming a hierarchy of competitions. Through this framework, the security could be significantly increased, not only by encrypting the data before it leaves the devices but also by eliminating the single point of failure as explained in Section 3.2. The experiments in this section used the same CPU, experiment environment, methods, and base parameters as those used in Section 4.2. We first ran experiments on different numbers of mining tasks to see if the offloading time was different for a higher number of tasks, and the results are depicted in Figure 8. In Figure 8 the experiment was done on K = 1 to 4 miners. However, since our framework does not focus on lowering the offloading time but on lowering the total latency overall, there was no difference in offloading time for different amounts of competing miners. As we can observe, there is a stable rise in offloading time as the number of mining tasks increases. At a low number of mining tasks, the offloading time is around 0.02 s, while it increases to 0.14 s at a high number of mining tasks. Figure 7: Blockchained EC with hierarchical competing miners. Based on the discussions in Section 2, one can naturally expect that hierarchically competing miners can achieve a higher performance compared with the case of only a single miner and even for the case of competing miners solely on each device. To confirm this, in Figures 9 and 10, the average latency required for mining and offloading in blockchain EC and the corresponding energy consumption are plotted for various values of difficulty level D. For these figures, we consider an EC network with three devices and one edge server. Additionally, the number K of hierarchical competing miners ranged from two to four and the number of mining tasks was set to 100. At most, four miners were used to make the experiments more realistic, as most UAVs do not have enough resources (i.e., processing power) to employ more miners. In Figures 9 and 10, the performance for the case of K = 1 is also presented as a baseline. In Figure 9, the combined times from blockchain mining and the offloading time are added together and shown as average latency. Figure 8: Offloading time for each number of mining tasks. Figure 9: Average latency required for mining and offloading in blockchain EC versus difficulty level D for different numbers (K) of hierarchical competing miners.