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

fix: store key uniqueness #9363

Merged
merged 6 commits into from
May 20, 2021
Merged

fix: store key uniqueness #9363

merged 6 commits into from
May 20, 2021

Conversation

robert-zaremba
Copy link
Collaborator

@robert-zaremba robert-zaremba commented May 19, 2021

Description

While reviewing the module store keys and app wiring I notice that we don't correctly check for collisions, which can happen when:

  1. There are 2 modules use the same key (in fact this is a special case of the next one)
  2. There are 2 store keys, such that, one key is a prefix of another

It's also not clear to me why we need all this different types:

StoreKey, CapabilityKey, KVStoreKey, TransientStoreKey, MemoryStoreKey

They don't really protect against collision, neither pointers - because modules will reference store keys by name.

PS: I didn't create an issue - just went ahead and updated the code.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

types/store_internal_test.go Outdated Show resolved Hide resolved
types/store_internal_test.go Outdated Show resolved Hide resolved
types/store.go Outdated Show resolved Hide resolved
@robert-zaremba
Copy link
Collaborator Author

so, StoreKey, CapabilityKey, TransientStoreKey, MemoryStoreKey (all except KVStoreKey) are not needed now, but could be useful for declaring module dependencies.

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

LGTM

@robert-zaremba robert-zaremba added the A:automerge Automatically merge PR once all prerequisites pass. label May 20, 2021
@mergify mergify bot merged commit 8161b3a into master May 20, 2021
@mergify mergify bot deleted the robert/store-key-uniqueness branch May 20, 2021 18:13
roysc pushed a commit to vulcanize/cosmos-sdk that referenced this pull request Jun 23, 2021
* fix: store key uniqueness

* gosimple: use copy instead of for loop

* Update types/store.go

Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>

* fix import

Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:Store T:Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants