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

DAOTracker: A Solution For Indexing New DAOs #640

Merged
merged 12 commits into from
Oct 5, 2019
Merged

DAOTracker: A Solution For Indexing New DAOs #640

merged 12 commits into from
Oct 5, 2019

Conversation

dOrgJelli
Copy link
Contributor

[Problem]
As discussed in this thread, we need a way to index newly deployed DAOs that satisfies the following constraints:

  1. Protects against DoS / spam.
  2. Doesn't require new DAOs to propose themselves to a single "central" DAORegistry.
  3. Doesn't require the use of the DaoCreator contract or the UController.

[Solution]
Create a new on-chain "source of truth" that dictates what the subgraph is indexing. All DAOs that wish to be cached will need to call the track(avatar, controller) method on this contract immediately after they've been created to ensure no events will be lost. This should typically happen after Avatar, DAOToken, Reputation, and Controller have all been deployed, and no other setup actions have taken place.

[Question]
Rename DAOTracker to DAONetwork?

[Contract Explained]

[This is part 1 of a 3 part update]

  1. Arc: This PR.
  2. Migration: Fix Migration scripts as this will be a breaking change (DaoCreator constructor).
  3. Subgraph: Add this contract to the subgraph, and add the following functionality:
export function handleTrackDAO(event: TrackDAO) {
  // Check to see if the DAO is already in the cache
  if (store.get("DAO", event.args._avatar) != null) {
    return;
  }

  // Check to see if the DAO being tracked is blacklisted
  // NOTE: the event we're processing could be from any historic block (ex: 5),
  //    but this smart contract view method is going to return the latest block's state.
  //    This detail needs to be verified, as the method could return the current block's state.
  const daoTrackerSC = DAOTracker.bind(event.address);
  const trackingInfo = daoTrackerSC.methods.tracked(event.args._avatar);

  if (trackingInfo.blacklist) {
    return;
  }

  // Start tracking the newly added DAO
  AvatarTemplate.create(event.args._avatar);
  DAOTokenTemplate.create(trackingInfo.nativeToken);
  ReputationTemplate.create(trackingInfo.nativeReputation);

  // Make sure the controller isn't the Universal Controller
  if (store.get("UniversalController", trackingInfo.controller) == null) {
    ControllerTemplate.create(trackingInfo.controller);
  }
}

@ben-kaufman
Copy link
Contributor

It looks like a good solution to me, and the code seems good as well, but since Oren is on vacation this week I prefer to wait for him with it since it's a relatively big change.

@orenyodfat
Copy link
Contributor

how this is different from the daoregistery solution at https://github.com/daostack/arc-hive ?

@dOrgJelli
Copy link
Contributor Author

how this is different from the daoregistery solution at https://github.com/daostack/arc-hive ?

Here's something you had said in our discussion that's linked to above: "The daoregistery is used by alchemy to fillet daos ,you can register dao on any time... not sure that tie that to indexing the dao is best option.".

I definitely agree with this, I don't think coupling a DAO registry with indexing makes sense.

@dOrgJelli
Copy link
Contributor Author

After talking with @orenyodfat (who spoke with @jellegerbrandy), it looks like a better / safer solution for indexing new DAOs is standing up a new DAO specific subgraph for them. I wrote something about how this might be done using Apollo Federations here: daostack/subgraph#270

Please let me know what your thoughts are and feel free to close this PR if you've decided to not take the "DAOTracker approach".

@dOrgJelli
Copy link
Contributor Author

@orenyodfat @jellegerbrandy @leviadam

Anything I can do to help get this merged? Once it's merged, I can work on adding support in the migration scripts, and then the subgraph. Then newly deployed DAOs will be automatically in Alchemy :)

@orenyodfat orenyodfat merged commit a7f50f2 into daostack:master Oct 5, 2019
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.

3 participants