Merge pull request #34 from vulcanize/postgres_refactor

New DB schema
This commit is contained in:
Ian Norden 2021-12-20 12:16:53 -06:00 committed by GitHub
commit 6c75ec7196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 1354 additions and 899 deletions

View File

@ -56,6 +56,16 @@ migrate: $(GOOSE) checkdbvars
$(GOOSE) -dir db/migrations postgres "$(CONNECT_STRING)" up
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
.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
.PHONY: new_migration
new_migration: $(GOOSE) checkmigname
@ -91,4 +101,4 @@ docker-concise-migration-build:
.PHONY: test-migrations
test-migrations: $(GOOSE)
./scripts/test_migration.sh
./scripts/test_migration.sh

View File

@ -8,7 +8,7 @@ ADD . /go/src/github.com/vulcanize/ipld-eth-db
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_mysql no_sqlite' -o goose .
RUN GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -tags='no_sqlite3' -o goose .
# app container
FROM alpine

View File

@ -1,6 +1,6 @@
-- +goose Up
CREATE TABLE IF NOT EXISTS public.blocks (
key TEXT UNIQUE NOT NULL,
key TEXT PRIMARY KEY,
data BYTEA NOT NULL
);

View File

@ -1,12 +1,10 @@
-- +goose Up
CREATE TABLE nodes (
id SERIAL PRIMARY KEY,
client_name VARCHAR,
genesis_block VARCHAR(66),
network_id VARCHAR,
node_id VARCHAR(128),
chain_id INTEGER DEFAULT 1,
CONSTRAINT node_uc UNIQUE (genesis_block, network_id, node_id, chain_id)
node_id VARCHAR(128) PRIMARY KEY,
client_name VARCHAR,
chain_id INTEGER DEFAULT 1
);
-- +goose Down

View File

@ -1,24 +1,22 @@
-- +goose Up
CREATE TABLE eth.header_cids (
id SERIAL PRIMARY KEY,
block_number BIGINT NOT NULL,
block_hash VARCHAR(66) NOT NULL,
parent_hash VARCHAR(66) NOT NULL,
cid TEXT NOT NULL,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
td NUMERIC NOT NULL,
node_id INTEGER NOT NULL REFERENCES nodes (id) ON DELETE CASCADE,
reward NUMERIC NOT NULL,
state_root VARCHAR(66) NOT NULL,
tx_root VARCHAR(66) NOT NULL,
receipt_root VARCHAR(66) NOT NULL,
uncle_root VARCHAR(66) NOT NULL,
bloom BYTEA NOT NULL,
timestamp NUMERIC NOT NULL,
times_validated INTEGER NOT NULL DEFAULT 1,
base_fee BIGINT,
UNIQUE (block_number, block_hash)
block_number BIGINT NOT NULL,
block_hash VARCHAR(66) PRIMARY KEY,
parent_hash VARCHAR(66) NOT NULL,
cid TEXT NOT NULL,
td NUMERIC NOT NULL,
node_id VARCHAR(128) NOT NULL REFERENCES nodes (node_id) ON DELETE CASCADE,
reward NUMERIC NOT NULL,
state_root VARCHAR(66) NOT NULL,
tx_root VARCHAR(66) NOT NULL,
receipt_root VARCHAR(66) NOT NULL,
uncle_root VARCHAR(66) NOT NULL,
bloom BYTEA NOT NULL,
timestamp BIGINT NOT NULL,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
times_validated INTEGER NOT NULL DEFAULT 1,
coinbase VARCHAR(66) NOT NULL
);
-- +goose Down
DROP TABLE eth.header_cids;
DROP TABLE eth.header_cids;

View File

@ -1,14 +1,12 @@
-- +goose Up
CREATE TABLE eth.uncle_cids (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES eth.header_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
block_hash VARCHAR(66) NOT NULL,
parent_hash VARCHAR(66) NOT NULL,
cid TEXT NOT NULL,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
reward NUMERIC NOT NULL,
UNIQUE (header_id, block_hash)
block_hash VARCHAR(66) PRIMARY KEY,
header_id VARCHAR(66) NOT NULL REFERENCES eth.header_cids (block_hash) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
parent_hash VARCHAR(66) 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
);
-- +goose Down
DROP TABLE eth.uncle_cids;
DROP TABLE eth.uncle_cids;

View File

@ -1,16 +1,15 @@
-- +goose Up
CREATE TABLE eth.transaction_cids (
id SERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES eth.header_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
tx_hash VARCHAR(66) NOT NULL,
index INTEGER NOT NULL,
cid TEXT NOT NULL,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
dst VARCHAR(66) NOT NULL,
src VARCHAR(66) NOT NULL,
tx_data BYTEA,
tx_type BYTEA,
UNIQUE (header_id, tx_hash)
header_id VARCHAR(66) NOT NULL REFERENCES eth.header_cids (block_hash) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
tx_hash VARCHAR(66) PRIMARY KEY,
cid TEXT NOT NULL,
dst VARCHAR(66) NOT NULL,
src VARCHAR(66) NOT NULL,
index INTEGER NOT NULL,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
tx_data BYTEA,
tx_type INTEGER,
value NUMERIC
);
-- +goose Down

View File

@ -1,16 +1,14 @@
-- +goose Up
CREATE TABLE eth.receipt_cids (
id SERIAL PRIMARY KEY,
tx_id INTEGER NOT NULL REFERENCES eth.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
leaf_cid TEXT NOT NULL,
leaf_mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
contract VARCHAR(66),
contract_hash VARCHAR(66),
post_state VARCHAR(66),
post_status INTEGER,
log_root VARCHAR(66),
UNIQUE (tx_id)
tx_id VARCHAR(66) PRIMARY KEY REFERENCES eth.transaction_cids (tx_hash) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
leaf_cid TEXT NOT NULL,
contract VARCHAR(66),
contract_hash VARCHAR(66),
leaf_mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
post_state VARCHAR(66),
post_status INTEGER,
log_root VARCHAR(66)
);
-- +goose Down
DROP TABLE eth.receipt_cids;
DROP TABLE eth.receipt_cids;

View File

@ -1,15 +1,14 @@
-- +goose Up
CREATE TABLE eth.state_cids (
id BIGSERIAL PRIMARY KEY,
header_id INTEGER NOT NULL REFERENCES eth.header_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
state_leaf_key VARCHAR(66),
cid TEXT NOT NULL,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
state_path BYTEA,
node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE,
UNIQUE (header_id, state_path)
header_id VARCHAR(66) NOT NULL REFERENCES eth.header_cids (block_hash) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
state_leaf_key VARCHAR(66),
cid TEXT NOT NULL,
state_path BYTEA NOT NULL,
node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
PRIMARY KEY (header_id, state_path)
);
-- +goose Down
DROP TABLE eth.state_cids;
DROP TABLE eth.state_cids;

View File

@ -1,15 +1,16 @@
-- +goose Up
CREATE TABLE eth.storage_cids (
id BIGSERIAL PRIMARY KEY,
state_id BIGINT NOT NULL REFERENCES eth.state_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
storage_leaf_key VARCHAR(66),
cid TEXT NOT NULL,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
storage_path BYTEA,
node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE,
UNIQUE (state_id, storage_path)
header_id VARCHAR(66) NOT NULL,
state_path BYTEA NOT NULL,
storage_leaf_key VARCHAR(66),
cid TEXT NOT NULL,
storage_path BYTEA NOT NULL,
node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE,
mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY (header_id, state_path) REFERENCES eth.state_cids (header_id, state_path) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
PRIMARY KEY (header_id, state_path, storage_path)
);
-- +goose Down
DROP TABLE eth.storage_cids;
DROP TABLE eth.storage_cids;

View File

@ -1,13 +1,14 @@
-- +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)
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,
FOREIGN KEY (header_id, state_path) REFERENCES eth.state_cids (header_id, state_path) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
PRIMARY KEY (header_id, state_path)
);
-- +goose Down
DROP TABLE eth.state_accounts;
DROP TABLE eth.state_accounts;

View File

@ -0,0 +1,11 @@
-- +goose Up
CREATE TABLE eth.access_list_elements (
tx_id VARCHAR(66) NOT NULL REFERENCES eth.transaction_cids (tx_hash) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
index INTEGER NOT NULL,
address VARCHAR(66),
storage_keys VARCHAR(66)[],
PRIMARY KEY (tx_id, index)
);
-- +goose Down
DROP TABLE eth.access_list_elements;

View File

@ -0,0 +1,18 @@
-- +goose Up
CREATE TABLE eth.log_cids (
leaf_cid TEXT NOT NULL,
leaf_mh_key TEXT NOT NULL REFERENCES public.blocks (key) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
rct_id VARCHAR(66) NOT NULL REFERENCES eth.receipt_cids (tx_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
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)
);
-- +goose Down
-- log indexes
DROP TABLE eth.log_cids;

View File

@ -1,69 +0,0 @@
-- +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();

View File

@ -1,76 +1,76 @@
-- +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);
-- uncle indexes
CREATE INDEX uncle_header_id_index ON eth.uncle_cids USING btree (header_id);
-- 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_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_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 account_state_path_index ON eth.state_accounts USING btree (state_path);
CREATE INDEX storage_root_index ON eth.state_accounts USING btree (storage_root);
-- access list indexes
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_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_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_mh_index;
-- access list indexes
DROP INDEX eth.access_list_storage_keys_index;
DROP INDEX eth.access_list_element_address_index;
-- state account indexes
DROP INDEX eth.storage_root_index;
DROP INDEX eth.account_state_id_index;
DROP index eth.account_state_path_index;
-- storage node indexes
DROP INDEX eth.storage_node_type_index;
@ -78,7 +78,7 @@ 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;
DROP INDEX eth.storage_state_path_index;
-- state node indexes
DROP INDEX eth.state_node_type_index;
@ -86,27 +86,26 @@ 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;
-- uncle indexes
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_index;
DROP INDEX eth.header_cid_index;
DROP INDEX eth.block_hash_index;
DROP INDEX eth.block_number_index;
DROP INDEX eth.block_number_index;

View File

@ -1,15 +0,0 @@
-- +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;

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION was_state_leaf_removed(key character varying, hash ch
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)
INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.block_hash)
WHERE state_leaf_key = key
AND block_number <= (SELECT block_number
FROM eth.header_cids
@ -98,7 +98,7 @@ LANGUAGE 'plpgsql';
-- +goose StatementEnd
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION canonical_header_id(height BIGINT) RETURNS INTEGER AS
CREATE OR REPLACE FUNCTION canonical_header_hash(height BIGINT) RETURNS character varying AS
$BODY$
DECLARE
canonical_header eth.header_cids;
@ -117,13 +117,13 @@ BEGIN
-- 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
-- if we have one header, return its hash
ELSIF header_count = 1 THEN
RETURN headers[1].id;
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.id;
RETURN canonical_header.block_hash;
END IF;
END;
$BODY$
@ -132,7 +132,7 @@ LANGUAGE 'plpgsql';
-- +goose Down
DROP FUNCTION was_state_leaf_removed;
DROP FUNCTION canonical_header_id;
DROP FUNCTION canonical_header_hash;
DROP FUNCTION canonical_header_from_array;
DROP FUNCTION has_child;
DROP TYPE child_result;
DROP TYPE child_result;

View File

@ -1,61 +0,0 @@
-- +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;

View File

@ -0,0 +1,116 @@
-- +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();

View File

@ -0,0 +1,25 @@
-- +goose Up
ALTER TABLE public.blocks SET LOGGED;
ALTER TABLE public.nodes SET LOGGED;
ALTER TABLE eth.header_cids SET LOGGED;
ALTER TABLE eth.uncle_cids SET LOGGED;
ALTER TABLE eth.transaction_cids SET LOGGED;
ALTER TABLE eth.receipt_cids SET LOGGED;
ALTER TABLE eth.state_cids SET LOGGED;
ALTER TABLE eth.storage_cids SET LOGGED;
ALTER TABLE eth.state_accounts SET LOGGED;
ALTER TABLE eth.access_list_elements SET LOGGED;
ALTER TABLE eth.log_cids SET LOGGED;
-- +goose Down
ALTER TABLE public.blocks SET UNLOGGED;
ALTER TABLE public.nodes SET UNLOGGED;
ALTER TABLE eth.header_cids SET UNLOGGED;
ALTER TABLE eth.uncle_cids SET UNLOGGED;
ALTER TABLE eth.transaction_cids SET UNLOGGED;
ALTER TABLE eth.receipt_cids SET UNLOGGED;
ALTER TABLE eth.state_cids SET UNLOGGED;
ALTER TABLE eth.storage_cids SET UNLOGGED;
ALTER TABLE eth.state_accounts SET UNLOGGED;
ALTER TABLE eth.access_list_elements SET UNLOGGED;
ALTER TABLE eth.log_cids SET UNLOGGED;

View File

@ -0,0 +1,67 @@
-- +goose Up
ALTER TABLE public.blocks
ADD CONSTRAINT pk_public_blocks PRIMARY KEY (key);
ALTER TABLE public.nodes
ADD CONSTRAINT pk_public_nodes PRIMARY KEY (node_id);
ALTER TABLE eth.header_cids
ADD CONSTRAINT pk_eth_header_cids PRIMARY KEY (block_hash);
ALTER TABLE eth.uncle_cids
ADD CONSTRAINT pk_eth_uncle_cids PRIMARY KEY (block_hash);
ALTER TABLE eth.transaction_cids
ADD CONSTRAINT pk_eth_transaction_cids PRIMARY KEY (tx_hash);
ALTER TABLE eth.receipt_cids
ADD CONSTRAINT pk_eth_receipt_cids PRIMARY KEY (tx_id);
ALTER TABLE eth.access_list_elements
ADD CONSTRAINT pk_eth_access_list_elements PRIMARY KEY (tx_id, index);
ALTER TABLE eth.log_cids
ADD CONSTRAINT pk_eth_log_cids PRIMARY KEY (rct_id, index);
ALTER TABLE eth.state_cids
ADD CONSTRAINT pk_eth_state_cids PRIMARY KEY (header_id, state_path);
ALTER TABLE eth.storage_cids
ADD CONSTRAINT pk_eth_storage_cids PRIMARY KEY (header_id, state_path, storage_path);
ALTER TABLE eth.state_accounts
ADD CONSTRAINT pk_eth_state_accounts PRIMARY KEY (header_id, state_path);
-- +goose Down
ALTER TABLE public.blocks
DROP CONSTRAINT pk_public_blocks;
ALTER TABLE public.nodes
DROP CONSTRAINT pk_public_nodes;
ALTER TABLE eth.header_cids
DROP CONSTRAINT pk_eth_header_cids;
ALTER TABLE eth.uncle_cids
DROP CONSTRAINT pk_eth_uncle_cids;
ALTER TABLE eth.transaction_cids
DROP CONSTRAINT pk_eth_transaction_cids;
ALTER TABLE eth.receipt_cids
DROP CONSTRAINT pk_eth_receipt_cids;
ALTER TABLE eth.access_list_elements
DROP CONSTRAINT pk_eth_access_list_elements;
ALTER TABLE eth.log_cids
DROP CONSTRAINT pk_eth_log_cids;
ALTER TABLE eth.state_cids
DROP CONSTRAINT pk_eth_state_cids;
ALTER TABLE eth.storage_cids
DROP CONSTRAINT pk_eth_storage_cids;
ALTER TABLE eth.state_accounts
DROP CONSTRAINT pk_eth_state_accounts;

View File

@ -0,0 +1,129 @@
-- +goose Up
ALTER TABLE eth.header_cids
ADD CONSTRAINT fk_header_mh_key
FOREIGN KEY (mh_key) REFERENCES public.blocks (key)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.header_cids
ADD CONSTRAINT fk_header_node_id
FOREIGN KEY (node_id) REFERENCES public.nodes (node_id)
ON DELETE CASCADE;
ALTER TABLE eth.uncle_cids
ADD CONSTRAINT fk_uncle_mh_key
FOREIGN KEY (mh_key) REFERENCES public.blocks (key)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.uncle_cids
ADD CONSTRAINT fk_uncle_header_id
FOREIGN KEY (header_id) REFERENCES eth.header_cids (block_hash)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.transaction_cids
ADD CONSTRAINT fk_tx_mh_key
FOREIGN KEY (mh_key) REFERENCES public.blocks (key)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.transaction_cids
ADD CONSTRAINT fk_tx_header_id
FOREIGN KEY (header_id) REFERENCES eth.header_cids (block_hash)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.receipt_cids
ADD CONSTRAINT fk_rct_leaf_mh_key
FOREIGN KEY (leaf_mh_key) REFERENCES public.blocks (key)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.receipt_cids
ADD CONSTRAINT fk_rct_tx_id
FOREIGN KEY (tx_id) REFERENCES eth.transaction_cids (tx_hash)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.state_cids
ADD CONSTRAINT fk_state_mh_key
FOREIGN KEY (mh_key) REFERENCES public.blocks (key)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.state_cids
ADD CONSTRAINT fk_state_header_id
FOREIGN KEY (header_id) REFERENCES eth.header_cids (block_hash)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.storage_cids
ADD CONSTRAINT fk_storage_mh_key
FOREIGN KEY (mh_key) REFERENCES public.blocks (key)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.storage_cids
ADD CONSTRAINT fk_storage_header_id_state_path
FOREIGN KEY (header_id, state_path) REFERENCES eth.state_cids (header_id, state_path)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.state_accounts
ADD CONSTRAINT fk_account_header_id_state_path
FOREIGN KEY (header_id, state_path) REFERENCES eth.state_cids (header_id, state_path)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.access_list_elements
ADD CONSTRAINT fk_access_list_tx_id
FOREIGN KEY (tx_id) REFERENCES eth.transaction_cids (tx_hash)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.log_cids
ADD CONSTRAINT fk_log_leaf_mh_key
FOREIGN KEY (leaf_mh_key) REFERENCES public.blocks (key)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE eth.log_cids
ADD CONSTRAINT fk_log_rct_id
FOREIGN KEY (rct_id) REFERENCES eth.receipt_cids (tx_id)
ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
-- +goose Down
ALTER TABLE eth.header_cids
DROP CONSTRAINT fk_header_mh_key;
ALTER TABLE eth.header_cids
DROP CONSTRAINT fk_header_node_id;
ALTER TABLE eth.uncle_cids
DROP CONSTRAINT fk_uncle_mh_key;
ALTER TABLE eth.uncle_cids
DROP CONSTRAINT fk_uncle_header_id;
ALTER TABLE eth.transaction_cids
DROP CONSTRAINT fk_tx_mh_key;
ALTER TABLE eth.transaction_cids
DROP CONSTRAINT fk_tx_header_id;
ALTER TABLE eth.receipt_cids
DROP CONSTRAINT fk_rct_leaf_mh_key;
ALTER TABLE eth.receipt_cids
DROP CONSTRAINT fk_rct_tx_id;
ALTER TABLE eth.state_cids
DROP CONSTRAINT fk_state_mh_key;
ALTER TABLE eth.state_cids
DROP CONSTRAINT fk_state_header_id;
ALTER TABLE eth.storage_cids
DROP CONSTRAINT fk_storage_mh_key;
ALTER TABLE eth.storage_cids
DROP CONSTRAINT fk_storage_header_id_state_path;
ALTER TABLE eth.state_accounts
DROP CONSTRAINT fk_account_header_id_state_path;
ALTER TABLE eth.access_list_elements
DROP CONSTRAINT fk_access_list_tx_id;
ALTER TABLE eth.log_cids
DROP CONSTRAINT fk_log_leaf_mh_key;
ALTER TABLE eth.log_cids
DROP CONSTRAINT fk_log_rct_id;

View File

@ -0,0 +1,14 @@
-- +goose Up
COMMENT ON TABLE public.nodes IS E'@name NodeInfo';
COMMENT ON TABLE eth.transaction_cids IS E'@name EthTransactionCids';
COMMENT ON TABLE eth.header_cids IS E'@name EthHeaderCids';
COMMENT ON COLUMN public.nodes.node_id IS E'@name ChainNodeID';
COMMENT ON COLUMN eth.header_cids.node_id IS E'@name EthNodeID';
-- +goose Down
COMMENT ON TABLE public.nodes IS NULL;
COMMENT ON TABLE eth.transaction_cids IS NULL;
COMMENT ON TABLE eth.header_cids IS NULL;
COMMENT ON COLUMN public.nodes.node_id IS NULL;
COMMENT ON COLUMN eth.header_cids.node_id IS NULL;

View File

@ -0,0 +1,111 @@
-- +goose Up
-- header indexes
CREATE INDEX block_number_index ON eth.header_cids USING brin (block_number);
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);
-- uncle indexes
CREATE INDEX uncle_header_id_index ON eth.uncle_cids USING btree (header_id);
-- transaction indexes
CREATE INDEX tx_header_id_index ON eth.transaction_cids USING btree (header_id);
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_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_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_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_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_path_index ON eth.state_accounts USING btree (state_path);
CREATE INDEX storage_root_index ON eth.state_accounts USING btree (storage_root);
-- access list indexes
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_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_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_mh_index;
-- access list indexes
DROP INDEX eth.access_list_storage_keys_index;
DROP INDEX eth.access_list_element_address_index;
-- state account indexes
DROP INDEX eth.storage_root_index;
DROP index eth.account_state_path_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_path_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;
-- 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;
-- 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_header_id_index;
-- uncle indexes
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_index;
DROP INDEX eth.header_cid_index;
DROP INDEX eth.block_number_index;

View File

@ -0,0 +1,139 @@
-- +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 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_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 Down
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;

View File

@ -0,0 +1,116 @@
-- +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')w 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();

View File

@ -0,0 +1,8 @@
-- +goose Up
CREATE TABLE IF NOT EXISTS public.blocks (
key TEXT NOT NULL,
data BYTEA NOT NULL
);
-- +goose Down
DROP TABLE public.blocks;

View File

@ -0,0 +1,11 @@
-- +goose Up
CREATE TABLE nodes (
genesis_block VARCHAR(66),
network_id VARCHAR,
node_id VARCHAR(128) NOT NULL,
client_name VARCHAR,
chain_id INTEGER DEFAULT 1
);
-- +goose Down
DROP TABLE nodes;

View File

@ -0,0 +1,5 @@
-- +goose Up
CREATE SCHEMA eth;
-- +goose Down
DROP SCHEMA eth;

View File

@ -0,0 +1,22 @@
-- +goose Up
CREATE TABLE eth.header_cids (
block_number BIGINT NOT NULL,
block_hash VARCHAR(66) NOT NULL,
parent_hash VARCHAR(66) NOT NULL,
cid TEXT NOT NULL,
td NUMERIC NOT NULL,
node_id VARCHAR(128) NOT NULL,
reward NUMERIC NOT NULL,
state_root VARCHAR(66) NOT NULL,
tx_root VARCHAR(66) NOT NULL,
receipt_root VARCHAR(66) NOT NULL,
uncle_root VARCHAR(66) NOT NULL,
bloom BYTEA NOT NULL,
timestamp BIGINT NOT NULL,
mh_key TEXT NOT NULL,
times_validated INTEGER NOT NULL DEFAULT 1,
coinbase VARCHAR(66) NOT NULL
);
-- +goose Down
DROP TABLE eth.header_cids;

View File

@ -0,0 +1,12 @@
-- +goose Up
CREATE TABLE eth.uncle_cids (
block_hash VARCHAR(66) NOT NULL,
header_id VARCHAR(66) NOT NULL,
parent_hash VARCHAR(66) NOT NULL,
cid TEXT NOT NULL,
reward NUMERIC NOT NULL,
mh_key TEXT NOT NULL
);
-- +goose Down
DROP TABLE eth.uncle_cids;

View File

@ -0,0 +1,16 @@
-- +goose Up
CREATE TABLE eth.transaction_cids (
header_id VARCHAR(66) NOT NULL,
tx_hash VARCHAR(66) NOT NULL,
cid TEXT NOT NULL,
dst VARCHAR(66) NOT NULL,
src VARCHAR(66) NOT NULL,
index INTEGER NOT NULL,
mh_key TEXT NOT NULL,
tx_data BYTEA,
tx_type INTEGER,
value NUMERIC
);
-- +goose Down
DROP TABLE eth.transaction_cids;

View File

@ -0,0 +1,14 @@
-- +goose Up
CREATE TABLE eth.receipt_cids (
tx_id VARCHAR(66) NOT NULL,
leaf_cid TEXT NOT NULL,
contract VARCHAR(66),
contract_hash VARCHAR(66),
leaf_mh_key TEXT NOT NULL,
post_state VARCHAR(66),
post_status INTEGER,
log_root VARCHAR(66)
);
-- +goose Down
DROP TABLE eth.receipt_cids;

View File

@ -0,0 +1,13 @@
-- +goose Up
CREATE TABLE eth.state_cids (
header_id VARCHAR(66) NOT NULL,
state_leaf_key VARCHAR(66),
cid TEXT NOT NULL,
state_path BYTEA NOT NULL,
node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE,
mh_key TEXT NOT NULL
);
-- +goose Down
DROP TABLE eth.state_cids;

View File

@ -0,0 +1,14 @@
-- +goose Up
CREATE TABLE eth.storage_cids (
header_id VARCHAR(66) NOT NULL,
state_path BYTEA NOT NULL,
storage_leaf_key VARCHAR(66),
cid TEXT NOT NULL,
storage_path BYTEA NOT NULL,
node_type INTEGER NOT NULL,
diff BOOLEAN NOT NULL DEFAULT FALSE,
mh_key TEXT NOT NULL
);
-- +goose Down
DROP TABLE eth.storage_cids;

View File

@ -0,0 +1,12 @@
-- +goose Up
CREATE TABLE eth.state_accounts (
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
);
-- +goose Down
DROP TABLE eth.state_accounts;

View File

@ -0,0 +1,10 @@
-- +goose Up
CREATE TABLE eth.access_list_elements (
tx_id VARCHAR(66) NOT NULL,
index INTEGER NOT NULL,
address VARCHAR(66),
storage_keys VARCHAR(66)[]
);
-- +goose Down
DROP TABLE eth.access_list_elements;

View File

@ -0,0 +1,17 @@
-- +goose Up
CREATE TABLE eth.log_cids (
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
);
-- +goose Down
-- log indexes
DROP TABLE eth.log_cids;

View File

@ -0,0 +1,25 @@
-- +goose Up
ALTER TABLE public.blocks SET UNLOGGED;
ALTER TABLE public.nodes SET UNLOGGED;
ALTER TABLE eth.header_cids SET UNLOGGED;
ALTER TABLE eth.uncle_cids SET UNLOGGED;
ALTER TABLE eth.transaction_cids SET UNLOGGED;
ALTER TABLE eth.receipt_cids SET UNLOGGED;
ALTER TABLE eth.state_cids SET UNLOGGED;
ALTER TABLE eth.storage_cids SET UNLOGGED;
ALTER TABLE eth.state_accounts SET UNLOGGED;
ALTER TABLE eth.access_list_elements SET UNLOGGED;
ALTER TABLE eth.log_cids SET UNLOGGED;
-- +goose Down
ALTER TABLE public.blocks SET LOGGED;
ALTER TABLE public.nodes SET LOGGED;
ALTER TABLE eth.header_cids SET LOGGED;
ALTER TABLE eth.uncle_cids SET LOGGED;
ALTER TABLE eth.transaction_cids SET LOGGED;
ALTER TABLE eth.receipt_cids SET LOGGED;
ALTER TABLE eth.state_cids SET LOGGED;
ALTER TABLE eth.storage_cids SET LOGGED;
ALTER TABLE eth.state_accounts SET LOGGED;
ALTER TABLE eth.access_list_elements SET LOGGED;
ALTER TABLE eth.log_cids SET LOGGED;

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 KiB

After

Width:  |  Height:  |  Size: 491 KiB

View File

@ -1,150 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<Diagram>
<ID>DATABASE</ID>
<OriginalElement>763cb2dc-728a-4fbd-a163-94dd564429aa</OriginalElement>
<OriginalElement>407978cb-39e6-453c-b9b7-c4183a4e26ef</OriginalElement>
<nodes>
<node x="508.5625" y="998.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.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="256.5" y="1031.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_accounts</node>
<node x="156.705078125" y="712.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.state_cids</node>
<node x="193.330078125" y="44.5">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks</node>
<node x="10.5" y="1009.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.storage_cids</node>
<node x="547.375" y="723.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.uncle_cids</node>
<node x="1146.375" y="0.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.goose_db_version</node>
<node x="499.455078125" y="0.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.nodes</node>
<node x="824.375" y="1042.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.access_list_element</node>
<node x="614.5" y="228.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.header_cids</node>
<node x="761.375" y="690.0">763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.eth.transaction_cids</node>
<node x="623.125" y="196.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.header_cids</node>
<node x="245.5" y="944.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.receipt_cids</node>
<node x="922.837890625" y="0.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.nodes</node>
<node x="689.794921875" y="966.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_accounts</node>
<node x="586.353515625" y="680.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.uncle_cids</node>
<node x="351.294921875" y="33.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.blocks</node>
<node x="226.353515625" y="636.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.transaction_cids</node>
<node x="10.5" y="988.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.access_list_elements</node>
<node x="800.353515625" y="669.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.state_cids</node>
<node x="152.435546875" y="1206.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.log_cids</node>
<node x="1273.837890625" y="0.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.public.goose_db_version</node>
<node x="906.794921875" y="944.0">407978cb-39e6-453c-b9b7-c4183a4e26ef.TABLE:vulcanize_test.eth.storage_cids</node>
</nodes>
<notes />
<edges>
<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="-76.5" y="83.0" />
<point x="575.955078125" y="151.63819095477388" />
<point x="532.3193997330402" y="151.63819095477388" />
<point x="532.3193997330402" y="83.0" />
<point x="-153.0" y="0.0" />
<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">
<point x="0.0" y="-61.0" />
<point x="118.0" y="922.0" />
<point x="396.353515625" y="922.0" />
<point x="0.0" y="127.0" />
</edge>
<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="48.5" y="-94.0" />
<point x="692.875" y="668.0" />
<point x="756.0" y="668.0" />
<point x="0.0" y="204.0" />
<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">
<point x="-52.25" y="-94.0" />
<point x="852.603515625" y="614.0" />
<point x="770.125" y="614.0" />
<point x="0.0" y="193.0" />
</edge>
<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="-56.5" y="-105.0" />
<point x="67.0" y="971.0" />
<point x="111.205078125" y="971.0" />
<point x="111.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 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">
<point x="-51.75" y="-105.0" />
<point x="297.25" y="912.0" />
<point x="129.669921875" y="912.0" />
<point x="129.669921875" y="175.0" />
<point x="108.0" y="175.0" />
<point x="108.0" y="165.0" />
<point x="376.544921875" y="165.0" />
<point x="-25.25" y="39.0" />
</edge>
<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">
<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="355.0" y="971.0" />
<point x="261.205078125" y="971.0" />
<point x="0.0" y="105.0" />
<point x="788.294921875" y="922.0" />
<point x="904.853515625" y="922.0" />
<point x="0.0" y="94.0" />
</edge>
<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="-48.5" y="-94.0" />
<point x="595.875" y="658.0" />
<point x="589.25" y="658.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 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="193.435546875" y="1180.0" />
<point x="0.0" y="1180.0" />
<point x="0.0" y="175.0" />
<point x="108.0" y="175.0" />
<point x="108.0" y="165.0" />
<point x="376.544921875" y="165.0" />
<point x="-25.25" y="39.0" />
</edge>
<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">
<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="180.0" y="971.0" />
<point x="261.205078125" y="971.0" />
<point x="1076.294921875" y="922.0" />
<point x="1024.794921875" y="922.0" />
<point x="1024.794921875" y="175.0" />
<point x="699.087890625" y="175.0" />
<point x="699.087890625" y="165.0" />
<point x="427.044921875" 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="400.75" y="922.0" />
<point x="396.353515625" y="922.0" />
<point x="0.0" y="127.0" />
</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">
<point x="85.0" y="-127.0" />
<point x="481.353515625" y="614.0" />
<point x="770.125" y="614.0" />
<point x="0.0" y="193.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="963.294921875" y="922.0" />
<point x="904.853515625" y="922.0" />
<point x="0.0" y="94.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="957.103515625" y="614.0" />
<point x="953.478515625" y="614.0" />
<point x="953.478515625" y="175.0" />
<point x="699.087890625" y="175.0" />
<point x="699.087890625" y="165.0" />
<point x="427.044921875" y="165.0" />
<point x="25.25" y="39.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="275.435546875" y="1180.0" />
<point x="349.0" y="1180.0" />
<point x="0.0" y="105.0" />
</edge>
<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="41.0" y="-138.0" />
<point x="350.705078125" y="1256.0" />
<point x="612.0625" y="1256.0" />
<point x="0.0" y="116.0" />
<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">
<point x="73.5" y="-193.0" />
<point x="843.625" y="165.0" />
<point x="1075.837890625" y="165.0" />
<point x="0.0" y="72.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.blocks" relationship="REFERENCES">
<point x="-70.75" y="-204.0" />
<point x="685.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 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">
<point x="48.5" y="-83.0" />
<point x="731.853515625" y="614.0" />
<point x="770.125" y="614.0" />
<point x="0.0" y="193.0" />
</edge>
<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 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">
<point x="-73.5" y="-193.0" />
<point x="696.625" y="175.0" />
<point x="699.087890625" y="175.0" />
<point x="699.087890625" y="165.0" />
<point x="427.044921875" y="165.0" />
<point x="25.25" y="39.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 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">
<point x="-48.5" y="-83.0" />
<point x="634.853515625" y="604.0" />
<point x="523.044921875" y="604.0" />
<point x="523.044921875" y="175.0" />
<point x="699.087890625" y="175.0" />
<point x="699.087890625" y="165.0" />
<point x="427.044921875" y="165.0" />
<point x="25.25" y="39.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">
<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">
<point x="-85.0" y="-127.0" />
<point x="846.375" 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.state_cids" target="763cb2dc-728a-4fbd-a163-94dd564429aa.TABLE:vulcanize_testing.public.blocks" relationship="REFERENCES">
<point x="-52.25" y="-105.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" />
<point x="311.353515625" y="614.0" />
<point x="386.353515625" y="614.0" />
<point x="386.353515625" y="175.0" />
<point x="699.087890625" y="175.0" />
<point x="699.087890625" y="165.0" />
<point x="427.044921875" y="165.0" />
<point x="25.25" y="39.0" />
</edge>
</edges>
<settings layout="Hierarchic" zoom="0.37832699619771865" showDependencies="false" x="667.5" y="779.0" />
<settings layout="Hierarchic" zoom="0.40337837837837837" showDependencies="false" x="731.0" y="730.0" />
<SelectedNodes />
<Categories>
<Category>Columns</Category>