From 1b6fd032e3def058133161a45a000dae4d0db729 Mon Sep 17 00:00:00 2001
From: Martin Holst Swende <martin@swende.se>
Date: Fri, 26 Oct 2018 08:52:41 +0200
Subject: core/vm: check empty in extcodehash

---
 core/vm/instructions.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/vm/instructions.go b/core/vm/instructions.go
index b7c3ca532..6696c6e3d 100644
--- a/core/vm/instructions.go
+++ b/core/vm/instructions.go
@@ -544,7 +544,12 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract,
 // this account should be regarded as a non-existent account and zero should be returned.
 func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
 	slot := stack.peek()
-	slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(common.BigToAddress(slot)).Bytes())
+	address := common.BigToAddress(slot)
+	if interpreter.evm.StateDB.Empty(address) {
+		slot.SetUint64(0)
+	} else {
+		slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(address).Bytes())
+	}
 	return nil, nil
 }
 
-- 
cgit v1.2.3