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 iter prefix #913

Merged
merged 18 commits into from
Feb 7, 2023
Merged

fix iter prefix #913

merged 18 commits into from
Feb 7, 2023

Conversation

tzemanovic
Copy link
Member

@tzemanovic tzemanovic commented Dec 16, 2022

fixes #165

based on v0.13.3

We're adding WlStorage (combined WriteLog and Storage) to be able to fix the prefix iter function to match uncommitted changes. This directly replaces write_log and storage in the Shell (but write_log and storage can still be accessed directly inside it) and in the queries RequestCtx.

With this, the Storage type no longer implements storage_api StorageRead and StorageWrite traits, because it's not possible to have fully working iter prefix on it and instead these are implemented on WlStorage. This is reflected in tests that were using TestStorage, now with TestWlStorage.

We attempted to re-use the WlStorage in multiple ways for host env that ended up in untypable lifetimes dead ends. In the end, we're just re-using the prefix_iter provided by the new wl_storage module, which is not as nice, but it works and is simpler with gas handling, which is needed in host env, but not in the shell. The StorageRead/Write in WlStorage ignores any gas as that's for non-tx logic which doesn't count it and the StorageRead/Write in the tx and VPs account the gas automatically in the host env function calls.

There was also an issue in has_key_pre VpEnv method, which was potentially missing keys written by previous txs in the same block, discovered in another test. This is fixed in b8f8d39.

@brentstone brentstone mentioned this pull request Dec 20, 2022
15 tasks
@tzemanovic tzemanovic force-pushed the tomas+brent/fix-iter-prefix branch 4 times, most recently from 8575db6 to e4838e2 Compare December 28, 2022 16:15
@juped juped added this to the 0.14 milestone Jan 10, 2023
@tzemanovic tzemanovic force-pushed the tomas+brent/fix-iter-prefix branch 3 times, most recently from ab33c84 to df2be3a Compare January 12, 2023 10:10
@tzemanovic
Copy link
Member Author

pls update wasm

tzemanovic added a commit that referenced this pull request Jan 12, 2023
@tzemanovic tzemanovic marked this pull request as ready for review January 12, 2023 10:50
@tzemanovic tzemanovic requested a review from brentstone January 12, 2023 10:51
@tzemanovic tzemanovic mentioned this pull request Jan 19, 2023
grarco pushed a commit that referenced this pull request Jan 20, 2023
brentstone pushed a commit that referenced this pull request Jan 23, 2023
@brentstone brentstone force-pushed the tomas+brent/fix-iter-prefix branch from 76ec13e to 4319e46 Compare January 23, 2023 07:28
brentstone
brentstone previously approved these changes Jan 23, 2023
Copy link
Collaborator

@brentstone brentstone left a comment

Choose a reason for hiding this comment

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

LGTM

grarco pushed a commit that referenced this pull request Jan 24, 2023
brentstone pushed a commit that referenced this pull request Jan 30, 2023
brentstone pushed a commit that referenced this pull request Jan 30, 2023
@tzemanovic
Copy link
Member Author

pls update wasm

@juped juped merged commit 0e57e9c into main Feb 7, 2023
@juped juped deleted the tomas+brent/fix-iter-prefix branch February 7, 2023 01:49
juped added a commit that referenced this pull request Feb 10, 2023
* tomas+brent/fix-iter-prefix:
  [ci] wasm checksums update
  changelog: add #913
  fix documentation
  fix IBC VP tests
  tests: update tests to use WlStorage
  use storage PrefixIter instead of DB iterator that respects write log
  use WlStorage in Shell and in queries RequestCtx
  core: remove storage_api StorageRead and StorageWrite from Storage
  make -C wasm_for_tests/wasm_source
  vp_host_fns: fix has_key_pre to see keys from prev txs (not yet in DB)
  test/vm_host_env: fix expected keys in VP iter prefix
  storage: extend iter_prefix test
  storage: rename `fn commit` to `commit_block`
  write_log: allow to commit genesis txs
  write_log: add prefix iter
  shared: Add WlStorage, combining WriteLog with Storage
  move write_log
  core/storage: add a warning to `iter_prefix`
bengtlofgren pushed a commit that referenced this pull request May 11, 2023
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.

Tx/VP prefix iter should include keys from write log
4 participants