Skip to content

Commit

Permalink
Merge pull request #56 from cerc-io/ian/v5
Browse files Browse the repository at this point in the history
bump to v1.11.5
  • Loading branch information
i-norden authored Mar 30, 2023
2 parents 4a52acb + 0e49b87 commit 2709f7b
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 70 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import (
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/repo/fsrepo"
"github.com/jmoiron/sqlx"
"github.com/vulcanize/ipfs-ethdb/v4"
"github.com/vulcanize/ipfs-ethdb/v5"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

ipfsethdb "github.com/cerc-io/ipfs-ethdb/v4"
ipfsethdb "github.com/cerc-io/ipfs-ethdb/v5"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

ipfsethdb "github.com/cerc-io/ipfs-ethdb/v4"
ipfsethdb "github.com/cerc-io/ipfs-ethdb/v5"
)

var (
Expand Down
25 changes: 12 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/cerc-io/ipfs-ethdb/v4
module github.com/cerc-io/ipfs-ethdb/v5

go 1.18
go 1.19

require (
github.com/ethereum/go-ethereum v1.10.26
github.com/ethereum/go-ethereum v1.11.5
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-blockservice v0.4.0
Expand All @@ -25,12 +25,13 @@ require github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
require (
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-datastore v0.5.0 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
Expand All @@ -42,7 +43,7 @@ require (
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
Expand All @@ -59,14 +60,12 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0 // indirect
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.26.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
lukechampine.com/blake3 v1.1.6 // indirect
)

replace github.com/ethereum/go-ethereum v1.10.26 => github.com/cerc-io/go-ethereum v1.10.26-statediff-4.2.2-alpha
75 changes: 49 additions & 26 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions postgres/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/trie"
"github.com/jmoiron/sqlx"
"github.com/vulcanize/ipfs-ethdb/v4/postgres"
"github.com/vulcanize/ipfs-ethdb/v5/postgres"
)

func main() {
connectStr := "postgresql://localhost:5432/vulcanize_testing?sslmode=disable"
connectStr := "postgresql://vdbm:password@localhost:8077/cerc_testing?sslmode=disable"
db, _ := sqlx.Connect("postgres", connectStr)

kvs := pgipfsethdb.NewKeyValueStore(db)
Expand Down
18 changes: 13 additions & 5 deletions postgres/shared/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@ package shared

import "github.com/jmoiron/sqlx"

/*
Hostname: "localhost",
Port: 8077,
DatabaseName: "cerc_testing",
Username: "vdbm",
Password: "password",
*/

// TestDB connect to the testing database
// it assumes the database has the IPFS public.blocks table present
// DO NOT use a production db for the test db, as it will remove all contents of the public.blocks table
// it assumes the database has the IPFS ipld.blocks table present
// DO NOT use a production db for the test db, as it will remove all contents of the ipld.blocks table
func TestDB() (*sqlx.DB, error) {
connectStr := "postgresql://localhost:5432/vulcanize_testing?sslmode=disable"
connectStr := "postgresql://vdbm:password@localhost:8077/cerc_testing?sslmode=disable"
return sqlx.Connect("postgres", connectStr)
}

// ResetTestDB drops all rows in the test db public.blocks table
// ResetTestDB drops all rows in the test db ipld.blocks table
func ResetTestDB(db *sqlx.DB) error {
_, err := db.Exec("TRUNCATE public.blocks CASCADE")
_, err := db.Exec("TRUNCATE ipld.blocks CASCADE")
return err
}
2 changes: 1 addition & 1 deletion postgres/v0/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewBatch(db *sqlx.DB, tx *sqlx.Tx, blockNumber *big.Int) ethdb.Batch {
// Put satisfies the ethdb.Batch interface
// Put inserts the given value into the key-value data store
// Key is expected to be a fully formulated cid key
// TODO: note, now that we expected a cid we could route to the "cids" tables based on prefix instead of to public.blocks
// TODO: note, now that we expected a cid we could route to the "cids" tables based on prefix instead of to ipld.blocks
// but is it better to handle this routing here, or use a completely different interface since we already have to refactor
// at levels above this package in order to pass in cids instead of raw keccak256 hashes
func (b *Batch) Put(cidBytes []byte, value []byte) (err error) {
Expand Down
4 changes: 2 additions & 2 deletions postgres/v0/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"math/big"
"time"

"github.com/cerc-io/ipfs-ethdb/v4/postgres/shared"
"github.com/cerc-io/ipfs-ethdb/v5/postgres/shared"

"github.com/ipfs/go-cid"

Expand All @@ -31,7 +31,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres/v0"
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v5/postgres/v0"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions postgres/v0/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import (
var errNotSupported = errors.New("this operation is not supported")

var (
hasPgStr = "SELECT exists(select 1 from public.blocks WHERE key = $1 LIMIT 1)"
getPgStr = "SELECT data FROM public.blocks WHERE key = $1 LIMIT 1"
putPgStr = "INSERT INTO public.blocks (key, data, block_number) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING"
deletePgStr = "DELETE FROM public.blocks WHERE key = $1"
hasPgStr = "SELECT exists(select 1 from ipld.blocks WHERE key = $1 LIMIT 1)"
getPgStr = "SELECT data FROM ipld.blocks WHERE key = $1 LIMIT 1"
putPgStr = "INSERT INTO ipld.blocks (key, data, block_number) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING"
deletePgStr = "DELETE FROM ipld.blocks WHERE key = $1"
dbSizePgStr = "SELECT pg_database_size(current_database())"
)

Expand Down
10 changes: 6 additions & 4 deletions postgres/v0/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"math/big"
"time"

"github.com/cerc-io/ipfs-ethdb/v4/postgres/shared"
"github.com/cerc-io/ipfs-ethdb/v5/postgres/shared"

"github.com/ipfs/go-cid"

Expand All @@ -32,7 +32,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres/v0"
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v5/postgres/v0"
)

var (
Expand Down Expand Up @@ -67,6 +67,8 @@ var _ = Describe("Database", func() {
groupcache.DeregisterGroup("db")
err = shared.ResetTestDB(db)
Expect(err).ToNot(HaveOccurred())
err = db.Close()
Expect(err).ToNot(HaveOccurred())
})

Describe("Has", func() {
Expand All @@ -76,7 +78,7 @@ var _ = Describe("Database", func() {
Expect(has).ToNot(BeTrue())
})
It("returns true if a key-pair exists in the db", func() {
_, err = db.Exec("INSERT into public.blocks (key, data, block_number) VALUES ($1, $2, $3)", testCID.String(), testValue, testBlockNumber.Uint64())
_, err = db.Exec("INSERT into ipld.blocks (key, data, block_number) VALUES ($1, $2, $3)", testCID.String(), testValue, testBlockNumber.Uint64())
Expect(err).ToNot(HaveOccurred())
has, err := database.Has(testCID.Bytes())
Expect(err).ToNot(HaveOccurred())
Expand All @@ -91,7 +93,7 @@ var _ = Describe("Database", func() {
Expect(err.Error()).To(ContainSubstring("sql: no rows in result set"))
})
It("returns the value associated with the key, if the pair exists", func() {
_, err = db.Exec("INSERT into public.blocks (key, data, block_number) VALUES ($1, $2, $3)", testCID.String(), testValue, testBlockNumber.Uint64())
_, err = db.Exec("INSERT into ipld.blocks (key, data, block_number) VALUES ($1, $2, $3)", testCID.String(), testValue, testBlockNumber.Uint64())
Expect(err).ToNot(HaveOccurred())
val, err := database.Get(testCID.Bytes())
Expect(err).ToNot(HaveOccurred())
Expand Down
4 changes: 2 additions & 2 deletions postgres/v1/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"math/big"
"time"

"github.com/cerc-io/ipfs-ethdb/v4/postgres/shared"
"github.com/cerc-io/ipfs-ethdb/v5/postgres/shared"

"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
Expand All @@ -29,7 +29,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres/v1"
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v5/postgres/v1"
)

var (
Expand Down
8 changes: 4 additions & 4 deletions postgres/v1/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import (
var errNotSupported = errors.New("this operation is not supported")

var (
hasPgStr = "SELECT exists(select 1 from public.blocks WHERE key = $1 LIMIT 1)"
getPgStr = "SELECT data FROM public.blocks WHERE key = $1 LIMIT 1"
putPgStr = "INSERT INTO public.blocks (key, data, block_number) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING"
deletePgStr = "DELETE FROM public.blocks WHERE key = $1"
hasPgStr = "SELECT exists(select 1 from ipld.blocks WHERE key = $1 LIMIT 1)"
getPgStr = "SELECT data FROM ipld.blocks WHERE key = $1 LIMIT 1"
putPgStr = "INSERT INTO ipld.blocks (key, data, block_number) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING"
deletePgStr = "DELETE FROM ipld.blocks WHERE key = $1"
dbSizePgStr = "SELECT pg_database_size(current_database())"
)

Expand Down
10 changes: 6 additions & 4 deletions postgres/v1/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"math/big"
"time"

"github.com/cerc-io/ipfs-ethdb/v4/postgres/shared"
"github.com/cerc-io/ipfs-ethdb/v5/postgres/shared"

"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
Expand All @@ -30,7 +30,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres/v1"
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v5/postgres/v1"
)

var (
Expand Down Expand Up @@ -65,6 +65,8 @@ var _ = Describe("Database", func() {
groupcache.DeregisterGroup("db")
err = shared.ResetTestDB(db)
Expect(err).ToNot(HaveOccurred())
err = db.Close()
Expect(err).ToNot(HaveOccurred())
})

Describe("Has", func() {
Expand All @@ -74,7 +76,7 @@ var _ = Describe("Database", func() {
Expect(has).ToNot(BeTrue())
})
It("returns true if a key-pair exists in the db", func() {
_, err = db.Exec("INSERT into public.blocks (key, data, block_number) VALUES ($1, $2, $3)", testMhKey, testValue, testBlockNumber.Uint64())
_, err = db.Exec("INSERT into ipld.blocks (key, data, block_number) VALUES ($1, $2, $3)", testMhKey, testValue, testBlockNumber.Uint64())
Expect(err).ToNot(HaveOccurred())
has, err := database.Has(testEthKey)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -89,7 +91,7 @@ var _ = Describe("Database", func() {
Expect(err.Error()).To(ContainSubstring("sql: no rows in result set"))
})
It("returns the value associated with the key, if the pair exists", func() {
_, err = db.Exec("INSERT into public.blocks (key, data, block_number) VALUES ($1, $2, $3)", testMhKey, testValue, testBlockNumber.Uint64())
_, err = db.Exec("INSERT into ipld.blocks (key, data, block_number) VALUES ($1, $2, $3)", testMhKey, testValue, testBlockNumber.Uint64())
Expect(err).ToNot(HaveOccurred())
val, err := database.Get(testEthKey)
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit 2709f7b

Please sign in to comment.