Commit graph

868 commits

Author SHA1 Message Date
Jason Rhinelander 37a341ff6b Remove boost regex dependencies
All boost::regex use is now replaced with std::regex.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 49c693d0a9 Split up common/util.h
common/util.h has become something of a dumping ground of random
functions.  This splits them up a little by moving the filesystem bits
to common/file.h, the sha256sum functions to common/sha256sum.h, and the
(singleton) signal handler to common/signal_handler.h.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 008558ba54 Header updates
Adding/removing a few required/unnneeded headers.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 19ca0e21ee Replace a few boost::bind's with lambda 2020-07-02 12:52:12 -03:00
Jason Rhinelander ae344c2534 epee serialization code: std::variant & C++17 modernization
This overhauls the (unpleasant) epee "portable storage" interface to be
a bit easier to work with.  The diff is fairly large because of the
amount of type indirection that was being used, but at its core does
this simplifications:

- `hsection` was just a typedef for a `section*`, so just use `section*`
instead to not pretend it the value is something it isn't.

- use std::variant instead of boost::variant to store the portable
storage items.

- don't make the variant list recursive with itself since the
serialization doesn't support that anyway (i.e. it doesn't support a
list of lists).

- greatly simplified the variant visiting by using generic lambdas.

- the array traversal interface was a horrible mess.  Replaced it with
a simpler custom iterator approach.

- replaced the `selector<bool>` templated class with templated function.
So for example,

    epee::serialization::selector<is_store>::serialize_t_val_as_blob(...)

becomes:

    epee::serialization::perform_serialize_blob<is_store>(bytes, stg, parent_section, "addr");

and similar for the other types of serializing.
2020-07-02 12:52:12 -03:00
Jason Rhinelander e02545ca4b boost->std: mutex, locks; C++17 lock vars
Changes all boost mutexes, locks, and condition_variables to their stl
equivalents.

Changes all lock_guard/unique_lock/shared_lock to not specify the mutex
type (C++17), e.g.

    std::lock_guard foo{mutex};

instead of

    std::lock_guard<oh::um::what::mutex> foo{mutex};

Also changes some related boost::thread calls to std::thread, and some
related boost chrono calls to stl chrono.

boost::thread isn't changed here to std::thread because some of the
instances rely on some boost thread extensions.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 96354a0e0f boost::optional -> std::optional 2020-07-02 12:52:12 -03:00
Jason Rhinelander 87b147c954 De-analize epee 2020-07-02 12:52:12 -03:00
Jason Rhinelander 6dc5d9ac68 boost::shared_ptr -> std::shared_ptr 2020-07-02 12:52:12 -03:00
Jason Rhinelander b9448febdf Replace boost::string_ref with std::string_view
Also a few related small places in here where a `const std::string&`
made mode sense to be a std::string_view.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 9c5c1dac50 Replace boost::regex with std::regex 2020-07-02 12:52:12 -03:00
Jason Rhinelander e9d48f67f9 Remove stupid OUT macro 2020-07-02 12:52:12 -03:00
Jason Rhinelander 2208432604 Set epee include dir via epee target instead of globally 2020-07-02 12:52:12 -03:00
Jason Rhinelander fb331eefb8 Removed unused epee headers
This is just a pile of dead code that isn't used anywhere.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 83dd656e74 C++17
Switch loki dev branch to C++17 compilation, and update the code with
various C++17 niceties.

- stop including the (deprecated) lokimq/string_view.h header and
instead switch everything to use std::string_view and `""sv` instead of
`""_sv`.

- std::string_view is much nicer than epee::span, so updated various
loki-specific code to use it instead.

- made epee "portable storage" serialization accept a std::string_view
instead of const lvalue std::string so that we can avoid copying.

- switched from mapbox::variant to std::variant

- use `auto [a, b] = whatever()` instead of `T1 a; T2 b; std::tie(a, b)
= whatever()` in a couple places (in the wallet code).

- switch to std::lock(...) instead of boost::lock(...) for simultaneous
lock acquisition.  boost::lock() won't compile in C++17 mode when given
locks of different types.

- removed various pre-C++17 workarounds, e.g. for fold expressions,
unused argument attributes, and byte-spannable object detection.

- class template deduction means lock types no longer have to specify
the mutex, so `std::unique_lock<std::mutex> lock{mutex}` can become
`std::unique_lock lock{mutex}`.  This will make switching any mutex
types (e.g. from boost to std mutexes) far easier as you just have to
update the type in the header and everything should work.  This also
makes the tools::unique_lock and tools::shared_lock methods redundant
(which were a sort of poor-mans-pre-C++17 way to eliminate the
redundancy) so they are now gone and replaced with direct unique_lock or
shared_lock constructions.

- Redid the LNS validation using a string_view; instead of using raw
char pointers the code now uses a string view and chops off parts of the
view as it validates.  So, for instance, it starts with "abcd.loki",
validates the ".loki" and chops the view to "abcd", then validates the
first character and chops to "bcd", validates the last and chops to
"bc", then can just check everything remaining for is-valid-middle-char.

- LNS validation gained a couple minor validation checks in the process:
  - slightly tightened the requirement on lokinet addresses to require
    that the last character of the mapped address is 'y' or 'o' (the
    last base32z char holds only one significant bit).
  - In parse_owner_to_generic_owner made sure that the owner value has
    the correct size (otherwise we could up end not filling or
    overfilling the pubkey buffer).

- Replaced base32z/base64/hex conversions with lokimq's versions which
have a nicer interface, are better optimized, and don't depend on epee.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 3b110879b6 Temp fix for boost compatibility
To be reverted with C++17 changes.
2020-06-14 23:43:35 -03:00
Jason Rhinelander 7636155ffc Temporary clang variable template workaround
Temporary in that this will go away (in favour of become `inline`
variables) in the C++17 PR.
2020-06-09 23:06:54 -03:00
Doyle 80c658a48d wallet: Fix wallet call/selecting fields from GET_SERVICE_NODES.
The wallet submits RPC calls for Service Node data by serialising the
data structure. The wallet will _always_ then serialize the fields in
requested_fields_t (to false, by default), so when it reaches the
Daemon, it detects it as if the wallet specifically specified all the
fields as false and returned an empty response breaking staking/registration.
2020-06-05 13:49:15 +10:00
Doyle df07176d14 Revert "Don't couple the cancelling wallet code with console_handler"
This reverts commit c7cf2935a3.
2020-06-03 14:45:51 +10:00
Doyle 67727ab6a7 Merge commit 'ac9f7c9' into MergeUpstream3 2020-05-29 13:47:02 +10:00
Doyle a8abb83b7d Merge commit '2d729fb' into MergeUpstream3 2020-05-28 16:56:01 +10:00
Doyle 05a7d674bd Merge commit '00ede00' into MergeUpstream3 2020-05-28 15:59:14 +10:00
Doyle abb8dfc48e Merge commit 'c4f75fe' into MergeUpstream3 2020-05-28 15:29:00 +10:00
Doyle b71ce522c1 Merge commit '6c7d928' into MergeUpstream3 2020-05-28 15:02:40 +10:00
Doyle 4e8786574e Merge commit '328e9db' into MergeUpstream3 2020-05-28 14:50:12 +10:00
Doyle bda1e6c97b Merge commit '2eee9bcdf8aa33c3fd8cee0685ee16a0131c5b59' into MergeUpstream3 2020-05-28 11:49:14 +10:00
Doyle 7345e62532 Merge commit '092a57df996be75e3a45e9dc69d15138093f503b' into MergeUpstream3 2020-05-28 11:48:41 +10:00
Doyle d84679e269 Merge commit '5e492c4cbcf966d8e73601358d35d70eb75bb4ca' into MergeUpstream3 2020-05-27 17:17:46 +10:00
Doyle 00545b4920 Merge commit '5e384f2' into MergeUpstream3 2020-05-27 15:45:13 +10:00
Doyle 95c9200099 Fix m_mime_tipe -> m_mime_type 2020-05-27 15:04:04 +10:00
Doyle 6fa5d0c5e3 Merge commit '8039fd4' into MergeUpstream3 2020-05-27 14:55:53 +10:00
Doyle fd233c28f9 Merge commit 'f1ca98a7efa4a9a113881b38fe587ba1d231a2f7' into MergeUpstream3 2020-05-27 14:42:34 +10:00
Doyle 4cc48ed813 Merge commit 'fe73607' into MergeUpstream3 2020-05-27 14:38:37 +10:00
Doyle 2114180485 Merge commit 'df98432' into MergeUpstream3 2020-05-26 15:34:36 +10:00
Doyle f0df6cfb82 Remove math_helper.h and dependers 2020-05-26 15:19:12 +10:00
Doyle 2e42202e94 Merge commit 'dcff02e4c3b1214143b19685361c3c6cffa62be7' into MergeUpstream3 2020-05-26 15:15:25 +10:00
Doyle 804b811ef9 Merge commit '42d84ad' into MergeUpstream3 2020-05-25 14:12:26 +10:00
Doyle 72085b20d7 Merge commit 'bb2bcf35216b819778fe09cee328e7acc2f680cf' into MergeUpstream3 2020-05-25 13:49:06 +10:00
Doyle d799af317d Merge commit '441ed9f2fef6a43708c115191c51ca16930ce95b' into MergeUpstream3 2020-05-25 10:36:27 +10:00
Doyle aa8c5bc4ce Merge commit 'fcb4c72bb56e2de1b034636c1ea88d23a5fb8c4b' into MergeUpstream3 2020-05-22 15:05:43 +10:00
Doyle e7b5e3ea81 Merge commit 'a74a82c8b2e520e487b65124a08af848a14b27b7' into MergeUpstream3 2020-05-22 14:05:20 +10:00
Doyle 170c01c7eb Merge commit '15b9b4e' into MergeUpstream3 2020-05-22 14:02:42 +10:00
Doyle 5822115e4e Adjust the prior commit here (epee: abstract_tcp_server2: resolve CID 203919 (DC.WEAK_CRYPTO))
Adjustment requested by Jagerman, -
It reinitializes std::random_device on each pass through the function, and that can block, and on
top of that doesn't give randomization at all (you might as well just use the random device results
directly rather than using a mt19937 for one single random value generation).

This code needs to be fixed to initialize the RNG from the random device *once*, by moving the
19937+seed construction into a function and then, in the code in the commit, doing:

    static std::mt19937 rng = get_seeded_mt19937();

so that the seeding happens just *once* and then the random values are retrieved repeatedly from the
RNG.

It's also slightly wrong in how it pulls a random value using `rng() % 50`: that produces a
*slightly* biased value (because the range of produced values is not a multiple of 50).  It should
do this instead, to be correct:

    int ms = std::uniform_int_distribution<>{250, 299}(rng);

In practice the bias here isn't going to be significant, but there is also no downside to doing it
correctly here.
2020-05-22 12:15:24 +10:00
Doyle f2ebd811d0 Merge commit 'c6430f9' into MergeUpstream3 2020-05-22 12:04:20 +10:00
Doyle 9742c0d91d Merge commit 'dbe31f63e1c96e0f6ad57643ef57454986b5d336' into MergeUpstream3 2020-05-21 16:13:28 +10:00
Doyle 39d74a0b38 Merge commit '48d8475b6ea77c6cc9670c9c312f3b7684b12a2c' into MergeUpstream3 2020-05-21 13:37:57 +10:00
Doyle 726910a8f3 Merge commit 'e4f11a6' into MergeUpstream3 2020-05-21 12:30:03 +10:00
Doyle c7cf2935a3 Don't couple the cancelling wallet code with console_handler 2020-05-21 10:21:05 +10:00
Doyle 6a357fa499 Merge commit '23547e6ed6c9f0dc694d55316540000b030bbb06' into MergeUpstream3 2020-05-20 18:14:48 +10:00
Doyle 15fd7f8200 Merge branch 'dev' into MergeUpstream3 2020-05-20 14:59:12 +10:00