Home

Awesome

Vulcanize DB

Build Status Go Report Card

Vulcanize DB is a set of tools that make it easier for developers to write application-specific indexes and caches for dapps built on Ethereum.

Table of Contents

  1. Background
  2. Install
  3. Usage
  4. Contributing
  5. License

Background

The same data structures and encodings that make Ethereum an effective and trust-less distributed virtual machine complicate data accessibility and usability for dApp developers. VulcanizeDB improves Ethereum data accessibility by providing a suite of tools to ease the extraction and transformation of data into a more useful state, including allowing for exposing aggregate data from a suite of smart contracts.

VulanizeDB includes processes that sync, transform and expose data. Syncing involves querying an Ethereum node and then persisting core data into a Postgres database. Transforming focuses on using previously synced data to query for and transform log event and storage data for specifically configured smart contract addresses. Exposing data is a matter of getting data from VulcanizeDB's underlying Postgres database and making it accessible.

VulcanizeDB Overview Diagram

Install

  1. Dependencies
  2. Building the project
  3. Setting up the database
  4. Configuring a synced Ethereum node

Dependencies

Building the project

Download the codebase to your local GOPATH via:

go get github.com/makerdao/vulcanizedb

Move to the project directory:

cd $GOPATH/src/github.com/makerdao/vulcanizedb

Be sure you have enabled Go Modules (export GO111MODULE=on), and build the executable with:

make build

If you need to use a different dependency than what is currently defined in go.mod, it may helpful to look into the replace directive. This instruction enables you to point at a fork or the local filesystem for dependency resolution.

If you are running into issues at this stage, ensure that GOPATH is defined in your shell. If necessary, GOPATH can be set in ~/.bashrc or ~/.bash_profile, depending upon your system. It can be additionally helpful to add $GOPATH/bin to your shell's $PATH.

Setting up the database

  1. Install Postgres
  2. Create a superuser for yourself and make sure psql --list works without prompting for a password.
  3. createdb vulcanize_public
  4. cd $GOPATH/src/github.com/makerdao/vulcanizedb
  5. Run the migrations: make migrate HOST_NAME=localhost NAME=vulcanize_public PORT=5432
    • There is an optional var USER=username if the database user is not the default user postgres

    • To rollback a single step: make rollback NAME=vulcanize_public

    • To rollback to a certain migration: make rollback_to MIGRATION=n NAME=vulcanize_public

    • To see status of migrations: make migration_status NAME=vulcanize_public

    • See below for configuring additional environments

In some cases (such as recent Ubuntu systems), it may be necessary to overcome failures of password authentication from localhost. To allow access on Ubuntu, set localhost connections via hostname, ipv4, and ipv6 from peer/md5 to trust in: /etc/postgresql/<version>/pg_hba.conf

(It should be noted that trusted auth should only be enabled on systems without sensitive data in them: development and local test databases)

Configuring a synced Ethereum node

Usage

As mentioned above, VulcanizeDB's processes can be split into three categories: syncing, transforming and exposing data.

Data syncing

To provide data for transformations, raw Ethereum data must first be synced into VulcanizeDB. This is accomplished through the use of the headerSync command. This command is described in detail here.

Data transformation

Data transformation uses the raw data that has been synced into Postgres to filter out and apply transformations to specific data of interest. Since there are different types of data that may be useful for observing smart contracts, it follows that there are different ways to transform this data. We've started by categorizing this into Generic and Custom transformers:

Exposing the data

Postgraphile is used to expose GraphQL endpoints for our database schemas, this is described in detail here.

Tests

Contributing

Contributions are welcome!

VulcanizeDB follows the Contributor Covenant Code of Conduct.

For more information on contributing, please see here.

License

AGPL-3.0 © Vulcanize Inc