Skip to content

Conversation

@ethanfrey
Copy link
Contributor

@ethanfrey ethanfrey commented Oct 19, 2017

This is based on PR #257 and should not be merged until that PR gets merged to develop, thus the WIP state. Beside the dependency, the code is ready to merge IMO.

We now keep the last 10 blocks available for queries and expose the height as an argument for queries. If H is the last committed block, the default (height=0) is to return H-1, as you can immediately get a proof for this. (Most recent query with proofs). If you just submitted a tx that was included on height H, you should query with --height=$H in order to ensure you read the state after the tx was processed.

This involved updating all the shell script integration tests, which do just this, send a tx, then immediately query the state.

client/query.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

genesis/parse.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do make([]Option, 0, cnt) then you can use append and don't need to have an i variable, and it's the same speed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice tip

state/merkle.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this, but I don't like it that much - it doesn't communicate the intent very well. I wonder if we should have a method inside Tree that is more descriptive, like tree.IsEmpty()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please do. So we can quickly check if we can save safely

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added IsEmpty to develop. You should be able to replace that with !s.committed.Tree.IsEmpty()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only really need to check the Size actually, since if the latest version is > 0, then there are keys in the tree, but I'd still recommend using the new !IsEmpty.

state/merkle.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice poor-man's pruning!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, hardcoded length, enough to get it out. We can work on other techniques later, but refactoring will change a lot, so it can wait.

app/app_test.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require.NoError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, here I require it is an error

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do require.Error then :)

genesis/parse.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's worth to make / a const? like KeyDelimiter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, did that

@ethanfrey ethanfrey force-pushed the feature/expose-historical-queries branch from 6747314 to 7ef20bb Compare October 20, 2017 11:46
@ethanfrey ethanfrey merged commit e61e7af into develop Oct 24, 2017
ParthDesai pushed a commit to ChorusOne/cosmos-sdk that referenced this pull request Apr 19, 2021
* Rebuild PDF
* Separate commitment path (ref cosmos#258)
* Clarify connection versioning (ref cosmos#269)
* Note private store key flexibility (ref cosmos#145)
catShaark referenced this pull request in notional-labs/cosmos-sdk Jun 11, 2022
yihuang pushed a commit to yihuang/cosmos-sdk that referenced this pull request Apr 5, 2024
…osmos#258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Dec 12, 2024
…osmos#258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Dec 12, 2024
…osmos#258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Dec 16, 2024
…osmos#258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Dec 16, 2024
…osmos#258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Dec 31, 2024
…osmos#258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Jan 9, 2025
…osmos#258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Apr 11, 2025
…osmos#258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
maxim-inj added a commit to InjectiveLabs/cosmos-sdk that referenced this pull request May 4, 2025
* [cosmos#207](crypto-org-chain#207) Remove api CacheWrapWithTrace.
* [cosmos#205](crypto-org-chain#205) Support object store.
* [cosmos#240](crypto-org-chain#240) Split methods from `MultiStore` into specialized `RootMultiStore`, keep `MultiStore` generic.
* [cosmos#241](crypto-org-chain#241) Refactor the cache store to be btree backed, prepare to support copy-on-write atomic branching.
* [cosmos#242](crypto-org-chain#242) Init cache on cache lazily, save memory allocations.
* [cosmos#243](crypto-org-chain#243) Support `RunAtomic` API to use new CoW cache store.
* [cosmos#244](crypto-org-chain#244) Add `Discard` method to CacheWrap to discard the write buffer.
* [cosmos#258](crypto-org-chain#258) Add `NewFromParent` API to cachemulti store to create a new store from block-stm multiversion data structure.
* [cosmos#1043](crypto-org-chain#1043) Add back CacheWrapWithTrace api.
mmsqe pushed a commit that referenced this pull request Sep 4, 2025
…258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
Eric-Warehime pushed a commit that referenced this pull request Sep 5, 2025
…258)

Solution:
- add API NewFromParent to cache multistore.

Update store/CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

fix test

fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants