evm: check height overflow (#597)

* evm: check height overflow

* rm

* c++
This commit is contained in:
Federico Kunze Küllmer
2021-09-28 09:48:11 +00:00
committed by GitHub
parent bc82f3f8eb
commit 83627b9967
4 changed files with 76 additions and 1 deletions
+7 -1
View File
@@ -66,8 +66,14 @@ func (k Keeper) VMConfig(msg core.Message, params types.Params, tracer vm.Tracer
// 3. The requested height is from a height greater than the latest one
func (k Keeper) GetHashFn() vm.GetHashFunc {
return func(height uint64) common.Hash {
h := int64(height)
ctx := k.Ctx()
h, err := ethermint.SafeInt64(height)
if err != nil {
k.Logger(ctx).Error("failed to cast height to int64", "error", err)
return common.Hash{}
}
switch {
case ctx.BlockHeight() == h:
// Case 1: The requested height matches the one from the context so we can retrieve the header