-
Notifications
You must be signed in to change notification settings - Fork 2.6k
pallet-mmr: batch proofs are sometimes broken #11753
Comments
ping @Wizdave97 as original PR author |
The depth is less than the proof items length by a difference of 1, so it fails at that point, If that check is commented out the test passes, seems the depth calculation might have a bug in that edge case. |
It's more than an off-by-one error - discrepancy grows with decreasing overlap of copaths of leaves to be proven. Within a merkle tree with n leaves, a proof for a single leaf to its peak requires
It's not necessary - I believe the only purpose is to fail early when the proof is clearly invalid, except in this case the bound is incorrect. Aside from removing it entirely, one possible replacement for the check is |
as described in paritytech#11753 (comment)
* pallet-mmr: extend batch proof verification test covers all possible 2-leaf combinations now, including current verification failures that batch proof item count limit is too low sometimes. * raise upper bound on proof item number as described in #11753 (comment) * test for powerset of leaves * refactor batch proof verification test * test all batch proofs for mmr sizes up to n=13 * limit mmr size to reduce batch proof test duration * use saturating integer addition for proof check * extract common chain building in batch proof tests note: right now, since not killing old chain, it keeps growing by 7 blocks for every leaf selection (added after proof generation), hence heavier to compute. * only add blocks after a proof generation once * increase batch proof testing range * register offchain extensions only once * fmt & remove unused util
* pallet-mmr: extend batch proof verification test covers all possible 2-leaf combinations now, including current verification failures that batch proof item count limit is too low sometimes. * raise upper bound on proof item number as described in paritytech#11753 (comment) * test for powerset of leaves * refactor batch proof verification test * test all batch proofs for mmr sizes up to n=13 * limit mmr size to reduce batch proof test duration * use saturating integer addition for proof check * extract common chain building in batch proof tests note: right now, since not killing old chain, it keeps growing by 7 blocks for every leaf selection (added after proof generation), hence heavier to compute. * only add blocks after a proof generation once * increase batch proof testing range * register offchain extensions only once * fmt & remove unused util
* pallet-mmr: extend batch proof verification test covers all possible 2-leaf combinations now, including current verification failures that batch proof item count limit is too low sometimes. * raise upper bound on proof item number as described in paritytech#11753 (comment) * test for powerset of leaves * refactor batch proof verification test * test all batch proofs for mmr sizes up to n=13 * limit mmr size to reduce batch proof test duration * use saturating integer addition for proof check * extract common chain building in batch proof tests note: right now, since not killing old chain, it keeps growing by 7 blocks for every leaf selection (added after proof generation), hence heavier to compute. * only add blocks after a proof generation once * increase batch proof testing range * register offchain extensions only once * fmt & remove unused util
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
#10635 added support for generating and/or verifying proofs for multiple leaves at a time.
Single leaf proof generation/verification seems to always work, but multi-leaf (batch) proof generation/verification sometimes fails.
Steps to reproduce
Apply following patch to substrate:
then run the test and it will incorrectly fail:
As an interesting observation, generating+verifying
[7, 11]
on a 12-leaves MMR works, while for a 13-leaves MMR it fails.The text was updated successfully, but these errors were encountered: