diff --git a/cmd/validate.go b/cmd/validate.go index c91fb918..1fcd5a82 100644 --- a/cmd/validate.go +++ b/cmd/validate.go @@ -63,12 +63,12 @@ func validate() { ExpiryDuration: time.Minute * time.Duration(CacheExpiryInMins), }) - validator := validator.NewValidator(nil, ethDB) - if err = validator.ValidateTrie(stateRoot); err != nil { + val := validator.NewValidator(nil, ethDB) + if err = val.ValidateTrie(stateRoot); err != nil { log.Fatalln("Error validating state root") } - stats := ethDB.GetCacheStats() + stats := ethDB.(*ipfsethdb.Database).GetCacheStats() log.Debugf("groupcache stats %+v", stats) log.Infoln("Successfully validated state root") diff --git a/pkg/eth/backend.go b/pkg/eth/backend.go index 1e1445f3..3d9485a4 100644 --- a/pkg/eth/backend.go +++ b/pkg/eth/backend.go @@ -130,7 +130,7 @@ func NewEthBackend(db *postgres.DB, c *Config) (*Backend, error) { ExpiryDuration: time.Minute * time.Duration(gcc.StateDB.CacheExpiryInMins), }) - logStateDBStatsOnTimer(ethDB, gcc) + logStateDBStatsOnTimer(ethDB.(*ipfsethdb.Database), gcc) return &Backend{ DB: db, @@ -825,6 +825,7 @@ func (b *Backend) GetHeader(hash common.Hash, height uint64) *types.Header { return header } +// ValidateTrie validates the trie for the given stateRoot func (b *Backend) ValidateTrie(stateRoot common.Hash) error { return validator.NewValidator(nil, b.EthDB).ValidateTrie(stateRoot) }