Compare commits
10
Commits
v4.0.13-alpha
...
v5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdff0776fd | ||
|
|
e1ab6a17b8 | ||
|
|
471da6be82 | ||
|
|
5eeeecf667 | ||
|
|
f09675a0f3 | ||
|
|
cc53aa02b2 | ||
|
|
0671028e81 | ||
|
|
63c11188a3 | ||
|
|
05946fc063 | ||
|
|
07b5ceb36c |
@@ -1,30 +0,0 @@
|
||||
# This workflow will build a golang project
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
|
||||
|
||||
name: Basic Go build and test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
- name : Bring up docker DB containers
|
||||
run: docker compose up -d
|
||||
|
||||
- name: Run test
|
||||
run: |
|
||||
sleep 30;
|
||||
go test -v ./...
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Run tests
|
||||
on:
|
||||
- pull_request
|
||||
|
||||
env:
|
||||
# Needed until we can incorporate docker startup into the executor container
|
||||
DOCKER_HOST: unix:///var/run/dind.sock
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Run unit tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
check-latest: true
|
||||
- name: Run dockerd
|
||||
run: |
|
||||
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
||||
sleep 5
|
||||
- name: Run DB container
|
||||
working-directory: ./test
|
||||
run: docker compose up --wait --quiet-pull
|
||||
- name: Set Gitea access token
|
||||
env:
|
||||
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
||||
run: |
|
||||
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
|
||||
|
||||
- name: Build and run tests
|
||||
run: |
|
||||
until [[ "$(docker inspect -f '{{.State.Status}}' test-ipld-eth-db)" = 'running' ]]
|
||||
do sleep 1; done &
|
||||
go build ./...
|
||||
wait $!
|
||||
go test -p 1 -v ./...
|
||||
@@ -1,6 +1,6 @@
|
||||
# eth-ipfs-state-validator
|
||||
|
||||
[](https://goreportcard.com/report/github.com/vulcanize/eth-ipfs-state-validator)
|
||||
[](https://goreportcard.com/report/github.com/cerc-io/eth-ipfs-state-validator)
|
||||
|
||||
> Uses [ipfs-ethdb](https://github.com/cerc-io/ipfs-ethdb/tree/master/postgres) to validate completeness of IPFS Ethereum state data
|
||||
|
||||
@@ -42,7 +42,7 @@ Postgres DB config:
|
||||
|
||||
```toml
|
||||
[database]
|
||||
name = "vulcanize_public"
|
||||
name = "cerc_public"
|
||||
hostname = "localhost"
|
||||
user = "postgres"
|
||||
password = ""
|
||||
@@ -50,7 +50,7 @@ Postgres DB config:
|
||||
```
|
||||
|
||||
## Maintainers
|
||||
@vulcanize
|
||||
@cerc-io
|
||||
@AFDudley
|
||||
@i-norden
|
||||
|
||||
@@ -60,4 +60,4 @@ Contributions are welcome!
|
||||
VulcanizeDB follows the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct).
|
||||
|
||||
## License
|
||||
[AGPL-3.0](LICENSE) © Vulcanize Inc
|
||||
[AGPL-3.0](LICENSE) © Vulcanize Inc
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ func init() {
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file location")
|
||||
rootCmd.PersistentFlags().String("logfile", "", "file path for logging")
|
||||
rootCmd.PersistentFlags().String("database-name", "vulcanize_public", "database name")
|
||||
rootCmd.PersistentFlags().String("database-name", "cerc_public", "database name")
|
||||
rootCmd.PersistentFlags().Int("database-port", 5432, "database port")
|
||||
rootCmd.PersistentFlags().String("database-hostname", "localhost", "database hostname")
|
||||
rootCmd.PersistentFlags().String("database-user", "", "database user")
|
||||
|
||||
+23
-19
@@ -24,7 +24,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
validator "github.com/cerc-io/eth-ipfs-state-validator/v4/pkg"
|
||||
validator "github.com/cerc-io/eth-ipfs-state-validator/v5/pkg"
|
||||
)
|
||||
|
||||
// validateTrieCmd represents the validateTrie command
|
||||
@@ -70,26 +70,30 @@ func validateTrie() {
|
||||
stateRootStr := viper.GetString("validator.stateRoot")
|
||||
storageRootStr := viper.GetString("validator.storageRoot")
|
||||
contractAddrStr := viper.GetString("validator.address")
|
||||
|
||||
if stateRootStr == "" {
|
||||
logWithCommand.Fatal("must provide a state root for state trie validation")
|
||||
}
|
||||
stateRoot := common.HexToHash(stateRootStr)
|
||||
|
||||
traversal := strings.ToLower(viper.GetString("validator.type"))
|
||||
switch traversal {
|
||||
case "f", "full":
|
||||
if stateRootStr == "" {
|
||||
logWithCommand.Fatal("must provide a state root for full state validation")
|
||||
}
|
||||
stateRoot := common.HexToHash(stateRootStr)
|
||||
logWithCommand.
|
||||
WithField("root", stateRoot).
|
||||
Debug("Validating full state")
|
||||
if err = v.ValidateTrie(stateRoot); err != nil {
|
||||
logWithCommand.Fatalf("State for root %s is not complete\r\nerr: %v", stateRoot.String(), err)
|
||||
logWithCommand.Fatalf("Validation failed: %v", err)
|
||||
}
|
||||
logWithCommand.Infof("State for root %s is complete", stateRoot.String())
|
||||
logWithCommand.Infof("State for root %s is complete", stateRoot)
|
||||
case "state":
|
||||
if stateRootStr == "" {
|
||||
logWithCommand.Fatal("must provide a state root for state trie validation")
|
||||
}
|
||||
stateRoot := common.HexToHash(stateRootStr)
|
||||
logWithCommand.
|
||||
WithField("root", stateRoot).
|
||||
Debug("Validating state trie")
|
||||
if err = v.ValidateStateTrie(stateRoot); err != nil {
|
||||
logWithCommand.Fatalf("State trie for root %s is not complete\r\nerr: %v", stateRoot.String(), err)
|
||||
logWithCommand.Fatalf("Validation failed: %s", err)
|
||||
}
|
||||
logWithCommand.Infof("State trie for root %s is complete", stateRoot.String())
|
||||
logWithCommand.Infof("State trie for root %s is complete", stateRoot)
|
||||
case "storage":
|
||||
if storageRootStr == "" {
|
||||
logWithCommand.Fatal("must provide a storage root for storage trie validation")
|
||||
@@ -97,16 +101,16 @@ func validateTrie() {
|
||||
if contractAddrStr == "" {
|
||||
logWithCommand.Fatal("must provide a contract address for storage trie validation")
|
||||
}
|
||||
if stateRootStr == "" {
|
||||
logWithCommand.Fatal("must provide a state root for state trie validation")
|
||||
}
|
||||
storageRoot := common.HexToHash(storageRootStr)
|
||||
addr := common.HexToAddress(contractAddrStr)
|
||||
stateRoot := common.HexToHash(stateRootStr)
|
||||
logWithCommand.
|
||||
WithField("contract", addr).
|
||||
WithField("storage root", storageRoot).
|
||||
Debug("Validating storage trie")
|
||||
if err = v.ValidateStorageTrie(stateRoot, addr, storageRoot); err != nil {
|
||||
logWithCommand.Fatalf("Storage trie for contract %s and root %s not complete\r\nerr: %v", addr.String(), storageRoot.String(), err)
|
||||
logWithCommand.Fatalf("Validation failed", err)
|
||||
}
|
||||
logWithCommand.Infof("Storage trie for contract %s and root %s is complete", addr.String(), storageRoot.String())
|
||||
logWithCommand.Infof("Storage trie for contract %s and root %s is complete", addr, storageRoot)
|
||||
default:
|
||||
logWithCommand.Fatalf("Invalid traversal level: '%s'", traversal)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[database]
|
||||
name = "vulcanize_public"
|
||||
name = "cerc_public"
|
||||
hostname = "localhost"
|
||||
port = 5432
|
||||
user = "postgres"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[database]
|
||||
name = "vulcanize_testing"
|
||||
name = "cerc_testing"
|
||||
hostname = "localhost"
|
||||
port = 5432
|
||||
|
||||
@@ -1,74 +1,78 @@
|
||||
module github.com/cerc-io/eth-ipfs-state-validator/v4
|
||||
module github.com/cerc-io/eth-ipfs-state-validator/v5
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/cerc-io/go-eth-state-node-iterator v1.1.11
|
||||
github.com/cerc-io/ipfs-ethdb/v4 v4.0.12-alpha
|
||||
github.com/ethereum/go-ethereum v1.11.4
|
||||
github.com/ipfs/go-blockservice v0.4.0
|
||||
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/ipfs/kubo v0.14.0
|
||||
github.com/cerc-io/eth-iterator-utils v0.1.1
|
||||
github.com/cerc-io/ipfs-ethdb/v5 v5.0.0-alpha
|
||||
github.com/cerc-io/ipld-eth-statedb v0.0.5-alpha
|
||||
github.com/ethereum/go-ethereum v1.11.6
|
||||
github.com/ipfs/go-blockservice v0.5.0
|
||||
github.com/ipfs/go-cid v0.4.1
|
||||
github.com/ipfs/kubo v0.18.1
|
||||
github.com/jmoiron/sqlx v1.3.5
|
||||
github.com/lib/pq v1.10.7
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/mailgun/groupcache/v2 v2.3.0
|
||||
github.com/multiformats/go-multihash v0.2.0
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/gomega v1.19.0
|
||||
github.com/multiformats/go-multihash v0.2.3
|
||||
github.com/onsi/ginkgo/v2 v2.9.2
|
||||
github.com/onsi/gomega v1.27.4
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/spf13/cobra v1.4.0
|
||||
github.com/spf13/viper v1.11.0
|
||||
golang.org/x/sync v0.1.0
|
||||
golang.org/x/sync v0.3.0
|
||||
)
|
||||
|
||||
require (
|
||||
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc // indirect
|
||||
github.com/DataDog/zstd v1.5.2 // indirect
|
||||
github.com/Stebalien/go-bitfield v0.0.1 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect
|
||||
github.com/DataDog/zstd v1.5.5 // indirect
|
||||
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
|
||||
github.com/benbjohnson/clock v1.3.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/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/cerc-io/plugeth-statediff v0.1.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/cheekybits/genny v1.0.0 // indirect
|
||||
github.com/cockroachdb/errors v1.9.1 // indirect
|
||||
github.com/cockroachdb/errors v1.10.0 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
||||
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 // indirect
|
||||
github.com/cockroachdb/redact v1.1.3 // indirect
|
||||
github.com/containerd/cgroups v1.0.3 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||
github.com/cockroachdb/pebble v0.0.0-20230720154706-692f3b61a3c4 // indirect
|
||||
github.com/cockroachdb/redact v1.1.5 // indirect
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230613231145-182959a1fad6 // indirect
|
||||
github.com/containerd/cgroups v1.0.4 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // 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/docker/go-units v0.4.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||
github.com/elastic/gosigar v0.14.2 // indirect
|
||||
github.com/emirpasic/gods v1.18.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.6.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.17.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.22.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-stack/stack v1.8.1 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/gofrs/flock v0.8.1 // 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/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/gopacket v1.1.19 // indirect
|
||||
github.com/google/pprof v0.0.0-20221203041831-ce31453925ec // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
@@ -76,128 +80,128 @@ require (
|
||||
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/holiman/uint256 v1.2.3 // indirect
|
||||
github.com/huin/goupnp v1.2.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/ipfs/bbloom v0.0.4 // indirect
|
||||
github.com/ipfs/go-bitfield v1.0.0 // indirect
|
||||
github.com/ipfs/go-bitswap v0.8.0 // indirect
|
||||
github.com/ipfs/go-bitswap v0.11.0 // indirect
|
||||
github.com/ipfs/go-block-format v0.0.3 // indirect
|
||||
github.com/ipfs/go-cidutil v0.1.0 // indirect
|
||||
github.com/ipfs/go-datastore v0.5.1 // indirect
|
||||
github.com/ipfs/go-delegated-routing v0.3.0 // indirect
|
||||
github.com/ipfs/go-datastore v0.6.0 // indirect
|
||||
github.com/ipfs/go-delegated-routing v0.7.0 // indirect
|
||||
github.com/ipfs/go-ds-measure v0.2.0 // indirect
|
||||
github.com/ipfs/go-fetcher v1.6.1 // indirect
|
||||
github.com/ipfs/go-filestore v1.2.0 //indirect
|
||||
github.com/ipfs/go-fs-lock v0.0.7 // indirect
|
||||
github.com/ipfs/go-graphsync v0.13.1 // indirect
|
||||
github.com/ipfs/go-graphsync v0.14.1 // indirect
|
||||
github.com/ipfs/go-ipfs-blockstore v1.2.0 // indirect
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5 // indirect
|
||||
github.com/ipfs/go-ipfs-delay v0.0.1 // indirect
|
||||
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.2.0 // indirect
|
||||
github.com/ipfs/go-ipfs-exchange-offline v0.3.0 // indirect
|
||||
github.com/ipfs/go-ipfs-files v0.1.1 // indirect
|
||||
github.com/ipfs/go-ipfs-keystore v0.0.2 // indirect
|
||||
github.com/ipfs/go-ipfs-keystore v0.1.0 // indirect
|
||||
github.com/ipfs/go-ipfs-pinner v0.2.1 // 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.7.1 // indirect
|
||||
github.com/ipfs/go-ipfs-routing v0.2.1 // indirect
|
||||
github.com/ipfs/go-ipfs-provider v0.8.1 // indirect
|
||||
github.com/ipfs/go-ipfs-routing v0.3.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-cbor v0.0.6 // indirect
|
||||
github.com/ipfs/go-ipld-format v0.4.0 // indirect
|
||||
github.com/ipfs/go-ipld-legacy v0.1.1 // indirect
|
||||
github.com/ipfs/go-ipns v0.1.2 // indirect
|
||||
github.com/ipfs/go-ipns v0.3.0 // indirect
|
||||
github.com/ipfs/go-libipfs v0.2.0 // indirect
|
||||
github.com/ipfs/go-log v1.0.5 // indirect
|
||||
github.com/ipfs/go-log/v2 v2.5.1 // indirect
|
||||
github.com/ipfs/go-merkledag v0.6.0 // indirect
|
||||
github.com/ipfs/go-merkledag v0.9.0 // indirect
|
||||
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
|
||||
github.com/ipfs/go-mfs v0.2.1 // indirect
|
||||
github.com/ipfs/go-namesys v0.5.0 // indirect
|
||||
github.com/ipfs/go-namesys v0.6.0 // indirect
|
||||
github.com/ipfs/go-path v0.3.0 // indirect
|
||||
github.com/ipfs/go-peertaskqueue v0.7.1 // indirect
|
||||
github.com/ipfs/go-unixfs v0.4.0 // indirect
|
||||
github.com/ipfs/go-unixfsnode v1.4.0 // indirect
|
||||
github.com/ipfs/go-verifcid v0.0.1 // indirect
|
||||
github.com/ipfs/interface-go-ipfs-core v0.7.0 // indirect
|
||||
github.com/ipld/edelweiss v0.1.4 // indirect
|
||||
github.com/ipld/go-codec-dagpb v1.4.0 // indirect
|
||||
github.com/ipld/go-ipld-prime v0.17.0 // indirect
|
||||
github.com/ipfs/go-peertaskqueue v0.8.0 // indirect
|
||||
github.com/ipfs/go-unixfs v0.4.2 // indirect
|
||||
github.com/ipfs/go-unixfsnode v1.5.1 // indirect
|
||||
github.com/ipfs/go-verifcid v0.0.2 // indirect
|
||||
github.com/ipfs/interface-go-ipfs-core v0.8.2 // indirect
|
||||
github.com/ipld/edelweiss v0.2.0 // indirect
|
||||
github.com/ipld/go-codec-dagpb v1.5.0 // indirect
|
||||
github.com/ipld/go-ipld-prime v0.19.0 // 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.15.15 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.0.12 // indirect
|
||||
github.com/koron/go-ssdp v0.0.2 // indirect
|
||||
github.com/klauspost/compress v1.16.7 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||
github.com/koron/go-ssdp v0.0.3 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/libp2p/go-cidranger v1.1.0 // indirect
|
||||
github.com/libp2p/go-doh-resolver v0.4.0 // 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.20.3 // indirect
|
||||
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
|
||||
github.com/libp2p/go-libp2p v0.24.2 // indirect
|
||||
github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect
|
||||
github.com/libp2p/go-libp2p-core v0.16.1 // indirect
|
||||
github.com/libp2p/go-libp2p-discovery v0.7.0 // indirect
|
||||
github.com/libp2p/go-libp2p-kad-dht v0.16.0 // 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-peerstore v0.6.0 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub v0.6.1 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub-router v0.5.0 // indirect
|
||||
github.com/libp2p/go-libp2p-record v0.1.3 // indirect
|
||||
github.com/libp2p/go-libp2p-resource-manager v0.3.0 // indirect
|
||||
github.com/libp2p/go-libp2p-routing-helpers v0.2.3 // indirect
|
||||
github.com/libp2p/go-libp2p-swarm v0.11.0 // indirect
|
||||
github.com/libp2p/go-libp2p-kad-dht v0.20.0 // indirect
|
||||
github.com/libp2p/go-libp2p-kbucket v0.5.0 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub v0.8.3 // indirect
|
||||
github.com/libp2p/go-libp2p-pubsub-router v0.6.0 // indirect
|
||||
github.com/libp2p/go-libp2p-record v0.2.0 // indirect
|
||||
github.com/libp2p/go-libp2p-routing-helpers v0.6.0 // indirect
|
||||
github.com/libp2p/go-libp2p-xor v0.1.0 // indirect
|
||||
github.com/libp2p/go-mplex v0.7.0 // indirect
|
||||
github.com/libp2p/go-msgio v0.2.0 // indirect
|
||||
github.com/libp2p/go-nat v0.1.0 // indirect
|
||||
github.com/libp2p/go-netroute v0.2.0 // indirect
|
||||
github.com/libp2p/go-openssl v0.0.7 // indirect
|
||||
github.com/libp2p/go-netroute v0.2.1 // indirect
|
||||
github.com/libp2p/go-openssl v0.1.0 // indirect
|
||||
github.com/libp2p/go-reuseport v0.2.0 // indirect
|
||||
github.com/libp2p/go-yamux/v3 v3.1.2 // indirect
|
||||
github.com/libp2p/zeroconf/v2 v2.1.1 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.27.1 // indirect
|
||||
github.com/libp2p/go-yamux/v4 v4.0.0 // indirect
|
||||
github.com/libp2p/zeroconf/v2 v2.2.0 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.31.1 // 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/qpack v0.3.0 // indirect
|
||||
github.com/marten-seemann/qtls-go1-18 v0.1.3 // indirect
|
||||
github.com/marten-seemann/qtls-go1-19 v0.1.1 // indirect
|
||||
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/marten-seemann/webtransport-go v0.4.3 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mattn/go-pointer v0.0.1 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/miekg/dns v1.1.48 // indirect
|
||||
github.com/miekg/dns v1.1.50 // indirect
|
||||
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
|
||||
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/multiformats/go-base32 v0.0.4 // indirect
|
||||
github.com/multiformats/go-base36 v0.1.0 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.5.0 // indirect
|
||||
github.com/multiformats/go-base32 v0.1.0 // indirect
|
||||
github.com/multiformats/go-base36 v0.2.0 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.8.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.1.0 // indirect
|
||||
github.com/multiformats/go-multicodec v0.5.0 // indirect
|
||||
github.com/multiformats/go-multibase v0.2.0 // indirect
|
||||
github.com/multiformats/go-multicodec v0.7.0 // indirect
|
||||
github.com/multiformats/go-multistream v0.3.3 // indirect
|
||||
github.com/multiformats/go-varint v0.0.6 // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/multiformats/go-varint v0.0.7 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/opencontainers/runtime-spec v1.0.2 // indirect
|
||||
github.com/openrelayxyz/plugeth-utils v1.2.0 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
|
||||
github.com/pelletier/go-toml v1.9.4 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.5 // 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.14.0 // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.37.1 // indirect
|
||||
github.com/prometheus/procfs v0.9.0 // indirect
|
||||
github.com/raulk/clock v1.1.0 // indirect
|
||||
github.com/raulk/go-watchdog v1.2.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
||||
github.com/prometheus/client_golang v1.16.0 // indirect
|
||||
github.com/prometheus/client_model v0.4.0 // indirect
|
||||
github.com/prometheus/common v0.44.0 // indirect
|
||||
github.com/prometheus/procfs v0.11.0 // indirect
|
||||
github.com/raulk/go-watchdog v1.3.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/samber/lo v1.36.0 // indirect
|
||||
github.com/segmentio/fasthash v1.0.3 // indirect
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
|
||||
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
|
||||
@@ -208,42 +212,44 @@ require (
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
|
||||
github.com/tidwall/gjson v1.14.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.11 // indirect
|
||||
github.com/tklauser/numcpus v0.6.0 // indirect
|
||||
github.com/wI2L/jsondiff v0.2.0 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
github.com/urfave/cli/v2 v2.25.7 // 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/cbor-gen v0.0.0-20221220214510-0333c149dec0 // 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/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect
|
||||
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/otel v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.7.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/dig v1.14.0 // indirect
|
||||
go.uber.org/fx v1.16.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
go.uber.org/zap v1.21.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/dig v1.15.0 // indirect
|
||||
go.uber.org/fx v1.18.2 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
|
||||
golang.org/x/crypto v0.6.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect
|
||||
golang.org/x/mod v0.6.0 // indirect
|
||||
golang.org/x/net v0.6.0 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
golang.org/x/tools v0.2.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
golang.org/x/crypto v0.11.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
|
||||
golang.org/x/mod v0.11.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sys v0.10.0 // indirect
|
||||
golang.org/x/text v0.11.0 // indirect
|
||||
golang.org/x/tools v0.7.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // 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.1 // indirect
|
||||
lukechampine.com/blake3 v1.1.7 // indirect
|
||||
lukechampine.com/blake3 v1.2.1 // indirect
|
||||
)
|
||||
|
||||
replace github.com/ethereum/go-ethereum v1.11.4 => github.com/cerc-io/go-ethereum v1.11.4-statediff-4.3.9-alpha
|
||||
replace (
|
||||
github.com/cerc-io/eth-iterator-utils => git.vdb.to/cerc-io/eth-iterator-utils v0.1.2
|
||||
github.com/cerc-io/eth-testing => git.vdb.to/cerc-io/eth-testing v0.3.1
|
||||
github.com/cerc-io/ipld-eth-statedb => git.vdb.to/cerc-io/ipld-eth-statedb v0.0.6-alpha
|
||||
github.com/cerc-io/plugeth-statediff => git.vdb.to/cerc-io/plugeth-statediff v0.1.4
|
||||
github.com/ethereum/go-ethereum => git.vdb.to/cerc-io/plugeth v0.0.0-20230808125822-691dc334fab1
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ package main
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/cerc-io/eth-ipfs-state-validator/v4/cmd"
|
||||
"github.com/cerc-io/eth-ipfs-state-validator/v5/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ package validator_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
|
||||
+8
-10
@@ -2,21 +2,19 @@ package validator_test
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||
dshelp "github.com/ipfs/go-ipfs-ds-help"
|
||||
"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, blockNumber uint64) (string, error) {
|
||||
func PublishRaw(tx *sqlx.Tx, codec, mh uint64, raw []byte, blockNumber uint64) error {
|
||||
c, err := RawdataToCid(codec, raw, mh)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return err
|
||||
}
|
||||
dbKey := dshelp.MultihashToDsKey(c.Hash())
|
||||
prefixedKey := blockstore.BlockPrefix.String() + dbKey.String()
|
||||
_, 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
|
||||
_, err = tx.Exec(
|
||||
`INSERT INTO ipld.blocks (key, data, block_number) VALUES ($1, $2, $3) ON CONFLICT DO NOTHING`,
|
||||
c.String(), raw, blockNumber)
|
||||
return err
|
||||
}
|
||||
|
||||
// RawdataToCid takes the desired codec, multihash type, and a slice of bytes
|
||||
@@ -34,8 +32,8 @@ func RawdataToCid(codec uint64, rawdata []byte, multiHash uint64) (cid.Cid, erro
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// ResetTestDB drops all rows in the test db public.blocks table
|
||||
// ResetTestDB truncates all used tables from the test DB
|
||||
func ResetTestDB(db *sqlx.DB) error {
|
||||
_, err := db.Exec("DELETE FROM public.blocks")
|
||||
_, err := db.Exec("TRUNCATE ipld.blocks")
|
||||
return err
|
||||
}
|
||||
|
||||
+51
-24
@@ -20,26 +20,30 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/spf13/viper"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"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/ethdb"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/ipfs/go-blockservice"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/mailgun/groupcache/v2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
nodeiter "github.com/cerc-io/go-eth-state-node-iterator"
|
||||
"github.com/cerc-io/go-eth-state-node-iterator/tracker"
|
||||
ipfsethdb "github.com/cerc-io/ipfs-ethdb/v4"
|
||||
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v4/postgres"
|
||||
iterutils "github.com/cerc-io/eth-iterator-utils"
|
||||
"github.com/cerc-io/eth-iterator-utils/tracker"
|
||||
ipfsethdb "github.com/cerc-io/ipfs-ethdb/v5"
|
||||
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v5/postgres/v0"
|
||||
"github.com/cerc-io/ipld-eth-statedb/trie_by_cid/state"
|
||||
"github.com/cerc-io/ipld-eth-statedb/trie_by_cid/trie"
|
||||
)
|
||||
|
||||
// Validator is used for validating Ethereum state and storage tries on PG-IPFS
|
||||
@@ -142,7 +146,7 @@ func (v *Validator) ValidateTrie(stateRoot common.Hash) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
iterate := func(it trie.NodeIterator) error { return v.iterate(it, true) }
|
||||
iterate := func(ctx context.Context, it trie.NodeIterator) error { return v.iterate(ctx, it, true) }
|
||||
return iterateTracked(t, fmt.Sprintf(v.params.RecoveryFormat, fullTraversal), v.params.Workers, iterate)
|
||||
}
|
||||
|
||||
@@ -154,7 +158,7 @@ func (v *Validator) ValidateStateTrie(stateRoot common.Hash) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
iterate := func(it trie.NodeIterator) error { return v.iterate(it, false) }
|
||||
iterate := func(ctx context.Context, it trie.NodeIterator) error { return v.iterate(ctx, it, false) }
|
||||
return iterateTracked(t, fmt.Sprintf(v.params.RecoveryFormat, stateTraversal), v.params.Workers, iterate)
|
||||
}
|
||||
|
||||
@@ -166,7 +170,7 @@ func (v *Validator) ValidateStorageTrie(stateRoot common.Hash, address common.Ad
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
iterate := func(it trie.NodeIterator) error { return v.iterate(it, false) }
|
||||
iterate := func(ctx context.Context, it trie.NodeIterator) error { return v.iterate(ctx, it, false) }
|
||||
return iterateTracked(t, fmt.Sprintf(v.params.RecoveryFormat, storageTraversal), v.params.Workers, iterate)
|
||||
}
|
||||
|
||||
@@ -180,12 +184,18 @@ func (v *Validator) Close() error {
|
||||
|
||||
// Traverses one iterator fully
|
||||
// If storage = true, also traverse storage tries for each leaf.
|
||||
func (v *Validator) iterate(it trie.NodeIterator, storage bool) error {
|
||||
func (v *Validator) iterate(ctx context.Context, it trie.NodeIterator, storage bool) error {
|
||||
// Iterate through entire state trie. it.Next() will return false when we have
|
||||
// either completed iteration of the entire trie or run into an error (e.g. a
|
||||
// missing node). If we are able to iterate through the entire trie without error
|
||||
// then the trie is complete.
|
||||
for it.Next(true) {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
// This block adapted from geth - core/state/iterator.go
|
||||
// If storage is not requested, or the state trie node is an internal entry, skip
|
||||
if !storage || !it.Leaf() {
|
||||
@@ -202,16 +212,15 @@ func (v *Validator) iterate(it trie.NodeIterator, storage bool) error {
|
||||
}
|
||||
dataIt := dataTrie.NodeIterator(nil)
|
||||
if !bytes.Equal(account.CodeHash, emptyCodeHash) {
|
||||
addrHash := common.BytesToHash(it.LeafKey())
|
||||
_, err := v.stateDatabase.ContractCode(addrHash, common.BytesToHash(account.CodeHash))
|
||||
_, err := v.stateDatabase.ContractCode(common.BytesToHash(account.CodeHash))
|
||||
if err != nil {
|
||||
return fmt.Errorf("code %x: %w (path %x)", account.CodeHash, err, nodeiter.HexToKeyBytes(it.Path()))
|
||||
return fmt.Errorf("code hash %x: %w (path %x)", account.CodeHash, err, iterutils.HexToKeyBytes(it.Path()))
|
||||
}
|
||||
}
|
||||
for dataIt.Next(true) {
|
||||
}
|
||||
if dataIt.Error() != nil {
|
||||
return fmt.Errorf("data iterator error (path %x): %w", nodeiter.HexToKeyBytes(dataIt.Path()), dataIt.Error())
|
||||
return fmt.Errorf("data iterator error (path %x): %w", iterutils.HexToKeyBytes(dataIt.Path()), dataIt.Error())
|
||||
}
|
||||
}
|
||||
return it.Error()
|
||||
@@ -219,18 +228,22 @@ func (v *Validator) iterate(it trie.NodeIterator, storage bool) error {
|
||||
|
||||
// Traverses each iterator in a separate goroutine.
|
||||
// Dumps to a recovery file on failure or interrupt.
|
||||
func iterateTracked(tree state.Trie, recoveryFile string, iterCount uint, fn func(trie.NodeIterator) error) error {
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
func iterateTracked(
|
||||
tree state.Trie,
|
||||
recoveryFile string,
|
||||
iterCount uint,
|
||||
fn func(context.Context, trie.NodeIterator) error,
|
||||
) error {
|
||||
tracker := tracker.New(recoveryFile, iterCount)
|
||||
tracker.CaptureSignal(cancelCtx)
|
||||
halt := func() {
|
||||
if err := tracker.HaltAndDump(); err != nil {
|
||||
log.Errorf("writing recovery file: %s", recoveryFile)
|
||||
if err := tracker.CloseAndSave(); err != nil {
|
||||
log.Errorf("failed to write recovery file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// attempt to restore from recovery file if it exists
|
||||
iters, err := tracker.Restore(tree)
|
||||
iters, _, err := tracker.Restore(tree.NodeIterator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -239,18 +252,32 @@ func iterateTracked(tree state.Trie, recoveryFile string, iterCount uint, fn fun
|
||||
}
|
||||
|
||||
if iters == nil { // nothing restored
|
||||
iters = nodeiter.SubtrieIterators(tree, iterCount)
|
||||
iters = iterutils.SubtrieIterators(tree.NodeIterator, iterCount)
|
||||
for i, it := range iters {
|
||||
iters[i] = tracker.Tracked(it, nil)
|
||||
iters[i] = tracker.Tracked(it)
|
||||
}
|
||||
} else {
|
||||
log.Debugf("restored %d iterators from: %s", len(iters), recoveryFile)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
g, ctx := errgroup.WithContext(ctx)
|
||||
defer halt()
|
||||
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
sig := <-sigChan
|
||||
log.Errorf("Signal received (%v), stopping", sig)
|
||||
cancel()
|
||||
}()
|
||||
|
||||
defer halt()
|
||||
for _, it := range iters {
|
||||
func(it trie.NodeIterator) {
|
||||
g.Go(func() error { return fn(it) })
|
||||
g.Go(func() error {
|
||||
return fn(ctx, it)
|
||||
})
|
||||
|
||||
}(it)
|
||||
}
|
||||
return g.Wait()
|
||||
|
||||
+19
-20
@@ -17,7 +17,6 @@
|
||||
package validator_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -29,10 +28,10 @@ import (
|
||||
cid "github.com/ipfs/go-cid/_rsrch/cidiface"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/multiformats/go-multihash"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
validator "github.com/cerc-io/eth-ipfs-state-validator/v4/pkg"
|
||||
validator "github.com/cerc-io/eth-ipfs-state-validator/v5/pkg"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -203,7 +202,7 @@ var (
|
||||
|
||||
config = validator.Config{
|
||||
Hostname: "localhost",
|
||||
Name: "vulcanize_testing",
|
||||
Name: "cerc_testing",
|
||||
User: "vdbm",
|
||||
Password: "password",
|
||||
Port: 8077,
|
||||
@@ -234,44 +233,40 @@ var _ = Describe("PG-IPFS Validator", func() {
|
||||
It("Returns an error if the state root node is missing", func() {
|
||||
// we write code to ethdb, there should probably be an EthCode IPLD codec
|
||||
// but there isn't, and we don't need one here since blockstore keys are mh-derived
|
||||
loadTrie(append(missingRootStateNodes, mockCode), trieStorageNodes)
|
||||
loadTrie(missingRootStateNodes, trieStorageNodes, mockCode)
|
||||
err = v.ValidateTrie(stateRoot)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("missing trie node"))
|
||||
})
|
||||
It("Returns an error if the storage root node is missing", func() {
|
||||
loadTrie(append(trieStateNodes, mockCode), missingRootStorageNodes)
|
||||
loadTrie(trieStateNodes, missingRootStorageNodes, mockCode)
|
||||
err = v.ValidateTrie(stateRoot)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("missing trie node"))
|
||||
})
|
||||
It("Returns an error if the state trie is missing node(s)", func() {
|
||||
loadTrie(append(missingNodeStateNodes, mockCode), trieStorageNodes)
|
||||
loadTrie(missingNodeStateNodes, trieStorageNodes, mockCode)
|
||||
err = v.ValidateTrie(stateRoot)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("missing trie node"))
|
||||
pathSubStr := fmt.Sprintf("path %x", missingStateNodePath)
|
||||
Expect(err.Error()).To(ContainSubstring(pathSubStr))
|
||||
Expect(err.Error()).To(ContainSubstring("%x", missingStateNodePath))
|
||||
})
|
||||
It("Returns an error if the storage trie is missing node(s)", func() {
|
||||
loadTrie(append(trieStateNodes, mockCode), missingNodeStorageNodes)
|
||||
loadTrie(trieStateNodes, missingNodeStorageNodes, mockCode)
|
||||
err = v.ValidateTrie(stateRoot)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("missing trie node"))
|
||||
pathSubStr := fmt.Sprintf("path %x", missingStorageNodePath)
|
||||
Expect(err.Error()).To(ContainSubstring(pathSubStr))
|
||||
Expect(err.Error()).To(ContainSubstring("%x", missingStorageNodePath))
|
||||
})
|
||||
It("Returns an error if contract code is missing", func() {
|
||||
loadTrie(trieStateNodes, trieStorageNodes)
|
||||
err = v.ValidateTrie(stateRoot)
|
||||
Expect(err).To(HaveOccurred())
|
||||
codeSubStr := fmt.Sprintf("code %s: not found", codeHash.Hex()[2:])
|
||||
Expect(err.Error()).To(ContainSubstring(codeSubStr))
|
||||
pathSubStr := fmt.Sprintf("path %x", codePath)
|
||||
Expect(err.Error()).To(ContainSubstring(pathSubStr))
|
||||
Expect(err.Error()).To(ContainSubstring("%x", codeHash))
|
||||
Expect(err.Error()).To(ContainSubstring("%x", codePath))
|
||||
})
|
||||
It("Returns no error if the entire state (state trie and storage tries) can be validated", func() {
|
||||
loadTrie(append(trieStateNodes, mockCode), trieStorageNodes)
|
||||
loadTrie(trieStateNodes, trieStorageNodes, mockCode)
|
||||
err = v.ValidateTrie(stateRoot)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
@@ -326,15 +321,19 @@ var _ = Describe("PG-IPFS Validator", func() {
|
||||
})
|
||||
})
|
||||
|
||||
func loadTrie(stateNodes, storageNodes [][]byte) {
|
||||
func loadTrie(stateNodes, storageNodes [][]byte, contractCode ...[]byte) {
|
||||
tx, err := db.Beginx()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
for _, node := range stateNodes {
|
||||
_, err := PublishRaw(tx, cid.EthStateTrie, multihash.KECCAK_256, node, blockNumber)
|
||||
err := PublishRaw(tx, cid.EthStateTrie, multihash.KECCAK_256, node, blockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
for _, node := range storageNodes {
|
||||
_, err := PublishRaw(tx, cid.EthStorageTrie, multihash.KECCAK_256, node, blockNumber)
|
||||
err := PublishRaw(tx, cid.EthStorageTrie, multihash.KECCAK_256, node, blockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
for _, code := range contractCode {
|
||||
err := PublishRaw(tx, cid.Raw, multihash.KECCAK_256, code, blockNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
err = tx.Commit()
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
version: "3.2"
|
||||
# Containers to run backing DB for testing
|
||||
|
||||
services:
|
||||
migrations:
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- ipld-eth-db
|
||||
image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v4.2.3-alpha
|
||||
image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v5.0.5-alpha
|
||||
environment:
|
||||
DATABASE_USER: "vdbm"
|
||||
DATABASE_NAME: "vulcanize_testing"
|
||||
DATABASE_NAME: "cerc_testing"
|
||||
DATABASE_PASSWORD: "password"
|
||||
DATABASE_HOSTNAME: "ipld-eth-db"
|
||||
DATABASE_PORT: 5432
|
||||
|
||||
ipld-eth-db:
|
||||
container_name: test-ipld-eth-db
|
||||
image: timescale/timescaledb:latest-pg14
|
||||
restart: always
|
||||
command: ["postgres", "-c", "log_statement=all"]
|
||||
environment:
|
||||
POSTGRES_USER: "vdbm"
|
||||
POSTGRES_DB: "vulcanize_testing"
|
||||
POSTGRES_DB: "cerc_testing"
|
||||
POSTGRES_PASSWORD: "password"
|
||||
ports:
|
||||
- "127.0.0.1:8077:5432"
|
||||
Reference in New Issue
Block a user