Use tagged version of eth-ipfs-state-validator

This commit is contained in:
Ashwin Phatak 2021-08-25 14:14:59 +05:30 committed by Arijit Das
parent cf0555d1a5
commit 2cde16c44a
4 changed files with 769 additions and 44 deletions

View File

@ -249,7 +249,7 @@ func startStateTrieValidator(server s.Server, validateEveryNthBlock uint64) {
backend := server.Backend()
for {
time.Sleep(10 * time.Second)
time.Sleep(5 * time.Second)
block, err := backend.CurrentBlock()
if err != nil {
@ -266,15 +266,15 @@ func startStateTrieValidator(server s.Server, validateEveryNthBlock uint64) {
err = backend.ValidateTrie(stateRoot)
if err != nil {
// Log an error and exit.
log.Fatalf("Error validating state trie for block %s (%d), state root %s",
blockHash,
log.Fatalf("Error validating state trie for block number %d hash %s state root %s",
blockNumber,
blockHash,
stateRoot,
)
} else {
log.Infof("Successfully validated state trie for block %s (%d), state root %s",
blockHash,
log.Infof("Successfully validated state trie for block number %d hash %s state root %s",
blockNumber,
blockHash,
stateRoot,
)
}

3
go.mod
View File

@ -18,12 +18,13 @@ require (
github.com/multiformats/go-multihash v0.0.14
github.com/onsi/ginkgo v1.16.2
github.com/onsi/gomega v1.10.1
github.com/prometheus/client_golang v1.5.1
github.com/prometheus/client_golang v1.7.1
github.com/shirou/gopsutil v3.21.5+incompatible // indirect
github.com/sirupsen/logrus v1.7.0
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
github.com/tklauser/go-sysconf v0.3.6 // indirect
github.com/vulcanize/eth-ipfs-state-validator v0.0.1
github.com/vulcanize/gap-filler v0.3.1
github.com/vulcanize/ipfs-ethdb v0.0.3
)

780
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,8 @@ import (
log "github.com/sirupsen/logrus"
ipfsethdb "github.com/vulcanize/ipfs-ethdb/postgres"
"github.com/vulcanize/ipld-eth-server/pkg/shared"
validator "github.com/vulcanize/eth-ipfs-state-validator/pkg"
)
var (
@ -814,24 +816,8 @@ func (b *Backend) GetHeader(hash common.Hash, height uint64) *types.Header {
return header
}
// ValidateTrie returns an error if the state and storage tries for the provided state root cannot be confirmed as complete
// This does consider child storage tries
func (b *Backend) ValidateTrie(stateRoot common.Hash) error {
// Generate the state.NodeIterator for this root
stateDB, err := state.New(stateRoot, b.StateDatabase, nil)
if err != nil {
return err
}
it := state.NewNodeIterator(stateDB)
for it.Next() {
// iterate through entire state trie and descendent storage tries
// it.Next() will return false when we have either completed iteration of the entire trie or have ran 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
}
return it.Error
return validator.NewValidator(nil, b.EthDB).ValidateTrie(stateRoot)
}
// RPCGasCap returns the configured gas cap for the rpc server