write preimages on process

pull/4514/head
Diego Nava 1 year ago
parent 9586553f5e
commit 270645155a
No known key found for this signature in database
GPG Key ID: 61AFC8738DA8B8B1
  1. 2
      core/preimages.go
  2. 14
      core/state_processor.go

@ -347,7 +347,7 @@ func VerifyPreimages(header *block.Header, chain BlockChain) (uint64, error) {
if len(preimage) == 0 { if len(preimage) == 0 {
return 0, errors.New( return 0, errors.New(
fmt.Sprintf( fmt.Sprintf(
"cannot find preimage for %x", key, "cannot find preimage for %x after '%d' accounts", key, existingPreimages,
), ),
) )
} }

@ -169,6 +169,8 @@ func (p *StateProcessor) Process(
if len(stakeMsgs) > 0 { if len(stakeMsgs) > 0 {
blockStakeMsgs = append(blockStakeMsgs, stakeMsgs...) blockStakeMsgs = append(blockStakeMsgs, stakeMsgs...)
} }
StorePreimageFromTx(statedb, tx)
allLogs = append(allLogs, receipt.Logs...) allLogs = append(allLogs, receipt.Logs...)
} }
utils.Logger().Debug().Int64("elapsed time", time.Now().Sub(startTime).Milliseconds()).Msg("Process Normal Txns") utils.Logger().Debug().Int64("elapsed time", time.Now().Sub(startTime).Milliseconds()).Msg("Process Normal Txns")
@ -685,3 +687,15 @@ func generateOneMigrationMessage(
} }
return nil, nil 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()),
},
)
}

Loading…
Cancel
Save