mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
core/vm: fix opExtCode{Size,Hash,Copy}
This commit is contained in:
parent
b2ae97892d
commit
6c97819d94
3 changed files with 18 additions and 12 deletions
|
|
@ -473,13 +473,6 @@ func (s *StateDB) SetCode(addr common.Address, code []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *StateDB) SetCodeEOF(addr common.Address, code []byte) {
|
||||
stateObject := s.getOrNewStateObject(addr)
|
||||
if stateObject != nil {
|
||||
stateObject.SetCode(types.EmptyEOFCodeHash, code)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StateDB) SetState(addr common.Address, key, value common.Hash) {
|
||||
stateObject := s.getOrNewStateObject(addr)
|
||||
if stateObject != nil {
|
||||
|
|
|
|||
|
|
@ -357,7 +357,12 @@ func opExtCodeSize(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
|||
witness.AddCode(interpreter.evm.StateDB.GetCode(address))
|
||||
witness.AddCode(interpreter.evm.StateDB.ResolveCode(address))
|
||||
}
|
||||
slot.SetUint64(uint64(len(interpreter.evm.StateDB.ResolveCode(slot.Bytes20()))))
|
||||
code := interpreter.evm.StateDB.GetCode(slot.Bytes20())
|
||||
if isEOFVersion1(code) {
|
||||
slot.SetUint64(2)
|
||||
} else {
|
||||
slot.SetUint64(uint64(len(interpreter.evm.StateDB.ResolveCode(slot.Bytes20()))))
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
@ -389,6 +394,7 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
|||
memOffset = stack.pop()
|
||||
codeOffset = stack.pop()
|
||||
length = stack.pop()
|
||||
lengthU64 = length.Uint64()
|
||||
)
|
||||
uint64CodeOffset, overflow := codeOffset.Uint64WithOverflow()
|
||||
if overflow {
|
||||
|
|
@ -400,8 +406,11 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
|||
witness.AddCode(interpreter.evm.StateDB.GetCode(addr))
|
||||
witness.AddCode(code)
|
||||
}
|
||||
codeCopy := getData(code, uint64CodeOffset, length.Uint64())
|
||||
scope.Memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy)
|
||||
if isEOFVersion1(code) {
|
||||
lengthU64 = 2
|
||||
}
|
||||
codeCopy := getData(code, uint64CodeOffset, lengthU64)
|
||||
scope.Memory.Set(memOffset.Uint64(), lengthU64, codeCopy)
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
|
@ -441,7 +450,12 @@ func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
|||
if interpreter.evm.StateDB.Empty(address) {
|
||||
slot.Clear()
|
||||
} else {
|
||||
slot.SetBytes(interpreter.evm.StateDB.ResolveCodeHash(address).Bytes())
|
||||
code := interpreter.evm.StateDB.GetCode(address)
|
||||
if HasEOFByte(code) {
|
||||
slot.SetFromHex("0x9dbf3648db8210552e9c4f75c6a1c3057c0ca432043bd648be15fe7be05646f5")
|
||||
} else {
|
||||
slot.SetBytes(interpreter.evm.StateDB.ResolveCodeHash(address).Bytes())
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ type StateDB interface {
|
|||
GetCodeHash(common.Address) common.Hash
|
||||
GetCode(common.Address) []byte
|
||||
SetCode(common.Address, []byte)
|
||||
SetCodeEOF(common.Address, []byte)
|
||||
GetCodeSize(common.Address) int
|
||||
|
||||
ResolveCodeHash(common.Address) common.Hash
|
||||
|
|
|
|||
Loading…
Reference in a new issue