diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 75f0dd5792..42c32c467a 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -778,10 +778,10 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory args := memory.GetPtr(inOffset.Int64(), inSize.Int64()) fmt.Printf("args 0%x\n", args) - if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args, OvmSLOADMethodId) { + if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args[0:4], OvmSLOADMethodId) { fmt.Println("SLOAD") } - if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args, OvmSSTOREMethodId) { + if bytes.Equal(toAddr.Bytes(), OvmContractAddress) && bytes.Equal(args[0:4], OvmSSTOREMethodId) { fmt.Println("SSTORE") } if value.Sign() != 0 { diff --git a/tests/ovm_test.go b/tests/ovm_test.go index c28c3e2f6c..3dd4b99658 100644 --- a/tests/ovm_test.go +++ b/tests/ovm_test.go @@ -10,6 +10,9 @@ import ( "github.com/ethereum/go-ethereum/core/vm/runtime" ) +var KEY = common.FromHex("0000000000000000000000000000000000000000000000000000000000000000") +var VALUE = common.FromHex("0000000000000000000000000000000000000000000000000000000000000001") + func mstoreBytes(bytes []byte) []byte { output := make([]byte, len(bytes)*5) for i, b := range bytes { @@ -46,13 +49,14 @@ func TestOvm(t *testing.T) { db := state.NewDatabase(rawdb.NewMemoryDatabase()) state, _ := state.New(common.Hash{}, db) address := common.HexToAddress("0x0a") - code := append( - mstoreBytes(vm.OvmSLOADMethodId), + code := mstoreBytes(KEY) + code = append(code, mstoreBytes(vm.OvmSLOADMethodId)...) + code = append(code, call( vm.OvmContractAddress, 0, 0, - 4, + 36, 0, 0)...)