From 1b00d37715ddd1242cb2ddb20e8efa47fee0389b Mon Sep 17 00:00:00 2001 From: i-norden Date: Wed, 29 Dec 2021 00:17:09 -0600 Subject: [PATCH 1/3] updates to satisfy the v1.10.14 ethdb.Database interface --- batch.go | 6 ++++-- database.go | 11 +++++++++-- iterator.go | 2 ++ mock_blockservice.go | 6 +++--- postgres/batch.go | 2 ++ postgres/database.go | 28 ++++++++++++++++++---------- postgres/iterator.go | 2 ++ postgres/util.go | 4 ++-- util.go | 2 +- 9 files changed, 43 insertions(+), 20 deletions(-) diff --git a/batch.go b/batch.go index f53b576..b27a615 100644 --- a/batch.go +++ b/batch.go @@ -21,8 +21,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" - "github.com/hashicorp/golang-lru" - "github.com/ipfs/go-block-format" + lru "github.com/hashicorp/golang-lru" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-blockservice" ) @@ -30,6 +30,8 @@ var ( EvictionWarningErr = errors.New("warn: batch has exceeded capacity, data has been evicted") ) +var _ ethdb.Batch = &Batch{} + // Batch is the type that satisfies the ethdb.Batch interface for IPFS Ethereum data using the ipfs blockservice interface // This is ipfs-backing-datastore agnostic but must operate through a configured ipfs node (and so is subject to lockfile contention with e.g. an ipfs daemon) // If blockservice block exchange is configured the blockservice can fetch data that are missing locally from IPFS peers diff --git a/database.go b/database.go index aaa7b0f..9f6c8cc 100644 --- a/database.go +++ b/database.go @@ -33,6 +33,8 @@ var ( errNotSupported = errors.New("this operation is not supported") ) +var _ ethdb.Database = &Database{} + // Database is the type that satisfies the ethdb.Database and ethdb.KeyValueStore interfaces for IPFS Ethereum data // This is ipfs-backing-datastore agnostic but must operate through a configured ipfs node (and so is subject to lockfile contention with e.g. an ipfs daemon) // If blockservice block exchange is configured the blockservice can fetch data that are missing locally from IPFS peers @@ -205,15 +207,20 @@ func (d *Database) AppendAncient(number uint64, hash, header, body, receipt, td return errNotSupported } -// ReadAncients retrieves multiple items in sequence, starting from the index 'start'. +// AncientRange retrieves all the items in a range, starting from the index 'start'. // It will return // - at most 'count' items, // - at least 1 item (even if exceeding the maxBytes), but will otherwise // return as many items as fit into maxBytes. -func (d *Database) ReadAncients(kind string, start, count, maxBytes uint64) ([][]byte, error) { +func (d *Database) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error) { return nil, errNotSupported } +// ReadAncients applies the provided AncientReader function +func (d *Database) ReadAncients(fn func(ethdb.AncientReader) error) (err error) { + return errNotSupported +} + // TruncateAncients satisfies the ethdb.AncientWriter interface // TruncateAncients discards all but the first n ancient data from the ancient store func (d *Database) TruncateAncients(n uint64) error { diff --git a/iterator.go b/iterator.go index 0fba100..41c2f9c 100644 --- a/iterator.go +++ b/iterator.go @@ -23,6 +23,8 @@ import ( "github.com/ipfs/go-blockservice" ) +var _ ethdb.Iterator = &Iterator{} + // Iterator is the type that satisfies the ethdb.Iterator interface for IPFS Ethereum data // Iteratee interface is used in Geth for various tests, trie/sync_bloom.go (for fast sync), // rawdb.InspectDatabase, and the new core/state/snapshot features. diff --git a/mock_blockservice.go b/mock_blockservice.go index fe25177..eb33818 100644 --- a/mock_blockservice.go +++ b/mock_blockservice.go @@ -20,11 +20,11 @@ import ( "context" "errors" - "github.com/ipfs/go-block-format" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-blockservice" "github.com/ipfs/go-cid" - "github.com/ipfs/go-ipfs-blockstore" - "github.com/ipfs/go-ipfs-exchange-interface" + blockstore "github.com/ipfs/go-ipfs-blockstore" + exchange "github.com/ipfs/go-ipfs-exchange-interface" ) var ( diff --git a/postgres/batch.go b/postgres/batch.go index d023868..1ceeaf8 100644 --- a/postgres/batch.go +++ b/postgres/batch.go @@ -21,6 +21,8 @@ import ( "github.com/jmoiron/sqlx" ) +var _ ethdb.Batch = &Batch{} + // Batch is the type that satisfies the ethdb.Batch interface for PG-IPFS Ethereum data using a direct Postgres connection type Batch struct { db *sqlx.DB diff --git a/postgres/database.go b/postgres/database.go index d7a861b..d65b06c 100644 --- a/postgres/database.go +++ b/postgres/database.go @@ -20,6 +20,7 @@ import ( "context" "errors" "fmt" + "strconv" "strings" "time" @@ -38,6 +39,8 @@ var ( dbSizePgStr = "SELECT pg_database_size(current_database())" ) +var _ ethdb.Database = &Database{} + // Database is the type that satisfies the ethdb.Database and ethdb.KeyValueStore interfaces for PG-IPFS Ethereum data using a direct Postgres connection type Database struct { db *sqlx.DB @@ -63,7 +66,7 @@ func NewKeyValueStore(db *sqlx.DB, cacheConfig CacheConfig) ethdb.KeyValueStore } // NewDatabase returns a ethdb.Database interface for PG-IPFS -func NewDatabase(db *sqlx.DB, cacheConfig CacheConfig) *Database { +func NewDatabase(db *sqlx.DB, cacheConfig CacheConfig) ethdb.Database { database := Database{db: db} database.InitCache(cacheConfig) @@ -212,19 +215,19 @@ func (d *Database) Stat(property string) (string, error) { var byteSize string return byteSize, d.db.Get(&byteSize, dbSizePgStr) case Idle: - return string(d.db.Stats().Idle), nil + return strconv.Itoa(d.db.Stats().Idle), nil case InUse: - return string(d.db.Stats().InUse), nil + return strconv.Itoa(d.db.Stats().InUse), nil case MaxIdleClosed: - return string(d.db.Stats().MaxIdleClosed), nil + return strconv.FormatInt(d.db.Stats().MaxIdleClosed, 10), nil case MaxLifetimeClosed: - return string(d.db.Stats().MaxLifetimeClosed), nil + return strconv.FormatInt(d.db.Stats().MaxLifetimeClosed, 10), nil case MaxOpenConnections: - return string(d.db.Stats().MaxOpenConnections), nil + return strconv.Itoa(d.db.Stats().MaxOpenConnections), nil case OpenConnections: - return string(d.db.Stats().OpenConnections), nil + return strconv.Itoa(d.db.Stats().OpenConnections), nil case WaitCount: - return string(d.db.Stats().WaitCount), nil + return strconv.FormatInt(d.db.Stats().WaitCount, 10), nil case WaitDuration: return d.db.Stats().WaitDuration.String(), nil default: @@ -292,15 +295,20 @@ func (d *Database) AppendAncient(number uint64, hash, header, body, receipt, td return errNotSupported } -// ReadAncients retrieves multiple items in sequence, starting from the index 'start'. +// AncientRange retrieves all the items in a range, starting from the index 'start'. // It will return // - at most 'count' items, // - at least 1 item (even if exceeding the maxBytes), but will otherwise // return as many items as fit into maxBytes. -func (d *Database) ReadAncients(kind string, start, count, maxBytes uint64) ([][]byte, error) { +func (d *Database) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error) { return nil, errNotSupported } +// ReadAncients applies the provided AncientReader function +func (d *Database) ReadAncients(fn func(ethdb.AncientReader) error) (err error) { + return errNotSupported +} + // TruncateAncients satisfies the ethdb.AncientWriter interface // TruncateAncients discards all but the first n ancient data from the ancient store func (d *Database) TruncateAncients(n uint64) error { diff --git a/postgres/iterator.go b/postgres/iterator.go index f673729..0d3a0a4 100644 --- a/postgres/iterator.go +++ b/postgres/iterator.go @@ -21,6 +21,8 @@ import ( "github.com/jmoiron/sqlx" ) +var _ ethdb.Iterator = &Iterator{} + // Iterator is the type that satisfies the ethdb.Iterator interface for PG-IPFS Ethereum data using a direct Postgres connection // Iteratee interface is used in Geth for various tests, trie/sync_bloom.go (for fast sync), // rawdb.InspectDatabase, and the new core/state/snapshot features. diff --git a/postgres/util.go b/postgres/util.go index cdd818f..69e9cdf 100644 --- a/postgres/util.go +++ b/postgres/util.go @@ -17,8 +17,8 @@ package pgipfsethdb import ( - "github.com/ipfs/go-ipfs-blockstore" - "github.com/ipfs/go-ipfs-ds-help" + blockstore "github.com/ipfs/go-ipfs-blockstore" + dshelp "github.com/ipfs/go-ipfs-ds-help" "github.com/jmoiron/sqlx" _ "github.com/lib/pq" //postgres driver "github.com/multiformats/go-multihash" diff --git a/util.go b/util.go index 177a9fa..5735952 100644 --- a/util.go +++ b/util.go @@ -17,7 +17,7 @@ package ipfsethdb import ( - "github.com/ipfs/go-block-format" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" _ "github.com/lib/pq" //postgres driver "github.com/multiformats/go-multihash" From 9db42029f712d2cac8a7998f098e125092367508 Mon Sep 17 00:00:00 2001 From: i-norden Date: Wed, 29 Dec 2021 00:17:24 -0600 Subject: [PATCH 2/3] bump geth version to v1.10.14 --- go.mod | 2 +- go.sum | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 91c6896..168beeb 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/vulcanize/ipfs-ethdb go 1.13 require ( - github.com/ethereum/go-ethereum v1.10.9 + github.com/ethereum/go-ethereum v1.10.14 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d github.com/ipfs/go-block-format v0.0.2 github.com/ipfs/go-blockservice v0.1.3 diff --git a/go.sum b/go.sum index 565ff6a..4fd7971 100644 --- a/go.sum +++ b/go.sum @@ -91,6 +91,7 @@ github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/ github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cskr/pubsub v1.0.2/go.mod h1:/8MzYXk/NJAz782G8RPkFzXTZVu63VotefPnR9TIRis= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= @@ -106,16 +107,17 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-bitstream v0.0.0-20180413035011-3522498ce2c8/go.mod h1:VMaSuZ+SZcx/wljOQKvp5srsbCiKDEb6K2wC4+PiBmQ= github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= +github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= +github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.10.9 h1:uMSWt0qDhaqqCk0PWqfDFOMUExmk4Tnbma6c6oXW+Pk= -github.com/ethereum/go-ethereum v1.10.9/go.mod h1:CaTMQrv51WaAlD2eULQ3f03KiahDRO28fleQcKjWrrg= +github.com/ethereum/go-ethereum v1.10.14 h1:EJ/ucQzFlgKgwblIwU8R6ABnZ9kgUnIG2+Q1tiSrt4M= +github.com/ethereum/go-ethereum v1.10.14/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= @@ -141,7 +143,7 @@ github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -211,7 +213,6 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -305,7 +306,7 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= -github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= +github.com/karalabe/usb v0.0.0-20211005121534-4c5740d64559/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -320,11 +321,13 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= @@ -777,8 +780,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= From aae2cba8ce782cc4e319944253ff4d7feea3eb92 Mon Sep 17 00:00:00 2001 From: i-norden Date: Wed, 29 Dec 2021 00:17:52 -0600 Subject: [PATCH 3/3] fix tests failing from the recent groupcache changes --- postgres/batch_test.go | 2 ++ postgres/database_test.go | 2 ++ postgres/util.go | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/postgres/batch_test.go b/postgres/batch_test.go index 54bbd9e..828ad98 100644 --- a/postgres/batch_test.go +++ b/postgres/batch_test.go @@ -23,6 +23,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/rlp" + "github.com/mailgun/groupcache/v2" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -51,6 +52,7 @@ var _ = Describe("Batch", func() { batch = database.NewBatch() }) AfterEach(func() { + groupcache.DeregisterGroup("db") err = pgipfsethdb.ResetTestDB(db) Expect(err).ToNot(HaveOccurred()) }) diff --git a/postgres/database_test.go b/postgres/database_test.go index 9e407e7..cd58bc8 100644 --- a/postgres/database_test.go +++ b/postgres/database_test.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/rlp" "github.com/jmoiron/sqlx" + "github.com/mailgun/groupcache/v2" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -54,6 +55,7 @@ var _ = Describe("Database", func() { database = pgipfsethdb.NewDatabase(db, cacheConfig) }) AfterEach(func() { + groupcache.DeregisterGroup("db") err = pgipfsethdb.ResetTestDB(db) Expect(err).ToNot(HaveOccurred()) }) diff --git a/postgres/util.go b/postgres/util.go index 69e9cdf..eedd8fd 100644 --- a/postgres/util.go +++ b/postgres/util.go @@ -44,6 +44,6 @@ func TestDB() (*sqlx.DB, error) { // ResetTestDB drops all rows in the test db public.blocks table func ResetTestDB(db *sqlx.DB) error { - _, err := db.Exec("TRUNCATE public.blocks") + _, err := db.Exec("TRUNCATE public.blocks CASCADE") return err }