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

Conform grafting auto-resolve feature to latest main #805

Closed
wants to merge 16 commits into from

Conversation

tilacog
Copy link
Contributor

@tilacog tilacog commented Oct 17, 2023

No description provided.

@tilacog tilacog changed the title Tiago/grafting auto resolve Adjustments to bring grafting auto-resolve feature to latest main Oct 17, 2023
@tilacog tilacog changed the title Adjustments to bring grafting auto-resolve feature to latest main Conform grafting auto-resolve feature to latest main Oct 17, 2023
@tilacog tilacog force-pushed the tiago/grafting-auto-resolve branch from 7f17f7d to a6ce65c Compare October 24, 2023 20:05
@tilacog tilacog force-pushed the tiago/grafting-auto-resolve branch 2 times, most recently from 868589a to 31d9213 Compare October 25, 2023 15:23
@tilacog tilacog force-pushed the tiago/grafting-auto-resolve branch from 31d9213 to 3e8c30b Compare October 25, 2023 15:34
@tilacog tilacog force-pushed the tiago/grafting-auto-resolve branch 2 times, most recently from bd5ba1d to bee85c9 Compare November 6, 2023 17:12
@tilacog tilacog force-pushed the tiago/grafting-auto-resolve branch from bee85c9 to f685641 Compare November 6, 2023 22:23
@tilacog
Copy link
Contributor Author

tilacog commented Nov 9, 2023

This is an update on the current status of this PR, which is still a work in progress.

This branch derives from #481, and the very first set of commits had the purpose of bringing it back to the latest main.

Changes so far

The main changes are the introduction of two new modules in indexer-common:

  • grafting.ts
  • subgraph-deployment.ts

The latter exposes a deploySubgraph function, which aims to replace calls to the GraphNode.ensure method. This method is called only if the new function detects that an incoming subgraph deployment does not have graft bases.

That's for the public items of this PR.

Internally, the grafting module contains types and functions:

  • iteratively fetch subgraph manifests on IPFS.
  • represent graft bases and subgraph graft lineage.
  • resolve the (possible) indexing status of such graft bases in Graph-Node.
  • produce deployment decisions out of a subgraph lineage.
  • create and remove temporary indexing rules to support syncing graft bases.

All of this is used by the public deploySubgraph function.

Usage

This PR only replaced the call to GraphNode.ensure() for deploySubgraph in the reconcileDeployments function.

It seems like the use of ensure in specific cases, like deploying the Network Subgraph, is intentional. Our primary focus was on the reconciliation loop itself.

Current Status and Observations

deploySubgraph is being called as expected, and grafted subgraphs had their subgraph lineage properly resolved.

The current design might contain flaws because the target (grafted) subgraph reentries the reconciliation loop after having its graft bases resolved. Also, all graft bases reenter the reconciliation loop, as new (temporary) indexing rules are created for them during deploySubgraph execution.

Besides that, I found a bug in which the program tried to deploy a grafted subgraph (still unsure if it was the target or one of its bases) while its base was still syncing behind its expected block height.

The strategy so far has been inspecting logs segmented by each reconciliation loop as to observe changes on the selected subgraph deployment sets.

My last effort was focused on upgrading our logs for the SubgraphDeploymentID type because those don't reveal their IPFS hash when printed to the console, but a different representation is shown.

Problems with the current Indexing Rules design

We need a value for the temporary indexing rule's protocolNetwork field.

Ideally, we would use the same protocol network as the target subgraph, but that information is erased in the previous steps of the reconciliation loop.

Possible fixes are:

  • Using a placeholder CAIP2-ID for offchian indexing rules, such as offchain:0, and adjusting the input validation components to allow for that exception.
  • Remove the NOT NULL constraint from the protocolNetwork column in the IndexingRules table so off-chain indexing rules can be excused from having such information. I've sketched a migration in 03e8b19 but removed it in ae4a62d, as further work was necessary to accommodate those changes.
  • Refactor the reconciliation loop operations to carry the original protocolNetwork over to the deployment reconciliation routine, but that might not be semantically accurate.

Alternative Designs

This might not be the best design to solve this problem.

The reconciliation loop holds no state in the application memory, and all data is collected fresh at every iteration. This turned out to be a problem, as the target (grafted) subgraph deployment indexing rule stays active until all the graft base resolution and the same is true for all graft bases except for the root.

Ideally, the Agent could use a high-level component that would be aware of grafted subgraph deployment requests and state-fully orchestrate the deployment of the subgraph lineage without resorting to the indexing rules system.

This migration works, but a bigger effort to adapt the whole system to
this new concept is still required.
@fordN
Copy link
Contributor

fordN commented Dec 5, 2023

We may revive this later, but ideally this will be solved in graph-node.

@fordN fordN closed this Dec 5, 2023
@rotarur rotarur deleted the tiago/grafting-auto-resolve branch October 31, 2024 16:30
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

Successfully merging this pull request may close these issues.

2 participants