vulcanize / sai_watcher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sai Contract Watcher

Description

A VulcanizeDB transformer for watching events related to the Sai contract.

Dependencies

Installation

  1. Setup Postgres and an Ethereum node - see VulcanizeDB README.
  2. git clone git@github.com:8thlight/sai_watcher.git

note: go get does not work for this project because need to run the (fixlibcrypto)[https://github.com/8thlight/sai_watcher/blob/master/Makefile] command along with go build.

  1. Install dependencies:
    make installtools
    
  2. Create the database based on the VulcanizeDB schema:
    make setup NAME=vulcanize_public
    
  3. Run the migrations to add project specific tables to the database:
    make migrate NAME=vulcanize_public
    
  4. Build:
    make build
    

Configuration

  • To use a local Ethereum node, copy environments/public.toml.example to environments/public.toml and update the ipcPath to the local node's IPC filepath:

    • when using geth:

      • The IPC file is called geth.ipc.
      • The geth IPC file path is printed to the console when you start geth.
      • The default location is:
        • Mac: $HOME/Library/Ethereum
        • Linux: $HOME/.ethereum
    • when using parity:

      • The IPC file is called jsonrpc.ipc.
      • The default location is:
        • Mac: $HOME/Library/Application\ Support/io.parity.ethereum/
        • Linux: $HOME/.local/share/io.parity.ethereum/
  • See environments/infura.toml to configure commands to run against infura, if a local node is unavailable.

Running the sync command

This command syncs VulcanizeDB with the configured Ethereum node.

  1. Start node (if fast syncing wait for initial sync to finish)
  2. In a separate terminal window: ./sai_watcher sync --config <config.toml> --starting-block-number <block-number>
  • where block-number is a recent enough block to fetch contract data with your node

Running the getEvents command

getEvents starts up a process to watch for blocks on specified contracts, as well as specific log events associated with those contracts. It then stores transformed values in the following tables and views in the VulcanizeDB database:

Tables:

  • maker.peps_everyblock
  • maker.cup_action
  • log_filters
  • maker.gov

Views:

  • public.cup_act
  • public.cup

This command will need to be run against a full archive node. If a local full archive node is unavailable, see the previous point about running this command against infura.

./sai_watcher getEvents --config <config.toml>

Graphql

We're using PostGraphile to create a GraphQL API from the VulcanizeDB postgres schema.

  1. Ensure that Node.js v8.6 is installed.
  2. Install postgraphile:
    npm install -g postgraphile
    
  3. Start the postgraphile server:
    postgraphile -c "postgresql://<user>@localhost:5432/vulcanize_public" --schema=public,maker
    
    • the -c "postgresql://user@localhost:5432/vulcanize_public" flag indicates which postgres connection postgraphile should be looking to, where <user> is your local postgres user
    • the --schema=public,maker flag indicates which schema(s) postgraphile should use to generate the GraphQL API

IPFS Reports

This task creates a report of your database and persists it on IPFS.

  1. Run the command:
    ./sai_watcher generateReport --config environments/public.toml
    
  2. This will return an IPFS hash.
  3. To fetch this hash from IPFS:
    ipfs dag get <the hash>
    

Running the tests

make installtools
make setup NAME=vulcanize_private
make migrate NAME=vulcanize_private
ginkgo -r

About

License:Apache License 2.0


Languages

Language:Go 97.1%Language:Makefile 1.8%Language:Shell 0.7%Language:PLpgSQL 0.5%