Skip to content

Commit

Permalink
tendermint/apps/roothash: fix restoring state
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Dec 16, 2019
1 parent ae64120 commit 2ce4286
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions go/consensus/tendermint/apps/roothash/roothash.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,18 @@ func (app *rootHashApplication) onNewRuntime(ctx *abci.Context, runtime *registr
// Create genesis block.
now := ctx.Now().Unix()
genesisBlock := block.NewGenesisBlock(runtime.ID, uint64(now))
genesisBlock.Header.Round = runtime.Genesis.Round
if !runtime.Genesis.StateRoot.IsEmpty() {
// Fill the Header fields with Genesis runtime states, if this was called during InitChain().
if ctx.IsInitChain() {
genesisRts := genesis.RuntimeStates[runtime.ID]
if genesisRts != nil {
genesisBlock.Header.Round = genesisRts.Round
genesisBlock.Header.StateRoot = genesisRts.StateRoot
genesisBlock.Header.StorageSignatures = []signature.Signature{runtime.Genesis.StorageReceipt}
}
} else {
genesisBlock.Header.Round = runtime.Genesis.Round
genesisBlock.Header.StateRoot = runtime.Genesis.StateRoot
genesisBlock.Header.StorageSignatures = []signature.Signature{runtime.Genesis.StorageReceipt}
}

// Create new state containing the genesis block.
Expand Down

0 comments on commit 2ce4286

Please sign in to comment.