Merge remote-tracking branch 'origin/develop' into jae/literefactor4

This commit is contained in:
Ethan Buchman
2018-08-02 19:12:22 -04:00
111 changed files with 5359 additions and 3140 deletions

View File

@@ -188,9 +188,12 @@ func execBlockOnProxyApp(logger log.Logger, proxyAppConn proxy.AppConnConsensus,
// Begin block.
_, err := proxyAppConn.BeginBlockSync(abci.RequestBeginBlock{
Hash: block.Hash(),
Header: types.TM2PB.Header(&block.Header),
Validators: signVals,
Hash: block.Hash(),
Header: types.TM2PB.Header(&block.Header),
LastCommitInfo: abci.LastCommitInfo{
CommitRound: int32(block.LastCommit.Round()),
Validators: signVals,
},
ByzantineValidators: byzVals,
})
if err != nil {
@@ -207,7 +210,7 @@ func execBlockOnProxyApp(logger log.Logger, proxyAppConn proxy.AppConnConsensus,
}
// End block.
abciResponses.EndBlock, err = proxyAppConn.EndBlockSync(abci.RequestEndBlock{block.Height})
abciResponses.EndBlock, err = proxyAppConn.EndBlockSync(abci.RequestEndBlock{Height: block.Height})
if err != nil {
logger.Error("Error in proxyAppConn.EndBlock", "err", err)
return nil, err
@@ -245,7 +248,7 @@ func getBeginBlockValidatorInfo(block *types.Block, lastValSet *types.ValidatorS
vote = block.LastCommit.Precommits[i]
}
val := abci.SigningValidator{
Validator: types.TM2PB.Validator(val),
Validator: types.TM2PB.ValidatorWithoutPubKey(val),
SignedLastBlock: vote != nil,
}
signVals[i] = val

View File

@@ -79,7 +79,7 @@ func TestBeginBlockValidators(t *testing.T) {
lastCommit := &types.Commit{BlockID: prevBlockID, Precommits: tc.lastCommitPrecommits}
// block for height 2
block, _ := state.MakeBlock(2, makeTxs(2), lastCommit)
block, _ := state.MakeBlock(2, makeTxs(2), lastCommit, nil)
_, err = ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), state.Validators, stateDB)
require.Nil(t, err, tc.desc)
@@ -138,7 +138,7 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
lastCommit := &types.Commit{BlockID: prevBlockID, Precommits: votes}
for _, tc := range testCases {
block, _ := state.MakeBlock(10, makeTxs(2), lastCommit)
block, _ := state.MakeBlock(10, makeTxs(2), lastCommit, nil)
block.Time = now
block.Evidence.Evidence = tc.evidence
_, err = ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), state.Validators, stateDB)
@@ -168,7 +168,7 @@ func TestUpdateValidators(t *testing.T) {
"adding a validator is OK",
types.NewValidatorSet([]*types.Validator{val1}),
[]abci.Validator{{[]byte{}, types.TM2PB.PubKey(pubkey2), 20}},
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey2), Power: 20}},
types.NewValidatorSet([]*types.Validator{val1, val2}),
false,
@@ -177,7 +177,7 @@ func TestUpdateValidators(t *testing.T) {
"updating a validator is OK",
types.NewValidatorSet([]*types.Validator{val1}),
[]abci.Validator{{[]byte{}, types.TM2PB.PubKey(pubkey1), 20}},
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey1), Power: 20}},
types.NewValidatorSet([]*types.Validator{types.NewValidator(pubkey1, 20)}),
false,
@@ -186,7 +186,7 @@ func TestUpdateValidators(t *testing.T) {
"removing a validator is OK",
types.NewValidatorSet([]*types.Validator{val1, val2}),
[]abci.Validator{{[]byte{}, types.TM2PB.PubKey(pubkey2), 0}},
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey2), Power: 0}},
types.NewValidatorSet([]*types.Validator{val1}),
false,
@@ -196,7 +196,7 @@ func TestUpdateValidators(t *testing.T) {
"removing a non-existing validator results in error",
types.NewValidatorSet([]*types.Validator{val1}),
[]abci.Validator{{[]byte{}, types.TM2PB.PubKey(pubkey2), 0}},
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey2), Power: 0}},
types.NewValidatorSet([]*types.Validator{val1}),
true,
@@ -206,7 +206,7 @@ func TestUpdateValidators(t *testing.T) {
"adding a validator with negative power results in error",
types.NewValidatorSet([]*types.Validator{val1}),
[]abci.Validator{{[]byte{}, types.TM2PB.PubKey(pubkey2), -100}},
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey2), Power: -100}},
types.NewValidatorSet([]*types.Validator{val1}),
true,
@@ -262,14 +262,14 @@ func state(nVals, height int) (State, dbm.DB) {
SaveState(stateDB, s)
for i := 1; i < height; i++ {
s.LastBlockHeight += 1
s.LastBlockHeight++
SaveState(stateDB, s)
}
return s, stateDB
}
func makeBlock(state State, height int64) *types.Block {
block, _ := state.MakeBlock(height, makeTxs(state.LastBlockHeight), new(types.Commit))
block, _ := state.MakeBlock(height, makeTxs(state.LastBlockHeight), new(types.Commit), nil)
return block
}
@@ -293,7 +293,7 @@ func (app *testApp) Info(req abci.RequestInfo) (resInfo abci.ResponseInfo) {
}
func (app *testApp) BeginBlock(req abci.RequestBeginBlock) abci.ResponseBeginBlock {
app.Validators = req.Validators
app.Validators = req.LastCommitInfo.Validators
app.ByzantineValidators = req.ByzantineValidators
return abci.ResponseBeginBlock{}
}

View File

@@ -98,19 +98,27 @@ func (state State) IsEmpty() bool {
//------------------------------------------------------------------------
// Create a block from the latest state
// MakeBlock builds a block with the given txs and commit from the current state.
func (state State) MakeBlock(height int64, txs []types.Tx, commit *types.Commit) (*types.Block, *types.PartSet) {
// Build base block.
block := types.MakeBlock(height, txs, commit)
// MakeBlock builds a block from the current state with the given txs, commit, and evidence.
func (state State) MakeBlock(
height int64,
txs []types.Tx,
commit *types.Commit,
evidence []types.Evidence,
) (*types.Block, *types.PartSet) {
// Fill header with state data.
// Build base block with block data.
block := types.MakeBlock(height, txs, commit, evidence)
// Fill rest of header with state data.
block.ChainID = state.ChainID
block.TotalTxs = state.LastBlockTotalTx + block.NumTxs
block.LastBlockID = state.LastBlockID
block.TotalTxs = state.LastBlockTotalTx + block.NumTxs
block.ValidatorsHash = state.Validators.Hash()
block.NextValidatorsHash = state.NextValidators.Hash()
block.AppHash = state.AppHash
block.ConsensusHash = state.ConsensusParams.Hash()
block.AppHash = state.AppHash
block.LastResultsHash = state.LastResultsHash
return block, block.MakePartSet(state.ConsensusParams.BlockGossip.BlockPartSizeBytes)

View File

@@ -185,7 +185,6 @@ func txResultWithTags(tags []cmn.KVPair) *types.TxResult {
Code: abci.CodeTypeOK,
Log: "",
Tags: tags,
Fee: cmn.KI64Pair{Key: nil, Value: 0},
},
}
}
@@ -201,7 +200,6 @@ func benchmarkTxIndex(txsCount int64, b *testing.B) {
Code: abci.CodeTypeOK,
Log: "",
Tags: []cmn.KVPair{},
Fee: cmn.KI64Pair{Key: []uint8{}, Value: 0},
},
}