mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 22:32:15 +00:00
[R4R] Add adr-034: PrivValidator file structure (#2751)
* add adr-034 * update changelog * minor changes * do some refactor
This commit is contained in:
parent
533b3cfb73
commit
e11699038d
@ -134,6 +134,8 @@ increasing attention to backwards compatibility. Thanks for bearing with us!
|
|||||||
- [abci] [\#2557](https://github.com/tendermint/tendermint/issues/2557) Add `Codespace` field to `Response{CheckTx, DeliverTx, Query}`
|
- [abci] [\#2557](https://github.com/tendermint/tendermint/issues/2557) Add `Codespace` field to `Response{CheckTx, DeliverTx, Query}`
|
||||||
- [abci] [\#2662](https://github.com/tendermint/tendermint/issues/2662) Add `BlockVersion` and `P2PVersion` to `RequestInfo`
|
- [abci] [\#2662](https://github.com/tendermint/tendermint/issues/2662) Add `BlockVersion` and `P2PVersion` to `RequestInfo`
|
||||||
- [crypto/merkle] [\#2298](https://github.com/tendermint/tendermint/issues/2298) General Merkle Proof scheme for chaining various types of Merkle trees together
|
- [crypto/merkle] [\#2298](https://github.com/tendermint/tendermint/issues/2298) General Merkle Proof scheme for chaining various types of Merkle trees together
|
||||||
|
- [docs/architecture] [\#1181](https://github.com/tendermint/tendermint/issues/1181) S
|
||||||
|
plit immutable and mutable parts of priv_validator.json
|
||||||
|
|
||||||
### IMPROVEMENTS:
|
### IMPROVEMENTS:
|
||||||
- Additional Metrics
|
- Additional Metrics
|
||||||
|
72
docs/architecture/adr-034-priv-validator-file-structure.md
Normal file
72
docs/architecture/adr-034-priv-validator-file-structure.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# ADR 034: PrivValidator file structure
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
|
||||||
|
03-11-2018: Initial Draft
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
For now, the PrivValidator file `priv_validator.json` contains mutable and immutable parts.
|
||||||
|
Even in an insecure mode which does not encrypt private key on disk, it is reasonable to separate
|
||||||
|
the mutable part and immutable part.
|
||||||
|
|
||||||
|
References:
|
||||||
|
[#1181](https://github.com/tendermint/tendermint/issues/1181)
|
||||||
|
[#2657](https://github.com/tendermint/tendermint/issues/2657)
|
||||||
|
[#2313](https://github.com/tendermint/tendermint/issues/2313)
|
||||||
|
|
||||||
|
## Proposed Solution
|
||||||
|
|
||||||
|
We can split mutable and immutable parts with two structs:
|
||||||
|
```go
|
||||||
|
// FilePVKey stores the immutable part of PrivValidator
|
||||||
|
type FilePVKey struct {
|
||||||
|
Address types.Address `json:"address"`
|
||||||
|
PubKey crypto.PubKey `json:"pub_key"`
|
||||||
|
PrivKey crypto.PrivKey `json:"priv_key"`
|
||||||
|
|
||||||
|
filePath string
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilePVState stores the mutable part of PrivValidator
|
||||||
|
type FilePVLastSignState struct {
|
||||||
|
Height int64 `json:"height"`
|
||||||
|
Round int `json:"round"`
|
||||||
|
Step int8 `json:"step"`
|
||||||
|
Signature []byte `json:"signature,omitempty"`
|
||||||
|
SignBytes cmn.HexBytes `json:"signbytes,omitempty"`
|
||||||
|
|
||||||
|
filePath string
|
||||||
|
mtx sync.Mutex
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then we can combine `FilePVKey` with `FilePVLastSignState` and will get the original `FilePV`.
|
||||||
|
|
||||||
|
```go
|
||||||
|
type FilePV struct {
|
||||||
|
Key FilePVKey
|
||||||
|
LastSignState FilePVLastSignState
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
As discussed, `FilePV` should be located in `config`, and `FilePVLastSignState` should be stored in `data`. The
|
||||||
|
store path of each file should be specified in `config.yml`.
|
||||||
|
|
||||||
|
What we need to do next is changing the methods of `FilePV`.
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Draft.
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
### Positive
|
||||||
|
|
||||||
|
- separate the mutable and immutable of PrivValidator
|
||||||
|
|
||||||
|
### Negative
|
||||||
|
|
||||||
|
- need to add more config for file path
|
||||||
|
|
||||||
|
### Neutral
|
Loading…
x
Reference in New Issue
Block a user