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

make prefix iterator ordered by storage keys and add reverse order prefix iterator #458

Merged
merged 40 commits into from
Oct 13, 2022

Conversation

tzemanovic
Copy link
Member

@tzemanovic tzemanovic commented Sep 8, 2022

based on #335

fixes #409

This PR adds support for int storage keys (all primitive [u|i][8|16|32|64|128]) which now preserve the order that can be relied upon in prefix iterator (internally, in the string form of storage key their BE bytes get encoded with base32hex and signed integers are complemented with their min values so that the order of negative values is also correct). Additionally, reverse prefix iterator is added.

tzemanovic and others added 30 commits August 17, 2022 18:39
@tzemanovic tzemanovic marked this pull request as ready for review September 8, 2022 16:24
@tzemanovic
Copy link
Member Author

pls update wasm

tzemanovic added a commit that referenced this pull request Sep 14, 2022
* namada/tomas/sorted-prefix-iter:
  [ci skip] wasm checksums update
  changelog: add #458
  tests: extend prefix iter tests for reverse order
  add support for rev_iter_prefix in storage and VP and tx envs
  test/vm_host_env: check prefix iter order in tx and VP
  shared/storage/key: add support for int/uint keys that maintain order
  deps: replace hex with data-encoding
  changelog: add #335
  wasm checksums update
  test/vm_host_env: refactor prefix iter tests with new `iter_prefix` fn
  storage_api: build a nicer `iter_prefix` function on top of StorageRead
  changelog: add #331
  update wasm checksums
  fix missing StorageWrite for Storage merkle tree update
  storage: remove unnecessary clone
  add more comments for StorageRead lifetime with an example usage
  add <'iter> lifetime to StorageRead trait to get around lack of GATs
  ledger: impl StorageWrite for Storage
  ledger: factor out TxEnv write methods into a new StorageWrite trait
  update wasm checksums
  ledger/pos: implement PosReadOnly using StorageRead trait
  ledger/tx: inherit StorageRead in TxEnv
  ledger/storage: impl StorageRead for Storage
  ledger/vp: impl StorageRead for WASM VPs pre and post state
  ledger/native_vp: implement StorageRead for pre and post state
  ledger: add StorageRead trait with extensible error type
  [ci skip] wasm checksums update
  update wasm checksums
  wasm_for_tests: make
  Update shared/src/ledger/vp_env.rs
  changelog: add #1093
  wasm: improve error handling
  macros: add error handling to transaction and validity_predicate macros
  wasm: update for VM API changes
  tests: update for VM API changes
  VM: move vm_env sub-mod into tx/vp_prelude and add Tx/VpEnv and Ctx
  shared: update native_vp implementations for VpEnv methods
  shared/ledger/native_vp: implement VpEnv
  shared/vm: rename host_env TxEnv/VpEnv to TxVmEnv/VpVmEnv
  ledger: add tx and VP traits with host env functions
tzemanovic added a commit that referenced this pull request Sep 14, 2022
handle TODOs to fix LazyVec's iter order to fix the API SM test
tzemanovic added a commit that referenced this pull request Sep 14, 2022
- updated `shared/src/types/key/mod.rs` to use `data_encoding::HEXLOWER` instead of `hex`

* namada/tomas/sorted-prefix-iter:
  [ci skip] wasm checksums update
  changelog: add #458
  tests: extend prefix iter tests for reverse order
  add support for rev_iter_prefix in storage and VP and tx envs
  test/vm_host_env: check prefix iter order in tx and VP
  shared/storage/key: add support for int/uint keys that maintain order
  deps: replace hex with data-encoding
@tzemanovic tzemanovic mentioned this pull request Sep 14, 2022
This was referenced Sep 21, 2022
tzemanovic added a commit that referenced this pull request Sep 23, 2022
- updated `shared/src/types/key/mod.rs` to use `data_encoding::HEXLOWER` instead of `hex`

* namada/tomas/sorted-prefix-iter:
  [ci skip] wasm checksums update
  changelog: add #458
  tests: extend prefix iter tests for reverse order
  add support for rev_iter_prefix in storage and VP and tx envs
  test/vm_host_env: check prefix iter order in tx and VP
  shared/storage/key: add support for int/uint keys that maintain order
  deps: replace hex with data-encoding
