mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Assert against the returned value of the CALL
..instead of the "success code"
This commit is contained in:
parent
a3a9d1d632
commit
eb5eb82137
2 changed files with 4 additions and 9 deletions
|
|
@ -19,7 +19,6 @@ package vm
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -768,7 +767,6 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory
|
||||||
// Pop other call parameters.
|
// Pop other call parameters.
|
||||||
addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
||||||
toAddr := common.BigToAddress(addr)
|
toAddr := common.BigToAddress(addr)
|
||||||
// log.Info(fmt.Sprintf("Calling %020x\n", toAddr.Bytes()))
|
|
||||||
value = math.U256(value)
|
value = math.U256(value)
|
||||||
|
|
||||||
// Get the arguments from the memory.
|
// Get the arguments from the memory.
|
||||||
|
|
@ -777,14 +775,12 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory
|
||||||
if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args[0:4], OvmSLOADMethodId) {
|
if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args[0:4], OvmSLOADMethodId) {
|
||||||
loc := common.BytesToHash(args[4:36])
|
loc := common.BytesToHash(args[4:36])
|
||||||
val := interpreter.evm.StateDB.GetState(contract.Address(), loc)
|
val := interpreter.evm.StateDB.GetState(contract.Address(), loc)
|
||||||
fmt.Printf("SLOAD %x\n", loc)
|
|
||||||
memory.Set(retOffset.Uint64(), retSize.Uint64(), val.Bytes())
|
memory.Set(retOffset.Uint64(), retSize.Uint64(), val.Bytes())
|
||||||
stack.push(interpreter.intPool.get().SetUint64(1))
|
stack.push(interpreter.intPool.get().SetUint64(1))
|
||||||
return val.Bytes(), nil
|
return val.Bytes(), nil
|
||||||
} else if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args[0:4], OvmSSTOREMethodId) {
|
} else if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args[0:4], OvmSSTOREMethodId) {
|
||||||
loc := common.BytesToHash(args[4:36])
|
loc := common.BytesToHash(args[4:36])
|
||||||
val := common.BytesToHash(args[36:68])
|
val := common.BytesToHash(args[36:68])
|
||||||
fmt.Printf("SSTORE %x %x\n", loc, val)
|
|
||||||
interpreter.evm.StateDB.SetState(contract.Address(), loc, val)
|
interpreter.evm.StateDB.SetState(contract.Address(), loc, val)
|
||||||
interpreter.intPool.put(val.Big())
|
interpreter.intPool.put(val.Big())
|
||||||
stack.push(interpreter.intPool.get().SetUint64(1))
|
stack.push(interpreter.intPool.get().SetUint64(1))
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,9 @@ func TestOvm(t *testing.T) {
|
||||||
0,
|
0,
|
||||||
36,
|
36,
|
||||||
0,
|
0,
|
||||||
0)...)
|
32)...)
|
||||||
code = append(code, []byte{
|
code = append(code, []byte{
|
||||||
byte(vm.PUSH1), 0,
|
byte(vm.POP),
|
||||||
byte(vm.MSTORE),
|
|
||||||
byte(vm.PUSH1), 32,
|
byte(vm.PUSH1), 32,
|
||||||
byte(vm.PUSH1), 0,
|
byte(vm.PUSH1), 0,
|
||||||
byte(vm.RETURN),
|
byte(vm.RETURN),
|
||||||
|
|
@ -86,8 +85,8 @@ func TestOvm(t *testing.T) {
|
||||||
t.Fatal("didn't expect error", err)
|
t.Fatal("didn't expect error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(common.BigToHash(common.Big1).Bytes(), returnValue) {
|
if !bytes.Equal(VALUE, returnValue) {
|
||||||
t.Errorf("Expected %020x; got %020x", common.BigToHash(common.Big1).Bytes(), returnValue)
|
t.Errorf("Expected %020x; got %020x", VALUE, returnValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue