Skip to content

Commit

Permalink
staging -> master (will be v0.0.13-rc1) (#56)
Browse files Browse the repository at this point in the history
* (VDB-1164) Get node name from web3_clientVersion

Use IPC path as node ID

* 1189 new move transformer interfaces (#48)

* Move storage Transformer interface to storage pkg

* Handle new storage transformer interface in plugin writer

* Add additional storage value loader logging

* Move event transformer interface to factories/event pkg

* Handle new event transformer interface location in plugin writer

* Memoize an transformer's keccakedAddress

* Update resetHeaderCheckCount docker setup (#50)

* 1189 fix (#52)

* Update ITransformer.GetStorageKeysLookup to return a KeysLookup

* Update custom-transformers.md with new transformer paths

* TO-879:docker ci (#40)

* dockerhub via travis

* add extract-diffs

* add reset-header-check

* (VDB-1207) Remove non-essential smart comments (#53)

- configure via postgraphile.tags.json5 instead

* Update postgres version in travis build (#54)

* Update postgres version in travis build to 11.6

this is the most recent posgres version available in RDS at the moment

* update travis secrets (#55)

Co-authored-by: Gabe Laughlin <gabe@bistrotech.net>
Co-authored-by: daimesava <56128157+daimesava@users.noreply.github.com>
Co-authored-by: Rob Mulholand <rmulholand@8thlight.com>
  • Loading branch information
4 people committed Feb 25, 2020
1 parent b6b676e commit 426d44b
Show file tree
Hide file tree
Showing 42 changed files with 284 additions and 326 deletions.
17 changes: 16 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ go:
- 1.12
services:
- postgresql
- docker
addons:
postgresql: '11.2'
postgresql: '11.6'
go_import_path: github.com/makerdao/vulcanizedb
before_install:
- make installtools
Expand All @@ -16,8 +17,22 @@ before_install:
script:
- env GO111MODULE=on make test
- env GO111MODULE=on make integrationtest
deploy:
- provider: script
script: bash ./.travis/deploy.sh staging
on:
branch: staging
- provider: script
script: bash ./.travis/deploy.sh prod
on:
branch: master
notifications:
email: false
env:
matrix:
secure: Bm0u6E0esyVjJ2SMg5kVKkTJI+q0vSTOlRUFsfYQG6xAPqaxPH3iXiIwtUIuWK/pKwGtMsXDTiLuoFFASdu+AWRto2I9FisgO/foZhnsfHc1w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XZLRlWIIisFkTKNYUP9x8RtwOM1OtbiM9HyVs4l7rBIw7iVmidEdb5PYlfFfK7sc32qrQtz5Pr+e9y6ogAMK3u7WEl5EP/ozeOI=
49 changes: 49 additions & 0 deletions .travis/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#! /usr/bin/env bash

set -e

function message() {
echo
echo -----------------------------------
echo "$@"
echo -----------------------------------
echo
}

ENVIRONMENT=$1
if [ "$ENVIRONMENT" == "prod" ]; then
TAG=latest
elif [ "$ENVIRONMENT" == "staging" ]; then
TAG=staging
else
message UNKNOWN ENVIRONMENT
fi

if [ -z "$ENVIRONMENT" ]; then
echo 'You must specifiy an envionrment (bash deploy.sh <ENVIRONMENT>).'
echo 'Allowed values are "staging" or "prod"'
exit 1
fi

message BUILDING HEADER-SYNC
docker build -f dockerfiles/header_sync/Dockerfile . -t makerdao/vdb-headersync:$TAG

message BUILDING EXTRACT-DIFFS
docker build -f dockerfiles/extract_diffs/Dockerfile . -t makerdao/vdb-extract-diffs:$TAG

message BUILDING RESET-HEADER-CHECK
docker build -f dockerfiles/reset_header_check_count/Dockerfile . -t makerdao/vdb-reset-header-check:$TAG

message LOGGING INTO DOCKERHUB
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USER" --password-stdin

message PUSHING HEADER-SYNC
docker push makerdao/vdb-headersync:$TAG

message PUSHING EXTRACT-DIFFS
docker push makerdao/vdb-extract-diffs:$TAG

message PUSHING RESET-HEADER-CHECK
docker push makerdao/vdb-reset-header-check:$TAG

# message DEPLOYING SERVICE
6 changes: 4 additions & 2 deletions cmd/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"time"

"github.com/makerdao/vulcanizedb/libraries/shared/constants"
"github.com/makerdao/vulcanizedb/libraries/shared/factories/event"
"github.com/makerdao/vulcanizedb/libraries/shared/factories/storage"
"github.com/makerdao/vulcanizedb/libraries/shared/logs"
"github.com/makerdao/vulcanizedb/libraries/shared/transformer"
"github.com/makerdao/vulcanizedb/libraries/shared/watcher"
Expand Down Expand Up @@ -118,7 +120,7 @@ func executeTransformers() {
}

type Exporter interface {
Export() ([]transformer.EventTransformerInitializer, []transformer.StorageTransformerInitializer, []transformer.ContractTransformerInitializer)
Export() ([]event.TransformerInitializer, []storage.TransformerInitializer, []transformer.ContractTransformerInitializer)
}

func watchEthEvents(w *watcher.EventWatcher, wg *sync.WaitGroup) {
Expand All @@ -139,7 +141,7 @@ func watchEthEvents(w *watcher.EventWatcher, wg *sync.WaitGroup) {

func watchEthStorage(w watcher.IStorageWatcher, wg *sync.WaitGroup) {
defer wg.Done()
// Execute over the StorageTransformerInitializer set using the storage watcher
// Execute over the storage.TransformerInitializer set using the storage watcher
LogWithCommand.Info("executing storage transformers")
ticker := time.NewTicker(pollingInterval)
defer ticker.Stop()
Expand Down
14 changes: 0 additions & 14 deletions cmd/getStorageValue.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
// Copyright © 2020 NAME HERE <EMAIL ADDRESS>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (

"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
"github.com/makerdao/vulcanizedb/libraries/shared/factories/event"
"github.com/makerdao/vulcanizedb/libraries/shared/factories/storage"
"github.com/makerdao/vulcanizedb/libraries/shared/transformer"
"github.com/makerdao/vulcanizedb/pkg/config"
"github.com/makerdao/vulcanizedb/pkg/eth"
Expand Down Expand Up @@ -223,7 +225,7 @@ func prepConfig() error {
return nil
}

func exportTransformers() ([]transformer.EventTransformerInitializer, []transformer.StorageTransformerInitializer, []transformer.ContractTransformerInitializer, error) {
func exportTransformers() ([]event.TransformerInitializer, []storage.TransformerInitializer, []transformer.ContractTransformerInitializer, error) {
// Build plugin generator config
configErr := prepConfig()
if configErr != nil {
Expand Down
5 changes: 1 addition & 4 deletions db/migrations/00001_create_nodes_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ CREATE TABLE eth_nodes
genesis_block VARCHAR(66),
network_id NUMERIC,
eth_node_id VARCHAR(128),
UNIQUE (genesis_block, network_id, eth_node_id)
UNIQUE (genesis_block, network_id, eth_node_id, client_name)
);

COMMENT ON TABLE public.eth_nodes
IS E'@omit';

-- +goose Down
DROP TABLE eth_nodes;
3 changes: 0 additions & 3 deletions db/migrations/00004_create_checked_headers_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ CREATE TABLE public.checked_headers
header_id INTEGER UNIQUE NOT NULL REFERENCES headers (id) ON DELETE CASCADE
);

COMMENT ON TABLE public.checked_headers
IS E'@omit';

-- +goose Down
DROP TABLE public.checked_headers;
3 changes: 0 additions & 3 deletions db/migrations/00007_create_receipts_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ CREATE INDEX receipts_contract_address
CREATE INDEX receipts_transaction
ON public.receipts (transaction_id);

COMMENT ON TABLE public.receipts
IS E'@omit';

-- +goose Down
DROP INDEX receipts_transaction;
DROP INDEX receipts_contract_address;
Expand Down
3 changes: 0 additions & 3 deletions db/migrations/00009_create_watched_logs_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ CREATE TABLE public.watched_logs
topic_zero VARCHAR(66)
);

COMMENT ON TABLE public.watched_logs
IS E'@omit';

-- +goose Down
-- SQL in this section is executed when the migration is rolled back.
DROP TABLE public.watched_logs;
40 changes: 6 additions & 34 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- PostgreSQL database dump
--

-- Dumped from database version 12.1
-- Dumped by pg_dump version 12.1
-- Dumped from database version 11.6
-- Dumped by pg_dump version 11.6

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -32,7 +32,7 @@ $$;

SET default_tablespace = '';

SET default_table_access_method = heap;
SET default_with_oids = false;

--
-- Name: addresses; Type: TABLE; Schema: public; Owner: -
Expand Down Expand Up @@ -75,13 +75,6 @@ CREATE TABLE public.checked_headers (
);


--
-- Name: TABLE checked_headers; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.checked_headers IS '@omit';


--
-- Name: checked_headers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
Expand Down Expand Up @@ -115,13 +108,6 @@ CREATE TABLE public.eth_nodes (
);


--
-- Name: TABLE eth_nodes; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.eth_nodes IS '@omit';


--
-- Name: eth_nodes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
Expand Down Expand Up @@ -269,13 +255,6 @@ CREATE TABLE public.receipts (
);


--
-- Name: TABLE receipts; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.receipts IS '@omit';


--
-- Name: receipts_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
Expand Down Expand Up @@ -382,13 +361,6 @@ CREATE TABLE public.watched_logs (
);


--
-- Name: TABLE watched_logs; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE public.watched_logs IS '@omit';


--
-- Name: watched_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
Expand Down Expand Up @@ -512,11 +484,11 @@ ALTER TABLE ONLY public.checked_headers


--
-- Name: eth_nodes eth_nodes_genesis_block_network_id_eth_node_id_key; Type: CONSTRAINT; Schema: public; Owner: -
-- Name: eth_nodes eth_nodes_genesis_block_network_id_eth_node_id_client_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.eth_nodes
ADD CONSTRAINT eth_nodes_genesis_block_network_id_eth_node_id_key UNIQUE (genesis_block, network_id, eth_node_id);
ADD CONSTRAINT eth_nodes_genesis_block_network_id_eth_node_id_client_name_key UNIQUE (genesis_block, network_id, eth_node_id, client_name);


--
Expand Down Expand Up @@ -690,7 +662,7 @@ CREATE INDEX transactions_header ON public.transactions USING btree (header_id);
-- Name: headers header_updated; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER header_updated BEFORE UPDATE ON public.headers FOR EACH ROW EXECUTE FUNCTION public.set_header_updated();
CREATE TRIGGER header_updated BEFORE UPDATE ON public.headers FOR EACH ROW EXECUTE PROCEDURE public.set_header_updated();


--
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ docker build -f dockerfiles/reset_header_check_count/Dockerfile . -t reset_heade

### Run
```
docker run -e CLIENT_IPCPATH=ipc_path -e DATABASE_USER=user -e DATABASE_PASSWORD=password -e DATABASE_HOSTNAME=host -e DATABASE_PORT=port -e DATABASE_NAME=name -e HEADER_BLOCK_NUMBER=0 -it reset_header_check_count:latest
docker run -e CLIENT_IPCPATH=ipc_path -e DATABASE_USER=user -e DATABASE_PASSWORD=password -e DATABASE_HOSTNAME=host -e DATABASE_PORT=port -e DATABASE_NAME=name -e RESET_HEADER_COUNT_BLOCK_NUMBER=block-number -it reset_header_check_count:latest
```
Notes:
- `HEADER_BLOCK_NUMBER` variable is required
Expand Down
6 changes: 3 additions & 3 deletions dockerfiles/reset_header_check_count/startup_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Verify required args present
MISSING_VAR_MESSAGE=" is required and no value was given"

if test -z "$HEADER_BLOCK_NUMBER"
if test -z "$RESET_HEADER_COUNT_BLOCK_NUMBER"
then
echo HEADER_BLOCK_NUMBER $MISSING_VAR_MESSAGE
echo RESET_HEADER_COUNT_BLOCK_NUMBER $MISSING_VAR_MESSAGE
exit 1
fi

Expand Down Expand Up @@ -36,4 +36,4 @@ fi
# Run resetHeaderCheckCount
echo "Running resetHeaderCheckCount..."
echo header_block_number: $HEADER_BLOCK_NUMBER
./vulcanizedb resetHeaderCheckCount --header-block-number=$HEADER_BLOCK_NUMBER
./vulcanizedb resetHeaderCheckCount --reset-header-count-block-number=$RESET_HEADER_COUNT_BLOCK_NUMBER
34 changes: 19 additions & 15 deletions documentation/custom-transformers.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ purpose can be leveraged.
Individual custom transformers can be composed together from any number of external repositories and executed as a
single process using the `compose` and `execute` commands or the `composeAndExecute` command. This is accomplished by
generating a Go plugin which allows the `vulcanizedb` binary to link to the external transformers, so long as they
abide by one of the standard [interfaces](../staging/libraries/shared/transformer).
abide by the [event transformer interface](../libraries/shared/factories/event/transformer.go) or the
[storage transformer interface](../libraries/shared/factories/storage/transformer.go).

## Writing custom transformers
For help with writing different types of custom transformers please see below:

Storage Transformers: transform data derived from contract storage tries
* [Guide](../../staging/libraries/shared/factories/storage/README.md)
* [Example](../../staging/libraries/shared/factories/storage/EXAMPLE.md)
* [Guide](../libraries/shared/factories/storage/README.md)
* [Example](../libraries/shared/factories/storage/EXAMPLE.md)

Event Transformers: transform data derived from Ethereum log events
* [Guide](../../staging/libraries/shared/factories/event/README.md)
* [Guide](../libraries/shared/factories/event/README.md)
* [Example 1](https://github.com/vulcanize/ens_transformers/tree/master/transformers/registar)
* [Example 2](https://github.com/vulcanize/ens_transformers/tree/master/transformers/registry)
* [Example 3](https://github.com/vulcanize/ens_transformers/tree/master/transformers/resolver)
Expand All @@ -27,12 +28,13 @@ Contract Transformers: transform data derived from Ethereum log events and use i
## Preparing custom transformers to work as part of a plugin
To plug in an external transformer we need to:

1. Create a package that exports a variable `TransformerInitializer`, `StorageTransformerInitializer`, or `ContractTransformerInitializer` that are of type [TransformerInitializer](../staging/libraries/shared/transformer/event_transformer.go#L33)
or [StorageTransformerInitializer](../../staging/libraries/shared/transformer/storage_transformer.go#L31),
or [ContractTransformerInitializer](../../staging/libraries/shared/transformer/contract_transformer.go#L31), respectively
2. Design the transformers to work in the context of their [event](../staging/libraries/shared/watcher/event_watcher.go#L83),
[storage](../../staging/libraries/shared/watcher/storage_watcher.go#L53),
or [contract](../../staging/libraries/shared/watcher/contract_watcher.go#L68) watcher execution modes
1. Create a package that exports a variable `EventTransformerInitializer`, `StorageTransformerInitializer`, or `ContractTransformerInitializer`
that are of type [event.TransformerInitializer](../libraries/shared/factories/event/transformer.go#L31)
or [storage.TransformerInitializer](../libraries/shared/factories/storage/transformer.go#L33),
or [ContractTransformerInitializer](../libraries/shared/transformer/contract_transformer.go#L31), respectively
2. Design the transformers to work in the context of their [event](../libraries/shared/watcher/event_watcher.go),
[storage](../libraries/shared/watcher/storage_watcher.go),
or [contract](../libraries/shared/watcher/contract_watcher.go) watcher `Execute` methods
3. Create db migrations to run against vulcanizeDB so that we can store the transformer output
* Do not `goose fix` the transformer migrations, this is to ensure they are always ran after the core vulcanizedb migrations which are kept in their fixed form
* Specify migration locations for each transformer in the config with the `exporter.transformer.migrations` fields
Expand Down Expand Up @@ -140,12 +142,12 @@ The config provides information for composing a set of transformers from externa
- `path` is the relative path from `repository` to the transformer's `TransformerInitializer` directory (initializer package).
- Transformer repositories need to be cloned into the user's $GOPATH (`go get`)
- `type` is the type of the transformer; indicating which type of watcher it works with (for now, there are only two options: `eth_event` and `eth_storage`)
- `eth_storage` indicates the transformer works with the [storage watcher](../../staging/libraries/shared/watcher/storage_watcher.go)
- `eth_storage` indicates the transformer works with the [storage watcher](../libraries/shared/watcher/storage_watcher.go)
that fetches state and storage diffs from an ETH node (instead of, for example, from IPFS)
- `eth_event` indicates the transformer works with the [event watcher](../../staging/libraries/shared/watcher/event_watcher.go)
- `eth_event` indicates the transformer works with the [event watcher](../libraries/shared/watcher/event_watcher.go)
that fetches event logs from an ETH node
- `eth_contract` indicates the transformer works with the [contract watcher](../staging/libraries/shared/watcher/contract_watcher.go)
that is made to work with [contract_watcher pkg](../../staging/pkg/contract_watcher)
- `eth_contract` indicates the transformer works with the [contract watcher](../libraries/shared/watcher/contract_watcher.go)
that is made to work with [contract_watcher pkg](../pkg/contract_watcher)
based transformers which work with vDB to watch events and poll public methods ([example1](https://github.com/vulcanize/account_transformers/tree/master/transformers/account/light), [example2](https://github.com/vulcanize/ens_transformers/tree/working/transformers/domain_records))
- `migrations` is the relative path from `repository` to the db migrations directory for the transformer
- `rank` determines the order that migrations are ran, with lower ranked migrations running first
Expand All @@ -167,7 +169,9 @@ The general structure of a plugin .go file, and what we would see built with the
package main

import (
interface1 "github.com/makerdao/vulcanizedb/libraries/shared/transformer"
"github.com/makerdao/vulcanizedb/libraries/shared/factories/event"
"github.com/makerdao/vulcanizedb/libraries/shared/factories/storage"
interface1 "github.com/makerdao/vulcanizedb/libraries/shared/transformer"
transformer1 "github.com/account/repo/path/to/transformer1"
transformer2 "github.com/account/repo/path/to/transformer2"
transformer3 "github.com/account/repo/path/to/transformer3"
Expand Down
Loading

0 comments on commit 426d44b

Please sign in to comment.