diff --git a/consensus/reactor.go b/consensus/reactor.go index be6745d3..e31b7ac8 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -629,7 +629,7 @@ OUTER_LOOP: // Load the block commit for prs.Height, // which contains precommit signatures for prs.Height. commit := conR.conS.blockStore.LoadBlockCommit(prs.Height) - commit.AddAddresses(conR.conS.Validators.GetAddresses()) + commit.SetAddresses(conR.conS.Validators.GetAddresses()) if ps.PickSendVote(commit) { logger.Debug("Picked Catchup commit to send", "height", prs.Height) continue OUTER_LOOP diff --git a/consensus/state.go b/consensus/state.go index 2ec7a5a0..ddcafc82 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -452,7 +452,7 @@ func (cs *ConsensusState) reconstructLastCommit(state sm.State) { return } seenCommit := cs.blockStore.LoadSeenCommit(state.LastBlockHeight) - seenCommit.AddAddresses(cs.Validators.GetAddresses()) + seenCommit.SetAddresses(cs.Validators.GetAddresses()) lastPrecommits := types.NewVoteSet(state.ChainID, state.LastBlockHeight, seenCommit.Round(), types.VoteTypePrecommit, state.LastValidators) for idx := 0; idx < len(seenCommit.Precommits); idx++ { if seenCommit.Precommits[idx] == nil { diff --git a/consensus/state_test.go b/consensus/state_test.go index a7fef713..ab1e347e 100644 --- a/consensus/state_test.go +++ b/consensus/state_test.go @@ -294,6 +294,7 @@ func TestStateFullRoundNil(t *testing.T) { validatePrevoteAndPrecommit(t, cs, round, 0, vss[0], nil, nil) } +// Tests that consensus state can be saved and reloaded from DB after committing a block. func TestStateFullRound1Reload(t *testing.T) { blockDB := dbm.NewMemDB() state, privVals := randGenesisState(1, false, 10) diff --git a/consensus/types/round_state_test.go b/consensus/types/round_state_test.go index 4a9ddf0b..b96a0e8c 100644 --- a/consensus/types/round_state_test.go +++ b/consensus/types/round_state_test.go @@ -26,7 +26,7 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) { sig := make([]byte, ed25519.SignatureSize) for i := 0; i < nval; i++ { precommits[i] = &types.CommitSig{ - Timestamp: time.Now(), + Timestamp: time.Now().UTC(), Signature: sig, } } @@ -38,7 +38,7 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) { block := &types.Block{ Header: types.Header{ ChainID: cmn.RandStr(12), - Time: time.Now(), + Time: time.Now().UTC(), LastBlockID: blockID, LastCommitHash: cmn.RandBytes(20), DataHash: cmn.RandBytes(20), @@ -60,7 +60,7 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) { parts := block.MakePartSet(4096) // Random Proposal proposal := &types.Proposal{ - Timestamp: time.Now(), + Timestamp: time.Now().UTC(), BlockPartsHeader: types.PartSetHeader{ Hash: cmn.RandBytes(20), }, @@ -71,8 +71,8 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) { // TODO: hvs := rs := &RoundState{ - StartTime: time.Now(), - CommitTime: time.Now(), + StartTime: time.Now().UTC(), + CommitTime: time.Now().UTC(), Validators: vset, Proposal: proposal, ProposalBlock: block, diff --git a/docs/spec/blockchain/blockchain.md b/docs/spec/blockchain/blockchain.md index ca64add5..6c393525 100644 --- a/docs/spec/blockchain/blockchain.md +++ b/docs/spec/blockchain/blockchain.md @@ -117,8 +117,8 @@ height and round by a sufficient set of validators. type Commit struct { HeightNum int64 RoundNum int - BlockID BlockID - Precommits []*CommitSig + BlockID BlockID + Precommits []*CommitSig } ``` diff --git a/lite/client/provider.go b/lite/client/provider.go index 292c5f74..f9d62860 100644 --- a/lite/client/provider.go +++ b/lite/client/provider.go @@ -129,7 +129,7 @@ func (p *provider) fillFullCommit(signedHeader types.SignedHeader) (fc lite.Full if err != nil { return lite.FullCommit{}, err } - signedHeader.Commit.AddAddresses(valset.GetAddresses()) + signedHeader.Commit.SetAddresses(valset.GetAddresses()) return lite.NewFullCommit(signedHeader, valset, nextValset), nil } diff --git a/lite/dbprovider.go b/lite/dbprovider.go index 80b23c17..91b2fdf1 100644 --- a/lite/dbprovider.go +++ b/lite/dbprovider.go @@ -177,7 +177,7 @@ func (dbp *DBProvider) fillFullCommit(sh types.SignedHeader) (FullCommit, error) if err != nil { return FullCommit{}, err } - sh.Commit.AddAddresses(valset.GetAddresses()) + sh.Commit.SetAddresses(valset.GetAddresses()) // Return filled FullCommit. return FullCommit{ SignedHeader: sh, diff --git a/types/block.go b/types/block.go index 57fa1986..f1fe6023 100644 --- a/types/block.go +++ b/types/block.go @@ -384,7 +384,7 @@ func (commit *Commit) BitArray() *cmn.BitArray { return commit.bitArray } -func (commit *Commit) AddAddresses(addresses []Address) { +func (commit *Commit) SetAddresses(addresses []Address) { commit.addresses = addresses } diff --git a/types/validator_set.go b/types/validator_set.go index 24a1a0d3..5dce1418 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -278,7 +278,7 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height i } talliedVotingPower := int64(0) - commit.AddAddresses(vals.GetAddresses()) + commit.SetAddresses(vals.GetAddresses()) for idx, precommit := range commit.Precommits { if precommit == nil {