tzemanovic added a commit that referenced this pull request Sep 23, 2022
- updated `shared/src/types/key/mod.rs` to use `data_encoding::HEXLOWER` instead of `hex`

* namada/tomas/sorted-prefix-iter:
  [ci skip] wasm checksums update
  changelog: add #458
  tests: extend prefix iter tests for reverse order
  add support for rev_iter_prefix in storage and VP and tx envs
  test/vm_host_env: check prefix iter order in tx and VP
  shared/storage/key: add support for int/uint keys that maintain order
  deps: replace hex with data-encoding
tzemanovic added a commit that referenced this pull request Sep 23, 2022
* namada/tomas+brent/lazy-vec-and-map:
  changelog: #503
  [ci] wasm checksums update
  remove unfinished lazy_set, lazy_hashset and lazy_hashmap for now
  ledger/storage/lazy: update lazy_set for updated trait LazyCollection
  ledger/storage/lazy: remove unused error cases
  WIP: Nested LazyMap validation and testing
  WIP: validation for lazy_map
  WIP: StateMachine tests for lazy_vec validation
  post-conditions for Transition::Update + some comments
  quick bug and documentation fix
  update after rebase on #458, #465
  storage/lazy_vec: add state machine test for lazy vec API
  storage/lazy_vec/validation: disallow unrecognized keys matching prefix
  impl LazyCollection trait for all the collections + refactor
  storage_api/collections/lazy: allow nested lazy collections in LazyMap
  add lazy_vec validation
  fix clippy
  storage_api/collections/lazy: add basic tests and missing methods
  cargo test test_lazy_vec_basics
  update lazy for explicit lifetime in StorageRead trait
  storage: add `Key::last` method, impl KeySeg for all ints
  Switch to use storage::KeySeg and add LazySet
  add lazy map without hashing
  refactored lazy collections, replaced hasher, added iter
  fmt && clippy
  add fn get_elem_key_by_hash to LazyMap
  lazy hash map first commit
  add lazy set (WIP), make LazyVec.get public
  add lazy vector
  create lazy data structures for storage access
  rustdoc: resolve ambiguous link
  fixup! Merge branch 'namada/tomas/sorted-prefix-iter' (#458)
tzemanovic added a commit that referenced this pull request Sep 27, 2022
* tomas+brent/lazy-vec-and-map:
  changelog: #503
  [ci] wasm checksums update
  remove unfinished lazy_set, lazy_hashset and lazy_hashmap for now
  ledger/storage/lazy: update lazy_set for updated trait LazyCollection
  ledger/storage/lazy: remove unused error cases
  WIP: Nested LazyMap validation and testing
  WIP: validation for lazy_map
  WIP: StateMachine tests for lazy_vec validation
  post-conditions for Transition::Update + some comments
  quick bug and documentation fix
  update after rebase on #458, #465
  storage/lazy_vec: add state machine test for lazy vec API
  storage/lazy_vec/validation: disallow unrecognized keys matching prefix
  impl LazyCollection trait for all the collections + refactor
  storage_api/collections/lazy: allow nested lazy collections in LazyMap
  add lazy_vec validation
  fix clippy
  storage_api/collections/lazy: add basic tests and missing methods
  cargo test test_lazy_vec_basics
  update lazy for explicit lifetime in StorageRead trait
  storage: add `Key::last` method, impl KeySeg for all ints
  Switch to use storage::KeySeg and add LazySet
  add lazy map without hashing
  refactored lazy collections, replaced hasher, added iter
  fmt && clippy
  add fn get_elem_key_by_hash to LazyMap
  lazy hash map first commit
  add lazy set (WIP), make LazyVec.get public
  add lazy vector
  create lazy data structures for storage access
  rustdoc: resolve ambiguous link
  fixup! Merge branch 'namada/tomas/sorted-prefix-iter' (#458)
@juped juped merged commit e3ce6bc into main Oct 13, 2022
@juped juped deleted the tomas/sorted-prefix-iter branch October 13, 2022 06:51
juped added a commit that referenced this pull request Oct 13, 2022
Draft drifted somewhat over this release cycle. We can clear this up
with a merge-and-delete.

* draft: (373 commits)
  changelog: add #452
  feat: rocksdb use jemalloc
  feat: update rocksdb version
  [ci] wasm checksums update
  changelog: add #501
  fix e2e tests
  fix e2e tests
  Misc refactoring
  Uses `end_epoch` in `query_proposal_result`
  Refactors governance e2e tests
  [ci] wasm checksums update
  changelog: #503
  [ci] wasm checksums update
  remove unfinished lazy_set, lazy_hashset and lazy_hashmap for now
  ledger/storage/lazy: update lazy_set for updated trait LazyCollection
  Fixes specs
  [ci] wasm checksums update
  fix display proposal result in cli
  fix proposal_submission e2e test
  [misc] rebase
  ledger/storage/lazy: remove unused error cases
  WIP: Nested LazyMap validation and testing
  WIP: validation for lazy_map
  WIP: StateMachine tests for lazy_vec validation
  update wasm checksums
  changelog: add #500
  remove intent gossiper, matchmaker and their deps
  Adds `max_proposal_period` governance parameter
  Removes `max_proposal_fund_transfer` parameter
  Use proposal `end_epoch` instead of `start_epoch` for voting power
  Skip tx whitelist for proposal code
  Rename `Treasury` to `SlashFund`
  fmt and fix clippy
  Speeds up testing
  Fixes `safe_exit` call only if `force` is not set
  [misc]: remove logs
  [fix]: votes accumulation
  Fixes test artifacts folder persistence
  Fixes e2e tests
  [fix]: e2e test
  [fix]: e2e test
  [misc]: clippy, fmt
  [fix]: error println
  [feat]: vote transaction validation
  [fix]: governance vp author address, proposal submission validation
  [fix]: bad validation condition
  [fix]: clippy, fmt
  [fix]: clippy, fmt
  [misc]: clippy, fmt
  [feat]: added total votes to query
  [fix]: governance overflow, proposal validation
  fixup! Merge branch 'yuji/multitoken' (#359)
  fixup! rustdoc: fix more broken links
  fixup! Sync with 'main'
  rustdoc: fix more broken links
  fixup! Sync with 'main'
  [ci] wasm checksums update
  changelog: add #359
  change the balance format
  update a test wasm
  remove an error message
  [ci skip] wasm checksums update
  multitoken transfer and query
  post-conditions for Transition::Update + some comments
  quick bug and documentation fix
  update after rebase on #458, #465
  storage/lazy_vec: add state machine test for lazy vec API
  storage/lazy_vec/validation: disallow unrecognized keys matching prefix
  impl LazyCollection trait for all the collections + refactor
  storage_api/collections/lazy: allow nested lazy collections in LazyMap
  add lazy_vec validation
  fix clippy
  storage_api/collections/lazy: add basic tests and missing methods
  cargo test test_lazy_vec_basics
  update lazy for explicit lifetime in StorageRead trait
  storage: add `Key::last` method, impl KeySeg for all ints
  Switch to use storage::KeySeg and add LazySet
  add lazy map without hashing
  refactored lazy collections, replaced hasher, added iter
  fmt && clippy
  add fn get_elem_key_by_hash to LazyMap
  lazy hash map first commit
  add lazy set (WIP), make LazyVec.get public
  add lazy vector
  create lazy data structures for storage access
  rustdoc: resolve ambiguous link
  changelog: add #465
  fixup! Merge branch 'namada/tomas/sorted-prefix-iter' (#458)
  [ci skip] wasm checksums update
  ledger: use storage_api::Error in VpEnv and TxEnv instead of generic
  [ci skip] wasm checksums update
  changelog: add #458
  tests: extend prefix iter tests for reverse order
  add support for rev_iter_prefix in storage and VP and tx envs
  test/vm_host_env: check prefix iter order in tx and VP
  shared/storage/key: add support for int/uint keys that maintain order
  deps: replace hex with data-encoding
  update wasm checksums
  changelog: add #380
  changelog: add #384
  ...
phy-chain pushed a commit to phy-chain/namada that referenced this pull request Mar 1, 2024
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.

storage prefix iter - deterministic order with reverse
2 participants