diff --git a/core/preimages.go b/core/preimages.go index 2ca1545a4..dcca3f0e1 100644 --- a/core/preimages.go +++ b/core/preimages.go @@ -347,7 +347,7 @@ func VerifyPreimages(header *block.Header, chain BlockChain) (uint64, error) { if len(preimage) == 0 { return 0, errors.New( fmt.Sprintf( - "cannot find preimage for %x", key, + "cannot find preimage for %x after '%d' accounts", key, existingPreimages, ), ) } diff --git a/core/state_processor.go b/core/state_processor.go index 04974f7be..b1eb04d87 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -169,6 +169,8 @@ func (p *StateProcessor) Process( if len(stakeMsgs) > 0 { blockStakeMsgs = append(blockStakeMsgs, stakeMsgs...) } + + StorePreimageFromTx(statedb, tx) allLogs = append(allLogs, receipt.Logs...) } utils.Logger().Debug().Int64("elapsed time", time.Now().Sub(startTime).Milliseconds()).Msg("Process Normal Txns") @@ -685,3 +687,15 @@ func generateOneMigrationMessage( } return nil, nil } + +func StorePreimageFromTx(statedb *state.DB, tx *types.Transaction) { + sender, _ := tx.SenderAddress() + + _ = rawdb.WritePreimages(statedb.Database().DiskDB(), + map[common.Hash][]byte{ + crypto.Keccak256Hash(sender.Bytes()): append(sender.Bytes()), + crypto.Keccak256Hash(tx.To().Bytes()): append(tx.To().Bytes()), + }, + ) + +}