onflow / flow-evm-gateway

FlowEVM Gateway implements an Ethereum-equivalent JSON-RPC API for EVM clients to use
https://developers.flow.com/evm/about
Apache License 2.0
11 stars 9 forks source link

eth_getFilterLogs returns null result instead of empty array #545

Closed treethought closed 2 weeks ago

treethought commented 2 weeks ago

Instructions

Problem

Calling eth_getFilterLogs: 1) when there are no logs for an existing filter => returns null result instead of empty array 2) filter does not exist => returns null instead of an error

Looks like this was discussed here, but geth returns an error if filter is not found or an empty array for nil logs https://github.com/ethereum/go-ethereum/blob/8d42e115b1cae4f09fd02b71c06ec9c85f22ad4f/eth/filters/api.go#L481

Steps to Reproduce

geth - create filter that has no logs

➜ curl $ENDPOINT -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"fromBlock": "latest", "toBlock": "latest", "topics": ["0x000000000000000000000000000000000000000000000000000000000000000a"]}],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x6f9fdf4de1d20291b4a68734da669c11"}

➜ curl -XPOST $ENDPOINT --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x6f9fdf4de1d20291b4a68734da669c11"],"id":5}'
{"jsonrpc":"2.0","id":5,"result":[]}

geth - get logs for filter that doesnt exist

➜ curl -XPOST $ENDPOINT --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["bad"],"id":5}'
{"jsonrpc":"2.0","id":5,"error":{"code":-32000,"message":"filter not found"}}

flow-evm-gateway - create filter that has no logs

➜ curl $ENDPOINT -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"fromBlock": "latest", "toBlock": "latest", "topics": ["0x000000000000000000000000000000000000000000000000000000000000000a"]}],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x1a120ffd47702063e3afdc69190185c1"}

➜ curl -XPOST $ENDPOINT --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x1a120ffd47702063e3afdc69190185c1"],"id":5}'
{"jsonrpc":"2.0","id":5,"result":null}

flow-evm-gateway - get logs for filter that doesnt exist

➜ curl -XPOST $ENDPOINT --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["bad"],"id":5}'
{"jsonrpc":"2.0","id":5,"result":null}

Dummy topic was used to ensure no logs from geth on mainnet, but specifying no topics/address results in same behavior, although I have seen this way sometimes return empty array

➜ curl $ENDPOINT -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"fromBlock": "latest", "toBlock": "latest"}],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x98112f669d491e0144bc2f8a177e7d60"}

➜ curl -XPOST $ENDPOINT --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x98112f669d491e0144bc2f8a177e7d60"],"id":5}'
{"jsonrpc":"2.0","id":5,"result":null}

Acceptance Criteria

Same behavior as geth