# HMM-Based Blockchain Visual Automatic Deployment System
## 3 Key Technologies and Principles of Blockchain Automation Deployment System  
### Predicting the Optimal Deployment of Blockchain through HMM  
The HMM is an extension of the Markov model that incorporates the concept of unobservable states, allowing the model to infer underlying state transfer processes from  
Figure 1: Functional design diagram of the blockchain visualization automation deployment system based on Hidden Markov Model. observable events. It is a statistical model used to study time series data and describes the relationship between two stochastic processes: one between unobservable states and the other between observations. The HMM is suitable for modeling stochastic processes in which the states are not visible but have corresponding observations [14]. The Chainmaker, as a representative of customizable blockchain, supports multiple deployment methods. By introducing the Hidden Markov Model, we are able to predict the best deployment method suitable for the current node based on its software dependency environment. This approach can significantly improve blockchain deployment efficiency and further optimize system performance. In the actual deployment scenario of blockchain, the different software-dependent environments on the currently deployed node belong to the observed states, and the different deployment methods adopted are the hidden states. By combining the above hidden and observed states, a Hidden Markov Model is formed. The HMM in the blockchain deployment process is shown in Figure 2.  
A Hidden Markov Model is a probabilistic model used to represent a doubly stochastic process [14]. In this context, \(Q\) represents the set of all deployment methods (i.e., hidden states), where \(Q=q_{1},q_{2},q_{3}\), with \(q_{1}\) denoting script-based deployment, \(q_{2}\) denoting docker deployment, and \(q_{3}\) denoting binary deployment. We assume that \(V\) is the set of software dependency environments (i.e., the set of observed states) that can be deployed by the blockchain on different devices. Specifically, the blockchain deployment requires three software dependencies: Gcc, Glibc, and Docker. Since each of these three dependencies can either be satisfied or not satisfied, the combination of their states results in \(2^{3}=8\) possible observed states, denoted as \(v_{1}\) to \(v_{8}\). For example, \(v_{1}\) could represent the state where all three dependencies (Gcc, Glibc, and Docker) are satisfied, \(v_{2}\) could represent the state where only Gcc is satisfied while Glibc and Docker are not, and so on. These eight observed states capture all the possible software dependency configurations that the blockchain deployment may encounter. For a sequence of length \(T\), \(I\) corresponds to a sequence of states and O corresponds to a sequence of observations, i.e., \(I=i_{1},i_{2},\ldots,i_{T},O=o_{1},o_{2},\ldots,o_{T}\); any hidden states \(i_{t}\in Q\); and any observed states \(o_{t}\in V\). The state transfer probability matrix \(A\) is  
\[a_{ij}=P\Big{(}\mathbf{i}_{t+1}=q_{j}\Big{)} \tag{1}\]  
of which  
\[a_{ij}=P\Big{(}i_{t+1}=q_{j}|i_{t}=q_{i}\Big{)},i=1,2,3;j=1,2,3 \tag{2}\]  
denotes the probability of transferring to the hidden state \(q_{j}\) at moment \(t+1\) given that the system is in the hidden state \(q_{i}\) at moment \(t\). Figure 2: Hidden Markov Model in the blockchain deployment process. The observed states probability matrix \(B\) is  
\[B=(b_{j}(k)) \tag{3}\]  
Among them,  
\[b_{j}(k)=P\Big{(}o_{t}=v_{k}\mid i_{t}=q_{j}\Big{)},k=1,\ldots,8;j=1,2,3 \tag{4}\]  
denotes the probability of generating an observed state \(v_{k}\) given that the system is in the hidden state \(q_{j}\) at moment \(t\). The initial probability matrix of the hidden states \(\Pi\) is  
\[\Pi=(\pi(\mathbf{i})) \tag{5}\]  
of which  
\[\pi(\mathbf{i})=P(i_{1}=q_{i}),i=1,2,3 \tag{6}\]  
denotes the probability of the initial state being \(q_{i}\) at moment \(t=i\) in the hidden states.