Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Problem: debug_traceBlockByNumber crashed when block height not found #744

Closed
calvinaco opened this issue Nov 11, 2021 · 0 comments · Fixed by #743
Closed

Problem: debug_traceBlockByNumber crashed when block height not found #744

calvinaco opened this issue Nov 11, 2021 · 0 comments · Fixed by #743

Comments

@calvinaco
Copy link
Contributor

System info: [Include Ethermint commit, operating system name, and other relevant details]

Steps to reproduce:

  1. Call debug_traceBlockByNumber with an unexisting block height
  2. JSON RPC returns
{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32000,
        "message": "method handler crashed"
    }
}
  1. Log returns
t=2021-11-11T14:32:45+0800 lvl=eror msg="RPC method debug_traceBlockByNumber crashed: runtime error: invalid memory address or nil pointer dereference\ngoroutine 2450 [running]:\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call.func1(0xc002c9cc48, 0x18, 0xc001835d58)\n\tgithub.com/ethereum/[email protected]/rpc/service.go:200 +0xbd\npanic(0x5b28380, 0x7175280)\n\truntime/panic.go:965 +0x1b9\ngithub.com/tharsis/ethermint/rpc/ethereum/namespaces/debug.(*API).traceBlock(0xc0014a0700, 0x1123123, 0x0, 0x0, 0x0, 0x2, 0x40, 0x40, 0x78861d8)\n\tgithub.com/tharsis/ethermint/rpc/ethereum/namespaces/debug/api.go:204 +0x3a\ngithub.com/tharsis/ethermint/rpc/ethereum/namespaces/debug.(*API).TraceBlockByNumber(0xc0014a0700, 0x1123123, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\tgithub.com/tharsis/ethermint/rpc/ethereum/namespaces/debug/api.go:173 +0x166\nreflect.Value.call(0xc002d22000, 0xc002d1a298, 0x13, 0x5dab6b1, 0x4, 0xc004934720, 0x3, 0x4, 0xc004934738, 0xc004122660, ...)\n\treflect/value.go:476 +0x8e7\nreflect.Value.Call(0xc002d22000, 0xc002d1a298, 0x13, 0xc004934720, 0x3, 0x4, 0x0, 0x0, 0x5b612a0)\n\treflect/value.go:337 +0xb9\ngithub.com/ethereum/go-ethereum/rpc.(*callback).call(0xc002d202a0, 0x635f270, 0xc002cdb980, 0xc002c9cc48, 0x18, 0xc004122660, 0x2, 0x2, 0x0, 0x0, ...)\n\tgithub.com/ethereum/[email protected]/rpc/service.go:206 +0x2c5\ngithub.com/ethereum/go-ethereum/rpc.(*handler).runMethod(0xc000fddcb0, 0x635f270, 0xc002cdb980, 0xc00078aa10, 0xc002d202a0, 0xc004122660, 0x2, 0x2, 0x2)\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:389 +0x8a\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCall(0xc000fddcb0, 0xc004122600, 0xc00078aa10, 0x203001)\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:337 +0x265\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg(0xc000fddcb0, 0xc004122600, 0xc00078aa10, 0x6340001)\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:298 +0x1be\ngithub.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1(0xc004122600)\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:139 +0x46\ngithub.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1(0xc000fddcb0, 0xc00353a4b0)\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:226 +0xd2\ncreated by github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc\n\tgithub.com/ethereum/[email protected]/rpc/handler.go:222 +0x66\n"
t=2021-11-11T14:32:45+0800 lvl=warn msg="Served debug_traceBlockByNumber" conn=[::1]:59797 reqid=1                t=2.347798ms               err="method handler crashed"
t=2021-11-11T14:32:46+0800 lvl=dbug msg="Served net_version"              conn=[::1]:59795 reqid=3944931663       t="23.27µs"
2:32PM INF Timed out dur=4891.172 height=156 module=consensus round=0 server=node step=1

Expected behavior: [What you expected to happen]

  • It should return "block not found" in JSON RPC response and should not crash.

Actual behavior: [What actually happened]

Stated above

Additional info: [Include gist of relevant config, logs, etc.]

calvinaco added a commit to calvinaco/ethermint that referenced this issue Nov 11, 2021
fedekunze added a commit that referenced this issue Nov 12, 2021
… non-existing block (#743)

* Problem: Missing debug_tranceBlockByHash RPC method

Solution: (Fix #742) Add the missing method

* Problem: debug_traceBlockByNumber crashed when block height not found

Solution: (Fix #744) Fix memory reference error

* Run go fmt

* Revert comment on init.sh

* Apply suggestions from code review

Co-authored-by: Federico Kunze Küllmer <[email protected]>

* Update rpc/ethereum/backend/backend.go

* Update rpc/ethereum/backend/backend.go

Co-authored-by: Federico Kunze Küllmer <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant