From 97a64c174c29cae5fdb13d7ac1466f5241646667 Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Thu, 6 Aug 2020 14:33:02 -0500 Subject: [PATCH] remove diff unique constraint --- db/migrations/00008_create_eth_state_cids_table.sql | 2 +- db/migrations/00009_create_eth_storage_cids_table.sql | 2 +- environments/example.toml | 3 ++- pkg/snapshot/publisher.go | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/db/migrations/00008_create_eth_state_cids_table.sql b/db/migrations/00008_create_eth_state_cids_table.sql index 4bfa822..e0bf6e5 100644 --- a/db/migrations/00008_create_eth_state_cids_table.sql +++ b/db/migrations/00008_create_eth_state_cids_table.sql @@ -8,7 +8,7 @@ CREATE TABLE eth.state_cids ( state_path BYTEA, node_type INTEGER, diff BOOLEAN NOT NULL DEFAULT FALSE, - UNIQUE (header_id, state_path, diff) + UNIQUE (header_id, state_path) ); -- +goose Down diff --git a/db/migrations/00009_create_eth_storage_cids_table.sql b/db/migrations/00009_create_eth_storage_cids_table.sql index f19bc62..944d39e 100644 --- a/db/migrations/00009_create_eth_storage_cids_table.sql +++ b/db/migrations/00009_create_eth_storage_cids_table.sql @@ -8,7 +8,7 @@ CREATE TABLE eth.storage_cids ( storage_path BYTEA, node_type INTEGER NOT NULL, diff BOOLEAN NOT NULL DEFAULT FALSE, - UNIQUE (state_id, storage_path, diff) + UNIQUE (state_id, storage_path) ); -- +goose Down diff --git a/environments/example.toml b/environments/example.toml index 2e80743..66e87b0 100644 --- a/environments/example.toml +++ b/environments/example.toml @@ -6,6 +6,7 @@ [leveldb] path = "/Users/user/Library/Ethereum/geth/chaindata" + ancient = "/Users/user/Library/Ethereum/geth/chaindata/ancient" [snapshot] - blockHeight = 0 \ No newline at end of file + blockHeight = -1 \ No newline at end of file diff --git a/pkg/snapshot/publisher.go b/pkg/snapshot/publisher.go index b3a25a5..ddda7e4 100644 --- a/pkg/snapshot/publisher.go +++ b/pkg/snapshot/publisher.go @@ -99,7 +99,7 @@ func (p *Publisher) PublishStateNode(node Node, headerID int64) (int64, error) { } mhKey, _ := shared.MultihashKeyFromCIDString(stateCIDStr) err = tx.QueryRowx(`INSERT INTO eth.state_cids (header_id, state_leaf_key, cid, state_path, node_type, diff, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7) - ON CONFLICT (header_id, state_path, diff) DO UPDATE SET (state_leaf_key, cid, node_type, mh_key) = ($2, $3, $5, $7) + ON CONFLICT (header_id, state_path) DO UPDATE SET state_path = state_cids.state_path RETURNING id`, headerID, stateKey, stateCIDStr, node.Path, node.NodeType, false, mhKey).Scan(&stateID) return stateID, err @@ -131,7 +131,7 @@ func (p *Publisher) PublishStorageNode(node Node, stateID int64) error { } mhKey, _ := shared.MultihashKeyFromCIDString(storageCIDStr) _, err = tx.Exec(`INSERT INTO eth.storage_cids (state_id, storage_leaf_key, cid, storage_path, node_type, diff, mh_key) VALUES ($1, $2, $3, $4, $5, $6, $7) - ON CONFLICT (state_id, storage_path, diff) DO UPDATE SET (storage_leaf_key, cid, node_type, mh_key) = ($2, $3, $5, $7)`, + ON CONFLICT (state_id, storage_path) DO NOTHING`, stateID, storageKey, storageCIDStr, node.Path, node.NodeType, false, mhKey) return err }