From 3036d803c360d0af520e46d26beabb0eb945c3ba Mon Sep 17 00:00:00 2001 From: jjy Date: Fri, 17 Mar 2023 15:54:51 +0800 Subject: [PATCH 1/3] refactor: implement append-only tree --- Cargo.toml | 2 - benches/smt_benchmark.rs | 1 + benches/store_counter_benchmark.rs | 9 +- proptest-regressions/tests/smt.txt | 7 + proptest-regressions/tests/tree.txt | 1 + src/default_store.rs | 53 ++-- src/h256.rs | 2 +- src/lib.rs | 7 +- src/merge.rs | 147 ++++++---- src/merkle_proof.rs | 7 +- src/tests/fixtures.rs | 5 +- src/tests/history.rs | 50 ++++ src/tests/mod.rs | 2 + src/tests/tree.rs | 232 ++++++--------- src/tests/utils.rs | 59 ++++ src/traits.rs | 12 +- src/tree.rs | 416 ++++++++++++++------------ src/trie_tree.rs | 436 ---------------------------- 18 files changed, 563 insertions(+), 885 deletions(-) create mode 100644 proptest-regressions/tests/smt.txt create mode 100644 src/tests/history.rs create mode 100644 src/tests/utils.rs delete mode 100644 src/trie_tree.rs diff --git a/Cargo.toml b/Cargo.toml index 37cc346..9e87172 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,8 +21,6 @@ default = ["std"] std = [] # SMT implemented in C smtc = [] -# A storage optimized SMT implemented in trie (https://ouvrard-pierre-alain.medium.com/sparse-merkle-tree-86e6e2fc26da) -trie = [] [dependencies] cfg-if = "1" diff --git a/benches/smt_benchmark.rs b/benches/smt_benchmark.rs index 72bd411..8f06986 100644 --- a/benches/smt_benchmark.rs +++ b/benches/smt_benchmark.rs @@ -30,6 +30,7 @@ fn random_smt(update_count: usize, rng: &mut impl Rng) -> (SMT, Vec) { (smt, keys) } +#[allow(deprecated)] fn random_smt_update_all(update_count: usize, rng: &mut impl Rng) { let mut smt = SMT::default(); let mut kvs = Vec::with_capacity(update_count); diff --git a/benches/store_counter_benchmark.rs b/benches/store_counter_benchmark.rs index 486e28e..8e573b7 100644 --- a/benches/store_counter_benchmark.rs +++ b/benches/store_counter_benchmark.rs @@ -9,7 +9,7 @@ use sparse_merkle_tree::{ default_store::DefaultStore, error::Error, traits::{StoreReadOps, StoreWriteOps}, - BranchKey, BranchNode, SparseMerkleTree, H256, + BranchNode, SparseMerkleTree, H256, }; #[derive(Debug, Default)] @@ -29,7 +29,7 @@ struct Counters { } impl StoreReadOps for DefaultStoreWithCounters { - fn get_branch(&self, branch_key: &BranchKey) -> Result, Error> { + fn get_branch(&self, branch_key: &H256) -> Result, Error> { self.counters .get_branch_counter .fetch_add(1, Ordering::SeqCst); @@ -44,7 +44,7 @@ impl StoreReadOps for DefaultStoreWithCounters { } impl StoreWriteOps for DefaultStoreWithCounters { - fn insert_branch(&mut self, branch_key: BranchKey, branch: BranchNode) -> Result<(), Error> { + fn insert_branch(&mut self, branch_key: H256, branch: BranchNode) -> Result<(), Error> { self.counters .insert_branch_counter .fetch_add(1, Ordering::SeqCst); @@ -56,7 +56,7 @@ impl StoreWriteOps for DefaultStoreWithCounters { .fetch_add(1, Ordering::SeqCst); self.store.insert_leaf(leaf_key, leaf) } - fn remove_branch(&mut self, branch_key: &BranchKey) -> Result<(), Error> { + fn remove_branch(&mut self, branch_key: &H256) -> Result<(), Error> { self.counters .remove_branch_counter .fetch_add(1, Ordering::SeqCst); @@ -95,6 +95,7 @@ fn random_smt(update_count: usize, rng: &mut impl Rng) { ); } +#[allow(deprecated)] fn random_smt_update_all(update_count: usize, rng: &mut impl Rng) { let mut smt = SMT::default(); let mut kvs = Vec::with_capacity(update_count); diff --git a/proptest-regressions/tests/smt.txt b/proptest-regressions/tests/smt.txt new file mode 100644 index 0000000..c3612a4 --- /dev/null +++ b/proptest-regressions/tests/smt.txt @@ -0,0 +1,7 @@ +# Seeds for failure cases proptest has generated in the past. It is +# automatically read and these particular cases re-run before any +# novel cases are generated. +# +# It is recommended to check this file in to source control so that +# everyone who runs the test benefits from these saved cases. +cc 6fb322c378fb6c8a2dbfb57bb5745424eff7046fd78bf8570d7935585beba82d # shrinks to key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], value = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] diff --git a/proptest-regressions/tests/tree.txt b/proptest-regressions/tests/tree.txt index c06d584..c683e20 100644 --- a/proptest-regressions/tests/tree.txt +++ b/proptest-regressions/tests/tree.txt @@ -11,3 +11,4 @@ cc 2ce7bcdfa66c14e553b2deedb21898a9a9189e6231593450410d5b9218b6947a # shrinks to cc ab275db7575201ad1e0b2f7f451e8acfe9af8512424a870021f4f39ea9bea273 # shrinks to (pairs, _n) = ([(H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110]), H256([0, 0, 0, 0, 0, 13, 201, 127, 12, 192, 143, 123, 190, 37, 17, 100, 63, 164, 208, 167, 243, 52, 122, 47, 182, 52, 234, 246, 179, 166, 246, 144]))], 1), (pairs2, _n2) = ([(H256([204, 74, 0, 146, 96, 195, 233, 44, 167, 38, 29, 40, 7, 186, 111, 207, 228, 143, 63, 245, 155, 193, 150, 181, 105, 174, 191, 244, 62, 3, 207, 109]), H256([93, 221, 131, 89, 167, 18, 128, 73, 41, 200, 163, 54, 240, 94, 38, 153, 8, 214, 182, 255, 74, 142, 159, 225, 79, 144, 11, 192, 124, 65, 67, 102])), (H256([242, 89, 32, 112, 131, 136, 50, 3, 56, 218, 110, 56, 126, 181, 146, 5, 199, 223, 115, 55, 40, 66, 111, 90, 1, 101, 84, 95, 89, 2, 136, 251]), H256([29, 70, 220, 77, 38, 10, 36, 127, 210, 208, 158, 168, 133, 143, 158, 211, 16, 242, 192, 17, 37, 153, 220, 87, 225, 126, 132, 2, 156, 196, 143, 44])), (H256([66, 53, 129, 105, 48, 135, 47, 223, 203, 152, 89, 162, 2, 141, 70, 241, 55, 58, 1, 126, 209, 106, 185, 46, 203, 151, 65, 16, 62, 191, 83, 130]), H256([223, 213, 169, 118, 201, 153, 134, 158, 37, 200, 132, 117, 195, 198, 230, 207, 74, 124, 206, 240, 114, 81, 65, 225, 132, 213, 126, 174, 173, 118, 212, 104])), (H256([31, 14, 190, 4, 99, 34, 86, 235, 51, 84, 18, 128, 59, 185, 180, 116, 216, 179, 224, 140, 205, 212, 179, 211, 172, 102, 243, 60, 223, 115, 50, 0]), H256([34, 8, 245, 65, 65, 116, 157, 61, 132, 192, 212, 80, 9, 15, 47, 89, 138, 187, 225, 252, 59, 147, 239, 43, 86, 156, 250, 127, 159, 89, 158, 127])), (H256([50, 81, 48, 127, 132, 3, 7, 102, 235, 210, 104, 8, 148, 6, 205, 157, 207, 152, 182, 93, 64, 231, 17, 237, 26, 208, 111, 226, 78, 90, 183, 11]), H256([14, 153, 220, 127, 146, 78, 163, 131, 226, 219, 195, 46, 150, 176, 41, 117, 193, 33, 55, 176, 4, 78, 160, 169, 75, 49, 78, 231, 6, 35, 2, 88]))], 2) cc 0d9207ede35b7a90a744133ee2d39d21bff873ecee220a6487a97bd80a3645c2 # shrinks to (pairs, _n) = ([(H256([81, 177, 205, 193, 25, 205, 35, 200, 97, 131, 56, 125, 126, 214, 161, 209, 45, 109, 20, 164, 43, 137, 143, 68, 120, 11, 153, 101, 176, 82, 79, 189]), H256([28, 135, 246, 251, 237, 201, 88, 248, 221, 139, 98, 164, 25, 40, 111, 84, 20, 62, 13, 129, 63, 9, 134, 160, 35, 101, 52, 195, 51, 63, 25, 3])), (H256([13, 31, 140, 221, 242, 98, 128, 212, 147, 117, 231, 12, 35, 62, 129, 209, 163, 219, 73, 194, 153, 102, 89, 238, 198, 177, 75, 15, 21, 24, 74, 133]), H256([120, 35, 10, 62, 49, 227, 251, 224, 16, 177, 123, 122, 220, 30, 109, 177, 19, 218, 67, 201, 141, 124, 104, 234, 157, 66, 153, 216, 76, 103, 246, 47])), (H256([125, 188, 241, 10, 144, 38, 192, 143, 209, 236, 174, 29, 82, 13, 121, 16, 49, 254, 67, 204, 8, 184, 188, 77, 69, 201, 55, 112, 212, 248, 114, 132]), H256([4, 173, 47, 177, 154, 160, 205, 249, 91, 231, 162, 240, 245, 43, 215, 35, 152, 34, 184, 51, 214, 36, 216, 252, 204, 123, 213, 61, 34, 156, 209, 181])), (H256([209, 210, 196, 56, 99, 7, 51, 147, 217, 72, 141, 243, 80, 221, 101, 157, 105, 97, 108, 135, 39, 125, 67, 62, 135, 121, 167, 69, 73, 19, 134, 114]), H256([191, 103, 214, 58, 255, 236, 27, 251, 54, 24, 173, 164, 122, 140, 61, 239, 185, 91, 221, 178, 198, 55, 189, 9, 196, 219, 16, 29, 62, 133, 95, 10]))], 1), (pairs2, _n2) = ([(H256([170, 219, 4, 148, 78, 252, 96, 210, 24, 142, 64, 139, 150, 134, 200, 137, 150, 45, 2, 241, 199, 86, 17, 142, 238, 5, 233, 217, 203, 13, 173, 31]), H256([45, 221, 65, 118, 79, 65, 191, 96, 182, 195, 226, 79, 195, 187, 140, 83, 33, 242, 252, 173, 205, 60, 98, 249, 126, 126, 18, 186, 115, 121, 73, 251])), (H256([117, 133, 199, 179, 128, 129, 96, 180, 188, 200, 198, 125, 241, 91, 79, 140, 92, 14, 158, 208, 29, 172, 123, 183, 204, 242, 51, 102, 233, 216, 241, 236]), H256([249, 56, 170, 3, 60, 92, 162, 75, 191, 20, 119, 82, 137, 174, 208, 243, 247, 52, 38, 193, 145, 134, 83, 48, 254, 137, 111, 172, 137, 239, 130, 180])), (H256([212, 152, 131, 201, 252, 104, 190, 145, 2, 245, 10, 23, 168, 93, 34, 35, 56, 9, 78, 45, 148, 203, 221, 132, 217, 20, 52, 172, 158, 115, 240, 132]), H256([102, 11, 230, 73, 184, 37, 32, 188, 165, 58, 51, 125, 122, 143, 190, 169, 166, 77, 96, 21, 15, 220, 205, 139, 53, 11, 219, 249, 200, 56, 66, 242])), (H256([197, 191, 104, 120, 153, 73, 102, 134, 109, 87, 71, 155, 231, 219, 200, 253, 255, 161, 185, 68, 138, 104, 8, 60, 125, 5, 213, 106, 137, 164, 103, 230]), H256([81, 32, 173, 55, 59, 158, 38, 252, 64, 220, 24, 184, 100, 249, 58, 7, 22, 164, 72, 31, 154, 189, 168, 75, 40, 117, 191, 52, 125, 82, 13, 208])), (H256([121, 98, 128, 132, 198, 101, 244, 156, 165, 57, 116, 97, 4, 92, 181, 96, 121, 99, 74, 152, 58, 45, 139, 63, 41, 6, 210, 200, 74, 85, 227, 244]), H256([121, 212, 121, 63, 74, 95, 90, 133, 106, 172, 130, 226, 117, 168, 62, 237, 191, 184, 146, 193, 109, 217, 244, 57, 190, 94, 2, 84, 206, 163, 18, 113]))], 2) cc 98ff489f3b7556e2d46b0a23b056b2fa89ae1d1f7a312ebcf8637f7d3425c00f # shrinks to (pairs, n) = ([(H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 206, 24, 134, 132]), H256([147, 108, 192, 109, 74, 230, 227, 79, 212, 17, 222, 190, 49, 214, 183, 12, 216, 162, 191, 151, 231, 218, 145, 178, 5, 77, 89, 48, 98, 46, 178, 58])), (H256([115, 249, 148, 158, 42, 219, 157, 50, 51, 111, 29, 79, 167, 253, 105, 127, 233, 37, 25, 51, 245, 73, 183, 61, 39, 216, 39, 108, 13, 141, 79, 135]), H256([89, 230, 227, 207, 80, 18, 69, 197, 35, 126, 16, 251, 93, 229, 247, 101, 39, 255, 98, 153, 40, 250, 35, 129, 39, 224, 193, 241, 168, 40, 68, 88]))], 2) +cc 8a54e42479b4b1058c6d99f1b5bd00e3c3fa91c8221913ad0c383c93ea1de7ab # shrinks to (pairs, _n) = ([(H256([113, 85, 231, 60, 226, 216, 216, 190, 115, 158, 194, 69, 23, 203, 212, 104, 155, 170, 17, 7, 187, 8, 178, 156, 102, 155, 151, 201, 206, 208, 85, 231]), H256([139, 81, 229, 184, 15, 83, 238, 69, 65, 217, 72, 205, 200, 178, 227, 84, 112, 69, 25, 236, 91, 178, 208, 204, 31, 66, 137, 66, 54, 97, 183, 198])), (H256([239, 188, 74, 208, 72, 230, 69, 151, 61, 255, 250, 217, 99, 69, 133, 190, 220, 99, 204, 95, 63, 112, 217, 209, 116, 131, 112, 220, 9, 147, 255, 2]), H256([8, 210, 39, 14, 197, 64, 233, 93, 7, 72, 32, 191, 182, 156, 143, 205, 170, 156, 195, 178, 134, 210, 68, 222, 211, 43, 232, 194, 146, 150, 153, 115])), (H256([244, 84, 79, 36, 91, 197, 69, 81, 39, 50, 36, 10, 61, 70, 80, 214, 66, 169, 230, 29, 240, 233, 224, 118, 156, 51, 69, 169, 197, 226, 65, 127]), H256([156, 179, 215, 13, 129, 12, 73, 32, 75, 124, 86, 16, 70, 101, 51, 155, 241, 160, 49, 72, 83, 37, 161, 221, 197, 138, 71, 38, 173, 66, 14, 211])), (H256([44, 140, 170, 179, 61, 31, 94, 68, 27, 197, 244, 20, 43, 152, 172, 128, 37, 52, 233, 114, 239, 207, 135, 5, 176, 89, 247, 241, 14, 154, 16, 212]), H256([143, 253, 51, 224, 84, 164, 201, 116, 178, 77, 131, 19, 131, 76, 103, 80, 150, 195, 233, 116, 223, 124, 205, 225, 111, 102, 138, 96, 72, 42, 187, 9])), (H256([146, 244, 109, 156, 186, 30, 49, 131, 225, 166, 68, 42, 47, 20, 142, 163, 56, 96, 177, 141, 175, 254, 172, 26, 146, 199, 218, 67, 59, 39, 191, 22]), H256([48, 238, 113, 82, 83, 182, 50, 12, 188, 12, 140, 60, 17, 184, 104, 60, 63, 57, 228, 7, 183, 169, 16, 209, 145, 48, 194, 79, 160, 200, 227, 91])), (H256([177, 167, 201, 39, 216, 213, 102, 48, 80, 108, 172, 16, 50, 232, 17, 35, 206, 18, 0, 82, 119, 196, 158, 155, 167, 49, 99, 196, 13, 220, 203, 221]), H256([247, 63, 212, 135, 102, 137, 105, 1, 98, 218, 105, 252, 208, 79, 187, 205, 170, 210, 113, 87, 34, 230, 249, 154, 58, 98, 61, 153, 44, 113, 20, 98])), (H256([2, 162, 213, 193, 193, 88, 186, 133, 79, 88, 37, 194, 196, 87, 57, 241, 20, 149, 248, 171, 177, 180, 144, 210, 68, 60, 255, 106, 52, 9, 245, 14]), H256([92, 39, 247, 201, 244, 171, 52, 79, 90, 2, 111, 0, 97, 157, 203, 68, 93, 54, 142, 105, 248, 55, 166, 46, 134, 182, 214, 235, 160, 20, 127, 225])), (H256([213, 99, 171, 178, 16, 37, 38, 42, 253, 136, 193, 181, 19, 21, 9, 231, 243, 117, 135, 95, 184, 238, 81, 217, 134, 54, 62, 58, 36, 211, 211, 198]), H256([195, 152, 146, 186, 234, 86, 105, 111, 108, 46, 1, 7, 20, 217, 202, 203, 83, 40, 25, 65, 226, 42, 53, 45, 33, 195, 163, 173, 114, 190, 67, 241])), (H256([81, 65, 175, 64, 168, 162, 249, 9, 93, 71, 247, 78, 146, 189, 48, 1, 101, 7, 208, 4, 230, 197, 165, 86, 90, 178, 83, 24, 100, 127, 190, 214]), H256([226, 92, 234, 230, 107, 154, 70, 80, 79, 38, 87, 248, 101, 252, 218, 56, 56, 57, 192, 176, 63, 161, 235, 200, 160, 206, 253, 237, 202, 26, 23, 78])), (H256([115, 42, 251, 21, 10, 129, 204, 237, 248, 146, 248, 82, 88, 250, 90, 110, 18, 238, 70, 141, 5, 162, 157, 180, 81, 241, 174, 138, 236, 220, 168, 207]), H256([127, 151, 71, 70, 116, 7, 82, 136, 77, 33, 25, 5, 110, 240, 190, 145, 224, 65, 213, 202, 166, 186, 227, 86, 65, 173, 215, 224, 55, 163, 232, 132])), (H256([228, 48, 3, 136, 153, 251, 69, 198, 255, 60, 97, 198, 32, 17, 114, 3, 138, 96, 146, 111, 234, 179, 172, 33, 146, 5, 26, 136, 178, 90, 100, 86]), H256([83, 110, 3, 250, 248, 169, 119, 86, 27, 184, 191, 220, 184, 100, 111, 66, 175, 86, 65, 183, 29, 27, 109, 46, 235, 73, 21, 223, 128, 129, 132, 108])), (H256([2, 39, 34, 43, 204, 94, 120, 55, 17, 46, 28, 181, 40, 224, 66, 117, 195, 129, 229, 134, 49, 250, 179, 28, 250, 2, 205, 202, 37, 203, 236, 108]), H256([111, 156, 57, 253, 133, 2, 21, 34, 64, 237, 227, 170, 97, 234, 222, 97, 109, 167, 79, 206, 201, 198, 131, 240, 179, 201, 196, 120, 38, 242, 9, 48])), (H256([1, 64, 121, 90, 191, 203, 217, 90, 9, 66, 197, 199, 143, 214, 130, 93, 15, 2, 210, 11, 161, 84, 41, 56, 104, 131, 184, 29, 119, 208, 114, 157]), H256([144, 145, 98, 224, 124, 86, 55, 108, 193, 103, 111, 90, 221, 39, 43, 179, 92, 110, 84, 154, 130, 12, 125, 135, 40, 27, 39, 252, 33, 7, 35, 62])), (H256([244, 90, 72, 32, 243, 182, 101, 249, 135, 38, 75, 239, 234, 23, 63, 215, 179, 139, 52, 159, 22, 233, 172, 51, 29, 100, 166, 103, 86, 221, 41, 30]), H256([37, 57, 176, 170, 37, 48, 22, 31, 187, 26, 108, 13, 197, 210, 245, 75, 190, 100, 114, 202, 35, 140, 224, 199, 222, 233, 69, 165, 189, 153, 80, 200])), (H256([131, 29, 237, 29, 72, 82, 100, 136, 11, 196, 166, 29, 75, 151, 15, 172, 46, 55, 76, 82, 235, 218, 215, 203, 156, 201, 89, 156, 88, 55, 204, 160]), H256([135, 205, 60, 123, 17, 19, 182, 80, 173, 51, 237, 204, 78, 114, 217, 215, 85, 74, 196, 0, 142, 114, 235, 224, 235, 151, 181, 182, 240, 26, 137, 19])), (H256([17, 204, 189, 127, 191, 254, 251, 53, 212, 183, 155, 175, 11, 60, 4, 152, 133, 177, 162, 226, 46, 191, 3, 100, 234, 20, 96, 19, 144, 199, 40, 145]), H256([27, 223, 175, 197, 254, 86, 83, 50, 80, 4, 53, 151, 178, 141, 28, 190, 5, 115, 48, 126, 84, 56, 28, 137, 44, 40, 101, 126, 14, 85, 199, 29])), (H256([227, 244, 170, 145, 189, 254, 60, 195, 23, 85, 59, 142, 228, 236, 114, 161, 21, 72, 131, 224, 255, 250, 115, 202, 148, 156, 253, 199, 42, 175, 187, 219]), H256([82, 189, 244, 67, 180, 12, 142, 142, 65, 52, 103, 147, 172, 128, 100, 221, 122, 18, 88, 54, 184, 200, 57, 28, 243, 149, 47, 86, 228, 112, 132, 208])), (H256([69, 251, 197, 5, 38, 197, 188, 96, 242, 129, 254, 201, 96, 220, 91, 138, 137, 222, 33, 179, 131, 119, 155, 6, 146, 35, 202, 164, 182, 50, 153, 87]), H256([226, 20, 28, 137, 46, 45, 130, 212, 129, 160, 147, 128, 60, 192, 196, 113, 83, 165, 242, 52, 142, 246, 9, 59, 122, 30, 181, 217, 96, 194, 233, 215])), (H256([236, 197, 20, 247, 249, 207, 4, 253, 219, 225, 1, 222, 174, 183, 60, 79, 101, 62, 100, 181, 95, 10, 84, 33, 255, 116, 80, 109, 139, 28, 19, 216]), H256([90, 179, 108, 4, 30, 175, 200, 228, 67, 100, 7, 147, 110, 229, 235, 100, 29, 200, 18, 8, 209, 157, 74, 198, 217, 0, 186, 168, 89, 254, 159, 148])), (H256([192, 6, 203, 206, 147, 169, 151, 7, 189, 217, 48, 123, 138, 126, 141, 145, 133, 161, 9, 184, 175, 232, 243, 23, 206, 72, 3, 207, 74, 198, 179, 214]), H256([44, 53, 255, 180, 212, 139, 187, 206, 81, 50, 200, 246, 6, 141, 61, 170, 22, 219, 234, 166, 61, 24, 167, 219, 27, 143, 173, 177, 155, 166, 204, 112])), (H256([35, 205, 104, 159, 39, 201, 208, 55, 137, 36, 121, 181, 24, 251, 83, 115, 154, 252, 139, 173, 157, 169, 28, 243, 171, 69, 146, 229, 137, 171, 104, 103]), H256([14, 211, 185, 62, 38, 155, 114, 134, 120, 12, 159, 0, 48, 179, 61, 7, 135, 163, 151, 222, 132, 71, 216, 247, 230, 86, 227, 204, 22, 112, 6, 215])), (H256([42, 141, 76, 168, 189, 40, 244, 225, 46, 9, 127, 42, 204, 240, 108, 17, 166, 107, 87, 2, 65, 34, 214, 182, 23, 81, 153, 98, 231, 147, 209, 254]), H256([212, 222, 215, 248, 195, 50, 189, 216, 237, 136, 89, 55, 35, 17, 152, 222, 3, 77, 118, 80, 240, 151, 33, 80, 164, 131, 101, 125, 12, 135, 93, 134])), (H256([232, 103, 113, 253, 96, 143, 138, 217, 16, 23, 142, 214, 34, 17, 20, 163, 53, 1, 113, 57, 146, 20, 60, 149, 41, 8, 104, 100, 163, 2, 24, 209]), H256([94, 37, 226, 44, 7, 175, 126, 158, 255, 157, 135, 209, 75, 9, 24, 109, 200, 22, 201, 149, 78, 171, 41, 20, 59, 156, 178, 125, 128, 87, 96, 234])), (H256([160, 131, 234, 217, 89, 106, 86, 55, 59, 85, 69, 198, 28, 83, 160, 164, 41, 79, 65, 215, 32, 148, 104, 158, 138, 124, 15, 246, 119, 127, 236, 29]), H256([17, 99, 29, 210, 35, 30, 246, 19, 254, 173, 246, 191, 253, 199, 195, 102, 118, 113, 177, 215, 81, 186, 122, 133, 64, 141, 24, 150, 42, 5, 75, 230])), (H256([76, 177, 146, 177, 149, 239, 205, 110, 153, 92, 61, 155, 201, 79, 120, 60, 99, 33, 37, 33, 15, 79, 61, 242, 156, 196, 171, 240, 71, 104, 198, 138]), H256([124, 185, 126, 93, 187, 235, 251, 85, 172, 76, 227, 100, 82, 208, 38, 20, 238, 240, 210, 149, 7, 85, 215, 133, 104, 201, 18, 170, 218, 111, 200, 72])), (H256([117, 232, 218, 196, 120, 97, 233, 29, 16, 166, 204, 14, 204, 135, 70, 122, 0, 20, 53, 123, 189, 139, 202, 9, 222, 2, 102, 136, 255, 53, 235, 58]), H256([234, 111, 181, 48, 253, 90, 205, 116, 89, 122, 111, 17, 40, 144, 15, 249, 44, 183, 95, 133, 210, 123, 226, 251, 240, 174, 114, 67, 189, 28, 130, 105]))], 12) diff --git a/src/default_store.rs b/src/default_store.rs index aede806..319d405 100644 --- a/src/default_store.rs +++ b/src/default_store.rs @@ -2,53 +2,64 @@ use crate::{ collections, error::Error, traits::{StoreReadOps, StoreWriteOps}, - tree::{BranchKey, BranchNode}, + tree::BranchNode, H256, }; -#[derive(Debug, Clone, Default)] +const DEFAULT_CAPACITY: usize = 256; + +#[derive(Debug, Clone)] pub struct DefaultStore { - branches_map: Map, - leaves_map: Map, + nodes: Map, + leaves: Map, +} + +impl Default for DefaultStore { + fn default() -> Self { + Self { + nodes: Map::with_capacity(DEFAULT_CAPACITY), + leaves: Map::with_capacity(DEFAULT_CAPACITY), + } + } } impl DefaultStore { - pub fn branches_map(&self) -> &Map { - &self.branches_map + pub fn branches_map(&self) -> &Map { + &self.nodes } pub fn leaves_map(&self) -> &Map { - &self.leaves_map + &self.leaves } pub fn clear(&mut self) { - self.branches_map.clear(); - self.leaves_map.clear(); + self.nodes.clear(); + self.leaves.clear(); } } impl StoreReadOps for DefaultStore { - fn get_branch(&self, branch_key: &BranchKey) -> Result, Error> { - Ok(self.branches_map.get(branch_key).map(Clone::clone)) + fn get_branch(&self, key: &H256) -> Result, Error> { + Ok(self.nodes.get(key).map(Clone::clone)) } - fn get_leaf(&self, leaf_key: &H256) -> Result, Error> { - Ok(self.leaves_map.get(leaf_key).map(Clone::clone)) + fn get_leaf(&self, key: &H256) -> Result, Error> { + Ok(self.leaves.get(key).map(Clone::clone)) } } impl StoreWriteOps for DefaultStore { - fn insert_branch(&mut self, branch_key: BranchKey, branch: BranchNode) -> Result<(), Error> { - self.branches_map.insert(branch_key, branch); + fn insert_branch(&mut self, key: H256, branch: BranchNode) -> Result<(), Error> { + self.nodes.insert(key, branch); Ok(()) } - fn insert_leaf(&mut self, leaf_key: H256, leaf: V) -> Result<(), Error> { - self.leaves_map.insert(leaf_key, leaf); + fn insert_leaf(&mut self, key: H256, leaf: V) -> Result<(), Error> { + self.leaves.insert(key, leaf); Ok(()) } - fn remove_branch(&mut self, branch_key: &BranchKey) -> Result<(), Error> { - self.branches_map.remove(branch_key); + fn remove_branch(&mut self, key: &H256) -> Result<(), Error> { + self.nodes.remove(key); Ok(()) } - fn remove_leaf(&mut self, leaf_key: &H256) -> Result<(), Error> { - self.leaves_map.remove(leaf_key); + fn remove_leaf(&mut self, key: &H256) -> Result<(), Error> { + self.leaves.remove(key); Ok(()) } } diff --git a/src/h256.rs b/src/h256.rs index cbf7c70..903fab6 100644 --- a/src/h256.rs +++ b/src/h256.rs @@ -28,7 +28,7 @@ impl H256 { pub fn set_bit(&mut self, i: u8) { let byte_pos = i / BYTE_SIZE; let bit_pos = i % BYTE_SIZE; - self.0[byte_pos as usize] |= 1 << bit_pos as u8; + self.0[byte_pos as usize] |= 1 << bit_pos; } #[inline] diff --git a/src/lib.rs b/src/lib.rs index 2b879d1..545dab1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,18 +73,13 @@ pub mod merkle_proof; mod tests; pub mod traits; mod tree; -#[cfg(feature = "trie")] -mod trie_tree; #[cfg(feature = "smtc")] pub use ckb_smt::{SMTBuilder, SMT}; pub use h256::H256; pub use merkle_proof::{CompiledMerkleProof, MerkleProof}; -#[cfg(not(feature = "trie"))] +pub use tree::BranchNode; pub use tree::SparseMerkleTree; -pub use tree::{BranchKey, BranchNode}; -#[cfg(feature = "trie")] -pub use trie_tree::SparseMerkleTree; /// Expected path size: log2(256) * 2, used for hint vector capacity pub const EXPECTED_PATH_SIZE: usize = 16; diff --git a/src/merge.rs b/src/merge.rs index cb9da9d..a8afb65 100644 --- a/src/merge.rs +++ b/src/merge.rs @@ -11,12 +11,7 @@ pub enum MergeValue { base_node: H256, zero_bits: H256, zero_count: u8, - }, - #[cfg(feature = "trie")] - ShortCut { - key: H256, value: H256, - height: u8, }, } @@ -33,25 +28,22 @@ impl MergeValue { match self { MergeValue::Value(v) => v.is_zero(), MergeValue::MergeWithZero { .. } => false, - #[cfg(feature = "trie")] - MergeValue::ShortCut { .. } => false, } } - #[cfg(feature = "trie")] - pub fn shortcut_or_value(key: H256, value: H256, height: u8) -> Self { - if height == 0 || value.is_zero() { - MergeValue::Value(value) - } else { - MergeValue::ShortCut { key, value, height } + pub fn dec_zero(&mut self, height: u8) { + if let MergeValue::MergeWithZero { + base_node: _, + zero_bits, + zero_count, + value: _, + } = self + { + zero_bits.clear_bit(height); + *zero_count -= 1; } } - #[cfg(feature = "trie")] - pub fn is_shortcut(&self) -> bool { - matches!(self, MergeValue::ShortCut { .. }) - } - pub fn hash(&self) -> H256 { match self { MergeValue::Value(v) => *v, @@ -59,6 +51,7 @@ impl MergeValue { base_node, zero_bits, zero_count, + value: _, } => { let mut hasher = H::default(); hasher.write_byte(MERGE_ZEROS); @@ -67,34 +60,6 @@ impl MergeValue { hasher.write_byte(*zero_count); hasher.finish() } - #[cfg(feature = "trie")] - MergeValue::ShortCut { key, value, height } => { - into_merge_value::(*key, *value, *height).hash::() - } - } - } -} - -/// Helper function for Shortcut node -/// Transform it into a MergeValue or MergeWithZero node -#[cfg(feature = "trie")] -pub fn into_merge_value(key: H256, value: H256, height: u8) -> MergeValue { - // try keep hash same with MergeWithZero - if value.is_zero() || height == 0 { - MergeValue::from_h256(value) - } else { - let base_key = key.parent_path(0); - let base_node = hash_base_node::(0, &base_key, &value); - let mut zero_bits = key; - for i in height..=core::u8::MAX { - if key.get_bit(i) { - zero_bits.clear_bit(i); - } - } - MergeValue::MergeWithZero { - base_node, - zero_bits, - zero_count: height, } } } @@ -139,6 +104,33 @@ pub fn merge( MergeValue::Value(hasher.finish()) } +/// Merge two hash with node information +/// this function optimized for ZERO_HASH +/// if lhs and rhs both are ZERO_HASH return ZERO_HASH, otherwise hash all info. +pub fn _merge( + height: u8, + node_key: &H256, + lhs: &MergeValue, + rhs: &MergeValue, +) -> MergeValue { + if lhs.is_zero() && rhs.is_zero() { + return MergeValue::zero(); + } + if lhs.is_zero() { + return merge_with_zero::(height, node_key, rhs, true); + } + if rhs.is_zero() { + return merge_with_zero::(height, node_key, lhs, false); + } + let mut hasher = H::default(); + hasher.write_byte(MERGE_NORMAL); + hasher.write_byte(height); + hasher.write_h256(node_key); + hasher.write_h256(&lhs.hash::()); + hasher.write_h256(&rhs.hash::()); + MergeValue::Value(hasher.finish()) +} + pub fn merge_with_zero( height: u8, node_key: &H256, @@ -156,12 +148,14 @@ pub fn merge_with_zero( base_node, zero_bits, zero_count: 1, + value: *v, } } MergeValue::MergeWithZero { base_node, zero_bits, zero_count, + value, } => { let mut zero_bits = *zero_bits; if set_bit { @@ -171,25 +165,58 @@ pub fn merge_with_zero( base_node: *base_node, zero_bits, zero_count: zero_count.wrapping_add(1), + value: *value, } } - #[cfg(feature = "trie")] - MergeValue::ShortCut { key, value, .. } => { - if height == core::u8::MAX { - let base_key = key.parent_path(0); - let base_node = hash_base_node::(0, &base_key, value); - MergeValue::MergeWithZero { - base_node, - zero_bits: *key, - zero_count: 0, + } +} + +/// Merge node with zeros +pub fn merge_with_zeros( + key: H256, + value: MergeValue, + target_height: u8, + zeros: u8, +) -> MergeValue { + if target_height == 0 || zeros == 0 || value.is_zero() { + return value; + } + let base_height = target_height - zeros; + match value { + MergeValue::Value(value) => { + let base_key = key.parent_path(base_height); + let base_node = hash_base_node::(base_height, &base_key, &value); + let mut zero_bits = H256::zero(); + for i in base_height..target_height { + if key.get_bit(i) { + zero_bits.set_bit(i); } - } else { - MergeValue::ShortCut { - key: *key, - value: *value, - height: height + 1, + } + MergeValue::MergeWithZero { + base_node, + zero_bits, + zero_count: zeros, + value, + } + } + MergeValue::MergeWithZero { + base_node, + zero_bits, + zero_count, + value, + } => { + let mut zero_bits = zero_bits; + for i in base_height..target_height { + if key.get_bit(i) { + zero_bits.set_bit(i); } } + MergeValue::MergeWithZero { + base_node, + zero_bits, + zero_count: zero_count.wrapping_add(zeros), + value, + } } } } diff --git a/src/merkle_proof.rs b/src/merkle_proof.rs index 3a9bb3c..e5e97e0 100644 --- a/src/merkle_proof.rs +++ b/src/merkle_proof.rs @@ -98,14 +98,13 @@ impl MerkleProof { base_node, zero_bits, zero_count, + value: _, } => { let mut buffer = crate::vec![*zero_count]; buffer.extend_from_slice(base_node.as_slice()); buffer.extend_from_slice(zero_bits.as_slice()); (Some(0x51), Some(buffer)) } - #[cfg(feature = "trie")] - _ => unreachable!(), } } else { zero_count += 1; @@ -293,6 +292,7 @@ impl CompiledMerkleProof { base_node, zero_bits, zero_count, + value: H256::zero(), }; let (height_u16, key, value) = stack.pop().unwrap(); if height_u16 > 255 { @@ -496,6 +496,7 @@ impl CompiledMerkleProof { base_node, zero_bits, zero_count, + value: _, } => { sub_proof.push(0x51); sub_proof.push(*zero_count); @@ -503,8 +504,6 @@ impl CompiledMerkleProof { sub_proof.extend(zero_bits.as_slice()); is_last_merge_zero = false; } - #[cfg(feature = "trie")] - _ => {} }; } } diff --git a/src/tests/fixtures.rs b/src/tests/fixtures.rs index 68d663c..5a37fd9 100644 --- a/src/tests/fixtures.rs +++ b/src/tests/fixtures.rs @@ -25,6 +25,7 @@ struct Case { proofs: Vec, } +#[allow(clippy::upper_case_acronyms)] type SMT = SparseMerkleTree>; fn new_smt(pairs: Vec<(H256, H256)>) -> SMT { @@ -109,7 +110,7 @@ fn test_gen_fixtures() { fn run_test_case(case: Case) -> Result<()> { let Case { - name: _name, + name, leaves, root, proofs, @@ -120,7 +121,7 @@ fn run_test_case(case: Case) -> Result<()> { .map(|(k, v)| ((*k).into(), (*v).into())) .collect(), ); - assert_eq!(smt.root(), &root.into(), "root"); + assert_eq!(smt.root(), &root.into(), "unexpected root in {}", name); for proof in proofs { let Proof { diff --git a/src/tests/history.rs b/src/tests/history.rs new file mode 100644 index 0000000..fd402a3 --- /dev/null +++ b/src/tests/history.rs @@ -0,0 +1,50 @@ +use crate::{blake2b::Blake2bHasher, default_store::DefaultStore, tests::utils::SMT, H256}; + +#[test] +fn test_access_history() { + fn to_h256(n: u8) -> H256 { + [n; 32].into() + } + + fn update_batch(tree: &mut SMT, kvs: Vec<(u8, u8)>) -> H256 { + for (k, v) in kvs { + tree.update(to_h256(k), to_h256(v)).expect("update"); + } + *tree.root() + } + + fn check_batch(store: DefaultStore, root: H256, kvs: Vec<(u8, u8)>) { + let tree = SMT::new(root, store); + for (i, (k, v)) in kvs.into_iter().enumerate() { + assert_eq!(tree.get(&to_h256(k)).expect("key"), to_h256(v)); + // check merkle proof + let proof = tree.merkle_proof(vec![to_h256(k)]).expect("proof"); + let valid = proof + .verify::(&root, vec![(to_h256(k), to_h256(v))]) + .expect("verify"); + assert!(valid, "key {}", i); + } + } + + let v1 = vec![(1, 1), (2, 2), (3, 3)]; + let v2 = vec![(1, 2), (3, 0)]; + let v3 = vec![(4, 5), (1, 0), (2, 0)]; + + let mut tree = SMT::default(); + // insert v1..v3 kvs + let v1_root = update_batch(&mut tree, v1.clone()); + let v2_root = update_batch(&mut tree, v2.clone()); + let v3_root = update_batch(&mut tree, v3.clone()); + + // test v1..v3 kvs + let store = tree.take_store(); + // v1 + check_batch(store.clone(), v1_root, v1); + check_batch(store.clone(), v1_root, vec![(4, 0), (5, 0)]); + // v2 + check_batch(store.clone(), v2_root, v2); + check_batch(store.clone(), v2_root, vec![(2, 2), (4, 0), (5, 0)]); + // v3 + check_batch(store.clone(), v3_root, v3); + check_batch(store, v3_root, vec![(3, 0), (5, 0)]); +} diff --git a/src/tests/mod.rs b/src/tests/mod.rs index e7c70e6..6b9537e 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,4 +1,6 @@ // FIXME: fix fixtures tests later mod fixtures; +mod history; mod smt; mod tree; +mod utils; diff --git a/src/tests/tree.rs b/src/tests/tree.rs index ed9efac..beb9008 100644 --- a/src/tests/tree.rs +++ b/src/tests/tree.rs @@ -1,15 +1,10 @@ -use crate::*; -use crate::{ - blake2b::Blake2bHasher, default_store::DefaultStore, error::Error, merge::MergeValue, - MerkleProof, -}; +use crate::tests::utils::*; +use crate::{blake2b::Blake2bHasher, error::Error, MerkleProof}; +use crate::{CompiledMerkleProof, H256}; use proptest::prelude::*; use rand::prelude::{Rng, SliceRandom}; use std::collections::HashMap; -#[allow(clippy::upper_case_acronyms)] -type SMT = SparseMerkleTree>; - #[test] fn test_default_root() { let mut tree = SMT::default(); @@ -118,41 +113,6 @@ fn test_zero_value_donot_change_root() { assert_eq!(tree.store().branches_map().len(), 0); } -#[test] -fn test_zero_value_donot_change_store() { - let mut tree = SMT::default(); - let key = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, - ] - .into(); - let value = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, - ] - .into(); - tree.update(key, value).unwrap(); - assert_ne!(tree.root(), &H256::zero()); - let root = *tree.root(); - let store = tree.store().clone(); - - // insert a zero value leaf - let key = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, - ] - .into(); - let value = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, - ] - .into(); - tree.update(key, value).unwrap(); - assert_eq!(tree.root(), &root); - assert_eq!(tree.store().leaves_map(), store.leaves_map()); - assert_eq!(tree.store().branches_map(), store.branches_map()); -} - #[test] fn test_delete_a_leaf() { let mut tree = SMT::default(); @@ -198,7 +158,7 @@ fn test_delete_a_leaf() { tree.update(key, H256::zero()).unwrap(); assert_eq!(tree.root(), &root); assert_eq!(tree.store().leaves_map(), store.leaves_map()); - assert_eq!(tree.store().branches_map(), store.branches_map()); + // assert_eq!(tree.store().branches_map(), store.branches_map()); } #[test] @@ -264,20 +224,6 @@ fn test_update(key: H256, value: H256) { assert_eq!(tree.get(&key), Ok(value)); } -#[cfg(not(feature = "trie"))] -fn test_update_tree_store(key: H256, value: H256, value2: H256) { - const EXPECTED_LEAVES_LEN: usize = 1; - - let mut tree = SMT::default(); - tree.update(key, value).expect("update"); - assert_eq!(tree.store().branches_map().len(), 256); - assert_eq!(tree.store().leaves_map().len(), EXPECTED_LEAVES_LEN); - tree.update(key, value2).expect("update"); - assert_eq!(tree.store().branches_map().len(), 256); - assert_eq!(tree.store().leaves_map().len(), EXPECTED_LEAVES_LEN); - assert_eq!(tree.get(&key), Ok(value2)); -} - fn test_merkle_proof(key: H256, value: H256) { const EXPECTED_MERKLE_PATH_SIZE: usize = 1; @@ -303,54 +249,6 @@ fn test_merkle_proof(key: H256, value: H256) { } } -fn new_smt(pairs: Vec<(H256, H256)>) -> SMT { - let mut smt = SMT::default(); - for (key, value) in pairs { - smt.update(key, value).unwrap(); - } - smt -} - -fn leaves( - min_leaves: usize, - max_leaves: usize, -) -> impl Strategy, usize)> { - prop::collection::vec( - prop::array::uniform2(prop::array::uniform32(0u8..)), - min_leaves..=max_leaves, - ) - .prop_flat_map(|mut pairs| { - pairs.dedup_by_key(|[k, _v]| *k); - let len = pairs.len(); - ( - Just( - pairs - .into_iter() - .map(|[k, v]| (k.into(), v.into())) - .collect(), - ), - core::cmp::min(1, len)..=len, - ) - }) -} - -fn leaves_bitmap(max_leaves_bitmap: usize) -> impl Strategy> { - prop::collection::vec(prop::array::uniform32(0u8..), max_leaves_bitmap).prop_flat_map( - |leaves_bitmap| Just(leaves_bitmap.into_iter().map(|item| item.into()).collect()), - ) -} - -fn merkle_proof(max_proof: usize) -> impl Strategy> { - prop::collection::vec(prop::array::uniform32(0u8..), max_proof).prop_flat_map(|proof| { - Just( - proof - .into_iter() - .map(|item| MergeValue::from_h256(item.into())) - .collect(), - ) - }) -} - proptest! { #[test] fn test_h256(key: [u8; 32], key2: [u8; 32]) { @@ -390,12 +288,6 @@ proptest! { test_update(key.into(), value.into()); } - #[cfg(not(feature = "trie"))] - #[test] - fn test_random_update_tree_store(key: [u8;32], value: [u8;32], value2: [u8;32]) { - test_update_tree_store(key.into(), value.into(), value2.into()); - } - #[test] fn test_random_construct(key: [u8;32], value: [u8;32]) { test_construct(key.into(), value.into()); @@ -510,12 +402,13 @@ proptest! { #[test] fn test_from_store((pairs, _n) in leaves(1, 20)) { - let smt = new_smt(pairs.clone()); - let smt2 = SMT::new_with_store(smt.store().clone()).expect("from store"); + let smt = new_smt(pairs); + let smt2 = SMT::new_with_store(smt.store().clone(), *smt.root()); assert_eq!(smt.root(), smt2.root()); } #[test] + #[allow(deprecated)] fn test_smt_update_all((pairs, _n) in leaves(1, 20), (pairs2, _n2) in leaves(1, 10)){ let mut smt = new_smt(pairs.clone()); for (k, v) in pairs2.clone().into_iter() { @@ -576,14 +469,14 @@ proptest! { } } - #[test] - fn test_zero_value_should_delete_branch((pairs, _n) in leaves(5, 30)){ - let mut smt = new_smt(pairs.clone()); - for (k, _v) in pairs { - smt.update(k, H256::zero()).unwrap(); - } - assert_eq!(0, smt.store().branches_map().len()); - } + // #[test] + // fn test_zero_value_should_delete_branch((pairs, _n) in leaves(5, 30)){ + // let mut smt = new_smt(pairs.clone()); + // for (k, _v) in pairs { + // smt.update(k, H256::zero()).unwrap(); + // } + // assert_eq!(0, smt.store().branches_map().len()); + // } #[test] fn test_smt_not_crash( @@ -716,33 +609,6 @@ fn test_v0_3_broken_sample() { assert_eq!(smt.get(&k1.into()).unwrap(), v1.into()); } -#[test] -fn test_trie_broken_sample() { - let keys = vec![ - "f652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40", - "5eff886ea0ce6ca488a3d6e336d6c0f75f46d19b42c06ce5ee98e42c96d256c7", - "6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df", - ] - .into_iter() - .map(parse_h256); - - let values = vec![ - "0000000000000000000000000000000000000000000000000000000000000001", - "0000000000000000000000000000000000000000000000000000000000000002", - "0000000000000000000000000000000000000000000000000000000000000003", - ] - .into_iter() - .map(parse_h256); - - let mut pairs = keys.zip(values).collect::>(); - let smt = new_smt(pairs.clone()); - let base_branches = smt.store().branches_map(); - pairs.reverse(); - let smt = new_smt(pairs.clone()); - let current_branches = smt.store().branches_map(); - assert_eq!(base_branches, current_branches); -} - #[test] fn test_trie_broken_sample_02() { let key1: H256 = [ @@ -791,7 +657,7 @@ fn test_trie_broken_sample_02() { .compute_root::( kv_state .iter() - .map(|(k, v)| (k.clone().into(), v.clone().into())) + .map(|(k, v)| ((*k).into(), (*v).into())) .collect(), ) .unwrap(); @@ -1170,3 +1036,69 @@ fn test_sub_proof( .expect("verify compiled sub proof")); } } + +#[test] +fn test_smt_non_exists_leaves_1() { + let pairs = [ + ( + H256::from([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, + ]), + H256::from([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 144, 63, 125, 212, 94, 72, 47, 214, 185, 222, 42, 12, + 23, 160, 228, 214, 23, 65, 49, 244, 83, 76, 232, + ]), + ), + ( + H256::from([ + 199, 179, 221, 10, 62, 199, 159, 25, 216, 237, 186, 187, 218, 221, 181, 55, 155, + 46, 26, 4, 103, 81, 213, 142, 17, 245, 51, 71, 209, 201, 79, 158, + ]), + H256::from([ + 158, 139, 222, 24, 203, 61, 251, 225, 250, 196, 198, 8, 72, 172, 37, 99, 198, 183, + 76, 53, 111, 133, 136, 121, 145, 68, 38, 46, 48, 222, 4, 20, + ]), + ), + ]; + let pairs2 = [ + ( + H256::from([ + 231, 62, 252, 83, 37, 221, 85, 106, 98, 135, 104, 126, 113, 94, 197, 235, 15, 66, + 144, 102, 110, 43, 130, 142, 34, 52, 179, 102, 114, 251, 248, 200, + ]), + H256::from([ + 58, 129, 32, 148, 197, 28, 118, 209, 223, 210, 173, 187, 241, 214, 229, 63, 232, + 160, 50, 68, 148, 19, 163, 59, 239, 92, 125, 26, 154, 28, 114, 139, + ]), + ), + ( + H256::from([ + 121, 69, 210, 98, 204, 170, 87, 98, 145, 171, 94, 131, 240, 86, 199, 184, 250, 120, + 172, 158, 78, 195, 138, 129, 37, 122, 13, 7, 167, 233, 241, 130, + ]), + H256::from([ + 90, 140, 149, 215, 82, 160, 32, 210, 53, 9, 61, 89, 236, 150, 110, 128, 140, 88, + 134, 81, 238, 112, 205, 221, 230, 70, 141, 242, 147, 170, 42, 206, + ]), + ), + ]; + let smt = new_smt(pairs.to_vec()); + let non_exists_keys: Vec<_> = pairs2.iter().map(|(k, _v)| *k).collect(); + let proof = smt + .merkle_proof(non_exists_keys.clone()) + .expect("gen proof"); + let data: Vec<(H256, H256)> = non_exists_keys.iter().map(|k| (*k, H256::zero())).collect(); + let compiled_proof = proof + .clone() + .compile(non_exists_keys) + .expect("compile proof"); + assert!(proof + .verify::(smt.root(), data.clone()) + .expect("verify proof")); + assert!(compiled_proof + .verify::(smt.root(), data.clone()) + .expect("verify compiled proof")); + + test_sub_proof(&compiled_proof, &smt, &data, 20); +} diff --git a/src/tests/utils.rs b/src/tests/utils.rs new file mode 100644 index 0000000..bba6089 --- /dev/null +++ b/src/tests/utils.rs @@ -0,0 +1,59 @@ +use proptest::{ + prelude::prop, + strategy::{Just, Strategy}, +}; + +use crate::{ + blake2b::Blake2bHasher, default_store::DefaultStore, merge::MergeValue, SparseMerkleTree, H256, +}; + +#[allow(clippy::upper_case_acronyms)] +pub type SMT = SparseMerkleTree>; + +pub fn new_smt(pairs: Vec<(H256, H256)>) -> SMT { + let mut smt = SMT::default(); + for (key, value) in pairs { + smt.update(key, value).unwrap(); + } + smt +} + +pub fn leaves( + min_leaves: usize, + max_leaves: usize, +) -> impl Strategy, usize)> { + prop::collection::vec( + prop::array::uniform2(prop::array::uniform32(0u8..)), + min_leaves..=max_leaves, + ) + .prop_flat_map(|mut pairs| { + pairs.dedup_by_key(|[k, _v]| *k); + let len = pairs.len(); + ( + Just( + pairs + .into_iter() + .map(|[k, v]| (k.into(), v.into())) + .collect(), + ), + core::cmp::min(1, len)..=len, + ) + }) +} + +pub fn leaves_bitmap(max_leaves_bitmap: usize) -> impl Strategy> { + prop::collection::vec(prop::array::uniform32(0u8..), max_leaves_bitmap).prop_flat_map( + |leaves_bitmap| Just(leaves_bitmap.into_iter().map(|item| item.into()).collect()), + ) +} + +pub fn merkle_proof(max_proof: usize) -> impl Strategy> { + prop::collection::vec(prop::array::uniform32(0u8..), max_proof).prop_flat_map(|proof| { + Just( + proof + .into_iter() + .map(|item| MergeValue::from_h256(item.into())) + .collect(), + ) + }) +} diff --git a/src/traits.rs b/src/traits.rs index 1b3b592..6de489c 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,8 +1,4 @@ -use crate::{ - error::Error, - tree::{BranchKey, BranchNode}, - H256, -}; +use crate::{error::Error, tree::BranchNode, H256}; /// Trait for customize hash function pub trait Hasher { @@ -28,13 +24,13 @@ impl Value for H256 { /// Traits for customize backend storage pub trait StoreReadOps { - fn get_branch(&self, branch_key: &BranchKey) -> Result, Error>; + fn get_branch(&self, branch_key: &H256) -> Result, Error>; fn get_leaf(&self, leaf_key: &H256) -> Result, Error>; } pub trait StoreWriteOps { - fn insert_branch(&mut self, node_key: BranchKey, branch: BranchNode) -> Result<(), Error>; + fn insert_branch(&mut self, node_key: H256, branch: BranchNode) -> Result<(), Error>; fn insert_leaf(&mut self, leaf_key: H256, leaf: V) -> Result<(), Error>; - fn remove_branch(&mut self, node_key: &BranchKey) -> Result<(), Error>; + fn remove_branch(&mut self, node_key: &H256) -> Result<(), Error>; fn remove_leaf(&mut self, leaf_key: &H256) -> Result<(), Error>; } diff --git a/src/tree.rs b/src/tree.rs index 2f29f39..0bd8a36 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -1,40 +1,20 @@ use crate::{ - collections::VecDeque, error::{Error, Result}, - merge::{merge, MergeValue}, + merge::{ + // hex_merge_value, + merge, + merge_with_zeros, + MergeValue, + }, merkle_proof::MerkleProof, traits::{Hasher, StoreReadOps, StoreWriteOps, Value}, vec::Vec, H256, MAX_STACK_SIZE, }; -use core::cmp::Ordering; use core::marker::PhantomData; -/// The branch key -#[derive(Debug, Clone, Eq, PartialEq, Hash)] -pub struct BranchKey { - pub height: u8, - pub node_key: H256, -} -impl BranchKey { - pub fn new(height: u8, node_key: H256) -> BranchKey { - BranchKey { height, node_key } - } -} - -impl PartialOrd for BranchKey { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} -impl Ord for BranchKey { - fn cmp(&self, other: &Self) -> Ordering { - match self.height.cmp(&other.height) { - Ordering::Equal => self.node_key.cmp(&other.node_key), - ordering => ordering, - } - } -} +/// Suggested merkle path capacity +const MERKLE_PATH_CAPACITY: usize = 16; /// A branch in the SMT #[derive(Debug, Eq, PartialEq, Clone)] @@ -104,18 +84,8 @@ impl SparseMerkleTree { impl> SparseMerkleTree { /// Build a merkle tree from store, the root will be calculated automatically - pub fn new_with_store(store: S) -> Result> { - let root_branch_key = BranchKey::new(core::u8::MAX, H256::zero()); - store - .get_branch(&root_branch_key) - .map(|branch_node| { - branch_node - .map(|n| { - merge::(core::u8::MAX, &H256::zero(), &n.left, &n.right).hash::() - }) - .unwrap_or_default() - }) - .map(|root| SparseMerkleTree::new(root, store)) + pub fn new_with_store(store: S, root: H256) -> SparseMerkleTree { + SparseMerkleTree::new(root, store) } } @@ -125,146 +95,229 @@ impl + StoreWriteOps> /// Update a leaf, return new merkle root /// set to zero value to delete a key pub fn update(&mut self, key: H256, value: V) -> Result<&H256> { - // compute and store new leaf - let node = MergeValue::from_h256(value.to_h256()); - // notice when value is zero the leaf is deleted, so we do not need to store it - if !node.is_zero() { - self.store.insert_leaf(key, value)?; - } else { - self.store.remove_leaf(&key)?; - } + let is_delete = value.to_h256().is_zero(); - // recompute the tree from bottom to top - let mut current_key = key; - let mut current_node = node; - for height in 0..=core::u8::MAX { - let parent_key = current_key.parent_path(height); - let parent_branch_key = BranchKey::new(height, parent_key); - let (left, right) = - if let Some(parent_branch) = self.store.get_branch(&parent_branch_key)? { - if current_key.is_right(height) { - (parent_branch.left, current_node) - } else { - (current_node, parent_branch.right) - } - } else if current_key.is_right(height) { - (MergeValue::zero(), current_node) - } else { - (current_node, MergeValue::zero()) - }; - - if !left.is_zero() || !right.is_zero() { - // insert or update branch - self.store.insert_branch( - parent_branch_key, - BranchNode { - left: left.clone(), - right: right.clone(), - }, - )?; - } else { - // remove empty branch - self.store.remove_branch(&parent_branch_key)?; - } - // prepare for next round - current_key = parent_key; - current_node = merge::(height, &parent_key, &left, &right); + // search siblings + let MerklePath { + height, + mut merkle_path, + .. + } = self.merkle_path(&key)?; + + // if height isn't 0, there is no leaf in the tree + if height != 0 && is_delete { + return Ok(&self.root); } - self.root = current_node.hash::(); - Ok(&self.root) - } + let mut node = MergeValue::Value(value.to_h256()); + // insert leaf + if !is_delete { + self.store.insert_leaf(node.hash::(), value)?; + } - /// Update multiple leaves at once - pub fn update_all(&mut self, mut leaves: Vec<(H256, V)>) -> Result<&H256> { - // Dedup(only keep the last of each key) and sort leaves - leaves.reverse(); - leaves.sort_by_key(|(a, _)| *a); - leaves.dedup_by_key(|(a, _)| *a); - - let mut nodes = leaves - .into_iter() - .map(|(k, v)| { - let value = MergeValue::from_h256(v.to_h256()); - if !value.is_zero() { - self.store.insert_leaf(k, v) - } else { - self.store.remove_leaf(&k) - } - .map(|_| (k, value, 0)) - }) - .collect::>>()?; - - while let Some((current_key, current_merge_value, height)) = nodes.pop_front() { - let parent_key = current_key.parent_path(height); - let parent_branch_key = BranchKey::new(height, parent_key); - - // Test for neighbors - let mut right = None; - if !current_key.is_right(height) && !nodes.is_empty() { - let (neighbor_key, _, neighbor_height) = nodes.front().expect("nodes is not empty"); - if neighbor_height.eq(&height) { - let mut right_key = current_key; - right_key.set_bit(height); - if neighbor_key.eq(&right_key) { - let (_, neighbor_value, _) = nodes.pop_front().expect("nodes is not empty"); - right = Some(neighbor_value); - } - } + let mut node_height = 0; + // the new leaf becomes descendent + while let Some((height, sibling)) = merkle_path.pop() { + // FIXME allign to fork_height???? + assert!(node_height <= height); + if node_height < height { + node = merge_with_zeros::(key, node, height, height - node_height); + node_height = height; } - let (left, right) = if let Some(right_merge_value) = right { - (current_merge_value, right_merge_value) + let (lhs, rhs) = if key.is_right(height) { + (sibling, node) } else { - // In case neighbor is not available, fetch from store - if let Some(parent_branch) = self.store.get_branch(&parent_branch_key)? { - if current_key.is_right(height) { - (parent_branch.left, current_merge_value) - } else { - (current_merge_value, parent_branch.right) - } - } else if current_key.is_right(height) { - (MergeValue::zero(), current_merge_value) - } else { - (current_merge_value, MergeValue::zero()) - } + (node, sibling) }; + let node_key = key.parent_path(height); + node = merge::(height, &node_key, &lhs, &rhs); - if !left.is_zero() || !right.is_zero() { + let is_merge_with_zero = lhs.is_zero() || rhs.is_zero(); + let next_sibling_is_zero = height != u8::MAX; + if !(is_merge_with_zero && next_sibling_is_zero) { self.store.insert_branch( - parent_branch_key, + node.hash::(), BranchNode { - left: left.clone(), - right: right.clone(), + left: lhs, + right: rhs, }, )?; - } else { - self.store.remove_branch(&parent_branch_key)?; } - if height == core::u8::MAX { - self.root = merge::(height, &parent_key, &left, &right).hash::(); - break; - } else { - nodes.push_back(( - parent_key, - merge::(height, &parent_key, &left, &right), - height + 1, - )); + if height == u8::MAX { + self.root = node.hash::(); + return Ok(&self.root); } + node_height += 1; } + node = merge_with_zeros::(key, node, u8::MAX, u8::MAX - node_height); + let height = u8::MAX; + let node_key = key.parent_path(height); + let (lhs, rhs) = if key.is_right(height) { + (MergeValue::zero(), node) + } else { + (node, MergeValue::zero()) + }; + node = merge::(height, &node_key, &lhs, &rhs); + self.store.insert_branch( + node.hash::(), + BranchNode { + left: lhs, + right: rhs, + }, + )?; + + self.root = node.hash::(); + Ok(&self.root) + } + + /// Update multiple leaves at once + #[deprecated(since = "0.6.1", note = "use update instead")] + pub fn update_all(&mut self, leaves: Vec<(H256, V)>) -> Result<&H256> { + // unimplemented!(); + for (key, value) in leaves { + self.update(key, value)?; + } Ok(&self.root) } } +struct MerklePath { + node: H256, + height: u8, + bitmap: H256, + merkle_path: Vec<(u8, MergeValue)>, +} + impl> SparseMerkleTree { + /// Get merkle path of a key + /// + /// # Arguments + /// - key + /// + /// # Returns + /// - node: internal node of the key + /// - height: height of the node + /// - bitmap: bitmap of the key + /// - merkle_path: merkle path in reverse order + /// + fn merkle_path(&self, key: &H256) -> Result { + let mut merkle_path = Vec::with_capacity(MERKLE_PATH_CAPACITY); + let mut node = self.root; + let mut height = u8::MAX; + + let mut bitmap = H256::zero(); + + if self.is_empty() { + return Ok(MerklePath { + node, + height, + bitmap, + merkle_path, + }); + } + + // search siblings from root + loop { + let branch = self + .store + .get_branch(&node)? + .ok_or(Error::MissingBranch(height, node))?; + // push sibling + let next; + let sibling; + if key.is_right(height) { + next = branch.right.clone(); + sibling = branch.left.clone(); + } else { + next = branch.left.clone(); + sibling = branch.right.clone(); + } + + if !sibling.is_zero() { + bitmap.set_bit(height); + merkle_path.push((height, sibling)); + } + if next.is_zero() { + break; + } + + // goto next + match next { + MergeValue::MergeWithZero { + base_node, + mut zero_bits, + mut zero_count, + value, + } => { + while zero_count > 0 { + zero_count -= 1; + height -= 1; + // if we are on a zero node, go descendent to zero + let descendent_to_zero = zero_bits.is_right(height) != key.is_right(height); + zero_bits.clear_bit(height); + if descendent_to_zero { + bitmap.set_bit(height); + let sibling = if zero_count == 0 { + MergeValue::Value(value) + } else { + MergeValue::MergeWithZero { + base_node, + zero_bits, + zero_count, + value, + } + }; + merkle_path.push((height, sibling)); + // we are at 0 branch, so all siblings from there are zeros + height = 0; + node = H256::zero(); + // skip descendent zeros + return Ok(MerklePath { + node, + height, + bitmap, + merkle_path, + }); + } + } + if height == 0 { + node = value; + break; + } + assert_eq!(zero_count, 0); + node = value; + height -= 1; + } + MergeValue::Value(n) => { + node = n; + if height == 0 { + // found leaf + break; + } + height -= 1; + } + } + } + Ok(MerklePath { + node, + height, + bitmap, + merkle_path, + }) + } + /// Get value of a leaf /// return zero value if leaf not exists pub fn get(&self, key: &H256) -> Result { - if self.is_empty() { - return Ok(V::zero()); + let MerklePath { node, height, .. } = self.merkle_path(key)?; + + if height == 0 { + Ok(self.store.get_leaf(&node)?.unwrap_or(V::zero())) + } else { + Ok(V::zero()) } - Ok(self.store.get_leaf(key)?.unwrap_or_else(V::zero)) } /// Generate merkle proof @@ -273,32 +326,23 @@ impl> SparseMerkleTree = Default::default(); - for current_key in &keys { - let mut bitmap = H256::zero(); - for height in 0..=core::u8::MAX { - let parent_key = current_key.parent_path(height); - let parent_branch_key = BranchKey::new(height, parent_key); - if let Some(parent_branch) = self.store.get_branch(&parent_branch_key)? { - let sibling = if current_key.is_right(height) { - parent_branch.left - } else { - parent_branch.right - }; - if !sibling.is_zero() { - bitmap.set_bit(height); - } - } else { - // The key is not in the tree (support non-inclusion proof) - } - } + let mut leaves_merkle_path: Vec<_> = Default::default(); + for key in &keys { + let MerklePath { + bitmap, + merkle_path, + .. + } = self.merkle_path(key)?; leaves_bitmap.push(bitmap); + leaves_merkle_path.push(merkle_path); } + // Iterate all leaves to compile proof let mut proof: Vec = Default::default(); let mut stack_fork_height = [0u8; MAX_STACK_SIZE]; // store fork height let mut stack_top = 0; @@ -315,28 +359,18 @@ impl> SparseMerkleTree 0 && stack_fork_height[stack_top - 1] == height { stack_top -= 1; - } else if leaves_bitmap[leaf_index].get_bit(height) { - let parent_branch_key = BranchKey::new(height, parent_key); - if let Some(parent_branch) = self.store.get_branch(&parent_branch_key)? { - let sibling = if is_right { - parent_branch.left - } else { - parent_branch.right - }; - if !sibling.is_zero() { - proof.push(sibling); - } else { - unreachable!(); - } - } else { - // The key is not in the tree (support non-inclusion proof) + // pop unused merkle path + if leaves_bitmap[leaf_index].get_bit(height) { + leaves_merkle_path[leaf_index].pop().unwrap(); } + } else if leaves_bitmap[leaf_index].get_bit(height) { + let sibling = leaves_merkle_path[leaf_index].pop().unwrap().1; + assert!(!sibling.is_zero()); + proof.push(sibling); } } debug_assert!(stack_top < MAX_STACK_SIZE); diff --git a/src/trie_tree.rs b/src/trie_tree.rs deleted file mode 100644 index e809120..0000000 --- a/src/trie_tree.rs +++ /dev/null @@ -1,436 +0,0 @@ -use crate::{ - error::{Error, Result}, - merge::{into_merge_value, merge, MergeValue}, - merkle_proof::MerkleProof, - traits::{Hasher, StoreReadOps, StoreWriteOps, Value}, - tree::{BranchKey, BranchNode}, - vec::Vec, - H256, MAX_STACK_SIZE, -}; -use core::marker::PhantomData; - -/// Sparse merkle tree -#[derive(Default, Debug)] -pub struct SparseMerkleTree { - store: S, - root: H256, - phantom: PhantomData<(H, V)>, -} - -impl SparseMerkleTree { - /// Build a merkle tree from root and store - pub fn new(root: H256, store: S) -> SparseMerkleTree { - SparseMerkleTree { - root, - store, - phantom: PhantomData, - } - } - - /// Merkle root - pub fn root(&self) -> &H256 { - &self.root - } - - /// Check empty of the tree - pub fn is_empty(&self) -> bool { - self.root.is_zero() - } - - /// Destroy current tree and retake store - pub fn take_store(self) -> S { - self.store - } - - /// Get backend store - pub fn store(&self) -> &S { - &self.store - } - - /// Get mutable backend store - pub fn store_mut(&mut self) -> &mut S { - &mut self.store - } -} - -impl> SparseMerkleTree { - /// Build a merkle tree from store, the root will be calculated automatically - pub fn new_with_store(store: S) -> Result> { - let root_branch_key = BranchKey::new(core::u8::MAX, H256::zero()); - store - .get_branch(&root_branch_key) - .map(|branch_node| { - branch_node - .map(|n| { - merge::(core::u8::MAX, &H256::zero(), &n.left, &n.right).hash::() - }) - .unwrap_or_default() - }) - .map(|root| SparseMerkleTree::new(root, store)) - } -} - -impl + StoreWriteOps> - SparseMerkleTree -{ - /// Update a leaf, return new merkle root - /// set to zero value to delete a key - pub fn update(&mut self, key: H256, value: V) -> Result<&H256> { - let value_h256 = value.to_h256(); - let is_delete = value_h256.is_zero(); - // notice when value is zero the leaf is deleted, so we do not need to store it - if is_delete { - self.store.remove_leaf(&key)?; - } else { - self.store.insert_leaf(key, value)?; - } - - let mut last_height = core::u8::MAX; - loop { - // walk from top to bottom - let node_key = key.parent_path(last_height); - let branch_key = BranchKey::new(last_height, node_key); // this represents a position in the tree - if let Some(branch) = self.store.get_branch(&branch_key)? { - // if we we found a record in here - // we need to determine whether is it a shortcut - let (target, another) = if key.is_right(last_height) { - (branch.right, branch.left) - } else { - (branch.left, branch.right) - }; - - match target { - MergeValue::ShortCut { - key: this_key, - value, - height: h, - } => { - if this_key.eq(&key) { - // we update its value - if is_delete && another.is_zero() { - self.store.remove_branch(&branch_key)?; - } else { - let target = MergeValue::shortcut_or_value(key, value_h256, h); - let new_branch = if key.is_right(last_height) { - BranchNode { - left: another, - right: target, - } - } else { - BranchNode { - left: target, - right: another, - } - }; - - // update this shortcut's value - self.store.insert_branch(branch_key, new_branch)?; - } - break; - } else if !is_delete { - // we need to move this shortcut down - - // OPTIMIZATION: the shortcut must dropping to the level where [shortcut's new_height + 1] = [insert/delete key's shortcut height + 1] - // check definition of H256.fork_height() - last_height = this_key.fork_height(&key); - - let (next_left, next_right) = if key.is_right(last_height) { - ( - MergeValue::shortcut_or_value(this_key, value, last_height), - MergeValue::shortcut_or_value(key, value_h256, last_height), - ) - } else { - ( - MergeValue::shortcut_or_value(key, value_h256, last_height), - MergeValue::shortcut_or_value(this_key, value, last_height), - ) - }; - - let next_branch_key = - BranchKey::new(last_height, this_key.parent_path(last_height)); - - self.store.insert_branch( - next_branch_key, - BranchNode { - left: next_left, - right: next_right, - }, - )?; - break; // go next round - } else { - // zero insertion meets shortcut, skip - break; // go next round - } - } - _ => { - if target.is_zero() || last_height == 0 { - let insert_value = - MergeValue::shortcut_or_value(key, value_h256, last_height); - let (left, right) = if key.is_right(last_height) { - (another, insert_value) - } else { - (insert_value, another) - }; - self.store - .insert_branch(branch_key, BranchNode { left, right })?; - break; - } else { - // walk down - last_height -= 1; - continue; - } - } - } - } else if !is_delete { - let target_node = MergeValue::shortcut_or_value(key, value_h256, last_height); - let (left, right) = if key.is_right(last_height) { - (MergeValue::zero(), target_node) - } else { - (target_node, MergeValue::zero()) - }; - self.store - .insert_branch(branch_key, BranchNode { left, right })?; - break; // stop walking - } else if last_height != 0 { - last_height -= 1; - } else { - // do nothing with a zero insertion - break; - } - } - - for height in last_height..=core::u8::MAX { - // update tree hash from insert pos to top - let node_key = key.parent_path(height); - let branch_key = BranchKey::new(height, node_key); - - let new_merge = if let Some(branch) = self.store.get_branch(&branch_key)? { - merge::(height, &node_key, &branch.left, &branch.right) - } else { - MergeValue::zero() - }; - if height == core::u8::MAX { - // updating root - self.root = new_merge.hash::(); - } else { - // updates parent branch - let parent_key = key.parent_path(height + 1); - let parent_branch_key = BranchKey::new(height + 1, parent_key); - if new_merge.is_shortcut() { - // move up - self.store.remove_branch(&branch_key)?; - } - if let Some(parent_branch) = self.store.get_branch(&parent_branch_key)? { - let (left, right) = if key.is_right(height + 1) { - (parent_branch.left, new_merge) - } else { - (new_merge, parent_branch.right) - }; - if left.is_zero() && right.is_zero() { - self.store.remove_branch(&parent_branch_key)?; - } else { - let new_parent_branch = BranchNode { left, right }; - self.store - .insert_branch(parent_branch_key, new_parent_branch)?; - } - } else if !new_merge.is_zero() { - let new_parent_branch = if key.is_right(height + 1) { - BranchNode { - left: MergeValue::zero(), - right: new_merge, - } - } else { - BranchNode { - left: new_merge, - right: MergeValue::zero(), - } - }; - self.store - .insert_branch(parent_branch_key, new_parent_branch)?; - } - } - } - - Ok(&self.root) - } - - /// Update multiple leaves at once - pub fn update_all(&mut self, mut leaves: Vec<(H256, V)>) -> Result<&H256> { - // Dedup(only keep the last of each key) and sort leaves - leaves.reverse(); - leaves.sort_by_key(|(a, _)| *a); - leaves.dedup_by_key(|(a, _)| *a); - - for (key, value) in leaves { - self.update(key, value)?; - } - - Ok(&self.root) - } -} - -impl> SparseMerkleTree { - /// Get value of a leaf - /// return zero value if leaf not exists - pub fn get(&self, key: &H256) -> Result { - if self.is_empty() { - return Ok(V::zero()); - } - Ok(self.store.get_leaf(key)?.unwrap_or_else(V::zero)) - } - - /// Generate merkle proof - pub fn merkle_proof(&self, mut keys: Vec) -> Result { - if keys.is_empty() { - return Err(Error::EmptyKeys); - } - - // sort keys - keys.sort_unstable(); - - // Collect leaf bitmaps - let mut leaves_bitmap: Vec = Default::default(); - for current_key in &keys { - let mut bitmap = H256::zero(); - for height in (0..=core::u8::MAX).rev() { - let parent_key = current_key.parent_path(height); - let parent_branch_key = BranchKey::new(height, parent_key); - if let Some(parent_branch) = self.store.get_branch(&parent_branch_key)? { - let (sibling, target) = if current_key.is_right(height) { - (parent_branch.left, parent_branch.right) - } else { - (parent_branch.right, parent_branch.left) - }; - - if !sibling.is_zero() { - bitmap.set_bit(height); - } - if let MergeValue::ShortCut { key, .. } = target { - if !key.eq(current_key) { - let fork_height = key.fork_height(current_key); - bitmap.set_bit(fork_height); - break; - } - } - } - } - leaves_bitmap.push(bitmap); - } - - let mut proof: Vec = Default::default(); - let mut stack_fork_height = [0u8; MAX_STACK_SIZE]; // store fork height - let mut stack_top = 0; - let mut leaf_index = 0; - - while leaf_index < keys.len() { - let leaf_key = keys[leaf_index]; - let fork_height = if leaf_index + 1 < keys.len() { - leaf_key.fork_height(&keys[leaf_index + 1]) - } else { - core::u8::MAX - }; - - let heights = (0..=fork_height) - .into_iter() - .filter(|height| { - if stack_top > 0 && stack_fork_height[stack_top - 1] == *height { - stack_top -= 1; - false - } else { - true - } - }) - .collect::>(); - - let mut proof_result = Vec::new(); - for height in heights.iter().copied().rev() { - if height == fork_height && leaf_index + 1 < keys.len() { - // If it's not final round, we don't need to merge to root (height=255) - continue; - } - - if leaves_bitmap[leaf_index].get_bit(height) { - let parent_key = leaf_key.parent_path(height); - let is_right = leaf_key.is_right(height); - let parent_branch_key = BranchKey::new(height, parent_key); - if let Some(parent_branch) = self.store.get_branch(&parent_branch_key)? { - let (sibling, current) = if is_right { - (parent_branch.left, parent_branch.right) - } else { - (parent_branch.right, parent_branch.left) - }; - push_sibling::(&mut proof_result, sibling); - if let MergeValue::ShortCut { key, value, .. } = current { - if !key.eq(&leaf_key) { - // this means key does not exist - let fork_height = key.fork_height(&leaf_key); - if leaves_bitmap[leaf_index].get_bit(fork_height) - && heights.contains(&fork_height) - { - proof_result.push(into_merge_value::( - key, - value, - fork_height, - )) - } - } - break; - } - } else { - // Maybe we've skipped shortcut node, find from up to down - for i in (height..=core::u8::MAX).rev() { - let parent_key = leaf_key.parent_path(i); - let is_right = leaf_key.is_right(i); - let parent_branch_key = BranchKey::new(i, parent_key); - if let Some(parent_branch) = - self.store.get_branch(&parent_branch_key)? - { - let current = if is_right { - parent_branch.right - } else { - parent_branch.left - }; - - match current { - MergeValue::ShortCut { key, value, .. } => { - if !key.eq(&leaf_key) { - let fork_at = key.fork_height(&leaf_key); - if fork_at == height { - proof_result.push(into_merge_value::( - key, value, fork_at, - )); - } - } - break; - } - _ => { - continue; - } - } - } - } - break; // we should stop further looping - } - } - } - - proof_result.reverse(); - proof.append(&mut proof_result); - debug_assert!(stack_top < MAX_STACK_SIZE); - stack_fork_height[stack_top] = fork_height; - stack_top += 1; - leaf_index += 1; - } - Ok(MerkleProof::new(leaves_bitmap, proof)) - } -} - -// Helper function for a merkle_path insertion -fn push_sibling(proof_result: &mut Vec, sibling: MergeValue) { - match sibling { - MergeValue::ShortCut { key, value, height } => { - proof_result.push(into_merge_value::(key, value, height)) - } - _ => proof_result.push(sibling), - } -} From 9c42b7b5f3d7a30f125ce1c1a9d2b3316d02f693 Mon Sep 17 00:00:00 2001 From: jjy Date: Tue, 28 Mar 2023 16:35:11 +0800 Subject: [PATCH 2/3] chore: upgrade criterion to 0.4 --- Cargo.toml | 2 +- benches/smt_benchmark.rs | 56 +++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9e87172..168a058 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ blake2b-rs = "0.2" [dev-dependencies] proptest = "0.9" -criterion = "0.2" +criterion = "0.4" rand = "0.8" hex = "0.4.3" serde = { version = "1.0", features = ["derive"] } diff --git a/benches/smt_benchmark.rs b/benches/smt_benchmark.rs index 8f06986..e9ad2a2 100644 --- a/benches/smt_benchmark.rs +++ b/benches/smt_benchmark.rs @@ -1,7 +1,7 @@ #[macro_use] extern crate criterion; -use criterion::Criterion; +use criterion::{BenchmarkId, Criterion}; use rand::{thread_rng, Rng}; use sparse_merkle_tree::{ blake2b::Blake2bHasher, default_store::DefaultStore, SparseMerkleTree, H256, @@ -43,40 +43,42 @@ fn random_smt_update_all(update_count: usize, rng: &mut impl Rng) { } fn bench(c: &mut Criterion) { - c.bench_function_over_inputs( - "SMT update", - |b, &&size| { - b.iter(|| { - let mut rng = thread_rng(); - random_smt(size, &mut rng) - }); - }, - &[100, 10_000], - ); + for input in [100usize, 10000] { + c.bench_with_input( + BenchmarkId::new("SMT update_all", input), + &input, + |b, &size| { + b.iter(|| { + let mut rng = thread_rng(); + random_smt(size, &mut rng) + }); + }, + ); + } - c.bench_function_over_inputs( - "SMT update_all", - |b, &&size| { - b.iter(|| { - let mut rng = thread_rng(); - random_smt_update_all(size, &mut rng) - }); - }, - &[100, 10_000], - ); + for input in [100usize, 10000] { + c.bench_with_input( + BenchmarkId::new("SMT update_all", input), + &input, + |b, &size| { + b.iter(|| { + let mut rng = thread_rng(); + random_smt_update_all(size, &mut rng) + }); + }, + ); + } - c.bench_function_over_inputs( - "SMT get", - |b, &&size| { + for input in [5000usize, 10000] { + c.bench_with_input(BenchmarkId::new("SMT get", input), &input, |b, &size| { let mut rng = thread_rng(); let (smt, _keys) = random_smt(size, &mut rng); b.iter(|| { let key = random_h256(&mut rng); smt.get(&key).unwrap(); }); - }, - &[5_000, 10_000], - ); + }); + } c.bench_function("SMT generate merkle proof", |b| { let mut rng = thread_rng(); From 2b8c59d027bacbe50d2c8e0a1f1ef312aa6f75c9 Mon Sep 17 00:00:00 2001 From: jjy Date: Tue, 28 Mar 2023 16:52:37 +0800 Subject: [PATCH 3/3] chore: remove unused make tasks --- Makefile | 11 +---------- proptest-regressions/tests.txt | 8 -------- proptest-regressions/tests/smt.txt | 7 ------- proptest-regressions/tests/tree.txt | 14 -------------- src/ckb_smt.rs | 2 +- src/default_store.rs | 13 +------------ 6 files changed, 3 insertions(+), 52 deletions(-) delete mode 100644 proptest-regressions/tests.txt delete mode 100644 proptest-regressions/tests/smt.txt delete mode 100644 proptest-regressions/tests/tree.txt diff --git a/Makefile b/Makefile index 529053f..95e410b 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,14 @@ -default: fmt clippy clippy-trie test test-trie bench-test bench-test-trie check test-c-impl test-cxx-build +default: fmt clippy test bench-test check test-c-impl test-cxx-build test: cargo test --all --features std,smtc -test-trie: - cargo test --all --all-features - bench-test: cargo bench -- --test -bench-test-trie: - cargo bench --features trie -- --test - clippy: cargo clippy --all --features std,smtc --all-targets -clippy-trie: - cargo clippy --all --all-features --all-targets - fmt: cargo fmt --all -- --check diff --git a/proptest-regressions/tests.txt b/proptest-regressions/tests.txt deleted file mode 100644 index 30c3d86..0000000 --- a/proptest-regressions/tests.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Seeds for failure cases proptest has generated in the past. It is -# automatically read and these particular cases re-run before any -# novel cases are generated. -# -# It is recommended to check this file in to source control so that -# everyone who runs the test benefits from these saved cases. -cc 914b209785774379f2eeb777aa162f98b896ba0ef454fca8b9ea6ea2d2d43a9b # shrinks to (leaves, _n) = ([(H256([90, 46, 238, 198, 2, 157, 104, 71, 209, 139, 59, 86, 41, 254, 159, 36, 238, 134, 39, 12, 5, 15, 59, 33, 103, 44, 70, 182, 232, 124, 160, 151]), H256([96, 196, 145, 15, 77, 189, 39, 255, 124, 242, 55, 52, 16, 173, 95, 15, 134, 119, 27, 54, 72, 249, 254, 4, 11, 165, 180, 152, 102, 173, 0, 149])), (H256([213, 20, 148, 65, 5, 143, 158, 81, 7, 31, 128, 34, 220, 97, 250, 225, 161, 50, 108, 98, 92, 130, 71, 154, 110, 76, 125, 234, 225, 125, 223, 165]), H256([34, 14, 238, 77, 176, 62, 187, 139, 228, 250, 249, 223, 0, 107, 130, 130, 44, 113, 103, 29, 16, 57, 240, 194, 93, 34, 209, 183, 206, 249, 226, 247])), (H256([132, 9, 252, 57, 185, 247, 251, 90, 128, 49, 149, 73, 116, 186, 133, 11, 14, 15, 175, 223, 30, 148, 246, 227, 74, 138, 194, 108, 49, 209, 13, 10]), H256([74, 245, 19, 243, 68, 170, 162, 152, 192, 214, 168, 39, 228, 155, 188, 174, 47, 38, 13, 234, 118, 66, 101, 162, 25, 130, 27, 155, 171, 233, 22, 168])), (H256([17, 200, 121, 110, 248, 79, 116, 90, 138, 216, 247, 151, 223, 33, 30, 168, 139, 113, 87, 75, 55, 85, 101, 104, 134, 158, 50, 8, 229, 123, 188, 67]), H256([210, 159, 87, 124, 46, 39, 254, 71, 14, 134, 5, 70, 247, 74, 111, 33, 216, 25, 202, 64, 66, 50, 69, 41, 174, 165, 109, 209, 81, 20, 221, 190])), (H256([4, 165, 17, 135, 58, 148, 20, 35, 5, 222, 29, 86, 148, 159, 225, 137, 135, 232, 145, 57, 101, 38, 51, 173, 128, 4, 181, 181, 160, 158, 105, 194]), H256([212, 245, 232, 111, 233, 18, 213, 1, 86, 103, 216, 86, 101, 140, 141, 44, 145, 211, 63, 65, 205, 139, 110, 68, 21, 37, 139, 88, 202, 181, 206, 185])), (H256([2, 176, 2, 27, 4, 192, 231, 6, 126, 183, 115, 13, 83, 21, 251, 120, 25, 117, 161, 112, 203, 52, 251, 199, 245, 77, 165, 205, 37, 203, 208, 105]), H256([5, 48, 190, 68, 111, 7, 102, 82, 156, 145, 174, 13, 185, 82, 243, 189, 199, 50, 193, 157, 216, 207, 139, 223, 35, 170, 163, 46, 213, 10, 228, 136])), (H256([193, 240, 93, 180, 87, 11, 228, 217, 99, 28, 155, 156, 48, 39, 1, 205, 196, 225, 164, 237, 147, 192, 230, 86, 13, 166, 116, 140, 69, 35, 115, 182]), H256([81, 251, 180, 235, 103, 202, 94, 19, 13, 24, 16, 183, 88, 24, 221, 123, 89, 96, 254, 119, 50, 88, 164, 13, 177, 226, 88, 213, 11, 24, 74, 208])), (H256([97, 97, 237, 11, 85, 208, 75, 96, 250, 145, 158, 198, 219, 121, 233, 164, 75, 219, 247, 238, 65, 42, 159, 95, 8, 71, 5, 31, 234, 141, 81, 107]), H256([122, 36, 197, 9, 201, 121, 5, 233, 215, 178, 115, 186, 235, 242, 237, 181, 125, 199, 93, 219, 128, 236, 217, 205, 154, 96, 54, 248, 133, 46, 171, 45])), (H256([134, 20, 238, 6, 241, 91, 51, 73, 103, 155, 233, 16, 253, 13, 53, 11, 221, 31, 22, 102, 84, 88, 144, 185, 255, 132, 107, 228, 41, 241, 62, 161]), H256([156, 126, 78, 162, 29, 111, 105, 28, 85, 165, 239, 175, 68, 219, 111, 31, 33, 142, 19, 233, 208, 203, 43, 159, 210, 189, 66, 79, 64, 69, 121, 151])), (H256([12, 90, 122, 78, 228, 169, 141, 38, 131, 139, 178, 212, 251, 16, 189, 41, 105, 108, 226, 174, 63, 44, 224, 234, 149, 182, 58, 237, 87, 233, 152, 84]), H256([219, 72, 233, 152, 161, 90, 108, 38, 246, 16, 136, 106, 57, 116, 181, 211, 3, 233, 128, 171, 114, 220, 39, 227, 164, 131, 247, 66, 33, 239, 132, 80])), (H256([202, 201, 101, 229, 68, 27, 120, 173, 106, 255, 103, 54, 239, 151, 48, 133, 81, 89, 117, 184, 174, 54, 199, 183, 68, 47, 201, 140, 45, 9, 188, 55]), H256([10, 137, 181, 55, 68, 139, 242, 20, 126, 249, 33, 122, 67, 3, 145, 134, 109, 32, 194, 131, 102, 77, 169, 167, 87, 160, 61, 56, 104, 158, 12, 73])), (H256([198, 131, 203, 84, 131, 170, 61, 219, 228, 110, 22, 165, 154, 107, 229, 138, 100, 196, 244, 3, 155, 233, 109, 229, 115, 43, 59, 133, 126, 8, 148, 116]), H256([137, 153, 89, 58, 45, 40, 185, 132, 233, 254, 128, 105, 87, 162, 120, 152, 55, 17, 70, 127, 207, 52, 175, 93, 219, 45, 68, 142, 193, 121, 210, 194])), (H256([143, 102, 19, 131, 102, 187, 106, 146, 189, 93, 176, 129, 131, 31, 50, 237, 96, 206, 173, 23, 54, 54, 106, 80, 99, 241, 97, 178, 243, 44, 175, 222]), H256([85, 209, 121, 201, 243, 120, 113, 5, 102, 193, 200, 34, 134, 87, 223, 235, 79, 82, 56, 97, 50, 34, 66, 33, 48, 12, 222, 145, 221, 8, 140, 190])), (H256([254, 9, 63, 25, 157, 147, 86, 158, 143, 14, 255, 215, 35, 225, 126, 96, 170, 214, 30, 160, 122, 243, 18, 214, 248, 81, 244, 53, 244, 140, 33, 12]), H256([97, 153, 170, 41, 121, 76, 211, 202, 108, 162, 166, 61, 140, 101, 53, 205, 184, 128, 186, 248, 164, 95, 208, 100, 200, 135, 20, 121, 97, 226, 180, 145])), (H256([16, 27, 242, 65, 141, 122, 242, 142, 246, 123, 231, 88, 146, 255, 14, 94, 222, 173, 209, 255, 97, 197, 224, 92, 123, 129, 6, 90, 48, 69, 0, 231]), H256([193, 120, 126, 212, 188, 112, 202, 43, 56, 212, 233, 64, 175, 203, 238, 164, 72, 143, 71, 82, 145, 195, 168, 192, 77, 80, 89, 160, 105, 217, 201, 201])), (H256([56, 169, 205, 43, 80, 9, 247, 135, 193, 83, 254, 102, 80, 49, 241, 31, 226, 93, 97, 57, 55, 155, 128, 74, 242, 44, 178, 185, 14, 243, 30, 63]), H256([87, 82, 191, 33, 51, 27, 208, 183, 45, 36, 72, 89, 179, 180, 86, 20, 29, 152, 109, 10, 55, 160, 10, 162, 10, 197, 73, 119, 15, 11, 44, 239])), (H256([132, 68, 11, 170, 248, 166, 27, 41, 208, 13, 185, 20, 24, 58, 166, 225, 179, 129, 203, 173, 52, 87, 113, 214, 101, 243, 108, 198, 47, 237, 153, 32]), H256([197, 116, 13, 112, 191, 228, 195, 54, 81, 52, 42, 149, 37, 212, 162, 110, 22, 244, 41, 57, 49, 235, 231, 130, 201, 101, 3, 86, 46, 50, 130, 125])), (H256([205, 95, 192, 16, 63, 242, 196, 142, 145, 233, 68, 220, 167, 207, 133, 59, 235, 245, 60, 140, 176, 117, 116, 38, 36, 76, 2, 123, 155, 180, 115, 76]), H256([240, 180, 209, 100, 180, 10, 190, 223, 170, 143, 133, 187, 209, 92, 192, 103, 96, 239, 88, 253, 10, 219, 50, 155, 85, 190, 233, 18, 53, 206, 29, 198])), (H256([118, 177, 182, 33, 165, 173, 5, 90, 169, 22, 72, 132, 84, 68, 246, 69, 175, 218, 91, 53, 251, 137, 32, 139, 62, 7, 120, 245, 139, 123, 141, 40]), H256([7, 110, 119, 7, 253, 53, 150, 183, 202, 254, 199, 164, 206, 16, 138, 28, 202, 13, 144, 21, 162, 57, 53, 152, 154, 177, 141, 215, 238, 154, 243, 185])), (H256([202, 72, 87, 242, 255, 205, 43, 2, 34, 77, 120, 187, 193, 168, 208, 181, 176, 27, 65, 4, 66, 22, 242, 199, 176, 226, 22, 214, 74, 168, 192, 227]), H256([13, 223, 80, 234, 36, 37, 55, 52, 186, 123, 46, 29, 77, 142, 128, 84, 132, 241, 208, 156, 198, 32, 204, 224, 40, 169, 110, 167, 145, 181, 37, 177])), (H256([251, 119, 92, 221, 130, 219, 234, 227, 29, 124, 12, 9, 208, 149, 107, 79, 204, 162, 200, 146, 88, 73, 79, 156, 223, 88, 89, 216, 31, 123, 77, 147]), H256([221, 174, 82, 94, 170, 3, 143, 115, 204, 71, 188, 157, 220, 38, 98, 88, 222, 3, 221, 85, 124, 218, 63, 133, 234, 195, 179, 70, 12, 44, 151, 112])), (H256([95, 6, 191, 198, 35, 109, 88, 60, 50, 66, 246, 127, 164, 224, 120, 32, 30, 35, 253, 67, 25, 157, 130, 92, 73, 23, 80, 71, 34, 190, 129, 218]), H256([150, 247, 165, 134, 61, 44, 214, 156, 29, 143, 107, 7, 122, 246, 109, 128, 238, 85, 230, 99, 74, 239, 9, 196, 144, 79, 227, 105, 141, 150, 184, 74])), (H256([252, 248, 52, 30, 118, 255, 175, 251, 93, 181, 234, 13, 231, 66, 176, 120, 163, 66, 228, 227, 140, 195, 56, 147, 28, 247, 163, 91, 170, 78, 249, 162]), H256([165, 169, 227, 29, 62, 94, 88, 25, 195, 83, 228, 158, 250, 107, 160, 234, 100, 160, 44, 189, 144, 208, 155, 165, 204, 130, 147, 45, 172, 44, 157, 48])), (H256([170, 195, 187, 215, 89, 20, 199, 75, 229, 223, 163, 73, 87, 136, 246, 74, 14, 20, 36, 81, 246, 142, 189, 52, 222, 203, 212, 131, 137, 22, 133, 106]), H256([96, 189, 251, 40, 50, 210, 109, 248, 73, 12, 244, 63, 243, 49, 220, 209, 51, 29, 166, 98, 4, 163, 36, 116, 5, 63, 18, 79, 107, 48, 249, 150])), (H256([209, 96, 11, 226, 94, 209, 203, 90, 184, 190, 181, 181, 163, 23, 69, 31, 213, 204, 145, 29, 231, 148, 121, 170, 181, 33, 68, 144, 115, 69, 163, 34]), H256([130, 95, 227, 18, 100, 184, 232, 217, 90, 159, 47, 11, 226, 222, 128, 41, 147, 115, 192, 116, 166, 139, 219, 132, 151, 18, 185, 95, 23, 96, 174, 201])), (H256([144, 166, 211, 76, 89, 32, 208, 233, 2, 146, 158, 114, 11, 141, 91, 149, 63, 206, 241, 233, 67, 32, 67, 236, 248, 88, 85, 60, 121, 195, 76, 161]), H256([99, 131, 101, 123, 172, 40, 32, 147, 147, 8, 49, 31, 83, 124, 135, 93, 119, 5, 113, 237, 175, 99, 66, 134, 29, 54, 155, 134, 225, 160, 163, 86])), (H256([6, 231, 204, 164, 123, 123, 224, 8, 215, 48, 55, 162, 124, 19, 35, 236, 247, 206, 235, 174, 89, 72, 196, 131, 58, 214, 147, 81, 223, 141, 124, 9]), H256([52, 108, 209, 169, 160, 222, 25, 174, 114, 23, 156, 62, 228, 211, 9, 189, 50, 37, 180, 42, 216, 251, 207, 89, 206, 223, 150, 106, 206, 180, 33, 198])), (H256([189, 108, 211, 224, 176, 160, 211, 231, 210, 128, 120, 130, 45, 141, 247, 18, 157, 1, 253, 98, 74, 147, 118, 49, 114, 118, 63, 10, 76, 73, 13, 160]), H256([190, 143, 125, 244, 48, 130, 110, 95, 62, 99, 90, 0, 10, 187, 33, 7, 67, 2, 71, 79, 143, 249, 205, 93, 130, 99, 166, 78, 159, 108, 78, 114])), (H256([240, 148, 226, 143, 171, 79, 143, 37, 142, 101, 235, 254, 72, 143, 118, 87, 29, 87, 94, 63, 245, 144, 151, 6, 5, 63, 41, 248, 227, 93, 230, 197]), H256([2, 128, 122, 39, 193, 41, 114, 32, 49, 62, 207, 50, 219, 42, 227, 118, 77, 37, 61, 159, 30, 16, 62, 122, 79, 21, 56, 180, 68, 219, 146, 111])), (H256([72, 145, 238, 248, 166, 203, 125, 155, 39, 37, 37, 246, 40, 74, 8, 133, 66, 123, 49, 138, 7, 129, 94, 39, 49, 116, 12, 199, 65, 65, 242, 47]), H256([165, 71, 76, 126, 17, 30, 56, 96, 159, 137, 106, 11, 49, 220, 234, 209, 164, 43, 171, 236, 89, 70, 14, 153, 213, 223, 239, 237, 96, 20, 203, 176]))], 1), leaves_path = [[205, 82, 100, 1, 146, 159, 156, 127, 35, 190, 64, 119, 178, 226, 91, 42, 59, 185, 38, 88, 28, 126, 10, 141, 250, 125, 80, 89, 90, 133], [64, 62, 22, 38, 105, 64, 173, 38, 143, 189, 2, 83, 54, 127, 41, 216, 99, 155, 111, 133, 97, 244, 19, 159, 113, 30, 15, 143, 22, 2], [78, 73, 122, 176, 196, 43, 226, 139, 252, 122, 165, 25, 37, 141, 42, 146, 44, 190, 62, 167, 11, 31, 152, 90, 1, 76, 107, 230, 68, 136], [17, 244, 205, 214, 237, 105, 224, 29, 54, 129, 161, 97, 136, 48, 96, 37, 190, 200, 136, 121, 75, 203, 17, 46, 228, 32, 50, 190, 18, 117], [171, 30, 160, 250, 10, 82, 72, 240, 245, 2, 3, 250, 249, 251, 238, 239, 37, 17, 63, 112, 63, 59, 39, 188, 165, 235, 222, 26, 229, 165], [227, 97, 191, 142, 47, 106, 5, 129, 44, 34, 111, 204, 141, 57, 179, 54, 192, 164, 11, 129, 161, 244, 180, 109, 102, 252, 210, 189, 243, 187], [184, 165, 128, 96, 37, 152, 14, 159, 129, 46, 98, 65, 201, 198, 238, 234, 114, 51, 58, 153, 242, 84, 218, 31, 53, 80, 193, 94, 37, 38], [186, 157, 233, 12, 74, 244, 71, 77, 3, 58, 98, 78, 247, 112, 54, 212, 146, 222, 249, 249, 100, 54, 42, 117, 166, 151, 118, 83, 20, 29], [228, 183, 159, 105, 35, 118, 132, 150, 130, 9, 51, 149, 64, 182, 32, 5, 7, 237, 93, 95, 254, 232, 135, 196, 253, 30, 234, 117, 133, 254], [30, 139, 243, 228, 76, 114, 237, 160, 123, 15, 28, 182, 16, 1, 138, 113, 56, 170, 113, 20, 7, 33, 88, 156, 253, 197, 166, 29, 206, 240], [162, 199, 22, 145, 170, 11, 8, 244, 242, 134, 33, 9, 115, 222, 182, 134, 101, 255, 142, 46, 176, 47, 60, 97, 64, 34, 221, 22, 203, 203], [50, 121, 59, 123, 206, 186, 204, 225, 58, 118, 6, 182, 97, 129, 241, 39, 215, 186, 53, 77, 106, 13, 139, 171, 56, 158, 135, 250, 149, 198], [160, 169, 27, 255, 96, 252, 148, 181, 250, 84, 253, 46, 229, 214, 179, 187, 20, 21, 42, 212, 82, 197, 69, 37, 250, 213, 238, 52, 55, 70], [183, 237, 66, 20, 42, 194, 221, 129, 21, 180, 39, 83, 134, 191, 57, 220, 24, 96, 163, 221, 116, 43, 201, 171, 58, 16, 39, 131, 117, 30], [133, 176, 87, 208, 21, 169, 18, 67, 203, 159, 200, 124, 70, 148, 248, 163, 224, 183, 229, 137, 2, 53, 114, 115, 243, 164, 9, 187, 15, 10], [174, 81, 86, 203, 86, 254, 84, 105, 234, 169, 204, 9, 89, 200, 140, 131, 175, 39, 64, 4, 169, 43, 123, 18, 83, 1, 82, 107, 109, 80], [167, 58, 247, 209, 213, 129, 53, 29, 240, 139, 185, 105, 7, 233, 13, 66, 76, 231, 86, 152, 129, 242, 56, 244, 106, 70, 185, 32, 242, 253], [117, 58, 223, 77, 48, 91, 68, 177, 39, 250, 251, 150, 74, 242, 192, 103, 226, 213, 85, 107, 18, 26, 149, 43, 1, 220, 171, 92, 177, 17], [221, 146, 105, 249, 40, 24, 110, 14, 49, 86, 53, 172, 102, 153, 229, 103, 243, 232, 14, 70, 140, 22, 19, 0, 232, 242, 255, 100, 96, 46], [30, 77, 137, 116, 144, 150, 190, 56, 136, 229, 148, 23, 69, 245, 187, 92, 176, 142, 26, 17, 59, 211, 197, 15, 160, 60, 201, 91, 148, 59], [241, 225, 168, 191, 167, 145, 0, 73, 231, 29, 134, 190, 237, 210, 237, 186, 15, 179, 85, 16, 30, 141, 37, 115, 25, 224, 44, 92, 73, 229], [93, 221, 231, 50, 177, 197, 40, 134, 249, 190, 153, 234, 99, 187, 113, 112, 140, 142, 210, 94, 209, 68, 186, 81, 18, 189, 97, 231, 168, 18], [173, 157, 248, 93, 60, 95, 154, 223, 23, 107, 160, 200, 9, 8, 230, 203, 17, 196, 247, 234, 179, 21, 225, 15, 102, 110, 126, 81, 87, 99], [44, 220, 91, 125, 180, 133, 11, 84, 204, 89, 192, 101, 215, 19, 160, 169, 24, 105, 236, 228, 180, 197, 126, 240, 212, 236, 50, 154, 148, 86], [52, 195, 23, 226, 128, 7, 5, 108, 247, 119, 151, 85, 203, 236, 11, 36, 96, 84, 174, 234, 1, 135, 221, 211, 184, 12, 205, 249, 199, 239], [219, 72, 81, 22, 151, 188, 184, 203, 78, 69, 106, 215, 132, 136, 233, 254, 209, 226, 41, 167, 189, 253, 127, 89, 11, 156, 69, 96, 112, 248], [129, 88, 73, 116, 181, 98, 68, 188, 53, 195, 62, 23, 53, 73, 80, 178, 62, 37, 98, 211, 90, 185, 189, 59, 75, 164, 170, 55, 121, 174], [213, 185, 118, 243, 35, 136, 91, 56, 90, 174, 102, 136, 38, 252, 148, 169, 245, 32, 6, 83, 215, 217, 76, 243, 209, 11, 75, 37, 48, 135], [64, 88, 54, 101, 249, 77, 63, 15, 178, 122, 113, 89, 35, 74, 254, 20, 99, 184, 80, 210, 249, 138, 244, 215, 131, 26, 243, 179, 40, 83], [216, 181, 33, 97, 169, 213, 205, 86, 68, 81, 41, 35, 191, 42, 157, 152, 165, 86, 38, 220, 124, 84, 69, 194, 208, 90, 153, 79, 218, 64]], proof = [(H256([148, 113, 11, 226, 191, 144, 45, 197, 58, 116, 59, 249, 188, 21, 73, 200, 15, 176, 254, 34, 56, 45, 161, 124, 202, 83, 218, 104, 37, 24, 182, 77]), 169), (H256([12, 124, 224, 12, 41, 116, 244, 135, 186, 178, 6, 248, 227, 195, 55, 139, 0, 220, 165, 100, 69, 141, 137, 242, 10, 53, 81, 169, 116, 195, 215, 239]), 225), (H256([121, 120, 158, 119, 76, 148, 114, 127, 198, 133, 116, 209, 23, 115, 72, 23, 132, 191, 53, 76, 9, 208, 105, 41, 73, 117, 188, 41, 183, 116, 45, 13]), 94), (H256([48, 34, 137, 7, 52, 1, 141, 33, 100, 192, 168, 69, 186, 59, 231, 131, 129, 8, 192, 56, 193, 13, 255, 70, 154, 29, 173, 230, 202, 241, 220, 111]), 152), (H256([140, 237, 61, 149, 157, 166, 200, 18, 222, 201, 172, 58, 158, 89, 188, 135, 219, 11, 202, 123, 225, 16, 144, 228, 114, 122, 173, 50, 44, 97, 59, 19]), 171), (H256([15, 215, 64, 222, 151, 203, 133, 45, 142, 140, 5, 9, 186, 191, 11, 9, 206, 56, 25, 88, 15, 220, 247, 245, 98, 66, 114, 66, 143, 207, 148, 145]), 182), (H256([97, 24, 23, 166, 91, 1, 102, 153, 141, 42, 28, 234, 98, 96, 245, 169, 253, 249, 53, 21, 170, 43, 11, 82, 161, 50, 57, 133, 110, 205, 193, 242]), 101), (H256([253, 90, 86, 147, 86, 230, 99, 237, 16, 201, 135, 4, 38, 191, 62, 104, 87, 82, 138, 120, 80, 63, 61, 138, 167, 221, 222, 98, 136, 115, 134, 91]), 159), (H256([236, 240, 91, 134, 223, 39, 83, 197, 198, 110, 229, 220, 202, 85, 72, 120, 7, 126, 171, 192, 159, 236, 130, 217, 22, 90, 223, 151, 194, 99, 107, 61]), 206), (H256([179, 34, 55, 78, 109, 145, 171, 228, 72, 45, 190, 242, 124, 242, 94, 137, 122, 29, 16, 154, 116, 207, 148, 95, 99, 0, 235, 212, 237, 221, 240, 69]), 115), (H256([163, 117, 118, 186, 81, 202, 165, 161, 204, 38, 208, 169, 117, 21, 73, 154, 90, 47, 251, 1, 252, 22, 219, 49, 190, 99, 5, 250, 116, 63, 222, 227]), 248), (H256([88, 65, 169, 153, 241, 109, 203, 64, 212, 237, 195, 31, 46, 227, 48, 192, 205, 120, 49, 2, 43, 145, 29, 231, 17, 127, 68, 84, 220, 88, 59, 41]), 243), (H256([47, 104, 170, 184, 218, 56, 101, 188, 206, 173, 153, 7, 75, 155, 24, 207, 242, 218, 178, 45, 167, 219, 224, 238, 143, 175, 218, 176, 199, 50, 64, 42]), 160), (H256([230, 84, 226, 78, 9, 63, 37, 159, 143, 230, 144, 76, 207, 112, 199, 193, 56, 246, 2, 60, 41, 132, 172, 230, 184, 178, 214, 232, 157, 128, 226, 15]), 170), (H256([133, 115, 179, 251, 113, 2, 7, 204, 243, 150, 254, 170, 150, 126, 96, 2, 74, 26, 10, 51, 21, 144, 228, 59, 140, 179, 137, 17, 30, 247, 70, 136]), 13), (H256([238, 254, 115, 55, 97, 133, 0, 238, 195, 43, 166, 198, 222, 97, 106, 8, 239, 2, 27, 84, 83, 216, 82, 91, 28, 158, 178, 9, 65, 101, 119, 196]), 210), (H256([194, 19, 35, 105, 245, 185, 0, 191, 57, 205, 249, 33, 164, 5, 181, 2, 229, 247, 62, 187, 129, 117, 110, 180, 196, 63, 168, 199, 97, 169, 65, 64]), 251), (H256([226, 4, 91, 95, 171, 156, 1, 52, 204, 44, 174, 187, 78, 160, 26, 69, 66, 106, 47, 108, 190, 86, 124, 31, 152, 218, 48, 232, 74, 57, 225, 249]), 91), (H256([36, 207, 144, 217, 88, 172, 90, 19, 96, 5, 124, 57, 243, 65, 8, 244, 174, 18, 170, 255, 64, 176, 226, 40, 162, 123, 32, 9, 35, 211, 31, 112]), 246), (H256([118, 152, 131, 220, 184, 208, 209, 67, 144, 104, 10, 100, 8, 214, 234, 175, 235, 161, 185, 92, 190, 11, 128, 167, 175, 225, 216, 95, 115, 242, 20, 19]), 172), (H256([189, 233, 65, 186, 194, 52, 23, 83, 215, 82, 202, 165, 16, 183, 185, 30, 72, 9, 55, 209, 2, 174, 132, 31, 136, 2, 251, 209, 191, 108, 93, 204]), 84), (H256([234, 237, 169, 241, 75, 44, 223, 178, 209, 205, 60, 121, 209, 255, 128, 3, 255, 1, 118, 142, 56, 66, 114, 82, 37, 26, 163, 78, 202, 22, 139, 184]), 214), (H256([65, 105, 200, 159, 164, 38, 136, 185, 105, 205, 143, 188, 37, 52, 135, 114, 18, 124, 19, 216, 81, 5, 156, 145, 189, 191, 158, 109, 93, 83, 11, 119]), 144), (H256([219, 198, 29, 187, 249, 201, 120, 221, 144, 220, 62, 23, 28, 185, 130, 180, 140, 149, 176, 20, 82, 57, 70, 144, 58, 32, 88, 218, 51, 66, 88, 196]), 50), (H256([203, 100, 8, 83, 149, 212, 35, 167, 77, 212, 108, 31, 133, 60, 204, 59, 163, 121, 105, 16, 12, 117, 202, 84, 92, 209, 178, 194, 209, 76, 185, 164]), 211), (H256([41, 35, 80, 13, 15, 93, 45, 103, 238, 71, 98, 248, 16, 37, 52, 10, 70, 255, 22, 20, 69, 191, 154, 161, 157, 53, 155, 208, 249, 67, 88, 50]), 169), (H256([131, 194, 7, 145, 64, 37, 11, 111, 144, 44, 119, 106, 112, 7, 186, 23, 161, 214, 60, 21, 78, 139, 98, 175, 30, 53, 77, 108, 217, 15, 55, 36]), 236), (H256([90, 208, 171, 91, 169, 173, 192, 93, 185, 227, 208, 157, 108, 107, 196, 197, 200, 25, 62, 180, 225, 178, 75, 251, 226, 189, 206, 237, 163, 19, 79, 77]), 147), (H256([152, 88, 195, 0, 30, 36, 219, 2, 254, 38, 177, 65, 233, 101, 4, 15, 193, 12, 195, 54, 221, 80, 118, 213, 83, 234, 20, 130, 235, 48, 246, 43]), 157), (H256([215, 116, 134, 116, 129, 190, 158, 121, 0, 62, 32, 90, 11, 4, 235, 136, 27, 139, 229, 188, 176, 30, 29, 21, 185, 76, 206, 16, 102, 165, 15, 59]), 71), (H256([250, 41, 52, 175, 215, 92, 153, 123, 174, 197, 167, 174, 33, 76, 184, 65, 55, 109, 10, 58, 236, 177, 29, 111, 177, 66, 23, 254, 10, 88, 2, 209]), 132), (H256([137, 186, 9, 60, 253, 92, 206, 114, 233, 158, 210, 111, 39, 0, 75, 203, 235, 33, 184, 14, 50, 25, 115, 131, 165, 45, 81, 30, 88, 245, 211, 98]), 162), (H256([140, 39, 212, 51, 57, 228, 237, 64, 64, 252, 211, 167, 247, 79, 225, 214, 193, 115, 147, 33, 197, 66, 106, 111, 70, 206, 165, 129, 206, 83, 12, 252]), 230), (H256([129, 55, 148, 141, 40, 228, 212, 74, 185, 100, 179, 69, 88, 174, 213, 114, 232, 140, 153, 254, 180, 214, 32, 195, 120, 146, 128, 140, 124, 68, 37, 76]), 240), (H256([91, 130, 154, 118, 202, 131, 13, 1, 169, 220, 138, 224, 151, 65, 143, 198, 241, 72, 219, 52, 199, 175, 1, 87, 186, 184, 27, 133, 158, 213, 97, 3]), 66), (H256([191, 113, 167, 0, 193, 5, 217, 5, 9, 128, 78, 108, 56, 118, 207, 165, 189, 211, 189, 8, 143, 106, 129, 92, 162, 23, 164, 74, 72, 74, 47, 9]), 1), (H256([252, 82, 126, 46, 200, 15, 14, 205, 8, 157, 4, 46, 172, 0, 191, 125, 218, 91, 66, 148, 242, 159, 24, 131, 193, 64, 167, 66, 198, 36, 171, 235]), 131), (H256([111, 26, 86, 43, 218, 145, 12, 63, 176, 195, 202, 12, 38, 205, 156, 214, 134, 202, 70, 154, 155, 255, 127, 123, 180, 107, 84, 60, 118, 200, 91, 236]), 17), (H256([119, 165, 78, 90, 126, 32, 211, 13, 6, 113, 17, 241, 56, 54, 10, 142, 219, 10, 108, 182, 201, 251, 228, 196, 171, 178, 1, 90, 238, 32, 39, 55]), 53), (H256([7, 164, 139, 83, 215, 147, 43, 73, 226, 125, 234, 81, 224, 220, 196, 151, 21, 131, 91, 184, 219, 43, 166, 14, 142, 114, 28, 194, 19, 141, 234, 7]), 106), (H256([110, 130, 230, 25, 85, 182, 196, 169, 234, 234, 186, 135, 57, 242, 114, 247, 71, 241, 210, 0, 158, 38, 153, 139, 113, 220, 69, 250, 135, 105, 131, 241]), 87), (H256([231, 100, 238, 170, 43, 133, 106, 220, 96, 129, 24, 104, 110, 161, 64, 26, 47, 10, 178, 251, 234, 176, 237, 44, 24, 123, 88, 107, 91, 168, 155, 41]), 5), (H256([249, 5, 147, 33, 16, 250, 213, 196, 164, 111, 234, 47, 181, 228, 83, 75, 122, 240, 14, 55, 238, 171, 218, 155, 93, 220, 65, 64, 50, 156, 203, 42]), 50), (H256([50, 68, 126, 56, 227, 227, 88, 224, 52, 201, 3, 150, 141, 93, 251, 149, 68, 54, 162, 158, 28, 247, 216, 64, 218, 41, 86, 193, 22, 234, 245, 184]), 134), (H256([76, 205, 67, 31, 199, 162, 218, 255, 181, 19, 198, 114, 147, 246, 9, 176, 193, 81, 132, 162, 52, 171, 179, 149, 164, 97, 127, 189, 138, 101, 246, 195]), 26), (H256([147, 29, 198, 229, 247, 102, 101, 172, 242, 251, 168, 125, 93, 90, 124, 162, 16, 21, 149, 144, 104, 244, 173, 249, 148, 74, 121, 134, 211, 30, 59, 236]), 144), (H256([101, 60, 16, 42, 200, 17, 161, 75, 196, 12, 28, 195, 134, 193, 146, 136, 22, 114, 57, 16, 148, 166, 21, 73, 150, 13, 133, 16, 170, 88, 191, 204]), 232), (H256([252, 60, 66, 186, 173, 125, 254, 110, 152, 178, 159, 47, 246, 121, 171, 28, 175, 140, 162, 188, 49, 105, 23, 169, 158, 152, 217, 139, 140, 225, 75, 93]), 178), (H256([109, 211, 196, 244, 56, 253, 104, 28, 77, 25, 108, 215, 93, 186, 251, 12, 55, 235, 155, 173, 196, 202, 246, 239, 243, 202, 127, 156, 93, 9, 218, 103]), 233), (H256([82, 200, 146, 129, 179, 252, 117, 239, 54, 52, 80, 167, 185, 222, 12, 100, 116, 140, 214, 0, 29, 96, 143, 8, 161, 133, 50, 119, 121, 237, 249, 7]), 44)] -cc d9019d1ce72b375ebd9442899d379674c0e2c2bedfa76ebdbd7da32aa1ce3d1b # shrinks to (leaves, _n) = ([(H256([6, 244, 231, 228, 174, 174, 186, 116, 173, 19, 23, 161, 117, 154, 71, 153, 224, 203, 33, 203, 69, 119, 57, 217, 15, 125, 87, 40, 141, 82, 121, 38]), H256([238, 105, 121, 3, 170, 97, 69, 141, 252, 161, 34, 245, 20, 54, 78, 130, 132, 71, 104, 222, 19, 96, 56, 62, 166, 69, 236, 204, 69, 72, 61, 210])), (H256([18, 234, 209, 104, 142, 160, 36, 133, 158, 45, 33, 101, 237, 200, 29, 195, 73, 235, 5, 11, 34, 153, 75, 15, 198, 25, 107, 5, 190, 57, 12, 121]), H256([48, 165, 62, 230, 126, 128, 46, 139, 0, 119, 208, 87, 155, 192, 144, 173, 168, 70, 169, 235, 111, 208, 230, 120, 40, 140, 39, 234, 245, 194, 29, 63])), (H256([156, 192, 89, 30, 212, 208, 179, 126, 125, 182, 183, 104, 251, 32, 220, 156, 188, 126, 182, 237, 4, 219, 162, 139, 201, 84, 35, 249, 105, 196, 82, 77]), H256([184, 159, 143, 171, 231, 100, 7, 125, 74, 222, 247, 67, 63, 95, 201, 250, 56, 105, 160, 144, 105, 129, 86, 51, 49, 247, 179, 240, 64, 87, 231, 130])), (H256([210, 71, 232, 36, 117, 254, 103, 10, 249, 229, 125, 49, 243, 46, 82, 236, 144, 11, 75, 117, 134, 84, 10, 34, 188, 71, 139, 162, 82, 226, 142, 41]), H256([191, 118, 108, 150, 132, 220, 220, 64, 20, 71, 126, 176, 212, 104, 146, 160, 157, 115, 2, 203, 178, 18, 1, 42, 197, 56, 115, 166, 148, 65, 1, 197])), (H256([11, 101, 100, 93, 201, 134, 106, 58, 182, 86, 187, 1, 221, 33, 77, 245, 94, 175, 246, 70, 182, 252, 168, 211, 155, 128, 20, 132, 13, 42, 223, 173]), H256([26, 221, 249, 223, 167, 248, 197, 9, 6, 237, 31, 251, 55, 152, 245, 47, 216, 202, 163, 99, 8, 80, 173, 7, 130, 244, 241, 200, 227, 205, 226, 96])), (H256([7, 85, 80, 211, 202, 165, 97, 157, 27, 150, 178, 180, 155, 89, 53, 245, 68, 164, 156, 53, 202, 167, 70, 214, 236, 92, 156, 43, 102, 228, 94, 60]), H256([163, 5, 128, 158, 188, 145, 107, 30, 129, 41, 230, 34, 120, 66, 108, 75, 148, 103, 90, 201, 212, 244, 160, 207, 128, 181, 203, 235, 199, 133, 188, 174])), (H256([240, 148, 103, 174, 101, 175, 19, 65, 247, 144, 106, 96, 188, 250, 208, 160, 116, 232, 242, 165, 173, 63, 211, 105, 136, 18, 78, 148, 23, 238, 41, 179]), H256([238, 78, 34, 186, 180, 138, 48, 175, 208, 156, 40, 11, 74, 218, 249, 239, 147, 229, 15, 8, 230, 238, 218, 59, 3, 150, 133, 247, 232, 139, 222, 102])), (H256([228, 54, 9, 90, 174, 158, 37, 159, 224, 79, 131, 143, 197, 13, 1, 182, 182, 210, 127, 48, 13, 123, 244, 142, 139, 142, 235, 113, 68, 173, 132, 18]), H256([30, 224, 229, 122, 206, 87, 136, 139, 2, 79, 77, 205, 29, 1, 89, 150, 27, 104, 132, 107, 247, 223, 90, 108, 217, 34, 255, 43, 110, 171, 249, 170])), (H256([171, 13, 132, 241, 47, 32, 142, 178, 21, 126, 174, 202, 49, 141, 3, 58, 241, 112, 173, 42, 129, 112, 37, 77, 216, 145, 72, 83, 120, 228, 2, 119]), H256([201, 139, 247, 0, 19, 207, 99, 108, 214, 230, 60, 142, 197, 76, 31, 219, 179, 56, 242, 164, 95, 185, 174, 123, 247, 69, 135, 120, 62, 155, 187, 243])), (H256([54, 201, 136, 244, 224, 244, 70, 27, 146, 12, 217, 13, 91, 49, 61, 5, 22, 244, 179, 204, 6, 196, 225, 19, 112, 250, 100, 87, 254, 37, 46, 230]), H256([30, 255, 1, 230, 224, 17, 35, 25, 34, 249, 206, 88, 111, 227, 123, 104, 196, 24, 76, 177, 99, 240, 71, 188, 250, 79, 74, 89, 189, 29, 82, 162])), (H256([146, 8, 137, 19, 251, 60, 174, 3, 240, 243, 152, 12, 152, 231, 199, 184, 140, 216, 131, 142, 4, 112, 251, 36, 51, 28, 41, 11, 75, 204, 163, 31]), H256([252, 103, 213, 130, 30, 141, 10, 8, 114, 53, 27, 3, 143, 213, 108, 207, 23, 67, 87, 174, 10, 226, 207, 118, 87, 39, 10, 160, 196, 114, 30, 22])), (H256([18, 209, 251, 229, 205, 80, 129, 66, 71, 50, 121, 160, 116, 146, 228, 7, 220, 10, 98, 3, 152, 36, 65, 60, 33, 235, 11, 153, 197, 236, 90, 223]), H256([194, 152, 57, 28, 18, 160, 66, 249, 48, 96, 141, 234, 74, 12, 25, 225, 252, 217, 112, 60, 79, 105, 107, 130, 122, 49, 223, 165, 189, 156, 22, 211])), (H256([212, 216, 105, 242, 163, 32, 180, 121, 128, 136, 73, 151, 19, 20, 239, 26, 9, 5, 237, 185, 32, 118, 100, 9, 172, 190, 144, 255, 145, 226, 69, 179]), H256([39, 10, 190, 33, 38, 229, 184, 19, 222, 237, 237, 108, 211, 54, 210, 12, 56, 148, 173, 162, 226, 24, 184, 148, 203, 109, 22, 231, 145, 123, 141, 126])), (H256([211, 28, 44, 202, 126, 59, 61, 141, 170, 157, 146, 150, 206, 176, 29, 60, 236, 142, 0, 19, 134, 79, 53, 112, 182, 0, 178, 213, 226, 175, 232, 161]), H256([210, 137, 105, 5, 255, 109, 66, 124, 233, 34, 142, 72, 99, 242, 225, 39, 245, 195, 63, 59, 66, 83, 2, 38, 161, 115, 73, 77, 41, 151, 216, 218])), (H256([117, 141, 221, 10, 243, 180, 197, 91, 156, 242, 254, 99, 55, 137, 60, 255, 246, 195, 162, 120, 176, 7, 105, 221, 232, 122, 19, 151, 162, 10, 245, 123]), H256([37, 4, 131, 49, 167, 229, 233, 179, 255, 212, 1, 108, 215, 63, 179, 207, 62, 151, 220, 45, 132, 204, 0, 196, 185, 133, 56, 142, 121, 196, 107, 73])), (H256([29, 215, 142, 161, 246, 44, 147, 171, 253, 174, 215, 87, 16, 143, 210, 199, 68, 244, 102, 190, 56, 142, 238, 68, 105, 95, 203, 119, 92, 70, 224, 157]), H256([59, 22, 165, 2, 106, 19, 38, 180, 86, 183, 88, 126, 207, 146, 218, 34, 237, 62, 100, 31, 197, 79, 195, 73, 64, 104, 157, 74, 26, 80, 32, 13])), (H256([41, 29, 103, 214, 212, 48, 215, 110, 126, 250, 160, 225, 205, 75, 232, 136, 220, 54, 91, 119, 40, 27, 68, 34, 94, 12, 186, 248, 12, 67, 117, 220]), H256([114, 198, 63, 183, 219, 29, 66, 129, 166, 245, 216, 173, 236, 77, 247, 233, 227, 235, 112, 57, 176, 141, 68, 113, 42, 108, 211, 229, 144, 214, 101, 97])), (H256([237, 251, 18, 5, 154, 118, 235, 168, 211, 162, 49, 53, 41, 227, 16, 10, 224, 95, 232, 6, 215, 72, 222, 209, 253, 138, 59, 237, 177, 210, 29, 213]), H256([138, 167, 121, 151, 232, 248, 73, 106, 240, 144, 114, 15, 210, 20, 245, 172, 58, 134, 111, 49, 205, 220, 191, 25, 224, 243, 194, 24, 22, 54, 77, 177])), (H256([38, 39, 149, 58, 63, 163, 96, 144, 1, 55, 25, 159, 205, 166, 157, 147, 229, 213, 2, 178, 193, 202, 145, 177, 33, 86, 252, 80, 190, 212, 252, 201]), H256([156, 193, 202, 6, 118, 141, 199, 184, 31, 150, 170, 40, 51, 8, 176, 62, 185, 223, 142, 208, 4, 73, 183, 131, 31, 139, 205, 128, 4, 146, 45, 179])), (H256([125, 217, 229, 138, 200, 221, 58, 94, 219, 65, 184, 22, 213, 57, 107, 201, 37, 142, 172, 113, 226, 35, 95, 232, 168, 38, 8, 7, 227, 69, 115, 169]), H256([27, 177, 160, 83, 234, 134, 79, 182, 120, 80, 169, 77, 220, 89, 23, 58, 68, 44, 214, 225, 238, 178, 148, 51, 42, 183, 80, 234, 100, 182, 0, 49])), (H256([80, 20, 137, 132, 70, 74, 6, 199, 55, 242, 197, 33, 188, 245, 23, 104, 98, 112, 222, 65, 150, 145, 115, 226, 122, 173, 77, 242, 235, 182, 143, 104]), H256([55, 192, 4, 126, 156, 139, 155, 111, 93, 246, 74, 39, 237, 42, 15, 190, 41, 224, 1, 65, 6, 57, 238, 161, 41, 248, 210, 165, 230, 224, 47, 45])), (H256([5, 134, 91, 253, 189, 108, 14, 189, 254, 144, 73, 252, 143, 40, 112, 179, 162, 195, 94, 76, 207, 119, 176, 177, 231, 126, 224, 19, 131, 83, 149, 131]), H256([161, 185, 165, 186, 210, 216, 197, 90, 67, 104, 21, 134, 79, 194, 219, 71, 107, 50, 179, 119, 94, 184, 98, 182, 66, 218, 178, 96, 240, 221, 4, 219])), (H256([75, 235, 150, 19, 251, 114, 187, 118, 40, 49, 207, 4, 246, 228, 110, 55, 137, 230, 242, 161, 233, 109, 150, 190, 0, 181, 52, 10, 66, 43, 146, 230]), H256([212, 48, 229, 143, 39, 243, 194, 89, 224, 25, 109, 152, 215, 25, 220, 228, 26, 2, 248, 46, 119, 88, 168, 178, 161, 115, 151, 106, 204, 34, 107, 220])), (H256([180, 87, 76, 11, 0, 118, 107, 207, 159, 84, 5, 18, 195, 85, 24, 148, 216, 186, 0, 48, 132, 204, 74, 149, 183, 68, 216, 77, 238, 23, 54, 20]), H256([236, 101, 4, 128, 79, 67, 63, 144, 228, 58, 59, 15, 40, 4, 89, 189, 127, 18, 173, 98, 108, 79, 68, 133, 147, 135, 18, 80, 165, 77, 238, 44])), (H256([255, 93, 121, 104, 108, 164, 120, 100, 209, 5, 209, 209, 155, 74, 124, 12, 58, 229, 179, 16, 76, 107, 23, 71, 138, 217, 136, 216, 63, 119, 74, 87]), H256([11, 250, 218, 100, 16, 248, 122, 163, 117, 18, 57, 129, 94, 27, 244, 173, 171, 125, 234, 8, 106, 77, 107, 56, 141, 61, 185, 176, 194, 57, 14, 25])), (H256([44, 116, 100, 2, 68, 231, 41, 165, 239, 173, 26, 63, 183, 187, 247, 98, 17, 185, 11, 23, 26, 147, 87, 80, 30, 102, 165, 61, 49, 124, 209, 111]), H256([13, 231, 251, 136, 103, 191, 143, 21, 149, 113, 180, 149, 204, 95, 168, 221, 235, 216, 164, 195, 208, 205, 134, 133, 145, 72, 201, 223, 91, 214, 101, 21])), (H256([177, 86, 85, 193, 103, 61, 66, 34, 4, 215, 46, 64, 148, 6, 131, 197, 142, 86, 160, 246, 134, 88, 2, 16, 126, 230, 166, 156, 104, 50, 55, 32]), H256([6, 34, 252, 8, 77, 202, 8, 89, 114, 63, 30, 94, 57, 5, 174, 94, 238, 198, 118, 124, 247, 220, 203, 57, 11, 109, 167, 155, 210, 117, 22, 105])), (H256([132, 252, 223, 46, 197, 123, 224, 186, 232, 46, 15, 208, 10, 173, 145, 189, 236, 111, 95, 246, 187, 217, 227, 198, 123, 80, 100, 58, 223, 230, 90, 20]), H256([26, 245, 70, 102, 88, 162, 244, 21, 43, 249, 70, 32, 147, 46, 4, 11, 204, 75, 192, 134, 55, 83, 236, 109, 223, 178, 178, 4, 101, 105, 241, 149])), (H256([70, 161, 89, 3, 137, 178, 133, 118, 203, 38, 230, 11, 42, 142, 23, 89, 253, 173, 199, 108, 153, 118, 124, 113, 88, 189, 225, 116, 53, 131, 250, 208]), H256([193, 181, 210, 194, 170, 177, 221, 215, 147, 171, 177, 78, 204, 75, 201, 163, 68, 208, 103, 14, 225, 151, 54, 83, 16, 209, 11, 95, 115, 193, 124, 178])), (H256([175, 34, 136, 105, 38, 110, 92, 197, 215, 128, 42, 172, 158, 6, 10, 78, 158, 146, 110, 181, 81, 230, 212, 202, 155, 122, 96, 7, 9, 109, 157, 109]), H256([160, 120, 141, 78, 140, 0, 218, 222, 138, 2, 62, 215, 96, 75, 30, 39, 37, 139, 109, 115, 77, 139, 3, 166, 12, 235, 126, 31, 167, 0, 102, 24]))], 1), leaves_path = [[134, 141, 92, 236, 176, 180, 228, 151, 118, 98, 190, 45, 30, 2, 159, 32, 193, 133, 94, 241, 52, 62, 52, 171, 47, 97, 192, 115, 79, 149], [190, 60, 200, 186, 150, 146, 49, 170, 48, 106, 232, 204, 180, 99, 129, 145, 62, 221, 156, 201, 126, 119, 135, 58, 218, 12, 91, 28, 1, 72], [119, 57, 168, 54, 96, 182, 230, 176, 26, 94, 231, 91, 13, 96, 0, 134, 100, 202, 253, 178, 206, 101, 228, 123, 167, 47, 188, 167, 211, 105], [114, 213, 3, 205, 77, 103, 143, 205, 189, 151, 95, 197, 213, 48, 120, 236, 70, 149, 79, 251, 65, 236, 202, 29, 206, 76, 26, 57, 212, 190], [54, 16, 236, 103, 136, 177, 26, 72, 56, 252, 68, 47, 25, 128, 118, 130, 202, 198, 82, 3, 66, 144, 101, 99, 232, 213, 116, 77, 47, 164], [109, 29, 223, 186, 164, 84, 116, 125, 69, 143, 119, 137, 194, 28, 217, 42, 12, 115, 229, 84, 204, 10, 186, 161, 25, 189, 87, 37, 70, 117], [231, 40, 208, 164, 202, 173, 102, 201, 76, 154, 213, 151, 184, 139, 179, 67, 134, 243, 149, 152, 199, 218, 62, 147, 22, 141, 247, 38, 28, 118], [141, 116, 241, 183, 166, 91, 172, 248, 93, 202, 189, 151, 157, 230, 172, 79, 118, 136, 90, 82, 82, 192, 43, 112, 121, 220, 103, 81, 105, 161], [29, 237, 37, 43, 127, 147, 214, 13, 1, 144, 107, 136, 200, 124, 43, 128, 206, 184, 93, 239, 49, 64, 199, 114, 236, 212, 93, 41, 189, 225], [188, 64, 59, 207, 17, 84, 202, 196, 104, 29, 197, 106, 172, 27, 27, 8, 62, 120, 174, 115, 107, 129, 122, 72, 7, 249, 113, 199, 11, 157], [87, 153, 145, 21, 76, 195, 136, 168, 188, 74, 238, 227, 189, 188, 68, 69, 67, 243, 127, 96, 41, 228, 110, 90, 175, 5, 174, 122, 163, 176], [211, 53, 251, 216, 72, 129, 55, 30, 115, 22, 204, 213, 245, 137, 218, 49, 166, 207, 104, 195, 224, 63, 192, 141, 89, 129, 92, 183, 184, 132], [98, 88, 105, 27, 100, 130, 80, 71, 135, 93, 186, 248, 97, 78, 158, 145, 163, 87, 91, 90, 235, 71, 185, 71, 75, 212, 162, 134, 252, 222], [135, 112, 147, 188, 206, 244, 24, 180, 222, 63, 80, 230, 175, 169, 19, 20, 41, 17, 126, 172, 3, 211, 222, 117, 111, 152, 67, 1, 12, 29], [148, 82, 125, 64, 34, 139, 163, 71, 119, 24, 12, 94, 37, 238, 197, 125, 48, 96, 141, 197, 87, 90, 29, 22, 116, 130, 32, 0, 194, 54], [188, 220, 135, 64, 179, 65, 171, 108, 42, 85, 109, 8, 173, 212, 148, 19, 199, 6, 208, 42, 165, 44, 121, 200, 37, 61, 56, 51, 25, 245], [12, 117, 65, 108, 19, 87, 54, 147, 77, 18, 254, 141, 192, 251, 176, 70, 82, 111, 46, 130, 142, 81, 122, 134, 20, 33, 238, 128, 155, 174], [151, 4, 139, 26, 100, 115, 186, 143, 91, 237, 216, 229, 64, 158, 197, 154, 109, 131, 159, 121, 216, 17, 79, 130, 62, 106, 124, 211, 248, 235], [170, 21, 45, 251, 36, 144, 141, 125, 211, 18, 217, 42, 130, 98, 31, 77, 230, 42, 27, 75, 14, 131, 42, 41, 100, 23, 66, 195, 173, 157], [118, 135, 255, 22, 226, 14, 146, 97, 32, 52, 144, 32, 34, 219, 87, 78, 184, 246, 204, 26, 24, 203, 202, 220, 232, 176, 228, 63, 161, 23], [154, 209, 237, 55, 211, 48, 105, 219, 103, 204, 160, 106, 176, 248, 65, 252, 124, 246, 172, 192, 52, 59, 94, 229, 238, 129, 112, 78, 28, 81], [250, 227, 31, 84, 239, 56, 169, 177, 65, 171, 65, 56, 206, 102, 14, 111, 95, 70, 82, 163, 141, 178, 216, 113, 157, 65, 224, 198, 213, 24], [213, 252, 84, 146, 9, 172, 225, 243, 239, 106, 198, 207, 34, 162, 195, 89, 154, 20, 94, 229, 71, 137, 209, 188, 184, 123, 119, 52, 126, 74], [21, 59, 172, 56, 64, 131, 215, 38, 66, 195, 245, 135, 88, 111, 174, 127, 210, 248, 111, 147, 182, 246, 27, 97, 102, 105, 108, 170, 6, 8], [38, 254, 84, 174, 119, 141, 106, 255, 140, 211, 112, 190, 191, 132, 175, 170, 209, 177, 173, 143, 219, 122, 198, 204, 19, 207, 235, 182, 168, 85], [181, 136, 102, 128, 108, 46, 250, 147, 112, 10, 85, 42, 123, 173, 135, 230, 95, 122, 250, 36, 87, 91, 147, 39, 7, 228, 40, 71, 147, 84], [108, 29, 20, 9, 37, 141, 79, 197, 84, 105, 96, 28, 39, 33, 96, 27, 129, 182, 66, 213, 85, 115, 96, 80, 240, 127, 129, 51, 195, 103], [167, 82, 6, 116, 165, 64, 199, 121, 141, 152, 157, 47, 193, 100, 226, 162, 63, 7, 46, 16, 161, 233, 30, 214, 81, 179, 130, 15, 45, 66], [174, 251, 204, 10, 140, 90, 148, 231, 180, 151, 174, 178, 56, 88, 241, 28, 52, 156, 192, 85, 76, 196, 98, 81, 29, 134, 13, 236, 126, 190], [117, 23, 118, 236, 158, 134, 84, 245, 216, 211, 134, 14, 45, 222, 51, 233, 128, 168, 243, 162, 132, 196, 254, 96, 76, 172, 124, 216, 232, 229]], proof = [(H256([103, 21, 106, 231, 65, 104, 126, 60, 55, 225, 247, 42, 243, 99, 77, 135, 169, 161, 178, 236, 10, 14, 144, 2, 164, 9, 242, 112, 208, 72, 249, 145]), 156), (H256([46, 192, 160, 111, 96, 63, 185, 107, 166, 229, 240, 108, 162, 222, 54, 207, 58, 126, 77, 8, 211, 156, 242, 182, 25, 85, 224, 110, 20, 180, 254, 168]), 181), (H256([207, 32, 156, 187, 247, 92, 98, 67, 55, 175, 3, 33, 32, 147, 107, 102, 231, 143, 128, 24, 15, 23, 247, 244, 176, 78, 5, 160, 68, 60, 213, 62]), 147), (H256([224, 117, 90, 157, 177, 130, 35, 75, 187, 242, 210, 157, 145, 47, 33, 191, 113, 193, 44, 163, 154, 176, 83, 57, 188, 247, 44, 32, 163, 61, 173, 164]), 210), (H256([140, 24, 116, 106, 195, 186, 121, 70, 29, 225, 15, 77, 186, 61, 67, 62, 230, 3, 139, 204, 9, 112, 23, 233, 190, 17, 188, 7, 162, 54, 87, 200]), 236), (H256([175, 252, 6, 253, 142, 29, 25, 41, 74, 165, 192, 28, 239, 155, 188, 56, 72, 106, 48, 246, 101, 128, 173, 64, 254, 109, 171, 41, 203, 204, 125, 59]), 234), (H256([222, 137, 28, 234, 71, 93, 162, 54, 182, 236, 213, 24, 67, 180, 21, 101, 160, 66, 8, 12, 1, 23, 141, 88, 186, 174, 201, 7, 243, 139, 20, 146]), 77), (H256([196, 80, 160, 77, 58, 111, 227, 109, 251, 47, 234, 223, 207, 232, 106, 197, 96, 32, 71, 117, 14, 162, 225, 33, 254, 192, 160, 76, 10, 249, 133, 164]), 41), (H256([67, 248, 70, 92, 31, 153, 17, 152, 167, 132, 57, 45, 65, 144, 152, 99, 206, 113, 180, 198, 48, 100, 186, 89, 237, 209, 245, 209, 25, 163, 229, 165]), 133), (H256([143, 76, 132, 145, 56, 249, 228, 220, 197, 137, 103, 168, 17, 238, 147, 242, 157, 3, 192, 200, 216, 201, 234, 210, 25, 249, 114, 54, 42, 116, 122, 35]), 174), (H256([203, 74, 27, 196, 13, 104, 71, 20, 175, 106, 126, 237, 172, 252, 75, 76, 130, 167, 186, 225, 85, 111, 72, 81, 183, 175, 48, 211, 195, 75, 154, 138]), 44), (H256([146, 151, 156, 226, 28, 42, 88, 127, 11, 28, 135, 215, 180, 227, 191, 206, 18, 151, 228, 203, 123, 29, 75, 84, 200, 251, 38, 164, 80, 122, 88, 3]), 188), (H256([170, 220, 148, 180, 248, 13, 113, 122, 95, 118, 47, 53, 174, 21, 237, 61, 57, 125, 149, 252, 157, 250, 131, 7, 201, 111, 49, 255, 159, 3, 158, 25]), 217), (H256([245, 189, 133, 216, 229, 138, 149, 232, 49, 40, 184, 180, 213, 204, 46, 204, 112, 68, 133, 38, 134, 254, 15, 78, 64, 98, 238, 58, 8, 228, 82, 44]), 127), (H256([207, 157, 60, 5, 129, 193, 69, 117, 123, 27, 230, 156, 252, 128, 57, 179, 137, 16, 41, 40, 22, 44, 184, 105, 87, 71, 86, 159, 194, 29, 12, 27]), 178), (H256([74, 116, 64, 167, 132, 47, 162, 34, 32, 158, 181, 18, 70, 215, 27, 179, 24, 18, 184, 219, 205, 112, 240, 161, 112, 35, 142, 123, 100, 165, 222, 44]), 131), (H256([94, 245, 166, 189, 66, 102, 222, 78, 250, 155, 22, 240, 175, 106, 201, 229, 186, 94, 21, 237, 71, 228, 105, 222, 160, 57, 159, 116, 151, 150, 172, 203]), 112), (H256([12, 139, 202, 139, 114, 9, 192, 67, 206, 57, 2, 169, 245, 228, 142, 63, 213, 98, 139, 230, 51, 19, 37, 206, 102, 112, 190, 221, 235, 95, 208, 56]), 38), (H256([214, 5, 204, 177, 160, 150, 34, 104, 202, 195, 138, 205, 106, 213, 214, 181, 88, 176, 234, 88, 135, 17, 121, 43, 66, 225, 67, 116, 228, 231, 236, 31]), 79), (H256([15, 247, 1, 77, 93, 224, 22, 196, 102, 171, 30, 5, 78, 141, 107, 213, 128, 136, 18, 76, 135, 84, 153, 42, 242, 73, 76, 12, 255, 217, 169, 22]), 221), (H256([84, 188, 117, 3, 143, 134, 157, 39, 3, 49, 46, 170, 140, 106, 34, 186, 160, 243, 57, 113, 40, 99, 8, 183, 197, 66, 222, 92, 63, 181, 96, 107]), 67), (H256([9, 2, 218, 205, 89, 100, 77, 6, 232, 118, 234, 113, 138, 99, 251, 50, 115, 102, 95, 128, 224, 26, 68, 51, 104, 62, 44, 162, 140, 17, 210, 71]), 161), (H256([115, 180, 172, 89, 24, 222, 160, 26, 40, 249, 198, 219, 162, 247, 143, 34, 81, 237, 169, 131, 39, 50, 0, 45, 123, 86, 172, 73, 45, 104, 67, 82]), 246), (H256([84, 7, 215, 168, 177, 202, 67, 185, 16, 39, 201, 240, 234, 116, 182, 139, 249, 238, 188, 70, 160, 42, 222, 243, 65, 210, 179, 154, 32, 125, 178, 138]), 243), (H256([154, 158, 4, 78, 190, 186, 242, 145, 166, 229, 185, 201, 57, 248, 178, 160, 72, 232, 254, 115, 221, 1, 178, 95, 239, 100, 86, 50, 67, 226, 74, 140]), 74), (H256([85, 135, 109, 156, 71, 82, 194, 231, 214, 177, 228, 183, 79, 157, 218, 45, 59, 58, 0, 193, 20, 151, 6, 120, 78, 211, 222, 164, 80, 186, 78, 18]), 96), (H256([54, 81, 140, 86, 162, 185, 115, 127, 60, 107, 254, 35, 149, 54, 240, 18, 8, 32, 50, 158, 79, 128, 93, 158, 49, 207, 37, 53, 60, 194, 238, 53]), 251), (H256([223, 133, 192, 152, 238, 227, 93, 136, 253, 145, 70, 115, 36, 216, 92, 168, 218, 202, 61, 247, 255, 142, 231, 71, 55, 242, 46, 215, 40, 9, 249, 29]), 136), (H256([206, 108, 156, 188, 24, 159, 230, 241, 10, 32, 19, 136, 240, 111, 158, 89, 31, 253, 25, 60, 12, 59, 155, 210, 71, 246, 198, 57, 208, 245, 2, 149]), 38), (H256([66, 164, 240, 170, 250, 161, 223, 107, 128, 183, 81, 222, 133, 49, 46, 84, 18, 29, 223, 142, 41, 79, 168, 93, 187, 201, 183, 202, 4, 79, 140, 171]), 212), (H256([97, 36, 38, 45, 70, 150, 252, 146, 154, 134, 230, 54, 237, 194, 141, 172, 64, 136, 227, 113, 186, 204, 49, 46, 200, 106, 144, 218, 69, 122, 164, 180]), 42), (H256([109, 18, 180, 59, 2, 195, 140, 106, 47, 17, 27, 25, 96, 97, 82, 242, 176, 251, 172, 26, 238, 250, 29, 50, 145, 75, 220, 31, 35, 105, 159, 119]), 189), (H256([184, 238, 30, 176, 29, 182, 63, 86, 164, 230, 161, 133, 89, 138, 205, 247, 146, 53, 186, 226, 221, 109, 244, 241, 52, 97, 87, 243, 47, 133, 176, 187]), 161), (H256([144, 118, 151, 94, 70, 9, 249, 52, 253, 115, 98, 192, 127, 134, 155, 69, 123, 12, 72, 223, 236, 105, 147, 59, 127, 48, 178, 137, 244, 174, 214, 204]), 104), (H256([186, 213, 104, 87, 206, 237, 123, 148, 89, 56, 254, 75, 156, 48, 72, 215, 70, 48, 229, 189, 142, 173, 194, 105, 55, 126, 165, 24, 5, 84, 148, 192]), 183), (H256([47, 36, 101, 5, 152, 197, 232, 105, 185, 238, 138, 243, 137, 74, 214, 164, 53, 101, 124, 233, 187, 84, 215, 248, 53, 172, 29, 227, 31, 122, 66, 54]), 191), (H256([67, 95, 157, 212, 213, 113, 40, 4, 145, 55, 229, 156, 51, 253, 171, 153, 52, 13, 20, 229, 143, 129, 25, 92, 114, 246, 154, 110, 144, 197, 44, 225]), 69), (H256([251, 248, 154, 81, 120, 43, 158, 113, 116, 24, 145, 117, 133, 251, 117, 186, 90, 239, 89, 173, 109, 217, 100, 5, 44, 187, 205, 111, 128, 102, 252, 246]), 3), (H256([233, 196, 193, 19, 141, 218, 186, 113, 44, 113, 66, 80, 230, 42, 124, 238, 31, 130, 42, 201, 67, 177, 67, 171, 169, 81, 234, 61, 153, 208, 47, 193]), 96), (H256([129, 55, 218, 160, 182, 104, 65, 156, 191, 167, 17, 60, 25, 108, 79, 80, 85, 223, 116, 90, 20, 190, 63, 131, 154, 172, 52, 198, 137, 118, 171, 173]), 135), (H256([105, 152, 79, 20, 214, 221, 223, 196, 91, 236, 197, 114, 9, 221, 86, 81, 187, 192, 100, 69, 205, 128, 249, 44, 15, 135, 222, 39, 12, 112, 146, 238]), 219), (H256([68, 141, 171, 252, 104, 66, 136, 8, 216, 83, 247, 36, 218, 53, 223, 166, 177, 201, 1, 227, 91, 125, 150, 126, 63, 0, 200, 36, 8, 124, 197, 113]), 146), (H256([191, 186, 56, 100, 162, 20, 201, 250, 35, 189, 87, 31, 95, 98, 219, 247, 29, 62, 25, 249, 104, 155, 107, 160, 123, 98, 224, 13, 146, 130, 236, 42]), 143), (H256([246, 129, 220, 242, 114, 243, 199, 53, 55, 229, 165, 48, 85, 243, 77, 188, 250, 154, 195, 217, 229, 168, 77, 25, 125, 159, 199, 57, 218, 57, 28, 233]), 130), (H256([95, 138, 144, 56, 178, 103, 59, 34, 191, 70, 10, 248, 66, 213, 140, 20, 6, 3, 240, 157, 196, 15, 226, 80, 11, 199, 191, 3, 79, 87, 94, 183]), 177), (H256([159, 60, 226, 204, 78, 148, 178, 65, 122, 130, 225, 169, 125, 119, 96, 65, 47, 206, 246, 96, 107, 148, 163, 186, 150, 63, 21, 250, 36, 70, 157, 87]), 164), (H256([72, 84, 225, 183, 44, 147, 143, 119, 37, 40, 78, 78, 30, 143, 138, 107, 59, 163, 70, 34, 70, 30, 252, 5, 56, 133, 124, 179, 162, 157, 37, 206]), 127), (H256([3, 132, 214, 48, 237, 112, 134, 238, 105, 168, 33, 134, 132, 133, 96, 4, 1, 151, 232, 139, 248, 94, 194, 194, 40, 72, 98, 219, 161, 92, 191, 47]), 198), (H256([203, 90, 55, 136, 240, 86, 78, 105, 46, 170, 61, 29, 201, 14, 143, 24, 23, 69, 55, 232, 232, 177, 18, 151, 33, 49, 129, 108, 218, 94, 204, 77]), 254), (H256([52, 188, 38, 5, 75, 230, 82, 132, 159, 226, 113, 149, 76, 217, 165, 51, 33, 165, 232, 131, 180, 79, 145, 101, 191, 150, 80, 49, 221, 69, 232, 169]), 255)] diff --git a/proptest-regressions/tests/smt.txt b/proptest-regressions/tests/smt.txt deleted file mode 100644 index c3612a4..0000000 --- a/proptest-regressions/tests/smt.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Seeds for failure cases proptest has generated in the past. It is -# automatically read and these particular cases re-run before any -# novel cases are generated. -# -# It is recommended to check this file in to source control so that -# everyone who runs the test benefits from these saved cases. -cc 6fb322c378fb6c8a2dbfb57bb5745424eff7046fd78bf8570d7935585beba82d # shrinks to key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], value = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] diff --git a/proptest-regressions/tests/tree.txt b/proptest-regressions/tests/tree.txt deleted file mode 100644 index c683e20..0000000 --- a/proptest-regressions/tests/tree.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Seeds for failure cases proptest has generated in the past. It is -# automatically read and these particular cases re-run before any -# novel cases are generated. -# -# It is recommended to check this file in to source control so that -# everyone who runs the test benefits from these saved cases. -cc d16572f0e2f0ca47f3828e01e2782609206c3651a5fc66157e61abf9f0b579bd # shrinks to (pairs, _n) = ([(H256([0, 0, 0, 8, 54, 93, 154, 3, 4, 224, 194, 250, 252, 78, 207, 188, 199, 228, 177, 200, 56, 180, 128, 74, 82, 119, 35, 16, 1, 152, 26, 65]), H256([31, 159, 4, 217, 73, 89, 239, 17, 221, 217, 45, 211, 121, 250, 177, 102, 171, 30, 68, 15, 135, 0, 68, 232, 38, 1, 154, 156, 205, 83, 247, 132])), (H256([98, 116, 16, 107, 128, 211, 82, 10, 57, 222, 35, 94, 152, 133, 47, 101, 210, 201, 249, 250, 177, 158, 118, 10, 25, 36, 244, 199, 207, 72, 202, 4]), H256([214, 146, 190, 187, 66, 164, 77, 91, 123, 235, 62, 230, 183, 190, 163, 184, 43, 113, 92, 207, 173, 53, 135, 236, 205, 171, 244, 184, 35, 0, 96, 51])), (H256([52, 10, 47, 79, 174, 122, 139, 167, 95, 226, 144, 175, 44, 57, 29, 131, 180, 113, 179, 78, 244, 197, 35, 247, 211, 40, 172, 33, 183, 39, 161, 47]), H256([39, 57, 154, 31, 130, 20, 246, 250, 149, 222, 189, 40, 101, 180, 46, 91, 77, 63, 221, 174, 61, 76, 201, 4, 122, 35, 206, 0, 254, 2, 97, 29])), (H256([118, 202, 125, 69, 137, 157, 242, 145, 26, 221, 110, 7, 40, 21, 77, 240, 158, 249, 248, 75, 191, 74, 94, 26, 189, 11, 103, 55, 154, 140, 103, 93]), H256([22, 28, 195, 139, 155, 73, 154, 129, 64, 235, 202, 44, 124, 135, 86, 183, 207, 62, 69, 52, 199, 245, 251, 224, 197, 172, 105, 98, 219, 74, 38, 119])), (H256([121, 33, 131, 77, 41, 187, 228, 202, 243, 84, 141, 95, 192, 246, 42, 81, 52, 101, 146, 239, 132, 225, 4, 208, 247, 133, 196, 93, 116, 161, 90, 10]), H256([14, 99, 39, 78, 12, 138, 214, 108, 19, 127, 244, 121, 7, 45, 132, 234, 151, 124, 149, 234, 114, 183, 44, 186, 57, 130, 16, 211, 9, 37, 41, 204]))], 2) -cc 326aaf45e8f3d10621dd9bb8a1532b11973124d93656463b1a8eed03cdb8b2e1 # shrinks to (leaves, _n) = ([(H256([131, 200, 22, 162, 232, 44, 175, 76, 18, 9, 244, 48, 168, 141, 251, 164, 206, 123, 106, 93, 106, 92, 20, 212, 147, 242, 71, 70, 229, 62, 210, 108]), H256([208, 132, 137, 74, 5, 243, 20, 210, 111, 216, 216, 52, 98, 123, 15, 44, 62, 20, 240, 36, 227, 42, 141, 114, 66, 38, 46, 208, 209, 37, 103, 245])), (H256([16, 86, 179, 40, 246, 238, 43, 205, 118, 152, 196, 79, 208, 88, 150, 228, 138, 8, 130, 189, 115, 238, 52, 34, 249, 54, 199, 229, 37, 158, 133, 102]), H256([14, 21, 212, 10, 104, 251, 67, 56, 76, 1, 208, 68, 78, 39, 136, 252, 199, 51, 26, 124, 22, 250, 236, 224, 184, 64, 212, 112, 8, 115, 111, 60])), (H256([11, 178, 50, 192, 33, 13, 72, 148, 154, 90, 31, 157, 188, 214, 235, 113, 31, 65, 149, 209, 201, 82, 20, 2, 131, 58, 133, 224, 221, 160, 174, 187]), H256([78, 157, 95, 102, 76, 15, 51, 168, 254, 39, 34, 9, 142, 150, 206, 134, 13, 66, 82, 33, 189, 95, 165, 175, 108, 202, 194, 191, 48, 181, 75, 137])), (H256([165, 198, 21, 253, 59, 56, 227, 179, 134, 20, 76, 49, 217, 160, 19, 67, 25, 105, 103, 241, 217, 134, 242, 7, 144, 33, 90, 102, 124, 17, 115, 52]), H256([185, 136, 233, 130, 89, 223, 111, 81, 52, 4, 199, 144, 12, 237, 28, 22, 100, 104, 191, 9, 50, 250, 132, 96, 49, 119, 250, 125, 170, 17, 69, 104])), (H256([151, 37, 51, 186, 186, 112, 252, 167, 19, 2, 75, 34, 207, 115, 148, 249, 236, 118, 253, 17, 204, 244, 180, 79, 142, 36, 61, 58, 162, 195, 4, 47]), H256([213, 78, 218, 82, 38, 39, 195, 230, 102, 106, 55, 121, 125, 195, 28, 233, 116, 225, 162, 80, 235, 48, 62, 224, 51, 220, 203, 30, 9, 145, 2, 117])), (H256([204, 219, 196, 129, 151, 63, 188, 240, 17, 39, 150, 252, 22, 144, 199, 196, 207, 212, 204, 143, 19, 180, 11, 73, 56, 76, 81, 81, 176, 91, 207, 234]), H256([188, 150, 74, 168, 174, 162, 18, 223, 213, 167, 52, 90, 182, 231, 163, 223, 147, 25, 72, 69, 176, 89, 43, 179, 94, 173, 103, 28, 216, 174, 136, 169])), (H256([50, 138, 174, 71, 58, 157, 131, 248, 120, 126, 195, 21, 3, 46, 181, 2, 97, 67, 193, 84, 218, 25, 4, 213, 232, 204, 67, 87, 187, 11, 162, 138]), H256([30, 66, 109, 43, 203, 77, 251, 118, 30, 244, 172, 121, 171, 234, 21, 10, 250, 131, 156, 236, 117, 201, 159, 178, 142, 25, 26, 174, 18, 230, 50, 171])), (H256([23, 255, 127, 207, 88, 126, 247, 121, 28, 245, 176, 77, 236, 146, 165, 48, 230, 203, 152, 89, 120, 74, 65, 239, 89, 109, 163, 87, 55, 208, 86, 236]), H256([17, 96, 202, 19, 22, 231, 151, 232, 52, 50, 79, 75, 61, 98, 54, 97, 130, 243, 167, 135, 3, 125, 76, 2, 247, 190, 42, 87, 228, 47, 111, 11])), (H256([203, 172, 211, 236, 125, 44, 236, 41, 217, 141, 172, 241, 244, 106, 85, 96, 243, 248, 27, 245, 208, 254, 196, 178, 242, 36, 92, 162, 30, 104, 163, 145]), H256([52, 23, 172, 21, 222, 113, 152, 27, 105, 52, 129, 14, 137, 230, 197, 40, 63, 195, 110, 244, 184, 156, 112, 51, 234, 198, 30, 68, 4, 13, 191, 89])), (H256([29, 136, 128, 18, 81, 232, 181, 57, 105, 228, 57, 44, 42, 70, 166, 186, 98, 148, 107, 16, 43, 173, 39, 171, 184, 151, 116, 102, 245, 93, 176, 57]), H256([37, 191, 99, 210, 193, 213, 245, 140, 200, 154, 122, 247, 129, 9, 145, 163, 251, 21, 73, 86, 118, 130, 123, 184, 235, 127, 184, 220, 94, 61, 100, 108])), (H256([106, 133, 236, 120, 193, 10, 90, 162, 49, 193, 180, 75, 78, 215, 100, 224, 113, 84, 72, 49, 82, 64, 34, 109, 0, 11, 46, 80, 56, 235, 203, 9]), H256([150, 55, 86, 222, 130, 167, 154, 81, 126, 101, 108, 82, 234, 212, 145, 113, 79, 221, 58, 250, 48, 210, 4, 42, 253, 5, 191, 58, 85, 30, 102, 152])), (H256([127, 51, 111, 7, 188, 211, 150, 224, 24, 76, 229, 143, 74, 120, 50, 178, 206, 119, 134, 159, 179, 103, 234, 214, 176, 18, 170, 187, 132, 0, 241, 230]), H256([167, 108, 150, 40, 214, 28, 230, 135, 60, 54, 178, 151, 185, 200, 100, 118, 39, 137, 16, 137, 8, 158, 177, 239, 170, 138, 41, 27, 107, 183, 2, 194])), (H256([150, 41, 191, 8, 249, 64, 181, 69, 10, 184, 246, 73, 191, 49, 88, 42, 182, 210, 168, 71, 27, 164, 23, 197, 177, 14, 109, 40, 21, 41, 84, 25]), H256([205, 64, 164, 207, 149, 254, 47, 213, 26, 42, 5, 3, 44, 229, 169, 10, 51, 130, 31, 159, 91, 233, 169, 149, 244, 35, 148, 52, 38, 178, 240, 81])), (H256([218, 35, 227, 38, 9, 12, 151, 196, 141, 223, 215, 7, 196, 15, 49, 196, 103, 196, 215, 188, 56, 203, 212, 181, 247, 233, 225, 54, 24, 181, 68, 0]), H256([167, 37, 28, 34, 216, 210, 211, 119, 183, 210, 210, 242, 23, 119, 40, 220, 44, 144, 255, 175, 141, 15, 197, 75, 10, 109, 3, 143, 240, 3, 22, 25])), (H256([123, 202, 230, 36, 141, 8, 19, 246, 242, 115, 51, 143, 3, 106, 8, 35, 114, 107, 10, 111, 252, 237, 40, 79, 244, 208, 127, 225, 71, 132, 22, 166]), H256([99, 35, 116, 62, 1, 89, 75, 254, 119, 156, 104, 147, 28, 119, 165, 197, 188, 66, 156, 125, 207, 176, 154, 142, 101, 80, 141, 98, 63, 130, 175, 103])), (H256([234, 83, 36, 53, 118, 135, 72, 33, 75, 145, 217, 112, 56, 45, 251, 216, 225, 170, 26, 29, 196, 178, 7, 197, 50, 109, 153, 120, 58, 58, 93, 104]), H256([80, 69, 60, 2, 162, 89, 112, 62, 140, 212, 215, 108, 231, 141, 83, 229, 141, 64, 46, 187, 31, 218, 91, 52, 17, 135, 185, 195, 174, 74, 57, 32])), (H256([90, 249, 148, 21, 107, 69, 17, 194, 148, 232, 183, 175, 154, 241, 242, 141, 74, 224, 54, 236, 175, 108, 175, 137, 133, 152, 2, 211, 179, 119, 36, 237]), H256([229, 99, 190, 79, 230, 30, 141, 226, 202, 186, 128, 54, 239, 212, 17, 174, 180, 26, 140, 240, 224, 3, 180, 175, 96, 102, 16, 196, 231, 121, 69, 4])), (H256([180, 193, 22, 57, 176, 21, 39, 202, 128, 67, 240, 102, 13, 12, 57, 48, 223, 27, 128, 125, 43, 137, 171, 52, 81, 42, 104, 226, 77, 207, 46, 72]), H256([158, 202, 159, 226, 59, 68, 122, 70, 254, 144, 63, 125, 212, 94, 72, 47, 214, 185, 222, 42, 12, 23, 160, 228, 214, 23, 65, 49, 244, 83, 76, 232])), (H256([7, 8, 190, 130, 237, 102, 174, 67, 37, 125, 165, 236, 90, 100, 230, 70, 25, 254, 186, 246, 187, 137, 68, 62, 254, 141, 37, 71, 100, 62, 36, 242]), H256([14, 95, 95, 207, 200, 106, 190, 186, 171, 177, 205, 16, 232, 46, 101, 164, 68, 185, 187, 111, 182, 51, 148, 2, 203, 126, 145, 248, 194, 118, 57, 201])), (H256([199, 179, 221, 10, 62, 199, 159, 25, 216, 237, 186, 187, 218, 221, 181, 55, 155, 46, 26, 4, 103, 81, 213, 142, 17, 245, 51, 71, 209, 201, 79, 158]), H256([158, 139, 222, 24, 203, 61, 251, 225, 250, 196, 198, 8, 72, 172, 37, 99, 198, 183, 76, 53, 111, 133, 136, 121, 145, 68, 38, 46, 48, 222, 4, 20])), (H256([15, 208, 82, 225, 244, 53, 230, 231, 218, 109, 35, 53, 154, 60, 146, 161, 248, 60, 173, 21, 65, 22, 67, 212, 216, 136, 96, 254, 245, 158, 28, 250]), H256([102, 149, 70, 173, 231, 62, 252, 83, 37, 221, 85, 106, 98, 135, 104, 126, 113, 94, 197, 235, 15, 66, 144, 102, 110, 43, 130, 142, 34, 52, 179, 102])), (H256([114, 251, 248, 200, 58, 129, 32, 148, 197, 28, 118, 209, 223, 210, 173, 187, 241, 214, 229, 63, 232, 160, 50, 68, 148, 19, 163, 59, 239, 92, 125, 26]), H256([154, 28, 114, 139, 121, 69, 210, 98, 204, 170, 87, 98, 145, 171, 94, 131, 240, 86, 199, 184, 250, 120, 172, 158, 78, 195, 138, 129, 37, 122, 13, 7])), (H256([167, 233, 241, 130, 90, 140, 149, 215, 82, 160, 32, 210, 53, 9, 61, 89, 236, 150, 110, 128, 140, 88, 134, 81, 238, 112, 205, 221, 230, 70, 141, 242]), H256([147, 170, 42, 206, 29, 189, 203, 227, 250, 201, 229, 157, 181, 97, 210, 2, 210, 136, 111, 64, 107, 29, 54, 19, 36, 180, 228, 222, 233, 228, 225, 56])), (H256([190, 192, 146, 101, 87, 245, 103, 212, 49, 172, 207, 80, 94, 115, 80, 240, 100, 111, 104, 125, 167, 203, 217, 119, 187, 101, 234, 157, 172, 51, 26, 170]), H256([32, 134, 119, 53, 68, 64, 21, 78, 188, 31, 52, 123, 61, 228, 170, 122, 99, 160, 249, 135, 146, 103, 133, 74, 130, 95, 139, 144, 37, 200, 67, 50])), (H256([79, 86, 105, 21, 185, 23, 141, 50, 42, 143, 75, 111, 0, 240, 147, 174, 219, 208, 231, 37, 209, 143, 233, 84, 78, 244, 87, 45, 188, 12, 101, 48]), H256([173, 234, 101, 179, 63, 35, 222, 85, 195, 69, 244, 112, 81, 56, 17, 40, 138, 56, 34, 131, 198, 252, 207, 54, 206, 165, 45, 247, 100, 144, 110, 17])), (H256([119, 125, 226, 0, 90, 219, 62, 88, 193, 156, 194, 222, 7, 148, 206, 52, 214, 137, 67, 173, 3, 106, 97, 16, 220, 241, 34, 130, 134, 152, 191, 46]), H256([99, 159, 122, 48, 160, 86, 190, 4, 39, 59, 227, 128, 28, 75, 54, 234, 248, 193, 86, 169, 137, 188, 237, 198, 224, 12, 6, 241, 143, 222, 37, 89])), (H256([155, 19, 172, 224, 167, 120, 191, 131, 86, 141, 215, 51, 30, 14, 232, 171, 96, 206, 181, 254, 222, 73, 84, 194, 92, 47, 56, 228, 85, 255, 149, 144]), H256([174, 16, 228, 143, 213, 120, 193, 60, 26, 101, 233, 88, 171, 143, 189, 198, 102, 166, 95, 40, 165, 113, 150, 157, 183, 217, 147, 41, 147, 55, 174, 243])), (H256([119, 232, 242, 223, 52, 165, 237, 210, 229, 134, 74, 118, 180, 121, 2, 179, 161, 90, 66, 203, 96, 168, 153, 114, 206, 15, 138, 239, 230, 66, 6, 171]), H256([230, 44, 132, 245, 15, 52, 0, 234, 74, 159, 28, 69, 21, 12, 44, 222, 177, 144, 80, 73, 156, 66, 198, 181, 227, 67, 63, 119, 122, 210, 96, 111])), (H256([48, 233, 217, 209, 42, 117, 198, 180, 52, 207, 78, 32, 229, 159, 204, 250, 189, 185, 54, 83, 237, 173, 99, 51, 162, 93, 122, 233, 15, 247, 17, 134]), H256([60, 129, 47, 44, 230, 242, 100, 252, 117, 208, 133, 205, 12, 192, 249, 195, 89, 242, 63, 203, 178, 187, 216, 190, 130, 31, 143, 93, 85, 232, 98, 156])), (H256([114, 148, 179, 209, 189, 137, 74, 176, 124, 241, 141, 68, 151, 61, 115, 195, 150, 16, 205, 26, 167, 153, 55, 191, 87, 104, 174, 226, 43, 113, 26, 238]), H256([27, 92, 210, 162, 172, 244, 63, 27, 48, 20, 224, 145, 222, 225, 210, 144, 126, 188, 26, 151, 134, 155, 154, 103, 232, 71, 130, 102, 246, 15, 65, 242]))], 1), leaves_bitmap = [H256([238, 152, 205, 60, 1, 206, 109, 90, 177, 49, 43, 226, 193, 92, 44, 206, 202, 157, 241, 184, 63, 117, 172, 133, 221, 3, 37, 26, 57, 4, 48, 87]), H256([240, 249, 208, 179, 93, 225, 93, 44, 86, 199, 217, 199, 41, 47, 121, 52, 231, 241, 227, 207, 90, 26, 107, 7, 132, 233, 5, 71, 98, 125, 211, 38]), H256([87, 178, 144, 86, 210, 208, 226, 68, 8, 163, 35, 43, 242, 79, 212, 3, 128, 72, 245, 229, 32, 111, 3, 142, 23, 175, 156, 47, 233, 98, 204, 20]), H256([153, 168, 145, 136, 47, 217, 153, 201, 193, 239, 210, 230, 199, 97, 18, 152, 186, 170, 117, 30, 126, 78, 174, 175, 214, 143, 102, 10, 30, 89, 202, 234]), H256([135, 238, 220, 1, 3, 74, 174, 28, 48, 176, 239, 41, 76, 199, 66, 62, 0, 83, 66, 119, 196, 210, 251, 206, 45, 94, 215, 235, 177, 205, 50, 149]), H256([214, 137, 46, 88, 155, 206, 20, 202, 200, 202, 171, 5, 37, 148, 146, 65, 133, 86, 236, 30, 36, 146, 51, 237, 12, 16, 99, 63, 54, 228, 184, 109]), H256([15, 158, 68, 218, 128, 115, 76, 72, 171, 59, 160, 156, 198, 119, 170, 59, 115, 155, 89, 53, 197, 248, 93, 134, 46, 0, 132, 73, 250, 254, 104, 49]), H256([36, 79, 182, 59, 163, 81, 209, 77, 178, 94, 82, 171, 92, 154, 140, 230, 40, 242, 46, 39, 212, 202, 238, 77, 189, 175, 104, 182, 65, 121, 193, 226]), H256([95, 43, 171, 213, 216, 118, 35, 157, 91, 219, 88, 62, 68, 17, 44, 52, 14, 21, 140, 65, 228, 43, 86, 240, 6, 141, 133, 129, 198, 231, 120, 242]), H256([4, 151, 157, 124, 21, 93, 113, 162, 219, 69, 160, 128, 186, 69, 7, 236, 5, 197, 9, 104, 34, 174, 120, 190, 60, 45, 177, 228, 26, 79, 114, 103]), H256([92, 51, 4, 164, 40, 103, 150, 54, 173, 118, 48, 253, 252, 60, 169, 188, 11, 78, 129, 151, 222, 70, 161, 121, 210, 25, 255, 93, 145, 245, 189, 220]), H256([214, 246, 187, 61, 108, 144, 24, 35, 1, 253, 87, 125, 158, 150, 105, 245, 229, 68, 162, 214, 3, 38, 106, 144, 121, 197, 233, 164, 241, 27, 46, 95]), H256([43, 56, 251, 252, 228, 173, 170, 19, 70, 25, 65, 63, 1, 131, 141, 4, 171, 240, 136, 130, 39, 97, 175, 160, 42, 183, 89, 58, 15, 177, 174, 46]), H256([19, 85, 170, 184, 178, 60, 73, 134, 216, 224, 7, 96, 150, 50, 187, 143, 114, 62, 155, 229, 37, 110, 54, 110, 55, 111, 87, 212, 45, 190, 164, 47]), H256([50, 19, 158, 68, 140, 182, 121, 192, 71, 74, 141, 243, 236, 127, 43, 101, 165, 127, 249, 96, 158, 67, 212, 152, 165, 115, 247, 98, 101, 228, 74, 170]), H256([4, 139, 30, 249, 149, 38, 230, 27, 129, 127, 224, 57, 128, 69, 17, 173, 181, 41, 30, 102, 208, 214, 223, 69, 22, 218, 139, 47, 215, 208, 160, 217]), H256([22, 33, 221, 24, 246, 53, 113, 200, 14, 49, 195, 90, 197, 56, 79, 218, 167, 126, 144, 170, 70, 190, 31, 85, 154, 244, 175, 161, 139, 128, 114, 185]), H256([212, 11, 207, 42, 253, 5, 202, 235, 13, 62, 79, 67, 207, 15, 167, 100, 96, 94, 5, 86, 151, 79, 133, 88, 240, 16, 151, 188, 96, 165, 119, 238]), H256([214, 115, 73, 47, 240, 33, 156, 80, 138, 64, 78, 83, 182, 198, 178, 75, 84, 143, 177, 129, 11, 252, 134, 144, 122, 233, 129, 103, 205, 156, 48, 220]), H256([59, 232, 190, 246, 182, 134, 141, 38, 176, 54, 152, 1, 225, 191, 123, 217, 101, 60, 146, 145, 179, 86, 135, 87, 221, 11, 244, 71, 120, 95, 214, 208]), H256([202, 242, 226, 117, 223, 159, 250, 32, 163, 87, 91, 121, 79, 8, 17, 84, 166, 42, 165, 142, 14, 56, 53, 25, 107, 255, 44, 9, 242, 51, 28, 9]), H256([33, 139, 204, 243, 189, 122, 158, 13, 53, 7, 173, 210, 210, 62, 226, 71, 163, 157, 219, 233, 206, 114, 35, 182, 226, 188, 52, 78, 49, 7, 16, 210]), H256([64, 66, 190, 91, 113, 105, 237, 46, 109, 112, 142, 55, 36, 106, 21, 71, 224, 106, 25, 183, 115, 19, 139, 62, 35, 115, 60, 230, 167, 34, 92, 59]), H256([83, 37, 121, 8, 154, 79, 67, 140, 161, 167, 116, 200, 219, 101, 101, 230, 28, 135, 165, 38, 146, 80, 75, 17, 45, 40, 81, 220, 200, 47, 194, 61]), H256([66, 124, 218, 42, 93, 220, 11, 220, 183, 144, 217, 118, 193, 154, 120, 197, 192, 73, 53, 130, 80, 160, 87, 102, 65, 132, 100, 5, 236, 25, 108, 157]), H256([33, 104, 205, 158, 245, 178, 80, 44, 132, 241, 75, 210, 38, 33, 0, 161, 245, 57, 12, 176, 14, 65, 98, 79, 204, 94, 164, 134, 197, 82, 88, 193]), H256([53, 233, 115, 101, 80, 153, 135, 195, 20, 2, 20, 151, 135, 147, 137, 7, 217, 253, 234, 204, 73, 115, 35, 197, 198, 102, 67, 147, 113, 123, 246, 61]), H256([135, 255, 39, 13, 24, 137, 8, 40, 93, 241, 5, 12, 242, 211, 163, 166, 244, 112, 121, 207, 47, 15, 199, 86, 235, 121, 70, 91, 160, 22, 159, 10]), H256([190, 108, 16, 156, 171, 52, 126, 133, 27, 164, 18, 115, 243, 168, 123, 18, 142, 247, 197, 26, 7, 178, 219, 231, 107, 11, 66, 223, 186, 190, 24, 204]), H256([126, 170, 93, 175, 181, 238, 5, 67, 86, 64, 39, 143, 193, 143, 97, 20, 19, 74, 184, 75, 32, 2, 173, 75, 228, 141, 26, 153, 211, 37, 140, 40])], proof = [H256([107, 130, 202, 80, 100, 58, 234, 6, 194, 254, 98, 71, 174, 219, 215, 73, 208, 232, 139, 85, 88, 77, 242, 27, 58, 147, 85, 151, 23, 220, 251, 196]), H256([0, 176, 249, 193, 96, 35, 111, 81, 113, 130, 91, 208, 214, 227, 68, 132, 190, 148, 255, 81, 145, 233, 84, 109, 9, 142, 97, 105, 234, 85, 41, 6]), H256([72, 185, 76, 100, 63, 161, 107, 138, 2, 185, 138, 87, 222, 13, 138, 215, 25, 36, 255, 23, 151, 233, 217, 250, 116, 23, 165, 145, 182, 92, 63, 138]), H256([210, 32, 243, 180, 14, 150, 143, 237, 142, 216, 13, 68, 167, 87, 172, 182, 112, 235, 49, 185, 18, 210, 67, 77, 59, 104, 2, 225, 174, 84, 117, 244]), H256([68, 255, 26, 137, 57, 76, 81, 14, 11, 197, 56, 124, 50, 183, 198, 51, 255, 140, 172, 104, 159, 64, 60, 24, 250, 51, 96, 147, 230, 50, 179, 22]), H256([136, 72, 196, 236, 49, 52, 193, 198, 235, 170, 24, 213, 25, 58, 62, 110, 48, 126, 136, 150, 42, 147, 138, 13, 230, 95, 153, 157, 224, 66, 56, 58]), H256([130, 160, 237, 244, 136, 65, 114, 175, 182, 243, 208, 15, 182, 244, 229, 162, 64, 61, 192, 108, 158, 211, 229, 228, 240, 128, 231, 11, 77, 135, 196, 16]), H256([116, 9, 206, 229, 218, 62, 228, 1, 217, 182, 209, 205, 62, 212, 26, 94, 73, 22, 31, 32, 218, 124, 131, 204, 154, 156, 233, 24, 92, 199, 73, 114]), H256([93, 141, 113, 5, 131, 237, 223, 25, 198, 30, 241, 213, 175, 211, 127, 16, 53, 92, 205, 114, 238, 206, 211, 181, 21, 115, 39, 23, 2, 121, 42, 127]), H256([38, 246, 194, 131, 209, 189, 7, 53, 233, 1, 242, 87, 82, 202, 46, 142, 148, 235, 184, 59, 214, 1, 113, 239, 253, 25, 95, 137, 131, 217, 244, 1]), H256([213, 247, 150, 144, 171, 1, 10, 144, 194, 246, 204, 198, 37, 23, 79, 214, 112, 5, 235, 176, 9, 119, 100, 136, 168, 251, 148, 252, 212, 146, 223, 145]), H256([101, 31, 98, 86, 42, 38, 152, 108, 88, 59, 181, 29, 45, 13, 73, 234, 181, 224, 241, 251, 97, 27, 193, 89, 60, 159, 73, 76, 133, 49, 167, 251]), H256([194, 209, 108, 87, 21, 144, 73, 121, 126, 103, 198, 129, 211, 191, 44, 223, 8, 239, 235, 50, 33, 112, 37, 56, 220, 227, 210, 57, 142, 120, 5, 78]), H256([229, 110, 86, 45, 98, 218, 64, 3, 114, 177, 138, 252, 178, 197, 42, 242, 116, 138, 201, 48, 125, 132, 62, 184, 115, 29, 140, 57, 116, 164, 152, 183]), H256([172, 165, 170, 60, 109, 49, 94, 173, 211, 179, 221, 235, 198, 53, 1, 31, 142, 167, 253, 251, 193, 69, 54, 50, 230, 159, 171, 221, 32, 54, 219, 186]), H256([247, 131, 199, 249, 99, 231, 145, 171, 94, 143, 101, 35, 200, 172, 25, 4, 216, 177, 207, 132, 53, 224, 149, 135, 44, 240, 246, 22, 152, 248, 188, 83]), H256([154, 139, 69, 7, 128, 235, 88, 73, 71, 107, 44, 73, 101, 4, 255, 49, 252, 232, 0, 31, 102, 66, 102, 102, 187, 138, 225, 200, 164, 237, 69, 222]), H256([181, 212, 74, 52, 111, 43, 86, 92, 128, 185, 90, 192, 105, 223, 213, 134, 228, 79, 48, 144, 150, 125, 146, 171, 203, 81, 240, 70, 232, 220, 229, 193]), H256([92, 255, 191, 106, 126, 163, 118, 1, 172, 121, 62, 169, 1, 136, 3, 28, 44, 130, 167, 89, 64, 253, 175, 224, 12, 100, 96, 71, 227, 23, 133, 152]), H256([66, 67, 9, 247, 89, 125, 50, 83, 29, 248, 91, 211, 77, 240, 70, 139, 148, 146, 138, 65, 85, 38, 81, 96, 201, 46, 103, 184, 99, 153, 78, 174]), H256([144, 188, 129, 15, 183, 102, 96, 222, 33, 181, 144, 1, 27, 178, 82, 16, 128, 17, 112, 211, 47, 204, 251, 131, 12, 172, 177, 52, 240, 144, 234, 142]), H256([174, 250, 186, 37, 80, 201, 165, 21, 40, 135, 194, 201, 152, 151, 81, 206, 10, 156, 132, 164, 95, 200, 44, 94, 196, 18, 21, 161, 50, 145, 20, 112]), H256([58, 93, 162, 37, 104, 162, 209, 227, 17, 54, 25, 124, 249, 12, 214, 149, 212, 84, 244, 80, 71, 199, 201, 23, 29, 252, 170, 71, 176, 30, 149, 89]), H256([215, 10, 119, 114, 34, 5, 188, 248, 206, 24, 188, 163, 18, 42, 156, 157, 152, 8, 26, 10, 120, 11, 242, 85, 240, 243, 51, 239, 251, 235, 62, 43]), H256([2, 251, 83, 101, 65, 10, 244, 177, 45, 1, 72, 221, 155, 213, 226, 208, 170, 238, 200, 12, 60, 0, 115, 222, 80, 198, 63, 30, 10, 239, 157, 109]), H256([179, 21, 208, 151, 16, 29, 213, 4, 167, 233, 44, 217, 164, 120, 122, 204, 204, 236, 152, 126, 154, 209, 137, 168, 138, 169, 175, 136, 243, 113, 238, 191]), H256([125, 188, 20, 95, 117, 97, 174, 11, 205, 207, 121, 168, 12, 133, 13, 117, 16, 175, 181, 183, 211, 53, 15, 229, 244, 197, 73, 28, 34, 170, 215, 228]), H256([54, 37, 196, 109, 114, 27, 171, 121, 44, 97, 10, 222, 11, 74, 75, 231, 76, 111, 202, 175, 175, 163, 175, 55, 28, 86, 154, 1, 184, 25, 34, 26]), H256([66, 66, 96, 209, 205, 195, 123, 11, 224, 105, 105, 107, 18, 57, 210, 193, 97, 250, 70, 141, 93, 185, 244, 232, 98, 147, 138, 63, 134, 219, 26, 41]), H256([161, 27, 101, 204, 102, 243, 56, 24, 19, 237, 183, 39, 251, 191, 184, 161, 130, 139, 212, 95, 8, 166, 208, 20, 2, 180, 67, 237, 193, 159, 176, 38]), H256([71, 55, 152, 180, 132, 153, 72, 206, 192, 107, 0, 212, 198, 192, 41, 239, 130, 129, 248, 96, 199, 217, 235, 113, 213, 168, 226, 101, 191, 142, 112, 168]), H256([20, 94, 218, 167, 169, 68, 91, 15, 1, 114, 248, 142, 179, 240, 132, 113, 9, 164, 101, 37, 161, 184, 239, 214, 33, 37, 231, 20, 37, 164, 198, 155]), H256([144, 183, 250, 19, 239, 35, 239, 2, 118, 237, 224, 180, 234, 45, 153, 24, 71, 195, 77, 108, 36, 171, 54, 197, 79, 120, 104, 157, 73, 159, 162, 190]), H256([227, 110, 153, 19, 190, 235, 19, 34, 225, 129, 156, 93, 26, 123, 19, 222, 148, 58, 20, 142, 229, 26, 168, 98, 77, 183, 164, 206, 213, 163, 129, 147]), H256([117, 176, 174, 251, 195, 246, 2, 190, 76, 212, 203, 27, 41, 104, 138, 180, 111, 117, 219, 176, 212, 175, 34, 82, 115, 125, 91, 27, 227, 225, 133, 24]), H256([183, 78, 147, 90, 118, 99, 205, 84, 4, 59, 244, 241, 217, 158, 132, 64, 120, 175, 151, 144, 55, 104, 180, 80, 37, 64, 101, 182, 53, 165, 205, 27]), H256([255, 72, 155, 28, 35, 153, 132, 210, 179, 224, 223, 230, 21, 226, 93, 246, 248, 230, 87, 67, 194, 24, 72, 192, 136, 200, 159, 113, 64, 50, 171, 224]), H256([103, 67, 33, 52, 209, 145, 139, 90, 99, 69, 89, 148, 108, 239, 226, 143, 131, 103, 149, 130, 78, 209, 191, 79, 186, 5, 1, 154, 109, 37, 223, 43]), H256([156, 40, 183, 157, 34, 42, 168, 250, 19, 243, 169, 110, 216, 83, 199, 236, 202, 240, 183, 12, 125, 193, 110, 240, 172, 24, 195, 131, 101, 88, 225, 249]), H256([17, 171, 38, 59, 158, 110, 242, 26, 86, 147, 106, 65, 199, 59, 121, 186, 114, 81, 82, 38, 4, 165, 63, 73, 73, 249, 54, 112, 232, 39, 58, 72]), H256([11, 146, 235, 60, 8, 106, 217, 243, 96, 20, 247, 141, 130, 240, 73, 64, 85, 223, 140, 107, 202, 74, 99, 51, 175, 160, 168, 71, 217, 250, 168, 116]), H256([131, 133, 47, 101, 170, 213, 119, 77, 201, 178, 197, 190, 47, 116, 24, 96, 5, 2, 246, 225, 232, 214, 6, 14, 128, 253, 188, 201, 9, 126, 150, 53]), H256([139, 41, 254, 218, 125, 173, 0, 40, 122, 108, 49, 208, 39, 98, 239, 98, 246, 113, 15, 24, 161, 81, 86, 111, 212, 76, 66, 31, 6, 216, 180, 157]), H256([126, 171, 99, 111, 23, 6, 3, 187, 154, 181, 192, 171, 11, 180, 204, 234, 250, 192, 213, 248, 185, 14, 91, 124, 207, 221, 172, 100, 220, 11, 154, 197]), H256([254, 177, 209, 59, 129, 122, 249, 58, 204, 22, 219, 51, 31, 178, 211, 74, 97, 117, 179, 233, 114, 148, 71, 131, 127, 31, 97, 35, 107, 108, 126, 165]), H256([159, 56, 43, 226, 241, 91, 73, 198, 29, 240, 114, 181, 59, 154, 98, 30, 173, 51, 96, 109, 111, 75, 143, 7, 46, 6, 220, 52, 63, 4, 34, 198]), H256([15, 109, 24, 93, 147, 217, 35, 69, 130, 138, 162, 104, 150, 62, 40, 7, 214, 150, 156, 194, 59, 113, 136, 131, 113, 239, 88, 197, 69, 210, 103, 181]), H256([28, 36, 211, 162, 35, 97, 117, 139, 148, 103, 255, 145, 165, 154, 107, 107, 255, 185, 50, 2, 131, 127, 144, 126, 163, 131, 36, 3, 184, 19, 101, 131]), H256([183, 168, 92, 210, 177, 66, 92, 252, 171, 127, 53, 230, 35, 236, 36, 127, 80, 68, 34, 133, 167, 92, 16, 116, 58, 152, 174, 92, 108, 127, 183, 13]), H256([105, 161, 138, 138, 56, 158, 93, 109, 0, 5, 20, 242, 200, 209, 187, 117, 39, 62, 172, 203, 57, 64, 174, 181, 184, 195, 132, 18, 121, 78, 241, 25])] -cc 0cce2ecd4386934fbf1fecf6994084f842cd446cb23c115c6a0f8a335d77d745 # shrinks to (pairs, _n) = ([(H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))], 1), (pairs2, _n2) = ([(H256([0, 0, 28, 19, 98, 176, 95, 98, 231, 175, 209, 146, 218, 126, 131, 62, 165, 198, 86, 162, 222, 242, 3, 154, 216, 186, 30, 16, 18, 58, 22, 0]), H256([12, 62, 243, 56, 6, 170, 148, 6, 255, 124, 27, 177, 4, 19, 173, 8, 192, 190, 3, 204, 238, 221, 199, 3, 224, 97, 74, 85, 218, 34, 195, 143])), (H256([136, 70, 6, 121, 82, 245, 222, 236, 217, 227, 7, 222, 6, 57, 141, 228, 126, 83, 116, 156, 7, 244, 144, 6, 142, 155, 104, 75, 87, 158, 109, 80]), H256([120, 94, 121, 42, 43, 185, 121, 215, 19, 188, 112, 111, 16, 124, 59, 43, 189, 203, 55, 192, 159, 233, 56, 217, 126, 150, 113, 232, 27, 66, 255, 10]))], 1) -cc 2ce7bcdfa66c14e553b2deedb21898a9a9189e6231593450410d5b9218b6947a # shrinks to (pairs, _n) = ([(H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))], 1), (pairs2, _n2) = ([(H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), H256([57, 15, 70, 126, 113, 19, 1, 153, 21, 132, 251, 4, 170, 27, 188, 68, 129, 71, 7, 122, 87, 244, 229, 152, 108, 242, 178, 132, 186, 39, 33, 0]))], 1) -cc ab275db7575201ad1e0b2f7f451e8acfe9af8512424a870021f4f39ea9bea273 # shrinks to (pairs, _n) = ([(H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110]), H256([0, 0, 0, 0, 0, 13, 201, 127, 12, 192, 143, 123, 190, 37, 17, 100, 63, 164, 208, 167, 243, 52, 122, 47, 182, 52, 234, 246, 179, 166, 246, 144]))], 1), (pairs2, _n2) = ([(H256([204, 74, 0, 146, 96, 195, 233, 44, 167, 38, 29, 40, 7, 186, 111, 207, 228, 143, 63, 245, 155, 193, 150, 181, 105, 174, 191, 244, 62, 3, 207, 109]), H256([93, 221, 131, 89, 167, 18, 128, 73, 41, 200, 163, 54, 240, 94, 38, 153, 8, 214, 182, 255, 74, 142, 159, 225, 79, 144, 11, 192, 124, 65, 67, 102])), (H256([242, 89, 32, 112, 131, 136, 50, 3, 56, 218, 110, 56, 126, 181, 146, 5, 199, 223, 115, 55, 40, 66, 111, 90, 1, 101, 84, 95, 89, 2, 136, 251]), H256([29, 70, 220, 77, 38, 10, 36, 127, 210, 208, 158, 168, 133, 143, 158, 211, 16, 242, 192, 17, 37, 153, 220, 87, 225, 126, 132, 2, 156, 196, 143, 44])), (H256([66, 53, 129, 105, 48, 135, 47, 223, 203, 152, 89, 162, 2, 141, 70, 241, 55, 58, 1, 126, 209, 106, 185, 46, 203, 151, 65, 16, 62, 191, 83, 130]), H256([223, 213, 169, 118, 201, 153, 134, 158, 37, 200, 132, 117, 195, 198, 230, 207, 74, 124, 206, 240, 114, 81, 65, 225, 132, 213, 126, 174, 173, 118, 212, 104])), (H256([31, 14, 190, 4, 99, 34, 86, 235, 51, 84, 18, 128, 59, 185, 180, 116, 216, 179, 224, 140, 205, 212, 179, 211, 172, 102, 243, 60, 223, 115, 50, 0]), H256([34, 8, 245, 65, 65, 116, 157, 61, 132, 192, 212, 80, 9, 15, 47, 89, 138, 187, 225, 252, 59, 147, 239, 43, 86, 156, 250, 127, 159, 89, 158, 127])), (H256([50, 81, 48, 127, 132, 3, 7, 102, 235, 210, 104, 8, 148, 6, 205, 157, 207, 152, 182, 93, 64, 231, 17, 237, 26, 208, 111, 226, 78, 90, 183, 11]), H256([14, 153, 220, 127, 146, 78, 163, 131, 226, 219, 195, 46, 150, 176, 41, 117, 193, 33, 55, 176, 4, 78, 160, 169, 75, 49, 78, 231, 6, 35, 2, 88]))], 2) -cc 0d9207ede35b7a90a744133ee2d39d21bff873ecee220a6487a97bd80a3645c2 # shrinks to (pairs, _n) = ([(H256([81, 177, 205, 193, 25, 205, 35, 200, 97, 131, 56, 125, 126, 214, 161, 209, 45, 109, 20, 164, 43, 137, 143, 68, 120, 11, 153, 101, 176, 82, 79, 189]), H256([28, 135, 246, 251, 237, 201, 88, 248, 221, 139, 98, 164, 25, 40, 111, 84, 20, 62, 13, 129, 63, 9, 134, 160, 35, 101, 52, 195, 51, 63, 25, 3])), (H256([13, 31, 140, 221, 242, 98, 128, 212, 147, 117, 231, 12, 35, 62, 129, 209, 163, 219, 73, 194, 153, 102, 89, 238, 198, 177, 75, 15, 21, 24, 74, 133]), H256([120, 35, 10, 62, 49, 227, 251, 224, 16, 177, 123, 122, 220, 30, 109, 177, 19, 218, 67, 201, 141, 124, 104, 234, 157, 66, 153, 216, 76, 103, 246, 47])), (H256([125, 188, 241, 10, 144, 38, 192, 143, 209, 236, 174, 29, 82, 13, 121, 16, 49, 254, 67, 204, 8, 184, 188, 77, 69, 201, 55, 112, 212, 248, 114, 132]), H256([4, 173, 47, 177, 154, 160, 205, 249, 91, 231, 162, 240, 245, 43, 215, 35, 152, 34, 184, 51, 214, 36, 216, 252, 204, 123, 213, 61, 34, 156, 209, 181])), (H256([209, 210, 196, 56, 99, 7, 51, 147, 217, 72, 141, 243, 80, 221, 101, 157, 105, 97, 108, 135, 39, 125, 67, 62, 135, 121, 167, 69, 73, 19, 134, 114]), H256([191, 103, 214, 58, 255, 236, 27, 251, 54, 24, 173, 164, 122, 140, 61, 239, 185, 91, 221, 178, 198, 55, 189, 9, 196, 219, 16, 29, 62, 133, 95, 10]))], 1), (pairs2, _n2) = ([(H256([170, 219, 4, 148, 78, 252, 96, 210, 24, 142, 64, 139, 150, 134, 200, 137, 150, 45, 2, 241, 199, 86, 17, 142, 238, 5, 233, 217, 203, 13, 173, 31]), H256([45, 221, 65, 118, 79, 65, 191, 96, 182, 195, 226, 79, 195, 187, 140, 83, 33, 242, 252, 173, 205, 60, 98, 249, 126, 126, 18, 186, 115, 121, 73, 251])), (H256([117, 133, 199, 179, 128, 129, 96, 180, 188, 200, 198, 125, 241, 91, 79, 140, 92, 14, 158, 208, 29, 172, 123, 183, 204, 242, 51, 102, 233, 216, 241, 236]), H256([249, 56, 170, 3, 60, 92, 162, 75, 191, 20, 119, 82, 137, 174, 208, 243, 247, 52, 38, 193, 145, 134, 83, 48, 254, 137, 111, 172, 137, 239, 130, 180])), (H256([212, 152, 131, 201, 252, 104, 190, 145, 2, 245, 10, 23, 168, 93, 34, 35, 56, 9, 78, 45, 148, 203, 221, 132, 217, 20, 52, 172, 158, 115, 240, 132]), H256([102, 11, 230, 73, 184, 37, 32, 188, 165, 58, 51, 125, 122, 143, 190, 169, 166, 77, 96, 21, 15, 220, 205, 139, 53, 11, 219, 249, 200, 56, 66, 242])), (H256([197, 191, 104, 120, 153, 73, 102, 134, 109, 87, 71, 155, 231, 219, 200, 253, 255, 161, 185, 68, 138, 104, 8, 60, 125, 5, 213, 106, 137, 164, 103, 230]), H256([81, 32, 173, 55, 59, 158, 38, 252, 64, 220, 24, 184, 100, 249, 58, 7, 22, 164, 72, 31, 154, 189, 168, 75, 40, 117, 191, 52, 125, 82, 13, 208])), (H256([121, 98, 128, 132, 198, 101, 244, 156, 165, 57, 116, 97, 4, 92, 181, 96, 121, 99, 74, 152, 58, 45, 139, 63, 41, 6, 210, 200, 74, 85, 227, 244]), H256([121, 212, 121, 63, 74, 95, 90, 133, 106, 172, 130, 226, 117, 168, 62, 237, 191, 184, 146, 193, 109, 217, 244, 57, 190, 94, 2, 84, 206, 163, 18, 113]))], 2) -cc 98ff489f3b7556e2d46b0a23b056b2fa89ae1d1f7a312ebcf8637f7d3425c00f # shrinks to (pairs, n) = ([(H256([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 206, 24, 134, 132]), H256([147, 108, 192, 109, 74, 230, 227, 79, 212, 17, 222, 190, 49, 214, 183, 12, 216, 162, 191, 151, 231, 218, 145, 178, 5, 77, 89, 48, 98, 46, 178, 58])), (H256([115, 249, 148, 158, 42, 219, 157, 50, 51, 111, 29, 79, 167, 253, 105, 127, 233, 37, 25, 51, 245, 73, 183, 61, 39, 216, 39, 108, 13, 141, 79, 135]), H256([89, 230, 227, 207, 80, 18, 69, 197, 35, 126, 16, 251, 93, 229, 247, 101, 39, 255, 98, 153, 40, 250, 35, 129, 39, 224, 193, 241, 168, 40, 68, 88]))], 2) -cc 8a54e42479b4b1058c6d99f1b5bd00e3c3fa91c8221913ad0c383c93ea1de7ab # shrinks to (pairs, _n) = ([(H256([113, 85, 231, 60, 226, 216, 216, 190, 115, 158, 194, 69, 23, 203, 212, 104, 155, 170, 17, 7, 187, 8, 178, 156, 102, 155, 151, 201, 206, 208, 85, 231]), H256([139, 81, 229, 184, 15, 83, 238, 69, 65, 217, 72, 205, 200, 178, 227, 84, 112, 69, 25, 236, 91, 178, 208, 204, 31, 66, 137, 66, 54, 97, 183, 198])), (H256([239, 188, 74, 208, 72, 230, 69, 151, 61, 255, 250, 217, 99, 69, 133, 190, 220, 99, 204, 95, 63, 112, 217, 209, 116, 131, 112, 220, 9, 147, 255, 2]), H256([8, 210, 39, 14, 197, 64, 233, 93, 7, 72, 32, 191, 182, 156, 143, 205, 170, 156, 195, 178, 134, 210, 68, 222, 211, 43, 232, 194, 146, 150, 153, 115])), (H256([244, 84, 79, 36, 91, 197, 69, 81, 39, 50, 36, 10, 61, 70, 80, 214, 66, 169, 230, 29, 240, 233, 224, 118, 156, 51, 69, 169, 197, 226, 65, 127]), H256([156, 179, 215, 13, 129, 12, 73, 32, 75, 124, 86, 16, 70, 101, 51, 155, 241, 160, 49, 72, 83, 37, 161, 221, 197, 138, 71, 38, 173, 66, 14, 211])), (H256([44, 140, 170, 179, 61, 31, 94, 68, 27, 197, 244, 20, 43, 152, 172, 128, 37, 52, 233, 114, 239, 207, 135, 5, 176, 89, 247, 241, 14, 154, 16, 212]), H256([143, 253, 51, 224, 84, 164, 201, 116, 178, 77, 131, 19, 131, 76, 103, 80, 150, 195, 233, 116, 223, 124, 205, 225, 111, 102, 138, 96, 72, 42, 187, 9])), (H256([146, 244, 109, 156, 186, 30, 49, 131, 225, 166, 68, 42, 47, 20, 142, 163, 56, 96, 177, 141, 175, 254, 172, 26, 146, 199, 218, 67, 59, 39, 191, 22]), H256([48, 238, 113, 82, 83, 182, 50, 12, 188, 12, 140, 60, 17, 184, 104, 60, 63, 57, 228, 7, 183, 169, 16, 209, 145, 48, 194, 79, 160, 200, 227, 91])), (H256([177, 167, 201, 39, 216, 213, 102, 48, 80, 108, 172, 16, 50, 232, 17, 35, 206, 18, 0, 82, 119, 196, 158, 155, 167, 49, 99, 196, 13, 220, 203, 221]), H256([247, 63, 212, 135, 102, 137, 105, 1, 98, 218, 105, 252, 208, 79, 187, 205, 170, 210, 113, 87, 34, 230, 249, 154, 58, 98, 61, 153, 44, 113, 20, 98])), (H256([2, 162, 213, 193, 193, 88, 186, 133, 79, 88, 37, 194, 196, 87, 57, 241, 20, 149, 248, 171, 177, 180, 144, 210, 68, 60, 255, 106, 52, 9, 245, 14]), H256([92, 39, 247, 201, 244, 171, 52, 79, 90, 2, 111, 0, 97, 157, 203, 68, 93, 54, 142, 105, 248, 55, 166, 46, 134, 182, 214, 235, 160, 20, 127, 225])), (H256([213, 99, 171, 178, 16, 37, 38, 42, 253, 136, 193, 181, 19, 21, 9, 231, 243, 117, 135, 95, 184, 238, 81, 217, 134, 54, 62, 58, 36, 211, 211, 198]), H256([195, 152, 146, 186, 234, 86, 105, 111, 108, 46, 1, 7, 20, 217, 202, 203, 83, 40, 25, 65, 226, 42, 53, 45, 33, 195, 163, 173, 114, 190, 67, 241])), (H256([81, 65, 175, 64, 168, 162, 249, 9, 93, 71, 247, 78, 146, 189, 48, 1, 101, 7, 208, 4, 230, 197, 165, 86, 90, 178, 83, 24, 100, 127, 190, 214]), H256([226, 92, 234, 230, 107, 154, 70, 80, 79, 38, 87, 248, 101, 252, 218, 56, 56, 57, 192, 176, 63, 161, 235, 200, 160, 206, 253, 237, 202, 26, 23, 78])), (H256([115, 42, 251, 21, 10, 129, 204, 237, 248, 146, 248, 82, 88, 250, 90, 110, 18, 238, 70, 141, 5, 162, 157, 180, 81, 241, 174, 138, 236, 220, 168, 207]), H256([127, 151, 71, 70, 116, 7, 82, 136, 77, 33, 25, 5, 110, 240, 190, 145, 224, 65, 213, 202, 166, 186, 227, 86, 65, 173, 215, 224, 55, 163, 232, 132])), (H256([228, 48, 3, 136, 153, 251, 69, 198, 255, 60, 97, 198, 32, 17, 114, 3, 138, 96, 146, 111, 234, 179, 172, 33, 146, 5, 26, 136, 178, 90, 100, 86]), H256([83, 110, 3, 250, 248, 169, 119, 86, 27, 184, 191, 220, 184, 100, 111, 66, 175, 86, 65, 183, 29, 27, 109, 46, 235, 73, 21, 223, 128, 129, 132, 108])), (H256([2, 39, 34, 43, 204, 94, 120, 55, 17, 46, 28, 181, 40, 224, 66, 117, 195, 129, 229, 134, 49, 250, 179, 28, 250, 2, 205, 202, 37, 203, 236, 108]), H256([111, 156, 57, 253, 133, 2, 21, 34, 64, 237, 227, 170, 97, 234, 222, 97, 109, 167, 79, 206, 201, 198, 131, 240, 179, 201, 196, 120, 38, 242, 9, 48])), (H256([1, 64, 121, 90, 191, 203, 217, 90, 9, 66, 197, 199, 143, 214, 130, 93, 15, 2, 210, 11, 161, 84, 41, 56, 104, 131, 184, 29, 119, 208, 114, 157]), H256([144, 145, 98, 224, 124, 86, 55, 108, 193, 103, 111, 90, 221, 39, 43, 179, 92, 110, 84, 154, 130, 12, 125, 135, 40, 27, 39, 252, 33, 7, 35, 62])), (H256([244, 90, 72, 32, 243, 182, 101, 249, 135, 38, 75, 239, 234, 23, 63, 215, 179, 139, 52, 159, 22, 233, 172, 51, 29, 100, 166, 103, 86, 221, 41, 30]), H256([37, 57, 176, 170, 37, 48, 22, 31, 187, 26, 108, 13, 197, 210, 245, 75, 190, 100, 114, 202, 35, 140, 224, 199, 222, 233, 69, 165, 189, 153, 80, 200])), (H256([131, 29, 237, 29, 72, 82, 100, 136, 11, 196, 166, 29, 75, 151, 15, 172, 46, 55, 76, 82, 235, 218, 215, 203, 156, 201, 89, 156, 88, 55, 204, 160]), H256([135, 205, 60, 123, 17, 19, 182, 80, 173, 51, 237, 204, 78, 114, 217, 215, 85, 74, 196, 0, 142, 114, 235, 224, 235, 151, 181, 182, 240, 26, 137, 19])), (H256([17, 204, 189, 127, 191, 254, 251, 53, 212, 183, 155, 175, 11, 60, 4, 152, 133, 177, 162, 226, 46, 191, 3, 100, 234, 20, 96, 19, 144, 199, 40, 145]), H256([27, 223, 175, 197, 254, 86, 83, 50, 80, 4, 53, 151, 178, 141, 28, 190, 5, 115, 48, 126, 84, 56, 28, 137, 44, 40, 101, 126, 14, 85, 199, 29])), (H256([227, 244, 170, 145, 189, 254, 60, 195, 23, 85, 59, 142, 228, 236, 114, 161, 21, 72, 131, 224, 255, 250, 115, 202, 148, 156, 253, 199, 42, 175, 187, 219]), H256([82, 189, 244, 67, 180, 12, 142, 142, 65, 52, 103, 147, 172, 128, 100, 221, 122, 18, 88, 54, 184, 200, 57, 28, 243, 149, 47, 86, 228, 112, 132, 208])), (H256([69, 251, 197, 5, 38, 197, 188, 96, 242, 129, 254, 201, 96, 220, 91, 138, 137, 222, 33, 179, 131, 119, 155, 6, 146, 35, 202, 164, 182, 50, 153, 87]), H256([226, 20, 28, 137, 46, 45, 130, 212, 129, 160, 147, 128, 60, 192, 196, 113, 83, 165, 242, 52, 142, 246, 9, 59, 122, 30, 181, 217, 96, 194, 233, 215])), (H256([236, 197, 20, 247, 249, 207, 4, 253, 219, 225, 1, 222, 174, 183, 60, 79, 101, 62, 100, 181, 95, 10, 84, 33, 255, 116, 80, 109, 139, 28, 19, 216]), H256([90, 179, 108, 4, 30, 175, 200, 228, 67, 100, 7, 147, 110, 229, 235, 100, 29, 200, 18, 8, 209, 157, 74, 198, 217, 0, 186, 168, 89, 254, 159, 148])), (H256([192, 6, 203, 206, 147, 169, 151, 7, 189, 217, 48, 123, 138, 126, 141, 145, 133, 161, 9, 184, 175, 232, 243, 23, 206, 72, 3, 207, 74, 198, 179, 214]), H256([44, 53, 255, 180, 212, 139, 187, 206, 81, 50, 200, 246, 6, 141, 61, 170, 22, 219, 234, 166, 61, 24, 167, 219, 27, 143, 173, 177, 155, 166, 204, 112])), (H256([35, 205, 104, 159, 39, 201, 208, 55, 137, 36, 121, 181, 24, 251, 83, 115, 154, 252, 139, 173, 157, 169, 28, 243, 171, 69, 146, 229, 137, 171, 104, 103]), H256([14, 211, 185, 62, 38, 155, 114, 134, 120, 12, 159, 0, 48, 179, 61, 7, 135, 163, 151, 222, 132, 71, 216, 247, 230, 86, 227, 204, 22, 112, 6, 215])), (H256([42, 141, 76, 168, 189, 40, 244, 225, 46, 9, 127, 42, 204, 240, 108, 17, 166, 107, 87, 2, 65, 34, 214, 182, 23, 81, 153, 98, 231, 147, 209, 254]), H256([212, 222, 215, 248, 195, 50, 189, 216, 237, 136, 89, 55, 35, 17, 152, 222, 3, 77, 118, 80, 240, 151, 33, 80, 164, 131, 101, 125, 12, 135, 93, 134])), (H256([232, 103, 113, 253, 96, 143, 138, 217, 16, 23, 142, 214, 34, 17, 20, 163, 53, 1, 113, 57, 146, 20, 60, 149, 41, 8, 104, 100, 163, 2, 24, 209]), H256([94, 37, 226, 44, 7, 175, 126, 158, 255, 157, 135, 209, 75, 9, 24, 109, 200, 22, 201, 149, 78, 171, 41, 20, 59, 156, 178, 125, 128, 87, 96, 234])), (H256([160, 131, 234, 217, 89, 106, 86, 55, 59, 85, 69, 198, 28, 83, 160, 164, 41, 79, 65, 215, 32, 148, 104, 158, 138, 124, 15, 246, 119, 127, 236, 29]), H256([17, 99, 29, 210, 35, 30, 246, 19, 254, 173, 246, 191, 253, 199, 195, 102, 118, 113, 177, 215, 81, 186, 122, 133, 64, 141, 24, 150, 42, 5, 75, 230])), (H256([76, 177, 146, 177, 149, 239, 205, 110, 153, 92, 61, 155, 201, 79, 120, 60, 99, 33, 37, 33, 15, 79, 61, 242, 156, 196, 171, 240, 71, 104, 198, 138]), H256([124, 185, 126, 93, 187, 235, 251, 85, 172, 76, 227, 100, 82, 208, 38, 20, 238, 240, 210, 149, 7, 85, 215, 133, 104, 201, 18, 170, 218, 111, 200, 72])), (H256([117, 232, 218, 196, 120, 97, 233, 29, 16, 166, 204, 14, 204, 135, 70, 122, 0, 20, 53, 123, 189, 139, 202, 9, 222, 2, 102, 136, 255, 53, 235, 58]), H256([234, 111, 181, 48, 253, 90, 205, 116, 89, 122, 111, 17, 40, 144, 15, 249, 44, 183, 95, 133, 210, 123, 226, 251, 240, 174, 114, 67, 189, 28, 130, 105]))], 12) diff --git a/src/ckb_smt.rs b/src/ckb_smt.rs index 074cf87..b059974 100644 --- a/src/ckb_smt.rs +++ b/src/ckb_smt.rs @@ -61,7 +61,7 @@ impl SMTBuilder { len: 0, capacity: 0, }), - _buffer: Vec::with_capacity(capacity as usize), + _buffer: Vec::with_capacity(capacity), }; unsafe { smt_state_init(smt.state.as_mut(), smt._buffer.as_ptr(), capacity as u32); diff --git a/src/default_store.rs b/src/default_store.rs index 319d405..bcae048 100644 --- a/src/default_store.rs +++ b/src/default_store.rs @@ -6,23 +6,12 @@ use crate::{ H256, }; -const DEFAULT_CAPACITY: usize = 256; - -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub struct DefaultStore { nodes: Map, leaves: Map, } -impl Default for DefaultStore { - fn default() -> Self { - Self { - nodes: Map::with_capacity(DEFAULT_CAPACITY), - leaves: Map::with_capacity(DEFAULT_CAPACITY), - } - } -} - impl DefaultStore { pub fn branches_map(&self) -> &Map { &self.nodes