From d0bbe110b4c3666cb49559ac1de727c8925d2b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 12 Dec 2017 16:03:04 +0100 Subject: [PATCH] evmjit: Implement STATICCALL --- core/vm/evmjit.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/core/vm/evmjit.go b/core/vm/evmjit.go index 3271a86b52..d2c3e0ba5c 100644 --- a/core/vm/evmjit.go +++ b/core/vm/evmjit.go @@ -358,13 +358,17 @@ func call(result *C.struct_evm_result, pCtx unsafe.Pointer, msg *C.struct_evm_me var gasLeft uint64 var err error - staticCall := (msg.flags & C.EVM_STATIC) != 0 - assert(!staticCall, "static call?") - switch msg.kind { case C.EVM_CALL: - fmt.Printf("CALL(gas %d, %x)\n", gas, addr) - output, gasLeft, err = env.Call(contract, addr, input, gas, value) + staticCall := (msg.flags & C.EVM_STATIC) != 0 + if staticCall { + fmt.Printf("STATICCALL(gas %d, %x)\n", gas, addr) + output, gasLeft, err = env.StaticCall(contract, addr, input, gas) + } else { + fmt.Printf("CALL(gas %d, %x)\n", gas, addr) + output, gasLeft, err = env.Call(contract, addr, input, gas, value) + } + case C.EVM_CALLCODE: fmt.Printf("CALLCODE(gas %d, %x, value %d)\n", gas, addr, value) @@ -468,8 +472,11 @@ func (evm *EVMJIT) Run(snapshot int, contract *Contract, input []byte) (ret []by msg.depth = C.int32_t(evm.env.depth - 1) codeHash := crypto.Keccak256Hash(code) msg.code_hash = HashToEvmc(codeHash) - assert(evm.readOnly == false, "read only?") - msg.flags = 0 + if evm.readOnly { + msg.flags = C.EVM_STATIC + } else { + msg.flags = 0 + } // fmt.Printf("EVMJIT pre Run (gas %d %d mode: %d, env: %d) %x %x\n", contract.Gas, gas, rev, wrapper.index, codeHash, contract.Address())