Skip to content

Commit

Permalink
And more
Browse files Browse the repository at this point in the history
  • Loading branch information
iKapitonau committed Sep 30, 2024
1 parent 8b75502 commit c4ff97b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions cosmos-sdk-store/pruning/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (m *Manager) LoadSnapshotHeights(db dbm.DB) error {
}

loadedPruneSnapshotHeights, err := loadPruningSnapshotHeights(db)
fmt.Printf("LOADED PRUNE SNAPSHOT HEIGHTS: %+v\n", loadedPruneSnapshotHeights)
if err != nil {
return err
}
Expand Down
15 changes: 15 additions & 0 deletions cosmos-sdk-store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"math"
"runtime/debug"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -245,7 +246,9 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error {
rs.logger.Debug("loadVersion commitID", "key", key, "ver", ver, "hash", fmt.Sprintf("%x", commitID.Hash))

// If it has been added, set the initial version
fmt.Printf("STORE OF %s WAS ADDED\n", key.Name())
if upgrades.IsAdded(key.Name()) || upgrades.RenamedFrom(key.Name()) != "" {
fmt.Printf("STORE: %s INITITAL VERSION: %d\n", key.Name(), int64(ver)+1)
storeParams.initialVersion = uint64(ver) + 1
} else if commitID.Version != ver && storeParams.typ == types.StoreTypeIAVL {
return fmt.Errorf("version of store %s mismatch root store's version; expected %d got %d; new stores should be added using StoreUpgrades", key.Name(), ver, commitID.Version)
Expand Down Expand Up @@ -461,6 +464,11 @@ func (rs *Store) LastCommitID() types.CommitID {

// Commit implements Committer/CommitStore.
func (rs *Store) Commit() types.CommitID {
fmt.Println("COMMIT")
fmt.Printf("STORE: %#v\n", rs)
fmt.Printf("LASTCOMMITINFOVERSION: %d\n", rs.lastCommitInfo.GetVersion())
fmt.Printf("INITIALVERSION: %d\n", rs.initialVersion)
debug.PrintStack()
var previousHeight, version int64
if rs.lastCommitInfo.GetVersion() == 0 && rs.initialVersion > 1 {
// This case means that no commit has been made in the store, we
Expand Down Expand Up @@ -1016,6 +1024,7 @@ func (rs *Store) loadCommitStoreFromParams(key types.StoreKey, id types.CommitID
db = dbm.NewPrefixDB(rs.db, []byte(prefix))
}

fmt.Printf("STORE PARAMS: %+v\n", params)
switch params.typ {
case types.StoreTypeMulti:
panic("recursive MultiStores not yet supported")
Expand All @@ -1024,9 +1033,12 @@ func (rs *Store) loadCommitStoreFromParams(key types.StoreKey, id types.CommitID
var store types.CommitKVStore
var err error

fmt.Println("DISABLE FAST NODE", rs.iavlDisableFastNode)
if params.initialVersion == 0 {
fmt.Println("INITVERSION Is 0")
store, err = iavl.LoadStore(db, rs.logger, key, id, rs.iavlCacheSize, rs.iavlDisableFastNode, rs.metrics)
} else {
fmt.Println("INITVERSION Is NOT 0")
store, err = iavl.LoadStoreWithInitialVersion(db, rs.logger, key, id, params.initialVersion, rs.iavlCacheSize, rs.iavlDisableFastNode, rs.metrics)
}

Expand Down Expand Up @@ -1191,12 +1203,15 @@ func GetLatestVersion(db dbm.DB) int64 {

// Commits each store and returns a new commitInfo.
func commitStores(version int64, storeMap map[types.StoreKey]types.CommitKVStore, removalMap map[types.StoreKey]bool) *types.CommitInfo {
fmt.Println("COMMIT STORES")
debug.PrintStack()
storeInfos := make([]types.StoreInfo, 0, len(storeMap))
storeKeys := keysFromStoreKeyMap(storeMap)

for _, key := range storeKeys {
store := storeMap[key]
last := store.LastCommitID()
fmt.Println("COMMIT STORES: KEY: %#v, LAST: %#v, VERSION: %d\n", key, last, version)

// If a commit event execution is interrupted, a new iavl store's version
// will be larger than the RMS's metadata, when the block is replayed, we
Expand Down
4 changes: 4 additions & 0 deletions iavl/mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func NewMutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool, lg lo
for _, opt := range options {
opt(&opts)
}
fmt.Printf("NEW MUTABLE TREE OPTS: %+v\n", opts)

ndb := newNodeDB(db, cacheSize, opts, lg)
head := &ImmutableTree{ndb: ndb, skipFastStorageUpgrade: skipFastStorageUpgrade}
Expand Down Expand Up @@ -435,10 +436,12 @@ func (tree *MutableTree) Load() (int64, error) {

// Returns the version number of the specific version found
func (tree *MutableTree) LoadVersion(targetVersion int64) (int64, error) {
fmt.Printf("TARGET VERSION: %d\n", targetVersion)
firstVersion, err := tree.ndb.getFirstVersion()
if err != nil {
return 0, err
}
fmt.Printf("FIRST VERSION: %d\n", firstVersion)

if firstVersion > 0 && firstVersion < int64(tree.ndb.opts.InitialVersion) {
return firstVersion, fmt.Errorf("initial version set to %v, but found earlier version %v",
Expand All @@ -450,6 +453,7 @@ func (tree *MutableTree) LoadVersion(targetVersion int64) (int64, error) {
return 0, err
}

fmt.Printf("LATEST VERSION: %d\n", latestVersion)
if firstVersion > 0 && firstVersion < int64(tree.ndb.opts.InitialVersion) {
return latestVersion, fmt.Errorf("initial version set to %v, but found earlier version %v",
tree.ndb.opts.InitialVersion, firstVersion)
Expand Down

0 comments on commit c4ff97b

Please sign in to comment.