# MSSP: A Blockchain Sharding Protocol Based on Multi-Shard Storage
## 4 System Design
### Block Sorting
#### 4.3.2 Priority Sorting Mechanism  
The tree like structure of blockchain eliminates the network's ability to resist double-spending attacks. To better understand this issue, we consider a specific scenario as shown in Figure 4. In shard A, a node n\({}_{1}\) attempts to execute two transactions simultaneously, intending to send the same token to node n\({}_{2}\) in shard B and node n\({}_{3}\) in shard C. At this point, the balance in the account of n\({}_{1}\) is only 1, which is insufficient to complete both transactions. However, due to the independent operation of nodes in consensus zones AB and AC, they may not be able to verify the transaction information of the other party promptly  
Figure 3: Comparison of blockchain structure between MSSP and Traditional Sharding Protocols.  
Figure 2: The relationship between sharding and consensus zones in MSSP, the nodes circled in red form consensus zone that specifically handles cross-shard transactions.  
and mistakenly assume that both transactions are valid. As a result, these two consensus zones independently add the transactions to their respective created blocks. Given the tree-like structure of the blockchain at this point, each consensus zone generates mutually independent chains, thus, the traditional mechanism for resolving transaction conflicts through rollback becomes ineffective.  
To address this issue, we propose a priority sorting mechanism.This mechanism consists of two parts: block sorting and priority auto-tuning. The consensus zone priority is set based on the total number of valid blocks generated in a cycle in the consensus zone. The block sorting process is shown in Figure 5. During the traversal process, a confirmed block is selected from each branch and sorted based on the consensus zone priority. This iteration process transforms the tree-shaped blockchain into a linear chain structure. When encountering conflicting blocks, their priorities are first checked. If a block has a higher priority, it is sorted while other conflicting blocks are discarded. Under this sorting mechanism, only blocks that have successfully passed through the sorting process without conflicts and have been confirmed are considered as valid components of the blockchain.  
Figure 4: The double-spending attack example in MSSP.  
Figure 5: Block sorting mechanism in MSSP.  
After the sorting process, the blockchain is restored to a traditional linear structure, thereby regaining the ability to resist double-spending attacks. However, this sorting mechanism is inherently unfair because blocks generated by consensus zones with higher priority are given precedence in the ordering. Since the priority of consensus zones cannot dynamically change, they become predictable, and malicious attackers can purposefully elevate the priority of their controlled consensus zones. This predictability allows them to gain an advantage more easily within the network.  
To address the fairness and security issues caused by static priorities, we propose a priority auto-tuning method. The priority auto-tuning method is shown in Algorithm 2. In this method, each consensus zone is assigned an initial priority, which decreases gradually with each block submission until it reaches the lowest priority level (Line 1-3). Once the lowest priority is reached, the priority is reset to the highest level based on predefined conditions (Line 4-6). This dynamic adjustment mechanism reduces the predictability of consensus zone priorities, making it more difficult for attackers to exploit the system and enhancing overall fairness and security.  
```
1:\(C_{i}\): Consensus zone numbering
2:\(cp\): Consensus zone priority
3:ifBlock confirmation then
4:\(cp=\texttt{decreaseCP}(C_{i})\)
5:if\(cp==\texttt{MIN\_CP}\)then
6:\(confirmations=\texttt{getConfirmations}(C_{i})\)
7:if\(confirmations\geq\texttt{REQUIRED\_CONFIGATIONS}\)then
8:\(cp=\texttt{increaseCP}(C_{i})\)
9:endif
10:endif
```  
**Algorithm 2** Adjust consensus zone priority algorithm