From d19e38833c884a16194bd579a63fce5bbbcc437d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Tue, 29 Mar 2022 15:38:22 +0200 Subject: [PATCH] changelog: v0.12.1 (#1019) * evm: update empty hash check for storage state (#1016) * v0.12.1: changelog --- CHANGELOG.md | 6 ++++++ x/evm/types/storage.go | 10 +++++----- x/evm/types/storage_test.go | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b205f6b6..6f6a4242 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## [v0.12.1] - 2022-03-29 + +### Bug Fixes + +* (evm) [tharsis#1016](https://github.com/tharsis/ethermint/pull/1016) Update validate basic check for storage state. + ## [v0.12.0] - 2022-03-24 ### Bug Fixes diff --git a/x/evm/types/storage.go b/x/evm/types/storage.go index 20104f82..40c5bcc0 100644 --- a/x/evm/types/storage.go +++ b/x/evm/types/storage.go @@ -2,11 +2,10 @@ package types import ( "fmt" + "strings" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" - - "github.com/tharsis/ethermint/types" ) // Storage represents the account Storage map as a slice of single key value @@ -49,11 +48,12 @@ func (s Storage) Copy() Storage { } // Validate performs a basic validation of the State fields. +// NOTE: state value can be empty func (s State) Validate() error { - if types.IsEmptyHash(s.Key) { - return sdkerrors.Wrap(ErrInvalidState, "state key hash cannot be empty") + if strings.TrimSpace(s.Key) == "" { + return sdkerrors.Wrap(ErrInvalidState, "state key hash cannot be blank") } - // NOTE: state value can be empty + return nil } diff --git a/x/evm/types/storage_test.go b/x/evm/types/storage_test.go index d5f0628e..515f2a83 100644 --- a/x/evm/types/storage_test.go +++ b/x/evm/types/storage_test.go @@ -23,7 +23,7 @@ func TestStorageValidate(t *testing.T) { { "empty storage key bytes", Storage{ - {Key: common.Hash{}.String()}, + {Key: ""}, }, false, },