-
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
Historical Block Scanning For Dynamic Data Sources #902
Comments
This is a use case that's likely to come up again and we'll want to support it in some way, however the design and implementation is not simple. It sounds like you can solve this in a different, less ideal way, so I recommend you take that route while we figure this one out. |
The three main parts that are difficult about this:
|
Thank you for this breakdown @Jannis, it was super insightful. We have a workaround we'll use for now @leodasvacas. Looking forward to seeing this spec progress. Godspeed! |
Rationale / Use CasesData source templates are commonly used in subgraphs that track contracts which server as registries for other contracts. In many cases the contract was already in use before being added to the registry and the subgraph would like to process that past data, but currently that's not possible. See the original comment for a description of a use case. A relatively simple way to solve this is to extend our logic that reprocesses a single block for the new data source to process any range of past blocks. Requirements
Proposed User ExperienceA new method is added to the generate data source class, A caveat is that this will halt indexing of other data sources and the progress is not stored across restarts of the graph node, so this should only be used if the triggers can be processed in a few minutes. Proposed ImplementationCode generation in graph-cli will need to include The implementation will generalize the logic we have for re-processing the current block in the instance manager, but we will to better organize our trigger filtering logic so that it can be used in the in the block stream for the initial filtering and also in the instance manager for processing dynamic data sources. The goal is to refactor the current code so we have end up with a re-usable function that looks like: fn triggers(from: BlockPtr, to: BlockPtr, current_block: BlockPtr,
log_filter: LogFilter, call_filter: CallFilter,
block_filter: BlockFilter) -> Vec<EthereumTrigger> This should internally check the reorg threshold to decide how to safely retrieve the triggers. Using this might simplify our current block stream, since what we do right now is basically:
I don't know what our rationale was to do things in this way, but steps 2-4 seem unecessary to me, I think we could just get the logs and calls and pass them to the data sources, which could also be a performance win. Proposed Documentation UpdatesThe secton 'Data Source Templates -> Instantiating a Data Source Template' should be updated to document Proposed Tests / Acceptance Criteria
Tasks
|
Would be good to simplify compounds subgraph and allow us to not upgrade it each time a new asset is added |
Is this supported now? |
@itopmoon This is still on the radar but it is a difficult one. |
Thanks for your update. Just wanted to know if it's available. It seems a good feature to have I think. |
Do you want to request a feature or report a bug?
Feature.
What is the current behavior?
From #832 :
"Whenever we we process a block and mappings request new data sources, these data sources are collected and, after having processed the block, are instantiated from templates. We then process the current block again but only with those new data sources. The entity operations from this are merged into the ones we already have for the block. After that, the dynamic data sources are persisted by adding the data sources to the subgraph instance and by adding entity operations to store them in the db (for 1.)."
What is the desired behavior?
".... We then process all blocks in the range of [contract creation -> current block] for each newly created data source."
More explanation.
In the DAOstack protocol, new DAOs can be created in a number of different ways. In order to support this (and minimize spam), the desired behavior for the subgraph is to only index DAOs that're added to a universal registry of "accepted" DAOs. Given the graph-node's current functionality, a lot of information about these newly registered DAOs would never be read/processed/stored because it has taken place prior to the current block. In order to support this scenario (which IMO is bound to be commonplace for other projects), being able to process the entire block history for a given contract upon instantiating it as a data source would be ideal.
Thread here: daostack/subgraph#197
The text was updated successfully, but these errors were encountered: