commit
40b1709c2c
@ -1,5 +1,7 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE IF NOT EXISTS public.blocks (
|
||||
CREATE SCHEMA ipld;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ipld.blocks (
|
||||
block_number BIGINT NOT NULL,
|
||||
key TEXT NOT NULL,
|
||||
data BYTEA NOT NULL,
|
||||
@ -7,4 +9,5 @@ CREATE TABLE IF NOT EXISTS public.blocks (
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE public.blocks;
|
||||
DROP TABLE ipld.blocks;
|
||||
DROP SCHEMA ipld;
|
||||
|
@ -13,7 +13,6 @@ CREATE TABLE IF NOT EXISTS eth.header_cids (
|
||||
uncles_hash VARCHAR(66) NOT NULL,
|
||||
bloom BYTEA NOT NULL,
|
||||
timestamp BIGINT NOT NULL,
|
||||
mh_key TEXT NOT NULL,
|
||||
coinbase VARCHAR(66) NOT NULL,
|
||||
PRIMARY KEY (block_hash, block_number)
|
||||
);
|
||||
|
@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS eth.uncle_cids (
|
||||
parent_hash VARCHAR(66) NOT NULL,
|
||||
cid TEXT NOT NULL,
|
||||
reward NUMERIC NOT NULL,
|
||||
mh_key TEXT NOT NULL,
|
||||
index INT NOT NULL,
|
||||
PRIMARY KEY (block_hash, block_number)
|
||||
);
|
||||
|
||||
|
@ -7,8 +7,6 @@ CREATE TABLE IF NOT EXISTS eth.transaction_cids (
|
||||
dst VARCHAR(66),
|
||||
src VARCHAR(66) NOT NULL,
|
||||
index INTEGER NOT NULL,
|
||||
mh_key TEXT NOT NULL,
|
||||
tx_data BYTEA,
|
||||
tx_type INTEGER,
|
||||
value NUMERIC,
|
||||
PRIMARY KEY (tx_hash, header_id, block_number)
|
||||
|
@ -3,13 +3,11 @@ CREATE TABLE IF NOT EXISTS eth.receipt_cids (
|
||||
block_number BIGINT NOT NULL,
|
||||
header_id VARCHAR(66) NOT NULL,
|
||||
tx_id VARCHAR(66) NOT NULL,
|
||||
leaf_cid TEXT NOT NULL,
|
||||
cid TEXT NOT NULL,
|
||||
contract VARCHAR(66),
|
||||
contract_hash VARCHAR(66),
|
||||
leaf_mh_key TEXT NOT NULL,
|
||||
post_state VARCHAR(66),
|
||||
post_status SMALLINT,
|
||||
log_root VARCHAR(66),
|
||||
PRIMARY KEY (tx_id, header_id, block_number)
|
||||
);
|
||||
|
||||
|
@ -4,9 +4,8 @@ CREATE TABLE IF NOT EXISTS eth.state_cids (
|
||||
header_id VARCHAR(66) NOT NULL,
|
||||
state_leaf_key VARCHAR(66) NOT NULL,
|
||||
cid TEXT NOT NULL,
|
||||
state_path BYTEA NOT NULL,
|
||||
partial_path BYTEA NOT NULL,
|
||||
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
mh_key TEXT NOT NULL,
|
||||
balance NUMERIC, -- NULL if "removed"
|
||||
nonce BIGINT, -- NULL if "removed"
|
||||
code_hash VARCHAR(66), -- NULL if "removed"
|
||||
|
@ -5,9 +5,8 @@ CREATE TABLE IF NOT EXISTS eth.storage_cids (
|
||||
state_leaf_key VARCHAR(66) NOT NULL,
|
||||
storage_leaf_key VARCHAR(66) NOT NULL,
|
||||
cid TEXT NOT NULL,
|
||||
storage_path BYTEA NOT NULL,
|
||||
partial_path BYTEA NOT NULL,
|
||||
diff BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
mh_key TEXT NOT NULL,
|
||||
val BYTEA, -- NULL if "removed"
|
||||
removed BOOLEAN NOT NULL,
|
||||
PRIMARY KEY (storage_leaf_key, state_leaf_key, header_id, block_number)
|
||||
|
@ -2,8 +2,7 @@
|
||||
CREATE TABLE IF NOT EXISTS eth.log_cids (
|
||||
block_number BIGINT NOT NULL,
|
||||
header_id VARCHAR(66) NOT NULL,
|
||||
leaf_cid TEXT NOT NULL,
|
||||
leaf_mh_key TEXT NOT NULL,
|
||||
cid TEXT NOT NULL,
|
||||
rct_id VARCHAR(66) NOT NULL,
|
||||
address VARCHAR(66) NOT NULL,
|
||||
index INTEGER NOT NULL,
|
||||
@ -11,7 +10,6 @@ CREATE TABLE IF NOT EXISTS eth.log_cids (
|
||||
topic1 VARCHAR(66),
|
||||
topic2 VARCHAR(66),
|
||||
topic3 VARCHAR(66),
|
||||
log_data BYTEA,
|
||||
PRIMARY KEY (rct_id, index, header_id, block_number)
|
||||
);
|
||||
|
||||
|
21
db/migrations/00013_create_pending_tables.sql
Normal file
21
db/migrations/00013_create_pending_tables.sql
Normal file
@ -0,0 +1,21 @@
|
||||
-- +goose Up
|
||||
-- pending tx isn't tightly associated with a block height, so we can't insert the RLP encoded tx as an IPLD block
|
||||
-- in ipld.blocks since it is denormalized by block number (we could do something hacky like using head height
|
||||
-- when the block was seen, or 0 or -1 or something)
|
||||
-- instead, what we are doing for the time being is embedding the RLP here
|
||||
CREATE TABLE IF NOT EXISTS eth.pending_txs (
|
||||
tx_hash VARCHAR(66) NOT NULL PRIMARY KEY,
|
||||
block_hash VARCHAR(66) NOT NULL, -- references block_hash in pending_blocks for the pending block this tx belongs to
|
||||
timestamp BIGINT NOT NULL,
|
||||
raw BYTEA NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS eth.pending_blocks (
|
||||
block_hash VARCHAR(66) NOT NULL PRIMARY KEY,
|
||||
block_number BIGINT NOT NULL,
|
||||
raw_header BYTEA NOT NULL
|
||||
)
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE eth.pending_blocks;
|
||||
DROP TABLE eth.pending_txs;
|
@ -1,12 +0,0 @@
|
||||
-- +goose Up
|
||||
-- pending tx isn't tightly associated with a block height, so we can't insert the RLP encoded tx as an IPLD block
|
||||
-- in public.blocks since it is denormalized by block number (we could do something hacky like using head height
|
||||
-- when the block was seen, or 0 or -1 or something)
|
||||
-- instead, what we are doing for the time being is embedding the RLP here
|
||||
CREATE TABLE IF NOT EXISTS eth.pending_txs (
|
||||
tx_hash VARCHAR(66) NOT NULL PRIMARY KEY,
|
||||
raw BYTEA NOT NULL
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE eth.pending_txs;
|
@ -1,39 +1,34 @@
|
||||
-- +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 UNIQUE INDEX header_cid_block_number_index ON eth.header_cids USING btree (cid, 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 UNIQUE INDEX uncle_cid_block_number_index ON eth.uncle_cids USING btree (cid, 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 INDEX tx_cid_index ON eth.transaction_cids USING btree (cid, block_number);
|
||||
CREATE INDEX tx_mh_block_number_index ON eth.transaction_cids USING btree (mh_key, block_number);
|
||||
CREATE INDEX tx_cid_block_number_index ON eth.transaction_cids USING btree (cid, 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);
|
||||
CREATE INDEX tx_data_index ON eth.transaction_cids USING btree (tx_data);
|
||||
|
||||
-- receipt indexes
|
||||
CREATE INDEX rct_block_number_index ON eth.receipt_cids USING brin (block_number);
|
||||
CREATE INDEX rct_header_id_index ON eth.receipt_cids USING btree (header_id);
|
||||
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_cid_block_number_index ON eth.receipt_cids USING btree (cid, 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_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_cid_block_number_index ON eth.state_cids USING btree (cid, block_number);
|
||||
CREATE INDEX state_header_id_index ON eth.state_cids USING btree (header_id);
|
||||
CREATE INDEX state_path_index ON eth.state_cids USING btree (state_path);
|
||||
CREATE INDEX state_partial_path_index ON eth.state_cids USING btree (partial_path);
|
||||
CREATE INDEX state_removed_index ON eth.state_cids USING btree (removed);
|
||||
CREATE INDEX state_code_hash_index ON eth.state_cids USING btree (code_hash); -- could be useful for e.g. selecting all the state accounts with the same contract bytecode deployed
|
||||
CREATE INDEX state_leaf_key_block_number_index ON eth.state_cids(state_leaf_key, block_number DESC);
|
||||
@ -41,10 +36,9 @@ CREATE INDEX state_leaf_key_block_number_index ON eth.state_cids(state_leaf_key,
|
||||
-- storage node indexes
|
||||
CREATE INDEX storage_block_number_index ON eth.storage_cids USING brin (block_number);
|
||||
CREATE INDEX storage_state_leaf_key_index ON eth.storage_cids USING btree (state_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_cid_block_number_index ON eth.storage_cids USING btree (cid, block_number);
|
||||
CREATE INDEX storage_header_id_index ON eth.storage_cids USING btree (header_id);
|
||||
CREATE INDEX storage_path_index ON eth.storage_cids USING btree (storage_path);
|
||||
CREATE INDEX storage_partial_path_index ON eth.storage_cids USING btree (partial_path);
|
||||
CREATE INDEX storage_removed_index ON eth.storage_cids USING btree (removed);
|
||||
CREATE INDEX storage_leaf_key_block_number_index ON eth.storage_cids(storage_leaf_key, block_number DESC);
|
||||
|
||||
@ -56,25 +50,21 @@ CREATE INDEX access_list_storage_keys_index ON eth.access_list_elements USING gi
|
||||
-- log indexes
|
||||
CREATE INDEX log_block_number_index ON eth.log_cids USING brin (block_number);
|
||||
CREATE INDEX log_header_id_index ON eth.log_cids USING btree (header_id);
|
||||
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_cid_block_number_index ON eth.log_cids USING btree (cid, block_number);
|
||||
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);
|
||||
CREATE INDEX log_data_index ON eth.log_cids USING btree (log_data);
|
||||
|
||||
-- +goose Down
|
||||
-- log indexes
|
||||
DROP INDEX eth.log_data_index;
|
||||
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_cid_block_number_index;
|
||||
DROP INDEX eth.log_header_id_index;
|
||||
DROP INDEX eth.log_block_number_index;
|
||||
|
||||
@ -85,10 +75,9 @@ DROP INDEX eth.access_list_block_number_index;
|
||||
|
||||
-- storage node indexes
|
||||
DROP INDEX eth.storage_removed_index;
|
||||
DROP INDEX eth.storage_path_index;
|
||||
DROP INDEX eth.storage_partial_path_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_cid_block_number_index;
|
||||
DROP INDEX eth.storage_leaf_key_index;
|
||||
DROP INDEX eth.storage_state_leaf_key_index;
|
||||
DROP INDEX eth.storage_block_number_index;
|
||||
@ -97,38 +86,33 @@ DROP INDEX eth.storage_leaf_key_block_number_index;
|
||||
-- state node indexes
|
||||
DROP INDEX eth.state_code_hash_index;
|
||||
DROP INDEX eth.state_removed_index;
|
||||
DROP INDEX eth.state_path_index;
|
||||
DROP INDEX eth.state_partial_path_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_cid_block_number_index;
|
||||
DROP INDEX eth.state_block_number_index;
|
||||
DROP INDEX eth.state_leaf_key_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_cid_block_number_index;
|
||||
DROP INDEX eth.rct_header_id_index;
|
||||
DROP INDEX eth.rct_block_number_index;
|
||||
|
||||
-- transaction indexes
|
||||
DROP INDEX eth.tx_data_index;
|
||||
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_cid_block_number_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_cid_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_cid_block_number_index;
|
||||
DROP INDEX eth.header_block_number_index;
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- +goose Up
|
||||
SELECT create_hypertable('public.blocks', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||
SELECT create_hypertable('ipld.blocks', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||
SELECT create_hypertable('eth.header_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||
SELECT create_hypertable('eth.uncle_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||
SELECT create_hypertable('eth.transaction_cids', 'block_number', migrate_data => true, chunk_time_interval => 32768);
|
||||
@ -27,7 +27,7 @@ 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);
|
||||
CREATE TABLE ipld.blocks_i (LIKE ipld.blocks INCLUDING ALL);
|
||||
|
||||
-- migrate data
|
||||
INSERT INTO eth.log_cids_i (SELECT * FROM eth.log_cids);
|
||||
@ -38,7 +38,7 @@ 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);
|
||||
INSERT INTO ipld.blocks_i (SELECT * FROM ipld.blocks);
|
||||
|
||||
-- drop hypertables
|
||||
DROP TABLE eth.log_cids;
|
||||
@ -49,7 +49,7 @@ DROP TABLE eth.receipt_cids;
|
||||
DROP TABLE eth.transaction_cids;
|
||||
DROP TABLE eth.uncle_cids;
|
||||
DROP TABLE eth.header_cids;
|
||||
DROP TABLE public.blocks;
|
||||
DROP TABLE ipld.blocks;
|
||||
|
||||
-- rename new tables
|
||||
ALTER TABLE eth.log_cids_i RENAME TO log_cids;
|
||||
@ -60,4 +60,4 @@ 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;
|
||||
ALTER TABLE ipld.blocks_i RENAME TO blocks;
|
||||
|
160
schema.sql
160
schema.sql
@ -44,6 +44,13 @@ CREATE SCHEMA eth;
|
||||
CREATE SCHEMA eth_meta;
|
||||
|
||||
|
||||
--
|
||||
-- Name: ipld; Type: SCHEMA; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
CREATE SCHEMA ipld;
|
||||
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_table_access_method = heap;
|
||||
@ -66,7 +73,6 @@ CREATE TABLE eth.header_cids (
|
||||
uncles_hash character varying(66) NOT NULL,
|
||||
bloom bytea NOT NULL,
|
||||
"timestamp" bigint NOT NULL,
|
||||
mh_key text NOT NULL,
|
||||
coinbase character varying(66) NOT NULL
|
||||
);
|
||||
|
||||
@ -315,16 +321,14 @@ CREATE TABLE eth.access_list_elements (
|
||||
CREATE TABLE eth.log_cids (
|
||||
block_number bigint NOT NULL,
|
||||
header_id character varying(66) NOT NULL,
|
||||
leaf_cid text NOT NULL,
|
||||
leaf_mh_key text NOT NULL,
|
||||
cid text NOT NULL,
|
||||
rct_id character varying(66) NOT NULL,
|
||||
address character varying(66) NOT NULL,
|
||||
index integer NOT NULL,
|
||||
topic0 character varying(66),
|
||||
topic1 character varying(66),
|
||||
topic2 character varying(66),
|
||||
topic3 character varying(66),
|
||||
log_data bytea
|
||||
topic3 character varying(66)
|
||||
);
|
||||
|
||||
|
||||
@ -334,6 +338,8 @@ CREATE TABLE eth.log_cids (
|
||||
|
||||
CREATE TABLE eth.pending_txs (
|
||||
tx_hash character varying(66) NOT NULL,
|
||||
block_hash character varying(66) NOT NULL,
|
||||
"timestamp" bigint NOT NULL,
|
||||
raw bytea NOT NULL
|
||||
);
|
||||
|
||||
@ -346,13 +352,11 @@ CREATE TABLE eth.receipt_cids (
|
||||
block_number bigint NOT NULL,
|
||||
header_id character varying(66) NOT NULL,
|
||||
tx_id character varying(66) NOT NULL,
|
||||
leaf_cid text NOT NULL,
|
||||
cid text NOT NULL,
|
||||
contract character varying(66),
|
||||
contract_hash character varying(66),
|
||||
leaf_mh_key text NOT NULL,
|
||||
post_state character varying(66),
|
||||
post_status smallint,
|
||||
log_root character varying(66)
|
||||
post_status smallint
|
||||
);
|
||||
|
||||
|
||||
@ -365,9 +369,8 @@ CREATE TABLE eth.state_cids (
|
||||
header_id character varying(66) NOT NULL,
|
||||
state_leaf_key character varying(66) NOT NULL,
|
||||
cid text NOT NULL,
|
||||
state_path bytea NOT NULL,
|
||||
partial_path bytea NOT NULL,
|
||||
diff boolean DEFAULT false NOT NULL,
|
||||
mh_key text NOT NULL,
|
||||
balance numeric,
|
||||
nonce bigint,
|
||||
code_hash character varying(66),
|
||||
@ -386,9 +389,8 @@ CREATE TABLE eth.storage_cids (
|
||||
state_leaf_key character varying(66) NOT NULL,
|
||||
storage_leaf_key character varying(66) NOT NULL,
|
||||
cid text NOT NULL,
|
||||
storage_path bytea NOT NULL,
|
||||
partial_path bytea NOT NULL,
|
||||
diff boolean DEFAULT false NOT NULL,
|
||||
mh_key text NOT NULL,
|
||||
val bytea,
|
||||
removed boolean NOT NULL
|
||||
);
|
||||
@ -406,8 +408,6 @@ CREATE TABLE eth.transaction_cids (
|
||||
dst character varying(66),
|
||||
src character varying(66) NOT NULL,
|
||||
index integer NOT NULL,
|
||||
mh_key text NOT NULL,
|
||||
tx_data bytea,
|
||||
tx_type integer,
|
||||
value numeric
|
||||
);
|
||||
@ -431,7 +431,7 @@ CREATE TABLE eth.uncle_cids (
|
||||
parent_hash character varying(66) NOT NULL,
|
||||
cid text NOT NULL,
|
||||
reward numeric NOT NULL,
|
||||
mh_key text NOT NULL
|
||||
index integer NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@ -577,10 +577,10 @@ CREATE TABLE eth_meta.watched_addresses (
|
||||
|
||||
|
||||
--
|
||||
-- Name: blocks; Type: TABLE; Schema: public; Owner: -
|
||||
-- Name: blocks; Type: TABLE; Schema: ipld; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public.blocks (
|
||||
CREATE TABLE ipld.blocks (
|
||||
block_number bigint NOT NULL,
|
||||
key text NOT NULL,
|
||||
data bytea NOT NULL
|
||||
@ -746,10 +746,10 @@ ALTER TABLE ONLY eth_meta.watched_addresses
|
||||
|
||||
|
||||
--
|
||||
-- Name: blocks blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
-- Name: blocks blocks_pkey; Type: CONSTRAINT; Schema: ipld; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.blocks
|
||||
ALTER TABLE ONLY ipld.blocks
|
||||
ADD CONSTRAINT blocks_pkey PRIMARY KEY (key, block_number);
|
||||
|
||||
|
||||
@ -806,17 +806,10 @@ CREATE INDEX header_block_number_index ON eth.header_cids USING brin (block_numb
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_cid_index; Type: INDEX; Schema: eth; Owner: -
|
||||
-- Name: header_cid_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX header_cid_index ON eth.header_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: header_mh_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX header_mh_block_number_index ON eth.header_cids USING btree (mh_key, block_number);
|
||||
CREATE UNIQUE INDEX header_cid_block_number_index ON eth.header_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
@ -834,17 +827,10 @@ CREATE INDEX log_block_number_index ON eth.log_cids USING brin (block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: log_cid_index; Type: INDEX; Schema: eth; Owner: -
|
||||
-- Name: log_cid_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX log_cid_index ON eth.log_cids USING btree (leaf_cid);
|
||||
|
||||
|
||||
--
|
||||
-- Name: log_data_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX log_data_index ON eth.log_cids USING btree (log_data);
|
||||
CREATE INDEX log_cid_block_number_index ON eth.log_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
@ -854,13 +840,6 @@ CREATE INDEX log_data_index ON eth.log_cids USING btree (log_data);
|
||||
CREATE INDEX log_header_id_index ON eth.log_cids USING btree (header_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: log_leaf_mh_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX log_leaf_mh_block_number_index ON eth.log_cids USING btree (leaf_mh_key, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: log_topic0_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
@ -896,6 +875,13 @@ CREATE INDEX log_topic3_index ON eth.log_cids USING btree (topic3);
|
||||
CREATE INDEX rct_block_number_index ON eth.receipt_cids USING brin (block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: rct_cid_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX rct_cid_block_number_index ON eth.receipt_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: rct_contract_hash_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
@ -917,20 +903,6 @@ CREATE INDEX rct_contract_index ON eth.receipt_cids USING btree (contract);
|
||||
CREATE INDEX rct_header_id_index ON eth.receipt_cids USING btree (header_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: rct_leaf_cid_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX rct_leaf_cid_index ON eth.receipt_cids USING btree (leaf_cid);
|
||||
|
||||
|
||||
--
|
||||
-- Name: rct_leaf_mh_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX rct_leaf_mh_block_number_index ON eth.receipt_cids USING btree (leaf_mh_key, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: state_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
@ -939,10 +911,10 @@ CREATE INDEX state_block_number_index ON eth.state_cids USING brin (block_number
|
||||
|
||||
|
||||
--
|
||||
-- Name: state_cid_index; Type: INDEX; Schema: eth; Owner: -
|
||||
-- Name: state_cid_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX state_cid_index ON eth.state_cids USING btree (cid);
|
||||
CREATE INDEX state_cid_block_number_index ON eth.state_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
@ -967,17 +939,10 @@ CREATE INDEX state_leaf_key_block_number_index ON eth.state_cids USING btree (st
|
||||
|
||||
|
||||
--
|
||||
-- Name: state_mh_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
-- Name: state_partial_path_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX state_mh_block_number_index ON eth.state_cids USING btree (mh_key, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: state_path_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX state_path_index ON eth.state_cids USING btree (state_path);
|
||||
CREATE INDEX state_partial_path_index ON eth.state_cids USING btree (partial_path);
|
||||
|
||||
|
||||
--
|
||||
@ -1002,10 +967,10 @@ CREATE INDEX storage_block_number_index ON eth.storage_cids USING brin (block_nu
|
||||
|
||||
|
||||
--
|
||||
-- Name: storage_cid_index; Type: INDEX; Schema: eth; Owner: -
|
||||
-- Name: storage_cid_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX storage_cid_index ON eth.storage_cids USING btree (cid);
|
||||
CREATE INDEX storage_cid_block_number_index ON eth.storage_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
@ -1023,17 +988,10 @@ CREATE INDEX storage_leaf_key_block_number_index ON eth.storage_cids USING btree
|
||||
|
||||
|
||||
--
|
||||
-- Name: storage_mh_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
-- Name: storage_partial_path_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX storage_mh_block_number_index ON eth.storage_cids USING btree (mh_key, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: storage_path_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX storage_path_index ON eth.storage_cids USING btree (storage_path);
|
||||
CREATE INDEX storage_partial_path_index ON eth.storage_cids USING btree (partial_path);
|
||||
|
||||
|
||||
--
|
||||
@ -1065,17 +1023,10 @@ CREATE INDEX tx_block_number_index ON eth.transaction_cids USING brin (block_num
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_cid_index; Type: INDEX; Schema: eth; Owner: -
|
||||
-- Name: tx_cid_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX tx_cid_index ON eth.transaction_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_data_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX tx_data_index ON eth.transaction_cids USING btree (tx_data);
|
||||
CREATE INDEX tx_cid_block_number_index ON eth.transaction_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
@ -1092,13 +1043,6 @@ CREATE INDEX tx_dst_index ON eth.transaction_cids USING btree (dst);
|
||||
CREATE INDEX tx_header_id_index ON eth.transaction_cids USING btree (header_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_mh_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX tx_mh_block_number_index ON eth.transaction_cids USING btree (mh_key, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_src_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
@ -1113,6 +1057,13 @@ CREATE INDEX tx_src_index ON eth.transaction_cids USING btree (src);
|
||||
CREATE INDEX uncle_block_number_index ON eth.uncle_cids USING brin (block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: uncle_cid_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX uncle_cid_block_number_index ON eth.uncle_cids USING btree (cid, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: uncle_header_id_index; Type: INDEX; Schema: eth; Owner: -
|
||||
--
|
||||
@ -1121,17 +1072,10 @@ CREATE INDEX uncle_header_id_index ON eth.uncle_cids USING btree (header_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: uncle_mh_block_number_index; Type: INDEX; Schema: eth; Owner: -
|
||||
-- Name: blocks_block_number_idx; Type: INDEX; Schema: ipld; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX uncle_mh_block_number_index ON eth.uncle_cids USING btree (mh_key, block_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: blocks_block_number_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX blocks_block_number_idx ON public.blocks USING btree (block_number DESC);
|
||||
CREATE INDEX blocks_block_number_idx ON ipld.blocks USING btree (block_number DESC);
|
||||
|
||||
|
||||
--
|
||||
@ -1247,10 +1191,10 @@ CREATE TRIGGER ts_insert_blocker BEFORE INSERT ON eth.uncle_cids FOR EACH ROW EX
|
||||
|
||||
|
||||
--
|
||||
-- Name: blocks ts_insert_blocker; Type: TRIGGER; Schema: public; Owner: -
|
||||
-- Name: blocks ts_insert_blocker; Type: TRIGGER; Schema: ipld; Owner: -
|
||||
--
|
||||
|
||||
CREATE TRIGGER ts_insert_blocker BEFORE INSERT ON public.blocks FOR EACH ROW EXECUTE FUNCTION _timescaledb_internal.insert_blocker();
|
||||
CREATE TRIGGER ts_insert_blocker BEFORE INSERT ON ipld.blocks FOR EACH ROW EXECUTE FUNCTION _timescaledb_internal.insert_blocker();
|
||||
|
||||
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user