Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Handle stranger cases in TokenManager#130

Merged
eternauta1337 merged 8 commits intomasterfrom
tokens-stranger-cases
Jul 15, 2020
Merged

Handle stranger cases in TokenManager#130
eternauta1337 merged 8 commits intomasterfrom
tokens-stranger-cases

Conversation

@eternauta1337
Copy link
Copy Markdown
Contributor

@eternauta1337 eternauta1337 commented Jul 9, 2020

This PR updates the tokens subgraph from v0.1.0 to v0.1.3 (which is stored in the schema, within the AragonInfo object).
This version of the subgraph is being deployed in https://thegraph.com/explorer/subgraph/aragon/aragon-tokens-mainnet right now, and a positive result needs to be tested before this is merged. Otherwise, this PR should not be merged and the subgraph rolled back to v0.1.0.

The stranger case is with the following entities:

  • Org: 0x5aAd137d8f7D2Dc6e1B2548c059B1483360bCC6a
  • App: 0x983dd5e5ce0f33774f49666e00d6a820ff8d8a07
  • Token: 0x0077Cd5Eca22e86177cc465633227652ff02F32d

Such entities produce a situation where the TokenManager app is not initialized by the time that the subgraph picks it up, and thus does not know its token. This is probably because the DAO was created from the CLI (not a template), and the token deployed and set manually. What's difficult about this situation is that the token will never enter the subgraph via the usual data sources, and thus never be linked to the TokenManager app!

An easy fix would be to add this TokenManager's token as a data source, but this would mean a complete re-index of the entire universal subgraph each time an "orphan" token like this is found. Alternatively, cases like this could add the token data source, remove a few other data sources, and deploy their own subgraph.

However, the way this PR attempts to fix the problem is by adding a new mechanism, where uninitialized TokenManagers are stored in a cache, and whenever a new app is detected in the subgraph, the list of pending-to-be-linked TokenManagers is checked. As soon as one of these can see its token, both are linked and the app is removed from the cache.

We tried triggering the orphan checking upon entering any new block, but unfortunately this makes the subgraph extremely slow. It's a nice feature, but not really production-friendly.

Comment thread packages/connect-thegraph-tokens/subgraph/schema.graphql
Comment thread packages/connect-thegraph-tokens/subgraph/src/TokenManager.ts
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 9, 2020

Codecov Report

Merging #130 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #130   +/-   ##
=======================================
  Coverage   23.92%   23.92%           
=======================================
  Files          59       59           
  Lines        1049     1049           
  Branches      168      168           
=======================================
  Hits          251      251           
  Misses        798      798           
Flag Coverage Δ
#unittests 23.92% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9cfe5f...702cf55. Read the comment docs.

Comment thread packages/connect-thegraph-tokens/subgraph/src/aragon/aragon.ts
Comment thread packages/connect-thegraph-tokens/subgraph/src/aragon/aragon.ts Outdated
Copy link
Copy Markdown
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 LGTM!

@eternauta1337 eternauta1337 marked this pull request as draft July 9, 2020 17:52
Comment thread packages/connect-thegraph-tokens/subgraph/schema.graphql
Comment thread packages/connect-thegraph-tokens/subgraph/src/TokenManager.ts
Comment thread packages/connect-thegraph-tokens/subgraph/src/aragon/aragon.ts Outdated
Copy link
Copy Markdown
Contributor

@0xGabi 0xGabi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

An easy fix would be to add this TokenManager's token as a data source, but this would mean a complete re-index of the entire universal subgraph each time an "orphan" token like this is found. Alternatively, cases like this could add the token data source, remove a few other data sources, and deploy their own subgraph.

I think this solution is the easiest but will not scale as I expect a lot of people deploying their own Minime token with the aragonCLI. I think the caching solution you implemented is better.

Comment thread packages/connect-thegraph-tokens/subgraph/src/TokenManager.ts
Comment thread packages/connect-thegraph-tokens/subgraph/src/aragon-hooks.ts Outdated
@eternauta1337 eternauta1337 marked this pull request as ready for review July 15, 2020 12:45
@eternauta1337 eternauta1337 merged commit ea54c73 into master Jul 15, 2020
@eternauta1337 eternauta1337 deleted the tokens-stranger-cases branch July 15, 2020 12:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants