Commit graph

74 commits

Author SHA1 Message Date
Jason Rhinelander
1dd98f3dae std::filesystem
Converts all use of boost::filesystem to std::filesystem.

For macos and potentially other exotic systems where std::filesystem
isn't available, we use ghc::filesystem instead (which is a drop-in
replacement for std::filesystem, unlike boost::filesystem).

This also greatly changes how we handle filenames internally by holding
them in filesystem::path objects as soon as possible (using
fs::u8path()), rather than strings, which avoids a ton of issues around
unicode filenames.  As a result this lets us drop the boost::locale
dependency on Windows along with a bunch of messy Windows ifdef code,
and avoids the need for doing gross boost locale codecvt calls.
2020-10-24 12:45:37 -03:00
Jason Rhinelander
caf5e59984 Merge branch 'pulse' into dev 2020-09-18 17:40:25 -03:00
Jason Rhinelander
d26b508e3c Add tools::equals_any for checking an item in a list
e.g.

tools::equals_any(foo, 1, 2, 3)

is equivalent to

foo == 1 || foo == 2 || foo == 3

(and false if there are no arguments at all).
2020-09-16 20:41:39 -03:00
Doyle
62fe4db413 config: Convert DIFFICULTY_BLOCKS_V2 to TARGET_BLOCK_TIME 2020-08-18 11:59:53 +10:00
Doyle
a62ff316e3 Pulse: Queue Block Gen code review
- Rename find_named_argument -> find_prefixed_value
- Update get_current_blockchain_height() comment to specify ability to lock
- Update memcmp(address1, address2) to address1 == address2
- Make create_next_miner_block_template call create_miner_block_template
- Update LMQ x25519 keys only when key has changed
- construct_miner_tx: Use C++17 features
- Pulse: Add log category "Pulse"
- Pulse: Check shutdown before blockchain height
- Pulse: Use get_human_readable_timespan
- Pulse: Switch to MINFO, enable with --log-level +pulse:DEBUG
- Pulse: Add height into context
- Pulse: Remove some default switch cases hiding compiler warnings
- SN: Update hardcoded '9' literals to network_version_9_service_nodes
- Core: Use using namespace std::literals
- Miner: Change num_blocks availability to debug
- RPC: Gate test rpc commands to != MAINNET
- Wallet: Store wallet before deinitialization instead of refresh
2020-08-18 11:59:53 +10:00
Jason Rhinelander
48a0dc9eef More string_view niceties
- Adds a tools::trim that operates on a string_view to replace boost
string trim usage.

- Replaces some boost::split's with tools::split's

- updates vercmp to operate on string_views instead of c strings
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
7a2811ba6a C++17 simplify memcpy_le
C++17 fold expressions and a mutable pointer-reference allow reducing
the code required here.
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
6af3666fd3 Improve checkpoint loading code; make sha256sum less dangerous
- replace the gross cmake shell script tools being used to create the data file with
cmake code and a single configure_file
- change checkpoint data to string_view
- tools::sha256sum() had two different overloads that did very different
things, yet presents two overloads: one that takes a pointer+size, the
other that takes a string lvalue ref, and yet the string lvalue
reference is *entirely* different (it reads a file).  Append _str and
_file suffixes to make it less dangerous.
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
Doyle
a8abb83b7d Merge commit '2d729fb' into MergeUpstream3 2020-05-28 16:56:01 +10:00
Doyle
6a357fa499 Merge commit '23547e6ed6c9f0dc694d55316540000b030bbb06' into MergeUpstream3 2020-05-20 18:14:48 +10:00
Jason Rhinelander
a8bdb1888e Remove dangerous and broken glob_to_regex function
This function is broken: if it encounters a \ it stays in "escape" more
forever.  However the entire function is also moronic because it is only
used in the test suite (and thus doesn't belong out of the test suite),
but is also only used for the test `--filter` arguments which have this
help message:

    Regular expression filter for which tests to run

Since a glob is not a regular expression, and because passing legitimate
regular expressions through this glob_to_regex function serious breaks
them, removing this stupid broken code is actually a bug fix.
2020-05-11 18:44:45 -03:00
Jason Rhinelander
5ea5d5c13b Remove useless --os-version option
This is a big chunk of code with little usefulness: It is not the job of
Loki to tell you what operating system you are using.  If someone needs
to know what OS they are on they can run `uname` themselves on anything
other than Windows, and click the Start menu in Windows.

(Contrary to the option description, this actually just tells you the
current OS, not the compiled-for OS).
2020-05-11 18:44:45 -03:00
rbrunner7
387fd668d1 Daemon: Print estimates for time until fully synced 2020-03-21 07:32:55 +01:00
Doyle
22e51bca1c LNS: Lowercase names at the boundary between LNS and user code 2020-03-13 13:46:45 +11:00
Doyle
291ba112b4 enum_top, use burn hf in sanity check, fill new construction data 2019-12-04 15:17:55 +11:00
Jason Rhinelander
d66e6e9e3f Align hashable data structures
We don't impose any alignment on hashable types, but this means the
hashing function is doing invalid misaligned access when converting to a
size_t.  This aligns all of the primitive data types (crypto::hash,
public keys, etc.) to the same alignment as size_t.

That cascades into a few places in epee which only allow byte spanning
types that have byte alignment when what it really requires is just that
the type has no padding.  In C++17 this is exactly the purpose of
std::has_unique_object_representations, but that isn't available (or
even implementable) in C++14 so add specializations for the type that
need it to tell epee that we know those types are properly packed and
that it can safely use them as bytes.

Related to this, monero/epee also misuses `is_standard_layout` when the
purpose is actually `is_trivially_copyable`, so fixed that too.  (You
need the latter but don't need the former for a type to be safely
memcpy'able; the only purpose of `is_standard_layout` is when you need
to be sure your structs are compatible with C structs which is
irrelevant here).
2019-11-27 14:07:52 -04:00
Jason Rhinelander
4522a7ae58 Add & use tools::enum_count to get _count as underlying type
Unify the field we use to store the count as `_count` (using the leading
underscore to indicate a private value rather than an intended enum
value) and add/use a new `enum_count` template variable to extract the
_count enum value and cast it to the enum's underlying_type.
2019-11-27 14:07:52 -04:00
Jason Rhinelander
f32e910d41 Add helper function to memcpy multiple variables
Lets you write `memcpy_le(dest, foo, bar, baz)` and memcpy the contents
of foo, bar, and baz sequentially.  Additionally, if any of those three
are integers, they are converted to little-endian order.
2019-10-07 22:09:17 -03:00
moneromooo-monero
1a367d6a22
simplewallet: lock console on inactivity 2019-08-28 19:01:48 +00:00
moneromooo-monero
880ebfdeea
daemon: add more chain specific info in alt_chain_info 2019-06-01 15:43:52 +00:00
Doyle
4778d862c9 Merge commit 'bd42903' into LokiMergeUpstream 2019-04-12 18:37:56 +10:00
Doyle
aded2cef69 Merge commit '1ed6441' into LokiMergeUpstream 2019-04-12 17:44:20 +10:00
Doyle
892469ded1 Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00
Riccardo Spagni
19e37c05d6
Merge pull request #5367
07b716bf util: name replace_file arguments better (moneromooo-monero)
2019-04-11 12:41:55 +02:00
moneromooo-monero
07b716bfea
util: name replace_file arguments better
It was confusing unless you read code and the rename(2) man page.
2019-03-29 16:32:00 +00:00
rbrunner7
c23ea7962d New interactive daemon command 'print_net_stats': Global traffic stats 2019-03-24 16:58:57 +01:00
Doyle
0b6a7706ac
Add rpc call for request stake unlock (#490) 2019-03-14 07:26:38 +00:00
binaryFate
1f2930ce0b Update 2019 copyright 2019-03-05 22:05:34 +01:00
rbrunner7
1ebcd7b9b0 MMS (Multisig Messaging System): Initial version 2018-12-12 21:49:20 +01:00
moneromooo-monero
177a9d76f9
wallet: warn if lockable memory limit is too low 2018-11-03 20:09:28 +00:00
moneromooo-monero
c774392985
spawn: close all file descriptors before execve
No need to give whatever we're calling access to what we use
2018-10-17 09:31:34 +00:00
fireice-uk
579383c26b simplewallet: Add Unicode input_line [Ryo backport] 2018-09-19 13:39:01 +01:00
p8p
9d6539923e
is_hdd update 2018-08-25 04:31:22 -07:00
luigi1111
1d2c08610b
Merge pull request #4136
4307489 wallet: disable core dumps on startup in release mode (moneromooo-monero)
2018-08-15 17:15:49 -05:00
moneromooo-monero
4307489147
wallet: disable core dumps on startup in release mode 2018-08-12 16:28:10 +00:00
moneromooo-monero
639ca3b1fa
core_tests: add --filter to select which tests to run 2018-07-07 19:33:35 +01:00
stoffu
59de6f8d99
util: add file_locker class 2018-06-28 09:40:31 +09:00
stoffu
248310de06
Move parse_subaddress_lookahead() from simplewallet.cpp to util.cpp 2018-06-21 12:36:17 +09:00
moneromooo-monero
284fe6438d
db_lmdb: warn about slowness when running off a spinning disk 2018-06-08 20:59:02 +01:00
Jethro Grassie
a4b50a6f51
handle ^D and ^C while password prompting 2018-02-10 18:29:49 -05:00
xmr-eric
18216f19dd Update 2018 copyright 2018-01-26 10:03:20 -05:00
iDunk5400
fdf0acbf97
Tools, daemonizer: fix building on Windows 2017-11-15 23:12:02 +01:00
Riccardo Spagni
f26e7a84a6
Merge pull request #2620
6bd4dac6 util: ignore SIGPIPE (moneromooo-monero)
2017-11-14 14:54:42 +02:00
moneromooo-monero
7130cf0c61
Add tools::on_startup, and warn about glibc 2.25 bug if found
https://sourceware.org/bugzilla/show_bug.cgi?id=21778
2017-10-14 09:12:28 +01:00
moneromooo-monero
6bd4dac6e2
util: ignore SIGPIPE
In practice, this seems to cause monero-wallet-rpc to exit
when ^C quits whatever its output is piped into (such as tee),
but it saves, while it did not before.
2017-10-09 21:46:01 +01:00
Lee Clagett
9c83f8063d Do not create file when RPC user/pass is given and use file locking 2017-08-30 17:39:59 -04:00