You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.8 KiB

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