forked from cerc-io/laconicd-deprecated
evm, rpc: fix parameters and block gas limit in getBlockByHeight and getBlockByHash (#312)
* fix evm set parameters * recompute header hash only if its not set * Update x/evm/keeper/state_transition.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze Küllmer
parent
0a8f02e067
commit
c8b88a3a8b
@@ -67,7 +67,21 @@ func (k Keeper) GetHashFn() vm.GetHashFunc {
|
||||
case k.ctx.BlockHeight() == h:
|
||||
// Case 1: The requested height matches the one from the context so we can retrieve the header
|
||||
// hash directly from the context.
|
||||
return common.BytesToHash(k.ctx.HeaderHash())
|
||||
// Note: The headerHash is only set at begin block, it will be nil in case of a query context
|
||||
headerHash := k.ctx.HeaderHash()
|
||||
if len(headerHash) != 0 {
|
||||
return common.BytesToHash(headerHash)
|
||||
}
|
||||
|
||||
// only recompute the hash if not set
|
||||
contextBlockHeader := k.ctx.BlockHeader()
|
||||
header, err := tmtypes.HeaderFromProto(&contextBlockHeader)
|
||||
if err != nil {
|
||||
k.Logger(k.ctx).Error("failed to cast tendermint header from proto", "error", err)
|
||||
return common.Hash{}
|
||||
}
|
||||
headerHash = header.Hash()
|
||||
return common.BytesToHash(headerHash)
|
||||
|
||||
case k.ctx.BlockHeight() > h:
|
||||
// Case 2: if the chain is not the current height we need to retrieve the hash from the store for the
|
||||
|
||||
Reference in New Issue
Block a user