|
@ -227,7 +227,8 @@ func TestStateBadProposal(t *testing.T) { |
|
|
proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal) |
|
|
proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal) |
|
|
voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote) |
|
|
voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote) |
|
|
|
|
|
|
|
|
propBlock, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
|
|
|
|
|
|
propBlock, _, err := cs1.createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
// make the second validator the proposer by incrementing round
|
|
|
// make the second validator the proposer by incrementing round
|
|
|
round++ |
|
|
round++ |
|
@ -240,7 +241,8 @@ func TestStateBadProposal(t *testing.T) { |
|
|
} |
|
|
} |
|
|
stateHash[0] = (stateHash[0] + 1) % 255 |
|
|
stateHash[0] = (stateHash[0] + 1) % 255 |
|
|
propBlock.AppHash = stateHash |
|
|
propBlock.AppHash = stateHash |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
proposal := types.NewProposal(vs2.Height, round, -1, blockID) |
|
|
proposal := types.NewProposal(vs2.Height, round, -1, blockID) |
|
|
p := proposal.ToProto() |
|
|
p := proposal.ToProto() |
|
@ -266,13 +268,19 @@ func TestStateBadProposal(t *testing.T) { |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], nil) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], nil) |
|
|
|
|
|
|
|
|
// add bad prevote from vs2 and wait for it
|
|
|
// add bad prevote from vs2 and wait for it
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) |
|
|
|
|
|
|
|
|
bps, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), bps.Header(), vs2) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
|
|
|
|
|
|
// wait for precommit
|
|
|
// wait for precommit
|
|
|
ensurePrecommit(voteCh, height, round) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil) |
|
|
validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil) |
|
|
signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bps2, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlock.Hash(), bps2.Header(), vs2) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func TestStateOversizedBlock(t *testing.T) { |
|
|
func TestStateOversizedBlock(t *testing.T) { |
|
@ -291,7 +299,8 @@ func TestStateOversizedBlock(t *testing.T) { |
|
|
timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose) |
|
|
timeoutProposeCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutPropose) |
|
|
voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote) |
|
|
voteCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryVote) |
|
|
|
|
|
|
|
|
propBlock, _ := cs1.createProposalBlock() |
|
|
|
|
|
|
|
|
propBlock, _, err := cs1.createProposalBlock() |
|
|
|
|
|
require.NoError(t, err) |
|
|
propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)} |
|
|
propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)} |
|
|
propBlock.Header.DataHash = propBlock.Data.Hash() |
|
|
propBlock.Header.DataHash = propBlock.Data.Hash() |
|
|
|
|
|
|
|
@ -299,7 +308,8 @@ func TestStateOversizedBlock(t *testing.T) { |
|
|
round++ |
|
|
round++ |
|
|
incrementRound(vss[1:]...) |
|
|
incrementRound(vss[1:]...) |
|
|
|
|
|
|
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
proposal := types.NewProposal(height, round, -1, blockID) |
|
|
proposal := types.NewProposal(height, round, -1, blockID) |
|
|
p := proposal.ToProto() |
|
|
p := proposal.ToProto() |
|
@ -331,11 +341,18 @@ func TestStateOversizedBlock(t *testing.T) { |
|
|
// precommit on it
|
|
|
// precommit on it
|
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], nil) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], nil) |
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bps, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), bps.Header(), vs2) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil) |
|
|
validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil) |
|
|
signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bps2, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrecommitType, propBlock.Hash(), bps2.Header(), vs2) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
@ -528,9 +545,7 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
|
|
|
|
|
|
rs := cs1.GetRoundState() |
|
|
rs := cs1.GetRoundState() |
|
|
|
|
|
|
|
|
if rs.ProposalBlock != nil { |
|
|
|
|
|
panic("Expected proposal block to be nil") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
require.Nil(t, rs.ProposalBlock, "Expected proposal block to be nil") |
|
|
|
|
|
|
|
|
// wait to finish prevote
|
|
|
// wait to finish prevote
|
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
@ -538,7 +553,10 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], rs.LockedBlock.Hash()) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], rs.LockedBlock.Hash()) |
|
|
|
|
|
|
|
|
// add a conflicting prevote from the other validator
|
|
|
// add a conflicting prevote from the other validator
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, hash, rs.LockedBlock.MakePartSet(partSize).Header(), vs2) |
|
|
|
|
|
|
|
|
bps, err := rs.LockedBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, hash, bps.Header(), vs2) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
|
|
|
|
|
|
// now we're going to enter prevote again, but with invalid args
|
|
|
// now we're going to enter prevote again, but with invalid args
|
|
@ -551,7 +569,9 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash) |
|
|
validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash) |
|
|
|
|
|
|
|
|
// add conflicting precommit from vs2
|
|
|
// add conflicting precommit from vs2
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrecommitType, hash, rs.LockedBlock.MakePartSet(partSize).Header(), vs2) |
|
|
|
|
|
|
|
|
bps2, err := rs.LockedBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrecommitType, hash, bps2.Header(), vs2) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
|
|
|
|
|
|
// (note we're entering precommit for a second time this round, but with invalid args
|
|
|
// (note we're entering precommit for a second time this round, but with invalid args
|
|
@ -581,7 +601,9 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
ensurePrevote(voteCh, height, round) // prevote
|
|
|
ensurePrevote(voteCh, height, round) // prevote
|
|
|
validatePrevote(ctx, t, cs1, round, vss[0], rs.LockedBlock.Hash()) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], rs.LockedBlock.Hash()) |
|
|
|
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, hash, rs.ProposalBlock.MakePartSet(partSize).Header(), vs2) |
|
|
|
|
|
|
|
|
bps0, err := rs.ProposalBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, hash, bps0.Header(), vs2) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
|
|
|
|
|
|
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds()) |
|
|
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds()) |
|
@ -589,13 +611,15 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
|
|
|
|
|
|
validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash) // precommit nil but be locked on proposal
|
|
|
validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash) // precommit nil but be locked on proposal
|
|
|
|
|
|
|
|
|
|
|
|
bps1, err := rs.ProposalBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
signAddVotes( |
|
|
signAddVotes( |
|
|
ctx, |
|
|
ctx, |
|
|
config, |
|
|
config, |
|
|
cs1, |
|
|
cs1, |
|
|
tmproto.PrecommitType, |
|
|
tmproto.PrecommitType, |
|
|
hash, |
|
|
hash, |
|
|
rs.ProposalBlock.MakePartSet(partSize).Header(), |
|
|
|
|
|
|
|
|
bps1.Header(), |
|
|
vs2) // NOTE: conflicting precommits at same height
|
|
|
vs2) // NOTE: conflicting precommits at same height
|
|
|
ensurePrecommit(voteCh, height, round) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
|
|
|
|
|
@ -605,7 +629,7 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
cs2, _, err := randState(ctx, config, log.TestingLogger(), 2) |
|
|
cs2, _, err := randState(ctx, config, log.TestingLogger(), 2) |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
// before we time out into new round, set next proposal block
|
|
|
// before we time out into new round, set next proposal block
|
|
|
prop, propBlock := decideProposal(ctx, cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
if prop == nil || propBlock == nil { |
|
|
if prop == nil || propBlock == nil { |
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
} |
|
|
} |
|
@ -621,7 +645,9 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
|
|
|
|
|
|
// now we're on a new round and not the proposer
|
|
|
// now we're on a new round and not the proposer
|
|
|
// so set the proposal block
|
|
|
// so set the proposal block
|
|
|
if err := cs1.SetProposalAndBlock(ctx, prop, propBlock, propBlock.MakePartSet(partSize), ""); err != nil { |
|
|
|
|
|
|
|
|
bps3, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
if err := cs1.SetProposalAndBlock(ctx, prop, propBlock, bps3, ""); err != nil { |
|
|
t.Fatal(err) |
|
|
t.Fatal(err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -631,20 +657,25 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
validatePrevote(ctx, t, cs1, 3, vss[0], cs1.LockedBlock.Hash()) |
|
|
validatePrevote(ctx, t, cs1, 3, vss[0], cs1.LockedBlock.Hash()) |
|
|
|
|
|
|
|
|
// prevote for proposed block
|
|
|
// prevote for proposed block
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) |
|
|
|
|
|
|
|
|
bps4, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlock.Hash(), bps4.Header(), vs2) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
|
|
|
|
|
|
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds()) |
|
|
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds()) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash) // precommit nil but locked on proposal
|
|
|
validatePrecommit(ctx, t, cs1, round, 0, vss[0], nil, theBlockHash) // precommit nil but locked on proposal
|
|
|
|
|
|
|
|
|
|
|
|
bps5, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
signAddVotes( |
|
|
signAddVotes( |
|
|
ctx, |
|
|
ctx, |
|
|
config, |
|
|
config, |
|
|
cs1, |
|
|
cs1, |
|
|
tmproto.PrecommitType, |
|
|
tmproto.PrecommitType, |
|
|
propBlock.Hash(), |
|
|
propBlock.Hash(), |
|
|
propBlock.MakePartSet(partSize).Header(), |
|
|
|
|
|
|
|
|
bps5.Header(), |
|
|
vs2) // NOTE: conflicting precommits at same height
|
|
|
vs2) // NOTE: conflicting precommits at same height
|
|
|
ensurePrecommit(voteCh, height, round) |
|
|
ensurePrecommit(voteCh, height, round) |
|
|
} |
|
|
} |
|
@ -708,11 +739,13 @@ func TestStateLockPOLRelock(t *testing.T) { |
|
|
cs2, err := newState(ctx, logger, cs1.state, vs2, kvstore.NewApplication()) |
|
|
cs2, err := newState(ctx, logger, cs1.state, vs2, kvstore.NewApplication()) |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
if prop == nil || propBlock == nil { |
|
|
if prop == nil || propBlock == nil { |
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
} |
|
|
} |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockHash := propBlock.Hash() |
|
|
require.NotEqual(t, propBlockHash, theBlockHash) |
|
|
require.NotEqual(t, propBlockHash, theBlockHash) |
|
|
|
|
|
|
|
@ -810,8 +843,9 @@ func TestStateLockPOLUnlock(t *testing.T) { |
|
|
signAddVotes(ctx, config, cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3) |
|
|
signAddVotes(ctx, config, cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3) |
|
|
|
|
|
|
|
|
// before we time out into new round, set next proposal block
|
|
|
// before we time out into new round, set next proposal block
|
|
|
prop, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round+1) |
|
|
|
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round+1) |
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
// timeout to new round
|
|
|
// timeout to new round
|
|
|
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds()) |
|
|
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds()) |
|
@ -905,11 +939,13 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { |
|
|
// before we timeout to the new round set the new proposal
|
|
|
// before we timeout to the new round set the new proposal
|
|
|
cs2, err := newState(ctx, logger, cs1.state, vs2, kvstore.NewApplication()) |
|
|
cs2, err := newState(ctx, logger, cs1.state, vs2, kvstore.NewApplication()) |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
prop, propBlock := decideProposal(ctx, cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
if prop == nil || propBlock == nil { |
|
|
if prop == nil || propBlock == nil { |
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
} |
|
|
} |
|
|
secondBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
secondBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
secondBlockHash := propBlock.Hash() |
|
|
secondBlockHash := propBlock.Hash() |
|
|
require.NotEqual(t, secondBlockHash, firstBlockHash) |
|
|
require.NotEqual(t, secondBlockHash, firstBlockHash) |
|
|
|
|
|
|
|
@ -950,11 +986,12 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { |
|
|
// before we timeout to the new round set the new proposal
|
|
|
// before we timeout to the new round set the new proposal
|
|
|
cs3, err := newState(ctx, logger, cs1.state, vs3, kvstore.NewApplication()) |
|
|
cs3, err := newState(ctx, logger, cs1.state, vs3, kvstore.NewApplication()) |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
prop, propBlock = decideProposal(ctx, cs3, vs3, vs3.Height, vs3.Round+1) |
|
|
|
|
|
|
|
|
prop, propBlock = decideProposal(ctx, t, cs3, vs3, vs3.Height, vs3.Round+1) |
|
|
if prop == nil || propBlock == nil { |
|
|
if prop == nil || propBlock == nil { |
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
} |
|
|
} |
|
|
thirdPropBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
thirdPropBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
thirdPropBlockHash := propBlock.Hash() |
|
|
thirdPropBlockHash := propBlock.Hash() |
|
|
require.NotEqual(t, secondBlockHash, thirdPropBlockHash) |
|
|
require.NotEqual(t, secondBlockHash, thirdPropBlockHash) |
|
|
|
|
|
|
|
@ -1023,8 +1060,11 @@ func TestStateLockPOLSafety1(t *testing.T) { |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], propBlock.Hash()) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], propBlock.Hash()) |
|
|
|
|
|
|
|
|
// the others sign a polka but we don't see it
|
|
|
// the others sign a polka but we don't see it
|
|
|
|
|
|
bps, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
prevotes := signVotes(ctx, config, tmproto.PrevoteType, |
|
|
prevotes := signVotes(ctx, config, tmproto.PrevoteType, |
|
|
propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), |
|
|
|
|
|
|
|
|
propBlock.Hash(), bps.Header(), |
|
|
vs2, vs3, vs4) |
|
|
vs2, vs3, vs4) |
|
|
|
|
|
|
|
|
t.Logf("old prop hash %v", fmt.Sprintf("%X", propBlock.Hash())) |
|
|
t.Logf("old prop hash %v", fmt.Sprintf("%X", propBlock.Hash())) |
|
@ -1038,9 +1078,10 @@ func TestStateLockPOLSafety1(t *testing.T) { |
|
|
|
|
|
|
|
|
t.Log("### ONTO ROUND 1") |
|
|
t.Log("### ONTO ROUND 1") |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round+1) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round+1) |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
incrementRound(vs2, vs3, vs4) |
|
|
incrementRound(vs2, vs3, vs4) |
|
|
|
|
|
|
|
@ -1139,18 +1180,20 @@ func TestStateLockPOLSafety2(t *testing.T) { |
|
|
|
|
|
|
|
|
// the block for R0: gets polkad but we miss it
|
|
|
// the block for R0: gets polkad but we miss it
|
|
|
// (even though we signed it, shhh)
|
|
|
// (even though we signed it, shhh)
|
|
|
_, propBlock0 := decideProposal(ctx, cs1, vss[0], height, round) |
|
|
|
|
|
|
|
|
_, propBlock0 := decideProposal(ctx, t, cs1, vss[0], height, round) |
|
|
propBlockHash0 := propBlock0.Hash() |
|
|
propBlockHash0 := propBlock0.Hash() |
|
|
propBlockParts0 := propBlock0.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts0, err := propBlock0.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
propBlockID0 := types.BlockID{Hash: propBlockHash0, PartSetHeader: propBlockParts0.Header()} |
|
|
propBlockID0 := types.BlockID{Hash: propBlockHash0, PartSetHeader: propBlockParts0.Header()} |
|
|
|
|
|
|
|
|
// the others sign a polka but we don't see it
|
|
|
// the others sign a polka but we don't see it
|
|
|
prevotes := signVotes(ctx, config, tmproto.PrevoteType, propBlockHash0, propBlockParts0.Header(), vs2, vs3, vs4) |
|
|
prevotes := signVotes(ctx, config, tmproto.PrevoteType, propBlockHash0, propBlockParts0.Header(), vs2, vs3, vs4) |
|
|
|
|
|
|
|
|
// the block for round 1
|
|
|
// the block for round 1
|
|
|
prop1, propBlock1 := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round+1) |
|
|
|
|
|
|
|
|
prop1, propBlock1 := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round+1) |
|
|
propBlockHash1 := propBlock1.Hash() |
|
|
propBlockHash1 := propBlock1.Hash() |
|
|
propBlockParts1 := propBlock1.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts1, err := propBlock1.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
incrementRound(vs2, vs3, vs4) |
|
|
incrementRound(vs2, vs3, vs4) |
|
|
|
|
|
|
|
@ -1253,8 +1296,10 @@ func TestProposeValidBlock(t *testing.T) { |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash) |
|
|
|
|
|
|
|
|
// the others sign a polka
|
|
|
// the others sign a polka
|
|
|
|
|
|
bps, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, |
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, |
|
|
propBlockHash, propBlock.MakePartSet(partSize).Header(), vs2, |
|
|
|
|
|
|
|
|
propBlockHash, bps.Header(), vs2, |
|
|
vs3, vs4) |
|
|
vs3, vs4) |
|
|
|
|
|
|
|
|
ensurePrecommit(voteCh, height, round) |
|
|
ensurePrecommit(voteCh, height, round) |
|
@ -1344,7 +1389,8 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) { |
|
|
rs := cs1.GetRoundState() |
|
|
rs := cs1.GetRoundState() |
|
|
propBlock := rs.ProposalBlock |
|
|
propBlock := rs.ProposalBlock |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash) |
|
@ -1415,9 +1461,10 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) { |
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], nil) |
|
|
validatePrevote(ctx, t, cs1, round, vss[0], nil) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round+1) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round+1) |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
// vs2, vs3 and vs4 send prevote for propBlock
|
|
|
// vs2, vs3 and vs4 send prevote for propBlock
|
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4) |
|
|
signAddVotes(ctx, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4) |
|
@ -1601,9 +1648,10 @@ func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) { |
|
|
newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound) |
|
|
newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound) |
|
|
validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock) |
|
|
validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock) |
|
|
|
|
|
|
|
|
_, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round) |
|
|
|
|
|
|
|
|
_, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round) |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
// start round in which PO is not proposer
|
|
|
// start round in which PO is not proposer
|
|
|
startTestRound(ctx, cs1, height, round) |
|
|
startTestRound(ctx, cs1, height, round) |
|
@ -1639,9 +1687,10 @@ func TestCommitFromPreviousRound(t *testing.T) { |
|
|
validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock) |
|
|
validBlockCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryValidBlock) |
|
|
proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal) |
|
|
proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, cs1, vs2, vs2.Height, vs2.Round) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs1, vs2, vs2.Height, vs2.Round) |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockHash := propBlock.Hash() |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
// start round in which PO is not proposer
|
|
|
// start round in which PO is not proposer
|
|
|
startTestRound(ctx, cs1, height, round) |
|
|
startTestRound(ctx, cs1, height, round) |
|
@ -1794,8 +1843,9 @@ func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) { |
|
|
|
|
|
|
|
|
ensureNewBlockHeader(newBlockHeader, height, theBlockHash) |
|
|
ensureNewBlockHeader(newBlockHeader, height, theBlockHash) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, cs1, vs2, height+1, 0) |
|
|
|
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs1, vs2, height+1, 0) |
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
if err := cs1.SetProposalAndBlock(ctx, prop, propBlock, propBlockParts, "some peer"); err != nil { |
|
|
if err := cs1.SetProposalAndBlock(ctx, prop, propBlock, propBlockParts, "some peer"); err != nil { |
|
|
t.Fatal(err) |
|
|
t.Fatal(err) |
|
@ -1921,7 +1971,8 @@ func TestStateHalt1(t *testing.T) { |
|
|
ensureNewProposal(proposalCh, height, round) |
|
|
ensureNewProposal(proposalCh, height, round) |
|
|
rs := cs1.GetRoundState() |
|
|
rs := cs1.GetRoundState() |
|
|
propBlock := rs.ProposalBlock |
|
|
propBlock := rs.ProposalBlock |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
|
|
|
|
|
|
propBlockParts, err := propBlock.MakePartSet(partSize) |
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
ensurePrevote(voteCh, height, round) |
|
|
ensurePrevote(voteCh, height, round) |
|
|
|
|
|
|
|
|