# A Robust Sharding-Enabled Blockchain with Efficient Hashgraph Mechanism for MANETs
## 6 Shard Recovery and Reconfiguration  
With the assistance of \(cTx^{e}\), the compromised shard can be recovered by other shards. To help readers clearly understand the scheme, suppose that at most, one shard is corrupted in a time. When the shard is found to be corrupted, a node within it sends a request of shard recovery to two shards along with its local \(inChain\) denoted by \(chainA^{\prime}\). The latest trusted block of \(inChain\) is denoted by \(ItBlock\) and determined based on the majority principle. For example, shards \(D\) and \(E\) are requested to recover shard \(A\), because the two latest \(cTx^{\prime}\)s generated from shard \(A\) are kept in shards \(D\) and \(E\). According to \(cTx^{\prime}\)s, the latest blocks of \(chainA^{\prime}\) in shards \(D\) and \(E\) are \(D1\) and \(E1\), respectively. Shard \(A\) confirms the latest block in \(chainA^{\prime}\) as \(A1\). \(ItBlock\) is generated in three cases in Figure 5. Particularly, \(ItBlock\ =\ A1\) for case1, \(ItBlock=E1\) for case2, and \(ItBlock\ =\ D1\) for case3. In case2, shard \(A\) is determined to be corrupted, because it does not agree with E1 confirmed by the other two shards. In case1 or case3, the reputation evaluation of shard \(A\) is based on the changes in honest/dishnest behaviors of nodes over time. \(p\) indicates the period between the time of the last sharding configuration and the timestamp of \(ItBlock\). According to the events with \(timestamp\in p\), the reputation values of shard \(A\) are calculated via a sigmoid function in (9), where \(\lambda\) and \(\epsilon\) as preset values control the range of the fast growth interval of the formula. \(I\) is the node whose events are included in the blacklist, and \(SD\) is the standard deviation of honest/dishnest behaviors of the node. In (10), \(p\) is divided into \(T\) time slots. In each time slot, \(r\) is the ratio of the number of times the node's events are included in the blacklist (\(nNBL\)) and the number of confirmed events (\(nEvent\)). \(u\) is the average of \(r\) in \(T\). \[shRep^{p}\ =\ \frac{1}{1+e^{-\lambda\cdot(1/\sum_{i\in I}SD_{i}- \epsilon)}} \tag{9}\]  
\[s.t.SD=\sqrt{\frac{\sum_{i=1}^{T}(r_{i}-u)^{2}}{T}}\]  
\[r=nNBL/nEvent\]  
\[u=\sum_{t=1}^{T}r_{t}/T\]  
For example, if a list of \(r\) of the node is \(setR1=\{0,0,0.5,0.5\}\), the node is more likely to have been compromised, because its generated events start to be included in the blacklist in the last two time slots. If a list of \(r\) of the node is \(setR2=\{0.5,0.5,0,0\}\), the node is more likely to launch on/off attacks, because it starts to work honestly or does not have any behaviors in the last two time slots. In Figure 6, the reputation values of shards whose nodes have \(setR1\), \(setR2\) and \(setR3=\{0.1,0.2,0.3,0.4\}\) are presented. The reputation values of the first two shards are the same, which are smaller than that of the third shard. It is because the changes of nodes' honest/dishnest behaviors in the first two shards are more frequent. In other words, they have more potential security risks. In addition, the reputation value of the shard decreases when more nodes in the shard change honest/dishnest behaviors. Figure 5: Three cases of a latest block in \(chainA^{\prime}\) determined by the majority principle of shards \(A\), \(D\) and \(E\). Denote the chain in shard \(A\) as \(chainA\). When the reputation value of shard \(A\) is less than threshold \(th2\), shard \(D\) and \(E\) replay the transactions after the latest trusted block in \(chainA\). If a false transaction is found by both shard \(D\) and \(E\), shard \(A\) is determined to be corrupted. Then, shard \(A\) is reconfigured, and the latest block of the chain is set to \(ltBlock\). In addition, accusation transactions associated to False Events, False Free-riding Events or Double-spent Events in \(chainA\) are generated and added into the blacklist of shard \(A\). Thus, as long as one node within a shard is honest, the shard can be recovered and its security is guaranteed.