# Blockchain-Based Resource Allocation Model in Fog Computing
## Materials and Methods  
### Problem Formulation and System Model  
Fog computing, as an extension of the cloud computing model, is a weakly centralized computing paradigm compared to cloud computing. The coalition chain model in the blockchain is also a traditional centralized public chain. A weakly centralized form of distributed computing allows combining the two structures. This paper proposes a resource contribution model for fog computing based on the coalition chain technology in blockchain, which combines the fog calculation to make full use of the idle resource cooperation mode and the characteristics of the incentive model in the blockchain technology to solve the problem of resource contribution in fog computing. At the same time, the safety of the fog computing itself is solved by the high security and non-destructible modification of the blockchain technology. Figure 1 shows a blockchain-based fog computing architecture diagram, which is a typical fog computing three-layer architecture scenario. Full nodes with all block information are placed in the cloud data center. The fog computing device has limited performance and storage capacity and is a weak node in some circumstances. The light nodes in the blockchain are deployed in the fog computing device and, according to the difference in device performance, can be used to run the number of blocks that the device can withstand. After the nodes in the blockchain access the system, a series of activities, such as creating a block or voting, need to be performed. Each activity needs to record the identity of the participating nodes or verify it. Therefore, each node (i.e., the fog computing device in the figure) adds an asymmetric key as the identity. Under this mechanism, every transaction in the system can be tracked, and the disguise of illegal nodes is also prevented. As depicted in Figure 2, when the cloud data center issued a task (or other nodes request service), it requires fog node to contribute resource cooperation to complete the task. At this point, in broadcasting system, it is necessary to find the positive contribution of resources in fog node to complete the task, while, at the end of the task, it will be relevant the task information (start time, task types, task to complete satisfaction, equivalent public key, and signature information identification equipment) to be managed into a \"deal\" information. The above information is converted into a certain  
Figure 1: Blockchain-based fog computing architecture diagram. length of hash through a chain system. The blockchain system verifies the rationality of the converted \"transaction\" information and sends it to the trading pool after verification. After the time specified by the system, the blockchain system encapsulates the transaction records in the transaction pool for some time and broadcasts them. At this time, the blockchain system decides the voting win according to the DPoS consensus [17], taking into account that the performance of fog node is limited, and the computing resources are limited. Consequently, this paper adopts the DPoS consensus with low computational requirements to complete the consensus link of the block system. Besides, the design of the consensus algorithm is not the focus of this paper, so the improved DPoS consensus algorithm is adopted [44] to complete the consensus process under the architecture proposed in this work. The DPoS consensus elects a group of proxy nodes (consensus committees) through elections. These nodes are responsible for packing and message records of the blocks, while other nodes are only responsible for monitoring and forwarding. In general, the DPoS consensus process is divided into two parts: The election of the consensus member status in the agent node group and the scheduling and production of its responsible block. Considering that block producers are primarily fixed, DPoS is a consensus solution that sacrifices decentralized features to improve system throughput.