|
@ -353,9 +353,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// HEIGHT 2
|
|
|
// HEIGHT 2
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
height++ |
|
|
height++ |
|
|
incrementHeight(vss...) |
|
|
incrementHeight(vss...) |
|
|
newValidatorPubKey1, err := css[nVals].privValidator.GetPubKey() |
|
|
newValidatorPubKey1, err := css[nVals].privValidator.GetPubKey() |
|
@ -365,7 +363,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) |
|
|
newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) |
|
|
err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx1, nil, mempl.TxInfo{}) |
|
|
err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx1, nil, mempl.TxInfo{}) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|
propBlock, _ := css[0].createProposalBlock() //changeProposer(t, cs1, vs2)
|
|
|
|
|
|
|
|
|
propBlock, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
propBlockParts := propBlock.MakePartSet(partSize) |
|
|
blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
|
|
|
|
|
@ -385,9 +383,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// HEIGHT 3
|
|
|
// HEIGHT 3
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
height++ |
|
|
height++ |
|
|
incrementHeight(vss...) |
|
|
incrementHeight(vss...) |
|
|
updateValidatorPubKey1, err := css[nVals].privValidator.GetPubKey() |
|
|
updateValidatorPubKey1, err := css[nVals].privValidator.GetPubKey() |
|
@ -397,7 +393,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) |
|
|
updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) |
|
|
err = assertMempool(css[0].txNotifier).CheckTx(updateValidatorTx1, nil, mempl.TxInfo{}) |
|
|
err = assertMempool(css[0].txNotifier).CheckTx(updateValidatorTx1, nil, mempl.TxInfo{}) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|
propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2)
|
|
|
|
|
|
|
|
|
propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
|
|
|
|
|
@ -417,9 +413,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// HEIGHT 4
|
|
|
// HEIGHT 4
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
height++ |
|
|
height++ |
|
|
incrementHeight(vss...) |
|
|
incrementHeight(vss...) |
|
|
newValidatorPubKey2, err := css[nVals+1].privValidator.GetPubKey() |
|
|
newValidatorPubKey2, err := css[nVals+1].privValidator.GetPubKey() |
|
@ -436,7 +430,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) |
|
|
newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) |
|
|
err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx3, nil, mempl.TxInfo{}) |
|
|
err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx3, nil, mempl.TxInfo{}) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|
propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2)
|
|
|
|
|
|
|
|
|
propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
newVss := make([]*validatorStub, nVals+1) |
|
|
newVss := make([]*validatorStub, nVals+1) |
|
@ -487,9 +481,7 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
|
|
|
|
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// HEIGHT 5
|
|
|
// HEIGHT 5
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
height++ |
|
|
height++ |
|
|
incrementHeight(vss...) |
|
|
incrementHeight(vss...) |
|
|
// Reflect the changes to vss[nVals] at height 3 and resort newVss.
|
|
|
// Reflect the changes to vss[nVals] at height 3 and resort newVss.
|
|
@ -507,15 +499,13 @@ func TestSimulateValidatorsChange(t *testing.T) { |
|
|
} |
|
|
} |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
ensureNewRound(newRoundCh, height+1, 0) |
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// HEIGHT 6
|
|
|
// HEIGHT 6
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
height++ |
|
|
height++ |
|
|
incrementHeight(vss...) |
|
|
incrementHeight(vss...) |
|
|
removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0) |
|
|
removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0) |
|
|
err = assertMempool(css[0].txNotifier).CheckTx(removeValidatorTx3, nil, mempl.TxInfo{}) |
|
|
err = assertMempool(css[0].txNotifier).CheckTx(removeValidatorTx3, nil, mempl.TxInfo{}) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|
propBlock, _ = css[0].createProposalBlock() //changeProposer(t, cs1, vs2)
|
|
|
|
|
|
|
|
|
propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2)
|
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
propBlockParts = propBlock.MakePartSet(partSize) |
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} |
|
|
newVss = make([]*validatorStub, nVals+3) |
|
|
newVss = make([]*validatorStub, nVals+3) |
|
@ -594,7 +584,7 @@ func TestHandshakeReplayNone(t *testing.T) { |
|
|
|
|
|
|
|
|
// Test mockProxyApp should not panic when app return ABCIResponses with some empty ResponseDeliverTx
|
|
|
// Test mockProxyApp should not panic when app return ABCIResponses with some empty ResponseDeliverTx
|
|
|
func TestMockProxyApp(t *testing.T) { |
|
|
func TestMockProxyApp(t *testing.T) { |
|
|
sim.CleanupFunc() //clean the test env created in TestSimulateValidatorsChange
|
|
|
|
|
|
|
|
|
sim.CleanupFunc() // clean the test env created in TestSimulateValidatorsChange
|
|
|
logger := log.TestingLogger() |
|
|
logger := log.TestingLogger() |
|
|
var validTxs, invalidTxs = 0, 0 |
|
|
var validTxs, invalidTxs = 0, 0 |
|
|
txIndex := 0 |
|
|
txIndex := 0 |
|
@ -676,7 +666,7 @@ func testHandshakeReplay(t *testing.T, config *cfg.Config, nBlocks int, mode uin |
|
|
chain = append([]*types.Block{}, sim.Chain...) // copy chain
|
|
|
chain = append([]*types.Block{}, sim.Chain...) // copy chain
|
|
|
commits = sim.Commits |
|
|
commits = sim.Commits |
|
|
store = newMockBlockStore(config, genesisState.ConsensusParams) |
|
|
store = newMockBlockStore(config, genesisState.ConsensusParams) |
|
|
} else { //test single node
|
|
|
|
|
|
|
|
|
} else { // test single node
|
|
|
testConfig := ResetConfig(fmt.Sprintf("%s_%v_s", t.Name(), mode)) |
|
|
testConfig := ResetConfig(fmt.Sprintf("%s_%v_s", t.Name(), mode)) |
|
|
defer os.RemoveAll(testConfig.RootDir) |
|
|
defer os.RemoveAll(testConfig.RootDir) |
|
|
walBody, err := WALWithNBlocks(t, numBlocks) |
|
|
walBody, err := WALWithNBlocks(t, numBlocks) |
|
@ -805,14 +795,14 @@ func buildAppStateFromChain(proxyApp proxy.AppConns, stateStore sm.Store, |
|
|
} |
|
|
} |
|
|
defer proxyApp.Stop() //nolint:errcheck // ignore
|
|
|
defer proxyApp.Stop() //nolint:errcheck // ignore
|
|
|
|
|
|
|
|
|
state.Version.Consensus.App = kvstore.ProtocolVersion //simulate handshake, receive app version
|
|
|
|
|
|
|
|
|
state.Version.Consensus.App = kvstore.ProtocolVersion // simulate handshake, receive app version
|
|
|
validators := types.TM2PB.ValidatorUpdates(state.Validators) |
|
|
validators := types.TM2PB.ValidatorUpdates(state.Validators) |
|
|
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{ |
|
|
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{ |
|
|
Validators: validators, |
|
|
Validators: validators, |
|
|
}); err != nil { |
|
|
}); err != nil { |
|
|
panic(err) |
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
if err := stateStore.Save(state); err != nil { //save height 1's validatorsInfo
|
|
|
|
|
|
|
|
|
if err := stateStore.Save(state); err != nil { // save height 1's validatorsInfo
|
|
|
panic(err) |
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
switch mode { |
|
|
switch mode { |
|
@ -853,16 +843,16 @@ func buildTMStateFromChain( |
|
|
if err := proxyApp.Start(); err != nil { |
|
|
if err := proxyApp.Start(); err != nil { |
|
|
panic(err) |
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
defer proxyApp.Stop() //nolint:errcheck //ignore
|
|
|
|
|
|
|
|
|
defer proxyApp.Stop() //nolint:errcheck
|
|
|
|
|
|
|
|
|
state.Version.Consensus.App = kvstore.ProtocolVersion //simulate handshake, receive app version
|
|
|
|
|
|
|
|
|
state.Version.Consensus.App = kvstore.ProtocolVersion // simulate handshake, receive app version
|
|
|
validators := types.TM2PB.ValidatorUpdates(state.Validators) |
|
|
validators := types.TM2PB.ValidatorUpdates(state.Validators) |
|
|
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{ |
|
|
if _, err := proxyApp.Consensus().InitChainSync(abci.RequestInitChain{ |
|
|
Validators: validators, |
|
|
Validators: validators, |
|
|
}); err != nil { |
|
|
}); err != nil { |
|
|
panic(err) |
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
if err := stateStore.Save(state); err != nil { //save height 1's validatorsInfo
|
|
|
|
|
|
|
|
|
if err := stateStore.Save(state); err != nil { // save height 1's validatorsInfo
|
|
|
panic(err) |
|
|
panic(err) |
|
|
} |
|
|
} |
|
|
switch mode { |
|
|
switch mode { |
|
|