Commit Graph

15 Commits

Author SHA1 Message Date
Kris Nuttycombe c284081a0a Merge remote-tracking branch 'upstream/master' into fix_bridgetree_checkpoint_rewind 2022-02-22 21:05:11 -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 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
Kris Nuttycombe 4e12c24807 Move `Position` into the base lib module and ensure wraps u64 explicitly. 2021-07-30 11:52:52 -06:00
Sean Bowe 09029e9a96
Expose new() only in tests. 2021-06-24 14:16:13 -06:00
Kris Nuttycombe 3decd0bf48 Use const generic parameter for tree depth. 2021-06-23 14:14:57 -06:00
Kris Nuttycombe aed785e896 Rename "Level" -> "Altitude"
The FlyClient spec uses "Altitude" for this concept in
Merkle mountain ranges, so I'm renaming for consistency.
2021-06-19 11:24:33 -06:00
Kris Nuttycombe 06e0a5772e Add `Frontier` trait as a subset of `Tree` operations.
For some applications, it is not necessary to include the
full range of witnessing and checkpointing operations. The
Frontier trait captures the minimal operations required:
appending leaves to the tree and constructing the root
of the tree by hashing against empty nodes.
2021-06-18 14:21:03 -06:00
Kris Nuttycombe 37d1f920e4 Refactor hashing api & contracts of witness & checkpoint methods.
In this commit:

* TreeHasher is replaced by the Hashable trait. Hashable is
  modified to use level information in the construction of
  the hash, and a convenience method is provided for obtaining
  the empty node at a given level.

* The pop_checkpoint method is removed from the `Tree` interface.
  Instead, a maximum number of checkpoints is established at tree
  construction time and then the oldest checkpoints are automatically
  dropped when adding new checkpoints once that number is reached.

* The `witness` method implementation in the sample tree
  is modified to ignore duplicate calls.

* Property testing functiona are modified to abstract over
  the type of hashable data.
2021-06-17 19:24:18 -06:00
Kris Nuttycombe 68c8d88bd3 Move sample tree & efficient tree to independent modules. 2021-06-17 19:17:47 -06:00