Commit Graph

76 Commits

Author SHA1 Message Date
Kris Nuttycombe 33b9bc9667
Merge pull request #16 from nuttycom/allow_duplicate_hashes
Use (position, hash) pair to uniquely identify leaves.
2022-02-23 13:35:41 -07:00
Kris Nuttycombe 1dbb0d057d Update the property tests to generate positioned unwitness and auth_path operations. 2022-02-23 13:35:17 -07:00
Kris Nuttycombe b23b6ff9ec Record position with hash when constructing witnesses. 2022-02-23 11:33:08 -07:00
Kris Nuttycombe 3f0566375b
Merge pull request #15 from nuttycom/remove_witness_deferred
Add garbage collection to the incremental merkle tree.
2022-02-23 11:32:47 -07:00
Kris Nuttycombe d5b7d90e13 Add bridgetree garbage collection.
This adds a garbage collection method to BridgeTree that
can be used to eliminate checkpoints and removed witnesses
that are no longer reachable for possible rewinds. It also
prunes unnecessary auth fragments from the tree.
2022-02-23 08:59:12 -07:00
Kris Nuttycombe c284081a0a Merge remote-tracking branch 'upstream/master' into fix_bridgetree_checkpoint_rewind 2022-02-22 21:05:11 -07:00
Kris Nuttycombe 96157ea5f3
Merge pull request #12 from ghassmo/master
use Self instead of the type's name
2022-02-22 21:01:28 -07:00
Kris Nuttycombe fd9300bf8f Simplify the checkpoint data structure by removing is_checkpointed
It's possible to figure out whether or not a checkpoint is a duplicate
just by looking at the list of checkpoints; the checkpoint doesn't
need to carry that data internally.
2022-02-22 09:51:19 -07:00
Kris Nuttycombe 993dd64650 Fix bridgetree checkpoint/rewind logic to fully restore the tree state.
Removal of witnesses is now recorded on a per-checkpoint
level, so that rewinding the tree state now restores any
witnesses that were removed since the checkpoint.

