mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 06:31:57 +00:00
Store LastConsensusHash in State as well
Update all BlockValidation that it matches the last state
This commit is contained in:
committed by
Ethan Buchman
parent
45bc106de7
commit
960b25408f
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user