From 5c13d5951502a776c4d2a5b27208a27173fca3ec Mon Sep 17 00:00:00 2001 From: i-norden Date: Fri, 31 Mar 2023 10:39:27 -0500 Subject: [PATCH] refactor to work with v4 vdb geth v1.11.5 --- pkg/prom/db_stats_collector.go | 4 ++-- pkg/snapshot/file/publisher_test.go | 4 ++-- pkg/snapshot/in_place_snapshot_test.go | 2 +- pkg/snapshot/pg/publisher_test.go | 4 ++-- pkg/snapshot/service.go | 7 +++---- pkg/snapshot/tracker.go | 3 +-- pkg/snapshot/util.go | 2 +- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pkg/prom/db_stats_collector.go b/pkg/prom/db_stats_collector.go index ea5efa6..7c77494 100644 --- a/pkg/prom/db_stats_collector.go +++ b/pkg/prom/db_stats_collector.go @@ -19,12 +19,12 @@ package prom import ( "github.com/prometheus/client_golang/prometheus" - "github.com/ethereum/go-ethereum/statediff/indexer/database/sql" + mets "github.com/ethereum/go-ethereum/statediff/indexer/database/metrics" ) // DBStatsGetter is an interface that gets sql.DBStats. type DBStatsGetter interface { - Stats() sql.Stats + Stats() mets.DbStats } // DBStatsCollector implements the prometheus.Collector interface. diff --git a/pkg/snapshot/file/publisher_test.go b/pkg/snapshot/file/publisher_test.go index 9713e46..0575aa0 100644 --- a/pkg/snapshot/file/publisher_test.go +++ b/pkg/snapshot/file/publisher_test.go @@ -9,9 +9,9 @@ import ( "path/filepath" "testing" - "github.com/ethereum/go-ethereum/statediff/indexer/test_helpers" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres" "github.com/ethereum/go-ethereum/statediff/indexer/ipld" + "github.com/ethereum/go-ethereum/statediff/indexer/test_helpers" fixt "github.com/cerc-io/ipld-eth-state-snapshot/fixture" snapt "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types" @@ -91,7 +91,7 @@ func TestPgCopy(t *testing.T) { ctx := context.Background() driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo) test.NoError(t, err) - db := postgres.NewPostgresDB(driver) + db := postgres.NewPostgresDB(driver, false) test_helpers.TearDownDB(t, db) diff --git a/pkg/snapshot/in_place_snapshot_test.go b/pkg/snapshot/in_place_snapshot_test.go index cd973db..740900a 100644 --- a/pkg/snapshot/in_place_snapshot_test.go +++ b/pkg/snapshot/in_place_snapshot_test.go @@ -80,7 +80,7 @@ func TestCreateInPlaceSnapshot(t *testing.T) { ctx := context.Background() driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo) test.NoError(t, err) - db := postgres.NewPostgresDB(driver) + db := postgres.NewPostgresDB(driver, false) test_helpers.TearDownDB(t, db) diff --git a/pkg/snapshot/pg/publisher_test.go b/pkg/snapshot/pg/publisher_test.go index 1996246..25c1290 100644 --- a/pkg/snapshot/pg/publisher_test.go +++ b/pkg/snapshot/pg/publisher_test.go @@ -4,9 +4,9 @@ import ( "context" "testing" - "github.com/ethereum/go-ethereum/statediff/indexer/test_helpers" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres" "github.com/ethereum/go-ethereum/statediff/indexer/ipld" + "github.com/ethereum/go-ethereum/statediff/indexer/test_helpers" fixt "github.com/cerc-io/ipld-eth-state-snapshot/fixture" snapt "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types" @@ -46,7 +46,7 @@ func TestBasic(t *testing.T) { ctx := context.Background() driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo) test.NoError(t, err) - db := postgres.NewPostgresDB(driver) + db := postgres.NewPostgresDB(driver, false) test_helpers.TearDownDB(t, db) diff --git a/pkg/snapshot/service.go b/pkg/snapshot/service.go index 3db370e..302a673 100644 --- a/pkg/snapshot/service.go +++ b/pkg/snapshot/service.go @@ -30,10 +30,10 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" + iter "github.com/ethereum/go-ethereum/trie/concurrent_iterator" log "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" - iter "github.com/cerc-io/go-eth-state-node-iterator" "github.com/cerc-io/ipld-eth-state-snapshot/pkg/prom" . "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types" ) @@ -59,9 +59,8 @@ type Service struct { } func NewLevelDB(con *EthConfig) (ethdb.Database, error) { - edb, err := rawdb.NewLevelDBDatabaseWithFreezer( - con.LevelDBPath, 1024, 256, con.AncientDBPath, "ipld-eth-state-snapshot", true, - ) + kvdb, _ := rawdb.NewLevelDBDatabase(con.LevelDBPath, 1024, 256, "ipld-eth-state-snapshot", true) + edb, err := rawdb.NewDatabaseWithFreezer(kvdb, con.AncientDBPath, "ipld-eth-state-snapshot", true) if err != nil { return nil, fmt.Errorf("unable to create NewLevelDBDatabaseWithFreezer: %s", err) } diff --git a/pkg/snapshot/tracker.go b/pkg/snapshot/tracker.go index 286b85c..946f8ad 100644 --- a/pkg/snapshot/tracker.go +++ b/pkg/snapshot/tracker.go @@ -11,9 +11,8 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/trie" + iter "github.com/ethereum/go-ethereum/trie/concurrent_iterator" log "github.com/sirupsen/logrus" - - iter "github.com/cerc-io/go-eth-state-node-iterator" ) type trackedIter struct { diff --git a/pkg/snapshot/util.go b/pkg/snapshot/util.go index 8a9ff16..19a4881 100644 --- a/pkg/snapshot/util.go +++ b/pkg/snapshot/util.go @@ -23,7 +23,7 @@ func NewPublisher(mode SnapshotMode, config *Config) (snapt.Publisher, error) { prom.RegisterDBCollector(config.DB.ConnConfig.DatabaseName, driver) - return pg.NewPublisher(postgres.NewPostgresDB(driver)), nil + return pg.NewPublisher(postgres.NewPostgresDB(driver, false)), nil case FileSnapshot: return file.NewPublisher(config.File.OutputDir, config.Eth.NodeInfo) }