-
Notifications
You must be signed in to change notification settings - Fork 987
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
Add a polling block handler #959
Comments
I'm following this. Would be a very useful feature for us as well. |
There is any plan for this? On L2 we track AMM pools, which result in bad performance (the number of events is thousands per block). For us, would be much simpler to call a view function every hour or so. |
👍 for us block handlers without filters are not an option and relying on external monitoring to perform these tasks, would be an great feature to have 👍 |
For a first implementation I think polling simply by block number makes the most sense:
I think this would require a new Pseudologic
|
Just a quick note about the pseudo-code, NEAR and Solana can "skip" blocks, so this would not be "perfect" each 100 blocks if block are skipped at the trigger boundary ( |
Thanks @maoueh that is definitely a good edge case to keep in mind |
@azf20 could we use the |
@Data-Nexus interesting that suggests it would run at every block at the chain head? |
Hmm, that wouldn't be workable then since indexers reach the chainhead at varying points. Seems like it would have to be stateful and find where this.block is greater than the previous handledBlock by the amount stated in the |
+1 to this! Our use case: We take treasury snapshots on Ethereum mainnet every epoch (8 hours) using an event handler. As a result, we have implemented a block handler that handles every 86,400th block: https://github.com/OlympusDAO/olympus-protocol-metrics-subgraph/blob/8a17a4c8bf5ccdafaf3ae9981e13527d6f3d56e4/subgraphs/arbitrum/src/treasury/Assets.ts#L20 This is... slow. I imagine it would be faster to just configure the subgraph to call the handler every X minutes/hours or every X blocks. |
@incrypto32 is picking this up! But now we need to decide on the exact semantics of
We also need to decide if the trigger should always run on the data source creation block, as a special case. |
Thanks @leoyvens and @incrypto32! I think that 3. is the most intuitive. And I think it should run on the data source creation block - perhaps |
Great @incrypto32 ! I also think 3 is the most intuitive. Also, would using a time window be out of scope? I think it could be more verbose for a user that have subgraphs deployed to multiple networks (blocks with different target time). Ofc, this could be handled by adding those block polling number to the |
+1 Agree, option 3 is very intuitive and this would allow us to take historical snapshots via subgraphs. It's not possible on non-mainnet chains due to performance issues right now. |
option 3 works for me as well! We've recently run into a few limitations when utilizing a blockHandler on fast chains. The use of a blockHandler seems to limit the scan range of the indexer (going from scanning a range of 2000 blocks down to 100 if the block handler hasn't reached it's start block or 1 if the block handler is active). While going through the implementation of this, can we also make a point to ensure that graph-node's block range selection isn't reduced below the eg, the block range scanned would be reduced from 2,000 to 1800 here:
|
Agree option 3
for this you can use the chainlink event to keep track of the time (timestamp start), when it reaches approx 8hr, it triggers the snapshot |
Is there a particular Chainlink event and/or feed that you have in mind? In my experience, the events are fired every few minutes, which is too often to make a significant difference in the indexing speed. |
Currently, we have blockHandlers with and without filter. Additionally, it would be great to have a polling filter that runs every nth block (or time window).
E.g.
The text was updated successfully, but these errors were encountered: