Optimize PMMR segments to only include hashes at pruning boundaries#3820
Optimize PMMR segments to only include hashes at pruning boundaries#3820mkorovkin2 wants to merge 1 commit into
Conversation
…t pruning boundaries; tests updated as segment size dropped from 521 to 281 bytes (7 hashes -> 1 hash)
|
First PR! (People in the Keybase/Telegram chat suggested to tag John/David) |
|
Hey @DavidBurkett - when you get a chance would appreciate your feedback on this PR! |
|
PIBD Sync is restarting every time before validation when this peer exists in the end of |
| true | ||
| } | ||
| }; | ||
| if need_hash { |
There was a problem hiding this comment.
If need_hash is true, silently skipping a missing hash can produce a segment that later fails validation with MissingHash or Invalid Root. Should this return an error instead?
like:
let hash = pmmr
.get_from_file(pos0)
.ok_or_else(|| SegmentError::MissingHash(pos0))?;
There was a problem hiding this comment.
This also matches the failure pattern you observed, @ardocrat.
| id: SegmentIdentifier, | ||
| ) -> Result<(Segment<OutputIdentifier>, Hash), Error> { | ||
| let now = Instant::now(); | ||
| let bitmap = self.bitmap_snapshot.as_bitmap().ok(); |
There was a problem hiding this comment.
Can we avoid .ok() here? If building the bitmap fails, I think this should return an error
| /// Create a rangeproof segment. | ||
| pub fn rangeproof_segment(&self, id: SegmentIdentifier) -> Result<Segment<RangeProof>, Error> { | ||
| let now = Instant::now(); | ||
| let bitmap = self.bitmap_snapshot.as_bitmap().ok(); |
There was a problem hiding this comment.
Same here, I think bitmap errors should be returned instead of being converted to None.
@ardocrat |
Then we'll need additional validation for segments, current validation or root validation after applying new segment is not helping as I tested |
Addressing TODO item in code: optimize PMMR segments to only include hashes at pruning boundaries; tests updated as segment size dropped from 521 to 281 bytes (7 hashes -> 1 hash)
name: Pull Request
about: Pull Request checklist
title: 'Optimize PMMR segments to only include hashes at pruning boundaries'
labels: ''
assignees: ''
cargo test -p grin_core unprunable_mmr/cargo test -p grin_store --test segment/cargo test -p grin_chain --test bitmap_segment