Merge pull request #113 from nuttycom/incrementalmerketree-testing
Extract `incrementalmerkletree::testing` module to a separate `incrementalmerkletree-testing` crate.
This commit is contained in:
commit
771c0858a2
|
@ -46,6 +46,7 @@ name = "bridgetree"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"incrementalmerkletree",
|
"incrementalmerkletree",
|
||||||
|
"incrementalmerkletree-testing",
|
||||||
"proptest",
|
"proptest",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "incrementalmerkletree"
|
name = "incrementalmerkletree"
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"either",
|
"either",
|
||||||
"proptest",
|
"proptest",
|
||||||
|
@ -120,6 +121,14 @@ dependencies = [
|
||||||
"rand_core",
|
"rand_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "incrementalmerkletree-testing"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"incrementalmerkletree",
|
||||||
|
"proptest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "instant"
|
name = "instant"
|
||||||
version = "0.1.12"
|
version = "0.1.12"
|
||||||
|
@ -324,6 +333,7 @@ dependencies = [
|
||||||
"bitflags 2.4.1",
|
"bitflags 2.4.1",
|
||||||
"either",
|
"either",
|
||||||
"incrementalmerkletree",
|
"incrementalmerkletree",
|
||||||
|
"incrementalmerkletree-testing",
|
||||||
"proptest",
|
"proptest",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
17
Cargo.toml
17
Cargo.toml
|
@ -1,6 +1,23 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"incrementalmerkletree",
|
"incrementalmerkletree",
|
||||||
|
"incrementalmerkletree-testing",
|
||||||
"bridgetree",
|
"bridgetree",
|
||||||
"shardtree",
|
"shardtree",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[workspace.package]
|
||||||
|
edition = "2021"
|
||||||
|
rust-version = "1.64"
|
||||||
|
repository = "https://github.com/zcash/incrementalmerkletree"
|
||||||
|
homepage = "https://github.com/zcash/incrementalmerkletree"
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
|
categories = ["algorithms", "data-structures"]
|
||||||
|
|
||||||
|
[workspace.dependencies]
|
||||||
|
# Intra-workspace dependencies
|
||||||
|
incrementalmerkletree = { version = "0.7", path = "incrementalmerkletree" }
|
||||||
|
incrementalmerkletree-testing = { version = "0.1", path = "incrementalmerkletree-testing" }
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
proptest = "1"
|
||||||
|
|
|
@ -7,6 +7,9 @@ and this project adheres to Rust's notion of
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- MSRV is now 1.64
|
||||||
|
|
||||||
## [0.5.0] - 2024-08-12
|
## [0.5.0] - 2024-08-12
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -1,25 +1,26 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bridgetree"
|
name = "bridgetree"
|
||||||
|
description = "A space-efficient Merkle tree designed for linear appends with witnessing of marked leaves, checkpointing & state restoration."
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
authors = [
|
authors = [
|
||||||
"Kris Nuttycombe <kris@nutty.land>",
|
"Kris Nuttycombe <kris@nutty.land>",
|
||||||
"Sean Bowe <ewillbefull@gmail.com>",
|
"Sean Bowe <ewillbefull@gmail.com>",
|
||||||
]
|
]
|
||||||
edition = "2021"
|
edition.workspace = true
|
||||||
license = "MIT OR Apache-2.0"
|
license.workspace = true
|
||||||
description = "A space-efficient Merkle tree designed for linear appends with witnessing of marked leaves, checkpointing & state restoration."
|
homepage.workspace = true
|
||||||
homepage = "https://github.com/zcash/incrementalmerkletree"
|
repository.workspace = true
|
||||||
repository = "https://github.com/zcash/incrementalmerkletree"
|
categories.workspace = true
|
||||||
categories = ["algorithms", "data-structures"]
|
rust-version.workspace = true
|
||||||
rust-version = "1.60"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
incrementalmerkletree = { version = "0.6", path = "../incrementalmerkletree" }
|
incrementalmerkletree.workspace = true
|
||||||
proptest = { version = "1.0.0", optional = true }
|
proptest = { workspace = true, optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
incrementalmerkletree = { version = "0.6", path = "../incrementalmerkletree", features = ["test-dependencies"] }
|
incrementalmerkletree = { workspace = true, features = ["test-dependencies"] }
|
||||||
proptest = "1.0.0"
|
incrementalmerkletree-testing.workspace = true
|
||||||
|
proptest.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-dependencies = ["proptest"]
|
test-dependencies = ["proptest"]
|
||||||
|
|
|
@ -986,13 +986,11 @@ mod tests {
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use incrementalmerkletree::{
|
use incrementalmerkletree::Hashable;
|
||||||
testing::{
|
use incrementalmerkletree_testing::{
|
||||||
self, apply_operation, arb_operation, check_checkpoint_rewind, check_operations,
|
self as testing, apply_operation, arb_operation, check_checkpoint_rewind, check_operations,
|
||||||
check_remove_mark, check_rewind_remove_mark, check_root_hashes, check_witnesses,
|
check_remove_mark, check_rewind_remove_mark, check_root_hashes, check_witnesses,
|
||||||
complete_tree::CompleteTree, CombinedTree, SipHashable,
|
complete_tree::CompleteTree, CombinedTree, SipHashable,
|
||||||
},
|
|
||||||
Hashable,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<H: Hashable + Clone + Ord, const DEPTH: u8> testing::Tree<H, usize>
|
impl<H: Hashable + Clone + Ord, const DEPTH: u8> testing::Tree<H, usize>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to Rust's notion of
|
||||||
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
## [0.1.0] - 2024-09-25
|
||||||
|
Initial release.
|
|
@ -0,0 +1,23 @@
|
||||||
|
[package]
|
||||||
|
name = "incrementalmerkletree-testing"
|
||||||
|
description = "Common types, interfaces, and utilities for testing Merkle tree data structures"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = [
|
||||||
|
"Kris Nuttycombe <kris@nutty.land>",
|
||||||
|
"Sean Bowe <ewillbefull@gmail.com>",
|
||||||
|
]
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
homepage.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
categories.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
incrementalmerkletree = { workspace = true, features = ["test-dependencies"] }
|
||||||
|
|
||||||
|
proptest.workspace = true
|
|
@ -0,0 +1,202 @@
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015-2021 The Electric Coin Company
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
|
@ -0,0 +1,6 @@
|
||||||
|
incrementalmerkletree-testing
|
||||||
|
=============================
|
||||||
|
|
||||||
|
This crate contains common testing infrastructure used in the implementation of
|
||||||
|
the `bridgetree` and `shardtree` crates.
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
use crate::Marking;
|
use crate::Tree;
|
||||||
use crate::{testing::Tree, Hashable, Level, Position, Retention};
|
use incrementalmerkletree::{Hashable, Level, Marking, Position, Retention};
|
||||||
|
|
||||||
const MAX_COMPLETE_SIZE_ERROR: &str = "Positions of a `CompleteTree` must fit into the platform word size, because larger complete trees are not representable.";
|
const MAX_COMPLETE_SIZE_ERROR: &str = "Positions of a `CompleteTree` must fit into the platform word size, because larger complete trees are not representable.";
|
||||||
|
|
||||||
|
@ -320,12 +320,10 @@ mod tests {
|
||||||
|
|
||||||
use super::CompleteTree;
|
use super::CompleteTree;
|
||||||
use crate::{
|
use crate::{
|
||||||
testing::{
|
check_append, check_checkpoint_rewind, check_rewind_remove_mark, check_root_hashes,
|
||||||
check_append, check_checkpoint_rewind, check_rewind_remove_mark, check_root_hashes,
|
check_witnesses, compute_root_from_witness, SipHashable, Tree,
|
||||||
check_witnesses, compute_root_from_witness, SipHashable, Tree,
|
|
||||||
},
|
|
||||||
Hashable, Level, Position, Retention,
|
|
||||||
};
|
};
|
||||||
|
use incrementalmerkletree::{Hashable, Level, Position, Retention};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn correct_empty_root() {
|
fn correct_empty_root() {
|
||||||
|
@ -384,7 +382,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn correct_witness() {
|
fn correct_witness() {
|
||||||
use crate::{testing::Tree, Retention};
|
use crate::Tree;
|
||||||
|
use incrementalmerkletree::Retention;
|
||||||
|
|
||||||
const DEPTH: u8 = 3;
|
const DEPTH: u8 = 3;
|
||||||
let values = (0..(1 << DEPTH)).map(SipHashable);
|
let values = (0..(1 << DEPTH)).map(SipHashable);
|
File diff suppressed because it is too large
Load Diff
|
@ -7,6 +7,15 @@ and this project adheres to Rust's notion of
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## [0.7.0] - 2024-09-25
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- MSRV is now 1.64
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- `incrementalmerkletree::testing::{Tree, complete_tree}` and related types and functions
|
||||||
|
have been removed. Use the `incrementalmerkletree-testing` crate instead.
|
||||||
|
|
||||||
## [0.6.0] - 2024-08-12
|
## [0.6.0] - 2024-08-12
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
[package]
|
[package]
|
||||||
name = "incrementalmerkletree"
|
name = "incrementalmerkletree"
|
||||||
description = "Common types, interfaces, and utilities for Merkle tree data structures"
|
description = "Common types, interfaces, and utilities for Merkle tree data structures"
|
||||||
version = "0.6.0"
|
version = "0.7.0"
|
||||||
authors = [
|
authors = [
|
||||||
"Sean Bowe <ewillbefull@gmail.com>",
|
"Sean Bowe <ewillbefull@gmail.com>",
|
||||||
"Kris Nuttycombe <kris@nutty.land>",
|
"Kris Nuttycombe <kris@nutty.land>",
|
||||||
]
|
]
|
||||||
edition = "2021"
|
edition.workspace = true
|
||||||
license = "MIT OR Apache-2.0"
|
license.workspace = true
|
||||||
homepage = "https://github.com/zcash/incrementalmerkletree"
|
homepage.workspace = true
|
||||||
repository = "https://github.com/zcash/incrementalmerkletree"
|
repository.workspace = true
|
||||||
categories = ["algorithms", "data-structures"]
|
categories.workspace = true
|
||||||
rust-version = "1.60"
|
rust-version.workspace = true
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
@ -19,12 +19,12 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
either = "1.8"
|
either = "1.8"
|
||||||
proptest = { version = "1.0.0", optional = true }
|
proptest = { workspace = true, optional = true }
|
||||||
rand = { version = "0.8", optional = true }
|
rand = { version = "0.8", optional = true }
|
||||||
rand_core = { version = "0.6", optional = true }
|
rand_core = { version = "0.6", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
proptest = "1.0.0"
|
proptest.workspace = true
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rand_core = "0.6"
|
rand_core = "0.6"
|
||||||
rand_chacha = "0.3"
|
rand_chacha = "0.3"
|
||||||
|
|
|
@ -561,7 +561,6 @@ impl<H: Hashable + Clone, const DEPTH: u8> CommitmentTree<H, DEPTH> {
|
||||||
left: Some(left),
|
left: Some(left),
|
||||||
right,
|
right,
|
||||||
parents: (1u8..DEPTH)
|
parents: (1u8..DEPTH)
|
||||||
.into_iter()
|
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
if u64::from(f.position()) & (1 << i) == 0 {
|
if u64::from(f.position()) & (1 << i) == 0 {
|
||||||
None
|
None
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,3 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.60.0"
|
channel = "1.64.0"
|
||||||
components = [ "clippy", "rustfmt" ]
|
components = [ "clippy", "rustfmt" ]
|
||||||
|
|
|
@ -7,6 +7,9 @@ and this project adheres to Rust's notion of
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- MSRV is now 1.64
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- `shardtree::store::ShardStore::for_each_checkpoint`
|
- `shardtree::store::ShardStore::for_each_checkpoint`
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
[package]
|
[package]
|
||||||
name = "shardtree"
|
name = "shardtree"
|
||||||
|
description = "A space-efficient Merkle tree with witnessing of marked leaves, checkpointing & state restoration."
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
authors = [
|
authors = [
|
||||||
"Kris Nuttycombe <kris@nutty.land>",
|
"Kris Nuttycombe <kris@nutty.land>",
|
||||||
]
|
]
|
||||||
edition = "2021"
|
edition.workspace = true
|
||||||
rust-version = "1.60"
|
rust-version.workspace = true
|
||||||
license = "MIT OR Apache-2.0"
|
license.workspace = true
|
||||||
description = "A space-efficient Merkle tree with witnessing of marked leaves, checkpointing & state restoration."
|
homepage.workspace = true
|
||||||
homepage = "https://github.com/zcash/incrementalmerkletree"
|
repository.workspace = true
|
||||||
repository = "https://github.com/zcash/incrementalmerkletree"
|
categories.workspace = true
|
||||||
categories = ["algorithms", "data-structures"]
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
@ -20,14 +20,16 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||||
assert_matches = { version = "1.5", optional = true }
|
assert_matches = { version = "1.5", optional = true }
|
||||||
bitflags = "2"
|
bitflags = "2"
|
||||||
either = "1.8"
|
either = "1.8"
|
||||||
incrementalmerkletree = { version = "0.6", path = "../incrementalmerkletree" }
|
incrementalmerkletree.workspace = true
|
||||||
proptest = { version = "1.0.0", optional = true }
|
proptest = { workspace = true, optional = true }
|
||||||
|
incrementalmerkletree-testing = { workspace = true, optional = true }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_matches = "1.5"
|
assert_matches = "1.5"
|
||||||
incrementalmerkletree = { version = "0.6", path = "../incrementalmerkletree", features = ["test-dependencies"] }
|
incrementalmerkletree = { workspace = true, features = ["test-dependencies"] }
|
||||||
proptest = "1.0.0"
|
incrementalmerkletree-testing.workspace = true
|
||||||
|
proptest.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# The legacy-api feature guards types and functions that are useful for
|
# The legacy-api feature guards types and functions that are useful for
|
||||||
|
|
|
@ -1309,14 +1309,13 @@ mod tests {
|
||||||
|
|
||||||
use incrementalmerkletree::{
|
use incrementalmerkletree::{
|
||||||
frontier::{Frontier, NonEmptyFrontier},
|
frontier::{Frontier, NonEmptyFrontier},
|
||||||
testing::{
|
|
||||||
arb_operation, check_append, check_checkpoint_rewind, check_operations,
|
|
||||||
check_remove_mark, check_rewind_remove_mark, check_root_hashes,
|
|
||||||
check_witness_consistency, check_witnesses, complete_tree::CompleteTree, CombinedTree,
|
|
||||||
SipHashable,
|
|
||||||
},
|
|
||||||
Address, Hashable, Level, Marking, MerklePath, Position, Retention,
|
Address, Hashable, Level, Marking, MerklePath, Position, Retention,
|
||||||
};
|
};
|
||||||
|
use incrementalmerkletree_testing::{
|
||||||
|
arb_operation, check_append, check_checkpoint_rewind, check_operations, check_remove_mark,
|
||||||
|
check_rewind_remove_mark, check_root_hashes, check_witness_consistency, check_witnesses,
|
||||||
|
complete_tree::CompleteTree, CombinedTree, SipHashable,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{QueryError, ShardTreeError},
|
error::{QueryError, ShardTreeError},
|
||||||
|
@ -1462,9 +1461,7 @@ mod tests {
|
||||||
// boundary.
|
// boundary.
|
||||||
tree.batch_insert(
|
tree.batch_insert(
|
||||||
frontier_end + 1,
|
frontier_end + 1,
|
||||||
('g'..='j')
|
('g'..='j').map(|c| (c.to_string(), Retention::Ephemeral)),
|
||||||
.into_iter()
|
|
||||||
.map(|c| (c.to_string(), Retention::Ephemeral)),
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -1476,9 +1473,7 @@ mod tests {
|
||||||
// Insert nodes that require the pruned nodes for witnessing
|
// Insert nodes that require the pruned nodes for witnessing
|
||||||
tree.batch_insert(
|
tree.batch_insert(
|
||||||
frontier_end - 1,
|
frontier_end - 1,
|
||||||
('e'..='f')
|
('e'..='f').map(|c| (c.to_string(), Retention::Marked)),
|
||||||
.into_iter()
|
|
||||||
.map(|c| (c.to_string(), Retention::Marked)),
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -220,12 +220,9 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use incrementalmerkletree::{
|
use incrementalmerkletree::{Hashable, Marking, Position, Retention};
|
||||||
testing::{
|
use incrementalmerkletree_testing::{
|
||||||
append_str, check_operations, unmark, witness, CombinedTree, Operation, TestHashable,
|
append_str, check_operations, unmark, witness, CombinedTree, Operation, TestHashable, Tree,
|
||||||
Tree,
|
|
||||||
},
|
|
||||||
Hashable, Marking, Position, Retention,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::CachingShardStore;
|
use super::CachingShardStore;
|
||||||
|
|
|
@ -6,7 +6,8 @@ use proptest::collection::vec;
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
use proptest::sample::select;
|
use proptest::sample::select;
|
||||||
|
|
||||||
use incrementalmerkletree::{testing, Hashable};
|
use incrementalmerkletree::Hashable;
|
||||||
|
use incrementalmerkletree_testing as testing;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::store::{memory::MemoryShardStore, ShardStore};
|
use crate::store::{memory::MemoryShardStore, ShardStore};
|
||||||
|
@ -323,9 +324,7 @@ pub fn check_shardtree_insertion<
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
tree.batch_insert(
|
tree.batch_insert(
|
||||||
Position::from(4),
|
Position::from(4),
|
||||||
('e'..'k')
|
('e'..'k').map(|c| (c.to_string(), Retention::Ephemeral))
|
||||||
.into_iter()
|
|
||||||
.map(|c| (c.to_string(), Retention::Ephemeral))
|
|
||||||
),
|
),
|
||||||
Ok(_)
|
Ok(_)
|
||||||
);
|
);
|
||||||
|
@ -379,7 +378,7 @@ pub fn check_witness_with_pruned_subtrees<
|
||||||
// simulate discovery of a note
|
// simulate discovery of a note
|
||||||
tree.batch_insert(
|
tree.batch_insert(
|
||||||
Position::from(24),
|
Position::from(24),
|
||||||
('a'..='h').into_iter().map(|c| {
|
('a'..='h').map(|c| {
|
||||||
(
|
(
|
||||||
c.to_string(),
|
c.to_string(),
|
||||||
match c {
|
match c {
|
||||||
|
|
Loading…
Reference in New Issue