fixes for ProposerAddress

- state.MakeBlock takes a proposerAddr
- validateBlock only checks that the ProposerAddress is in the validator
  set
- fix raceyness from bad proposer test:
  - use privValidator to get the proposer address (instead of racy
    state)
  - note we had to remove the test that checked the correct proposer was
    included for higher rounds because we don't have a good way to test
    this with multiple consensus states and not using the
    privValidator.Address while calling createProposalBlock was a hack!
This commit is contained in:
Ethan Buchman
2018-08-05 15:19:21 -04:00
parent 4d998b7c03
commit e1062a657f
7 changed files with 22 additions and 14 deletions
+6 -2
View File
@@ -99,12 +99,14 @@ func (state State) IsEmpty() bool {
// Create a block from the latest state
// MakeBlock builds a block from the current state with the given txs, commit,
// and evidence.
// and evidence. Note it also takes a proposerAddress because the state does not
// track rounds, and hence doesn't know the correct proposer. TODO: alleviate this!
func (state State) MakeBlock(
height int64,
txs []types.Tx,
commit *types.Commit,
evidence []types.Evidence,
proposerAddress []byte,
) (*types.Block, *types.PartSet) {
// Build base block with block data.
@@ -122,7 +124,9 @@ func (state State) MakeBlock(
block.AppHash = state.AppHash
block.LastResultsHash = state.LastResultsHash
block.ProposerAddress = state.Validators.GetProposer().Address
// NOTE: we can't use the state.Validators because we don't
// IncrementAccum for rounds there.
block.ProposerAddress = proposerAddress
return block, block.MakePartSet(state.ConsensusParams.BlockGossip.BlockPartSizeBytes)
}