-
Notifications
You must be signed in to change notification settings - Fork 956
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
New storage write API #2355
New storage write API #2355
Conversation
80f2ca1
to
0d5cfdc
Compare
b27bc60
to
5a6c6f8
Compare
c8bcb96
to
1798f81
Compare
03c5977
to
fd7e817
Compare
aaca999
to
7207603
Compare
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.
Overall, it looks good to me. I left some comments
71833cd
to
a668827
Compare
eea0a55
to
ef90ed1
Compare
|
||
// If not persisting the diffs, remove the existing diffs from two block | ||
// heights earlier than `height` | ||
if !persist_diffs { |
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 don't think this works. This deletes a key with height height - 2
. But say that we write a non-diff key at height 5 and than the next write happens at height 7, than we'll try to delete the keys 6/old/
and 6/new
which don't exist. Instead we should be deleting the keys 5/old
and 5/new
. This can build up and we can end up with quite a few stale keys in storage
|
||
// If not persisting the diffs, remove the existing diffs from two block | ||
// heights earlier than `height` | ||
if !persist_diffs { |
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.
Same here
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 new API is definitely an improvement. A few minor nits and some questions on negative gas.
batch.0.put_cf(cf, new_val_key, new_value); | ||
} | ||
|
||
// If not persisting the diffs, remove the last diffs. |
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.
Seems like the same code as above? Can we abstract this into a function?
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.
unfortunately they don't have the same interface - I think we'll want to get rid of the non-batch methods though
crates/state/src/lib.rs
Outdated
} | ||
|
||
/// Write with diffs but no merklization | ||
pub fn write_without_merkl( |
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.
Nit, but it's "merkle"
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.
fixed in 9ca40ed
StorageModification::Write { | ||
ref value, | ||
action: _, | ||
} => len as i64 - value.len() as i64, |
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.
What happens here if value.len() > len
? Do we charge negative gas? Is this intended?
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.
This is only used for size_diff
and we don't do anything with it on the caller side(s). We don't subtract from gas cost
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.
Ah ah OK nvm then
StorageModification::Write { | ||
ref value, | ||
action: _, | ||
} => len as i64 - value.len() as i64, |
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.
Same question (what happens if len - value.len() < 0
?)
9ca40ed
to
89bb67d
Compare
* brent/new-storage-write: rename new fns prune non-persisted DB diffs No merkle/diffs for remaining masp keys changelog: add #2355 ibc: storage keys refactor handle non-merklized values in `State` methods some TODOs and another comment remake wasms for tests ibc writes without merklization or diffs tests for writing without merklization or diffs use consts instead of string literals abstract instances of `write_bytes` to `write` masp writes without merklization or diffs storage write/delete options for inclusion in merkle tree and diffs
closing in favor of #2438 |
Describe your changes
StorageWrite API changes.
Some notes:
write
anddelete
functionsmasp/note_commitment_anchor/<hash>
masp/commitment_tree
masp/convert_anchor
masp/nullifiers/<hash>
masp/pin-<id>
ibc/clients/counter
ibc/connections/counter
ibc/channelEnds/counter
write_bytes
are abstracted abstracted to a different write API callIndicate on which release or other PRs this topic is based on
v0.30.1
Checklist before merging to
draft