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

fix: ensures mutable MMR bitmaps are compressed #5278

Merged

Conversation

AaronFeickert
Copy link
Collaborator

@AaronFeickert AaronFeickert commented Mar 28, 2023

Description

Ensures that mutable MMR root computation first performs deletion bitmap compression.

Closes issue 5277.

Motivation and Context

Currently, when mutable MMR roots are computed, it's implicitly assumed that the underlying deletion bitmap has been compressed. If it has not, it's possible for the resulting root to be different than if the bitmap were compressed. This already resulted in an intermittent test failure.

To reduce the risk that a caller does not perform this compression correctly, this PR adds compression to the Merkle root computation functionality directly. It also removes a few compression calls that become redundant with this change.

Note that this may constitute an efficiency regression. If a mutable MMR does not have any deletions since its last bitmap compression, subsequent compression is not necessary. Further, we perform the compression on a clone of the bitmap; this is necessary to avoid mutability and ensure that operations like equality (which rely on root computation) function properly. The efficiency consequences of this change should be examined to ensure they are acceptable.

How Has This Been Tested?

Existing CI passes.

What process can a PR reviewer use to test or verify this change?

Run existing CI. To further check for intermittent test failures, loop affected tests.

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

It may be the case that this change affects the way mutable MMR roots are computed in certain cases, which in turn may be a breaking change.

@AaronFeickert AaronFeickert marked this pull request as draft March 28, 2023 16:20
@ghpbot-tari-project ghpbot-tari-project added P-acks_required Process - Requires more ACKs or utACKs P-reviews_required Process - Requires a review from a lead maintainer to be merged labels Mar 28, 2023
@AaronFeickert AaronFeickert marked this pull request as ready for review March 28, 2023 16:31
Copy link
Collaborator

@stringhandler stringhandler left a comment

Choose a reason for hiding this comment

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

Nice

@ghpbot-tari-project ghpbot-tari-project removed the P-reviews_required Process - Requires a review from a lead maintainer to be merged label Mar 28, 2023
@stringhandler stringhandler merged commit dfddc66 into tari-project:development Mar 28, 2023
@AaronFeickert AaronFeickert deleted the mmr-compression branch March 28, 2023 17:46
agubarev pushed a commit to agubarev/tari that referenced this pull request Mar 31, 2023
Description
---
Ensures that mutable MMR root computation first performs deletion bitmap
compression.

Closes [issue 5277](tari-project#5277).

Motivation and Context
---
Currently, when mutable MMR roots [are
computed](https://github.com/tari-project/tari/blob/e334a404e432b0911bae3054a28d8e8ca5876e6c/base_layer/mmr/src/mutable_mmr.rs#L119-L131),
it's implicitly assumed that the underlying deletion bitmap has been
compressed. If it has not, it's possible for the resulting root to be
different than if the bitmap were compressed. This already resulted in
an intermittent [test
failure](tari-project#5268).

To reduce the risk that a caller does not perform this compression
correctly, this PR adds compression to the Merkle root computation
functionality directly. It also removes a few compression calls that
become redundant with this change.

Note that this may constitute an efficiency regression. If a mutable MMR
does not have any deletions since its last bitmap compression,
subsequent compression is not necessary. Further, we perform the
compression on a clone of the bitmap; this is necessary to avoid
mutability and ensure that operations like equality (which rely on root
computation) function properly. The efficiency consequences of this
change should be examined to ensure they are acceptable.

How Has This Been Tested?
---
Existing CI passes.

What process can a PR reviewer use to test or verify this change?
---
Run existing CI. To further check for intermittent test failures, loop
affected tests.

Breaking Changes
---

- [ ] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [x] Other - Please specify

It may be the case that this change affects the way mutable MMR roots
are computed in certain cases, which in turn may be a breaking change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-acks_required Process - Requires more ACKs or utACKs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check that all mutable MMRs properly compress deletion bitmaps
3 participants