Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions src/storage/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,23 +840,17 @@ impl StorageEngine {
node: &mut Node,
common_prefix_length: usize,
) -> Result<PointerChange, Error> {
if changes.is_empty() {
return Ok(PointerChange::None);
}
// Skip any deletion changes at the start since they are no-ops
let first_non_delete_idx = changes.iter().position(|(_, value)| value.is_some());
let first_non_delete_idx = match first_non_delete_idx {
None => return Ok(PointerChange::None),
Some(idx) => idx,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this not being caught by the current code? Is it stack overflow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we don't have unit tests or benchmarks which requires deleting many non-existing values in a single transaction until #106 (comment)


// the account has no storage trie yet, so we need to create a new leaf node for the first
// slot Get the first change and create a new leaf node
let changes = &changes[first_non_delete_idx..];
let ((path, value), remaining_changes) = changes.split_first().unwrap();
if value.is_none() {
// this is a delete on a storage value that doesn't exist. skip it.
return self.set_values_in_cloned_page(
context,
remaining_changes,
path_offset,
slotted_page,
page_index,
);
}

let node_size_incr = node.size_incr_with_new_child();
let remaining_path = path.slice(path_offset as usize + common_prefix_length..);
Expand Down