Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth_getLogs inconsistent behaviour around query range #1206

Closed
Tracked by #936
lalexgap opened this issue Dec 6, 2022 · 2 comments
Closed
Tracked by #936

eth_getLogs inconsistent behaviour around query range #1206

lalexgap opened this issue Dec 6, 2022 · 2 comments

Comments

@lalexgap
Copy link

lalexgap commented Dec 6, 2022

I'm seeing a bit of inconsistent behaviour depending on what fromBlock and toBlock I specify for the eth_getLogs json-rpc call.

If I try to call eth_getLogs from the genesis block to "latest" I get an invalid epoch error:

curl https://wallaby.node.glif.io/rpc/v0 -X POST -H "Content-Type: application/json"  --data '{"jsonrpc":"2.0","id":1,"method":"eth_getLogs","params":[{"address":["0xab5c7ff206ed23180dbf9c6f3b98ec984d0b0ab8"],"fromBlock":"0x0","toBlock":"latest","topics":null}]}'
{"jsonrpc":"2.0","id":1,"error":{"code":1,"message":"invalid epoch range"}}

If I manually grab the latest block number

curl --location --request POST 'https://wallaby.node.glif.io/rpc/v0' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0",
 "method":"eth_blockNumber",
 "params":[],
 "id":67
 }'
{"jsonrpc":"2.0","result":"0x462b","id":67}

and then manually insert it into the eth_getLogs call I get 0 results:

curl https://wallaby.node.glif.io/rpc/v0 -X POST -H "Content-Type: application/json"  --data '{"jsonrpc":"2.0","id":1,"method":"eth_getLogs","params":[{"address":["0xab5c7ff206ed23180dbf9c6f3b98ec984d0b0ab8"],"fromBlock":"0x0","toBlock":"0x462b","topics":null}]}'
{"jsonrpc":"2.0","result":[],"id":1}

If I call eth_getLogs with the specific block number(0x460c) as the fromBlock and ToBlock we do get results:

curl https://wallaby.node.glif.io/rpc/v0 -X POST -H "Content-Type: application/json"  --data '{"jsonrpc":"2.0","id":1,"method":"eth_getLogs","params":[{"address":["0xab5c7ff206ed23180dbf9c6f3b98ec984d0b0ab8"],"fromBlock":"0x460c","toBlock":"0x460c","topics":null}]}'
{"jsonrpc":"2.0","result":[{"address":"0xab5c7ff206ed23180dbf9c6f3b98ec984d0b0ab8","data":"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000f4","topics":["0x2dcdaad87b561ba5a69835009b4c53ef9d3c41ca6cc9574049187659d6c6a715","0x497ed4b8c46fe3f67615c3572a10cdb257272714b3cc9352f658367fd77a9ea7"],"removed":false,"logIndex":"0x0","transactionIndex":"0x0","transactionHash":"0x6e0d2577c7994b48d692f89a9c11a9d0b2171f2d183bc253bfdd1b11f84378ae","blockHash":"0xdaed020fc1266a365300418bd52d2c909a2e2424761346c7595bd0341de6a075","blockNumber":"0x460c"},{"address":"0xab5c7ff206ed23180dbf9c6f3b98ec984d0b0ab8","data":"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000f4","topics":["0x2dcdaad87b561ba5a69835009b4c53ef9d3c41ca6cc9574049187659d6c6a715","0x497ed4b8c46fe3f67615c3572a10cdb257272714b3cc9352f658367fd77a9ea7"],"removed":true,"logIndex":"0x0","transactionIndex":"0x0","transactionHash":"0x6e0d2577c7994b48d692f89a9c11a9d0b2171f2d183bc253bfdd1b11f84378ae","blockHash":"0xdaed020fc1266a365300418bd52d2c909a2e2424761346c7595bd0341de6a075","blockNumber":"0x460c"},{"address":"0xab5c7ff206ed23180dbf9c6f3b98ec984d0b0ab8","data":"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000f4","topics":["0x2dcdaad87b561ba5a69835009b4c53ef9d3c41ca6cc9574049187659d6c6a715","0x497ed4b8c46fe3f67615c3572a10cdb257272714b3cc9352f658367fd77a9ea7"],"removed":false,"logIndex":"0x0","transactionIndex":"0x0","transactionHash":"0x6e0d2577c7994b48d692f89a9c11a9d0b2171f2d183bc253bfdd1b11f84378ae","blockHash":"0xdaed020fc1266a365300418bd52d2c909a2e2424761346c7595bd0341de6a075","blockNumber":"0x460c"}],"id":1}

However if I try adjusting the fromBlock to 0x460b and the toBlock to 0x460d we get no results:

curl https://wallaby.node.glif.io/rpc/v0 -X POST -H "Content-Type: application/json"  --data '{"jsonrpc":"2.0","id":1,"method":"eth_getLogs","params":[{"address":["0xab5c7ff206ed23180dbf9c6f3b98ec984d0b0ab8"],"fromBlock":"0x460b","toBlock":"0x460d","topics":null}]}'
{"jsonrpc":"2.0","result":[],"id":1}
@iand
Copy link

iand commented Dec 7, 2022

This sounds like a bug in the query building logic. Suggest half a day to fiix

@iand
Copy link

iand commented Dec 8, 2022

If I try to call eth_getLogs from the genesis block to "latest" I get an invalid epoch error:

I suspect this is caused by the query exceeding the node's configured maximum filter height range. This is designed to prevent accidentally querying the entire chain which could be very resource intensive. This is defined at https://github.com/filecoin-project/lotus/blob/feat/nv18-events/node/config/types.go#L669 and defaults to 2880 epochs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants