mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
evmjit: Add some debug logs
This commit is contained in:
parent
bc9a71e7ab
commit
db67881a29
1 changed files with 22 additions and 14 deletions
|
|
@ -190,12 +190,13 @@ func account_exists(pCtx unsafe.Pointer, pAddr unsafe.Pointer) C.int {
|
||||||
} else if env.StateDB.Exist(addr) {
|
} else if env.StateDB.Exist(addr) {
|
||||||
exist = 1
|
exist = 1
|
||||||
}
|
}
|
||||||
// fmt.Printf("EXISTS? %x : %v\n", addr, exist)
|
fmt.Printf("EXISTS? %x : %v\n", addr, exist)
|
||||||
return exist
|
return exist
|
||||||
}
|
}
|
||||||
|
|
||||||
//export get_storage
|
//export get_storage
|
||||||
func get_storage(pResult *C.struct_evm_uint256be, pCtx unsafe.Pointer, pAddr unsafe.Pointer, pArg *C.struct_evm_uint256be) {
|
func get_storage(pResult *C.struct_evm_uint256be, pCtx unsafe.Pointer, pAddr unsafe.Pointer, pArg *C.struct_evm_uint256be) {
|
||||||
|
fmt.Printf("SLOAD\n")
|
||||||
result := EvmcHashToSlice(pResult)
|
result := EvmcHashToSlice(pResult)
|
||||||
env := getEnv(pCtx)
|
env := getEnv(pCtx)
|
||||||
|
|
||||||
|
|
@ -205,10 +206,12 @@ func get_storage(pResult *C.struct_evm_uint256be, pCtx unsafe.Pointer, pAddr uns
|
||||||
arg := *(*[32]byte)(unsafe.Pointer(pArg))
|
arg := *(*[32]byte)(unsafe.Pointer(pArg))
|
||||||
val := env.StateDB.GetState(addr, arg)
|
val := env.StateDB.GetState(addr, arg)
|
||||||
copy(result, val[:])
|
copy(result, val[:])
|
||||||
|
fmt.Printf("SLOAD %x : %v\n", addr, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export set_storage
|
//export set_storage
|
||||||
func set_storage(pCtx unsafe.Pointer, pAddr unsafe.Pointer, pArg1 unsafe.Pointer, pArg2 unsafe.Pointer) {
|
func set_storage(pCtx unsafe.Pointer, pAddr unsafe.Pointer, pArg1 unsafe.Pointer, pArg2 unsafe.Pointer) {
|
||||||
|
fmt.Printf("SSTORE\n")
|
||||||
env := getEnv(pCtx)
|
env := getEnv(pCtx)
|
||||||
|
|
||||||
var addr common.Address
|
var addr common.Address
|
||||||
|
|
@ -221,11 +224,12 @@ func set_storage(pCtx unsafe.Pointer, pAddr unsafe.Pointer, pArg1 unsafe.Pointer
|
||||||
if !common.EmptyHash(oldVal) && common.EmptyHash(newVal) {
|
if !common.EmptyHash(oldVal) && common.EmptyHash(newVal) {
|
||||||
env.StateDB.AddRefund(params.SstoreRefundGas)
|
env.StateDB.AddRefund(params.SstoreRefundGas)
|
||||||
}
|
}
|
||||||
// fmt.Printf("EVMJIT STORE %x : %x [%x, %d]\n", arg1, arg2, ctx.contract.Address(), int(uintptr(pEnv)))
|
fmt.Printf("EVMJIT STORE %x : %x [%x]\n", key, newVal, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export get_balance
|
//export get_balance
|
||||||
func get_balance(pResult unsafe.Pointer, pCtx unsafe.Pointer, pAddr unsafe.Pointer) {
|
func get_balance(pResult unsafe.Pointer, pCtx unsafe.Pointer, pAddr unsafe.Pointer) {
|
||||||
|
fmt.Printf("BALANCE\n")
|
||||||
result := GoByteSlice(pResult, 32)
|
result := GoByteSlice(pResult, 32)
|
||||||
env := getEnv(pCtx)
|
env := getEnv(pCtx)
|
||||||
|
|
||||||
|
|
@ -234,6 +238,7 @@ func get_balance(pResult unsafe.Pointer, pCtx unsafe.Pointer, pAddr unsafe.Point
|
||||||
balance := env.StateDB.GetBalance(addr)
|
balance := env.StateDB.GetBalance(addr)
|
||||||
val := common.BigToHash(balance)
|
val := common.BigToHash(balance)
|
||||||
copy(result, val[:])
|
copy(result, val[:])
|
||||||
|
fmt.Printf("BALANCE %x : %v\n", addr, balance)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export get_code
|
//export get_code
|
||||||
|
|
@ -324,15 +329,16 @@ func set_logs(pCtx unsafe.Pointer, pAddr unsafe.Pointer, pData unsafe.Pointer, d
|
||||||
|
|
||||||
//export call
|
//export call
|
||||||
func call(
|
func call(
|
||||||
pCtx unsafe.Pointer,
|
pCtx unsafe.Pointer,
|
||||||
kind int32,
|
kind int32,
|
||||||
gas int64,
|
gas int64,
|
||||||
pAddr unsafe.Pointer,
|
pAddr unsafe.Pointer,
|
||||||
pValue unsafe.Pointer,
|
pValue unsafe.Pointer,
|
||||||
pInput unsafe.Pointer,
|
pInput unsafe.Pointer,
|
||||||
inputSize C.size_t,
|
inputSize C.size_t,
|
||||||
pOutput unsafe.Pointer,
|
pOutput unsafe.Pointer,
|
||||||
outputSize C.size_t) int64 {
|
outputSize C.size_t) int64 {
|
||||||
|
fmt.Printf("CALL\n")
|
||||||
|
|
||||||
ctxWrapper := (*ContextWrapper)(pCtx)
|
ctxWrapper := (*ContextWrapper)(pCtx)
|
||||||
ctx := getCtx(ctxWrapper.index)
|
ctx := getCtx(ctxWrapper.index)
|
||||||
|
|
@ -442,7 +448,6 @@ func (evm *EVMJIT) Run(contract *Contract, input []byte) (ret []byte, err error)
|
||||||
codeSize := C.size_t(len(code))
|
codeSize := C.size_t(len(code))
|
||||||
gas := C.int64_t(contract.Gas.Int64())
|
gas := C.int64_t(contract.Gas.Int64())
|
||||||
rev := getRevision(evm.env)
|
rev := getRevision(evm.env)
|
||||||
// fmt.Printf("EVMJIT pre Run (gas %d %d mode: %d, env: %d) %x\n", contract.Gas, gas, mode, env, evm.contract.Address())
|
|
||||||
|
|
||||||
// Create context for this execution.
|
// Create context for this execution.
|
||||||
wrapper := ContextWrapper{}
|
wrapper := ContextWrapper{}
|
||||||
|
|
@ -457,13 +462,16 @@ func (evm *EVMJIT) Run(contract *Contract, input []byte) (ret []byte, err error)
|
||||||
msg.input_size = C.size_t(len(input))
|
msg.input_size = C.size_t(len(input))
|
||||||
msg.gas = gas
|
msg.gas = gas
|
||||||
msg.depth = C.int32_t(evm.env.depth - 1)
|
msg.depth = C.int32_t(evm.env.depth - 1)
|
||||||
msg.code_hash = HashToEvmc(crypto.Keccak256Hash(code))
|
codeHash := crypto.Keccak256Hash(code)
|
||||||
|
msg.code_hash = HashToEvmc(codeHash)
|
||||||
|
|
||||||
|
fmt.Printf("EVMJIT pre Run (gas %d %d mode: %d, env: %d) %x %x\n", contract.Gas, gas, rev, wrapper.index, codeHash, contract.Address())
|
||||||
|
|
||||||
r := C.evm_execute(evm.jit, &wrapper.c, rev, &msg, codePtr, codeSize)
|
r := C.evm_execute(evm.jit, &wrapper.c, rev, &msg, codePtr, codeSize)
|
||||||
|
|
||||||
unpinCtx(wrapper.index)
|
unpinCtx(wrapper.index)
|
||||||
|
|
||||||
// fmt.Printf("EVMJIT Run %d %d %x\n", r.code, r.gas_left, evm.contract.Address())
|
fmt.Printf("EVMJIT Run %d %d %x\n", r.status_code, r.gas_left, contract.Address())
|
||||||
if r.gas_left > gas {
|
if r.gas_left > gas {
|
||||||
panic("OOPS")
|
panic("OOPS")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue