Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SeiDB] Fix SS apply changeset version off by 1 #424

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion storev2/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
// Commit implements interface Committer, called by ABCI Commit
func (rs *Store) Commit(bumpVersion bool) types.CommitID {
if !bumpVersion {
panic("Commit should always bump version in root multistore")

Check warning on line 94 in storev2/rootmulti/store.go

View check run for this annotation

Codecov / codecov/patch

storev2/rootmulti/store.go#L94

Added line #L94 was not covered by tests
}
if err := rs.flush(); err != nil {
panic(err)
Expand Down Expand Up @@ -141,7 +141,7 @@
// Flush all the pending changesets to commit store.
func (rs *Store) flush() error {
var changeSets []*proto.NamedChangeSet
currentVersion := rs.lastCommitInfo.Version
currentVersion := rs.lastCommitInfo.Version + 1

Check warning on line 144 in storev2/rootmulti/store.go

View check run for this annotation

Codecov / codecov/patch

storev2/rootmulti/store.go#L144

Added line #L144 was not covered by tests
for key := range rs.ckvStores {
// it'll unwrap the inter-block cache
store := rs.GetCommitKVStore(key)
Expand Down Expand Up @@ -206,8 +206,8 @@
}

// Implements interface CacheWrapper
func (rs *Store) CacheWrap(_ types.StoreKey) types.CacheWrap {
return rs.CacheMultiStore().(types.CacheWrap)

Check warning on line 210 in storev2/rootmulti/store.go

View check run for this annotation

Codecov / codecov/patch

storev2/rootmulti/store.go#L209-L210

Added lines #L209 - L210 were not covered by tests
}

// Implements interface CacheWrapper
Expand Down Expand Up @@ -356,11 +356,11 @@
if err := rs.scStore.Initialize(initialStores); err != nil {
return err
}
if version > 0 {
_, err := rs.scStore.LoadVersion(version, false)
if err != nil {
return nil
}

Check warning on line 363 in storev2/rootmulti/store.go

View check run for this annotation

Codecov / codecov/patch

storev2/rootmulti/store.go#L359-L363

Added lines #L359 - L363 were not covered by tests
}

var treeUpgrades []*proto.TreeNameUpgrade
Expand Down Expand Up @@ -494,7 +494,7 @@
return sdkerrors.QueryResult(err)
}
var store types.Queryable
var commitInfo *types.CommitInfo

Check warning on line 497 in storev2/rootmulti/store.go

View check run for this annotation

Codecov / codecov/patch

storev2/rootmulti/store.go#L497

Added line #L497 was not covered by tests

if !req.Prove && version < rs.lastCommitInfo.Version && rs.ssStore != nil {
// Serve abci query from ss store if no proofs needed
Expand All @@ -507,13 +507,13 @@
return sdkerrors.QueryResult(err)
}
store = types.Queryable(commitment.NewStore(scStore.GetTreeByName(storeName), rs.logger))
commitInfo = convertCommitInfo(scStore.LastCommitInfo())
commitInfo = amendCommitInfo(commitInfo, rs.storesParams)

Check warning on line 511 in storev2/rootmulti/store.go

View check run for this annotation

Codecov / codecov/patch

storev2/rootmulti/store.go#L510-L511

Added lines #L510 - L511 were not covered by tests
} else {
// Serve directly from latest sc store
store = types.Queryable(commitment.NewStore(rs.scStore.GetTreeByName(storeName), rs.logger))
commitInfo = convertCommitInfo(rs.scStore.LastCommitInfo())
commitInfo = amendCommitInfo(commitInfo, rs.storesParams)

Check warning on line 516 in storev2/rootmulti/store.go

View check run for this annotation

Codecov / codecov/patch

storev2/rootmulti/store.go#L515-L516

Added lines #L515 - L516 were not covered by tests
}

// trim the path and execute the query
Expand All @@ -522,9 +522,9 @@

if !req.Prove || !rootmulti.RequireProof(subPath) {
return res
} else if commitInfo != nil {
// Restore origin path and append proof op.
res.ProofOps.Ops = append(res.ProofOps.Ops, commitInfo.ProofOp(storeName))

Check warning on line 527 in storev2/rootmulti/store.go

View check run for this annotation

Codecov / codecov/patch

storev2/rootmulti/store.go#L525-L527

Added lines #L525 - L527 were not covered by tests
}
if res.ProofOps == nil || len(res.ProofOps.Ops) == 0 {
return sdkerrors.QueryResult(errors.Wrap(sdkerrors.ErrInvalidRequest, "proof is unexpectedly empty; ensure height has not been pruned"))
Expand Down
Loading