From b9be09a89ea4bc3fe5d5e3519b69804ca27b86ed Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Mon, 14 Nov 2022 23:09:45 -0600 Subject: [PATCH 1/7] Use new get_storage_at DB functions. --- pkg/eth/ipld_retriever.go | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/pkg/eth/ipld_retriever.go b/pkg/eth/ipld_retriever.go index dc18fa68..b93f8ad4 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 eth.get_storage_at_by_number($1, $2, $3)` + RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `SELECT cid, mh_key, block_number, node_type, state_leaf_removed FROM eth.get_storage_at_by_hash($1, $2, $3)` ) var EmptyNodeValue = make([]byte, common.HashLength) -- 2.45.2 From e11b478ee2e0840e930f24a8c39753b89d5f09dd Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Tue, 15 Nov 2022 19:41:38 -0600 Subject: [PATCH 2/7] public, not eth --- pkg/eth/ipld_retriever.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/eth/ipld_retriever.go b/pkg/eth/ipld_retriever.go index b93f8ad4..8c613a84 100644 --- a/pkg/eth/ipld_retriever.go +++ b/pkg/eth/ipld_retriever.go @@ -261,8 +261,8 @@ const ( AND header_cids.block_number <= $2 ORDER BY header_cids.block_number DESC LIMIT 1` - RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockNumberPgStr = `SELECT cid, mh_key, block_number, node_type, state_leaf_removed FROM eth.get_storage_at_by_number($1, $2, $3)` - RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr = `SELECT cid, mh_key, block_number, node_type, state_leaf_removed FROM eth.get_storage_at_by_hash($1, $2, $3)` + 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) @@ -667,8 +667,10 @@ func (r *IPLDRetriever) RetrieveAccountByAddressAndBlockNumber(address common.Ad func (r *IPLDRetriever) RetrieveStorageAtByAddressAndStorageSlotAndBlockHash(address common.Address, key, hash common.Hash) (string, []byte, []byte, error) { storageResult := new(nodeInfo) stateLeafKey := crypto.Keccak256Hash(address.Bytes()) - storageHash := crypto.Keccak256Hash(key.Bytes()) - if err := r.db.Get(storageResult, RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr, stateLeafKey.Hex(), storageHash.Hex(), hash.Hex()); err != nil { + //storageHash := crypto.Keccak256Hash(key.Bytes()) + if err := r.db.Get(storageResult, RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr, + stateLeafKey.Hex(), + "0xc72d34190eb49919ab169f38b9ed5dd83409e7b11afaa2ef0ef3137f6e700b39", hash.Hex()); err != nil { return "", nil, nil, err } if storageResult.StateLeafRemoved || storageResult.NodeType == removedNode { -- 2.45.2 From f4ee261dc7894d3276aefaff1113d3743cd8be2c Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Tue, 15 Nov 2022 20:08:34 -0600 Subject: [PATCH 3/7] Remove debugging code. --- pkg/eth/ipld_retriever.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/eth/ipld_retriever.go b/pkg/eth/ipld_retriever.go index 8c613a84..2cbdcaea 100644 --- a/pkg/eth/ipld_retriever.go +++ b/pkg/eth/ipld_retriever.go @@ -667,10 +667,8 @@ func (r *IPLDRetriever) RetrieveAccountByAddressAndBlockNumber(address common.Ad func (r *IPLDRetriever) RetrieveStorageAtByAddressAndStorageSlotAndBlockHash(address common.Address, key, hash common.Hash) (string, []byte, []byte, error) { storageResult := new(nodeInfo) stateLeafKey := crypto.Keccak256Hash(address.Bytes()) - //storageHash := crypto.Keccak256Hash(key.Bytes()) - if err := r.db.Get(storageResult, RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr, - stateLeafKey.Hex(), - "0xc72d34190eb49919ab169f38b9ed5dd83409e7b11afaa2ef0ef3137f6e700b39", hash.Hex()); err != nil { + storageHash := crypto.Keccak256Hash(key.Bytes()) + if err := r.db.Get(storageResult, RetrieveStorageLeafByAddressHashAndLeafKeyAndBlockHashPgStr, stateLeafKey.Hex(), storageHash.Hex(), hash.Hex()); err != nil { return "", nil, nil, err } if storageResult.StateLeafRemoved || storageResult.NodeType == removedNode { -- 2.45.2 From 4af9d32dc4ba8477bad7801e952e017193a33fd4 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 16 Nov 2022 12:07:21 -0600 Subject: [PATCH 4/7] Use latest ipld-eth-db --- .github/workflows/on-pr-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.45.2 From f1d319914a6aa7f2897d2c5eedc6ffb07492ad12 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 16 Nov 2022 12:49:50 -0600 Subject: [PATCH 5/7] Don't hide test output --- .github/workflows/run_unit_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_unit_test.sh b/.github/workflows/run_unit_test.sh index c1c5e182..284c225a 100755 --- a/.github/workflows/run_unit_test.sh +++ b/.github/workflows/run_unit_test.sh @@ -21,7 +21,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 -- 2.45.2 From 1dbfacc39e710290abef1098f204cda0f26e821f Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 16 Nov 2022 13:19:40 -0600 Subject: [PATCH 6/7] pipefail --- .github/workflows/run_unit_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_unit_test.sh b/.github/workflows/run_unit_test.sh index 284c225a..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) -- 2.45.2 From b28de6d4e2b6164b1c71b3cc39050a64f6c8122c Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 16 Nov 2022 13:45:01 -0600 Subject: [PATCH 7/7] More recent ipld-eth-db. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" -- 2.45.2