use the updated state in case there is one

pull/4510/head
Diego Nava 1 year ago
parent 310b4cd5d8
commit 924d1336f1
No known key found for this signature in database
GPG Key ID: 61AFC8738DA8B8B1
  1. 4
      core/genesis.go
  2. 7
      core/preimages.go

@ -254,9 +254,9 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
statedb.SetState(addr, key, value)
}
//statedb.AddPreimage(crypto.Keccak256Hash((addr[:])), addr.Bytes()[:])
rawdb.WritePreimages(
_ = rawdb.WritePreimages(
statedb.Database().DiskDB(), map[ethCommon.Hash][]byte{
crypto.Keccak256Hash((addr.Bytes())): addr.Bytes(),
crypto.Keccak256Hash(addr.Bytes()): addr.Bytes(),
},
)
}

@ -233,7 +233,12 @@ func GeneratePreimages(chain BlockChain, start, end uint64) error {
if err != nil {
return fmt.Errorf("error executing block #%d: %s", i, err)
}
startingState = endingState
stateAt, err := chain.StateAt(block.Root())
if err == nil && stateAt != nil {
startingState = stateAt
} else {
startingState = endingState
}
}
// force any pre-images in memory so far to go to disk, if they haven't already
fmt.Println("committing images")

Loading…
Cancel
Save