Update README, add State sync test (#1)

This commit is contained in:
Matt K 2018-01-26 13:38:14 -06:00 committed by GitHub
parent afdeadeca1
commit 3b31e2a342
3 changed files with 31 additions and 19 deletions

View File

@ -38,3 +38,14 @@ build: dep
test: $(GINKGO) test: $(GINKGO)
ginkgo -r ginkgo -r
createprivate:
#!/bin/bash
echo "Deleting test blockchain"
rm -rf test_data_dir
echo "Creating test blockchain with a new account"
mkdir test_data_dir
geth --dev --datadir test_data_dir --password .private_blockchain_password account new
startprivate: createprivate
geth --datadir test_data_dir --dev --nodiscover --mine --minerthreads 1 --maxpeers 0 --verbosity 3 --unlock 0 --password .private_blockchain_password --rpc

View File

@ -18,40 +18,32 @@
2. Create a superuser for yourself and make sure `psql --list` works without prompting for a password. 2. Create a superuser for yourself and make sure `psql --list` works without prompting for a password.
3. `createdb vulcanize_private` 3. `createdb vulcanize_private`
4. `cd $GOPATH/src/github.com/vulcanize/vulcanizedb` 4. `cd $GOPATH/src/github.com/vulcanize/vulcanizedb`
5. Import the schema: 5. Import the schema: `psql vulcanize_private < db/schema.sql`
`psql vulcanize_private < db/schema.sql`
or run the migrations: or run the migrations: `make migrate HOST_NAME=localhost NAME=vulcanize_public PORT=5432`
`make migrate HOST_NAME=localhost NAME=vulcanize_public PORT=5432`
* See below for configuring additional environments * See below for configuring additional environments
Adding a new migration: `./scripts/create_migration <migration-name>` Adding a new migration: `./scripts/create_migration <migration-name>`
## Start syncing with postgres ## Start syncing with postgres
1. Start geth 1. Start geth node (**if fast syncing wait for geth to finsh initial sync**)
2. In a separate terminal start vulcanize_db 2. In a separate terminal start vulcanize_db
- `vulcanizedb sync --config <config.toml> --starting-block-number <block-numbe>` - `vulcanizedb sync --config <config.toml> --starting-block-number <block-numbe>`
* see `environments` for example config * see `environments` for example config
## Watch specific contract events ## Watch specific events
1. Start geth 1. Start geth
2. In a separate terminal start vulcanize_db 2. In a separate terminal start vulcanize_db
- `vulcanizedb sync --config <config.toml> --starting-block-number <block-numbe>` - `vulcanizedb sync --config <config.toml> --starting-block-number <block-numbe>`
3. Create event filter 3. Create event filter
- `vulcanizedb addFilter --config <config.toml> --filter-filepath <filter.json>` - `vulcanizedb addFilter --config <config.toml> --filter-filepath <filter.json>`
4. The filters are tracked in the `log_filters` table and the filtered events
* see `filters` for example filter will show up in the `watched_log_events` view
* see `./filters` for example filter
## Development Setup ## Development Setup
### Cloning the Repository (Private repo only)
1. `git config --global url."git@github.com:".insteadOf "https://github.com/"`
- By default, `go get` does not work for private GitHub repos. This will fix that.
2. `go get github.com/vulcanize/vulcanizedb`
3. `cd $GOPATH/src/github.com/vulcanize/vulcanizedb`
4. `dep ensure`
### Creating/Using a test node ### Creating/Using a test node
Syncing the against the public network takes many hours for the initial sync and will download 20+ GB of data. Syncing the against the public network takes many hours for the initial sync and will download 20+ GB of data.
@ -80,5 +72,10 @@ The default location for Ethereum is:
In order to run the integration tests, you will need to run them against a real blockchain. At the moment the integration tests require [Geth v1.7.2](https://ethereum.github.io/go-ethereum/downloads/) as they depend on the `--dev` mode, which changed in v1.7.3 In order to run the integration tests, you will need to run them against a real blockchain. At the moment the integration tests require [Geth v1.7.2](https://ethereum.github.io/go-ethereum/downloads/) as they depend on the `--dev` mode, which changed in v1.7.3
1. Run `./scripts/start_private_blockchain` as a separate process. 1. Run `make startprivate` in a separate terminal
2. `go test ./...` to run all tests. 2. Setup a test database and import the schema:
`createdb vulcanize_private`
`psql vulcanize_private < db/schema.sql`
3. `go test ./...` to run all tests.

View File

@ -11,6 +11,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/repositories" "github.com/vulcanize/vulcanizedb/pkg/repositories"
"github.com/vulcanize/vulcanizedb/utils" "github.com/vulcanize/vulcanizedb/utils"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"log"
) )
// syncCmd represents the sync command // syncCmd represents the sync command
@ -58,6 +59,9 @@ func sync() {
defer ticker.Stop() defer ticker.Stop()
blockchain := geth.NewBlockchain(ipc) blockchain := geth.NewBlockchain(ipc)
if blockchain.LastBlock().Int64() == 0 {
log.Fatal("geth initial: state sync not finished")
}
repository := utils.LoadPostgres(databaseConfig, blockchain.Node()) repository := utils.LoadPostgres(databaseConfig, blockchain.Node())
validator := history.NewBlockValidator(blockchain, repository, 15) validator := history.NewBlockValidator(blockchain, repository, 15)