Compare commits
23
Commits
v0.0.1
...
v4.0.3-alpha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6d7948220 | ||
|
|
e64788e900 | ||
|
|
afe207445a | ||
|
|
f029bb323f | ||
|
|
169229b86c | ||
|
|
dbd73f5361 | ||
|
|
242db8870a | ||
|
|
f95f8aaa20 | ||
|
|
e9da27e34a | ||
|
|
c8813448e9 | ||
|
|
bce89d43da | ||
|
|
54f5f4cd9c | ||
|
|
a42ad0441b | ||
|
|
bd01384525 | ||
|
|
c64a6e59f8 | ||
|
|
8a46648418 | ||
|
|
6e5bfa6bc5 | ||
|
|
e66ac139fa | ||
|
|
5203c506b0 | ||
|
|
0926e1f53f | ||
|
|
eea7ef859d | ||
|
|
f7ce7a48dd | ||
|
|
3fb74dfbf6 |
+1
-1
@@ -24,7 +24,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
validator "github.com/vulcanize/eth-ipfs-state-validator/pkg"
|
||||
validator "github.com/vulcanize/eth-ipfs-state-validator/v4/pkg"
|
||||
)
|
||||
|
||||
// validateTrieCmd represents the validateTrie command
|
||||
|
||||
@@ -1,23 +1,238 @@
|
||||
module github.com/vulcanize/eth-ipfs-state-validator
|
||||
module github.com/vulcanize/eth-ipfs-state-validator/v4
|
||||
|
||||
go 1.13
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/ethereum/go-ethereum v1.9.15
|
||||
github.com/ipfs/go-blockservice v0.1.3
|
||||
github.com/ethereum/go-ethereum v1.10.19
|
||||
github.com/ipfs/go-blockservice v0.1.7
|
||||
github.com/ipfs/go-cid v0.0.7
|
||||
github.com/ipfs/go-filestore v1.0.0 //indirect
|
||||
github.com/ipfs/go-ipfs v0.7.0
|
||||
github.com/ipfs/go-ipfs-blockstore v1.0.0
|
||||
github.com/ipfs/go-ipfs v0.10.0
|
||||
github.com/ipfs/go-ipfs-blockstore v1.0.1
|
||||
github.com/ipfs/go-ipfs-ds-help v1.0.0
|
||||
github.com/jmoiron/sqlx v1.2.0
|
||||
github.com/lib/pq v1.5.2
|
||||
github.com/mailgun/groupcache/v2 v2.2.1
|
||||
github.com/multiformats/go-multihash v0.0.14
|
||||
github.com/onsi/ginkgo v1.14.0
|
||||
github.com/onsi/gomega v1.10.1
|
||||
github.com/sirupsen/logrus v1.6.0
|
||||
github.com/spf13/cobra v1.0.0
|
||||
github.com/spf13/viper v1.7.0
|
||||
github.com/vulcanize/ipfs-ethdb v0.0.3
|
||||
github.com/jmoiron/sqlx v1.3.5
|
||||
github.com/lib/pq v1.10.5
|
||||
github.com/mailgun/groupcache/v2 v2.3.0
|
||||
github.com/multiformats/go-multihash v0.1.0
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/gomega v1.19.0
|
||||
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/v4 v4.0.2-alpha
|
||||
)
|
||||
|
||||
require (
|
||||
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc // indirect
|
||||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
|
||||
github.com/Stebalien/go-bitfield v0.0.1 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
|
||||
github.com/benbjohnson/clock v1.1.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||
github.com/btcsuite/btcd v0.22.1 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.1 // indirect
|
||||
github.com/cheekybits/genny v1.0.0 // indirect
|
||||
github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect
|
||||
github.com/cskr/pubsub v1.0.2 // indirect
|
||||
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
|
||||
github.com/flynn/noise v1.0.0 // indirect
|
||||
github.com/francoispqt/gojay v1.2.13 // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.1 // indirect
|
||||
github.com/go-ole/go-ole v1.2.1 // indirect
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/gopacket v1.1.19 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e // indirect
|
||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/huin/goupnp v1.0.3 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/ipfs/bbloom v0.0.4 // indirect
|
||||
github.com/ipfs/go-bitswap v0.4.0 // indirect
|
||||
github.com/ipfs/go-block-format v0.0.3 // indirect
|
||||
github.com/ipfs/go-cidutil v0.0.2 // indirect
|
||||
github.com/ipfs/go-datastore v0.4.6 // indirect
|
||||
github.com/ipfs/go-ds-measure v0.1.0 // indirect
|
||||
github.com/ipfs/go-fetcher v1.5.0 // indirect
|
||||
github.com/ipfs/go-filestore v1.0.0 //indirect
|
||||
github.com/ipfs/go-fs-lock v0.0.7 // indirect
|
||||
github.com/ipfs/go-graphsync v0.8.0 // indirect
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5 // indirect
|
||||
github.com/ipfs/go-ipfs-config v0.16.0 // indirect
|
||||
github.com/ipfs/go-ipfs-delay v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipfs-exchange-offline v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipfs-files v0.0.8 // indirect
|
||||
github.com/ipfs/go-ipfs-keystore v0.0.2 // indirect
|
||||
github.com/ipfs/go-ipfs-pinner v0.1.2 // indirect
|
||||
github.com/ipfs/go-ipfs-posinfo v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipfs-pq v0.0.2 // indirect
|
||||
github.com/ipfs/go-ipfs-provider v0.6.1 // indirect
|
||||
github.com/ipfs/go-ipfs-routing v0.1.0 // indirect
|
||||
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
|
||||
github.com/ipfs/go-ipld-cbor v0.0.5 // indirect
|
||||
github.com/ipfs/go-ipld-format v0.2.0 // indirect
|
||||
github.com/ipfs/go-ipld-legacy v0.1.0 // indirect
|
||||
github.com/ipfs/go-ipns v0.1.2 // indirect
|
||||
github.com/ipfs/go-log v1.0.5 // indirect
|
||||
github.com/ipfs/go-log/v2 v2.3.0 // indirect
|
||||
github.com/ipfs/go-merkledag v0.4.0 // indirect
|
||||
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
|
||||
github.com/ipfs/go-mfs v0.1.2 // indirect
|
||||
github.com/ipfs/go-namesys v0.3.1 // indirect
|
||||
github.com/ipfs/go-path v0.1.2 // indirect
|
||||
github.com/ipfs/go-peertaskqueue v0.4.0 // indirect
|
||||
github.com/ipfs/go-unixfs v0.2.5 // indirect
|
||||
github.com/ipfs/go-unixfsnode v1.1.3 // indirect
|
||||
github.com/ipfs/go-verifcid v0.0.1 // indirect
|
||||
github.com/ipfs/interface-go-ipfs-core v0.5.1 // indirect
|
||||
github.com/ipld/go-codec-dagpb v1.3.0 // indirect
|
||||
github.com/ipld/go-ipld-prime v0.12.2 // indirect
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
||||
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
|
||||
github.com/jbenet/goprocess v0.1.4 // indirect
|
||||
github.com/klauspost/compress v1.11.7 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
||||
github.com/koron/go-ssdp v0.0.2 // indirect
|
||||
github.com/libp2p/go-addr-util v0.1.0 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
||||
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
||||
github.com/libp2p/go-conn-security-multistream v0.2.1 // indirect
|
||||
github.com/libp2p/go-doh-resolver v0.3.1 // indirect
|
||||
github.com/libp2p/go-eventbus v0.2.1 // indirect
|
||||
github.com/libp2p/go-flow-metrics v0.0.3 // indirect
|
||||
github.com/libp2p/go-libp2p v0.15.0 // indirect
|
||||
github.com/libp2p/go-libp2p-asn-util v0.0.0-20200825225859-85005c6cf052 // indirect
|
||||
github.com/libp2p/go-libp2p-autonat v0.4.2 // indirect
|
||||
github.com/libp2p/go-libp2p-blankhost v0.2.0 // indirect
|
||||
github.com/libp2p/go-libp2p-circuit v0.4.0 // indirect
|
||||
github.com/libp2p/go-libp2p-connmgr v0.2.4 // indirect
|
||||
github.com/libp2p/go-libp2p-core v0.9.0 // indirect
|
||||
github.com/libp2p/go-libp2p-discovery v0.5.1 // indirect
|
||||
github.com/libp2p/go-libp2p-kad-dht v0.13.1 // indirect
|
||||
github.com/libp2p/go-libp2p-kbucket v0.4.7 // indirect
|
||||
github.com/libp2p/go-libp2p-loggables v0.1.0 // indirect
|
||||
github.com/libp2p/go-libp2p-mplex v0.4.1 // indirect
|
||||
github.com/libp2p/go-libp2p-nat v0.0.6 // indirect
|
||||
github.com/libp2p/go-libp2p-noise v0.2.2 // indirect
|
||||
github.com/libp2p/go-libp2p-peerstore v0.2.8 // indirect
|
||||
github.com/libp2p/go-libp2p-pnet v0.2.0 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub v0.5.4 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub-router v0.4.0 // indirect
|
||||
github.com/libp2p/go-libp2p-quic-transport v0.12.0 // indirect
|
||||
github.com/libp2p/go-libp2p-record v0.1.3 // indirect
|
||||
github.com/libp2p/go-libp2p-routing-helpers v0.2.3 // indirect
|
||||
github.com/libp2p/go-libp2p-swarm v0.5.3 // indirect
|
||||
github.com/libp2p/go-libp2p-tls v0.2.0 // indirect
|
||||
github.com/libp2p/go-libp2p-transport-upgrader v0.4.6 // indirect
|
||||
github.com/libp2p/go-libp2p-xor v0.0.0-20210714161855-5c005aca55db // indirect
|
||||
github.com/libp2p/go-libp2p-yamux v0.5.4 // indirect
|
||||
github.com/libp2p/go-maddr-filter v0.1.0 // indirect
|
||||
github.com/libp2p/go-mplex v0.3.0 // indirect
|
||||
github.com/libp2p/go-msgio v0.0.6 // indirect
|
||||
github.com/libp2p/go-nat v0.0.5 // indirect
|
||||
github.com/libp2p/go-netroute v0.1.6 // indirect
|
||||
github.com/libp2p/go-openssl v0.0.7 // indirect
|
||||
github.com/libp2p/go-reuseport v0.0.2 // indirect
|
||||
github.com/libp2p/go-reuseport-transport v0.0.5 // indirect
|
||||
github.com/libp2p/go-sockaddr v0.1.1 // indirect
|
||||
github.com/libp2p/go-stream-muxer-multistream v0.3.0 // indirect
|
||||
github.com/libp2p/go-tcp-transport v0.2.8 // indirect
|
||||
github.com/libp2p/go-ws-transport v0.5.0 // indirect
|
||||
github.com/libp2p/go-yamux/v2 v2.2.0 // indirect
|
||||
github.com/libp2p/zeroconf/v2 v2.0.0 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.26.0 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
|
||||
github.com/marten-seemann/qtls-go1-17 v0.1.1 // indirect
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.1 // indirect
|
||||
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/miekg/dns v1.1.43 // indirect
|
||||
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
|
||||
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
|
||||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/multiformats/go-base32 v0.0.3 // indirect
|
||||
github.com/multiformats/go-base36 v0.1.0 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.4.0 // indirect
|
||||
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
|
||||
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
|
||||
github.com/multiformats/go-multibase v0.0.3 // indirect
|
||||
github.com/multiformats/go-multicodec v0.3.0 // indirect
|
||||
github.com/multiformats/go-multistream v0.2.2 // indirect
|
||||
github.com/multiformats/go-varint v0.0.6 // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/pelletier/go-toml v1.9.4 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect
|
||||
github.com/prometheus/client_golang v1.11.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.30.0 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/prometheus/tsdb v0.7.1 // indirect
|
||||
github.com/segmentio/fasthash v1.0.3 // indirect
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
|
||||
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.8.2 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.5 // indirect
|
||||
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2 // indirect
|
||||
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
|
||||
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
|
||||
github.com/whyrusleeping/mdns v0.0.0-20190826153040-b9b60ed33aa9 // indirect
|
||||
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
|
||||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
go.opentelemetry.io/otel v0.20.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v0.20.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v0.20.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/dig v1.10.0 // indirect
|
||||
go.uber.org/fx v1.13.1 // indirect
|
||||
go.uber.org/multierr v1.7.0 // indirect
|
||||
go.uber.org/zap v1.19.0 // indirect
|
||||
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 // indirect
|
||||
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
lukechampine.com/blake3 v1.1.6 // indirect
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ package main
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/vulcanize/eth-ipfs-state-validator/cmd"
|
||||
"github.com/vulcanize/eth-ipfs-state-validator/v4/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
+4
-4
@@ -21,22 +21,22 @@ import (
|
||||
|
||||
"github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-cid"
|
||||
"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/ipfs/go-ipfs/core"
|
||||
"github.com/ipfs/go-ipfs/repo/fsrepo"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -28,8 +28,8 @@ import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/mailgun/groupcache/v2"
|
||||
|
||||
ipfsethdb "github.com/vulcanize/ipfs-ethdb"
|
||||
pgipfsethdb "github.com/vulcanize/ipfs-ethdb/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
|
||||
@@ -58,7 +58,7 @@ func NewPGIPFSValidator(db *sqlx.DB) *Validator {
|
||||
kvs: kvs,
|
||||
trieDB: trie.NewDatabase(kvs),
|
||||
stateDatabase: state.NewDatabase(database),
|
||||
db: database,
|
||||
db: database.(*pgipfsethdb.Database),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,3 +138,11 @@ func (v *Validator) ValidateStorageTrie(address common.Address, storageRoot comm
|
||||
}
|
||||
return it.Error()
|
||||
}
|
||||
|
||||
// Close implements io.Closer
|
||||
// it deregisters the groupcache name
|
||||
func (v *Validator) Close() error {
|
||||
groupcache.DeregisterGroup("kv")
|
||||
groupcache.DeregisterGroup("db")
|
||||
return nil
|
||||
}
|
||||
|
||||
+26
-22
@@ -21,28 +21,29 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ipfs/go-cid/_rsrch/cidiface"
|
||||
cid "github.com/ipfs/go-cid/_rsrch/cidiface"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/multiformats/go-multihash"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/eth-ipfs-state-validator/pkg"
|
||||
"github.com/vulcanize/ipfs-ethdb/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")
|
||||
nullCodeHash = crypto.Keccak256Hash([]byte{})
|
||||
emptyRootNode, _ = rlp.EncodeToBytes([]byte{})
|
||||
emptyRootNode, _ = rlp.EncodeToBytes(&[]byte{})
|
||||
emptyContractRoot = crypto.Keccak256Hash(emptyRootNode)
|
||||
|
||||
stateBranchRootNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
stateBranchRootNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
crypto.Keccak256(bankAccountLeafNode),
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
@@ -65,62 +66,62 @@ var (
|
||||
|
||||
mockCode = []byte{1, 2, 3, 4, 5}
|
||||
codeHash = crypto.Keccak256Hash(mockCode)
|
||||
contractAccount, _ = rlp.EncodeToBytes(state.Account{
|
||||
contractAccount, _ = rlp.EncodeToBytes(&types.StateAccount{
|
||||
Nonce: 1,
|
||||
Balance: big.NewInt(0),
|
||||
CodeHash: codeHash.Bytes(),
|
||||
Root: crypto.Keccak256Hash(storageBranchRootNode),
|
||||
})
|
||||
contractAccountLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
contractAccountLeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45"),
|
||||
contractAccount,
|
||||
})
|
||||
|
||||
minerAccount, _ = rlp.EncodeToBytes(state.Account{
|
||||
minerAccount, _ = rlp.EncodeToBytes(&types.StateAccount{
|
||||
Nonce: 0,
|
||||
Balance: big.NewInt(1000),
|
||||
CodeHash: nullCodeHash.Bytes(),
|
||||
Root: emptyContractRoot,
|
||||
})
|
||||
minerAccountLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
minerAccountLeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
common.Hex2Bytes("3380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a"),
|
||||
minerAccount,
|
||||
})
|
||||
|
||||
account1, _ = rlp.EncodeToBytes(state.Account{
|
||||
account1, _ = rlp.EncodeToBytes(&types.StateAccount{
|
||||
Nonce: 2,
|
||||
Balance: big.NewInt(1000),
|
||||
CodeHash: nullCodeHash.Bytes(),
|
||||
Root: emptyContractRoot,
|
||||
})
|
||||
account1LeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
account1LeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
common.Hex2Bytes("3926db69aaced518e9b9f0f434a473e7174109c943548bb8f23be41ca76d9ad2"),
|
||||
account1,
|
||||
})
|
||||
|
||||
account2, _ = rlp.EncodeToBytes(state.Account{
|
||||
account2, _ = rlp.EncodeToBytes(&types.StateAccount{
|
||||
Nonce: 0,
|
||||
Balance: big.NewInt(1000),
|
||||
CodeHash: nullCodeHash.Bytes(),
|
||||
Root: emptyContractRoot,
|
||||
})
|
||||
account2LeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
account2LeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45"),
|
||||
account2,
|
||||
})
|
||||
|
||||
bankAccount, _ = rlp.EncodeToBytes(state.Account{
|
||||
bankAccount, _ = rlp.EncodeToBytes(&types.StateAccount{
|
||||
Nonce: 2,
|
||||
Balance: big.NewInt(1000),
|
||||
CodeHash: nullCodeHash.Bytes(),
|
||||
Root: emptyContractRoot,
|
||||
})
|
||||
bankAccountLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
bankAccountLeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
common.Hex2Bytes("30bf49f440a1cd0527e4d06e2765654c0f56452257516d793a9b8d604dcfdf2a"),
|
||||
bankAccount,
|
||||
})
|
||||
|
||||
storageBranchRootNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
storageBranchRootNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
[]byte{},
|
||||
[]byte{},
|
||||
crypto.Keccak256(slot0StorageLeafNode),
|
||||
@@ -141,11 +142,11 @@ var (
|
||||
})
|
||||
storageRoot = crypto.Keccak256Hash(storageBranchRootNode)
|
||||
|
||||
slot0StorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
slot0StorageLeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
common.Hex2Bytes("390decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563"),
|
||||
slot0StorageValue,
|
||||
})
|
||||
slot1StorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{
|
||||
slot1StorageLeafNode, _ = rlp.EncodeToBytes(&[]interface{}{
|
||||
common.Hex2Bytes("310e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6"),
|
||||
slot1StorageValue,
|
||||
})
|
||||
@@ -201,6 +202,9 @@ var _ = Describe("PG-IPFS Validator", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
v = validator.NewPGIPFSValidator(db)
|
||||
})
|
||||
AfterEach(func() {
|
||||
v.Close()
|
||||
})
|
||||
Describe("ValidateTrie", func() {
|
||||
AfterEach(func() {
|
||||
err = validator.ResetTestDB(db)
|
||||
@@ -236,7 +240,7 @@ var _ = Describe("PG-IPFS Validator", func() {
|
||||
loadTrie(trieStateNodes, trieStorageNodes)
|
||||
err = v.ValidateTrie(stateRoot)
|
||||
Expect(err).To(HaveOccurred())
|
||||
subStr := fmt.Sprintf("code %s: sql: no rows in result set", codeHash.Hex()[2:])
|
||||
subStr := fmt.Sprintf("code %s: not found", codeHash.Hex()[2:])
|
||||
Expect(err.Error()).To(ContainSubstring(subStr))
|
||||
})
|
||||
It("Returns no error if the entire state (state trie and storage tries) can be validated", func() {
|
||||
@@ -299,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()
|
||||
|
||||
Reference in New Issue
Block a user