watcher-ts/packages/graph-node
Nabarun Gogoi cd29b47ecc
Implement peer package to send messages between peers (#279)
* Initial implementation of class and discoving other peers

* Implement peer connection and sending messages between peers

* Add react app and use peer package for broadcasting

* Maintain stream for each remote peer

* Refactor code in peer package

* Add serve package for react-app

* Add readme for running react app

* Add peer package readme

* Add logs for events with details

* Add a chat CLI using peer package (#280)

* Add a flag to instantiate Peer for nodejs

* Add a basic chat CLI using peer

* Add a signal server arg to chat CLI

* Add instructions for chat CLI

* Fix typescript and ESM issues after adding peer package (#282)

* Fix build issues in util package

* Update eslint TS plugins

* Scope react app package name

* Convert cli package back to CJS and dynamically import ESM

* Upgrade ts-node version

* Fix tests

* Setup a relay node and pubsub based discovery (#284)

* Add a script to setup a relay node

* Use pubsub based peer discovery

* Add peer multiaddr to connection log

* Catch relay node dial errors

* Increase discovery interval and dial all mutiaddr

* Add UI to display self peer ID and multiaddrs

* Add UI for displaying live remote connections

* Send js objects in peer broadcast messages

* Add react-peer package for using peer in react app

* Reduce disconnect frequency between peers (#287)

* Restrict number of max concurrent dials per peer

* Increase hop relay timeout to 1 day

* Self review changes

* Review changes

* Increase pubsub discovery interval and add steps to create a peer id  (#290)

* Increase pubsub discovery interval

* Disable autodial to avoid peer dials without protocol on a reconnect

* Add steps to create a peer id and use for relay node

* Add back dependency to run signalling server

* Avoid bootstrapping and dial to relay node directly

Co-authored-by: prathamesh0 <42446521+prathamesh0@users.noreply.github.com>
Co-authored-by: prathamesh0 <prathamesh.musale0@gmail.com>
2023-01-10 20:10:27 +05:30
..
assembly Implement compare CLI for multiple entities for given block range (#108) 2022-01-17 15:18:44 +05:30
bin Implement compare CLI for multiple entities for given block range (#108) 2022-01-17 15:18:44 +05:30
environments Changes to use packages in uniswap-watcher (#196) 2022-10-11 13:41:26 +05:30
src Implement peer package to send messages between peers (#279) 2023-01-10 20:10:27 +05:30
test Use graph-ts and graph-cli packages from gitea (#283) 2022-12-29 16:59:42 +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 Deploy example contract in graph-node (#113) 2022-04-29 15:11:40 +05:30
.mocharc.yml Test case for EdenNetwork event handler (#31) 2021-12-28 16:08:05 +05:30
.npmignore Refactor code in graph-node to use in uniswap watcher (#205) 2022-10-20 14:39:32 +05:30
asconfig.json WASM instance setup (#11) 2021-12-28 16:08:04 +05:30
hardhat.config.ts Add demo for graph-watcher IPLD statediff and checkpointing 2022-05-06 15:43:45 +05:30
ipld-demo.md Clear cache of latest entities on event processing error (#201) 2022-10-19 14:26:10 +05:30
package.json Implement peer package to send messages between peers (#279) 2023-01-10 20:10:27 +05:30
README.md Refactor state creation code (#204) 2022-10-19 15:24:14 +05:30
tsconfig.json Update compare CLI to verify IPLD block meta data (#179) 2022-09-12 17:44:53 +05:30

graph-node

Test

  1. Run yarn to install all dependencies.

  2. Create .env file

    $ cp .env.example .env
    
  3. Run yarn build:example to build the wasm files.

  4. 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.

    • For comparing queries in a range of blocks:

      • Config file should have the names of queries to be fired along with the corresponding entity names.

        [queries]
          queryDir = "../graph-test-watcher/src/gql/queries"
          [queries.names]
            author = "Author"
            blog = "Blog"
        

        The queries will be fired if the corresponding entities are updated.

      • Run the CLI:

        ./bin/compare-blocks --config-file environments/compare-cli-config.toml --start-block 1 --end-block 10
        
      • For comparing entities after fetching updated entity ids from watcher database:

        • Set the watcher config file path and entities directory.

          [endpoints]
            gqlEndpoint1 = "http://localhost:8000/subgraphs/name/example1"
            gqlEndpoint2 = "http://localhost:3008/graphql"
          
          [queries]
            queryDir = "../graph-test-watcher/src/gql/queries"
            [queries.names]
              author = "Author"
              blog = "Blog"
          
          [watcher]
            configPath = "../../graph-test-watcher/environments/local.toml"
            entitiesDir = "../../graph-test-watcher/dist/entity/*"
          
        • To verify diff State state generated at each block, set the watcher endpoint and verifyState flag to true

          [watcher]
            configPath = "../../graph-test-watcher/environments/local.toml"
            entitiesDir = "../../graph-test-watcher/dist/entity/*"
            endpoint = "gqlEndpoint2"
            verifyState = true
          
        • Run the CLI with fetch-ids flag set to true:\

          ./bin/compare-blocks --config-file environments/compare-cli-config.toml --start-block 1 --end-block 10 --fetch-ids