github.com/pokt-network/tendermint@v0.32.11-0.20230426215212-59310158d3e9/docs/architecture/adr-034-priv-validator-file-structure.md (about) 1 # ADR 034: PrivValidator file structure 2 3 ## Changelog 4 5 03-11-2018: Initial Draft 6 7 ## Context 8 9 For now, the PrivValidator file `priv_validator.json` contains mutable and immutable parts. 10 Even in an insecure mode which does not encrypt private key on disk, it is reasonable to separate 11 the mutable part and immutable part. 12 13 References: 14 [#1181](https://github.com/tendermint/tendermint/issues/1181) 15 [#2657](https://github.com/tendermint/tendermint/issues/2657) 16 [#2313](https://github.com/tendermint/tendermint/issues/2313) 17 18 ## Proposed Solution 19 20 We can split mutable and immutable parts with two structs: 21 ```go 22 // FilePVKey stores the immutable part of PrivValidator 23 type FilePVKey struct { 24 Address types.Address `json:"address"` 25 PubKey crypto.PubKey `json:"pub_key"` 26 PrivKey crypto.PrivKey `json:"priv_key"` 27 28 filePath string 29 } 30 31 // FilePVState stores the mutable part of PrivValidator 32 type FilePVLastSignState struct { 33 Height int64 `json:"height"` 34 Round int `json:"round"` 35 Step int8 `json:"step"` 36 Signature []byte `json:"signature,omitempty"` 37 SignBytes cmn.HexBytes `json:"signbytes,omitempty"` 38 39 filePath string 40 mtx sync.Mutex 41 } 42 ``` 43 44 Then we can combine `FilePVKey` with `FilePVLastSignState` and will get the original `FilePV`. 45 46 ```go 47 type FilePV struct { 48 Key FilePVKey 49 LastSignState FilePVLastSignState 50 } 51 ``` 52 53 As discussed, `FilePV` should be located in `config`, and `FilePVLastSignState` should be stored in `data`. The 54 store path of each file should be specified in `config.yml`. 55 56 What we need to do next is changing the methods of `FilePV`. 57 58 ## Status 59 60 Draft. 61 62 ## Consequences 63 64 ### Positive 65 66 - separate the mutable and immutable of PrivValidator 67 68 ### Negative 69 70 - need to add more config for file path 71 72 ### Neutral