Fix validValue rule
This commit is contained in:
parent
45a05b4726
commit
61430ec3e8
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/p2p"
|
"github.com/tendermint/tendermint/p2p"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ShowNodeIDCmd dumps node's ID to the standard output.
|
// ShowNodeIDCmd dumps node's ID to the standard output.
|
||||||
|
|
|
@ -2,6 +2,7 @@ package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
privval "github.com/tendermint/tendermint/types/priv_validator"
|
privval "github.com/tendermint/tendermint/types/priv_validator"
|
||||||
|
|
|
@ -1306,6 +1306,22 @@ func (cs *ConsensusState) addProposalBlockPart(height int64, part *types.Part, v
|
||||||
}
|
}
|
||||||
// NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal
|
// NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal
|
||||||
cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash())
|
cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash())
|
||||||
|
|
||||||
|
// Update ValidBlock
|
||||||
|
prevotes := cs.Votes.Prevotes(cs.Round)
|
||||||
|
blockID, ok := prevotes.TwoThirdsMajority()
|
||||||
|
if ok && !blockID.IsZero() && (cs.ValidRound < cs.Round) {
|
||||||
|
// update valid value
|
||||||
|
if !cs.ValidBlock.HashesTo(blockID.Hash) && cs.ProposalBlock.HashesTo(blockID.Hash) {
|
||||||
|
cs.ValidRound = cs.Round
|
||||||
|
cs.ValidBlock = cs.ProposalBlock
|
||||||
|
cs.ValidBlockParts = cs.ProposalBlockParts
|
||||||
|
}
|
||||||
|
//TODO: In case there is +2/3 majority in Prevotes set for some block and cs.ProposalBlock contains different block,
|
||||||
|
//either proposer is faulty or voting power of faulty processes is more than 1/3. We should
|
||||||
|
//trigger in the future accountability procedure at this point.
|
||||||
|
}
|
||||||
|
|
||||||
if cs.Step == cstypes.RoundStepPropose && cs.isProposalComplete() {
|
if cs.Step == cstypes.RoundStepPropose && cs.isProposalComplete() {
|
||||||
// Move onto the next step
|
// Move onto the next step
|
||||||
cs.enterPrevote(height, cs.Round)
|
cs.enterPrevote(height, cs.Round)
|
||||||
|
@ -1412,9 +1428,9 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update ValidBlock
|
// Update ValidBlock
|
||||||
if ok && !blockID.IsZero() && !cs.ValidBlock.HashesTo(blockID.Hash) && vote.Round > cs.ValidRound {
|
if ok && !blockID.IsZero() && (cs.ValidRound < vote.Round) && (vote.Round <= cs.Round) {
|
||||||
// update valid value
|
// update valid value
|
||||||
if cs.ProposalBlock.HashesTo(blockID.Hash) {
|
if !cs.ValidBlock.HashesTo(blockID.Hash) && cs.ProposalBlock.HashesTo(blockID.Hash) {
|
||||||
cs.ValidRound = vote.Round
|
cs.ValidRound = vote.Round
|
||||||
cs.ValidBlock = cs.ProposalBlock
|
cs.ValidBlock = cs.ProposalBlock
|
||||||
cs.ValidBlockParts = cs.ProposalBlockParts
|
cs.ValidBlockParts = cs.ProposalBlockParts
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestWaitForHeight(t *testing.T) {
|
||||||
|
|
||||||
// now set current block height to 10
|
// now set current block height to 10
|
||||||
m.Call = mock.Call{
|
m.Call = mock.Call{
|
||||||
Response: &ctypes.ResultStatus{SyncInfo: ctypes.SyncInfo{LatestBlockHeight: 10} },
|
Response: &ctypes.ResultStatus{SyncInfo: ctypes.SyncInfo{LatestBlockHeight: 10}},
|
||||||
}
|
}
|
||||||
|
|
||||||
// we will not wait for more than 10 blocks
|
// we will not wait for more than 10 blocks
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGenesisBad(t *testing.T) {
|
func TestGenesisBad(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue