This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 161
MisUse of headHash as blockHash when create EVM context #775
Comments
Problem reproduction process1. deploy this contract to ethermint network with branch development by remix
2. transfer the function T13. call the rpc api eth_getLogs
4. get the block hash from logs5. query block message by block hash, but the block hash are not correct hash, it will return empty.
root case1. block hash from Logs are set by CommitStateDB.bhash// AddLog adds a new log to the state and sets the log metadata from the state.
func (csdb *CommitStateDB) AddLog(log *ethtypes.Log) {
csdb.journal.append(addLogChange{txhash: csdb.thash})
log.TxHash = csdb.thash
log.BlockHash = csdb.BHash
log.TxIndex = uint(csdb.txIndex)
log.Index = csdb.logSize
logs, err := csdb.GetLogs(csdb.thash)
if err != nil {
// panic on unmarshal error
panic(err)
}
if err = csdb.SetLogs(csdb.thash, append(logs, log)); err != nil {
// panic on marshal error
panic(err)
}
} 2. CommitStateDB.bhash are set by function HashFromContext, and the function return the header hash but not block hashblockHash := types.HashFromContext(ctx)
k.CommitStateDB.Prepare(ethHash, blockHash, k.TxCount) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
System info: [Include Ethermint commit, operating system name, and other relevant details]
When Create EVM, we will pass a getHash function to the evm context:
in the GetHashFn,when the require height is the current block height, it will return the current Block's head hash, but not the blockHash
this would lead to something wrong for we can only get the block detail with blockHash, not headHash.
Steps to reproduce:
Expected behavior: [What you expected to happen]
always return BlockHash, not HeadHash
Actual behavior: [What actually happened]
Additional info: [Include gist of relevant config, logs, etc.]
The text was updated successfully, but these errors were encountered: