mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Only match methodIds on the first 4 bytes of calldata
Th remaining bytes are parameter data
This commit is contained in:
parent
e83f2b7c9a
commit
2ed2db0cbe
2 changed files with 9 additions and 5 deletions
|
|
@ -778,10 +778,10 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory
|
||||||
args := memory.GetPtr(inOffset.Int64(), inSize.Int64())
|
args := memory.GetPtr(inOffset.Int64(), inSize.Int64())
|
||||||
fmt.Printf("args 0%x\n", args)
|
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")
|
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")
|
fmt.Println("SSTORE")
|
||||||
}
|
}
|
||||||
if value.Sign() != 0 {
|
if value.Sign() != 0 {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/vm/runtime"
|
"github.com/ethereum/go-ethereum/core/vm/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var KEY = common.FromHex("0000000000000000000000000000000000000000000000000000000000000000")
|
||||||
|
var VALUE = common.FromHex("0000000000000000000000000000000000000000000000000000000000000001")
|
||||||
|
|
||||||
func mstoreBytes(bytes []byte) []byte {
|
func mstoreBytes(bytes []byte) []byte {
|
||||||
output := make([]byte, len(bytes)*5)
|
output := make([]byte, len(bytes)*5)
|
||||||
for i, b := range bytes {
|
for i, b := range bytes {
|
||||||
|
|
@ -46,13 +49,14 @@ func TestOvm(t *testing.T) {
|
||||||
db := state.NewDatabase(rawdb.NewMemoryDatabase())
|
db := state.NewDatabase(rawdb.NewMemoryDatabase())
|
||||||
state, _ := state.New(common.Hash{}, db)
|
state, _ := state.New(common.Hash{}, db)
|
||||||
address := common.HexToAddress("0x0a")
|
address := common.HexToAddress("0x0a")
|
||||||
code := append(
|
code := mstoreBytes(KEY)
|
||||||
mstoreBytes(vm.OvmSLOADMethodId),
|
code = append(code, mstoreBytes(vm.OvmSLOADMethodId)...)
|
||||||
|
code = append(code,
|
||||||
call(
|
call(
|
||||||
vm.OvmContractAddress,
|
vm.OvmContractAddress,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
4,
|
36,
|
||||||
0,
|
0,
|
||||||
0)...)
|
0)...)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue