mit-dci / libutreexo Goto Github PK
View Code? Open in Web Editor NEWlibrary for utreexo accumulator in c++
License: MIT License
library for utreexo accumulator in c++
License: MIT License
Utreexo is part of Summer of Bitcoin but with no C++ project ideas.
After a brief discussion with @kcalvinalvin, I am opening this issue in order to get @dergoegge take on what work needs to be done and if from that a project idea could be potentially created.
Calvin already mentioned that some tests need to be ported to the C++ implementation, so apart from a more solid project idea, it would be great to get a few guidelines on things I can tackle while preparing for my proposal.
I went to give a try to build this project (mostly just to poke around with it), and following the standard auto-tools process (./autogen.sh
, ./configure
, make
), I ran into several build errors (fixable just by adding four includes).
I tried to open a PR for the fixes, but github seems to be struggling on my browser, so attached is the appropriate patch for use with git apply
!
When I do the normal steps of
The tests seem to be failing because of linking.
log:
In file included from src/test/../../include/utreexo.h:4,
from src/test/accumulator_tests.cpp:1:
src/test/../../include/accumulator.h:9:25: error: ‘uint8_t’ was not declared in this scope
9 | using Hash = std::array<uint8_t, 32>;
| ^~~~~~~
src/test/../../include/accumulator.h:9:36: error: template argument 1 is invalid
9 | using Hash = std::array<uint8_t, 32>;
| ^
src/test/../../include/accumulator.h:10:24: error: ‘Hash’ was not declared in this scope
10 | using Leaf = std::pair<Hash, bool>;
| ^~~~
src/test/../../include/accumulator.h:10:34: error: template argument 1 is invalid
10 | using Leaf = std::pair<Hash, bool>;
| ^
src/test/../../include/accumulator.h:18:25: error: expected ‘)’ before ‘num_leaves’
18 | Accumulator(uint64_t num_leaves);
| ~ ^~~~~~~~~~~
| )
src/test/../../include/accumulator.h:25:61: error: ‘Hash’ was not declared in this scope
25 | virtual bool Prove(BatchProof& proof, const std::vector<Hash>& target_hashes) const = 0;
| ^~~~
src/test/../../include/accumulator.h:25:65: error: template argument 1 is invalid
25 | virtual bool Prove(BatchProof& proof, const std::vector<Hash>& target_hashes) const = 0;
| ^
src/test/../../include/accumulator.h:25:65: error: template argument 2 is invalid
src/test/../../include/accumulator.h:35:35: error: ‘Leaf’ was not declared in this scope
35 | bool Modify(const std::vector<Leaf>& new_leaves, const std::vector<uint64_t>& targets);
| ^~~~
src/test/../../include/accumulator.h:35:39: error: template argument 1 is invalid
35 | bool Modify(const std::vector<Leaf>& new_leaves, const std::vector<uint64_t>& targets);
| ^
src/test/../../include/accumulator.h:35:39: error: template argument 2 is invalid
src/test/../../include/accumulator.h:35:72: error: ‘uint64_t’ was not declared in this scope
35 | bool Modify(const std::vector<Leaf>& new_leaves, const std::vector<uint64_t>& targets);
| ^~~~~~~~
src/test/../../include/accumulator.h:35:80: error: template argument 1 is invalid
35 | bool Modify(const std::vector<Leaf>& new_leaves, const std::vector<uint64_t>& targets);
| ^
src/test/../../include/accumulator.h:35:80: error: template argument 2 is invalid
src/test/../../include/accumulator.h:38:28: error: ‘Hash’ was not declared in this scope
38 | void Roots(std::vector<Hash>& roots) const;
| ^~~~
src/test/../../include/accumulator.h:38:32: error: template argument 1 is invalid
38 | void Roots(std::vector<Hash>& roots) const;
| ^
src/test/../../include/accumulator.h:38:32: error: template argument 2 is invalid
src/test/../../include/accumulator.h:57:5: error: ‘uint64_t’ does not name a type
57 | uint64_t m_num_leaves;
| ^~~~~~~~
src/test/../../include/accumulator.h:66:53: error: ‘uint64_t’ has not been declared
66 | virtual NodePtr<Accumulator::Node> SwapSubTrees(uint64_t from, uint64_t to) = 0;
| ^~~~~~~~
src/test/../../include/accumulator.h:66:68: error: ‘uint64_t’ has not been declared
66 | virtual NodePtr<Accumulator::Node> SwapSubTrees(uint64_t from, uint64_t to) = 0;
| ^~~~~~~~
src/test/../../include/accumulator.h:73:50: error: ‘uint64_t’ has not been declared
73 | virtual NodePtr<Accumulator::Node> MergeRoot(uint64_t parent_pos, Hash parent_hash) = 0;
| ^~~~~~~~
src/test/../../include/accumulator.h:73:71: error: ‘Hash’ has not been declared
73 | virtual NodePtr<Accumulator::Node> MergeRoot(uint64_t parent_pos, Hash parent_hash) = 0;
| ^~~~
src/test/../../include/accumulator.h:75:54: error: ‘Leaf’ does not name a type
75 | virtual NodePtr<Accumulator::Node> NewLeaf(const Leaf& leaf) = 0;
...
Line 83 in 375b2d8
ProofPositions()
will return the sibling of the node to be cached as a computable node.
For example:
std::vector<Leaf> leaves;
CreateTestLeaves(leaves, 8);
leaves[1].second = true;
Will create a tree like so (* means the leaf needs to be cached):
14
|---------------\
12 13
|-------\ |-------\
08 09 10 11
|---\ |---\ |---\ |---\
00 01* 02 03 04 05 06 07
00
must also be cached in order to prove 01
and is not computable. However:
auto positions = current_state.ProofPositions(std::vector<uint64_t>{0})
will output
positions: [1, 9, 13]
computable: [0, 8, 12, 14]
I'm on aarch64 Darwin and am unable to build tests due to boost linking error.
src/test/tests.cpp:2:10: fatal error: 'boost/test/included/unit_test.hpp' file not found
#include <boost/test/included/unit_test.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [src/test/test_verify-tests.o] Error 1
make: *** Waiting for unfinished jobs....
src/test/state_tests.cpp:2:10: fatal error: 'boost/test/unit_test.hpp' file not found
#include <boost/test/unit_test.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [src/test/test_verify-state_tests.o] Error 1
src/test/accumulator_tests.cpp:2:10: fatal error: 'boost/test/unit_test.hpp' file not found
#include <boost/test/unit_test.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [src/test/test_verify-accumulator_tests.o] Error 1
Boost is located in /opt/homebrew/Cellar/boost/1.78.0_1
for me and I'm linking them with ./configure --with-boost="/opt/homebrew/Cellar/boost/1.78.0_1"
. The logs tell me that it was able to find the boost test framework but fails to build. Log:
checking for boostlib >= 1.58.0 (105800) includes in "/opt/homebrew/Cellar/boost/1.78.0_1/include"... yes
checking for boostlib >= 1.58.0 (105800) lib path in "/opt/homebrew/Cellar/boost/1.78.0_1/lib/aarch64-darwin21.5.0"... no
checking for boostlib >= 1.58.0 (105800) lib path in "/opt/homebrew/Cellar/boost/1.78.0_1/lib64"... no
checking for boostlib >= 1.58.0 (105800) lib path in "/opt/homebrew/Cellar/boost/1.78.0_1/lib"... yes
checking for boostlib >= 1.58.0 (105800)... yes
checking whether the Boost::Unit_Test_Framework library is available... yes
I'm able to link boost with Bitcoin core. Seems like Bitcoin Core is just linking directly to the homebrew directory.
S["BOOST_LDFLAGS"]="-L/opt/homebrew//lib"
S["BOOST_CPPFLAGS"]="-I/opt/homebrew//include -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.