A number of internal consistency checks previously enforced
by the property tests have been removed as they did not
correctly implement this semantic, and reimplementing these
consistency checks would be equivalent to reimplementing the
sample tree, so these checks are now performed simply by
comparison against the reference implentation.
2022-02-22 09:44:32 -07:00
Kris Nuttycombe aedd865d42 Make example tests reusable across tree implementations. 2022-02-20 13:09:49 -07:00
Kris Nuttycombe ba4fe68eb2 Update bridgetree checkpoint/rewind tests to demonstrate the rewind error. 2022-02-20 10:21:58 -07:00
Kris Nuttycombe efffa8a442 Key auth fragments by note position rather than bridge index.
This substantially simplifies reasoning about authentication
path fragments in garbage collection.
2022-02-20 10:21:58 -07:00
Kris Nuttycombe da420277a5 Use BTreeMap instead of HashMap when keyed by leaf hashes 2022-02-20 10:21:58 -07:00
Kris Nuttycombe 6327364524 Add current_leaf and is_witnessed to the tree API
Rename `current_position` to `current_offset` in the
sample API to avoid confusion with the meaning of
the `Position` type.
2022-02-20 10:21:21 -07:00
Kris Nuttycombe 60d12057a0 Fix a second error in checkpoint/witness/rewind ordering for the sample tree. 2022-02-18 13:32:45 -07:00
Kris Nuttycombe c73cedf8b6 Fix failing rewind/remove_witness interaction. 2022-02-18 13:32:45 -07:00
Kris Nuttycombe 6440119cf7 Add a failing test for remove_witness/rewind interaction 2022-02-18 13:32:45 -07:00
ghassmo 24e1980e8a use Self instead of the type's name 2022-01-23 23:16:30 +04:00
Daira Hopwood 971e84e780
Merge pull request #8 from daira/dual-license
Ensure that GitHub's "View license" link points to complete license information
2022-01-05 15:34:56 +00:00
Daira Hopwood 864990d128 Update copyright year, and change the copyright holder to The Electric Coin Company.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-01-04 19:40:02 +00:00
Daira Hopwood 17d6ccbebe Ensure that GitHub's "View license" link points to complete license information.
refs https://github.com/zcash/librustzcash/issues/443

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-01-04 17:37:34 +00:00
str4d a829044d8a
Merge pull request #11 from zcash/release-0.2.0
incrementalmerkletree 0.2.0
2021-12-17 16:35:37 +00:00
Jack Grigg 1ac3ad239f incrementalmerkletree 0.2.0
Closes zcash/incrementalmerkletree#10.
2021-12-17 16:00:32 +00:00
Kris Nuttycombe 5312649292
Merge pull request #7 from nuttycom/use_witness_for_checkpointing
Use witness for checkpointing
2021-12-10 10:32:04 -07:00
Kris Nuttycombe 0a8854f1b0 Apply suggestions from code review & fix clippy complaints. 2021-12-09 16:31:22 -07:00
Kris Nuttycombe e4573b81c1 Ensure that we always drop old checkpoints when adding a checkpoint. 2021-12-06 13:37:48 -07:00
Kris Nuttycombe 67a5d6ff29 Fix documentation of tree methods. 2021-12-06 13:37:48 -07:00
Kris Nuttycombe 6296748cad Use witness functionality for checkpointing.
This restores an earlier approach to creating checkpoints
that is more space-efficient and reuses the `witness`
machinery. This is preparatory work for supporting arbitrary
rewind-to-witnessed-position.
2021-12-02 08:09:12 -07:00
str4d b7bd624612
Merge pull request #6 from nuttycom/serialization_support
Two minor fixes, plus methods required to support parsing and serialization.
2021-08-03 14:18:22 +01:00
str4d a36a98b64d
Documentation typos
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-08-03 14:18:08 +01:00
Kris Nuttycombe 616344aa9b Document newly added BridgeTree methods. 2021-07-30 15:30:11 -06:00
Kris Nuttycombe 75b26c1dea Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-07-30 15:04:55 -06:00
Kris Nuttycombe 4e12c24807 Move `Position` into the base lib module and ensure wraps u64 explicitly. 2021-07-30 11:52:52 -06:00
Kris Nuttycombe 04384b2b66 Add AuthFragment::from_parts and MerkleBridge::from_parts 2021-07-22 12:21:36 -06:00
Kris Nuttycombe 7b3ac3a22f Lighten constraints on BridgeTree methods. 2021-07-22 12:21:36 -06:00
Kris Nuttycombe d6c0088fc6 Add construction of BridgeTree from parts. 2021-07-22 12:21:36 -06:00
Kris Nuttycombe f705a68db8 Add `TryFrom<NonEmptyFrontier<H>> for Frontier<H, DEPTH>` 2021-07-22 12:21:36 -06:00
Kris Nuttycombe 9a8d388ec8 Implement `PartialEq` and `Eq` for Frontier 2021-07-22 12:21:36 -06:00
Kris Nuttycombe 54430890b1 Add Leaf::into_value 2021-07-22 12:21:36 -06:00
Kris Nuttycombe 6d527c7a67 Add accessors to private frontier elements. 2021-07-22 12:21:33 -06:00
Kris Nuttycombe 909f0d6224 Add `From<usize>` impl for Position 2021-07-22 12:20:12 -06:00
Kris Nuttycombe a5bd5b6a2a Add Frontier::from_parts constructor. 2021-07-22 12:19:55 -06:00
Kris Nuttycombe 98c4dc8de2 Fix an off-by-one error in the maximum height of the tree. 2021-07-22 12:19:16 -06:00
Kris Nuttycombe 2f65f19fa6 Fix formatting. 2021-07-22 12:10:42 -06:00
Kris Nuttycombe 5684063539
Merge pull request #5 from nuttycom/rename_ommer
Rename "parent" to "ommer" and add a few public operations required for serialization support.
2021-07-22 12:01:30 -06:00
Kris Nuttycombe 4d44fb56f5
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
Co-authored-by: ying tong <yingtong@z.cash>
2021-07-20 09:45:36 -06:00
Kris Nuttycombe 9dfc9ecdcc Auth fragment concatenation is only associative, not commutative. 2021-07-20 07:40:13 -06:00
Kris Nuttycombe 63d8437d72 Simplify leaf_value match. 2021-07-20 07:25:26 -06:00
Kris Nuttycombe e6dd1c2461 Remove value_at 2021-07-20 07:22:59 -06:00
Kris Nuttycombe d188121cbe Improve bridgetree documentation. 2021-07-08 10:16:55 -06:00