From 4714610b726d360fb7836392964c4c5e5375aca5 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 16 Nov 2022 14:13:10 -0600 Subject: [PATCH] Use get_storage_at DB functions. (#205) * Use new get_storage_at DB functions. * Use latest ipld-eth-db for tests. --- .github/workflows/on-pr-publish.yaml | 2 +- .github/workflows/run_unit_test.sh | 3 ++- docker-compose.yml | 2 +- pkg/eth/ipld_retriever.go | 37 ++-------------------------- 4 files changed, 6 insertions(+), 38 deletions(-) diff --git a/.github/workflows/on-pr-publish.yaml b/.github/workflows/on-pr-publish.yaml index 9308f676..fcb7af07 100644 --- a/.github/workflows/on-pr-publish.yaml +++ b/.github/workflows/on-pr-publish.yaml @@ -30,7 +30,7 @@ jobs: with: STACK_ORCHESTRATOR_REF: "f2fd766f5400fcb9eb47b50675d2e3b1f2753702" GO_ETHEREUM_REF: "2ddad81c1a04ff494a706f2f757a0f75d2616fbd" - IPLD_ETH_DB_REF: "d4d704616ba0f87733853c78787bf54c9868d2ac" + IPLD_ETH_DB_REF: "6c00c38cc4e1db6f7c4cecbb62fdfd540fba50d6" build: name: Run docker build runs-on: ubuntu-latest diff --git a/.github/workflows/run_unit_test.sh b/.github/workflows/run_unit_test.sh index c1c5e182..7a311477 100755 --- a/.github/workflows/run_unit_test.sh +++ b/.github/workflows/run_unit_test.sh @@ -1,6 +1,7 @@ #!/bin/bash set -e +set -o pipefail # Set up repo start_dir=$(pwd) @@ -21,7 +22,7 @@ sleep 60 # Remove old logs so there's no confusion, then run test rm -f /tmp/test.log /tmp/return_test.txt -PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=localhost DATABASE_NAME=vulcanize_testing make test > /tmp/test.log +PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=localhost DATABASE_NAME=vulcanize_testing make test | tee /tmp/test.log echo $? > /tmp/return_test.txt # Clean up diff --git a/docker-compose.yml b/docker-compose.yml index 805eac62..2051ec71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: restart: on-failure depends_on: - ipld-eth-db - image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v4.2.1-alpha-unstable + image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v4.2.3-alpha environment: DATABASE_USER: "vdbm" DATABASE_NAME: "vulcanize_testing" diff --git a/pkg/eth/ipld_retriever.go b/pkg/eth/ipld_retriever.go index dc18fa68..2cbdcaea 100644 --- a/pkg/eth/ipld_retriever.go +++ b/pkg/eth/ipld_retriever.go @@ -261,41 +261,8 @@ const ( AND header_cids.block_number <= $2 ORDER BY header_cids.block_number DESC LIMIT 1` - RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockNumberPgStr = `SELECT storage_cids.cid, storage_cids.mh_key, storage_cids.node_type, was_state_leaf_removed($1, $3) AS state_leaf_removed - FROM eth.storage_cids - INNER JOIN eth.state_cids ON ( - storage_cids.header_id = state_cids.header_id - AND storage_cids.state_path = state_cids.state_path - AND storage_cids.block_number = state_cids.block_number - ) - INNER JOIN eth.header_cids ON ( - state_cids.header_id = header_cids.block_hash - AND state_cids.block_number = header_cids.block_number - ) - WHERE state_leaf_key = $1 - AND storage_leaf_key = $2 - AND header_cids.block_number <= $3 - ORDER BY header_cids.block_number DESC - LIMIT 1` - RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `SELECT storage_cids.cid, storage_cids.mh_key, storage_cids.block_number, storage_cids.node_type, was_state_leaf_removed($1, $3) AS state_leaf_removed - FROM eth.storage_cids - INNER JOIN eth.state_cids ON ( - storage_cids.header_id = state_cids.header_id - AND storage_cids.state_path = state_cids.state_path - AND storage_cids.block_number = state_cids.block_number - ) - INNER JOIN eth.header_cids ON ( - state_cids.header_id = header_cids.block_hash - AND state_cids.block_number = header_cids.block_number - ) - WHERE state_leaf_key = $1 - AND storage_leaf_key = $2 - AND header_cids.block_number <= (SELECT block_number - FROM eth.header_cids - WHERE block_hash = $3) - AND header_cids.block_hash = (SELECT canonical_header_hash(header_cids.block_number)) - ORDER BY header_cids.block_number DESC - LIMIT 1` + RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockNumberPgStr = `SELECT cid, mh_key, block_number, node_type, state_leaf_removed FROM get_storage_at_by_number($1, $2, $3)` + RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `SELECT cid, mh_key, block_number, node_type, state_leaf_removed FROM get_storage_at_by_hash($1, $2, $3)` ) var EmptyNodeValue = make([]byte, common.HashLength)