diff --git a/blockchain/reactor_test.go b/blockchain/reactor_test.go index d3e341644..a84051291 100644 --- a/blockchain/reactor_test.go +++ b/blockchain/reactor_test.go @@ -112,7 +112,7 @@ func makeBlock(height int64, state *sm.State) *types.Block { block, _ := types.MakeBlock(height, "test_chain", makeTxs(height), state.LastBlockTotalTx, new(types.Commit), prevBlockID, valHash, state.AppHash, - state.Params.Hash(), + state.LastConsensusHash, state.Params.BlockGossipParams.BlockPartSizeBytes) return block } diff --git a/consensus/state.go b/consensus/state.go index 1018d3704..8187ea72f 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -866,7 +866,7 @@ func (cs *ConsensusState) createProposalBlock() (block *types.Block, blockParts return types.MakeBlock(cs.Height, cs.state.ChainID, txs, cs.state.LastBlockTotalTx, commit, cs.state.LastBlockID, cs.state.Validators.Hash(), - cs.state.AppHash, cs.state.Params.Hash(), + cs.state.AppHash, cs.state.LastConsensusHash, cs.state.Params.BlockPartSizeBytes) } diff --git a/state/execution.go b/state/execution.go index fbb0954d3..6f3266f6b 100644 --- a/state/execution.go +++ b/state/execution.go @@ -187,7 +187,7 @@ func (s *State) ValidateBlock(block *types.Block) error { func (s *State) validateBlock(block *types.Block) error { // Basic block validation. err := block.ValidateBasic(s.ChainID, s.LastBlockHeight, - s.LastBlockTotalTx, s.LastBlockID, s.LastBlockTime, s.AppHash, s.Params.Hash()) + s.LastBlockTotalTx, s.LastBlockID, s.LastBlockTime, s.AppHash, s.LastConsensusHash) if err != nil { return err } diff --git a/state/execution_test.go b/state/execution_test.go index 081a71e91..3080187b3 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -120,7 +120,7 @@ func makeBlock(height int64, state *State) *types.Block { block, _ := types.MakeBlock(height, chainID, makeTxs(height), state.LastBlockTotalTx, new(types.Commit), prevBlockID, valHash, - state.AppHash, state.Params.Hash(), testPartSize) + state.AppHash, state.LastConsensusHash, testPartSize) return block } diff --git a/state/state.go b/state/state.go index d3bca4a81..268e3ae90 100644 --- a/state/state.go +++ b/state/state.go @@ -59,6 +59,8 @@ type State struct { // AppHash is updated after Commit AppHash []byte + // LastConsensusHash is updated after Commit + LastConsensusHash []byte logger log.Logger } @@ -120,6 +122,7 @@ func (s *State) Copy() *State { Validators: s.Validators.Copy(), LastValidators: s.LastValidators.Copy(), AppHash: s.AppHash, + LastConsensusHash: s.LastConsensusHash, LastHeightValidatorsChanged: s.LastHeightValidatorsChanged, logger: s.logger, ChainID: s.ChainID, @@ -319,6 +322,7 @@ func (s *State) setBlockAndValidators(height int64, s.LastBlockTime = blockTime s.Validators = nextValSet s.LastValidators = prevValSet + s.LastConsensusHash = s.Params.Hash() s.Params = nextParams } @@ -428,6 +432,7 @@ func MakeGenesisState(db dbm.DB, genDoc *types.GenesisDoc) (*State, error) { Validators: types.NewValidatorSet(validators), LastValidators: types.NewValidatorSet(nil), AppHash: genDoc.AppHash, + LastConsensusHash: genDoc.ConsensusParams.Hash(), LastHeightValidatorsChanged: 1, }, nil } diff --git a/types/block.go b/types/block.go index 356776579..48b59027c 100644 --- a/types/block.go +++ b/types/block.go @@ -92,10 +92,6 @@ func (b *Block) ValidateBasic(chainID string, lastBlockHeight int64, if !bytes.Equal(b.AppHash, appHash) { return errors.New(cmn.Fmt("Wrong Block.Header.AppHash. Expected %X, got %v", appHash, b.AppHash)) } - // TODO: make testing easier - if len(consensusHash) == 0 { - panic("food") - } if !bytes.Equal(b.ConsensusHash, consensusHash) { return errors.New(cmn.Fmt("Wrong Block.Header.ConsensusHash. Expected %X, got %v", consensusHash, b.ConsensusHash)) }