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

RPC for getting latest vmlog entries #579

Open
weserickson opened this issue Mar 19, 2022 · 6 comments
Open

RPC for getting latest vmlog entries #579

weserickson opened this issue Mar 19, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@weserickson
Copy link
Contributor

The current RPC for getting event logs has some limitations (for instance it is not easy to request the latest n entries).
https://docs.vite.org/vite-docs/api/rpc/ledger_v2.html#ledger-getvmlogsbyfilter

Possibly look at ethereum RPC for inspiration for improvements.
https://eth.wiki/json-rpc/API#eth_getlogs

@vuilder0 vuilder0 added the enhancement New feature or request label Mar 19, 2022
@niklr
Copy link
Contributor

niklr commented Mar 20, 2022

This sounds interesting. Do you have an example how to get the latest n entries with eth_getLogs? I was not aware this would be possible. Apart from that what are you particulary missing with the current implementation? Comparing with https://eth.wiki/json-rpc/API#eth_getlogs only address and blockhash are additional filter options.

@weserickson
Copy link
Contributor Author

weserickson commented Mar 25, 2022

Actually, looks like I'm wrong about eth_getLogs being able to access latest n logs, but it can at least access logs in only the latest block by setting "fromBlock": "latest" and "toBlock": "latest".

In comparisonledger_getVmLogsByFilter with "fromHeight": "0" and "toHeight": "0" seems to return ALL logs rather than only logs from the latest block. This behavior at least does not seem to match what is suggested by the docs docs

fromHeight: uint64 Start height. 0 means starting from the latest block
toHeight: uint64 End height. 0 means no specific ending block

Maybe not essential change the RPC, but we will at least want to correct this documentation.

As for other features, I agree they may not be needed (address is unneeded and blockhash is already covered by ledger_getVmLogs). @charles-liu , did you have other features in mind?

@vuilder0
Copy link
Contributor

vuilder0 commented Mar 29, 2022

Let's fix this unexpected behavior, let fromHeight of 0 mean the latest block instead of the genesis block and avoid returning all events without pagination.

@vuilder0
Copy link
Contributor

In addition, we could add two pagination parameters pageIndex and pageSize to limit the maximum size of events returned in a single RPC call like ledger-getaccountblocksbyaddress.

@viteshan
Copy link
Collaborator

viteshan commented Apr 6, 2022

This fix changes the implementation of this interface, will it affect the current user?
I think we should add quantity limits and update the documentation.

@niklr
Copy link
Contributor

niklr commented Apr 22, 2022

Update: #583 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants