Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

evm: update empty hash check for storage state #1016

Merged
merged 1 commit into from Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions x/evm/types/storage.go
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion x/evm/types/storage_test.go
Expand Up @@ -23,7 +23,7 @@ func TestStorageValidate(t *testing.T) {
{
"empty storage key bytes",
Storage{
{Key: common.Hash{}.String()},
{Key: ""},
},
false,
},
Expand Down