evmjit: Implement STATICCALL

This commit is contained in:
Paweł Bylica 2017-12-12 16:03:04 +01:00
parent 07379eb387
commit d0bbe110b4
No known key found for this signature in database
GPG key ID: 7A0C037434FE77EF

View file

@ -358,13 +358,17 @@ func call(result *C.struct_evm_result, pCtx unsafe.Pointer, msg *C.struct_evm_me
var gasLeft uint64 var gasLeft uint64
var err error var err error
staticCall := (msg.flags & C.EVM_STATIC) != 0
assert(!staticCall, "static call?")
switch msg.kind { switch msg.kind {
case C.EVM_CALL: case C.EVM_CALL:
fmt.Printf("CALL(gas %d, %x)\n", gas, addr) staticCall := (msg.flags & C.EVM_STATIC) != 0
output, gasLeft, err = env.Call(contract, addr, input, gas, value) 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: case C.EVM_CALLCODE:
fmt.Printf("CALLCODE(gas %d, %x, value %d)\n", gas, addr, value) 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) msg.depth = C.int32_t(evm.env.depth - 1)
codeHash := crypto.Keccak256Hash(code) codeHash := crypto.Keccak256Hash(code)
msg.code_hash = HashToEvmc(codeHash) msg.code_hash = HashToEvmc(codeHash)
assert(evm.readOnly == false, "read only?") if evm.readOnly {
msg.flags = 0 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()) // fmt.Printf("EVMJIT pre Run (gas %d %d mode: %d, env: %d) %x %x\n", contract.Gas, gas, rev, wrapper.index, codeHash, contract.Address())