mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Use native SSTORE and SLOAD
This commit is contained in:
parent
d30dd58a7e
commit
681f566af3
1 changed files with 14 additions and 11 deletions
|
|
@ -771,18 +771,21 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory
|
||||||
|
|
||||||
// Get the arguments from the memory.
|
// Get the arguments from the memory.
|
||||||
args := memory.GetPtr(inOffset.Int64(), inSize.Int64())
|
args := memory.GetPtr(inOffset.Int64(), inSize.Int64())
|
||||||
|
methodId := args[0:4]
|
||||||
|
|
||||||
if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args[0:4], OvmSLOADMethodId) {
|
if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(methodId, OvmSLOADMethodId) {
|
||||||
loc := common.BytesToHash(args[4:36])
|
storageSlot := new(big.Int).SetBytes(args[4:36])
|
||||||
val := interpreter.evm.StateDB.GetState(contract.Address(), loc)
|
stack.push(storageSlot)
|
||||||
memory.Set(retOffset.Uint64(), retSize.Uint64(), val.Bytes())
|
opSload(pc, interpreter, contract, memory, stack)
|
||||||
stack.push(interpreter.intPool.get().SetUint64(1))
|
storageValue := stack.peek()
|
||||||
return val.Bytes(), nil
|
memory.Set(retOffset.Uint64(), retSize.Uint64(), storageValue.Bytes())
|
||||||
} else if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args[0:4], OvmSSTOREMethodId) {
|
return storageValue.Bytes(), nil
|
||||||
loc := common.BytesToHash(args[4:36])
|
} else if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(methodId, OvmSSTOREMethodId) {
|
||||||
val := common.BytesToHash(args[36:68])
|
storageSlot := new(big.Int).SetBytes(args[4:36])
|
||||||
interpreter.evm.StateDB.SetState(contract.Address(), loc, val)
|
storageValue := new(big.Int).SetBytes(args[36:68])
|
||||||
interpreter.intPool.put(val.Big())
|
stack.push(storageValue)
|
||||||
|
stack.push(storageSlot)
|
||||||
|
opSstore(pc, interpreter, contract, memory, stack)
|
||||||
stack.push(interpreter.intPool.get().SetUint64(1))
|
stack.push(interpreter.intPool.get().SetUint64(1))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue