watcher-ts/packages/graph-node
prathamesh0 560df57ac7 Performance improvements for IPLDBlocks in eden watcher (#80)
* Avoid fetching contracts while creating a checkpoint

* Use enum for state kind and cache ipld status

* Avoid fetching block twice while finalizing a staged diff IPLDBlock

* Create checkpoints at fixed block numbers and refactor checkpointing code

* Avoid calling block handler until start block is reached

* Use delete while finalizing staged diff IPLDBlocks

* Add a check to ensure hooks job is created only once

* Avoid check for initial state while creating a checkpoint
2021-12-28 16:08:05 +05:30
..
assembly Implement graph-ts numbers, typeConversion and log host APIs (#64) 2021-12-28 16:08:05 +05:30
bin Add an executable for compare-entity CLI (#69) 2021-12-28 16:08:05 +05:30
environments Add a CLI to compare entity query results from two GQL endpoints (#57) 2021-12-28 16:08:05 +05:30
src Performance improvements for IPLDBlocks in eden watcher (#80) 2021-12-28 16:08:05 +05:30
test Pass provider while instantiating the loader and use block hash while making the eth-calls (#74) 2021-12-28 16:08:05 +05:30
.env.example Test case for EdenNetwork event handler (#31) 2021-12-28 16:08:05 +05:30
.eslintignore Example subgraph, ethCall test to drive implementation (#18) 2021-12-28 16:08:04 +05:30
.eslintrc.json Test case for EdenNetwork event handler (#31) 2021-12-28 16:08:05 +05:30
.gitignore Test case for EdenNetwork event handler (#31) 2021-12-28 16:08:05 +05:30
.mocharc.yml Test case for EdenNetwork event handler (#31) 2021-12-28 16:08:05 +05:30
.npmrc Test case for EdenNetwork event handler (#31) 2021-12-28 16:08:05 +05:30
asconfig.json WASM instance setup (#11) 2021-12-28 16:08:04 +05:30
package.json Use pg-type numeric for bigint in entities and use custom decimal in graph-node (#71) 2021-12-28 16:08:05 +05:30
README.md Add an executable for compare-entity CLI (#69) 2021-12-28 16:08:05 +05:30
tsconfig.json Integrate generated watcher to invoke handlers in graph-node (#33) 2021-12-28 16:08:05 +05:30

graph-node

Test

  1. Run yarn to install all dependencies.

  2. Create .env file

    $ cp .env.example .env
    
  3. To deploy contract for example subgraph use https://github.com/deep-stack/eth-contract-tests

    # In eth-contract-test repo.
    $ yarn
    
    $ yarn example:deploy
    

    Use the address the contract got deployed to and set it to EXAMPLE_CONTRACT_ADDRESS in .env file.

  4. To deploy contracts for eden subgraph use https://github.com/vulcanize/governance

  5. Follow the steps in https://github.com/vulcanize/governance/tree/watcher-ts#instructions

  6. Set the contract addresses for eden contracts in .env file from deployments/localhost directory in the governance repository.

    Following are the contracts whose address needs to be set in .env file:

    • EdenNetwork - EDEN_NETWORK_CONTRACT_ADDRESS
    • MerkleDistributor - EDEN_NETWORK_DISTRIBUTION_CONTRACT_ADDRESS
    • DistributorGovernance - EDEN_NETWORK_GOVERNANCE_CONTRACT_ADDRESS
  7. Run yarn build:example to build the wasm files.

  8. Run yarn test.

Run

  • Compare query results from two different GQL endpoints:

    • In a config file (sample: environments/compare-cli-config.toml):

      • Specify the two GQL endpoints in the endpoints config.

      • Specify the query directory in queries config or pass as an arg. to the CLI.

      • Example:

        [endpoints]
          gqlEndpoint1 = "http://localhost:8000/subgraphs/name/example1"
          gqlEndpoint2 = "http://localhost:3008/graphql"
        
        [queries]
          queryDir = "../graph-test-watcher/src/gql/queries"
        
    • Fire a query and get the diff of the results from the two GQL endpoints:

      ./bin/compare-entity --config-file <config-file-path> --query-dir [query-dir] --query-name <query-name> --block-hash <block-hash> --entity-id <entity-id> --raw-json [true | false]
      
      • config-file(alias: cf): Configuration file path (toml) (required).
      • query-dir(alias: qf): Path to queries directory (defualt: taken from the config file).
      • query-name(alias: q): Query to be fired (required).
      • block-hash(alias: b): Block hash (required).
      • entity-id(alias: i): Entity Id (required).
      • raw-json(alias: j): Whether to print out a raw diff object (default: false).

      Example:

      ```bash
      ./bin/compare-entity --config-file environments/compare-cli-config.toml --query-name author --block-hash 0xceed7ee9d3de97c99db12e42433cae9115bb311c516558539fb7114fa17d545b --entity-id 0xdc7d7a8920c8eecc098da5b7522a5f31509b5bfc
      ```
      
    • The program will exit with code 1 if the query results are not equal.