2018-06-20 17:35:30 -07:00
|
|
|
package privval
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/tendermint/tendermint/crypto"
|
2018-07-18 08:38:44 -07:00
|
|
|
"github.com/tendermint/tendermint/crypto/ed25519"
|
2018-07-01 22:36:49 -04:00
|
|
|
cmn "github.com/tendermint/tendermint/libs/common"
|
2018-07-03 16:31:34 +04:00
|
|
|
"github.com/tendermint/tendermint/types"
|
2018-09-01 01:33:51 +02:00
|
|
|
tmtime "github.com/tendermint/tendermint/types/time"
|
2018-06-20 17:35:30 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO: type ?
|
|
|
|
const (
|
|
|
|
stepNone int8 = 0 // Used to distinguish the initial state
|
|
|
|
stepPropose int8 = 1
|
|
|
|
stepPrevote int8 = 2
|
|
|
|
stepPrecommit int8 = 3
|
|
|
|
)
|
|
|
|
|
|
|
|
func voteToStep(vote *types.Vote) int8 {
|
|
|
|
switch vote.Type {
|
2018-10-13 01:21:46 +02:00
|
|
|
case types.PrevoteType:
|
2018-06-20 17:35:30 -07:00
|
|
|
return stepPrevote
|
2018-10-13 01:21:46 +02:00
|
|
|
case types.PrecommitType:
|
2018-06-20 17:35:30 -07:00
|
|
|
return stepPrecommit
|
|
|
|
default:
|
|
|
|
cmn.PanicSanity("Unknown vote type")
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FilePV implements PrivValidator using data persisted to disk
|
|
|
|
// to prevent double signing.
|
2018-11-17 18:48:33 +08:00
|
|
|
// NOTE: the directories containing pv.Key.filePath and pv.LastSignState.filePath must already exist.
|
2018-09-30 13:28:34 -04:00
|
|
|
// It includes the LastSignature and LastSignBytes so we don't lose the signature
|
|
|
|
// if the process crashes after signing but before the resulting consensus message is processed.
|
2018-06-20 17:35:30 -07:00
|
|
|
type FilePV struct {
|
2018-11-17 18:48:33 +08:00
|
|
|
Key FilePVKey
|
|
|
|
LastSignState FilePVLastSignState
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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"`
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
filePath string
|
|
|
|
mtx sync.Mutex
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetAddress returns the address of the validator.
|
|
|
|
// Implements PrivValidator.
|
|
|
|
func (pv *FilePV) GetAddress() types.Address {
|
2018-11-17 18:48:33 +08:00
|
|
|
return pv.Key.Address
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetPubKey returns the public key of the validator.
|
|
|
|
// Implements PrivValidator.
|
|
|
|
func (pv *FilePV) GetPubKey() crypto.PubKey {
|
2018-11-17 18:48:33 +08:00
|
|
|
return pv.Key.PubKey
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// GenFilePV generates a new validator with randomly generated private key
|
2018-11-17 18:48:33 +08:00
|
|
|
// and sets the filePaths, but does not call Save().
|
|
|
|
func GenFilePV(keyFilePath string, stateFilePath string) *FilePV {
|
2018-07-20 10:44:21 -07:00
|
|
|
privKey := ed25519.GenPrivKey()
|
2018-11-17 18:48:33 +08:00
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
return &FilePV{
|
2018-11-17 18:48:33 +08:00
|
|
|
Key: FilePVKey{
|
|
|
|
Address: privKey.PubKey().Address(),
|
|
|
|
PubKey: privKey.PubKey(),
|
|
|
|
PrivKey: privKey,
|
|
|
|
filePath: keyFilePath,
|
|
|
|
},
|
|
|
|
LastSignState: FilePVLastSignState{
|
|
|
|
Step: stepNone,
|
|
|
|
filePath: stateFilePath,
|
|
|
|
},
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-17 18:48:33 +08:00
|
|
|
// LoadFilePV loads a FilePV from the filePaths. The FilePV handles double
|
2018-11-24 17:22:11 +08:00
|
|
|
// signing prevention by persisting data to the stateFilePath. If the filePaths
|
|
|
|
// does not exist, the FilePV must be created manually and saved.
|
2018-11-17 18:48:33 +08:00
|
|
|
func LoadFilePV(keyFilePath string, stateFilePath string) *FilePV {
|
|
|
|
keyJSONBytes, err := ioutil.ReadFile(keyFilePath)
|
2018-06-20 17:35:30 -07:00
|
|
|
if err != nil {
|
|
|
|
cmn.Exit(err.Error())
|
|
|
|
}
|
2018-11-17 18:48:33 +08:00
|
|
|
pvKey := FilePVKey{}
|
|
|
|
err = cdc.UnmarshalJSON(keyJSONBytes, &pvKey)
|
2018-06-20 17:35:30 -07:00
|
|
|
if err != nil {
|
2018-11-17 18:48:33 +08:00
|
|
|
cmn.Exit(fmt.Sprintf("Error reading PrivValidator key from %v: %v\n", keyFilePath, err))
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
|
2018-07-03 16:31:34 +04:00
|
|
|
// overwrite pubkey and address for convenience
|
2018-11-17 18:48:33 +08:00
|
|
|
pvKey.PubKey = pvKey.PrivKey.PubKey()
|
|
|
|
pvKey.Address = pvKey.PubKey.Address()
|
|
|
|
pvKey.filePath = keyFilePath
|
|
|
|
|
|
|
|
stateJSONBytes, err := ioutil.ReadFile(stateFilePath)
|
|
|
|
if err != nil {
|
|
|
|
cmn.Exit(err.Error())
|
|
|
|
}
|
|
|
|
pvState := FilePVLastSignState{}
|
|
|
|
err = cdc.UnmarshalJSON(stateJSONBytes, &pvState)
|
|
|
|
if err != nil {
|
|
|
|
cmn.Exit(fmt.Sprintf("Error reading PrivValidator state from %v: %v\n", stateFilePath, err))
|
|
|
|
}
|
|
|
|
|
|
|
|
pvState.filePath = stateFilePath
|
|
|
|
|
|
|
|
pv := &FilePV{}
|
|
|
|
|
|
|
|
pv.Key = pvKey
|
|
|
|
pv.LastSignState = pvState
|
2018-07-03 16:31:34 +04:00
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
return pv
|
|
|
|
}
|
|
|
|
|
2018-11-17 18:48:33 +08:00
|
|
|
// LoadOrGenFilePV loads a FilePV from the given filePaths
|
|
|
|
// or else generates a new one and saves it to the filePaths.
|
|
|
|
func LoadOrGenFilePV(keyFilePath string, stateFilePath string) *FilePV {
|
2018-06-20 17:35:30 -07:00
|
|
|
var pv *FilePV
|
2018-11-17 18:48:33 +08:00
|
|
|
if cmn.FileExists(keyFilePath) {
|
|
|
|
pv = LoadFilePV(keyFilePath, stateFilePath)
|
2018-06-20 17:35:30 -07:00
|
|
|
} else {
|
2018-11-17 18:48:33 +08:00
|
|
|
pv = GenFilePV(keyFilePath, stateFilePath)
|
2018-06-20 17:35:30 -07:00
|
|
|
pv.Save()
|
|
|
|
}
|
|
|
|
return pv
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save persists the FilePV to disk.
|
|
|
|
func (pv *FilePV) Save() {
|
2018-11-17 18:48:33 +08:00
|
|
|
pv.saveKey()
|
|
|
|
|
|
|
|
pv.LastSignState.mtx.Lock()
|
|
|
|
defer pv.LastSignState.mtx.Unlock()
|
|
|
|
pv.saveState()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (pv *FilePV) saveKey() {
|
|
|
|
outFile := pv.Key.filePath
|
|
|
|
if outFile == "" {
|
|
|
|
panic("Cannot save PrivValidator key: filePath not set")
|
|
|
|
}
|
|
|
|
|
|
|
|
jsonBytes, err := cdc.MarshalJSONIndent(pv.Key, "", " ")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
err = cmn.WriteFileAtomic(outFile, jsonBytes, 0600)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
|
2018-11-17 18:48:33 +08:00
|
|
|
func (pv *FilePV) saveState() {
|
|
|
|
outFile := pv.LastSignState.filePath
|
2018-06-20 17:35:30 -07:00
|
|
|
if outFile == "" {
|
2018-11-17 18:48:33 +08:00
|
|
|
panic("Cannot save PrivValidator state: filePath not set")
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
2018-11-17 18:48:33 +08:00
|
|
|
jsonBytes, err := cdc.MarshalJSONIndent(pv.LastSignState, "", " ")
|
2018-06-20 17:35:30 -07:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
err = cmn.WriteFileAtomic(outFile, jsonBytes, 0600)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset resets all fields in the FilePV.
|
|
|
|
// NOTE: Unsafe!
|
|
|
|
func (pv *FilePV) Reset() {
|
2018-08-01 17:02:05 -07:00
|
|
|
var sig []byte
|
2018-11-17 18:48:33 +08:00
|
|
|
pv.LastSignState.Height = 0
|
|
|
|
pv.LastSignState.Round = 0
|
|
|
|
pv.LastSignState.Step = 0
|
|
|
|
pv.LastSignState.Signature = sig
|
|
|
|
pv.LastSignState.SignBytes = nil
|
2018-06-20 17:35:30 -07:00
|
|
|
pv.Save()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SignVote signs a canonical representation of the vote, along with the
|
|
|
|
// chainID. Implements PrivValidator.
|
|
|
|
func (pv *FilePV) SignVote(chainID string, vote *types.Vote) error {
|
2018-11-17 18:48:33 +08:00
|
|
|
pv.LastSignState.mtx.Lock()
|
|
|
|
defer pv.LastSignState.mtx.Unlock()
|
2018-06-20 17:35:30 -07:00
|
|
|
if err := pv.signVote(chainID, vote); err != nil {
|
2018-08-10 00:25:57 -05:00
|
|
|
return fmt.Errorf("Error signing vote: %v", err)
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SignProposal signs a canonical representation of the proposal, along with
|
|
|
|
// the chainID. Implements PrivValidator.
|
|
|
|
func (pv *FilePV) SignProposal(chainID string, proposal *types.Proposal) error {
|
2018-11-17 18:48:33 +08:00
|
|
|
pv.LastSignState.mtx.Lock()
|
|
|
|
defer pv.LastSignState.mtx.Unlock()
|
2018-06-20 17:35:30 -07:00
|
|
|
if err := pv.signProposal(chainID, proposal); err != nil {
|
|
|
|
return fmt.Errorf("Error signing proposal: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns error if HRS regression or no LastSignBytes. returns true if HRS is unchanged
|
|
|
|
func (pv *FilePV) checkHRS(height int64, round int, step int8) (bool, error) {
|
2018-11-17 18:48:33 +08:00
|
|
|
if pv.LastSignState.Height > height {
|
2018-06-20 17:35:30 -07:00
|
|
|
return false, errors.New("Height regression")
|
|
|
|
}
|
|
|
|
|
2018-11-17 18:48:33 +08:00
|
|
|
if pv.LastSignState.Height == height {
|
|
|
|
if pv.LastSignState.Round > round {
|
2018-06-20 17:35:30 -07:00
|
|
|
return false, errors.New("Round regression")
|
|
|
|
}
|
|
|
|
|
2018-11-17 18:48:33 +08:00
|
|
|
if pv.LastSignState.Round == round {
|
|
|
|
if pv.LastSignState.Step > step {
|
2018-06-20 17:35:30 -07:00
|
|
|
return false, errors.New("Step regression")
|
2018-11-17 18:48:33 +08:00
|
|
|
} else if pv.LastSignState.Step == step {
|
|
|
|
if pv.LastSignState.SignBytes != nil {
|
|
|
|
if pv.LastSignState.Signature == nil {
|
2018-06-20 17:35:30 -07:00
|
|
|
panic("pv: LastSignature is nil but LastSignBytes is not!")
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
return false, errors.New("No LastSignature found")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// signVote checks if the vote is good to sign and sets the vote signature.
|
|
|
|
// It may need to set the timestamp as well if the vote is otherwise the same as
|
|
|
|
// a previously signed vote (ie. we crashed after signing but before the vote hit the WAL).
|
|
|
|
func (pv *FilePV) signVote(chainID string, vote *types.Vote) error {
|
|
|
|
height, round, step := vote.Height, vote.Round, voteToStep(vote)
|
|
|
|
signBytes := vote.SignBytes(chainID)
|
|
|
|
|
|
|
|
sameHRS, err := pv.checkHRS(height, round, step)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// We might crash before writing to the wal,
|
|
|
|
// causing us to try to re-sign for the same HRS.
|
|
|
|
// If signbytes are the same, use the last signature.
|
|
|
|
// If they only differ by timestamp, use last timestamp and signature
|
|
|
|
// Otherwise, return error
|
|
|
|
if sameHRS {
|
2018-11-17 18:48:33 +08:00
|
|
|
if bytes.Equal(signBytes, pv.LastSignState.SignBytes) {
|
|
|
|
vote.Signature = pv.LastSignState.Signature
|
|
|
|
} else if timestamp, ok := checkVotesOnlyDifferByTimestamp(pv.LastSignState.SignBytes, signBytes); ok {
|
2018-06-20 17:35:30 -07:00
|
|
|
vote.Timestamp = timestamp
|
2018-11-17 18:48:33 +08:00
|
|
|
vote.Signature = pv.LastSignState.Signature
|
2018-06-20 17:35:30 -07:00
|
|
|
} else {
|
|
|
|
err = fmt.Errorf("Conflicting data")
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// It passed the checks. Sign the vote
|
2018-11-17 18:48:33 +08:00
|
|
|
sig, err := pv.Key.PrivKey.Sign(signBytes)
|
2018-06-20 17:35:30 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pv.saveSigned(height, round, step, signBytes, sig)
|
|
|
|
vote.Signature = sig
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// signProposal checks if the proposal is good to sign and sets the proposal signature.
|
|
|
|
// It may need to set the timestamp as well if the proposal is otherwise the same as
|
|
|
|
// a previously signed proposal ie. we crashed after signing but before the proposal hit the WAL).
|
|
|
|
func (pv *FilePV) signProposal(chainID string, proposal *types.Proposal) error {
|
|
|
|
height, round, step := proposal.Height, proposal.Round, stepPropose
|
|
|
|
signBytes := proposal.SignBytes(chainID)
|
|
|
|
|
|
|
|
sameHRS, err := pv.checkHRS(height, round, step)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// We might crash before writing to the wal,
|
|
|
|
// causing us to try to re-sign for the same HRS.
|
|
|
|
// If signbytes are the same, use the last signature.
|
|
|
|
// If they only differ by timestamp, use last timestamp and signature
|
|
|
|
// Otherwise, return error
|
|
|
|
if sameHRS {
|
2018-11-17 18:48:33 +08:00
|
|
|
if bytes.Equal(signBytes, pv.LastSignState.SignBytes) {
|
|
|
|
proposal.Signature = pv.LastSignState.Signature
|
|
|
|
} else if timestamp, ok := checkProposalsOnlyDifferByTimestamp(pv.LastSignState.SignBytes, signBytes); ok {
|
2018-06-20 17:35:30 -07:00
|
|
|
proposal.Timestamp = timestamp
|
2018-11-17 18:48:33 +08:00
|
|
|
proposal.Signature = pv.LastSignState.Signature
|
2018-06-20 17:35:30 -07:00
|
|
|
} else {
|
|
|
|
err = fmt.Errorf("Conflicting data")
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// It passed the checks. Sign the proposal
|
2018-11-17 18:48:33 +08:00
|
|
|
sig, err := pv.Key.PrivKey.Sign(signBytes)
|
2018-06-20 17:35:30 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
pv.saveSigned(height, round, step, signBytes, sig)
|
|
|
|
proposal.Signature = sig
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Persist height/round/step and signature
|
|
|
|
func (pv *FilePV) saveSigned(height int64, round int, step int8,
|
2018-08-01 17:02:05 -07:00
|
|
|
signBytes []byte, sig []byte) {
|
2018-06-20 17:35:30 -07:00
|
|
|
|
2018-11-17 18:48:33 +08:00
|
|
|
pv.LastSignState.Height = height
|
|
|
|
pv.LastSignState.Round = round
|
|
|
|
pv.LastSignState.Step = step
|
|
|
|
pv.LastSignState.Signature = sig
|
|
|
|
pv.LastSignState.SignBytes = signBytes
|
|
|
|
pv.saveState()
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// String returns a string representation of the FilePV.
|
|
|
|
func (pv *FilePV) String() string {
|
2018-11-17 18:48:33 +08:00
|
|
|
return fmt.Sprintf("PrivValidator{%v LH:%v, LR:%v, LS:%v}", pv.GetAddress(), pv.LastSignState.Height, pv.LastSignState.Round, pv.LastSignState.Step)
|
2018-06-20 17:35:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------
|
|
|
|
|
|
|
|
// returns the timestamp from the lastSignBytes.
|
|
|
|
// returns true if the only difference in the votes is their timestamp.
|
|
|
|
func checkVotesOnlyDifferByTimestamp(lastSignBytes, newSignBytes []byte) (time.Time, bool) {
|
2018-09-29 01:57:29 +02:00
|
|
|
var lastVote, newVote types.CanonicalVote
|
2018-10-25 03:34:01 +02:00
|
|
|
if err := cdc.UnmarshalBinaryLengthPrefixed(lastSignBytes, &lastVote); err != nil {
|
2018-06-20 17:35:30 -07:00
|
|
|
panic(fmt.Sprintf("LastSignBytes cannot be unmarshalled into vote: %v", err))
|
|
|
|
}
|
2018-10-25 03:34:01 +02:00
|
|
|
if err := cdc.UnmarshalBinaryLengthPrefixed(newSignBytes, &newVote); err != nil {
|
2018-06-20 17:35:30 -07:00
|
|
|
panic(fmt.Sprintf("signBytes cannot be unmarshalled into vote: %v", err))
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:57:29 +02:00
|
|
|
lastTime := lastVote.Timestamp
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
// set the times to the same value and check equality
|
2018-09-29 01:57:29 +02:00
|
|
|
now := tmtime.Now()
|
2018-06-20 17:35:30 -07:00
|
|
|
lastVote.Timestamp = now
|
|
|
|
newVote.Timestamp = now
|
|
|
|
lastVoteBytes, _ := cdc.MarshalJSON(lastVote)
|
|
|
|
newVoteBytes, _ := cdc.MarshalJSON(newVote)
|
|
|
|
|
|
|
|
return lastTime, bytes.Equal(newVoteBytes, lastVoteBytes)
|
|
|
|
}
|
|
|
|
|
|
|
|
// returns the timestamp from the lastSignBytes.
|
|
|
|
// returns true if the only difference in the proposals is their timestamp
|
|
|
|
func checkProposalsOnlyDifferByTimestamp(lastSignBytes, newSignBytes []byte) (time.Time, bool) {
|
2018-09-29 01:57:29 +02:00
|
|
|
var lastProposal, newProposal types.CanonicalProposal
|
2018-10-25 03:34:01 +02:00
|
|
|
if err := cdc.UnmarshalBinaryLengthPrefixed(lastSignBytes, &lastProposal); err != nil {
|
2018-06-20 17:35:30 -07:00
|
|
|
panic(fmt.Sprintf("LastSignBytes cannot be unmarshalled into proposal: %v", err))
|
|
|
|
}
|
2018-10-25 03:34:01 +02:00
|
|
|
if err := cdc.UnmarshalBinaryLengthPrefixed(newSignBytes, &newProposal); err != nil {
|
2018-06-20 17:35:30 -07:00
|
|
|
panic(fmt.Sprintf("signBytes cannot be unmarshalled into proposal: %v", err))
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:57:29 +02:00
|
|
|
lastTime := lastProposal.Timestamp
|
2018-06-20 17:35:30 -07:00
|
|
|
// set the times to the same value and check equality
|
2018-09-29 01:57:29 +02:00
|
|
|
now := tmtime.Now()
|
2018-06-20 17:35:30 -07:00
|
|
|
lastProposal.Timestamp = now
|
|
|
|
newProposal.Timestamp = now
|
2018-10-25 03:34:01 +02:00
|
|
|
lastProposalBytes, _ := cdc.MarshalBinaryLengthPrefixed(lastProposal)
|
|
|
|
newProposalBytes, _ := cdc.MarshalBinaryLengthPrefixed(newProposal)
|
2018-06-20 17:35:30 -07:00
|
|
|
|
|
|
|
return lastTime, bytes.Equal(newProposalBytes, lastProposalBytes)
|
|
|
|
}
|