Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed Nov 20, 2023
1 parent 9617032 commit 41d7f76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 71 deletions.
58 changes: 0 additions & 58 deletions store/metrics/metrics.go

This file was deleted.

19 changes: 8 additions & 11 deletions store/root/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import (
"fmt"
"io"
"slices"
"time"

"github.com/cockroachdb/errors"

"github.com/cosmos/cosmos-sdk/telemetry"

"cosmossdk.io/log"
"cosmossdk.io/store/v2"
"cosmossdk.io/store/v2/kv/branch"
"cosmossdk.io/store/v2/kv/trace"
"cosmossdk.io/store/v2/metrics"
"cosmossdk.io/store/v2/pruning"
)

Expand Down Expand Up @@ -58,17 +60,13 @@ type Store struct {

// pruningManager manages pruning of the SS and SC backends
pruningManager *pruning.Manager

// telemetry reflects a telemetry agent responsible for emitting metrics (if any)
telemetry metrics.StoreMetrics
}

func New(
logger log.Logger,
initVersion uint64,
ss store.VersionedDatabase,
sc store.Committer,
m metrics.StoreMetrics,
) (store.RootStore, error) {
rootKVStore, err := branch.New(defaultStoreKey, ss)
if err != nil {
Expand All @@ -84,7 +82,6 @@ func New(
stateCommitment: sc,
rootKVStore: rootKVStore,
pruningManager: pruningManager,
telemetry: m,
}, nil
}

Expand Down Expand Up @@ -164,7 +161,7 @@ func (s *Store) GetLatestVersion() (uint64, error) {
}

func (s *Store) Query(storeKey string, version uint64, key []byte, prove bool) (store.QueryResult, error) {
defer s.telemetry.MeasureSince("root_store", "query")
defer telemetry.MeasureSince(time.Now(), "root_store", "query")

val, err := s.stateStore.Get(storeKey, version, key)
if err != nil {
Expand Down Expand Up @@ -210,7 +207,7 @@ func (s *Store) GetBranchedKVStore(_ string) store.BranchedKVStore {
}

func (s *Store) LoadLatestVersion() error {
defer s.telemetry.MeasureSince("root_store", "load_latest_version")
defer telemetry.MeasureSince(time.Now(), "root_store", "load_latest_version")

lv, err := s.GetLatestVersion()
if err != nil {
Expand All @@ -221,7 +218,7 @@ func (s *Store) LoadLatestVersion() error {
}

func (s *Store) LoadVersion(version uint64) error {
defer s.telemetry.MeasureSince("root_store", "load_version")
defer telemetry.MeasureSince(time.Now(), "root_store", "load_version")

return s.loadVersion(version)
}
Expand Down Expand Up @@ -290,7 +287,7 @@ func (s *Store) Branch() store.BranchedRootStore {
// by constructing a CommitInfo object, which in turn creates and writes a batch
// of the current changeset to the SC tree.
func (s *Store) WorkingHash() ([]byte, error) {
defer s.telemetry.MeasureSince("root_store", "working_hash")
defer telemetry.MeasureSince(time.Now(), "root_store", "working_hash")

if s.workingHash == nil {
if err := s.writeSC(); err != nil {
Expand All @@ -316,7 +313,7 @@ func (s *Store) Write() {
//
// Note, Commit() commits SC and SC synchronously.
func (s *Store) Commit() ([]byte, error) {
defer s.telemetry.MeasureSince("root_store", "commit")
defer telemetry.MeasureSince(time.Now(), "root_store", "commit")

if s.workingHash == nil {
return nil, fmt.Errorf("working hash is nil; must call WorkingHash() before Commit()")
Expand Down
3 changes: 1 addition & 2 deletions store/root/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/store/v2"
"cosmossdk.io/store/v2/commitment/iavl"
"cosmossdk.io/store/v2/metrics"
"cosmossdk.io/store/v2/storage/sqlite"
)

Expand All @@ -33,7 +32,7 @@ func (s *RootStoreTestSuite) SetupTest() {

sc := iavl.NewIavlTree(dbm.NewMemDB(), noopLog, iavl.DefaultConfig())

rs, err := New(noopLog, 1, ss, sc, metrics.NoOpMetrics{})
rs, err := New(noopLog, 1, ss, sc)
s.Require().NoError(err)

rs.SetTracer(io.Discard)
Expand Down

0 comments on commit 41d7f76

Please sign in to comment.