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

feat: implement object stores #206

Merged
merged 13 commits into from
Mar 25, 2024

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Mar 23, 2024

Description

Module parameters are loaded multiple times for each tx, although the raw bytes are cached, the decoding process is not.

Support an object store that is transient stores for interface{}, applications can cache objects directly, without doing unnecessary encoding/decoding.

Caching module parameters is an important use case for this, there are also many use cases out there.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@yihuang yihuang requested a review from mmsqe March 23, 2024 09:00
CHANGELOG.md Outdated Show resolved Hide resolved
types/context.go Outdated Show resolved Hide resolved
@yihuang yihuang changed the title Problem: kv store require unnesserary encoding/decoding objects Problem: transient store require unnesserary encoding/decoding objects Mar 23, 2024
@yihuang yihuang changed the title Problem: transient store require unnesserary encoding/decoding objects Problem: duplicated parameters decoding Mar 23, 2024
@yihuang yihuang changed the title Problem: duplicated parameters decoding Problem: duplicated parameters decoding put big pressure on memory allocations Mar 23, 2024
func (cms Store) GetKVStore(key types.StoreKey) types.KVStore {
store, ok := cms.getCacheWrap(key).(types.KVStore)
if !ok {
panic(fmt.Sprintf("store with key %v is not KVStore", key))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
store := types.KVStore(s)
store, ok := s.(types.KVStore)
if !ok {
panic(fmt.Sprintf("store with key %v is not KVStore", key))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
Copy link
Collaborator

@mmsqe mmsqe left a comment

Choose a reason for hiding this comment

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

need use storetypes.GKVStore[V] in runtime right?

@yihuang
Copy link
Collaborator Author

yihuang commented Mar 24, 2024

need use storetypes.GKVStore[V] in runtime right?

dependers to be changed in other PR.

store/internal/btreeadaptor.go Fixed Show fixed Hide fixed
store/internal/btreeadaptor.go Fixed Show fixed Hide fixed
@yihuang yihuang force-pushed the object-store branch 2 times, most recently from 9348ebf to 7fc4763 Compare March 25, 2024 02:09
@yihuang yihuang enabled auto-merge (squash) March 25, 2024 02:09
Solution:
- revert the iavl bump, v1.0.2 is the version referenced by outer packages
store/types/validity.go Fixed Show fixed Hide fixed
generic interface

generic btree

generic cachekv

generic transient store

support ObjStore

changelog

Update CHANGELOG.md

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

object store key

Apply review suggestions

fix merge conflict

fix snapshot

revert dependers

value validation

seems still need to replace store

object store in api

gas accounting for object store
baseapp/baseapp.go Outdated Show resolved Hide resolved
Signed-off-by: yihuang <huang@crypto.com>
// AssertValidValueLength checks if the value length is within length limit
func AssertValidValueLength(l int) {
if l > MaxValueLength {
panic(errors.New("value is too large"))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@yihuang yihuang merged commit 90f3048 into crypto-org-chain:release/v0.50.x Mar 25, 2024
43 of 45 checks passed
@yihuang yihuang deleted the object-store branch March 25, 2024 06:15
zsystm pushed a commit to b-harvest/cosmos-sdk that referenced this pull request May 23, 2024
Reason for Cherry-pick:
- Migrate Block STM (Parallel Transaction Execution)

Original Commit Message:

generic interface

generic btree

generic cachekv

generic transient store

support ObjStore

changelog

Update CHANGELOG.md

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

object store key

Apply review suggestions

fix merge conflict

fix snapshot

revert dependers

Original author: yihuang <huang@crypto.com>

-----------

Cherry-picked-by: zsystm <actor93kor@gmail.com>
zsystm pushed a commit to b-harvest/cosmos-sdk that referenced this pull request May 24, 2024
…-org-chain#235)

Reason for Cherry-pick:
- Migrate Block STM (Parallel Transaction Execution)
- Solve dependency problem after adding ObjectStore (crypto-org-chain#206)

Original Commit Message:

* Revert "build(deps): Bump github.com/cosmos/iavl from 1.0.1 to 1.1.1 in store (cosmos#19770)"

This reverts commit ff30f6e.

* Problem: store package has dependency issues

Solution:
- revert the iavl bump, v1.0.2 is the version referenced by outer packages

Original author: yihuang <huang@crypto.com>

-----------

Cherry-picked-by: zsystm <actor93kor@gmail.com>
@yihuang yihuang changed the title Problem: duplicated parameters decoding put big pressure on memory allocations feat: implement object store Jun 5, 2024
@yihuang yihuang changed the title feat: implement object store feat: implement object stores Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants