Merge pull request #139 from roysc/v5-cleanup

Clean up
This commit is contained in:
Ian Norden 2023-08-01 08:35:25 -05:00 committed by GitHub
commit 146282fb7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 189 deletions

View File

@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run docker build
run: make docker-build
run: docker compose build
test:
# Add a dummy job to avoid failing GitHub CI checks.
# Other checks to be added later.

View File

@ -4,24 +4,23 @@ on:
types: [published, edited]
jobs:
build:
name: Run docker build
name: Build and publish image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get the version
id: vars
- id: vars
name: Output SHA and version tag
run: |
echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})
- name: Run docker build
run: make docker-build
- name: Tag docker image
run: docker tag cerc/ipld-eth-db git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.sha}}
- name: Tag docker image
run: docker tag git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.sha}} git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.tag}}
- name: Docker Login
run: echo ${{ secrets.GITEA_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
- name: Docker Push
run: docker push git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.sha}}
- name: Docker Push with TAG to git.vdb.to
run: docker push git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.tag}}
echo sha=$(echo ${GITHUB_SHA:0:7}) >> "$GITHUB_OUTPUT"
echo tag=$(echo ${GITHUB_REF#refs/tags/}) >> "$GITHUB_OUTPUT""
- name: Build and tag image
run: |
docker build . \
-t cerc-io/ipld-eth-db \
-t git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.sha}} \
-t git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.tag}}
- name: Push image tags
run: |
echo ${{ secrets.GITEA_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
docker push git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.sha}}
docker push git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:${{steps.vars.outputs.tag}}

View File

@ -111,17 +111,6 @@ import:
test -n "$(NAME)" # $$NAME
psql $(NAME) < schema.sql
## Build docker image with schema
.PHONY: docker-build
docker-build:
docker-compose -f docker-compose.test.yml build
# ## Build docker image for migration
# .PHONY: docker-concise-migration-build
# docker-concise-migration-build:
# docker build -t cerc/concise-migration-build -f ./db/Dockerfile .
.PHONY: test-migrations
test-migrations: $(GOOSE)
./scripts/test_migration.sh

View File

@ -1,13 +1,14 @@
version: '3.2'
services:
migrations:
restart: on-failure
depends_on:
- ipld-eth-db
# Use local build
build:
context: .
dockerfile: Dockerfile
# Use an existing image
image: cerc/ipld-eth-db
# Build image using local context
build: .
environment:
DATABASE_USER: "vdbm"
DATABASE_NAME: "cerc_testing"

View File

@ -29,62 +29,6 @@ $$
language sql;
-- +goose StatementEnd
-- +goose StatementBegin
-- duplicate of eth.header_cids as a separate type: if we use the table directly, dropping the hypertables
-- on downgrade of step 00018 will fail due to the dependency on this type.
CREATE TYPE header_result AS (
block_number bigint,
block_hash character varying(66),
parent_hash character varying(66),
cid text,
td numeric,
node_ids character varying(128)[],
reward numeric,
state_root character varying(66),
tx_root character varying(66),
receipt_root character varying(66),
uncles_hash character varying(66),
bloom bytea,
"timestamp" bigint,
coinbase character varying(66),
canonical bool
);
CREATE TYPE child_result AS (
has_child BOOLEAN,
children header_result[]
);
CREATE OR REPLACE FUNCTION get_child(hash VARCHAR(66), height BIGINT) RETURNS child_result AS
$BODY$
DECLARE
child_height INT;
temp_child header_result;
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
AND canonical = true
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 AND canonical = true
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_hash(height BIGINT) RETURNS character varying AS
$BODY$
@ -97,5 +41,3 @@ LANGUAGE sql;
DROP FUNCTION was_state_leaf_removed;
DROP FUNCTION was_state_leaf_removed_by_number;
DROP FUNCTION canonical_header_hash;
DROP FUNCTION get_child;
DROP TYPE child_result;

View File

@ -1,30 +0,0 @@
version: '3.2'
services:
migrations:
restart: on-failure
depends_on:
- ipld-eth-db
# Use local build
#build:
#context: .
#dockerfile: Dockerfile
# Use an existing image
image: cerc/ipld-eth-db:v5.0.0-alpha
environment:
DATABASE_USER: "vdbm"
DATABASE_NAME: "cerc_testing"
DATABASE_PASSWORD: "password"
DATABASE_HOSTNAME: "ipld-eth-db"
DATABASE_PORT: 5432
ipld-eth-db:
image: timescale/timescaledb:latest-pg14
restart: always
command: ["postgres", "-c", "log_statement=all"]
environment:
POSTGRES_USER: "vdbm"
POSTGRES_DB: "cerc_testing"
POSTGRES_PASSWORD: "password"
ports:
- "127.0.0.1:8077:5432"

View File

@ -51,39 +51,6 @@ CREATE SCHEMA eth_meta;
CREATE SCHEMA ipld;
--
-- Name: header_result; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.header_result AS (
block_number bigint,
block_hash character varying(66),
parent_hash character varying(66),
cid text,
td numeric,
node_ids character varying(128)[],
reward numeric,
state_root character varying(66),
tx_root character varying(66),
receipt_root character varying(66),
uncles_hash character varying(66),
bloom bytea,
"timestamp" bigint,
coinbase character varying(66),
canonical boolean
);
--
-- Name: child_result; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.child_result AS (
has_child boolean,
children public.header_result[]
);
--
-- Name: canonical_header_hash(bigint); Type: FUNCTION; Schema: public; Owner: -
--
@ -95,40 +62,6 @@ CREATE FUNCTION public.canonical_header_hash(height bigint) RETURNS character va
$$;
--
-- Name: get_child(character varying, bigint); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.get_child(hash character varying, height bigint) RETURNS public.child_result
LANGUAGE plpgsql
AS $$
DECLARE
child_height INT;
temp_child header_result;
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
AND canonical = true
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 AND canonical = true
LOOP
new_child_result.children = array_append(new_child_result.children, temp_child);
END LOOP;
END IF;
RETURN new_child_result;
END
$$;
--
-- Name: get_storage_at_by_hash(text, text, text); Type: FUNCTION; Schema: public; Owner: -
--