Commit Graph

39 Commits

Author SHA1 Message Date
Jack Grigg c301e321e4 Migrate `OrchardMerkleFrontier` to use new `CppStream` APIs 2023-04-06 21:30:38 +00:00
Jack Grigg 33367709f7 Merge most `cxx::bridge` definitions into a single bridge
This enables us to use Rust types across more bridged APIs, which we
can't do with multiple bridge definitions until `cxx` adds support.
2023-04-05 10:50:35 +00:00
Jack Grigg 817276c02f rust: Migrate `OrchardMerkleFrontier` to `cxx`
Closes zcash/zcash#6333.
2023-01-24 21:04:48 +00:00
Steven Smith 85889bb99c Add orchard pool metrics 2022-05-02 16:02:56 -07:00
Kris Nuttycombe f86a65d7cb Make Orchard `finalState` serialization format match Sapling.
For consistency, we serialize the `finalState` field in the
same (sparse) encoding as Sapling and Sprout use. In the future
we may want to update this to the dense encoding that
incrementalmerkletree::bridgetree::Frontier uses, but that's not
necessary for the moment.
2022-04-08 19:48:40 -06:00
Kris Nuttycombe 6fbcba641d Fix a bug in initialization of the Orchard wallet after NU5 activation.
When initializing a new Orchard wallet after NU5 activation, it is
not valid to start from the empty note commitment tree; instead,
the note commitment tree needs to be initialized from the state of
the global Orchard Merkle frontier.

In addition, this change necessitates a change to how rewinds work,
such that in a rollback scenario with a newly initialized wallet
that does not have sufficient checkpoints to fully satisfy a requested
rewind, the rewind is allowed to proceed so long as it does not
invalidate any persisted witness data.
2022-04-04 13:05:42 -06:00
Kris Nuttycombe f49f4c73d8 Rename OrchardMerkleTree -> OrchardMerkleFrontier
Remove IncrementalSinsemillaTree; this will be replaced by
a more full-featured OrchardWallet type which embeds the
incremental merkle tree used in wallet operations.
2021-11-23 07:27:34 -07:00
Kris Nuttycombe 572719fca6 Apply suggestions from code review
Use const pointers wherever possible.

