## 3 Scalable Dynamic Multi-Agent Byzantine Consensus
### Process
#### 3.2.1 Process in Pre-Prepare Stage
A consensus node can access the blockchain consensus system safely and fast and execute consensus algorithms with other nodes without affecting the current system performance. The consensus time meets the system tolerance conditions, and the output characteristics of the entire system are enhanced as the number of nodes increases._

In our algorithm, when a new node enters, the system judges whether the node accesses the network. If it accesses the network, the node sends the broadcast information to the surrounding nodes. When an agent node receives this broadcast message, the agent judges whether the maximum number of internal nodes in the area has been reached and, if the area is already full, does not process it. If not, the dynamic nodes are put into the area and added to the multicast list. If no agent stores the node, the node is treated as a next-level agent. The exit mechanism is relatively convenient. The agent will delete the node directly from the multicast list. To maximize the functionality of the system, an equalization server is utilized. If part of the load is larger, it is transferred to other areas to be processed and the spanning tree is reconstructed. The interface function should be set in the blockchain system to manage the identities of the nodes for access or termination. Node ID management is a basic guarantee of the permissioned blockchain. ### Safety and Liveness

As a decentralized distributed database, a perfectly correct blockchain system must be able to satisfy two important properties of distributed systems: safety and liveness. **Definition 8**. : _Safety. The safety property asserts that a system does not exhibit bad behavior. That is to say, nothing bad happens._

The ultimate goal of a consensus algorithm is to achieve consistent results. It encounters Byzantine errors, software errors and other unpredictable circumstances in the course of its work, and thus it must be fault tolerant. The fault-tolerance performance of the PBFT algorithm is \([n-1]/3\), which means that it can tolerate \(n/3\) error nodes in the system. Our proposed SDMA-PBFT algorithm isbased on PBFT, and its fault-tolerance performance also satisfies \([n-1]/3\). However, if the agent node is chosen incorrectly, the system fault tolerance is reduced. In a permissioned blockchain system, assume that \(n\) is the total number of nodes in the system, \(p\) is the probability of a single node failure, and \(k\) is the maximum number of tolerable failures. The fault-tolerance performance formula can be expressed as

\[\text{Fault}(p)=\sum_{i=k}^{n}\left(\frac{n}{k}\right)\times p^{k}\times\left( 1-p\right)^{n-k} \tag{16}\]

Assume that there are \(n=50\) nodes for consensus and the system has a maximum number of tolerable failures \(k=16\) and \(p=0.05\). The probability of failure is approximately 1.46 \(\times\)\(10^{-9}\). This demonstrates that the probability of a system error is negligible. Therefore, the safety of the BFT-based fault-tolerant algorithm is very high. In the meantime, each non-faulty node will eventually return the voting result to the client in the form of 0 or 1 in a blockchain system. The system satisfies the definition of safety. **Definition 9**. : _Liveness. The liveness property asserts that a system will eventually obtain satisfactory results._

As in a blockchain system, each node starts with an input message. At the end of the execution of the algorithm, all consensus nodes output the same results. If the number of nodes that agree exceeds \(2/3\), the blocks or transactions of clients will be accepted. We assume that the phase property guarantees that specific events will eventually occur. We define the phase property as follows: phase P = \(\{p_{1},p_{2},p_{3},\ldots,p_{n}\}\) asserts that in an infinite execution of a blockchain system, at least one of the actions will be executed infinitely often. In a blockchain system, consensus nodes participate in the voting. The main objective of voting is to check the integrity of local data and whether the message has been tampered with.