refactor to work with v4 vdb geth v1.11.5

This commit is contained in:
i-norden 2023-03-31 10:39:27 -05:00
parent 6fe54aa8b4
commit 5c13d59515
7 changed files with 12 additions and 14 deletions

View File

@ -19,12 +19,12 @@ package prom
import ( import (
"github.com/prometheus/client_golang/prometheus" "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. // DBStatsGetter is an interface that gets sql.DBStats.
type DBStatsGetter interface { type DBStatsGetter interface {
Stats() sql.Stats Stats() mets.DbStats
} }
// DBStatsCollector implements the prometheus.Collector interface. // DBStatsCollector implements the prometheus.Collector interface.

View File

@ -9,9 +9,9 @@ import (
"path/filepath" "path/filepath"
"testing" "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/database/sql/postgres"
"github.com/ethereum/go-ethereum/statediff/indexer/ipld" "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" fixt "github.com/cerc-io/ipld-eth-state-snapshot/fixture"
snapt "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types" snapt "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types"
@ -91,7 +91,7 @@ func TestPgCopy(t *testing.T) {
ctx := context.Background() ctx := context.Background()
driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo) driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo)
test.NoError(t, err) test.NoError(t, err)
db := postgres.NewPostgresDB(driver) db := postgres.NewPostgresDB(driver, false)
test_helpers.TearDownDB(t, db) test_helpers.TearDownDB(t, db)

View File

@ -80,7 +80,7 @@ func TestCreateInPlaceSnapshot(t *testing.T) {
ctx := context.Background() ctx := context.Background()
driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo) driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo)
test.NoError(t, err) test.NoError(t, err)
db := postgres.NewPostgresDB(driver) db := postgres.NewPostgresDB(driver, false)
test_helpers.TearDownDB(t, db) test_helpers.TearDownDB(t, db)

View File

@ -4,9 +4,9 @@ import (
"context" "context"
"testing" "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/database/sql/postgres"
"github.com/ethereum/go-ethereum/statediff/indexer/ipld" "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" fixt "github.com/cerc-io/ipld-eth-state-snapshot/fixture"
snapt "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types" snapt "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types"
@ -46,7 +46,7 @@ func TestBasic(t *testing.T) {
ctx := context.Background() ctx := context.Background()
driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo) driver, err := postgres.NewSQLXDriver(ctx, pgConfig, nodeInfo)
test.NoError(t, err) test.NoError(t, err)
db := postgres.NewPostgresDB(driver) db := postgres.NewPostgresDB(driver, false)
test_helpers.TearDownDB(t, db) test_helpers.TearDownDB(t, db)

View File

@ -30,10 +30,10 @@ import (
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
iter "github.com/ethereum/go-ethereum/trie/concurrent_iterator"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup" "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/prom"
. "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types" . "github.com/cerc-io/ipld-eth-state-snapshot/pkg/types"
) )
@ -59,9 +59,8 @@ type Service struct {
} }
func NewLevelDB(con *EthConfig) (ethdb.Database, error) { func NewLevelDB(con *EthConfig) (ethdb.Database, error) {
edb, err := rawdb.NewLevelDBDatabaseWithFreezer( kvdb, _ := rawdb.NewLevelDBDatabase(con.LevelDBPath, 1024, 256, "ipld-eth-state-snapshot", true)
con.LevelDBPath, 1024, 256, con.AncientDBPath, "ipld-eth-state-snapshot", true, edb, err := rawdb.NewDatabaseWithFreezer(kvdb, con.AncientDBPath, "ipld-eth-state-snapshot", true)
)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to create NewLevelDBDatabaseWithFreezer: %s", err) return nil, fmt.Errorf("unable to create NewLevelDBDatabaseWithFreezer: %s", err)
} }

View File

@ -11,9 +11,8 @@ import (
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
iter "github.com/ethereum/go-ethereum/trie/concurrent_iterator"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
iter "github.com/cerc-io/go-eth-state-node-iterator"
) )
type trackedIter struct { type trackedIter struct {

View File

@ -23,7 +23,7 @@ func NewPublisher(mode SnapshotMode, config *Config) (snapt.Publisher, error) {
prom.RegisterDBCollector(config.DB.ConnConfig.DatabaseName, driver) prom.RegisterDBCollector(config.DB.ConnConfig.DatabaseName, driver)
return pg.NewPublisher(postgres.NewPostgresDB(driver)), nil return pg.NewPublisher(postgres.NewPostgresDB(driver, false)), nil
case FileSnapshot: case FileSnapshot:
return file.NewPublisher(config.File.OutputDir, config.Eth.NodeInfo) return file.NewPublisher(config.File.OutputDir, config.Eth.NodeInfo)
} }