Co-authored-by: str4d <jack@electriccoin.co>
2021-06-28 17:37:32 -06:00
Kris Nuttycombe 5550dbe1b8 Fix implmentation of OrchardMerkleTree.DynamicMemoryUsage 2021-06-28 16:33:40 -06:00
Kris Nuttycombe 8ee8c9f6ab Consistently panic on null commitment tree pointers.
Orchard commitment tree pointers should never be null.
2021-06-28 15:27:21 -06:00
Kris Nuttycombe 0a1e845681 Documentation cleanup. 2021-06-23 16:17:53 -06:00
Kris Nuttycombe 13fd4c9a1c Add Orchard merkle tree anchor tests. 2021-06-23 16:06:30 -06:00
Kris Nuttycombe 437b8c488a Orchard changes to coins & consensus. 2021-06-23 16:06:30 -06:00
Jack Grigg d8d0918951 scripted-diff: Migrate from boost::optional to std::optional
-BEGIN VERIFY SCRIPT-
sed -i 's/boost::none/std::nullopt/g' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h* ./src/*/*/*.cpp ;
sed -i 's/boost::optional/std::optional/g' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h* ./src/*/*/*.cpp ;
sed -i 's/std::optional<\(.*\)&>/std::optional<std::reference_wrapper<\1>>/' ./src/*/*.h ./src/*/*.cpp ;
sed -i 's/is_initialized()/has_value()/' ./src/*.cpp ./src/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include <boost\/optional.hpp>\n//' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include "boost\/optional.hpp"\n//' ./src/*.h ;
-END VERIFY SCRIPT-
2020-12-16 22:59:35 +00:00
Jack Grigg 521eb81a95 Add <optional> header to files that will need it 2020-12-16 22:59:34 +00:00
Jack Grigg d476537d86 scripted-diff: Remove BOOST_STATIC_ASSERT
-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_STATIC_ASSERT(/static_assert(/' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include <boost\/static_assert.hpp>\n//' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
2020-10-27 10:44:58 +00:00
Larry Ruane 7ec8c5d309 precompute empty merkle roots 2019-10-12 18:03:36 -06:00
Eirik Ogilvie-Wigley 7d379f18c5 Rename test objects to include sprout or sapling 2018-08-01 10:52:58 -06:00
Eirik Ogilvie-Wigley 8ea8ef9850 Rename Witnesses to include sprout or sapling 2018-08-01 10:41:36 -06:00
Eirik Ogilvie-Wigley 4fc309f0f5 Rename Merkle Trees to include sprout or sapling 2018-08-01 10:31:09 -06:00
Jack Grigg 70a7535ae8
Expose note position in IncrementalMerkleWitness 2018-07-24 14:54:07 +02:00
Jack Grigg a6bbb26e08
Replace boost::array with std::array 2018-05-26 00:12:57 +12:00
Sean Bowe 2b002a7e60 Add implementation of Sapling merkle tree 2018-05-07 13:46:06 -06:00
Sean Bowe a7cbb8475f Abstract `uncommitted` and depth personalization for IncrementalMerkleTree. 2018-05-07 13:46:06 -06:00
Jack Grigg 68a1a592ca
Remove nType and nVersion from Zcash-specific code 2018-04-17 13:09:47 +01:00
Jack Grigg 4fe053e6e8
Move explicit instantiation of IncrementalMerkleTree::emptyroots into header
Fixes a -Wundefined-var-template warning with clang.
2018-03-28 18:29:19 +02:00
Jack Grigg d58ed91af0
Optimise serialization of MerklePath, avoiding ambiguity of std::vector<bool>
The serialization enforces a maximum supported Merkle tree depth of 64.

Closes #2831.
2018-03-28 18:26:08 +02:00
syd 4e4aa5b6ec Get rid of underscore prefixes for include guards.
This is because they may conflict with reserved names. Also took
this opportunity to make the guards in the zcash subdir a bit
more uniform by having them all conform to ZC_<...>_H_

This closes #1272
2017-11-28 14:57:58 -05:00
Jack Grigg 5d6e1aa60f
Add total number of commitments to getblockchaininfo 2016-12-15 15:50:26 +13:00
Sean Bowe 5f0a73ce11 Improve accuracy of constraint system violation diagnostics. 2016-11-05 11:27:23 -06:00
Simon 19bec4d9bb Fixes CID 1352715 uninitialized scalar field. 2016-10-20 11:25:36 -07:00
Jack Grigg 5abaca1af6 Fix the failing test! 2016-09-01 13:00:02 +12:00
Jack Grigg ac91ebbe92 Add test showing that the witness cache isn't being serialised 2016-09-01 12:47:44 +12:00
Sean Bowe 7f3c7a683b Flush to disk more consistently by accounting memory usage of serials/anchors in cache. 2016-06-27 10:52:34 -06:00
Taylor Hornby bf2e3122ac Remove the Merkle tree hash function's fixed point. 2016-05-16 20:20:36 -06:00
Sean Bowe 5961dcb6da Change ciphertext length to match protocol spec, and refactor the use of constants. 2016-05-05 21:02:03 -06:00
Sean Bowe 6f1b70300d Small nit fixes 2016-04-30 11:59:39 -06:00
Sean Bowe 482aefbd0d Test old tree along with new tree as much as possible. 2016-04-28 16:07:52 -06:00
Sean Bowe e1ff849d8d New implementation of incremental merkle tree
This is a new implementation of the incremental merkle tree used by our
scheme to witness commitments to spendable value. It serves as a fixed-sized
accumulator.

This new construction has a much simpler API surface area, avoids memory
safety issues, remains pruned at all times, avoids serialization edge cases,
has more efficient insertion, and is abstract over the depth and hash
function used at the type level.

Further, it lays the groundwork for efficient "fast-forwarding" of witnesses
into the tree as the treestate is updated.
2016-04-28 16:07:52 -06:00