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

Add invalidate block method and invalidated_blocks field to NonFinalizedState #9167

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

elijahhampton
Copy link
Contributor

@elijahhampton elijahhampton commented Jan 26, 2025

Motivation

This PR implements a new method invalidate_block to invalidate a block based on the block::Hash along with the blocks descendants. This PR closes the following issue: #8840 , #8841

Specifications & References

Reference: #8634

Solution

  • Adds invalidate_block method to NonFinalizedState
  • Changes visibility to pub(crate) for UpdateWith / RevertPosition in chain.rs
  • Adds test for invalidate_block in vectors.rs
  • Adds new invalidated_blocks state to NonFinalizedState

Tests

Follow-up Work

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

PR Reviewer's Checklist

  • The PR Author's checklist is complete.
  • The PR resolves the issue.

Elijah Hampton added 2 commits January 25, 2025 19:38
…se in vectors.rs. Updates non finalized state to track invalidated_blocks
@elijahhampton elijahhampton requested a review from a team as a code owner January 26, 2025 00:47
@elijahhampton elijahhampton requested review from arya2 and removed request for a team January 26, 2025 00:47
@elijahhampton
Copy link
Contributor Author

Closes #8840 , #8841

arya2
arya2 previously approved these changes Jan 29, 2025
Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

Thank you for getting this done.

This looks excellent. I left some optional suggestions, but none of them are blockers so feel free to resolve them without making changes if you'd like this to merge as-is.

zebra-state/src/service/non_finalized_state.rs Outdated Show resolved Hide resolved
zebra-state/src/service/non_finalized_state.rs Outdated Show resolved Hide resolved
zebra-state/src/request.rs Outdated Show resolved Hide resolved
zebra-state/src/request.rs Outdated Show resolved Hide resolved
@arya2 arya2 added I-usability Zebra is hard to understand or use C-testing Category: These are tests A-rpc Area: Remote Procedure Call interfaces A-state Area: State / database changes C-feature Category: New features P-Medium ⚡ labels Jan 29, 2025
@oxarbitrage oxarbitrage added do-not-merge Tells Mergify not to merge this PR and removed do-not-merge Tells Mergify not to merge this PR labels Feb 3, 2025
… values with Arc. Optimizies invalidate_block fn to return early if root has hash of desired block.
@elijahhampton elijahhampton requested a review from arya2 February 5, 2025 22:56
Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

Thank you for the updates!

I left a suggestion for refactoring the methods, but if you'd prefer to keep it as-is, the only blocker is updating the invalidated_blocks field before returning early in NonFinalizedState.invalidate_block().

zebra-state/src/service/non_finalized_state/chain.rs Outdated Show resolved Hide resolved
zebra-state/src/service/non_finalized_state.rs Outdated Show resolved Hide resolved
…Refactors invalidate_block in NonFinalizedState.
@elijahhampton
Copy link
Contributor Author

Thank you for the updates!

I left a suggestion for refactoring the methods, but if you'd prefer to keep it as-is, the only blocker is updating the invalidated_blocks field before returning early in NonFinalizedState.invalidate_block().

I refactored the functions with the suggested changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Area: Remote Procedure Call interfaces A-state Area: State / database changes C-feature Category: New features C-testing Category: These are tests I-usability Zebra is hard to understand or use P-Medium ⚡
Projects
None yet
3 participants