Merge pull request #46 from vulcanize/update-readme

Updates to README
This commit is contained in:
A. F. Dudley 2018-04-17 22:32:08 -06:00 committed by GitHub
commit 2553f892ea
3 changed files with 98 additions and 94 deletions

View File

@ -2,55 +2,53 @@
[![Build Status](https://travis-ci.org/vulcanize/VulcanizeDB.svg?branch=master)](https://travis-ci.org/vulcanize/VulcanizeDB)
### Dependencies
## Dependencies
- Go 1.9+
- Postgres 10
- Postgres 10
- Ethereum Node
- [Go Ethereum](https://ethereum.github.io/go-ethereum/downloads/) (1.8+)
- [Parity 1.8.11+](https://github.com/paritytech/parity/releases)
### Installation
## Installation
`go get github.com/vulcanize/vulcanizedb`
### Setting up the Databases
## Setting up the Database
1. Install Postgres
1. Create a superuser for yourself and make sure `psql --list` works without prompting for a password.
1. `createdb vulcanize_private`
1. `createdb vulcanize_public`
1. `cd $GOPATH/src/github.com/vulcanize/vulcanizedb`
1. Import the schema: `psql vulcanize_private < db/schema.sql`
1. Run the migrations: `make migrate HOST_NAME=localhost NAME=vulcanize_public PORT=5432`
or run the migrations: `make migrate HOST_NAME=localhost NAME=vulcanize_public PORT=5432`
* See below for configuring additional environments
### IPC File Paths
The default location for Ethereum is:
- `$HOME/Library/Ethereum` for Mac
- `$HOME/.ethereum` for Ubuntu
- `$GOPATH/src/gihub.com/vulcanize/vulcanizedb/test_data_dir/geth.ipc` for private node.
## 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`
**Note the location of the ipc file is printed to the console when you start geth. It is needed to for configuration**
- 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
## Start syncing with postgres
1. Start geth node (**if fast syncing wait for geth to finsh initial sync**)
Syncs VulcanizeDB with the configured Ethereum node.
1. Start node (**if fast syncing wait for initial sync to finish**)
1. In a separate terminal start vulcanize_db
- `vulcanizedb sync --config <config.toml> --starting-block-number <block-number>`
* see `./environments` for example config
## Running the Tests
### Unit Tests
- `go test ./pkg/...`
1. `go test ./pkg/...`
### Integration Test
1. Setup a test database and import the schema:
`createdb vulcanize_private`
`psql vulcanize_private < db/schema.sql`
1. `go test ./...` to run all tests.
### Integration Tests
- `go test ./...` to run all tests.

View File

@ -2,14 +2,15 @@
-- PostgreSQL database dump
--
-- Dumped from database version 10.1
-- Dumped by pg_dump version 10.1
-- Dumped from database version 10.3
-- Dumped by pg_dump version 10.3
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
@ -28,8 +29,6 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
@ -38,7 +37,7 @@ SET default_with_oids = false;
-- Name: logs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE logs (
CREATE TABLE public.logs (
id integer NOT NULL,
block_number bigint,
address character varying(66),
@ -57,17 +56,17 @@ CREATE TABLE logs (
-- Name: block_stats; Type: VIEW; Schema: public; Owner: -
--
CREATE VIEW block_stats AS
CREATE VIEW public.block_stats AS
SELECT max(logs.block_number) AS max_block,
min(logs.block_number) AS min_block
FROM logs;
FROM public.logs;
--
-- Name: blocks; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE blocks (
CREATE TABLE public.blocks (
number bigint,
gaslimit bigint,
gasused bigint,
@ -92,7 +91,7 @@ CREATE TABLE blocks (
-- Name: blocks_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE blocks_id_seq
CREATE SEQUENCE public.blocks_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -105,14 +104,14 @@ CREATE SEQUENCE blocks_id_seq
-- Name: blocks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE blocks_id_seq OWNED BY blocks.id;
ALTER SEQUENCE public.blocks_id_seq OWNED BY public.blocks.id;
--
-- Name: eth_nodes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE eth_nodes (
CREATE TABLE public.eth_nodes (
id integer NOT NULL,
genesis_block character varying(66),
network_id numeric,
@ -125,7 +124,7 @@ CREATE TABLE eth_nodes (
-- Name: log_filters; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE log_filters (
CREATE TABLE public.log_filters (
id integer NOT NULL,
name character varying NOT NULL,
from_block bigint,
@ -145,7 +144,7 @@ CREATE TABLE log_filters (
-- Name: log_filters_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE log_filters_id_seq
CREATE SEQUENCE public.log_filters_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -158,14 +157,14 @@ CREATE SEQUENCE log_filters_id_seq
-- Name: log_filters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE log_filters_id_seq OWNED BY log_filters.id;
ALTER SEQUENCE public.log_filters_id_seq OWNED BY public.log_filters.id;
--
-- Name: logs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE logs_id_seq
CREATE SEQUENCE public.logs_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -178,14 +177,14 @@ CREATE SEQUENCE logs_id_seq
-- Name: logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE logs_id_seq OWNED BY logs.id;
ALTER SEQUENCE public.logs_id_seq OWNED BY public.logs.id;
--
-- Name: nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE nodes_id_seq
CREATE SEQUENCE public.nodes_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -198,14 +197,14 @@ CREATE SEQUENCE nodes_id_seq
-- Name: nodes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE nodes_id_seq OWNED BY eth_nodes.id;
ALTER SEQUENCE public.nodes_id_seq OWNED BY public.eth_nodes.id;
--
-- Name: receipts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE receipts (
CREATE TABLE public.receipts (
id integer NOT NULL,
transaction_id integer NOT NULL,
contract_address character varying(42),
@ -221,7 +220,7 @@ CREATE TABLE receipts (
-- Name: receipts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE receipts_id_seq
CREATE SEQUENCE public.receipts_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -234,14 +233,14 @@ CREATE SEQUENCE receipts_id_seq
-- Name: receipts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE receipts_id_seq OWNED BY receipts.id;
ALTER SEQUENCE public.receipts_id_seq OWNED BY public.receipts.id;
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE schema_migrations (
CREATE TABLE public.schema_migrations (
version bigint NOT NULL,
dirty boolean NOT NULL
);
@ -251,7 +250,7 @@ CREATE TABLE schema_migrations (
-- Name: transactions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE transactions (
CREATE TABLE public.transactions (
id integer NOT NULL,
hash character varying(66),
nonce numeric,
@ -269,7 +268,7 @@ CREATE TABLE transactions (
-- Name: transactions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE transactions_id_seq
CREATE SEQUENCE public.transactions_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -282,14 +281,14 @@ CREATE SEQUENCE transactions_id_seq
-- Name: transactions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE transactions_id_seq OWNED BY transactions.id;
ALTER SEQUENCE public.transactions_id_seq OWNED BY public.transactions.id;
--
-- Name: watched_contracts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE watched_contracts (
CREATE TABLE public.watched_contracts (
contract_id integer NOT NULL,
contract_hash character varying(66),
contract_abi json
@ -300,7 +299,7 @@ CREATE TABLE watched_contracts (
-- Name: watched_contracts_contract_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE watched_contracts_contract_id_seq
CREATE SEQUENCE public.watched_contracts_contract_id_seq
AS integer
START WITH 1
INCREMENT BY 1
@ -313,14 +312,14 @@ CREATE SEQUENCE watched_contracts_contract_id_seq
-- Name: watched_contracts_contract_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE watched_contracts_contract_id_seq OWNED BY watched_contracts.contract_id;
ALTER SEQUENCE public.watched_contracts_contract_id_seq OWNED BY public.watched_contracts.contract_id;
--
-- Name: watched_event_logs; Type: VIEW; Schema: public; Owner: -
--
CREATE VIEW watched_event_logs AS
CREATE VIEW public.watched_event_logs AS
SELECT log_filters.name,
logs.id,
logs.block_number,
@ -333,9 +332,9 @@ CREATE VIEW watched_event_logs AS
logs.topic3,
logs.data,
logs.receipt_id
FROM ((log_filters
CROSS JOIN block_stats)
JOIN logs ON ((((logs.address)::text = (log_filters.address)::text) AND (logs.block_number >= COALESCE(log_filters.from_block, block_stats.min_block)) AND (logs.block_number <= COALESCE(log_filters.to_block, block_stats.max_block)))))
FROM ((public.log_filters
CROSS JOIN public.block_stats)
JOIN public.logs ON ((((logs.address)::text = (log_filters.address)::text) AND (logs.block_number >= COALESCE(log_filters.from_block, block_stats.min_block)) AND (logs.block_number <= COALESCE(log_filters.to_block, block_stats.max_block)))))
WHERE ((((log_filters.topic0)::text = (logs.topic0)::text) OR (log_filters.topic0 IS NULL)) AND (((log_filters.topic1)::text = (logs.topic1)::text) OR (log_filters.topic1 IS NULL)) AND (((log_filters.topic2)::text = (logs.topic2)::text) OR (log_filters.topic2 IS NULL)) AND (((log_filters.topic3)::text = (logs.topic3)::text) OR (log_filters.topic3 IS NULL)));
@ -343,56 +342,56 @@ CREATE VIEW watched_event_logs AS
-- Name: blocks id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY blocks ALTER COLUMN id SET DEFAULT nextval('blocks_id_seq'::regclass);
ALTER TABLE ONLY public.blocks ALTER COLUMN id SET DEFAULT nextval('public.blocks_id_seq'::regclass);
--
-- Name: eth_nodes id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY eth_nodes ALTER COLUMN id SET DEFAULT nextval('nodes_id_seq'::regclass);
ALTER TABLE ONLY public.eth_nodes ALTER COLUMN id SET DEFAULT nextval('public.nodes_id_seq'::regclass);
--
-- Name: log_filters id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY log_filters ALTER COLUMN id SET DEFAULT nextval('log_filters_id_seq'::regclass);
ALTER TABLE ONLY public.log_filters ALTER COLUMN id SET DEFAULT nextval('public.log_filters_id_seq'::regclass);
--
-- Name: logs id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY logs ALTER COLUMN id SET DEFAULT nextval('logs_id_seq'::regclass);
ALTER TABLE ONLY public.logs ALTER COLUMN id SET DEFAULT nextval('public.logs_id_seq'::regclass);
--
-- Name: receipts id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY receipts ALTER COLUMN id SET DEFAULT nextval('receipts_id_seq'::regclass);
ALTER TABLE ONLY public.receipts ALTER COLUMN id SET DEFAULT nextval('public.receipts_id_seq'::regclass);
--
-- Name: transactions id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY transactions ALTER COLUMN id SET DEFAULT nextval('transactions_id_seq'::regclass);
ALTER TABLE ONLY public.transactions ALTER COLUMN id SET DEFAULT nextval('public.transactions_id_seq'::regclass);
--
-- Name: watched_contracts contract_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY watched_contracts ALTER COLUMN contract_id SET DEFAULT nextval('watched_contracts_contract_id_seq'::regclass);
ALTER TABLE ONLY public.watched_contracts ALTER COLUMN contract_id SET DEFAULT nextval('public.watched_contracts_contract_id_seq'::regclass);
--
-- Name: blocks blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY blocks
ALTER TABLE ONLY public.blocks
ADD CONSTRAINT blocks_pkey PRIMARY KEY (id);
@ -400,7 +399,7 @@ ALTER TABLE ONLY blocks
-- Name: watched_contracts contract_hash_uc; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY watched_contracts
ALTER TABLE ONLY public.watched_contracts
ADD CONSTRAINT contract_hash_uc UNIQUE (contract_hash);
@ -408,7 +407,7 @@ ALTER TABLE ONLY watched_contracts
-- Name: blocks eth_node_id_block_number_uc; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY blocks
ALTER TABLE ONLY public.blocks
ADD CONSTRAINT eth_node_id_block_number_uc UNIQUE (number, eth_node_id);
@ -416,7 +415,7 @@ ALTER TABLE ONLY blocks
-- Name: eth_nodes eth_node_uc; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY eth_nodes
ALTER TABLE ONLY public.eth_nodes
ADD CONSTRAINT eth_node_uc UNIQUE (genesis_block, network_id, eth_node_id);
@ -424,7 +423,7 @@ ALTER TABLE ONLY eth_nodes
-- Name: logs logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY logs
ALTER TABLE ONLY public.logs
ADD CONSTRAINT logs_pkey PRIMARY KEY (id);
@ -432,7 +431,7 @@ ALTER TABLE ONLY logs
-- Name: log_filters name_uc; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY log_filters
ALTER TABLE ONLY public.log_filters
ADD CONSTRAINT name_uc UNIQUE (name);
@ -440,7 +439,7 @@ ALTER TABLE ONLY log_filters
-- Name: eth_nodes nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY eth_nodes
ALTER TABLE ONLY public.eth_nodes
ADD CONSTRAINT nodes_pkey PRIMARY KEY (id);
@ -448,7 +447,7 @@ ALTER TABLE ONLY eth_nodes
-- Name: receipts receipts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY receipts
ALTER TABLE ONLY public.receipts
ADD CONSTRAINT receipts_pkey PRIMARY KEY (id);
@ -456,7 +455,7 @@ ALTER TABLE ONLY receipts
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY schema_migrations
ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
@ -464,7 +463,7 @@ ALTER TABLE ONLY schema_migrations
-- Name: transactions transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY transactions
ALTER TABLE ONLY public.transactions
ADD CONSTRAINT transactions_pkey PRIMARY KEY (id);
@ -472,7 +471,7 @@ ALTER TABLE ONLY transactions
-- Name: watched_contracts watched_contracts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY watched_contracts
ALTER TABLE ONLY public.watched_contracts
ADD CONSTRAINT watched_contracts_pkey PRIMARY KEY (contract_id);
@ -480,74 +479,74 @@ ALTER TABLE ONLY watched_contracts
-- Name: block_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX block_id_index ON transactions USING btree (block_id);
CREATE INDEX block_id_index ON public.transactions USING btree (block_id);
--
-- Name: block_number_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX block_number_index ON blocks USING btree (number);
CREATE INDEX block_number_index ON public.blocks USING btree (number);
--
-- Name: node_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX node_id_index ON blocks USING btree (eth_node_id);
CREATE INDEX node_id_index ON public.blocks USING btree (eth_node_id);
--
-- Name: transaction_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX transaction_id_index ON receipts USING btree (transaction_id);
CREATE INDEX transaction_id_index ON public.receipts USING btree (transaction_id);
--
-- Name: tx_from_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX tx_from_index ON transactions USING btree (tx_from);
CREATE INDEX tx_from_index ON public.transactions USING btree (tx_from);
--
-- Name: tx_to_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX tx_to_index ON transactions USING btree (tx_to);
CREATE INDEX tx_to_index ON public.transactions USING btree (tx_to);
--
-- Name: transactions blocks_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY transactions
ADD CONSTRAINT blocks_fk FOREIGN KEY (block_id) REFERENCES blocks(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.transactions
ADD CONSTRAINT blocks_fk FOREIGN KEY (block_id) REFERENCES public.blocks(id) ON DELETE CASCADE;
--
-- Name: blocks node_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY blocks
ADD CONSTRAINT node_fk FOREIGN KEY (eth_node_id) REFERENCES eth_nodes(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.blocks
ADD CONSTRAINT node_fk FOREIGN KEY (eth_node_id) REFERENCES public.eth_nodes(id) ON DELETE CASCADE;
--
-- Name: logs receipts_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY logs
ADD CONSTRAINT receipts_fk FOREIGN KEY (receipt_id) REFERENCES receipts(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.logs
ADD CONSTRAINT receipts_fk FOREIGN KEY (receipt_id) REFERENCES public.receipts(id) ON DELETE CASCADE;
--
-- Name: receipts transaction_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY receipts
ADD CONSTRAINT transaction_fk FOREIGN KEY (transaction_id) REFERENCES transactions(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.receipts
ADD CONSTRAINT transaction_fk FOREIGN KEY (transaction_id) REFERENCES public.transactions(id) ON DELETE CASCADE;
--

View File

@ -0,0 +1,7 @@
[database]
name = "vulcanize_public"
hostname = "localhost"
port = 5432
[client]
ipcPath = <local node's IPC filepath>