-
Notifications
You must be signed in to change notification settings - Fork 63
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
not handling non int block params
#472
Comments
Fix will like take the form of updating eth.getLogs() if (toBlock) {
// @ts-ignore
filters.push(`lte:${parseInt(toBlock)}`);
order = constants.ORDER.DESC;
}
if (fromBlock) {
// @ts-ignore
filters.push(`gte:${parseInt(fromBlock)}`);
order = constants.ORDER.ASC;
} after if (toBlock) {
const blockNumber = await this.translateBlockTag(toBlock, requestId);
// @ts-ignore
filters.push(`lte:${blockNumber}`);
order = constants.ORDER.DESC;
}
if (fromBlock) {
const blockNumber = await this.translateBlockTag(fromBlock, requestId);
// @ts-ignore
filters.push(`gte:${blockNumber}`);
order = constants.ORDER.ASC;
} |
Wouldn't In the case of In the case of |
@dimitrovmaksim actually made more progress on this, below is where i got to. Also i think most of your suggestions are already captured in if (toBlock) {
const blockResponse = await this.getHistoricalBlockResponse(toBlock, true, requestId);
// @ts-ignore
params.timestamp = [`lte:${blockResponse?.timestamp?.to}`];
order = constants.ORDER.DESC;
}
if (fromBlock) {
const blockResponse = await this.getHistoricalBlockResponse(fromBlock, undefined, requestId);
// @ts-ignore
if (params.timestamp) {
params.timestamp.push(`gte:${blockResponse?.timestamp?.from}`);
} else {
params.timestamp = [`gte:${blockResponse?.timestamp?.from}`];
}
order = constants.ORDER.ASC;
} |
Many JSON-RPC providers limit the block range for eth_getLogs, bsc is 5000, Infura I think is 2000, so I guess its fine to have a limit and return an error if the range exceeds the limit. BSC: Wouldn't this [ Also this implementation, If I understand correctly, gets the block passed as either IMO, it would probably be the better if the mirror node could handle the block tags and build a where clause accordingly, instead of the relay performing multiple requests. |
@dimitrovmaksim good points. Let's start with a configureable limit of 500 and the error message Regarding the toBlock, for the mean time as a band aid, let's
Also open a ticket against mirror node with your suggestion that we can adopt at a later time |
To sum it up:
The only issue here is that |
Description
Currently the
eth_getLogs
endpoint parses thefromBlock
andtoBlock
without consideration for non int values.This results in the block time frames not being honoured
See eth.getLogs where
parseInt(toBlock)
andparseInt(fromBlock)
are used.These should apply the
blockNumberOrTag
logic used by the other methodsSteps to reproduce
curl -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"2","method":"eth_getLogs","params":[{ "fromBlock": "0x0", "toBlock": "latest", "addresss": "0x0000000000000000000000000000000002dC46Db"}]}' http://localhost:7546
blocks?block.number=lte:NaN&block.number=gte:0&order=asc 400 status
Additional context
No response
Hedera network
previewnet
Version
v0.6.0
Operating system
No response
The text was updated successfully, but these errors were encountered: