From 82988a3472476b3825fccee0749a3b5e9743a1f2 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Tue, 28 May 2024 22:24:28 +0800 Subject: [PATCH 1/3] Add eth.blob_hashes table Map transaction hashes to (externally stored) blob versioned hashes. --- .../00022_create_eth_blob_hash_cids_table.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/migrations/00022_create_eth_blob_hash_cids_table.sql diff --git a/db/migrations/00022_create_eth_blob_hash_cids_table.sql b/db/migrations/00022_create_eth_blob_hash_cids_table.sql new file mode 100644 index 0000000..f0f2386 --- /dev/null +++ b/db/migrations/00022_create_eth_blob_hash_cids_table.sql @@ -0,0 +1,12 @@ +-- +goose Up +CREATE TABLE eth.blob_hashes ( + tx_hash VARCHAR(66) NOT NULL, + index INTEGER NOT NULL, + blob_hash BYTEA NOT NULL +); + +CREATE UNIQUE INDEX blob_hashes_tx_hash_index ON eth.blob_hashes(tx_hash, index); + +-- +goose Down +DROP INDEX eth.blob_hashes_tx_hash_index; +DROP TABLE eth.blob_hashes; -- 2.45.2 From 375c08de68f62d7192c7903b1fe0c848436f61a4 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Thu, 25 Jul 2024 19:16:19 +0800 Subject: [PATCH 2/3] update schema.sql --- schema.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/schema.sql b/schema.sql index d426acc..4be10e3 100644 --- a/schema.sql +++ b/schema.sql @@ -190,6 +190,17 @@ SET default_tablespace = ''; SET default_table_access_method = heap; +-- +-- Name: blob_hashes; Type: TABLE; Schema: eth; Owner: - +-- + +CREATE TABLE eth.blob_hashes ( + tx_hash character varying(66) NOT NULL, + index integer NOT NULL, + blob_hash bytea NOT NULL +); + + -- -- Name: header_cids; Type: TABLE; Schema: eth; Owner: - -- @@ -554,6 +565,13 @@ ALTER TABLE ONLY public.nodes ADD CONSTRAINT nodes_pkey PRIMARY KEY (node_id); +-- +-- Name: blob_hashes_tx_hash_index; Type: INDEX; Schema: eth; Owner: - +-- + +CREATE UNIQUE INDEX blob_hashes_tx_hash_index ON eth.blob_hashes USING btree (tx_hash, index); + + -- -- Name: header_block_number_index; Type: INDEX; Schema: eth; Owner: - -- -- 2.45.2 From c36d2907c1e13ef0cc6c77c77da43db59959e3b8 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Thu, 25 Jul 2024 20:04:48 +0800 Subject: [PATCH 3/3] fix migration version --- .gitea/workflows/on-pr.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/on-pr.yaml b/.gitea/workflows/on-pr.yaml index 0949d02..4599779 100644 --- a/.gitea/workflows/on-pr.yaml +++ b/.gitea/workflows/on-pr.yaml @@ -14,9 +14,10 @@ jobs: - name: Check migration version timeout-minutes: 1 run: | + MIGRATION_VERSION=$(ls db/migrations/*.sql | wc -l) while version=$(docker compose run --rm migrations version 2>&1 | tail -1 | awk '{print $(NF)}') - [[ $version != 21 ]]; do + [[ $version != $MIGRATION_VERSION ]]; do echo "Incorrect version: $version" echo "Retrying..." done -- 2.45.2