From 4678b6a73395ec3b33b937e627459860fad16602 Mon Sep 17 00:00:00 2001 From: i-norden Date: Mon, 13 Mar 2023 18:23:49 -0500 Subject: [PATCH] ipld-eth-statedb initialization/instantiation --- go.mod | 4 +++- go.sum | 2 -- pkg/eth/backend.go | 8 +++----- pkg/serve/service.go | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index f31c5dc9..00bc9781 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/ipfs/go-cid v0.2.0 github.com/ipfs/go-ipfs-blockstore v1.2.0 github.com/ipfs/go-ipfs-ds-help v1.1.0 - github.com/jackc/pgx/v4 v4.18.1 github.com/jmoiron/sqlx v1.3.5 github.com/joho/godotenv v1.4.0 github.com/lib/pq v1.10.6 @@ -146,6 +145,7 @@ require ( github.com/jackc/pgproto3/v2 v2.3.2 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgtype v1.14.0 // indirect + github.com/jackc/pgx/v4 v4.18.1 // indirect github.com/jackc/puddle v1.3.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect @@ -295,3 +295,5 @@ require ( ) replace github.com/ethereum/go-ethereum v1.10.26 => github.com/cerc-io/go-ethereum v1.10.26-statediff-4.2.2-alpha + +replace github.com/cerc-io/ipld-eth-statedb v0.0.2-alpha => /Users/iannorden/go/src/github.com/cerc-io/ipld-eth-statedb diff --git a/go.sum b/go.sum index 4d78b373..1733dac5 100644 --- a/go.sum +++ b/go.sum @@ -153,8 +153,6 @@ github.com/cerc-io/go-ethereum v1.10.26-statediff-4.2.2-alpha h1:gesMZEbNU+fcAMc github.com/cerc-io/go-ethereum v1.10.26-statediff-4.2.2-alpha/go.mod h1:lKBVBWksSwBDR/5D9CAxaGQzDPIS3ueWb6idy7X1Shg= github.com/cerc-io/ipfs-ethdb/v4 v4.0.10-alpha h1:5iqNXeitkj3g7FxyKK/Pz+1HN7Ac9JZzCRj3Lv+uHiw= github.com/cerc-io/ipfs-ethdb/v4 v4.0.10-alpha/go.mod h1:dPscFRMvTWPKnoZ4U0D9v4bsrw6XdH7sOp8hUrVzOWA= -github.com/cerc-io/ipld-eth-statedb v0.0.2-alpha h1:Dj6XG6T14iHRBMFYHKcnMkNsdxZ7xqAaah2Z+QiOe1k= -github.com/cerc-io/ipld-eth-statedb v0.0.2-alpha/go.mod h1:914KQXnRylWQxRQOvlIr74NmGw7t1CyJJaEr5VSKW8E= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= diff --git a/pkg/eth/backend.go b/pkg/eth/backend.go index b5595778..fd25a5c7 100644 --- a/pkg/eth/backend.go +++ b/pkg/eth/backend.go @@ -25,8 +25,6 @@ import ( "math/big" "time" - "github.com/jackc/pgx/v4/pgxpool" - validator "github.com/cerc-io/eth-ipfs-state-validator/v4/pkg" ipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres" "github.com/cerc-io/ipld-eth-server/v4/pkg/log" @@ -111,7 +109,7 @@ type Backend struct { EthDB ethdb.Database StateDatabase state.Database // We'll use this state.Database for eth_call and any place we don't need trie access - IpldStateDatabase ipld_eth_statedb.Database + IpldStateDatabase ipld_eth_statedb.StateDatabase Config *Config } @@ -124,7 +122,7 @@ type Config struct { GroupCacheConfig *shared.GroupCacheConfig } -func NewEthBackend(db *sqlx.DB, pgxdb *pgxpool.Pool, c *Config) (*Backend, error) { +func NewEthBackend(db *sqlx.DB, c *Config) (*Backend, error) { gcc := c.GroupCacheConfig groupName := gcc.StateDB.Name @@ -140,7 +138,7 @@ func NewEthBackend(db *sqlx.DB, pgxdb *pgxpool.Pool, c *Config) (*Backend, error }) logStateDBStatsOnTimer(ethDB.(*ipfsethdb.Database), gcc) - ipldStateDB, err := ipld_eth_statedb.NewStateDatabaseWithPool(pgxdb) + ipldStateDB, err := ipld_eth_statedb.NewStateDatabaseWithSqlxPool(db) if err != nil { return nil, err } diff --git a/pkg/serve/service.go b/pkg/serve/service.go index 5d92a9f8..d36d96e8 100644 --- a/pkg/serve/service.go +++ b/pkg/serve/service.go @@ -58,7 +58,7 @@ type Service struct { sync.Mutex // Used to signal shutdown of the service QuitChan chan bool - // Underlying db + // Underlying db connection pool db *sqlx.DB // rpc client for forwarding cache misses client *rpc.Client