Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c91f7cd9c6 | ||
|
|
c15061dee6 | ||
|
|
174ac94752 | ||
|
|
79c852d949 | ||
|
|
61a4cea80b | ||
|
|
e05942ec17 |
@@ -3,61 +3,61 @@ name: Docker Build
|
|||||||
on: [pull_request]
|
on: [pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# concise_migration_diff:
|
concise_migration_diff:
|
||||||
# name: Verify concise migration and generated schema
|
name: Verify concise migration and generated schema
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
# - name: Run docker concise migration build
|
- name: Run docker concise migration build
|
||||||
# run: make docker-concise-migration-build
|
run: make docker-concise-migration-build
|
||||||
# - name: Run database
|
- name: Run database
|
||||||
# run: docker-compose -f docker-compose.test.yml up -d test-db
|
run: docker-compose -f docker-compose.test.yml up -d test-db
|
||||||
# - name: Test concise migration
|
- name: Test concise migration
|
||||||
# run: |
|
run: |
|
||||||
# sleep 10
|
sleep 10
|
||||||
# docker run --rm --network host -e DATABASE_USER=vdbm -e DATABASE_PASSWORD=password \
|
docker run --rm --network host -e DATABASE_USER=vdbm -e DATABASE_PASSWORD=password \
|
||||||
# -e DATABASE_HOSTNAME=127.0.0.1 -e DATABASE_PORT=8066 -e DATABASE_NAME=vulcanize_testing \
|
-e DATABASE_HOSTNAME=127.0.0.1 -e DATABASE_PORT=8066 -e DATABASE_NAME=vulcanize_testing \
|
||||||
# vulcanize/concise-migration-build
|
vulcanize/concise-migration-build
|
||||||
# - name: Verify schema is latest
|
- name: Verify schema is latest
|
||||||
# run: |
|
run: |
|
||||||
# PGPASSWORD="password" pg_dump -h localhost -p 8066 -U vdbm vulcanize_testing --no-owner --schema-only > ./db/migration_schema.sql
|
PGPASSWORD="password" pg_dump -h localhost -p 8066 -U vdbm vulcanize_testing --no-owner --schema-only > ./db/migration_schema.sql
|
||||||
# ./scripts/check_diff.sh ./db/migration_schema.sql db/schema.sql
|
./scripts/check_diff.sh ./db/migration_schema.sql db/schema.sql
|
||||||
|
|
||||||
# incremental_migration_diff:
|
incremental_migration_diff:
|
||||||
# name: Compare conscise migration schema with incremental migration.
|
name: Compare conscise migration schema with incremental migration.
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
# - name: Run database
|
- name: Run database
|
||||||
# run: docker-compose -f docker-compose.test.yml up -d test-db statediff-migrations
|
run: docker-compose -f docker-compose.test.yml up -d test-db statediff-migrations
|
||||||
# - name: Test incremental migration
|
- name: Test incremental migration
|
||||||
# run: |
|
run: |
|
||||||
# sleep 10
|
sleep 10
|
||||||
# docker run --rm --network host -e DATABASE_USER=vdbm -e DATABASE_PASSWORD=password \
|
docker run --rm --network host -e DATABASE_USER=vdbm -e DATABASE_PASSWORD=password \
|
||||||
# -e DATABASE_HOSTNAME=127.0.0.1 -e DATABASE_PORT=8066 -e DATABASE_NAME=vulcanize_testing \
|
-e DATABASE_HOSTNAME=127.0.0.1 -e DATABASE_PORT=8066 -e DATABASE_NAME=vulcanize_testing \
|
||||||
# vulcanize/statediff-migrations:v0.9.0
|
vulcanize/statediff-migrations:v0.9.0
|
||||||
# - name: Verify schema is latest
|
- name: Verify schema is latest
|
||||||
# run: |
|
run: |
|
||||||
# PGPASSWORD="password" pg_dump -h localhost -p 8066 -U vdbm vulcanize_testing --no-owner --schema-only > ./db/migration_schema.sql
|
PGPASSWORD="password" pg_dump -h localhost -p 8066 -U vdbm vulcanize_testing --no-owner --schema-only > ./db/migration_schema.sql
|
||||||
# ./scripts/check_diff.sh db/schema.sql ./db/migration_schema.sql
|
./scripts/check_diff.sh db/schema.sql ./db/migration_schema.sql
|
||||||
|
|
||||||
# migration:
|
migration:
|
||||||
# name: Compare up and down migration
|
name: Compare up and down migration
|
||||||
# env:
|
env:
|
||||||
# GOPATH: /tmp/go
|
GOPATH: /tmp/go
|
||||||
# strategy:
|
strategy:
|
||||||
# matrix:
|
matrix:
|
||||||
# go-version: [ 1.16.x ]
|
go-version: [ 1.16.x ]
|
||||||
# os: [ ubuntu-latest ]
|
os: [ ubuntu-latest ]
|
||||||
# runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
# steps:
|
steps:
|
||||||
# - name: Create GOPATH
|
- name: Create GOPATH
|
||||||
# run: mkdir -p /tmp/go
|
run: mkdir -p /tmp/go
|
||||||
# - name: Install Go
|
- name: Install Go
|
||||||
# uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
# with:
|
with:
|
||||||
# go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
# - uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
# - name: Test migration
|
- name: Test migration
|
||||||
# run: |
|
run: |
|
||||||
# timeout 5m make test-migrations
|
timeout 5m make test-migrations
|
||||||
+2
-27
@@ -1,28 +1,3 @@
|
|||||||
FROM golang:1.16-alpine as builder
|
FROM postgres:12-alpine
|
||||||
|
|
||||||
RUN apk --update --no-cache add make git g++ linux-headers
|
COPY ./schema.sql /docker-entrypoint-initdb.d/init.sql
|
||||||
|
|
||||||
ADD . /go/src/github.com/vulcanize/ipld-eth-db
|
|
||||||
|
|
||||||
# Build migration tool
|
|
||||||
WORKDIR /go/src/github.com/pressly
|
|
||||||
RUN git clone https://github.com/pressly/goose.git
|
|
||||||
WORKDIR /go/src/github.com/pressly/goose/cmd/goose
|
|
||||||
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -tags='no_sqlite3' -o goose .
|
|
||||||
|
|
||||||
# app container
|
|
||||||
FROM alpine
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-db/scripts/startup_script.sh .
|
|
||||||
|
|
||||||
# copy over files for multi-node setup
|
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-db/docker-compose.test.yml docker-multi-node/docker-compose.test.yml
|
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-db/scripts/init-access-node.sh docker-multi-node/scripts/init-access-node.sh
|
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-db/scripts/init-data-node.sh docker-multi-node/scripts/init-data-node.sh
|
|
||||||
|
|
||||||
COPY --from=builder /go/src/github.com/pressly/goose/cmd/goose/goose goose
|
|
||||||
COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-db/db/migrations migrations/vulcanizedb
|
|
||||||
|
|
||||||
ENTRYPOINT ["/app/startup_script.sh"]
|
|
||||||
@@ -1,14 +1,10 @@
|
|||||||
ifndef GOPATH
|
|
||||||
override GOPATH = $(HOME)/go
|
|
||||||
endif
|
|
||||||
|
|
||||||
BIN = $(GOPATH)/bin
|
BIN = $(GOPATH)/bin
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
## Migration tool
|
## Migration tool
|
||||||
GOOSE = $(BIN)/goose
|
GOOSE = $(BIN)/goose
|
||||||
$(BIN)/goose:
|
$(BIN)/goose:
|
||||||
GO111MODULE=off go get -u github.com/pressly/goose/cmd/goose
|
go get -u github.com/pressly/goose/cmd/goose
|
||||||
|
|
||||||
.PHONY: installtools
|
.PHONY: installtools
|
||||||
installtools: | $(GOOSE)
|
installtools: | $(GOOSE)
|
||||||
@@ -48,47 +44,18 @@ rollback: $(GOOSE) checkdbvars
|
|||||||
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" down
|
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" down
|
||||||
pg_dump -O -s $(CONNECT_STRING) > schema.sql
|
pg_dump -O -s $(CONNECT_STRING) > schema.sql
|
||||||
|
|
||||||
|
|
||||||
## Rollback to a select migration (id/timestamp)
|
## Rollback to a select migration (id/timestamp)
|
||||||
.PHONY: rollback_to
|
.PHONY: rollback_to
|
||||||
rollback_to: $(GOOSE) checkmigration checkdbvars
|
rollback_to: $(GOOSE) checkmigration checkdbvars
|
||||||
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" down-to "$(MIGRATION)"
|
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" down-to "$(MIGRATION)"
|
||||||
|
|
||||||
## Rollback pre_batch_set
|
|
||||||
.PHONY: `rollback_pre_batch_set`
|
|
||||||
rollback_pre_batch_set: $(GOOSE) checkdbvars
|
|
||||||
$(GOOSE) -dir db/pre_batch_processing_migrations postgres "$(CONNECT_STRING)" down
|
|
||||||
|
|
||||||
## Rollback post_batch_set
|
|
||||||
.PHONY: rollback_post_batch_set
|
|
||||||
rollback_post_batch_set: $(GOOSE) checkdbvars
|
|
||||||
$(GOOSE) -dir db/post_batch_processing_migrations postgres "$(CONNECT_STRING)" down
|
|
||||||
|
|
||||||
## Apply the next up migration
|
|
||||||
.PHONY: migrate_up_by_one
|
|
||||||
migrate_up_by_one: $(GOOSE) checkdbvars
|
|
||||||
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" up-by-one
|
|
||||||
|
|
||||||
## Apply all migrations not already run
|
## Apply all migrations not already run
|
||||||
.PHONY: migrate
|
.PHONY: migrate
|
||||||
migrate: $(GOOSE) checkdbvars
|
migrate: $(GOOSE) checkdbvars
|
||||||
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" up
|
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" up
|
||||||
pg_dump -O -s $(CONNECT_STRING) > schema.sql
|
pg_dump -O -s $(CONNECT_STRING) > schema.sql
|
||||||
|
|
||||||
## Apply migrations to be ran before a batch processing
|
|
||||||
.PHONY: migrate_pre_batch_set
|
|
||||||
migrate_pre_batch_set: $(GOOSE) checkdbvars
|
|
||||||
$(GOOSE) -dir db/pre_batch_processing_migrations postgres "$(CONNECT_STRING)" up
|
|
||||||
|
|
||||||
## Apply migrations to be ran after a batch processing, one-by-one
|
|
||||||
.PHONY: migrate_post_batch_set_up_by_one
|
|
||||||
migrate_post_batch_set_up_by_one: $(GOOSE) checkdbvars
|
|
||||||
$(GOOSE) -dir db/post_batch_processing_migrations postgres "$(CONNECT_STRING)" up-by-one
|
|
||||||
|
|
||||||
## Apply migrations to be ran after a batch processing
|
|
||||||
.PHONY: migrate_post_batch_set
|
|
||||||
migrate_post_batch_set: $(GOOSE) checkdbvars
|
|
||||||
$(GOOSE) -dir db/post_batch_processing_migrations postgres "$(CONNECT_STRING)" up
|
|
||||||
|
|
||||||
## Create a new migration file
|
## Create a new migration file
|
||||||
.PHONY: new_migration
|
.PHONY: new_migration
|
||||||
new_migration: $(GOOSE) checkmigname
|
new_migration: $(GOOSE) checkmigname
|
||||||
@@ -124,4 +91,4 @@ docker-concise-migration-build:
|
|||||||
|
|
||||||
.PHONY: test-migrations
|
.PHONY: test-migrations
|
||||||
test-migrations: $(GOOSE)
|
test-migrations: $(GOOSE)
|
||||||
./scripts/test_migration.sh
|
./scripts/test_migration.sh
|
||||||
@@ -2,44 +2,4 @@
|
|||||||
Schemas and utils for IPLD ETH Postgres database
|
Schemas and utils for IPLD ETH Postgres database
|
||||||
|
|
||||||
## Database UML
|
## Database UML
|
||||||

|

|
||||||
|
|
||||||
## Run
|
|
||||||
|
|
||||||
* Remove any existing containers / volumes:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose down -v --remove-orphans
|
|
||||||
```
|
|
||||||
|
|
||||||
* Spin up an access node and three data nodes using [docker-compose.test.yml](./docker-compose.test.yml):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose -f docker-compose.test.yml up
|
|
||||||
```
|
|
||||||
|
|
||||||
Following final output should be seen on all the nodes:
|
|
||||||
|
|
||||||
```
|
|
||||||
LOG: TimescaleDB background worker launcher connected to shared catalogs
|
|
||||||
```
|
|
||||||
|
|
||||||
* Edit [startup_script.sh](./scripts/startup_script.sh) to change the number of migrations to be run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./goose -dir migrations/vulcanizedb postgres "$VDB_PG_CONNECT" up-to 21
|
|
||||||
```
|
|
||||||
|
|
||||||
* In another `ipld-eth-db` terminal window, build an image `migrations-test` using [Dockerfile](./db/Dockerfile):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker build -t migrations-test -f ./db/Dockerfile .
|
|
||||||
```
|
|
||||||
|
|
||||||
* After the access and data nodes have spun up, start a container using `migrations-test` image to run the db migrations:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Here, we are running the container using host network.
|
|
||||||
# So connect to access node on 127.0.0.1:8066
|
|
||||||
docker run --rm --network host -e DATABASE_USER=postgres -e DATABASE_PASSWORD=password -e DATABASE_HOSTNAME=127.0.0.1 -e DATABASE_PORT=8066 -e DATABASE_NAME=vulcanize_testing_v4 migrations-test
|
|
||||||
```
|
|
||||||
+1
-1
@@ -8,7 +8,7 @@ ADD . /go/src/github.com/vulcanize/ipld-eth-db
|
|||||||
WORKDIR /go/src/github.com/pressly
|
WORKDIR /go/src/github.com/pressly
|
||||||
RUN git clone https://github.com/pressly/goose.git
|
RUN git clone https://github.com/pressly/goose.git
|
||||||
WORKDIR /go/src/github.com/pressly/goose/cmd/goose
|
WORKDIR /go/src/github.com/pressly/goose/cmd/goose
|
||||||
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -tags='no_sqlite3' -o goose .
|
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -tags='no_mysql no_sqlite' -o goose .
|
||||||
|
|
||||||
# app container
|
# app container
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS public.blocks (
|
CREATE TABLE IF NOT EXISTS public.blocks (
|
||||||
block_number BIGINT NOT NULL,
|
key TEXT UNIQUE NOT NULL,
|
||||||
key TEXT NOT NULL,
|
data BYTEA NOT NULL
|
||||||
data BYTEA NOT NULL,
|
|
||||||
PRIMARY KEY (key, block_number)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS nodes (
|
CREATE TABLE nodes (
|
||||||
genesis_block VARCHAR(66),
|
id SERIAL PRIMARY KEY,
|
||||||
network_id VARCHAR,
|
client_name VARCHAR,
|
||||||
node_id VARCHAR(128) PRIMARY KEY,
|
genesis_block VARCHAR(66),
|
||||||
client_name VARCHAR,
|
network_id VARCHAR,
|
||||||
chain_id INTEGER DEFAULT 1
|
node_id VARCHAR(128),
|
||||||
|
chain_id INTEGER DEFAULT 1,
|
||||||
|
CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id, chain_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS eth.header_cids (
|
CREATE TABLE eth.header_cids (
|
||||||
block_number BIGINT NOT NULL,
|
id SERIAL PRIMARY KEY,
|
||||||
block_hash VARCHAR(66) NOT NULL,
|
block_number BIGINT NOT NULL,
|
||||||
parent_hash VARCHAR(66) NOT NULL,
|
block_hash VARCHAR(66) NOT NULL,
|
||||||
cid TEXT NOT NULL,
|
parent_hash VARCHAR(66) NOT NULL,
|
||||||
td NUMERIC NOT NULL,
|
cid TEXT NOT NULL,
|
||||||
node_id VARCHAR(128) NOT NULL,
|
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
reward NUMERIC NOT NULL,
|
td NUMERIC NOT NULL,
|
||||||
state_root VARCHAR(66) NOT NULL,
|
node_id INTEGER NOT NULL REFERENCES nodes (id) ON DELETE CASCADE,
|
||||||
tx_root VARCHAR(66) NOT NULL,
|
reward NUMERIC NOT NULL,
|
||||||
receipt_root VARCHAR(66) NOT NULL,
|
state_root VARCHAR(66) NOT NULL,
|
||||||
uncle_root VARCHAR(66) NOT NULL,
|
tx_root VARCHAR(66) NOT NULL,
|
||||||
bloom BYTEA NOT NULL,
|
receipt_root VARCHAR(66) NOT NULL,
|
||||||
timestamp BIGINT NOT NULL,
|
uncle_root VARCHAR(66) NOT NULL,
|
||||||
mh_key TEXT NOT NULL,
|
bloom BYTEA NOT NULL,
|
||||||
times_validated INTEGER NOT NULL DEFAULT 1,
|
timestamp NUMERIC NOT NULL,
|
||||||
coinbase VARCHAR(66) NOT NULL,
|
times_validated INTEGER NOT NULL DEFAULT 1,
|
||||||
PRIMARY KEY (block_hash, block_number)
|
base_fee BIGINT,
|
||||||
|
UNIQUE (block_number, block_hash)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
DROP TABLE eth.header_cids;
|
DROP TABLE eth.header_cids;
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS eth.uncle_cids (
|
CREATE TABLE eth.uncle_cids (
|
||||||
block_number BIGINT NOT NULL,
|
id SERIAL PRIMARY KEY,
|
||||||
block_hash VARCHAR(66) NOT NULL,
|
header_id INTEGER NOT NULL REFERENCES eth.header_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
header_id VARCHAR(66) NOT NULL,
|
block_hash VARCHAR(66) NOT NULL,
|
||||||
parent_hash VARCHAR(66) NOT NULL,
|
parent_hash VARCHAR(66) NOT NULL,
|
||||||
cid TEXT NOT NULL,
|
cid TEXT NOT NULL,
|
||||||
reward NUMERIC NOT NULL,
|
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
mh_key TEXT NOT NULL,
|
reward NUMERIC NOT NULL,
|
||||||
PRIMARY KEY (block_hash, block_number)
|
UNIQUE (header_id, block_hash)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
DROP TABLE eth.uncle_cids;
|
DROP TABLE eth.uncle_cids;
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS eth.transaction_cids (
|
CREATE TABLE eth.transaction_cids (
|
||||||
block_number BIGINT NOT NULL,
|
id SERIAL PRIMARY KEY,
|
||||||
header_id VARCHAR(66) NOT NULL,
|
header_id INTEGER NOT NULL REFERENCES eth.header_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
tx_hash VARCHAR(66) NOT NULL,
|
tx_hash VARCHAR(66) NOT NULL,
|
||||||
cid TEXT NOT NULL,
|
index INTEGER NOT NULL,
|
||||||
dst VARCHAR(66) NOT NULL,
|
cid TEXT NOT NULL,
|
||||||
src VARCHAR(66) NOT NULL,
|
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
index INTEGER NOT NULL,
|
dst VARCHAR(66) NOT NULL,
|
||||||
mh_key TEXT NOT NULL,
|
src VARCHAR(66) NOT NULL,
|
||||||
tx_data BYTEA,
|
tx_data BYTEA,
|
||||||
tx_type INTEGER,
|
tx_type BYTEA,
|
||||||
value NUMERIC,
|
UNIQUE (header_id, tx_hash)
|
||||||
PRIMARY KEY (tx_hash, block_number)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS eth.receipt_cids (
|
CREATE TABLE eth.receipt_cids (
|
||||||
block_number BIGINT NOT NULL,
|
id SERIAL PRIMARY KEY,
|
||||||
tx_id VARCHAR(66) NOT NULL,
|
tx_id INTEGER NOT NULL REFERENCES eth.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
leaf_cid TEXT NOT NULL,
|
leaf_cid TEXT NOT NULL,
|
||||||
contract VARCHAR(66),
|
leaf_mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
contract_hash VARCHAR(66),
|
contract VARCHAR(66),
|
||||||
leaf_mh_key TEXT NOT NULL,
|
contract_hash VARCHAR(66),
|
||||||
post_state VARCHAR(66),
|
post_state VARCHAR(66),
|
||||||
post_status INTEGER,
|
post_status INTEGER,
|
||||||
log_root VARCHAR(66),
|
log_root VARCHAR(66),
|
||||||
PRIMARY KEY (tx_id, block_number)
|
UNIQUE (tx_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
DROP TABLE eth.receipt_cids;
|
DROP TABLE eth.receipt_cids;
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS eth.state_cids (
|
CREATE TABLE eth.state_cids (
|
||||||
block_number BIGINT NOT NULL,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
header_id VARCHAR(66) NOT NULL,
|
header_id INTEGER NOT NULL REFERENCES eth.header_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
state_leaf_key VARCHAR(66),
|
state_leaf_key VARCHAR(66),
|
||||||
cid TEXT NOT NULL,
|
cid TEXT NOT NULL,
|
||||||
state_path BYTEA NOT NULL,
|
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
node_type INTEGER NOT NULL,
|
state_path BYTEA,
|
||||||
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
node_type INTEGER NOT NULL,
|
||||||
mh_key TEXT NOT NULL,
|
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
PRIMARY KEY (state_path, header_id, block_number)
|
UNIQUE (header_id, state_path)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
DROP TABLE eth.state_cids;
|
DROP TABLE eth.state_cids;
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
-- +goose Up
|
-- +goose Up
|
||||||
CREATE TABLE IF NOT EXISTS eth.storage_cids (
|
CREATE TABLE eth.storage_cids (
|
||||||
block_number BIGINT NOT NULL,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
header_id VARCHAR(66) NOT NULL,
|
state_id BIGINT NOT NULL REFERENCES eth.state_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
state_path BYTEA NOT NULL,
|
storage_leaf_key VARCHAR(66),
|
||||||
storage_leaf_key VARCHAR(66),
|
cid TEXT NOT NULL,
|
||||||
cid TEXT NOT NULL,
|
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
storage_path BYTEA NOT NULL,
|
storage_path BYTEA,
|
||||||
node_type INTEGER NOT NULL,
|
node_type INTEGER NOT NULL,
|
||||||
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
mh_key TEXT NOT NULL,
|
UNIQUE (state_id, storage_path)
|
||||||
PRIMARY KEY (storage_path, state_path, header_id, block_number)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-- +goose Down
|
-- +goose Down
|
||||||
DROP TABLE eth.storage_cids;
|
DROP TABLE eth.storage_cids;
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
CREATE TABLE IF NOT EXISTS eth.state_accounts (
|
|
||||||
block_number BIGINT NOT NULL,
|
|
||||||
header_id VARCHAR(66) NOT NULL,
|
|
||||||
state_path BYTEA NOT NULL,
|
|
||||||
balance NUMERIC NOT NULL,
|
|
||||||
nonce BIGINT NOT NULL,
|
|
||||||
code_hash BYTEA NOT NULL,
|
|
||||||
storage_root VARCHAR(66) NOT NULL,
|
|
||||||
PRIMARY KEY (state_path, header_id, block_number)
|
|
||||||
);
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
DROP TABLE eth.state_accounts;
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
-- +goose Up
|
||||||
|
CREATE TABLE eth.state_accounts (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
state_id BIGINT NOT NULL REFERENCES eth.state_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
|
balance NUMERIC NOT NULL,
|
||||||
|
nonce INTEGER NOT NULL,
|
||||||
|
code_hash BYTEA NOT NULL,
|
||||||
|
storage_root VARCHAR(66) NOT NULL,
|
||||||
|
UNIQUE (state_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP TABLE eth.state_accounts;
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
CREATE TABLE IF NOT EXISTS eth.access_list_elements (
|
|
||||||
block_number BIGINT NOT NULL,
|
|
||||||
tx_id VARCHAR(66) NOT NULL,
|
|
||||||
index INTEGER NOT NULL,
|
|
||||||
address VARCHAR(66),
|
|
||||||
storage_keys VARCHAR(66)[],
|
|
||||||
PRIMARY KEY (tx_id, index, block_number)
|
|
||||||
);
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
DROP TABLE eth.access_list_elements;
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
CREATE TABLE IF NOT EXISTS eth.log_cids (
|
|
||||||
block_number BIGINT NOT NULL,
|
|
||||||
leaf_cid TEXT NOT NULL,
|
|
||||||
leaf_mh_key TEXT NOT NULL,
|
|
||||||
rct_id VARCHAR(66) NOT NULL,
|
|
||||||
address VARCHAR(66) NOT NULL,
|
|
||||||
index INTEGER NOT NULL,
|
|
||||||
topic0 VARCHAR(66),
|
|
||||||
topic1 VARCHAR(66),
|
|
||||||
topic2 VARCHAR(66),
|
|
||||||
topic3 VARCHAR(66),
|
|
||||||
log_data BYTEA,
|
|
||||||
PRIMARY KEY (rct_id, index, block_number)
|
|
||||||
);
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
-- log indexes
|
|
||||||
DROP TABLE eth.log_cids;
|
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- +goose StatementBegin
|
||||||
|
CREATE FUNCTION eth.graphql_subscription() returns TRIGGER as $$
|
||||||
|
declare
|
||||||
|
table_name text = TG_ARGV[0];
|
||||||
|
attribute text = TG_ARGV[1];
|
||||||
|
id text;
|
||||||
|
begin
|
||||||
|
execute 'select $1.' || quote_ident(attribute)
|
||||||
|
using new
|
||||||
|
into id;
|
||||||
|
perform pg_notify('postgraphile:' || table_name,
|
||||||
|
json_build_object(
|
||||||
|
'__node__', json_build_array(
|
||||||
|
table_name,
|
||||||
|
id
|
||||||
|
)
|
||||||
|
)::text
|
||||||
|
);
|
||||||
|
return new;
|
||||||
|
end;
|
||||||
|
$$ language plpgsql;
|
||||||
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
CREATE TRIGGER header_cids_ai
|
||||||
|
after INSERT ON eth.header_cids
|
||||||
|
for each row
|
||||||
|
execute procedure eth.graphql_subscription('header_cids', 'id');
|
||||||
|
|
||||||
|
CREATE TRIGGER receipt_cids_ai
|
||||||
|
after INSERT ON eth.receipt_cids
|
||||||
|
for each row
|
||||||
|
execute procedure eth.graphql_subscription('receipt_cids', 'id');
|
||||||
|
|
||||||
|
CREATE TRIGGER state_accounts_ai
|
||||||
|
after INSERT ON eth.state_accounts
|
||||||
|
for each row
|
||||||
|
execute procedure eth.graphql_subscription('state_accounts', 'id');
|
||||||
|
|
||||||
|
CREATE TRIGGER state_cids_ai
|
||||||
|
after INSERT ON eth.state_cids
|
||||||
|
for each row
|
||||||
|
execute procedure eth.graphql_subscription('state_cids', 'id');
|
||||||
|
|
||||||
|
CREATE TRIGGER storage_cids_ai
|
||||||
|
after INSERT ON eth.storage_cids
|
||||||
|
for each row
|
||||||
|
execute procedure eth.graphql_subscription('storage_cids', 'id');
|
||||||
|
|
||||||
|
CREATE TRIGGER transaction_cids_ai
|
||||||
|
after INSERT ON eth.transaction_cids
|
||||||
|
for each row
|
||||||
|
execute procedure eth.graphql_subscription('transaction_cids', 'id');
|
||||||
|
|
||||||
|
CREATE TRIGGER uncle_cids_ai
|
||||||
|
after INSERT ON eth.uncle_cids
|
||||||
|
for each row
|
||||||
|
execute procedure eth.graphql_subscription('uncle_cids', 'id');
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP TRIGGER uncle_cids_ai ON eth.uncle_cids;
|
||||||
|
DROP TRIGGER transaction_cids_ai ON eth.transaction_cids;
|
||||||
|
DROP TRIGGER storage_cids_ai ON eth.storage_cids;
|
||||||
|
DROP TRIGGER state_cids_ai ON eth.state_cids;
|
||||||
|
DROP TRIGGER state_accounts_ai ON eth.state_accounts;
|
||||||
|
DROP TRIGGER receipt_cids_ai ON eth.receipt_cids;
|
||||||
|
DROP TRIGGER header_cids_ai ON eth.header_cids;
|
||||||
|
|
||||||
|
DROP FUNCTION eth.graphql_subscription();
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- header indexes
|
||||||
|
CREATE INDEX block_number_index ON eth.header_cids USING brin (block_number);
|
||||||
|
|
||||||
|
CREATE INDEX block_hash_index ON eth.header_cids USING btree (block_hash);
|
||||||
|
|
||||||
|
CREATE INDEX header_cid_index ON eth.header_cids USING btree (cid);
|
||||||
|
|
||||||
|
CREATE INDEX header_mh_index ON eth.header_cids USING btree (mh_key);
|
||||||
|
|
||||||
|
CREATE INDEX state_root_index ON eth.header_cids USING btree (state_root);
|
||||||
|
|
||||||
|
CREATE INDEX timestamp_index ON eth.header_cids USING brin (timestamp);
|
||||||
|
|
||||||
|
-- transaction indexes
|
||||||
|
CREATE INDEX tx_header_id_index ON eth.transaction_cids USING btree (header_id);
|
||||||
|
|
||||||
|
CREATE INDEX tx_hash_index ON eth.transaction_cids USING btree (tx_hash);
|
||||||
|
|
||||||
|
CREATE INDEX tx_cid_index ON eth.transaction_cids USING btree (cid);
|
||||||
|
|
||||||
|
CREATE INDEX tx_mh_index ON eth.transaction_cids USING btree (mh_key);
|
||||||
|
|
||||||
|
CREATE INDEX tx_dst_index ON eth.transaction_cids USING btree (dst);
|
||||||
|
|
||||||
|
CREATE INDEX tx_src_index ON eth.transaction_cids USING btree (src);
|
||||||
|
|
||||||
|
-- receipt indexes
|
||||||
|
CREATE INDEX rct_tx_id_index ON eth.receipt_cids USING btree (tx_id);
|
||||||
|
|
||||||
|
CREATE INDEX rct_leaf_cid_index ON eth.receipt_cids USING btree (leaf_cid);
|
||||||
|
|
||||||
|
CREATE INDEX rct_leaf_mh_index ON eth.receipt_cids USING btree (leaf_mh_key);
|
||||||
|
|
||||||
|
CREATE INDEX rct_contract_index ON eth.receipt_cids USING btree (contract);
|
||||||
|
|
||||||
|
CREATE INDEX rct_contract_hash_index ON eth.receipt_cids USING btree (contract_hash);
|
||||||
|
|
||||||
|
-- state node indexes
|
||||||
|
CREATE INDEX state_header_id_index ON eth.state_cids USING btree (header_id);
|
||||||
|
|
||||||
|
CREATE INDEX state_leaf_key_index ON eth.state_cids USING btree (state_leaf_key);
|
||||||
|
|
||||||
|
CREATE INDEX state_cid_index ON eth.state_cids USING btree (cid);
|
||||||
|
|
||||||
|
CREATE INDEX state_mh_index ON eth.state_cids USING btree (mh_key);
|
||||||
|
|
||||||
|
CREATE INDEX state_path_index ON eth.state_cids USING btree (state_path);
|
||||||
|
|
||||||
|
CREATE INDEX state_node_type_index ON eth.state_cids USING btree (node_type);
|
||||||
|
|
||||||
|
-- storage node indexes
|
||||||
|
CREATE INDEX storage_state_id_index ON eth.storage_cids USING btree (state_id);
|
||||||
|
|
||||||
|
CREATE INDEX storage_leaf_key_index ON eth.storage_cids USING btree (storage_leaf_key);
|
||||||
|
|
||||||
|
CREATE INDEX storage_cid_index ON eth.storage_cids USING btree (cid);
|
||||||
|
|
||||||
|
CREATE INDEX storage_mh_index ON eth.storage_cids USING btree (mh_key);
|
||||||
|
|
||||||
|
CREATE INDEX storage_path_index ON eth.storage_cids USING btree (storage_path);
|
||||||
|
|
||||||
|
CREATE INDEX storage_node_type_index ON eth.storage_cids USING btree (node_type);
|
||||||
|
|
||||||
|
-- state accounts indexes
|
||||||
|
CREATE INDEX account_state_id_index ON eth.state_accounts USING btree (state_id);
|
||||||
|
|
||||||
|
CREATE INDEX storage_root_index ON eth.state_accounts USING btree (storage_root);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
-- state account indexes
|
||||||
|
DROP INDEX eth.storage_root_index;
|
||||||
|
DROP INDEX eth.account_state_id_index;
|
||||||
|
|
||||||
|
-- storage node indexes
|
||||||
|
DROP INDEX eth.storage_node_type_index;
|
||||||
|
DROP INDEX eth.storage_path_index;
|
||||||
|
DROP INDEX eth.storage_mh_index;
|
||||||
|
DROP INDEX eth.storage_cid_index;
|
||||||
|
DROP INDEX eth.storage_leaf_key_index;
|
||||||
|
DROP INDEX eth.storage_state_id_index;
|
||||||
|
|
||||||
|
-- state node indexes
|
||||||
|
DROP INDEX eth.state_node_type_index;
|
||||||
|
DROP INDEX eth.state_path_index;
|
||||||
|
DROP INDEX eth.state_mh_index;
|
||||||
|
DROP INDEX eth.state_cid_index;
|
||||||
|
DROP INDEX eth.state_leaf_key_index;
|
||||||
|
DROP INDEX eth.state_header_id_index;
|
||||||
|
|
||||||
|
-- receipt indexes
|
||||||
|
DROP INDEX eth.rct_contract_hash_index;
|
||||||
|
DROP INDEX eth.rct_contract_index;
|
||||||
|
DROP INDEX eth.rct_leaf_mh_index;
|
||||||
|
DROP INDEX eth.rct_leaf_cid_index;
|
||||||
|
DROP INDEX eth.rct_tx_id_index;
|
||||||
|
|
||||||
|
-- transaction indexes
|
||||||
|
DROP INDEX eth.tx_src_index;
|
||||||
|
DROP INDEX eth.tx_dst_index;
|
||||||
|
DROP INDEX eth.tx_mh_index;
|
||||||
|
DROP INDEX eth.tx_cid_index;
|
||||||
|
DROP INDEX eth.tx_hash_index;
|
||||||
|
DROP INDEX eth.tx_header_id_index;
|
||||||
|
|
||||||
|
-- header indexes
|
||||||
|
DROP INDEX eth.timestamp_index;
|
||||||
|
DROP INDEX eth.state_root_index;
|
||||||
|
DROP INDEX eth.header_mh_index;
|
||||||
|
DROP INDEX eth.header_cid_index;
|
||||||
|
DROP INDEX eth.block_hash_index;
|
||||||
|
DROP INDEX eth.block_number_index;
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
-- header indexes
|
|
||||||
CREATE INDEX header_block_number_index ON eth.header_cids USING brin (block_number);
|
|
||||||
CREATE UNIQUE INDEX header_cid_index ON eth.header_cids USING btree (cid, block_number);
|
|
||||||
CREATE UNIQUE INDEX header_mh_block_number_index ON eth.header_cids USING btree (mh_key, block_number);
|
|
||||||
CREATE INDEX state_root_index ON eth.header_cids USING btree (state_root);
|
|
||||||
CREATE INDEX timestamp_index ON eth.header_cids USING brin (timestamp);
|
|
||||||
|
|
||||||
-- uncle indexes
|
|
||||||
CREATE INDEX uncle_block_number_index ON eth.uncle_cids USING brin (block_number);
|
|
||||||
CREATE UNIQUE INDEX uncle_mh_block_number_index ON eth.uncle_cids USING btree (mh_key, block_number);
|
|
||||||
CREATE INDEX uncle_header_id_index ON eth.uncle_cids USING btree (header_id);
|
|
||||||
|
|
||||||
-- transaction indexes
|
|
||||||
CREATE INDEX tx_block_number_index ON eth.transaction_cids USING brin (block_number);
|
|
||||||
CREATE INDEX tx_header_id_index ON eth.transaction_cids USING btree (header_id);
|
|
||||||
CREATE UNIQUE INDEX tx_cid_index ON eth.transaction_cids USING btree (cid, block_number);
|
|
||||||
CREATE UNIQUE INDEX tx_mh_block_number_index ON eth.transaction_cids USING btree (mh_key, block_number);
|
|
||||||
CREATE INDEX tx_dst_index ON eth.transaction_cids USING btree (dst);
|
|
||||||
CREATE INDEX tx_src_index ON eth.transaction_cids USING btree (src);
|
|
||||||
|
|
||||||
-- receipt indexes
|
|
||||||
CREATE INDEX rct_block_number_index ON eth.receipt_cids USING brin (block_number);
|
|
||||||
CREATE INDEX rct_leaf_cid_index ON eth.receipt_cids USING btree (leaf_cid);
|
|
||||||
CREATE INDEX rct_leaf_mh_block_number_index ON eth.receipt_cids USING btree (leaf_mh_key, block_number);
|
|
||||||
CREATE INDEX rct_contract_index ON eth.receipt_cids USING btree (contract);
|
|
||||||
CREATE INDEX rct_contract_hash_index ON eth.receipt_cids USING btree (contract_hash);
|
|
||||||
|
|
||||||
-- state node indexes
|
|
||||||
CREATE INDEX state_block_number_index ON eth.state_cids USING brin (block_number);
|
|
||||||
CREATE INDEX state_leaf_key_index ON eth.state_cids USING btree (state_leaf_key);
|
|
||||||
CREATE INDEX state_cid_index ON eth.state_cids USING btree (cid);
|
|
||||||
CREATE INDEX state_mh_block_number_index ON eth.state_cids USING btree (mh_key, block_number);
|
|
||||||
CREATE INDEX state_header_id_index ON eth.state_cids USING btree (header_id);
|
|
||||||
CREATE INDEX state_node_type_index ON eth.state_cids USING btree (node_type);
|
|
||||||
|
|
||||||
-- storage node indexes
|
|
||||||
CREATE INDEX storage_block_number_index ON eth.storage_cids USING brin (block_number);
|
|
||||||
CREATE INDEX storage_state_path_index ON eth.storage_cids USING btree (state_path);
|
|
||||||
CREATE INDEX storage_leaf_key_index ON eth.storage_cids USING btree (storage_leaf_key);
|
|
||||||
CREATE INDEX storage_cid_index ON eth.storage_cids USING btree (cid);
|
|
||||||
CREATE INDEX storage_mh_block_number_index ON eth.storage_cids USING btree (mh_key, block_number);
|
|
||||||
CREATE INDEX storage_header_id_index ON eth.storage_cids USING btree (header_id);
|
|
||||||
CREATE INDEX storage_node_type_index ON eth.storage_cids USING btree (node_type);
|
|
||||||
|
|
||||||
-- state accounts indexes
|
|
||||||
CREATE INDEX account_block_number_index ON eth.state_accounts USING brin (block_number);
|
|
||||||
CREATE INDEX account_header_id_index ON eth.state_accounts USING btree (header_id);
|
|
||||||
CREATE INDEX account_storage_root_index ON eth.state_accounts USING btree (storage_root);
|
|
||||||
|
|
||||||
-- access list indexes
|
|
||||||
CREATE INDEX access_list_block_number_index ON eth.access_list_elements USING brin (block_number);
|
|
||||||
CREATE INDEX access_list_element_address_index ON eth.access_list_elements USING btree (address);
|
|
||||||
CREATE INDEX access_list_storage_keys_index ON eth.access_list_elements USING gin (storage_keys);
|
|
||||||
|
|
||||||
-- log indexes
|
|
||||||
CREATE INDEX log_block_number_index ON eth.log_cids USING brin (block_number);
|
|
||||||
CREATE INDEX log_leaf_mh_block_number_index ON eth.log_cids USING btree (leaf_mh_key, block_number);
|
|
||||||
CREATE INDEX log_cid_index ON eth.log_cids USING btree (leaf_cid);
|
|
||||||
CREATE INDEX log_address_index ON eth.log_cids USING btree (address);
|
|
||||||
CREATE INDEX log_topic0_index ON eth.log_cids USING btree (topic0);
|
|
||||||
CREATE INDEX log_topic1_index ON eth.log_cids USING btree (topic1);
|
|
||||||
CREATE INDEX log_topic2_index ON eth.log_cids USING btree (topic2);
|
|
||||||
CREATE INDEX log_topic3_index ON eth.log_cids USING btree (topic3);
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
-- log indexes
|
|
||||||
DROP INDEX eth.log_topic3_index;
|
|
||||||
DROP INDEX eth.log_topic2_index;
|
|
||||||
DROP INDEX eth.log_topic1_index;
|
|
||||||
DROP INDEX eth.log_topic0_index;
|
|
||||||
DROP INDEX eth.log_address_index;
|
|
||||||
DROP INDEX eth.log_cid_index;
|
|
||||||
DROP INDEX eth.log_leaf_mh_block_number_index;
|
|
||||||
DROP INDEX eth.log_block_number_index;
|
|
||||||
|
|
||||||
-- access list indexes
|
|
||||||
DROP INDEX eth.access_list_storage_keys_index;
|
|
||||||
DROP INDEX eth.access_list_element_address_index;
|
|
||||||
DROP INDEX eth.access_list_block_number_index;
|
|
||||||
|
|
||||||
-- state account indexes
|
|
||||||
DROP INDEX eth.account_storage_root_index;
|
|
||||||
DROP index eth.account_header_id_index;
|
|
||||||
DROP INDEX eth.account_block_number_index;
|
|
||||||
|
|
||||||
-- storage node indexes
|
|
||||||
DROP INDEX eth.storage_node_type_index;
|
|
||||||
DROP INDEX eth.storage_header_id_index;
|
|
||||||
DROP INDEX eth.storage_mh_block_number_index;
|
|
||||||
DROP INDEX eth.storage_cid_index;
|
|
||||||
DROP INDEX eth.storage_leaf_key_index;
|
|
||||||
DROP INDEX eth.storage_state_path_index;
|
|
||||||
DROP INDEX eth.storage_block_number_index;
|
|
||||||
|
|
||||||
-- state node indexes
|
|
||||||
DROP INDEX eth.state_node_type_index;
|
|
||||||
DROP INDEX eth.state_header_id_index;
|
|
||||||
DROP INDEX eth.state_mh_block_number_index;
|
|
||||||
DROP INDEX eth.state_cid_index;
|
|
||||||
DROP INDEX eth.state_leaf_key_index;
|
|
||||||
DROP INDEX eth.state_block_number_index;
|
|
||||||
|
|
||||||
-- receipt indexes
|
|
||||||
DROP INDEX eth.rct_contract_hash_index;
|
|
||||||
DROP INDEX eth.rct_contract_index;
|
|
||||||
DROP INDEX eth.rct_leaf_mh_block_number_index;
|
|
||||||
DROP INDEX eth.rct_leaf_cid_index;
|
|
||||||
DROP INDEX eth.rct_block_number_index;
|
|
||||||
|
|
||||||
-- transaction indexes
|
|
||||||
DROP INDEX eth.tx_src_index;
|
|
||||||
DROP INDEX eth.tx_dst_index;
|
|
||||||
DROP INDEX eth.tx_mh_block_number_index;
|
|
||||||
DROP INDEX eth.tx_cid_index;
|
|
||||||
DROP INDEX eth.tx_header_id_index;
|
|
||||||
DROP INDEX eth.tx_block_number_index;
|
|
||||||
|
|
||||||
-- uncle indexes
|
|
||||||
DROP INDEX eth.uncle_block_number_index;
|
|
||||||
DROP INDEX eth.uncle_mh_block_number_index;
|
|
||||||
DROP INDEX eth.uncle_header_id_index;
|
|
||||||
|
|
||||||
-- header indexes
|
|
||||||
DROP INDEX eth.timestamp_index;
|
|
||||||
DROP INDEX eth.state_root_index;
|
|
||||||
DROP INDEX eth.header_mh_block_number_index;
|
|
||||||
DROP INDEX eth.header_cid_index;
|
|
||||||
DROP INDEX eth.header_block_number_index;
|
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- +goose StatementBegin
|
||||||
|
-- returns if a state leaf node was removed within the provided block number
|
||||||
|
CREATE OR REPLACE FUNCTION was_state_leaf_removed(key character varying, hash character varying)
|
||||||
|
RETURNS boolean AS $$
|
||||||
|
SELECT state_cids.node_type = 3
|
||||||
|
FROM eth.state_cids
|
||||||
|
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id)
|
||||||
|
WHERE state_leaf_key = key
|
||||||
|
AND block_number <= (SELECT block_number
|
||||||
|
FROM eth.header_cids
|
||||||
|
WHERE block_hash = hash)
|
||||||
|
ORDER BY block_number DESC LIMIT 1;
|
||||||
|
$$
|
||||||
|
language sql;
|
||||||
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
-- +goose StatementBegin
|
||||||
|
CREATE TYPE child_result AS (
|
||||||
|
has_child BOOLEAN,
|
||||||
|
children eth.header_cids[]
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION has_child(hash VARCHAR(66), height BIGINT) RETURNS child_result AS
|
||||||
|
$BODY$
|
||||||
|
DECLARE
|
||||||
|
child_height INT;
|
||||||
|
temp_child eth.header_cids;
|
||||||
|
new_child_result child_result;
|
||||||
|
BEGIN
|
||||||
|
child_height = height + 1;
|
||||||
|
-- short circuit if there are no children
|
||||||
|
SELECT exists(SELECT 1
|
||||||
|
FROM eth.header_cids
|
||||||
|
WHERE parent_hash = hash
|
||||||
|
AND block_number = child_height
|
||||||
|
LIMIT 1)
|
||||||
|
INTO new_child_result.has_child;
|
||||||
|
-- collect all the children for this header
|
||||||
|
IF new_child_result.has_child THEN
|
||||||
|
FOR temp_child IN
|
||||||
|
SELECT * FROM eth.header_cids WHERE parent_hash = hash AND block_number = child_height
|
||||||
|
LOOP
|
||||||
|
new_child_result.children = array_append(new_child_result.children, temp_child);
|
||||||
|
END LOOP;
|
||||||
|
END IF;
|
||||||
|
RETURN new_child_result;
|
||||||
|
END
|
||||||
|
$BODY$
|
||||||
|
LANGUAGE 'plpgsql';
|
||||||
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
-- +goose StatementBegin
|
||||||
|
CREATE OR REPLACE FUNCTION canonical_header_from_array(headers eth.header_cids[]) RETURNS eth.header_cids AS
|
||||||
|
$BODY$
|
||||||
|
DECLARE
|
||||||
|
canonical_header eth.header_cids;
|
||||||
|
canonical_child eth.header_cids;
|
||||||
|
header eth.header_cids;
|
||||||
|
current_child_result child_result;
|
||||||
|
child_headers eth.header_cids[];
|
||||||
|
current_header_with_child eth.header_cids;
|
||||||
|
has_children_count INT DEFAULT 0;
|
||||||
|
BEGIN
|
||||||
|
-- for each header in the provided set
|
||||||
|
FOREACH header IN ARRAY headers
|
||||||
|
LOOP
|
||||||
|
-- check if it has any children
|
||||||
|
current_child_result = has_child(header.block_hash, header.block_number);
|
||||||
|
IF current_child_result.has_child THEN
|
||||||
|
-- if it does, take note
|
||||||
|
has_children_count = has_children_count + 1;
|
||||||
|
current_header_with_child = header;
|
||||||
|
-- and add the children to the growing set of child headers
|
||||||
|
child_headers = array_cat(child_headers, current_child_result.children);
|
||||||
|
END IF;
|
||||||
|
END LOOP;
|
||||||
|
-- if none of the headers had children, none is more canonical than the other
|
||||||
|
IF has_children_count = 0 THEN
|
||||||
|
-- return the first one selected
|
||||||
|
SELECT * INTO canonical_header FROM unnest(headers) LIMIT 1;
|
||||||
|
-- if only one header had children, it can be considered the heaviest/canonical header of the set
|
||||||
|
ELSIF has_children_count = 1 THEN
|
||||||
|
-- return the only header with a child
|
||||||
|
canonical_header = current_header_with_child;
|
||||||
|
-- if there are multiple headers with children
|
||||||
|
ELSE
|
||||||
|
-- find the canonical header from the child set
|
||||||
|
canonical_child = canonical_header_from_array(child_headers);
|
||||||
|
-- the header that is parent to this header, is the canonical header at this level
|
||||||
|
SELECT * INTO canonical_header FROM unnest(headers)
|
||||||
|
WHERE block_hash = canonical_child.parent_hash;
|
||||||
|
END IF;
|
||||||
|
RETURN canonical_header;
|
||||||
|
END
|
||||||
|
$BODY$
|
||||||
|
LANGUAGE 'plpgsql';
|
||||||
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
-- +goose StatementBegin
|
||||||
|
CREATE OR REPLACE FUNCTION canonical_header_id(height BIGINT) RETURNS INTEGER AS
|
||||||
|
$BODY$
|
||||||
|
DECLARE
|
||||||
|
canonical_header eth.header_cids;
|
||||||
|
headers eth.header_cids[];
|
||||||
|
header_count INT;
|
||||||
|
temp_header eth.header_cids;
|
||||||
|
BEGIN
|
||||||
|
-- collect all headers at this height
|
||||||
|
FOR temp_header IN
|
||||||
|
SELECT * FROM eth.header_cids WHERE block_number = height
|
||||||
|
LOOP
|
||||||
|
headers = array_append(headers, temp_header);
|
||||||
|
END LOOP;
|
||||||
|
-- count the number of headers collected
|
||||||
|
header_count = array_length(headers, 1);
|
||||||
|
-- if we have less than 1 header, return NULL
|
||||||
|
IF header_count IS NULL OR header_count < 1 THEN
|
||||||
|
RETURN NULL;
|
||||||
|
-- if we have one header, return its id
|
||||||
|
ELSIF header_count = 1 THEN
|
||||||
|
RETURN headers[1].id;
|
||||||
|
-- if we have multiple headers we need to determine which one is canonical
|
||||||
|
ELSE
|
||||||
|
canonical_header = canonical_header_from_array(headers);
|
||||||
|
RETURN canonical_header.id;
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$BODY$
|
||||||
|
LANGUAGE 'plpgsql';
|
||||||
|
-- +goose StatementEnd
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP FUNCTION was_state_leaf_removed;
|
||||||
|
DROP FUNCTION canonical_header_id;
|
||||||
|
DROP FUNCTION canonical_header_from_array;
|
||||||
|
DROP FUNCTION has_child;
|
||||||
|
DROP TYPE child_result;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
-- +goose Up
|
||||||
|
CREATE TABLE eth.access_list_element (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
tx_id INTEGER NOT NULL REFERENCES eth.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
|
index INTEGER NOT NULL,
|
||||||
|
address VARCHAR(66),
|
||||||
|
storage_keys VARCHAR(66)[],
|
||||||
|
UNIQUE (tx_id, index)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX accesss_list_element_address_index ON eth.access_list_element USING btree (address);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP INDEX eth.accesss_list_element_address_index;
|
||||||
|
DROP TABLE eth.access_list_element;
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
-- Name: graphql_subscription(); Type: FUNCTION; Schema: eth; Owner: -
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
CREATE FUNCTION eth.graphql_subscription() RETURNS TRIGGER AS $$
|
|
||||||
DECLARE
|
|
||||||
obj jsonb;
|
|
||||||
BEGIN
|
|
||||||
IF (TG_TABLE_NAME = 'state_cids') OR (TG_TABLE_NAME = 'state_accounts') THEN
|
|
||||||
obj := json_build_array(
|
|
||||||
TG_TABLE_NAME,
|
|
||||||
NEW.header_id,
|
|
||||||
NEW.state_path
|
|
||||||
);
|
|
||||||
ELSIF (TG_TABLE_NAME = 'storage_cids') THEN
|
|
||||||
obj := json_build_array(
|
|
||||||
TG_TABLE_NAME,
|
|
||||||
NEW.header_id,
|
|
||||||
NEW.state_path,
|
|
||||||
NEW.storage_path
|
|
||||||
);
|
|
||||||
ELSIF (TG_TABLE_NAME = 'log_cids') THEN
|
|
||||||
obj := json_build_array(
|
|
||||||
TG_TABLE_NAME,
|
|
||||||
NEW.rct_id,
|
|
||||||
NEW.index
|
|
||||||
);
|
|
||||||
ELSIF (TG_TABLE_NAME = 'receipt_cids') THEN
|
|
||||||
obj := json_build_array(
|
|
||||||
TG_TABLE_NAME,
|
|
||||||
NEW.tx_id
|
|
||||||
);
|
|
||||||
ELSIF (TG_TABLE_NAME = 'transaction_cids') THEN
|
|
||||||
obj := json_build_array(
|
|
||||||
TG_TABLE_NAME,
|
|
||||||
NEW.tx_hash
|
|
||||||
);
|
|
||||||
ELSIF (TG_TABLE_NAME = 'access_list_elements') THEN
|
|
||||||
obj := json_build_array(
|
|
||||||
TG_TABLE_NAME,
|
|
||||||
NEW.tx_id,
|
|
||||||
NEW.index
|
|
||||||
);
|
|
||||||
ELSIF (TG_TABLE_NAME = 'uncle_cids') OR (TG_TABLE_NAME = 'header_cids') THEN
|
|
||||||
obj := json_build_array(
|
|
||||||
TG_TABLE_NAME,
|
|
||||||
NEW.block_hash
|
|
||||||
);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
perform pg_notify('postgraphile:' || TG_RELNAME , json_build_object(
|
|
||||||
'__node__', obj
|
|
||||||
)::text
|
|
||||||
);
|
|
||||||
RETURN NEW;
|
|
||||||
END;
|
|
||||||
$$ language plpgsql;
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_header_cids
|
|
||||||
AFTER INSERT ON eth.header_cids
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_uncle_cids
|
|
||||||
AFTER INSERT ON eth.uncle_cids
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_transaction_cids
|
|
||||||
AFTER INSERT ON eth.transaction_cids
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_receipt_cids
|
|
||||||
AFTER INSERT ON eth.receipt_cids
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_state_cids
|
|
||||||
AFTER INSERT ON eth.state_cids
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_log_cids
|
|
||||||
AFTER INSERT ON eth.log_cids
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_storage_cids
|
|
||||||
AFTER INSERT ON eth.storage_cids
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_state_accounts
|
|
||||||
AFTER INSERT ON eth.state_accounts
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
CREATE TRIGGER trg_eth_access_list_elements
|
|
||||||
AFTER INSERT ON eth.access_list_elements
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE PROCEDURE eth.graphql_subscription();
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
DROP TRIGGER trg_eth_uncle_cids ON eth.uncle_cids;
|
|
||||||
DROP TRIGGER trg_eth_transaction_cids ON eth.transaction_cids;
|
|
||||||
DROP TRIGGER trg_eth_storage_cids ON eth.storage_cids;
|
|
||||||
DROP TRIGGER trg_eth_state_cids ON eth.state_cids;
|
|
||||||
DROP TRIGGER trg_eth_state_accounts ON eth.state_accounts;
|
|
||||||
DROP TRIGGER trg_eth_receipt_cids ON eth.receipt_cids;
|
|
||||||
DROP TRIGGER trg_eth_header_cids ON eth.header_cids;
|
|
||||||
DROP TRIGGER trg_eth_log_cids ON eth.log_cids;
|
|
||||||
DROP TRIGGER trg_eth_access_list_elements ON eth.access_list_elements;
|
|
||||||
|
|
||||||
DROP FUNCTION eth.graphql_subscription();
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
CREATE TABLE IF NOT EXISTS public.db_version (
|
|
||||||
singleton BOOLEAN NOT NULL DEFAULT TRUE UNIQUE CHECK (singleton),
|
|
||||||
version TEXT NOT NULL,
|
|
||||||
tstamp TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW()
|
|
||||||
);
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
DROP TABLE public.db_version;
|
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
-- +goose Up
|
||||||
|
CREATE TABLE eth.log_cids (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
leaf_cid TEXT NOT NULL,
|
||||||
|
leaf_mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
|
receipt_id INTEGER NOT NULL REFERENCES eth.receipt_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||||
|
address VARCHAR(66) NOT NULL,
|
||||||
|
log_data BYTEA,
|
||||||
|
index INTEGER NOT NULL,
|
||||||
|
topic0 VARCHAR(66),
|
||||||
|
topic1 VARCHAR(66),
|
||||||
|
topic2 VARCHAR(66),
|
||||||
|
topic3 VARCHAR(66),
|
||||||
|
UNIQUE (receipt_id, index)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX log_mh_index ON eth.log_cids USING btree (leaf_mh_key);
|
||||||
|
|
||||||
|
CREATE INDEX log_cid_index ON eth.log_cids USING btree (leaf_cid);
|
||||||
|
|
||||||
|
CREATE INDEX log_rct_id_index ON eth.log_cids USING btree (receipt_id);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_topic0_index; Type: INDEX; Schema: eth; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX log_topic0_index ON eth.log_cids USING btree (topic0);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_topic1_index; Type: INDEX; Schema: eth; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX log_topic1_index ON eth.log_cids USING btree (topic1);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_topic2_index; Type: INDEX; Schema: eth; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX log_topic2_index ON eth.log_cids USING btree (topic2);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: log_topic3_index; Type: INDEX; Schema: eth; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX log_topic3_index ON eth.log_cids USING btree (topic3);
|
||||||
|
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
-- log indexes
|
||||||
|
DROP INDEX eth.log_mh_index;
|
||||||
|
DROP INDEX eth.log_cid_index;
|
||||||
|
DROP INDEX eth.log_rct_id_index;
|
||||||
|
DROP INDEX eth.log_topic0_index;
|
||||||
|
DROP INDEX eth.log_topic1_index;
|
||||||
|
DROP INDEX eth.log_topic2_index;
|
||||||
|
DROP INDEX eth.log_topic3_index;
|
||||||
|
|
||||||
|
DROP TABLE eth.log_cids;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- +goose Up
|
||||||
|
CREATE SCHEMA eth_meta;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP SCHEMA eth_meta;
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
INSERT INTO public.db_version (singleton, version) VALUES (true, 'v4.0.0')
|
|
||||||
ON CONFLICT (singleton) DO UPDATE SET (version, tstamp) = ('v4.0.0', NOW());
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
DELETE FROM public.db_version WHERE version = 'v4.0.0';
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
-- +goose NO TRANSACTION
|
|
||||||
-- +goose Up
|
|
||||||
-- this is generated by a script
|
|
||||||
SELECT add_data_node('dn3', host => 'data-node-3', port => 5432, database => 'vulcanize_testing_v4', password => 'password');
|
|
||||||
SELECT add_data_node('dn2', host => 'data-node-2', port => 5432, database => 'vulcanize_testing_v4', password => 'password');
|
|
||||||
SELECT add_data_node('dn1', host => 'data-node-1', port => 5432, database => 'vulcanize_testing_v4', password => 'password');
|
|
||||||
|
|
||||||
CALL distributed_exec($$ CREATE SCHEMA eth $$);
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
-- this is generated by a script
|
|
||||||
CALL distributed_exec($$ DROP SCHEMA eth $$);
|
|
||||||
|
|
||||||
SELECT delete_data_node('dn1', force => true, if_attached => true);
|
|
||||||
SELECT delete_data_node('dn2', force => true, if_attached => true);
|
|
||||||
SELECT delete_data_node('dn3', force => true, if_attached => true);
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
-- +goose Up
|
||||||
|
CREATE TABLE eth_meta.watched_addresses (
|
||||||
|
address VARCHAR(66) PRIMARY KEY,
|
||||||
|
created_at BIGINT NOT NULL,
|
||||||
|
watched_at BIGINT NOT NULL,
|
||||||
|
last_filled_at BIGINT NOT NULL DEFAULT 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP TABLE eth_meta.watched_addresses;
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
-- creating distributed hypertables from duplicate tables for now as we are getting the following error (while running geth
|
|
||||||
-- unit tests) if regular tables are directly converted to distributed hypertables
|
|
||||||
-- error: "cannot PREPARE a transaction that has executed LISTEN, UNLISTEN, or NOTIFY"
|
|
||||||
|
|
||||||
-- create new regular tables
|
|
||||||
CREATE TABLE eth.log_cids_i (LIKE eth.log_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.access_list_elements_i (LIKE eth.access_list_elements INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.state_accounts_i (LIKE eth.state_accounts INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.storage_cids_i (LIKE eth.storage_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.state_cids_i (LIKE eth.state_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.receipt_cids_i (LIKE eth.receipt_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.transaction_cids_i (LIKE eth.transaction_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.uncle_cids_i (LIKE eth.uncle_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.header_cids_i (LIKE eth.header_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE public.blocks_i (LIKE public.blocks INCLUDING ALL);
|
|
||||||
|
|
||||||
-- turn them into distributed hypertables
|
|
||||||
SELECT create_distributed_hypertable('public.blocks_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.header_cids_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.uncle_cids_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.transaction_cids_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.receipt_cids_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.state_cids_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.storage_cids_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.state_accounts_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.access_list_elements_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
SELECT create_distributed_hypertable('eth.log_cids_i', 'block_number', chunk_time_interval => 32768);
|
|
||||||
|
|
||||||
-- migrate data
|
|
||||||
INSERT INTO eth.log_cids_i (SELECT * FROM eth.log_cids);
|
|
||||||
INSERT INTO eth.access_list_elements_i (SELECT * FROM eth.access_list_elements);
|
|
||||||
INSERT INTO eth.state_accounts_i (SELECT * FROM eth.state_accounts);
|
|
||||||
INSERT INTO eth.storage_cids_i (SELECT * FROM eth.storage_cids);
|
|
||||||
INSERT INTO eth.state_cids_i (SELECT * FROM eth.state_cids);
|
|
||||||
INSERT INTO eth.receipt_cids_i (SELECT * FROM eth.receipt_cids);
|
|
||||||
INSERT INTO eth.transaction_cids_i (SELECT * FROM eth.transaction_cids);
|
|
||||||
INSERT INTO eth.uncle_cids_i (SELECT * FROM eth.uncle_cids);
|
|
||||||
INSERT INTO eth.header_cids_i (SELECT * FROM eth.header_cids);
|
|
||||||
INSERT INTO public.blocks_i (SELECT * FROM public.blocks);
|
|
||||||
|
|
||||||
-- drop tables
|
|
||||||
DROP TABLE eth.log_cids;
|
|
||||||
DROP TABLE eth.access_list_elements;
|
|
||||||
DROP TABLE eth.state_accounts;
|
|
||||||
DROP TABLE eth.storage_cids;
|
|
||||||
DROP TABLE eth.state_cids;
|
|
||||||
DROP TABLE eth.receipt_cids;
|
|
||||||
DROP TABLE eth.transaction_cids;
|
|
||||||
DROP TABLE eth.uncle_cids;
|
|
||||||
DROP TABLE eth.header_cids;
|
|
||||||
DROP TABLE public.blocks;
|
|
||||||
|
|
||||||
-- rename distributed hypertables
|
|
||||||
ALTER TABLE eth.log_cids_i RENAME TO log_cids;
|
|
||||||
ALTER TABLE eth.access_list_elements_i RENAME TO access_list_elements;
|
|
||||||
ALTER TABLE eth.state_accounts_i RENAME TO state_accounts;
|
|
||||||
ALTER TABLE eth.storage_cids_i RENAME TO storage_cids;
|
|
||||||
ALTER TABLE eth.state_cids_i RENAME TO state_cids;
|
|
||||||
ALTER TABLE eth.receipt_cids_i RENAME TO receipt_cids;
|
|
||||||
ALTER TABLE eth.transaction_cids_i RENAME TO transaction_cids;
|
|
||||||
ALTER TABLE eth.uncle_cids_i RENAME TO uncle_cids;
|
|
||||||
ALTER TABLE eth.header_cids_i RENAME TO header_cids;
|
|
||||||
ALTER TABLE public.blocks_i RENAME TO blocks;
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.log_cids_i RENAME TO log_cids');
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.access_list_elements_i RENAME TO access_list_elements');
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.state_accounts_i RENAME TO state_accounts');
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.storage_cids_i RENAME TO storage_cids');
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.state_cids_i RENAME TO state_cids');
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.receipt_cids_i RENAME TO receipt_cids');
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.transaction_cids_i RENAME TO transaction_cids');
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.uncle_cids_i RENAME TO uncle_cids');
|
|
||||||
CALL distributed_exec('ALTER TABLE eth.header_cids_i RENAME TO header_cids');
|
|
||||||
CALL distributed_exec('ALTER TABLE public.blocks_i RENAME TO blocks');
|
|
||||||
|
|
||||||
-- update version
|
|
||||||
INSERT INTO public.db_version (singleton, version) VALUES (true, 'v4.0.00-dh')
|
|
||||||
ON CONFLICT (singleton) DO UPDATE SET (version, tstamp) = ('v4.0.0-dh', NOW());
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
INSERT INTO public.db_version (singleton, version) VALUES (true, 'v4.0.0')
|
|
||||||
ON CONFLICT (singleton) DO UPDATE SET (version, tstamp) = ('v4.0.0', NOW());
|
|
||||||
-- reversing conversion to hypertables requires migrating all data from every chunk back to a single table
|
|
||||||
-- create new regular tables
|
|
||||||
CREATE TABLE eth.log_cids_i (LIKE eth.log_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.access_list_elements_i (LIKE eth.access_list_elements INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.state_accounts_i (LIKE eth.state_accounts INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.storage_cids_i (LIKE eth.storage_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.state_cids_i (LIKE eth.state_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.receipt_cids_i (LIKE eth.receipt_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.transaction_cids_i (LIKE eth.transaction_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.uncle_cids_i (LIKE eth.uncle_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE eth.header_cids_i (LIKE eth.header_cids INCLUDING ALL);
|
|
||||||
CREATE TABLE public.blocks_i (LIKE public.blocks INCLUDING ALL);
|
|
||||||
|
|
||||||
-- migrate data
|
|
||||||
INSERT INTO eth.log_cids_i (SELECT * FROM eth.log_cids);
|
|
||||||
INSERT INTO eth.access_list_elements_i (SELECT * FROM eth.access_list_elements);
|
|
||||||
INSERT INTO eth.state_accounts_i (SELECT * FROM eth.state_accounts);
|
|
||||||
INSERT INTO eth.storage_cids_i (SELECT * FROM eth.storage_cids);
|
|
||||||
INSERT INTO eth.state_cids_i (SELECT * FROM eth.state_cids);
|
|
||||||
INSERT INTO eth.receipt_cids_i (SELECT * FROM eth.receipt_cids);
|
|
||||||
INSERT INTO eth.transaction_cids_i (SELECT * FROM eth.transaction_cids);
|
|
||||||
INSERT INTO eth.uncle_cids_i (SELECT * FROM eth.uncle_cids);
|
|
||||||
INSERT INTO eth.header_cids_i (SELECT * FROM eth.header_cids);
|
|
||||||
INSERT INTO public.blocks_i (SELECT * FROM public.blocks);
|
|
||||||
|
|
||||||
-- drop distributed hypertables
|
|
||||||
DROP TABLE eth.log_cids;
|
|
||||||
DROP TABLE eth.access_list_elements;
|
|
||||||
DROP TABLE eth.state_accounts;
|
|
||||||
DROP TABLE eth.storage_cids;
|
|
||||||
DROP TABLE eth.state_cids;
|
|
||||||
DROP TABLE eth.receipt_cids;
|
|
||||||
DROP TABLE eth.transaction_cids;
|
|
||||||
DROP TABLE eth.uncle_cids;
|
|
||||||
DROP TABLE eth.header_cids;
|
|
||||||
DROP TABLE public.blocks;
|
|
||||||
|
|
||||||
-- rename hypertable tables
|
|
||||||
ALTER TABLE eth.log_cids_i RENAME TO log_cids;
|
|
||||||
ALTER TABLE eth.access_list_elements_i RENAME TO access_list_elements;
|
|
||||||
ALTER TABLE eth.state_accounts_i RENAME TO state_accounts;
|
|
||||||
ALTER TABLE eth.storage_cids_i RENAME TO storage_cids;
|
|
||||||
ALTER TABLE eth.state_cids_i RENAME TO state_cids;
|
|
||||||
ALTER TABLE eth.receipt_cids_i RENAME TO receipt_cids;
|
|
||||||
ALTER TABLE eth.transaction_cids_i RENAME TO transaction_cids;
|
|
||||||
ALTER TABLE eth.uncle_cids_i RENAME TO uncle_cids;
|
|
||||||
ALTER TABLE eth.header_cids_i RENAME TO header_cids;
|
|
||||||
ALTER TABLE public.blocks_i RENAME TO blocks;
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
-- to be generated by a script
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
-- to be generated by a script
|
|
||||||
@@ -1,248 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
-- +goose StatementBegin
|
|
||||||
-- returns if a state leaf node was removed within the provided block number
|
|
||||||
CREATE OR REPLACE FUNCTION was_state_leaf_removed(key character varying, hash character varying)
|
|
||||||
RETURNS boolean AS $$
|
|
||||||
SELECT state_cids.node_type = 3
|
|
||||||
FROM eth.state_cids
|
|
||||||
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
|
|
||||||
WHERE state_leaf_key = key
|
|
||||||
AND state_cids.block_number <= (SELECT block_number
|
|
||||||
FROM eth.header_cids
|
|
||||||
WHERE block_hash = hash)
|
|
||||||
ORDER BY state_cids.block_number DESC LIMIT 1;
|
|
||||||
$$
|
|
||||||
language sql;
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
CREATE TYPE child_result AS (
|
|
||||||
has_child BOOLEAN,
|
|
||||||
children eth.header_cids[]
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION has_child(hash VARCHAR(66), height BIGINT) RETURNS child_result AS
|
|
||||||
$BODY$
|
|
||||||
DECLARE
|
|
||||||
child_height INT;
|
|
||||||
temp_child eth.header_cids;
|
|
||||||
new_child_result child_result;
|
|
||||||
BEGIN
|
|
||||||
child_height = height + 1;
|
|
||||||
-- short circuit if there are no children
|
|
||||||
SELECT exists(SELECT 1
|
|
||||||
FROM eth.header_cids
|
|
||||||
WHERE parent_hash = hash
|
|
||||||
AND block_number = child_height
|
|
||||||
LIMIT 1)
|
|
||||||
INTO new_child_result.has_child;
|
|
||||||
-- collect all the children for this header
|
|
||||||
IF new_child_result.has_child THEN
|
|
||||||
FOR temp_child IN
|
|
||||||
SELECT * FROM eth.header_cids WHERE parent_hash = hash AND block_number = child_height
|
|
||||||
LOOP
|
|
||||||
new_child_result.children = array_append(new_child_result.children, temp_child);
|
|
||||||
END LOOP;
|
|
||||||
END IF;
|
|
||||||
RETURN new_child_result;
|
|
||||||
END
|
|
||||||
$BODY$
|
|
||||||
LANGUAGE 'plpgsql';
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
CREATE OR REPLACE FUNCTION canonical_header_from_array(headers eth.header_cids[]) RETURNS eth.header_cids AS
|
|
||||||
$BODY$
|
|
||||||
DECLARE
|
|
||||||
canonical_header eth.header_cids;
|
|
||||||
canonical_child eth.header_cids;
|
|
||||||
header eth.header_cids;
|
|
||||||
current_child_result child_result;
|
|
||||||
child_headers eth.header_cids[];
|
|
||||||
current_header_with_child eth.header_cids;
|
|
||||||
has_children_count INT DEFAULT 0;
|
|
||||||
BEGIN
|
|
||||||
-- for each header in the provided set
|
|
||||||
FOREACH header IN ARRAY headers
|
|
||||||
LOOP
|
|
||||||
-- check if it has any children
|
|
||||||
current_child_result = has_child(header.block_hash, header.block_number);
|
|
||||||
IF current_child_result.has_child THEN
|
|
||||||
-- if it does, take note
|
|
||||||
has_children_count = has_children_count + 1;
|
|
||||||
current_header_with_child = header;
|
|
||||||
-- and add the children to the growing set of child headers
|
|
||||||
child_headers = array_cat(child_headers, current_child_result.children);
|
|
||||||
END IF;
|
|
||||||
END LOOP;
|
|
||||||
-- if none of the headers had children, none is more canonical than the other
|
|
||||||
IF has_children_count = 0 THEN
|
|
||||||
-- return the first one selected
|
|
||||||
SELECT * INTO canonical_header FROM unnest(headers) LIMIT 1;
|
|
||||||
-- if only one header had children, it can be considered the heaviest/canonical header of the set
|
|
||||||
ELSIF has_children_count = 1 THEN
|
|
||||||
-- return the only header with a child
|
|
||||||
canonical_header = current_header_with_child;
|
|
||||||
-- if there are multiple headers with children
|
|
||||||
ELSE
|
|
||||||
-- find the canonical header from the child set
|
|
||||||
canonical_child = canonical_header_from_array(child_headers);
|
|
||||||
-- the header that is parent to this header, is the canonical header at this level
|
|
||||||
SELECT * INTO canonical_header FROM unnest(headers)
|
|
||||||
WHERE block_hash = canonical_child.parent_hash;
|
|
||||||
END IF;
|
|
||||||
RETURN canonical_header;
|
|
||||||
END
|
|
||||||
$BODY$
|
|
||||||
LANGUAGE 'plpgsql';
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
CREATE OR REPLACE FUNCTION canonical_header_hash(height BIGINT) RETURNS character varying AS
|
|
||||||
$BODY$
|
|
||||||
DECLARE
|
|
||||||
canonical_header eth.header_cids;
|
|
||||||
headers eth.header_cids[];
|
|
||||||
header_count INT;
|
|
||||||
temp_header eth.header_cids;
|
|
||||||
BEGIN
|
|
||||||
-- collect all headers at this height
|
|
||||||
FOR temp_header IN
|
|
||||||
SELECT * FROM eth.header_cids WHERE block_number = height
|
|
||||||
LOOP
|
|
||||||
headers = array_append(headers, temp_header);
|
|
||||||
END LOOP;
|
|
||||||
-- count the number of headers collected
|
|
||||||
header_count = array_length(headers, 1);
|
|
||||||
-- if we have less than 1 header, return NULL
|
|
||||||
IF header_count IS NULL OR header_count < 1 THEN
|
|
||||||
RETURN NULL;
|
|
||||||
-- if we have one header, return its hash
|
|
||||||
ELSIF header_count = 1 THEN
|
|
||||||
RETURN headers[1].block_hash;
|
|
||||||
-- if we have multiple headers we need to determine which one is canonical
|
|
||||||
ELSE
|
|
||||||
canonical_header = canonical_header_from_array(headers);
|
|
||||||
RETURN canonical_header.block_hash;
|
|
||||||
END IF;
|
|
||||||
END
|
|
||||||
$BODY$
|
|
||||||
LANGUAGE 'plpgsql';
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
CREATE TYPE state_node_result AS (
|
|
||||||
data BYTEA,
|
|
||||||
state_leaf_key VARCHAR(66),
|
|
||||||
cid TEXT,
|
|
||||||
state_path BYTEA,
|
|
||||||
node_type INTEGER,
|
|
||||||
mh_key TEXT
|
|
||||||
);
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
CREATE OR REPLACE FUNCTION state_snapshot(starting_height BIGINT, ending_height BIGINT) RETURNS void AS
|
|
||||||
$BODY$
|
|
||||||
DECLARE
|
|
||||||
canonical_hash VARCHAR(66);
|
|
||||||
results state_node_result[];
|
|
||||||
BEGIN
|
|
||||||
-- get the canonical hash for the header at ending_height
|
|
||||||
canonical_hash = canonical_header_hash(ending_height);
|
|
||||||
IF canonical_hash IS NULL THEN
|
|
||||||
RAISE EXCEPTION 'cannot create state snapshot, no header can be found at height %', ending_height;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- select all of the state nodes for this snapshot: the latest state node record at every unique path
|
|
||||||
SELECT DISTINCT ON (state_path) blocks.data, state_cids.state_leaf_key, state_cids.cid, state_cids.state_path,
|
|
||||||
state_cids.node_type, state_cids.mh_key
|
|
||||||
INTO results
|
|
||||||
FROM eth.state_cids
|
|
||||||
INNER JOIN public.blocks
|
|
||||||
ON (state_cids.mh_key, state_cids.block_number) = (blocks.key, blocks.block_number)
|
|
||||||
WHERE state_cids.block_number BETWEEN starting_height AND ending_height
|
|
||||||
ORDER BY state_path, block_number DESC;
|
|
||||||
|
|
||||||
-- from the set returned above, insert public.block records at the ending_height block number
|
|
||||||
INSERT INTO public.blocks (block_number, key, data)
|
|
||||||
SELECT ending_height, r.mh_key, r.data
|
|
||||||
FROM results r;
|
|
||||||
|
|
||||||
-- from the set returned above, insert eth.state_cids records at the ending_height block number
|
|
||||||
-- anchoring all the records to the canonical header found at ending_height
|
|
||||||
INSERT INTO eth.state_cids (block_number, header_id, state_leaf_key, cid, state_path, node_type, diff, mh_key)
|
|
||||||
SELECT ending_height, canonical_hash, r.state_leaf_key, r.cid, r.state_path, r.node_type, false, r.mh_key
|
|
||||||
FROM results r
|
|
||||||
ON CONFLICT (state_path, header_id) DO NOTHING;
|
|
||||||
END
|
|
||||||
$BODY$
|
|
||||||
LANGUAGE 'plpgsql';
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
CREATE TYPE storage_node_result AS (
|
|
||||||
data BYTEA,
|
|
||||||
state_path BYTEA,
|
|
||||||
storage_leaf_key VARCHAR(66),
|
|
||||||
cid TEXT,
|
|
||||||
storage_path BYTEA,
|
|
||||||
node_type INTEGER,
|
|
||||||
mh_key TEXT
|
|
||||||
);
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose StatementBegin
|
|
||||||
-- this should only be ran after a state_snapshot has been completed
|
|
||||||
-- this should probably be rolled together with state_snapshot into a single procedure...
|
|
||||||
CREATE OR REPLACE FUNCTION storage_snapshot(starting_height BIGINT, ending_height BIGINT) RETURNS void AS
|
|
||||||
$BODY$
|
|
||||||
DECLARE
|
|
||||||
canonical_hash VARCHAR(66);
|
|
||||||
results storage_node_result[];
|
|
||||||
BEGIN
|
|
||||||
-- get the canonical hash for the header at ending_height
|
|
||||||
SELECT canonical_header_hash(ending_height) INTO canonical_hash;
|
|
||||||
IF canonical_hash IS NULL THEN
|
|
||||||
RAISE EXCEPTION 'cannot create state snapshot, no header can be found at height %', ending_height;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- select all of the storage nodes for this snapshot: the latest storage node record at every unique state leaf key
|
|
||||||
SELECT DISTINCT ON (state_leaf_key, storage_path) block.data, storage_cids.state_path, storage_cids.storage_leaf_key,
|
|
||||||
storage_cids.cid, storage_cids.storage_path, storage_cids.node_type, storage_cids.mh_key
|
|
||||||
INTO results
|
|
||||||
FROM eth.storage_cids
|
|
||||||
INNER JOIN public.blocks
|
|
||||||
ON (storage_cids.mh_key, storage_cids.block_number) = (blocks.key, blocks.block_number)
|
|
||||||
INNER JOIN eth.state_cids
|
|
||||||
ON (storage_cids.state_path, storage_cids.header_id) = (state_cids.state_path, state_cids.header_id)
|
|
||||||
WHERE storage_cids.block_number BETWEEN starting_height AND ending_height
|
|
||||||
ORDER BY state_path, storage_path, block_number DESC;
|
|
||||||
|
|
||||||
-- from the set returned above, insert public.block records at the ending_height block number
|
|
||||||
INSERT INTO public.blocks (block_number, key, data)
|
|
||||||
SELECT ending_height, r.mh_key, r.data
|
|
||||||
FROM results r;
|
|
||||||
|
|
||||||
-- from the set returned above, insert eth.state_cids records at the ending_height block number
|
|
||||||
-- anchoring all the records to the canonical header found at ending_height
|
|
||||||
INSERT INTO eth.storage_cids (block_number, header_id, state_path, storage_leaf_key, cid, storage_path,
|
|
||||||
node_type, diff, mh_key)
|
|
||||||
SELECT ending_height, canonical_hash, r.state_path, r.storage_leaf_key, r.cid, r.storage_path, r.node_type, false, r.mh_key
|
|
||||||
FROM results r
|
|
||||||
ON CONFLICT (storage_path, state_path, header_id) DO NOTHING;
|
|
||||||
END
|
|
||||||
$BODY$
|
|
||||||
LANGUAGE 'plpgsql';
|
|
||||||
-- +goose StatementEnd
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
DROP FUNCTION storage_snapshot;
|
|
||||||
DROP TYPE storage_node_result;
|
|
||||||
DROP FUNCTION state_snapshot;
|
|
||||||
DROP TYPE state_node_result;
|
|
||||||
DROP FUNCTION was_state_leaf_removed;
|
|
||||||
DROP FUNCTION canonical_header_hash;
|
|
||||||
DROP FUNCTION canonical_header_from_array;
|
|
||||||
DROP FUNCTION has_child;
|
|
||||||
DROP TYPE child_result;
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
-- +goose Up
|
|
||||||
-- to be generated by a script
|
|
||||||
|
|
||||||
SELECT set_replication_factor('public.blocks', 3);
|
|
||||||
SELECT set_replication_factor('eth.header_cids', 3);
|
|
||||||
SELECT set_replication_factor('eth.uncle_cids', 3);
|
|
||||||
SELECT set_replication_factor('eth.transaction_cids', 3);
|
|
||||||
SELECT set_replication_factor('eth.receipt_cids', 3);
|
|
||||||
SELECT set_replication_factor('eth.state_cids', 3);
|
|
||||||
SELECT set_replication_factor('eth.storage_cids', 3);
|
|
||||||
SELECT set_replication_factor('eth.state_accounts', 3);
|
|
||||||
SELECT set_replication_factor('eth.access_list_elements', 3);
|
|
||||||
SELECT set_replication_factor('eth.log_cids', 3);
|
|
||||||
|
|
||||||
-- +goose Down
|
|
||||||
-- to be generated by a script
|
|
||||||
|
|
||||||
SELECT set_replication_factor('public.blocks', 1);
|
|
||||||
SELECT set_replication_factor('eth.header_cids', 1);
|
|
||||||
SELECT set_replication_factor('eth.uncle_cids', 1);
|
|
||||||
SELECT set_replication_factor('eth.transaction_cids', 1);
|
|
||||||
SELECT set_replication_factor('eth.receipt_cids', 1);
|
|
||||||
SELECT set_replication_factor('eth.state_cids', 1);
|
|
||||||
SELECT set_replication_factor('eth.storage_cids', 1);
|
|
||||||
SELECT set_replication_factor('eth.state_accounts', 1);
|
|
||||||
SELECT set_replication_factor('eth.access_list_elements', 1);
|
|
||||||
SELECT set_replication_factor('eth.log_cids', 1);
|
|
||||||
+10
-53
@@ -1,62 +1,19 @@
|
|||||||
version: '3.2'
|
version: '3.2'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
access-node:
|
statediff-migrations:
|
||||||
image: timescale/timescaledb:latest-pg14
|
restart: on-failure
|
||||||
restart: always
|
|
||||||
container_name: access-node
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- data-node-1
|
- test-db
|
||||||
- data-node-2
|
image: vulcanize/statediff-migrations:v0.9.0
|
||||||
- data-node-3
|
|
||||||
command: ["postgres", "-c", "log_statement=all"]
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: "postgres"
|
|
||||||
POSTGRES_DB: "vulcanize_testing_v4"
|
|
||||||
POSTGRES_PASSWORD: "password"
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:8066:5432"
|
|
||||||
volumes:
|
|
||||||
- ./scripts/init-access-node.sh:/docker-entrypoint-initdb.d/init-access-node.sh
|
|
||||||
|
|
||||||
data-node-1:
|
test-db:
|
||||||
image: timescale/timescaledb:latest-pg14
|
restart: always
|
||||||
restart: unless-stopped
|
image: postgres:10.12-alpine
|
||||||
container_name: data-node-1
|
|
||||||
command: ["postgres", "-c", "log_statement=all"]
|
command: ["postgres", "-c", "log_statement=all"]
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: "postgres"
|
POSTGRES_USER: "vdbm"
|
||||||
POSTGRES_DB: "vulcanize_testing_v4"
|
POSTGRES_DB: "vulcanize_testing"
|
||||||
POSTGRES_PASSWORD: "password"
|
POSTGRES_PASSWORD: "password"
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:8067:5432"
|
- "127.0.0.1:8066:5432"
|
||||||
volumes:
|
|
||||||
- ./scripts/init-data-node.sh:/docker-entrypoint-initdb.d/init-data-node.sh
|
|
||||||
|
|
||||||
data-node-2:
|
|
||||||
image: timescale/timescaledb:latest-pg14
|
|
||||||
restart: unless-stopped
|
|
||||||
container_name: data-node-2
|
|
||||||
command: ["postgres", "-c", "log_statement=all"]
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: "postgres"
|
|
||||||
POSTGRES_DB: "vulcanize_testing_v4"
|
|
||||||
POSTGRES_PASSWORD: "password"
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:8068:5432"
|
|
||||||
volumes:
|
|
||||||
- ./scripts/init-data-node.sh:/docker-entrypoint-initdb.d/init-data-node.sh
|
|
||||||
|
|
||||||
data-node-3:
|
|
||||||
image: timescale/timescaledb:latest-pg14
|
|
||||||
restart: unless-stopped
|
|
||||||
container_name: data-node-3
|
|
||||||
command: ["postgres", "-c", "log_statement=all"]
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: "postgres"
|
|
||||||
POSTGRES_DB: "vulcanize_testing_v4"
|
|
||||||
POSTGRES_PASSWORD: "password"
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:8069:5432"
|
|
||||||
volumes:
|
|
||||||
- ./scripts/init-data-node.sh:/docker-entrypoint-initdb.d/init-data-node.sh
|
|
||||||
+633
-380
File diff suppressed because it is too large
Load Diff
@@ -1,138 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Guards
|
|
||||||
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ -z "$5" ]
|
|
||||||
then
|
|
||||||
echo "Env variables not provided"
|
|
||||||
echo "Usage: ./add_nodes.sh <MIGRATION_FILE_PATH:string> <NODE_NAME:string> <NODE_HOST:string> <NODE_PORT:numeric/string> <NODE_DATABASE:string> <EXECUTE_SQL:bool>"
|
|
||||||
echo "Only <EXECUTE_SQL> is optional"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -z "$6" ]
|
|
||||||
then
|
|
||||||
echo "EXECUTE_SQL not set, will not run statements against an access server"
|
|
||||||
else
|
|
||||||
echo "EXECUTE_SQL is set, will run stataments against an access server"
|
|
||||||
echo "Note: this mode is not recommended except in the case when the migration has already been applied with previous
|
|
||||||
nodes and we need/want to add more while still recording them in the existing migration (and adding their Down statements to said migration)"
|
|
||||||
echo "Expected environment variables:"
|
|
||||||
echo "DATABASE_HOSTNAME, DATABASE_NAME, DATABASE_PORT, DATABASE_USER"
|
|
||||||
echo "For now, DATABASE_PASSWORD will be prompted for on each psql call"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remote DB node info
|
|
||||||
export MIGRATION_FILE_PATH=$1
|
|
||||||
export NODE_NAME=$2
|
|
||||||
export NODE_HOST=$3
|
|
||||||
export NODE_PORT=$4
|
|
||||||
export NODE_DATABASE=$5
|
|
||||||
printf "Enter the ${NODE_HOST} database password:\n"
|
|
||||||
stty -echo
|
|
||||||
read NODE_PASSWORD
|
|
||||||
stty echo
|
|
||||||
export NODE_PASSWORD
|
|
||||||
|
|
||||||
if ! [ -z "$6" ]
|
|
||||||
then
|
|
||||||
# Access DB info
|
|
||||||
echo "heeeeey"
|
|
||||||
export DATABASE_HOSTNAME=localhost
|
|
||||||
export DATABASE_PORT=5432
|
|
||||||
export DATABASE_USER=vdbm
|
|
||||||
export DATABASE_NAME=vulcanize_db
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Array of distributed hypertable names
|
|
||||||
declare -a tables_names=("public.blocks" "eth.header_cid" "eth.uncle_cids" "eth.transaction_cids"
|
|
||||||
"eth.receipt_cids" "eth.state_cid" "eth.storage_cids" "eth.state_accounts"
|
|
||||||
"eth.access_list_elements" "eth.log_cids"
|
|
||||||
)
|
|
||||||
# Array to append Up statements to for later (optional) execution
|
|
||||||
declare -a up_stmts=()
|
|
||||||
|
|
||||||
echo "Writing Up and Down statements to provided migration file at ${migration_file_path}"
|
|
||||||
|
|
||||||
# Create add node statement
|
|
||||||
up_add_pg_str="SELECT add_data_node('${NODE_NAME}', host => '${NODE_HOST}', port => ${NODE_PORT}, database => '${NODE_DATABASE}', password => '${NODE_PASSWORD}');"
|
|
||||||
up_stmts+=(${up_add_pg_str})
|
|
||||||
|
|
||||||
# Insert at the 3rd line of the file
|
|
||||||
sed -i.bak '3 i\
|
|
||||||
'"${up_add_pg_str}"'
|
|
||||||
' "${MIGRATION_FILE_PATH}"
|
|
||||||
|
|
||||||
# Check for error
|
|
||||||
if [[ $? -eq 0 ]]; then
|
|
||||||
echo "Wrote Up add node statement ${up_add_pg_str}"
|
|
||||||
else
|
|
||||||
echo "Could not write Up add node statement ${up_add_pg_str}. Is the migration file path correct?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create attach node statements
|
|
||||||
for table_name in "${tables_names[@]}"
|
|
||||||
do
|
|
||||||
up_attach_pg_str="SELECT attach_data_node('${NODE_NAME}', '${table_name}', if_not_attached => true);"
|
|
||||||
up_stmts+=(${up_attach_pg_str})
|
|
||||||
# Insert at the 4th line of the file
|
|
||||||
sed -i.bak '4 i\
|
|
||||||
'"${up_attach_pg_str}"'
|
|
||||||
' "${MIGRATION_FILE_PATH}"
|
|
||||||
# Check for error
|
|
||||||
if [[ $? -eq 0 ]]; then
|
|
||||||
echo "Wrote Up attach node statement ${up_attach_pg_str}"
|
|
||||||
else
|
|
||||||
echo "Could not write Up attach node statement ${up_attach_pg_str}. Is the migration file path correct?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
## Create detach and remove node statement
|
|
||||||
down_attach_pg_str="SELECT detach_data_node('${NODE_NAME}', force => true, if_attached = true);"
|
|
||||||
down_add_pg_str="SELECT delete_data_node('${NODE_NAME}', force => true, if_attached => true);"
|
|
||||||
|
|
||||||
# Append them at the last line in the file
|
|
||||||
sed -i.bak '$ a\
|
|
||||||
'"${down_attach_pg_str}"'
|
|
||||||
' "${MIGRATION_FILE_PATH}"
|
|
||||||
# Check for error
|
|
||||||
if [[ $? -eq 0 ]]; then
|
|
||||||
echo "Wrote Down attach node statement ${down_attach_pg_str}"
|
|
||||||
else
|
|
||||||
echo "Could not write Down attach node statement ${down_attach_pg_str}. Is the migration file path correct?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Append them at the last line in the file
|
|
||||||
sed -i.bak '$ a\
|
|
||||||
'"${down_add_pg_str}"'
|
|
||||||
' "${MIGRATION_FILE_PATH}"
|
|
||||||
# Check for error
|
|
||||||
if [[ $? -eq 0 ]]; then
|
|
||||||
echo "Wrote Down add node statement ${down_add_pg_str}"
|
|
||||||
else
|
|
||||||
echo "Could not write Down add node statement ${down_add_pg_str}. Is the migration file path correct?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Execute Up statements on the server if we are in that mode
|
|
||||||
if [ -z "$6" ]
|
|
||||||
then
|
|
||||||
echo "Done!"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Executing Up statements against provided server"
|
|
||||||
|
|
||||||
for up_stmt in "${up_stmts[@]}"
|
|
||||||
do
|
|
||||||
psql -c '\x' -c "${up_stmt}" -h $DATABASE_HOSTNAME -p $DATABASE_PORT -U $DATABASE_USER -d $DATABASE_NAME -W
|
|
||||||
# Check for error
|
|
||||||
if [[ $? -eq 0 ]]; then
|
|
||||||
echo "Executed Up statement ${up_stmt}}"
|
|
||||||
else
|
|
||||||
echo "Could not execute Up statement ${up_stmt}. Is the migration file path correct?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Done!"
|
|
||||||
exit 0
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# https://docs.timescale.com/timescaledb/latest/how-to-guides/multinode-timescaledb/multinode-config/
|
|
||||||
|
|
||||||
# To achieve good query performance you need to enable partition-wise aggregation on the access node. This pushes down aggregation queries to the data nodes.
|
|
||||||
# https://www.postgresql.org/docs/12/runtime-config-query.html#enable_partitionwise_aggregate
|
|
||||||
sed -ri "s!^#?(enable_partitionwise_aggregate)\s*=.*!\1 = on!" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
grep "enable_partitionwise_aggregate" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
|
|
||||||
# JIT should be set to off on the access node as JIT currently doesn't work well with distributed queries.
|
|
||||||
# https://www.postgresql.org/docs/12/runtime-config-query.html#jit
|
|
||||||
sed -ri "s!^#?(jit)\s*=.*!\1 = off!" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
grep "jit" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
|
|
||||||
# https://docs.timescale.com/timescaledb/latest/how-to-guides/multinode-timescaledb/multinode-auth/
|
|
||||||
# https://docs.timescale.com/timescaledb/latest/how-to-guides/multinode-timescaledb/multinode-auth/#password-authentication
|
|
||||||
|
|
||||||
# Set password_encryption = 'scram-sha-256' in postgresql.conf on the access node.
|
|
||||||
sed -ri "s!^#?(password_encryption)\s*=.*!\1 = 'scram-sha-256'!" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
grep "password_encryption" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
|
|
||||||
# Append to data/passfile *:*:*:ROLE:ROLE_PASSWORD
|
|
||||||
# This file stores the passwords for each role that the access node connects to on the data nodes.
|
|
||||||
echo "*:*:*:postgres:password">>/var/lib/postgresql/data/passfile
|
|
||||||
chmod 0600 /var/lib/postgresql/data/passfile
|
|
||||||
|
|
||||||
# Add "host all all ACCESS_NODE_IP scram-sha-256" pg_hba.conf on the data nodes.
|
|
||||||
# Skipped. Using default "host all all all scram-sha-256" for now.
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# https://docs.timescale.com/timescaledb/latest/how-to-guides/configuration/timescaledb-config/#timescaledb-last-tuned-string
|
|
||||||
# https://docs.timescale.com/timescaledb/latest/how-to-guides/multi-node-setup/required-configuration/
|
|
||||||
|
|
||||||
# It is necessary to change the parameter max_prepared_transactions to a non-zero value ('150' is recommended).
|
|
||||||
# https://www.postgresql.org/docs/12/runtime-config-resource.html#max_prepared_transactions
|
|
||||||
sed -ri "s!^#?(max_prepared_transactions)\s*=.*!\1 = 150!" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
grep "max_prepared_transactions" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
|
|
||||||
# Statement timeout should be disabled on the data nodes and managed through the access node configuration if desired.
|
|
||||||
# https://www.postgresql.org/docs/12/runtime-config-client.html#statement_timeout
|
|
||||||
sed -ri "s!^#?(statement_timeout)\s*=.*!\1 = 0!" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
grep "statement_timeout" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
|
|
||||||
# On the data nodes, set the wal_level to logical or higher to move or copy chunks between data nodes.
|
|
||||||
# https://www.postgresql.org/docs/14/runtime-config-wal.html
|
|
||||||
sed -ri "s!^#?(wal_level)\s*=.*!\1 = 'logical'!" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
grep "wal_level" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
|
|
||||||
# https://docs.timescale.com/timescaledb/latest/how-to-guides/multinode-timescaledb/multinode-auth/
|
|
||||||
# https://docs.timescale.com/timescaledb/latest/how-to-guides/multinode-timescaledb/multinode-auth/#password-authentication
|
|
||||||
|
|
||||||
# Set password_encryption = 'scram-sha-256' in postgresql.conf on the data node.
|
|
||||||
sed -ri "s!^#?(password_encryption)\s*=.*!\1 = 'scram-sha-256'!" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
grep "password_encryption" /var/lib/postgresql/data/postgresql.conf
|
|
||||||
@@ -7,9 +7,8 @@ VDB_PG_CONNECT=postgresql://$DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOSTNAME
|
|||||||
|
|
||||||
# Run the DB migrations
|
# Run the DB migrations
|
||||||
echo "Connecting with: $VDB_PG_CONNECT"
|
echo "Connecting with: $VDB_PG_CONNECT"
|
||||||
sleep 15
|
|
||||||
echo "Running database migrations"
|
echo "Running database migrations"
|
||||||
./goose -dir migrations/vulcanizedb postgres "$VDB_PG_CONNECT" up-to 21
|
./goose -dir migrations/vulcanizedb postgres "$VDB_PG_CONNECT" up
|
||||||
|
|
||||||
# If the db migrations ran without err
|
# If the db migrations ran without err
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 516 KiB After Width: | Height: | Size: 493 KiB |
+127
-125
@@ -1,148 +1,150 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Diagram>
|
<Diagram>
|
||||||
<ID>DATABASE</ID>
|
<ID>DATABASE</ID>
|
||||||
<OriginalElement>407978cb-39e6-453c-b9b7-c4183a4e26ef</OriginalElement>
|
<OriginalElement>763cb2dc-728a-4fbd-a163-94dd564429aa</OriginalElement>
|
||||||
<nodes>
|
<nodes>
|
||||||
<node x="553.96484375" y="196.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.header_cids</node>
|
<node x="508.5625" y="998.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.receipt_cids</node>
|
||||||
<node x="93.5" y="944.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.receipt_cids</node>
|
<node x="227.705078125" y="1282.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.log_cids</node>
|
||||||
<node x="884.80078125" y="966.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_accounts</node>
|
<node x="256.5" y="1031.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_accounts</node>
|
||||||
<node x="849.705078125" y="0.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.nodes</node>
|
<node x="156.705078125" y="712.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_cids</node>
|
||||||
<node x="127.30078125" y="680.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.uncle_cids</node>
|
<node x="193.330078125" y="44.5">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks</node>
|
||||||
<node x="102.67578125" y="33.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks</node>
|
<node x="10.5" y="1009.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.storage_cids</node>
|
||||||
<node x="341.30078125" y="636.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.transaction_cids</node>
|
<node x="547.375" y="723.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.uncle_cids</node>
|
||||||
<node x="357.365234375" y="988.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.access_list_elements</node>
|
<node x="1146.375" y="0.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.goose_db_version</node>
|
||||||
<node x="832.365234375" y="669.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_cids</node>
|
<node x="499.455078125" y="0.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.nodes</node>
|
||||||
<node x="1433.705078125" y="0.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.db_version</node>
|
<node x="824.375" y="1042.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.access_list_element</node>
|
||||||
<node x="58.0" y="1206.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.log_cids</node>
|
<node x="614.5" y="228.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.header_cids</node>
|
||||||
<node x="1200.705078125" y="0.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.goose_db_version</node>
|
<node x="761.375" y="690.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.transaction_cids</node>
|
||||||
<node x="592.365234375" y="944.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.storage_cids</node>
|
|
||||||
</nodes>
|
</nodes>
|
||||||
<notes />
|
<notes />
|
||||||
<edges>
|
<edges>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.access_list_elements" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.transaction_cids" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.nodes" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.nodes" relationship="REFERENCES">
|
||||||
<point x="0.0" y="-61.0" />
|
<point x="-76.5" y="83.0" />
|
||||||
<point x="464.865234375" y="922.0" />
|
<point x="575.955078125" y="151.63819095477388" />
|
||||||
<point x="511.30078125" y="922.0" />
|
<point x="532.3193997330402" y="151.63819095477388" />
|
||||||
<point x="0.0" y="127.0" />
|
<point x="532.3193997330402" y="83.0" />
|
||||||
|
<point x="-153.0" y="0.0" />
|
||||||
</edge>
|
</edge>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.header_cids" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.uncle_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.header_cids" relationship="REFERENCES">
|
||||||
<point x="-52.25" y="-94.0" />
|
<point x="48.5" y="-94.0" />
|
||||||
<point x="884.615234375" y="614.0" />
|
<point x="692.875" y="668.0" />
|
||||||
<point x="700.96484375" y="614.0" />
|
<point x="756.0" y="668.0" />
|
||||||
<point x="0.0" y="193.0" />
|
<point x="0.0" y="204.0" />
|
||||||
</edge>
|
</edge>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.receipt_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.storage_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks" relationship="REFERENCES">
|
||||||
<point x="-51.75" y="-105.0" />
|
|
||||||
<point x="145.25" y="922.0" />
|
|
||||||
<point x="59.365234375" y="922.0" />
|
|
||||||
<point x="59.365234375" y="175.0" />
|
|
||||||
<point x="52.75" y="175.0" />
|
|
||||||
<point x="52.75" y="165.0" />
|
|
||||||
<point x="127.92578125" y="165.0" />
|
|
||||||
<point x="-25.25" y="39.0" />
|
|
||||||
</edge>
|
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_accounts" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_cids" relationship="REFERENCES">
|
|
||||||
<point x="0.0" y="-83.0" />
|
|
||||||
<point x="983.30078125" y="922.0" />
|
|
||||||
<point x="936.865234375" y="922.0" />
|
|
||||||
<point x="0.0" y="94.0" />
|
|
||||||
</edge>
|
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.log_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks" relationship="REFERENCES">
|
|
||||||
<point x="-41.0" y="-127.0" />
|
|
||||||
<point x="99.0" y="1180.0" />
|
|
||||||
<point x="47.5" y="1180.0" />
|
|
||||||
<point x="47.5" y="175.0" />
|
|
||||||
<point x="52.75" y="175.0" />
|
|
||||||
<point x="52.75" y="165.0" />
|
|
||||||
<point x="127.92578125" y="165.0" />
|
|
||||||
<point x="-25.25" y="39.0" />
|
|
||||||
</edge>
|
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.receipt_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.transaction_cids" relationship="REFERENCES">
|
|
||||||
<point x="51.75" y="-105.0" />
|
|
||||||
<point x="248.75" y="922.0" />
|
|
||||||
<point x="511.30078125" y="922.0" />
|
|
||||||
<point x="0.0" y="127.0" />
|
|
||||||
</edge>
|
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.storage_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks" relationship="REFERENCES">
|
|
||||||
<point x="-56.5" y="-105.0" />
|
<point x="-56.5" y="-105.0" />
|
||||||
<point x="648.865234375" y="912.0" />
|
<point x="67.0" y="971.0" />
|
||||||
<point x="116.80078125" y="912.0" />
|
<point x="111.205078125" y="971.0" />
|
||||||
<point x="116.80078125" y="175.0" />
|
<point x="111.205078125" y="207.0" />
|
||||||
<point x="437.205078125" y="175.0" />
|
<point x="502.875" y="207.0" />
|
||||||
<point x="437.205078125" y="165.0" />
|
<point x="502.875" y="197.0" />
|
||||||
<point x="178.42578125" y="165.0" />
|
<point x="269.080078125" y="197.0" />
|
||||||
<point x="25.25" y="39.0" />
|
<point x="25.25" y="38.5" />
|
||||||
</edge>
|
</edge>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.transaction_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.header_cids" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_accounts" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_cids" relationship="REFERENCES">
|
||||||
<point x="85.0" y="-127.0" />
|
<point x="0.0" y="-83.0" />
|
||||||
<point x="596.30078125" y="614.0" />
|
<point x="355.0" y="971.0" />
|
||||||
<point x="700.96484375" y="614.0" />
|
<point x="261.205078125" y="971.0" />
|
||||||
<point x="0.0" y="193.0" />
|
|
||||||
</edge>
|
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks" relationship="REFERENCES">
|
|
||||||
<point x="52.25" y="-94.0" />
|
|
||||||
<point x="989.115234375" y="614.0" />
|
|
||||||
<point x="970.279296875" y="614.0" />
|
|
||||||
<point x="970.279296875" y="175.0" />
|
|
||||||
<point x="437.205078125" y="175.0" />
|
|
||||||
<point x="437.205078125" y="165.0" />
|
|
||||||
<point x="178.42578125" y="165.0" />
|
|
||||||
<point x="25.25" y="39.0" />
|
|
||||||
</edge>
|
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.storage_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_cids" relationship="REFERENCES">
|
|
||||||
<point x="56.5" y="-105.0" />
|
|
||||||
<point x="761.865234375" y="922.0" />
|
|
||||||
<point x="936.865234375" y="922.0" />
|
|
||||||
<point x="0.0" y="94.0" />
|
|
||||||
</edge>
|
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.log_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.receipt_cids" relationship="REFERENCES">
|
|
||||||
<point x="41.0" y="-127.0" />
|
|
||||||
<point x="181.0" y="1180.0" />
|
|
||||||
<point x="197.0" y="1180.0" />
|
|
||||||
<point x="0.0" y="105.0" />
|
<point x="0.0" y="105.0" />
|
||||||
</edge>
|
</edge>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.header_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.nodes" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.uncle_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks" relationship="REFERENCES">
|
||||||
<point x="73.5" y="-193.0" />
|
<point x="-48.5" y="-94.0" />
|
||||||
<point x="774.46484375" y="165.0" />
|
<point x="595.875" y="658.0" />
|
||||||
<point x="1002.705078125" y="165.0" />
|
<point x="589.25" y="658.0" />
|
||||||
<point x="0.0" y="72.0" />
|
<point x="589.25" y="207.0" />
|
||||||
|
<point x="502.875" y="207.0" />
|
||||||
|
<point x="502.875" y="197.0" />
|
||||||
|
<point x="269.080078125" y="197.0" />
|
||||||
|
<point x="25.25" y="38.5" />
|
||||||
</edge>
|
</edge>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.uncle_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.header_cids" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.storage_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_cids" relationship="REFERENCES">
|
||||||
<point x="48.5" y="-83.0" />
|
<point x="56.5" y="-105.0" />
|
||||||
<point x="272.80078125" y="614.0" />
|
<point x="180.0" y="971.0" />
|
||||||
<point x="700.96484375" y="614.0" />
|
<point x="261.205078125" y="971.0" />
|
||||||
<point x="0.0" y="193.0" />
|
<point x="0.0" y="105.0" />
|
||||||
</edge>
|
</edge>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.header_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.log_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.receipt_cids" relationship="REFERENCES">
|
||||||
<point x="-73.5" y="-193.0" />
|
<point x="41.0" y="-138.0" />
|
||||||
<point x="627.46484375" y="175.0" />
|
<point x="350.705078125" y="1256.0" />
|
||||||
<point x="437.205078125" y="175.0" />
|
<point x="612.0625" y="1256.0" />
|
||||||
<point x="437.205078125" y="165.0" />
|
<point x="0.0" y="116.0" />
|
||||||
<point x="178.42578125" y="165.0" />
|
|
||||||
<point x="25.25" y="39.0" />
|
|
||||||
</edge>
|
</edge>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.uncle_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.header_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks" relationship="REFERENCES">
|
||||||
<point x="-48.5" y="-83.0" />
|
<point x="-70.75" y="-204.0" />
|
||||||
<point x="175.80078125" y="614.0" />
|
<point x="685.25" y="207.0" />
|
||||||
<point x="214.30078125" y="614.0" />
|
<point x="502.875" y="207.0" />
|
||||||
<point x="214.30078125" y="175.0" />
|
<point x="502.875" y="197.0" />
|
||||||
<point x="437.205078125" y="175.0" />
|
<point x="269.080078125" y="197.0" />
|
||||||
<point x="437.205078125" y="165.0" />
|
<point x="25.25" y="38.5" />
|
||||||
<point x="178.42578125" y="165.0" />
|
|
||||||
<point x="25.25" y="39.0" />
|
|
||||||
</edge>
|
</edge>
|
||||||
<edge source="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.transaction_cids" target="407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks" relationship="REFERENCES">
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.header_cids" relationship="REFERENCES">
|
||||||
|
<point x="52.25" y="-105.0" />
|
||||||
|
<point x="313.455078125" y="668.0" />
|
||||||
|
<point x="756.0" y="668.0" />
|
||||||
|
<point x="0.0" y="204.0" />
|
||||||
|
</edge>
|
||||||
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.receipt_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.transaction_cids" relationship="REFERENCES">
|
||||||
|
<point x="51.75" y="-116.0" />
|
||||||
|
<point x="663.8125" y="971.0" />
|
||||||
|
<point x="931.375" y="971.0" />
|
||||||
|
<point x="0.0" y="127.0" />
|
||||||
|
</edge>
|
||||||
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.transaction_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks" relationship="REFERENCES">
|
||||||
|
<point x="85.0" y="-127.0" />
|
||||||
|
<point x="1016.375" y="668.0" />
|
||||||
|
<point x="923.3125" y="668.0" />
|
||||||
|
<point x="923.3125" y="207.0" />
|
||||||
|
<point x="502.875" y="207.0" />
|
||||||
|
<point x="502.875" y="197.0" />
|
||||||
|
<point x="269.080078125" y="197.0" />
|
||||||
|
<point x="25.25" y="38.5" />
|
||||||
|
</edge>
|
||||||
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.receipt_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks" relationship="REFERENCES">
|
||||||
|
<point x="-51.75" y="-116.0" />
|
||||||
|
<point x="560.3125" y="971.0" />
|
||||||
|
<point x="497.625" y="971.0" />
|
||||||
|
<point x="497.625" y="207.0" />
|
||||||
|
<point x="502.875" y="207.0" />
|
||||||
|
<point x="502.875" y="197.0" />
|
||||||
|
<point x="269.080078125" y="197.0" />
|
||||||
|
<point x="25.25" y="38.5" />
|
||||||
|
</edge>
|
||||||
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.log_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks" relationship="REFERENCES">
|
||||||
|
<point x="-41.0" y="-138.0" />
|
||||||
|
<point x="268.705078125" y="1256.0" />
|
||||||
|
<point x="0.0" y="1256.0" />
|
||||||
|
<point x="0.0" y="197.0" />
|
||||||
|
<point x="218.580078125" y="197.0" />
|
||||||
|
<point x="-25.25" y="38.5" />
|
||||||
|
</edge>
|
||||||
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.transaction_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.header_cids" relationship="REFERENCES">
|
||||||
<point x="-85.0" y="-127.0" />
|
<point x="-85.0" y="-127.0" />
|
||||||
<point x="426.30078125" y="604.0" />
|
<point x="846.375" y="668.0" />
|
||||||
<point x="344.55078125" y="604.0" />
|
<point x="756.0" y="668.0" />
|
||||||
<point x="344.55078125" y="175.0" />
|
<point x="0.0" y="204.0" />
|
||||||
<point x="437.205078125" y="175.0" />
|
</edge>
|
||||||
<point x="437.205078125" y="165.0" />
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks" relationship="REFERENCES">
|
||||||
<point x="178.42578125" y="165.0" />
|
<point x="-52.25" y="-105.0" />
|
||||||
<point x="25.25" y="39.0" />
|
<point x="208.955078125" y="668.0" />
|
||||||
|
<point x="256.205078125" y="668.0" />
|
||||||
|
<point x="256.205078125" y="207.0" />
|
||||||
|
<point x="502.875" y="207.0" />
|
||||||
|
<point x="502.875" y="197.0" />
|
||||||
|
<point x="269.080078125" y="197.0" />
|
||||||
|
<point x="25.25" y="38.5" />
|
||||||
|
</edge>
|
||||||
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.access_list_element" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.transaction_cids" relationship="REFERENCES">
|
||||||
|
<point x="0.0" y="-72.0" />
|
||||||
|
<point x="0.0" y="127.0" />
|
||||||
|
</edge>
|
||||||
|
<edge source="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.header_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.nodes" relationship="REFERENCES">
|
||||||
|
<point x="70.75" y="-204.0" />
|
||||||
|
<point x="826.75" y="197.0" />
|
||||||
|
<point x="728.955078125" y="197.0" />
|
||||||
|
<point x="76.5" y="83.0" />
|
||||||
</edge>
|
</edge>
|
||||||
</edges>
|
</edges>
|
||||||
<settings layout="Hierarchic" zoom="0.40337837837837837" showDependencies="false" x="791.0" y="730.0" />
|
<settings layout="Hierarchic" zoom="0.37832699619771865" showDependencies="false" x="667.5" y="779.0" />
|
||||||
<SelectedNodes />
|
<SelectedNodes />
|
||||||
<Categories>
|
<Categories>
|
||||||
<Category>Columns</Category>
|
<Category>Columns</Category>
|
||||||
|
|||||||
Reference in New Issue
Block a user