consensus: don't check InitChain app hash vs genesis app hash, replace it (#5237)

Followup from #5227. Instead of checking `ResponseInitChain.app_hash` against the genesis doc app hash, we instead replace it. We should probably remove the genesis doc app hash completely, and rely solely on the one from `InitChain`, I'll open a separate issue to discuss this.
This commit is contained in:
Erik Grinaker
2020-08-13 10:58:07 +02:00
committed by GitHub
parent b1b82c493a
commit e1a1395cf4
3 changed files with 10 additions and 15 deletions

View File

@@ -323,15 +323,15 @@ func (h *Handshaker) ReplayBlocks(
return nil, err
}
if !bytes.Equal(res.AppHash, h.genDoc.AppHash) {
return nil, fmt.Errorf(
"app hash from InitChain does not match genesis, got %X expected %X",
res.AppHash, h.genDoc.AppHash)
}
appHash = res.AppHash
if stateBlockHeight == 0 { //we only update state when we are in initial state
state.AppHash = res.AppHash
// If the app did not return an app hash, we keep the one set from the genesis doc in
// the state. We don't set appHash since we don't want the genesis doc app hash
// recorded in the genesis block. We should probably just remove GenesisDoc.AppHash.
if len(res.AppHash) > 0 {
state.AppHash = res.AppHash
}
// If the app returned validators or consensus params, update the state.
if len(res.Validators) > 0 {
vals, err := types.PB2TM.ValidatorUpdates(res.Validators)