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 5 commits 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 |
@ardocrat |
Then we'll need additional validation for segments, current validation or root validation after applying new segment is not helping as I tested |
Segment root validation only checked hashes that participate in reconstructing the segment root. Apply, however, writes every hash in the segment into the local PMMR. A peer could therefore pass a segment with a valid root proof while poisoning intermediate hashes; the corruption only showed up at full state validation as a bad root, with no peer attribution. After the merkle proof succeeds, verify every carried hash is bound to the proof-validated root: either consumed during reconstruction, or a child of an already bound parent that hashes to that parent. Legitimate dense segments from uncompacted peers (pre-mimblewimble#3820 style) still pass when their extra hashes are consistent; only inconsistent or unbound hashes are rejected early as UnverifiableHash. Adds store segment tests covering tampered intermediate hashes and the uncompacted-peer dense format.
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