Skip to content

Commit

Permalink
Fix for hasEmptyAccount (ethereum#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcontracts authored Jan 12, 2021
1 parent 5314233 commit 4d8f7ba
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/vm/ovm_state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var funcs = map[string]stateManagerFunction{
"putContractStorage": putContractStorage,
"isAuthenticated": nativeFunctionTrue,
"hasAccount": nativeFunctionTrue,
"hasEmptyAccount": nativeFunctionTrue,
"hasEmptyAccount": hasEmptyAccount,
"hasContractStorage": nativeFunctionTrue,
"testAndSetAccountLoaded": testAndSetAccount,
"testAndSetAccountChanged": testAndSetAccount,
Expand Down Expand Up @@ -210,6 +210,20 @@ func testAndSetContractStorage(evm *EVM, contract *Contract, args map[string]int
return []interface{}{true}, nil
}

func hasEmptyAccount(evm *EVM, contract *Contract, args map[string]interface{}) ([]interface{}, error) {
address, ok := args["_address"].(common.Address)
if !ok {
return nil, errors.New("Could not parse address arg in hasEmptyAccount")
}

contractHash := evm.StateDB.GetCodeHash(address)
if evm.StateDB.GetNonce(address) != 0 || (contractHash != (common.Hash{}) && contractHash != emptyCodeHash) {
return []interface{}{false}, nil
}

return []interface{}{true}, nil
}

func nativeFunctionTrue(evm *EVM, contract *Contract, args map[string]interface{}) ([]interface{}, error) {
return []interface{}{true}, nil
}
Expand Down

0 comments on commit 4d8f7ba

Please sign in to comment.