Commit graph

701 commits

Author SHA1 Message Date
Doyle e7e622e08b Merge commit '459beb5' into MergeUpstream2 2020-04-20 17:25:53 +10:00
Doyle ca9ce15103 Merge commit 'c5e9266' into MergeUpstream2 2020-04-20 17:07:14 +10:00
Doyle 1895694e65 Merge commit '9a6006bad89db877ee082c7dfa01da76efd6231a' into MergeUpstream 2020-04-09 15:42:03 +10:00
Doyle 254df85d0a Merge commit '8774384acec8f5020323f11585b5cdeb02ea00b0' into MergeUpstream 2020-04-09 15:38:15 +10:00
Doyle 7c22487613 Merge commit '1880c1a58290cde589fe6db1062284ddba294483' into MergeUpstream 2020-04-07 14:49:59 +10:00
Jason Rhinelander 743d4e60ce Various linking and build fixes
- updating to latest loki-mq (1.0.0 + various linking fixes)
- BUILD_SHARED_LIBS was being handled very strangely; make it a full
option instead (defaulting to off) that a cmake invoker can specify, as
per cmake recommendations.
- travis ci tweaks/changes:
  - Add a static bionic build
  - Simplify cmake argument code
  - Add `--version` invocation for lokid and loki-wallet-cli to test
    that the binaries were linked properly.
- always build an embedded sodium statically; if we do it dynamically
and an older system one exists we are going to have trouble.
- don't force epee and blocks to be static; rather they get controlled
by the above BUILD_SHARED_LIBS, just like all the other internal
libraries.
- use some PkgConfig:: imported targets rather than bunch-of-variables.
2020-03-15 14:29:47 -03:00
Jason Rhinelander 5b97ff6e9c cmake modernization
The archaic (i.e. decade old) cmake usage here really got in the way of
trying to properly use newer libraries (like lokimq), so this undertakes
overhauling it considerably to make it much more sane (and significantly
reduce the size).

I left more of the architecture-specific bits in the top-level
CMakeLists.txt intact; most of the efforts here are about properly
loading dependencies, specifying dependencies and avoiding a whole pile
of cmake antipatterns.

This bumps the required cmake version to 3.5, which is what xenial comes
with.

- extensive use of interface libraries to include libraries,
definitions, and include paths

- use Boost::whatever instead of ${Boost_WHATEVER_LIBRARY}.  The
interface targets are (again) much better as they also give you any
needed include or linking flags without needing to worry about them.

- don't list header files when building things.  This has *never* been
correct cmake usage (cmake has always known how to wallet_rpc_headers
the headers that .cpp files include to know about build changes).

- remove the loki_add_library monstrosity; it breaks target names and
makes compiling less efficient because the author couldn't figure out
how to link things together.

- make loki_add_executable take the output filename, and set the output
path to bin/ and install to bin because *every single usage* of
loki_add_executable was immediately followed by setting the output
filename and setting the output path to bin/ and installing to bin.

- move a bunch of crap that is only used in one particular
src/whatever/CMakeLists.txt into that particular CMakeLists.txt instead
of the top level CMakeLists.txt (or src/CMakeLists.txt).

- Remove a bunch of redundant dependencies; most of them look like they
were just copy-and-pasted in, and many more aren't needed (since they
are implied by the PUBLIC linking of other dependencies).

- Removed `die` since it just does a FATAL_ERROR, but adds color (which
is useless since CMake already makes FATAL_ERRORs perfectly visible).

- Change the way LOKI_DAEMON_AND_WALLET_ONLY works to just change the
make targets to daemon and simplewallet rather than changing the build
process (this should make it faster, too, since there are various other
things that will be excluded).
2020-03-06 00:36:57 -04:00
Jason Rhinelander f3fdcb1fbc Replace once_a_time_seconds; send proofs faster
This replaces the horrible, horrible, badly misused templated
once_a_time_seconds and once_a_time_milliseconds with a `periodic_task`
that works the same way but takes parameters as constructor arguments
instead of template parameters.

It also makes various small improvements:

- uses std::chrono::steady_clock instead of ifdef'ing platform dependent
  timer code.
- takes a std::chrono duration rather than a template integer and
  scaling parameter.
- timers can be reset to trigger on the next invocation, and this is
  thread-safe.
- timer intervals can be changed at run-time.

This all then gets used to reset the proof timer immediately upon
receiving a ping (initially or after expiring) from storage server and
lokinet so that we send proofs out faster.
2019-12-26 12:29:05 -04:00
Jason Rhinelander 38a4240c71 Avoid long-deprecated boost::sleep
Also don't return a completely useless bool.
2019-12-26 12:26:03 -04:00
Jason Rhinelander 19c562f800 Vote serialization compatibility fix (#984)
quorum_vote_t's were serialized as blob data, which is highly
non-portable (probably isn't the same on non-amd64 arches) and broke
between 5.x and 6.x because `signature` is aligned now (which changed
its offset and thus broke 5.x <-> 6.x vote transmission).

This adds a hack to write votes into a block of memory compatible with
AMD64 5.x nodes up until HF14, then switches to a new command that fully
serializes starting at the hard fork (after which we can remove the
backwards compatibility stuff added here).
2019-12-17 10:47:12 +10:00
iDunk5400 59eac93514 depends: attempt to fix readline
Make readline actually compile, and make ncurses use existing terminfo data (if available).
2019-12-03 17:07:18 -04:00
Jason Rhinelander ca36648749 Split up huge instanciations & header fixes
rpc/instanciations.cpp is a huge compiler job because it includes two
separate huge template instanciations [sic] in it.  Splitting it apart
into two separate compilation units makes compilation more
parallelizable and requires less ram for the individual job.

The split also revealed a few missing headers in epee for logging macros.
2019-12-03 00:51:18 -04:00
Doyle 8df27d99b7
Merge pull request #935 from jagerman/blink-wallet-burn
Blink wallet burn
2019-11-29 13:51:00 +11:00
Jason Rhinelander fc0abd94e5 Don't try forward declaring is_byte_spannable 2019-11-28 02:09:58 -04:00
Jason Rhinelander e50a445a0f Fix for older libc++ (#938)
Older libc++ (as on our travis-ci darwin build) apparently don't
properly treat std::array's size() method as constexpr.  Work around
this by using the deduced `Size` template parameter instead.
2019-11-28 16:27:12 +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 00098181fe epee serialization simplifications
Removes one unnecessary layer of templated indirection in kv
serialization, and removes use of boost::mpl::vector code generation.

Also removes a double-specification of the same type in the epee
array_entry specification.
2019-11-27 14:07:52 -04:00
Jason Rhinelander 29be7f6552 Allow epee async call response values to be moved
This allows the caller to also take the response by rvalue reference so
that they can move outsubvalues.  The rvalue is totally fine here (once
the callback is invoked it is never used again) and still binds
perfectly well to const-lvalue accepting callbacks.
2019-11-27 14:07:52 -04:00
Jason Rhinelander 8632c63738 Teach epee to serialize std::array & simplify template code
Also adds unordered_set serialization support (not that we currently
need it, but it's just two lines to support).
2019-11-26 18:49:33 -04:00
Jason Rhinelander a9294cdbef Remove boost::value_initialized and BOOST_FOREACH (#921)
Neither of these have a place in modern C++11; boost::value_initialized
is entirely superseded by `Type var{};` which does value initialization
(or default construction if a default constructor is defined).  More
problematically, each `boost::value_initialized<T>` requires
instantiation of another wrapping templated type which is a pointless
price to pay the compiler in C++11 or newer.

Also removed is the AUTO_VAL_INIT macro (which is just a simple macro
around constructing a boost::value_initialized<T>).

BOOST_FOREACH is a similarly massive pile of code to implement
C++11-style for-each loops. (And bizarrely it *doesn't* appear to fall
back to C++ for-each loops even when under a C++11 compiler!)

This removes both entirely from the codebase.
2019-11-01 09:26:58 +11:00
Jason Rhinelander 0408af80ef iOS build fix (#903)
Apple clang is resolving the `quoted()` calls here with
std::quoted(std::string) because of the ADL with the std::string
argument, then boost fails because rather than passing boost ranges the
code ends up passing libc++'s internal `__quoted_output_proxy` (the
opaque return type of `std::quoted()`.

(This only appeared now because std::quoted() doesn't exist before
C++14).

This works around the issue by just renaming the internal `quoted()`
function to `add_quotes()`.
2019-10-18 08:48:18 +10:00
Doyle 0bf62d0dfd
Merge pull request #888 from Doy-lee/FixTravisOnMacAndMakeDepends
Fix travis on mac and make depends
2019-10-10 14:00:22 +11:00
Doyle 7568fb9d1e Specify boost no system paths properly, fix type ambiguity in epee 2019-10-10 12:17:29 +11:00
Doyle 4825c4c023 In openssl >1.1, SSL_CTX_set_ecdh_auto is macroed 1, cast to calm warnings 2019-10-10 11:43:50 +11:00
Jason Rhinelander 0b384f5f52 Use perfect forwarding to set default serialize value
Avoids an extra copy plus also allows move assignment where available.
2019-10-07 22:09:17 -03:00
Howard Chu 3b8dd4b25b Updated RandomX integration from upstream
Support RandomX PoW algorithm
2019-09-25 17:12:23 -03:00
moneromooo-monero 9fc266df58 epee: misc_log_ex.h can now be used in C code
use mfatal/merror/mwarning/minfo/mdebug/mtrace
2019-09-25 14:46:53 -03:00
Doyle aaf4c5a32c Add WARNINGS_AS_ERRORS flag for release builds 2019-09-16 18:02:58 +10:00
Doyle 97c7c0f5fd Revert "Remove -Werror"
This reverts commit 707c2f836b.
2019-09-16 10:09:34 +10:00
Doyle 6689f70d09
Check wallet is connected before entering trigger happy exception functions (#838) 2019-09-13 13:10:47 +10:00
moneromooo-monero eeca5ca0c8
epee: support unicode in parsed strings 2019-08-16 17:06:03 +00:00
luigi1111 8a0711f2f2
Merge pull request #5674
fcbf7b3 p2p: propagate out peers limit to payload handler (moneromooo-monero)
098aadf p2p: close the right number of connections on setting max in/out peers (moneromooo-monero)
2019-08-15 17:22:39 -05:00
luigi1111 df064eaa36
Merge pull request #5649
a182df2 Bans for RPC connections (hyc)
2019-08-15 17:10:49 -05:00
Jason Rhinelander c8b1749333 Fix IPv6 addr parsing for boost <1.66 2019-08-15 00:24:56 -03:00
Thomas Winget 80be9b1dfa Add IPv6 support
new cli options (RPC ones also apply to wallet):
  --p2p-bind-ipv6-address (default = "::")
  --p2p-bind-port-ipv6    (default same as ipv4 port for given nettype)
  --rpc-bind-ipv6-address (default = "::1")

  --p2p-use-ipv6          (default false)
  --rpc-use-ipv6          (default false)

  --p2p-require-ipv4      (default true, if ipv4 bind fails and this is
                           true, will not continue even if ipv6 bind
                           successful)
  --rpc-require-ipv4      (default true, description as above)

ipv6 addresses are to be specified as "[xx:xx:xx::xx:xx]:port" except
in the cases of the cli args for bind address.  For those the square
braces can be omitted.
2019-08-14 23:05:22 -03:00
moneromooo-monero 78f820b2f5 remove obsolete save_graph skeleton code 2019-08-14 22:28:20 -03:00
moneromooo-monero de1f881b01 allow blocking whole subnets 2019-08-14 22:26:49 -03:00
Jason Rhinelander 9a4c1262d4 Make close() delete the connection
Without this change a connection that is explicitly close()d is not
properly deleted and so hangs around erroneously in the list of
connections (as a `before_handshake`) even though it is actually closed.
2019-08-13 02:45:56 -03:00
moneromooo-monero 7070686107 p2p: close the right number of connections on setting max in/out peers 2019-08-13 02:45:56 -03:00
Thomas Winget 155475d971
Add IPv6 support
new cli options (RPC ones also apply to wallet):
  --p2p-bind-ipv6-address (default = "::")
  --p2p-bind-port-ipv6    (default same as ipv4 port for given nettype)
  --rpc-bind-ipv6-address (default = "::1")

  --p2p-use-ipv6          (default false)
  --rpc-use-ipv6          (default false)

  --p2p-require-ipv4      (default true, if ipv4 bind fails and this is
                           true, will not continue even if ipv6 bind
                           successful)
  --rpc-require-ipv4      (default true, description as above)

ipv6 addresses are to be specified as "[xx:xx:xx::xx:xx]:port" except
in the cases of the cli args for bind address.  For those the square
braces can be omitted.
2019-07-31 20:04:57 -04:00
luigi1111 38e0e58a95
Merge pull request #5531
9a6006b abstract_tcp_server2: move some things out of a lock (moneromooo-monero)
2019-07-24 14:08:52 -05:00
luigi1111 e579fe4ae0
Merge pull request #5530
6abaaaa remove obsolete save_graph skeleton code (moneromooo-monero)
2019-07-24 14:07:29 -05:00
luigi1111 8774384ace
Merge pull request #5528
f61a315 net_utils: fix m_ssl type from time_t to bool (moneromooo-monero)
2019-07-24 14:05:18 -05:00
moneromooo-monero 65c4004963
allow blocking whole subnets 2019-07-16 11:35:53 +00:00
Doyle d0fb04db46
Improved print_checkpoints + json_rpc get_checkpoints call (#708)
* Improved print_checkpoints

* Flesh out print checkpoints and associated RPC call

* Remove debug print checkpoints

* Update help text for print_checkpoints

* Rewrite to fix num_checkpoints != heights as a unit of measurement

* Use GET_ALL_CHECKPOINTS defined value in get_checkpoints_range

* Let T be deduced in parse_if_present, json_rpc_request not rpc_request
2019-07-05 09:34:51 +10:00
Jason Rhinelander b0e2de3c1b Don't include stack trace dumping at default log-level (#710)
There are several places in loki now that legitimate use caught
exceptions, and these are polluting the logs (even at log-level=0) with
unnecessary stack traces which aren't actually errors to worry about.
2019-07-04 13:21:13 +10:00
Doyle 918cfec703
Merge pull request #671 from jagerman/ip-switch-penalty
Add penalty for switching IPs
2019-06-27 13:21:42 +10:00
Jason Rhinelander 0754885103 Tighten allowed IPv4 ranges
epee's is_ip_local is missing two ranges that are commonly found:
link-local auto-config addresses (169.254.0.0/16) that are sometimes
used as a fallback when DHCP isn't present; and the carrier-grade NAT
range (100.64.0.0/10) reserved for carriers who impose NAT on their
customers.

There are also other ranges that aren't exactly "local" but aren't
public either: 0.0.0.0/8 isn't a valid destination address; and
224.0.0.0/3 (includes includes both the 224/4 multicast range, and the
reserved (but will most likely never be used) 240.0.0.0/4 range).

These are now added to a new `is_ip_public` function that returns true
if it's not local or loopback, and not one of these special ranges.

This also simplifies some convoluted netmask logic.  (The simplification
would look better except that epee took the extremely bizarre and wrong
decision to store IPv4 addresses in little-endian order).
2019-06-26 01:14:52 -03:00
Doyle 639d7456f7 Merge commit '1d5e8f4' into LokiMergeUpstream 2019-06-26 13:04:37 +10:00
Doyle f761ed6345 Merge commit '51766d0' into LokiMergeUpstream 2019-06-26 12:43:21 +10:00