0xPolygonHermez / zkevm-node

Go implementation of a node that operates the Polygon zkEVM Network
Other
511 stars 649 forks source link

eth_getFilterLogs returns empty may cause NullPointerException (NPE) in web3j #3686

Open bylingo opened 3 weeks ago

bylingo commented 3 weeks ago

Rationale

From user's feedback, we have found that there is a difference between Erigon and zkevm-node when querying events with eth_getFilterLogs RPC method. When the RPC cannot find the filter ID from user in its own memory, Erigon will return a [] while the zkevm-node will return null. But null leads to a NullPointerException (NPE) in web3j and thus causes a crash on user's program. So maybe zkevm-node should change its return from null to an empty slice when nothing returns and no error occors, and the RPC query response will be like the following:

{
    "jsonrpc": "2.0",
    "id": 73,
    "result": []
}

Implementation

We modified jsonrpc/endpoints_eth.go Line 493 & 499 into return []types.Log{}, nil, and it works.