diff --git a/cmd/validateTrie.go b/cmd/validateTrie.go index c89cc86..8f019b5 100644 --- a/cmd/validateTrie.go +++ b/cmd/validateTrie.go @@ -24,7 +24,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - validator "github.com/vulcanize/eth-ipfs-state-validator/v3/pkg" + validator "github.com/vulcanize/eth-ipfs-state-validator/v4/pkg" ) // validateTrieCmd represents the validateTrie command diff --git a/go.mod b/go.mod index 313a576..a8b8c5d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/vulcanize/eth-ipfs-state-validator/v3 +module github.com/vulcanize/eth-ipfs-state-validator/v4 go 1.15 @@ -19,5 +19,5 @@ require ( github.com/sirupsen/logrus v1.8.1 github.com/spf13/cobra v1.4.0 github.com/spf13/viper v1.11.0 - github.com/vulcanize/ipfs-ethdb/v3 v3.0.1 + github.com/vulcanize/ipfs-ethdb/v4 v4.0.0-alpha ) diff --git a/go.sum b/go.sum index b531281..ad45583 100644 --- a/go.sum +++ b/go.sum @@ -1610,8 +1610,8 @@ github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPU github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/vulcanize/ipfs-ethdb/v3 v3.0.1 h1:gm+6SgxcNOCz6mgwvhsxORLXsr9yIFvbJDuoAK85ONs= -github.com/vulcanize/ipfs-ethdb/v3 v3.0.1/go.mod h1:SPBTTl5CqRexYfkI66pbzE5nQziYpoQ+7hH0XveA9IU= +github.com/vulcanize/ipfs-ethdb/v4 v4.0.0-alpha h1:XaltpDMGFqcEe+tsYTmqICeFhR+jTHHzc85YTVigEdE= +github.com/vulcanize/ipfs-ethdb/v4 v4.0.0-alpha/go.mod h1:sSTqwalaV7CiXq83YkMJpZetoSxgcdzr0AG0NnuaGMM= github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30/go.mod h1:YkocrP2K2tcw938x9gCOmT5G5eCD6jsTz0SZuyAqwIE= github.com/warpfork/go-testmark v0.3.0 h1:Q81c4u7hT+BR5kNfNQhEF0VT2pmL7+Kk0wD+ORYl7iA= github.com/warpfork/go-testmark v0.3.0/go.mod h1:jhEf8FVxd+F17juRubpmut64NEG6I2rgkUhlcqqXwE0= diff --git a/main.go b/main.go index d33abd7..4e016be 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ package main import ( "github.com/sirupsen/logrus" - "github.com/vulcanize/eth-ipfs-state-validator/v3/cmd" + "github.com/vulcanize/eth-ipfs-state-validator/v4/cmd" ) func main() { diff --git a/pkg/util.go b/pkg/util.go index b9bdb2e..6fac145 100644 --- a/pkg/util.go +++ b/pkg/util.go @@ -29,14 +29,14 @@ import ( ) // PublishRaw derives a cid from raw bytes and provided codec and multihash type, and writes it to the db tx -func PublishRaw(tx *sqlx.Tx, codec, mh uint64, raw []byte) (string, error) { +func PublishRaw(tx *sqlx.Tx, codec, mh uint64, raw []byte, blockNumber uint64) (string, error) { c, err := RawdataToCid(codec, raw, mh) if err != nil { return "", err } dbKey := dshelp.MultihashToDsKey(c.Hash()) prefixedKey := blockstore.BlockPrefix.String() + dbKey.String() - _, err = tx.Exec(`INSERT INTO public.blocks (key, data) VALUES ($1, $2) ON CONFLICT (key) DO NOTHING`, prefixedKey, raw) + _, err = tx.Exec(`INSERT INTO public.blocks (key, data, block_number) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING`, prefixedKey, raw, blockNumber) return c.String(), err } diff --git a/pkg/validator.go b/pkg/validator.go index 9b2bbf3..3f6c72e 100644 --- a/pkg/validator.go +++ b/pkg/validator.go @@ -28,8 +28,8 @@ import ( "github.com/jmoiron/sqlx" "github.com/mailgun/groupcache/v2" - ipfsethdb "github.com/vulcanize/ipfs-ethdb/v3" - pgipfsethdb "github.com/vulcanize/ipfs-ethdb/v3/postgres" + ipfsethdb "github.com/vulcanize/ipfs-ethdb/v4" + pgipfsethdb "github.com/vulcanize/ipfs-ethdb/v4/postgres" ) // Validator is used for validating Ethereum state and storage tries on PG-IPFS diff --git a/pkg/validator_test.go b/pkg/validator_test.go index c128be1..afb47db 100644 --- a/pkg/validator_test.go +++ b/pkg/validator_test.go @@ -30,11 +30,12 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - validator "github.com/vulcanize/eth-ipfs-state-validator/v3/pkg" - pgipfsethdb "github.com/vulcanize/ipfs-ethdb/v3/postgres" + validator "github.com/vulcanize/eth-ipfs-state-validator/v4/pkg" + pgipfsethdb "github.com/vulcanize/ipfs-ethdb/v4/postgres" ) var ( + blockNumber = uint64(1) contractAddr = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476592") slot0StorageValue = common.Hex2Bytes("94703c4b2bd70c169f5717101caee543299fc946c7") slot1StorageValue = common.Hex2Bytes("01") @@ -302,11 +303,11 @@ func loadTrie(stateNodes, storageNodes [][]byte) { tx, err := db.Beginx() Expect(err).ToNot(HaveOccurred()) for _, node := range stateNodes { - _, err := validator.PublishRaw(tx, cid.EthStateTrie, multihash.KECCAK_256, node) + _, err := validator.PublishRaw(tx, cid.EthStateTrie, multihash.KECCAK_256, node, blockNumber) Expect(err).ToNot(HaveOccurred()) } for _, node := range storageNodes { - _, err := validator.PublishRaw(tx, cid.EthStorageTrie, multihash.KECCAK_256, node) + _, err := validator.PublishRaw(tx, cid.EthStorageTrie, multihash.KECCAK_256, node, blockNumber) Expect(err).ToNot(HaveOccurred()) } err = tx.Commit()