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

Enabling changes for merkle.remove #647

Closed
wants to merge 2 commits into from

Conversation

danlaine
Copy link

Broken out of #644 to make reviewing easier.

  • Changes the value type of modified to Option, where None indicates the node was deleted.
  • Allows setting the root of a node store to None.

if let Some((modified_node, _)) = modified_node {
Ok(modified_node.clone())
} else {
Err(Error::new(std::io::ErrorKind::Other, "Node not found"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Although I think this code shouldn't be needed at all (see earlier comment) at a minimum this should be the same as when a node is read that has been freed, see read_node in nodestore which does this:

Err(Error::new(
                ErrorKind::InvalidData,
                "Attempted to read a freed area",
            )),

modified: HashMap<LinearAddress, (Arc<Node>, u8)>,
// Linear Address -> (Node, Node Size Index)
// None means the node was deleted.
modified: HashMap<LinearAddress, Option<(Arc<Node>, u8)>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is not needed. Why can't you just remove it from modified when it is deleted?

Nobody should ever reference it once it has been deleted in any case.

Copy link
Author

@danlaine danlaine May 16, 2024

Choose a reason for hiding this comment

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

What does the delete_node implementation look like without this?

Why can't you just remove it from modified when it is deleted?

What if the node being deleted wasn't modified in this HashedNodeStore? Then removing it from modified would be a no-op.

If the node is in modified, and we delete it, what happens then? When do we tell the underlying node store to delete the node at the given address?

Copy link
Collaborator

@rkuris rkuris May 16, 2024

Choose a reason for hiding this comment

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

If the node is in modified, and we delete it, what happens then? When do we tell the underlying node store to delete the node at the given address?

Yes. We should just delete it from the linear store. If you don't do this, then the space for it can't be reused by another node in the same batch, for example.

Copy link
Author

Choose a reason for hiding this comment

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

If you don't do this, then the space for it can't be reused by another node in the same batch, for example.

Yeah that's definitely a bug in this PR. Going to close this. I removed these changes from #644

@danlaine danlaine closed this May 16, 2024
@danlaine danlaine deleted the remove-shale-allow-deletion branch May 16, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants