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

Query past block event using LCD's txs endpoint instead of fetching block from RPC to speed up indexing. #40

Open
y-pakorn opened this issue Jul 12, 2022 · 2 comments

Comments

@y-pakorn
Copy link
Contributor

By using /txs endpoint on LCD we can directly query transaction that has specific event without need to query every past block from RPC.

- handler: handleEvent
  kind: cosmos/EventHandler
  filter:
    type: execute
    messageFilter:
      type: "/cosmwasm.wasm.v1.MsgExecuteContract"
      contractCall:
        contract: "juno1v99ehkuetkpf0yxdry8ce92yeqaeaa7lyxr2aagkesrw67wcsn8qxpxay0"

Filter above with start block at 3062001 can be translated to
lcd.endpoint/cosmos/tx/v1beta1/txs?events=message.action=/cosmwasm.wasm.v1.MsgExecuteContract&events=execute._contract_address=juno1v99ehkuetkpf0yxdry8ce92yeqaeaa7lyxr2aagkesrw67wcsn8qxpxay0&events=tx.height>=3062001

@stwiname
Copy link
Contributor

Hi @y-pakorn, thanks for your suggestion, we will do some more investigation into this, it does seem like a good idea but may not be particularly scalable if there are handlers for multiple contracts.

We do already have a dictionary solution that we know scales well for this use case. You can read more about them here https://doc.subquery.network/academy/tutorials_examples/dictionary/

We have dictionaries running for various cosmos networks, including Juno https://explorer.subquery.network/subquery/subquery/cosmos-juno-dictionary

@y-pakorn
Copy link
Contributor Author

Oh, I forgot that the dictionary could be used! Thanks! By the way, the key is to fetch txs based on events using LCD capabilities, which could be great for the network that doesn't have the dictionary, such as testnet or local network.

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

No branches or pull requests

2 participants