Skip to content

Commit d0675e9

Browse files
authored
Merge pull request #17982 from holiman/polish_contantinople_extcodehash
core/vm: check empty in extcodehash
2 parents bd519ab + 1b6fd03 commit d0675e9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/vm/instructions.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,12 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract,
544544
// this account should be regarded as a non-existent account and zero should be returned.
545545
func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
546546
slot := stack.peek()
547-
slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(common.BigToAddress(slot)).Bytes())
547+
address := common.BigToAddress(slot)
548+
if interpreter.evm.StateDB.Empty(address) {
549+
slot.SetUint64(0)
550+
} else {
551+
slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(address).Bytes())
552+
}
548553
return nil, nil
549554
}
550555

0 commit comments

Comments
 (0)