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 temporary values read #2735
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2735 +/- ##
==========================================
+ Coverage 53.44% 53.49% +0.05%
==========================================
Files 310 310
Lines 101574 101623 +49
==========================================
+ Hits 54288 54368 +80
+ Misses 47286 47255 -31 ☔ View full report in Codecov by Sentry. |
d32eb42
to
2cf6b23
Compare
One thing I noticed is that here the type system doesn't really help us: the namada/crates/state/src/write_log.rs Line 84 in 78519dd
|
@@ -188,7 +188,9 @@ where | |||
Ok(false) | |||
} | |||
Some(&write_log::StorageModification::InitAccount { .. }) => Ok(true), | |||
Some(&write_log::StorageModification::Temp { .. }) => Ok(true), | |||
Some(&write_log::StorageModification::Temp { .. }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API we provide to the VPs is different to the one we have in protocol or expose to transactions. For VPs we report an error whereas in protocol and for transactions we simply ignore temporary writes and try to look for other storage modifications or directly from storage. I tend to like the latter better but I can understand that returning an error might be more explicit. Should we try to unify the api and apply the same logic everywhere (either errors or read-through?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the latter is better and I'm for unifying this in VPs. If a VP allows temp values, it has to read them explicitly so ignoring them for non-temp reads is fine
aa89818
to
22f3c56
Compare
a0f479a
to
f588ec5
Compare
rebased on 0.32.0 |
* origin/grarco/fix-vps-api: Changelog #2735 `read_persistent` returns a `PersistentStorageModification` Unit tests write log temp writes In write log `write`, `write_temp` and `delete` now take the precommit into account vp `read_temp` ignores non-temp values instead of error Unifies read interface of vps to that of txs and protocol Refactors `read` and `has_key` implementations in `impl_storage_read` Adds a new `read_persistent` method on `WriteLog`. Refactors `iter_prefix_post` Host fn iterator does not return temporary values Fixes check on address existence Fixes retrieval of wasm code in `fetch_or_compile` Ingores temporary writes in `impl_storage_read` macro Prevents a write log temp write after a write `has_key` host fns return error on temp write
* origin/grarco/fix-vps-api: Changelog #2735 `read_persistent` returns a `PersistentStorageModification` Unit tests write log temp writes In write log `write`, `write_temp` and `delete` now take the precommit into account vp `read_temp` ignores non-temp values instead of error Unifies read interface of vps to that of txs and protocol Refactors `read` and `has_key` implementations in `impl_storage_read` Adds a new `read_persistent` method on `WriteLog`. Refactors `iter_prefix_post` Host fn iterator does not return temporary values Fixes check on address existence Fixes retrieval of wasm code in `fetch_or_compile` Ingores temporary writes in `impl_storage_read` macro Prevents a write log temp write after a write `has_key` host fns return error on temp write # Conflicts: # crates/namada/src/vm/wasm/run.rs
Describe your changes
Closes #2683.
Fixes the
has_key
method provided to the vp env to not return an error on temporary write values (theread
method was already fine).Adds a new
read_persistent
method onWriteLog
that ignore temporary writes and modifies theread
andhas_key
implementation ofimpl_storage_read
to call this new method.Modifies
tx_iter_next
to skip temporary writes.Refactors
fetch_or_compile
to callstate.read
(which should include possible updated in the write log of the wasm codes).Updates
write_temp
inWriteLog
to return an error when trying to overwrite aStorageModification::Write
with aStorageModification::Temp
.Updates
iter_prefix_post
inWriteLog
to iterate also on the precommit bucket.Updates
write
,write_temp
anddelete
inWriteLog
to take the precommit bucket into account.Indicate on which release or other PRs this topic is based on
v0.32.0
Checklist before merging to
draft