Commit Graph

539 Commits

Author SHA1 Message Date
Sean Darcy 866691d9d8 Batching of service node rewards
This updates the coinbase transactions to reward service nodes
periodically rather than every block. If you recieve a service node
reward this reward will be delayed x blocks, if you receive another
reward to the same wallet before those blocks have been completed it
will be added to your total and all will be paid out after those x
blocks has passed.

For example if our batching interval is 2 blocks:

Block 1 - Address A receives reward of 10 oxen - added to batch
Block 2 - Address A receives reward of 10 oxen - added to batch
Block 3 - Address A is paid out 20 oxen.

Batching accumulates a small reward for all nodes every block

The batching of service node rewards allows us to drip feed rewards
to service nodes. Rather than accruing each service node 16.5 oxen every
time they are pulse block leader we now reward every node the 16.5 /
num_service_nodes every block and pay each wallet the full amount that
has been accrued after a period of time (Likely 3.5 days).

To spread each payment evenly we now pay the rewards based on the
address of the recipient. This modulus of their address determines which
block the address should be paid and by setting the interval to our
service_node_batching interval we can guarantee they will be paid out
regularly and evenly distribute the payments for all wallets over this
2022-04-29 09:51:14 +10:00
Jason Rhinelander 5e95cef882
Remove openssl, unbound, expat, OpenAlias
openssl is a miserable dependency to fight with, especially for
iOS/Android, and we use it for very little:

- it gets (mis)used to write base64 data to a file in wallet2 for things
  like multisig data.  However this mode is *not* enabled by default,
  basically completely unknown, completely unused, only exists in the
  cli wallet, and is just dumb.  (Honestly the justification given in
  the PR is that "Windows users might want it", presupposing that there
  exists Windows users who are capable of generating a multisig wallet
  in a CLI-only application and yet are incapable of dealing with binary
  files).

- it's a dependency of unbound (in order to do dnssec, I believe).
  Unbound itself is fairly useless for Oxen, so I've removed it too:
    - it does OpenAlias lookups, which are a Monero thing that has never
      been used outside Monero, doesn't work reliably (because it fails
      if the result isn't DNSSEC validated) and is pointless when we
      have ONS.

    - it does DNS resolution on seed nodes, but we have never set seed
      nodes by name and just use seed node IPs instead (which seems a
      bit better anyway since the DNS lookup leaks some metadata).

- it *was* being used for sha256, but an earlier commit in this PR
  already replaced that with libsodium (entirely coincidentally).

- for static deps, it enables HTTPS support for the wallet.  However
  only the CLI wallet actually supports this (the GUI and mobile wallets
  don't), and since oxend hasn't support this for a while I have strong
  doubts it is being used anywhere.  (Plus wallet3 will do everything
  encrypted using zmq/libsodium, so doesn't need this to be secure).
  Note here that it is *only* removed by this commit for static builds:
  if doing a system build that links to libcurl supporting HTTPS then
  HTTPS support will still work.

Libexpat is also gone because it was only there for libunbound.
2022-04-15 13:51:57 -03:00
Jason Rhinelander 47ff596533
Remove UPnP support
We have disabled uPnP by default for nearly a year now (#1423) with no
adverse affects; this commit finishes it off entirely, removing it from
the codebase.

Fixes #1419 -- see discussion in that issue for why UPnP really doesn't
add much utility to Oxen.
2022-04-14 14:34:49 -03:00
Thomas Winget 73e787a9ec sqlitecpp cmake nonsense 2021-10-06 19:36:46 -04:00
Jeff 5597fc748b
Update CMakeLists.txt
consolidate the cmake logic
2021-10-04 21:18:08 -04:00
Thomas Winget 435c189a9b sqlitecpp 2021-10-04 20:33:24 -04:00
Jason Rhinelander 5f1bd2f1e4 Drop integration test code.
This code is bitrotting, doesn't compile, and isn't being maintained
anymore.

The integration test suite was an interesting idea, in early Loki days,
but is no longer being maintained and is quite cumbersome to run (for
instance, it is not possible to run it via CI because it depends on
xterm to actually run).  The code to actually run it (in doy-lee's
loki-integration-testing repository) is also a large burden of "janky"
code that isn't worth maintaining.

Remove this from the code; if someone wants to pick it back up in the
future reverting this commit shouldn't be too difficult (though I'd
suggest that a much better approach to integration testing would be to
run different daemons/wallets via rpc commands, as the network-tests do,
rather than trying to feed stdin and parse stdout from running
individual oxends/wallets).
2021-08-19 16:42:15 -03:00
Jason Rhinelander 3644861971 lokinet/SS minimum proof versions; 9.2.0 version bump
Remove support for old (non-bt) proofs with the 9.2.0 snode revision
block (I'm not 100% sure on what to call this; "snode revision"? "soft
fork"? "spork"?).

Also bumps the working version to 9.2.0; this likely isn't release
ready, but allows for testing of this on testnet.
2021-06-19 15:13:57 -03:00
Jason Rhinelander f24fc05f2f Version bump 2021-06-10 16:00:41 -03:00
Jason Rhinelander 041d01318e Disable -fstack-clash-protection on macOS
It breaks the build on the latest Big Sur Xcode version because it
accepts the option but then later produces warnings about it being
unused when trying to use it.
2021-05-12 12:00:23 -03:00
Jason Rhinelander add87f2519 Modernize how -pie gets set
Let cmake deal with setting up -pie; this ought to avoid a bunch of
unused argument errors on apple clang where -pie is being forced on
incorrectly.
2021-05-12 12:00:23 -03:00
Jason Rhinelander e5bc4e31c4 Clean up pkg-config use
- Convert pkg-config library finding to use IMPORTED_TARGET rather than
the old hacky way of using multiple variables.

- Remove libunbound finding from external (it gets set up already in the
root CMakeLists.txt)

- Remove libzmq searching since we no longer directly depend on it
(except through oxenmq).
2021-05-12 11:59:22 -03:00
Jason Rhinelander c789fd5d77 Remove dead DEPENDS code
We dropped the contrib/depends build system quite a while ago (because
it was nasty), but there are still various DEPENDS checks scattered
through cmake that are just dead code now.  This removes them.
2021-05-12 10:46:57 -03:00
Jason Rhinelander c5143f0a31 9.1.2 hotfix -- fix proofs for older nodes with both pubkeys
bt-encoded proofs have a bug for nodes with different legacy/ed25519
pubkeys that isn't easily solvable (it needs a fix on *both* sender and
receiver ends).  That fix is in here (in uptime_proof.cpp) but that
isn't enough to solve it immediately.

This works around the issue by submitting old-style proofs if we are a
node with different legacy/ed25519 pubkeys.
2021-04-29 21:23:16 -03:00
Jason Rhinelander 9eb1743949 Update codename 2021-04-23 00:28:19 -03:00
Sean Darcy 2f12e84938 Bump versions and minimum versions for uptime proofs 2021-04-22 14:01:56 +10:00
Jason Rhinelander 2fb0dbcaa3 Tweak uptime proof times; reduce times for testnet
This makes uptime proof times network-dependent, and tweaks them a bit.
Also converts the times to type-safe std::chrono types rather than
macros.

Mainnet/testnet/devnet:

- Send the first proof 30s after startup rather than waiting 2 minutes.
- Check for whether we need to send a proof every 30s rather than every
5mins.

Mainnet:

Other times unchanged.

Testnet/devnet:

- Send proofs every 10min instead of 1h, and consider nodes to be down
after 21m instead of 2h5m.

Fakechain:

- Send 5s after startup, check every 5s, and send every 1min.
- Expiry after 2min5s

Also remove the cmake debug option for short proofs since the fakechain
changes above basically incorporate what it did.
2021-03-25 11:46:23 -03:00
Jason Rhinelander 2861648627 Merge remote-tracking branch 'origin/stable' into dev 2021-01-08 19:36:58 -04:00
Jason Rhinelander eca6b6ad8d Disable Trezor by default
Trezor support currently doesn't work (Trezor's hardware wallet is
hard-coded for a Monero net-id), and this saves needing to muck around
with protobuf.
2021-01-08 18:15:25 -04:00
Jason Rhinelander 645ce86393 Bump version to 8.1.5 2021-01-07 18:43:40 -04:00
Sean Darcy ccd712542d executable names changed 2021-01-07 18:40:18 -04:00
Sean Darcy 432dc319a9 executable names changed 2021-01-04 14:19:42 +11:00
Sean Darcy 5b30dea2a4 bump to 9.0.0 2020-12-18 16:06:02 +11:00
Sean Darcy ed5b946c0a quorumnet message for timestamp requests
random sampling of service nodes, call timestamp lmq message

checks timestamp of 5 service nodes, if local time is 30 seconds different from 80% of the nodes tested then warn user

tracks external timesync status and timestamp participation of service nodes

clean up includes

new template struct for participation history, individual types for participation entry

refactor checking participation

update select_randomly, move the testing for variance overflow

version locks, bump to 8.1.5

explicit casting for mac & clang

note to remove after hard fork

timestamp debugging log messages

debugging messages for before timesync - before message sent

logging errord with compiling

print version and change add_command to add_request_command

log if statement test

std::to_string replaced with tools::view_guts for x25519 key

check if my sn is active before sending timestamp requests

logging the failures

checking if statement for success of message

more logging, if guards arn't passing

more logging, successfully tests if service node might be out of sync

more tests before we decide we are out of sync

logging output if sn isn't passing tests

if check_participation fails then disconnect

print timestamp status

remove saving variance from the participation history

reduce MIN_TIME_IN_S_BEFORE_VOTING

reset participation history on recommission

undo reduction in startup time

reduce log levels

Set hardfork time in testnet
2020-12-18 16:05:51 +11:00
Jason Rhinelander 8e3ed0efa8
Merge pull request #1355 from loki-project/dev
Merge dev -> stable branch for 8.1.4 release
2020-11-19 23:29:29 -04:00
Jason Rhinelander 77424b0edf 8.1.4 version bump 2020-11-19 22:56:17 -04:00
Jason Rhinelander 24dd1ee800 Merge remote-tracking branch 'origin/dev' into 813-release 2020-11-11 15:19:21 -04:00
Jason Rhinelander 4d8718692a Bump version 2020-11-11 15:18:34 -04:00
Jason Rhinelander 8db38d6f23 Replace CMakeLists_IOS.txt hack job with proper toolchain file 2020-11-04 15:06:59 -04:00
Jason Rhinelander 1127ac51fd Remove BUILD_GUI_DEPS, enable FORCE_USE_HEAP on android
BUILD_GUI_DEPS was dumb: it should have just been a non-"all" target (as
it is now) that can be explicitly built, rather than misusing a cmake
option.

It was doing one useful thing, however, of turning on FORCE_USE_HEAP --
but that was wrong too, because that needs to be enabled when doing an
android build (and probably IOS as well).
2020-11-04 12:11:20 -04:00
Jason Rhinelander bb40433612 Android build infrastructure updates
- Various static deps updated needed for properly cross-compiling
libraries for android.
- disable LTO because it doesn't work reliably with the android NDK.
- allow building without miniupnpc, and default to not building it under
android.
- make sure we build translation tools on the native arch when
cross-compiling for android.
- don't build ncurses, libusb, hidapi when doing an android build
2020-11-04 12:11:20 -04:00
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 682ed158a7 Make untagged stable builds add -<n>-<tag> suffix 2020-10-23 00:46:56 -03:00
Jason Rhinelander fd1a3e4dab 8.1.2 release 2020-10-20 03:24:34 -03:00
Jason Rhinelander 3608fdd9ca 8.1.2 version bump 2020-10-19 23:41:02 -03:00
Jason Rhinelander b7dd5e8911 Target macos 10.12
When targetting macos <10.14 macos won't allow use of anything from
C++17 that throws, such as:
- std::get on a variant
- std::visit
- std::optional::value()
- std::any_cast

This avoids all of these.

For std::get, we either replace with std::get_if (where appropriate), or
else use a `var::get` implementation of std::get added to lokimq (also
updated here).  (This `var` namespace is just an `std` alias everywhere
*except* old target macos).

For std::visit, likewise lokimq adds an var::visit implementation for
old macos that we use.

std::optional::value() uses weren't useful anyway as everywhere it calls
them we've already checked that the option has a value, in which case we
can use `*opt` (which doesn't check for contents and throw).

std::any just has to be avoided as far as I can tell, but the one place
we used it is only ever a block, so I just replaced it with a `const
block*`.
2020-10-18 11:18:08 -03:00
Jason Rhinelander 0a42731829
Merge pull request #1321 from jagerman/macos1014
Macos 10.14 compatibility
2020-10-15 19:50:52 -03:00
Jason Rhinelander de924e80ac MacOS 10.14 compatibility 2020-10-13 18:13:08 -03:00
Jason Rhinelander bf4f62c58a Fix release suffix for stable 2020-10-11 23:00:36 -03:00
Jason Rhinelander 674fa682bb
Bump version (mainly wallet-related fixes) (#1312) 2020-10-12 10:43:29 +11:00
Jason Rhinelander 27aa2fb9bc Merge remote-tracking branch 'origin/stable' into dev 2020-10-03 23:35:37 -03:00
Jason Rhinelander f6c3adfb8e Small tweaks to build system
- make tagged and stable branch builds not add git tag to the tar.xz
  filename
- copy apt-get tweaks (to make it less noisy) from deb branches
- do a faster shallow submodule clone
- remove exclusion for removed is_hdd test
- remove deb_builder (deb building drone code is in its own branches)
- fix upload dir for a tagged build
2020-10-03 23:24:08 -03:00
Jason Rhinelander 9ae405c06c Merge commit '61d6564bc' into dev 2020-10-01 21:27:38 -03:00
Jason Rhinelander 61d6564bc3 Remove -dev suffix for stable branch 2020-10-01 21:21:37 -03:00
Jason Rhinelander 915e6109f6
Bump version to 8.1.0 and set HF16/17 fork times (#1295) 2020-10-01 11:36:25 +10:00
Jason Rhinelander a0bfda8e25 Bump version with testnet fixes 2020-09-29 20:26:52 -03:00
Jason Rhinelander 9eb854dedb
Drone: don't build debug tools in static builds (#1281)
The strip_binaries target was depending on all binaries, including
debug utilities, and so the static builds would end up building and
including them.

This makes strip_binaries not strip or depend on EXCLUDE_FROM_ALL
targets (or targets inside EXCLUDE_FROM_ALL directories) to prevent
this.  (A separate strip_binaries_all target is set up in case someone
builds them and wants to strip them as well).
2020-09-26 12:59:34 +10:00
Jason Rhinelander 23cecefe6f Merge remote-tracking branch 'origin/master' into master-to-dev 2020-09-21 19:09:14 -03:00
Jason Rhinelander b3f3de135d Bump dev version to 8.0.0
(For anyone watching at home: 8.0.x is our testnet version, the first
release meant for mainnet will be 8.1.0).
2020-09-18 19:21:48 -03:00
Jason Rhinelander 42a7e83c33 Replace epee http rpc server with uWebSockets
This replaces the NIH epee http server which does not work all that well
with an external C++ library called uWebSockets.  Fundamentally this
gives the following advantages:

- Much less code to maintain
- Just one thread for handling HTTP connections versus epee's pool of
threads
- Uses existing LokiMQ job server and existing thread pool for handling
the actual tasks; they are processed/scheduled in the same "rpc" or
"admin" queues as lokimq rpc calls.  One notable benefit is that "admin"
rpc commands get their own queue (and thus cannot be delayed by long rpc
commands).  Currently the lokimq threads and the http rpc thread pool
and the p2p thread pool and the job queue thread pool and the dns lookup
thread pool and... are *all* different thread pools; this is a step
towards consolidating them.
- Very little mutex contention (which has been a major problem with epee
RPC in the past): there is one mutex (inside uWebSockets) for putting
responses back into the thread managing the connection; everything
internally gets handled through (lock-free) lokimq inproc sockets.
- Faster RPC performance on average, and much better worst case
performance.  Epee's http interface seems to have some race condition
that ocassionally stalls a request (even a very simple one) for a dozen
or more seconds for no good reason.
- Long polling gets redone here to no longer need threads; instead we
just store the request and respond when the thread pool, or else in a
timer (that runs once/second) for timing out long polls.

---

The basic idea of how this works from a high level:

We launch a single thread to handle HTTP RPC requests and response data.
This uWebSockets thread is essentially running an event loop: it never
actually handles any logic; it only serves to shuttle data that arrives
in a request to some other thread, and then, at some later point, to
send some reply back to that waiting connection.  Everything is
asynchronous and non-blocking here: the basic uWebSockets event loop
just operates as things arrive, passes it off immediately, and goes back
to waiting for the next thing to arrive.

The basic flow is like this:

    0. uWS thread -- listens on localhost:22023
    1. uWS thread -- incoming request on localhost:22023
    2. uWS thread -- fires callback, which injects the task into the LokiMQ job queue
    3. LMQ main loop -- schedules it as an RPC job
    4. LMQ rpc thread -- Some LokiMQ thread runs it, gets the result
    5. LMQ rpc thread -- Result gets queued up for the uWS thread
    6. uWS thread -- takes the request and starts sending it
       (asynchronously) back to the requestor.

In more detail:

uWebSockets has registered has registered handlers for non-jsonrpc
requests (legacy JSON or binary).  If the port is restricted then admin
commands get mapped to a "Access denied" response handler, otherwise
public commands (and admin commands on an unrestricted port) go to the
rpc command handler.

POST requests to /json_rpc have their own handler; this is a little
different than the above because it has to parse the request before it
can determine whether it is allowed or not, but once this is done it
continues roughly the same as legacy/binary requests.

uWebSockets then listens on the given IP/port for new incoming requests,
and starts listening for requests in a thread (we own this thread).
When a request arrives, it fires the event handler for that request.
(This may happen multiple times, if the client is sending a bunch of
data in a POST request).  Once we have the full request, we then queue
the job in LokiMQ, putting it in the "rpc" or "admin" command
categories.  (The one practical different here is that "admin" is
configured to be allowed to start up its own thread if all other threads
are busy, while "rpc" commands are prioritized along with everything
else.)  LokiMQ then schedules this, along with native LokiMQ "rpc." or
"admin." requests.

When a LMQ worker thread becomes available, the RPC command gets called
in it and runs.  Whatever output it produces (or error message, if it
throws) then gets wrapped up in jsonrpc boilerplate (if necessary), and
delivered to the uWebSockets thread to be sent in reply to that request.

uWebSockets picks up the data and sends whatever it can without
blocking, then buffers whatever it couldn't send to be sent again in a
later event loop iteration once the requestor can accept more data.
(This part is outside lokid; we only have to give uWS the data and let
it worry about delivery).

---

PR specifics:

Things removed from this PR:

1. ssl settings; with this PR the HTTP RPC interface is plain-text.  The
previous default generated a self-signed certificate for the server on
startup and then the client accepted any certificate.  This is actually
*worse* than unencrypted because it is entirely MITM-readable and yet
might make people think that their RPC communication is encrypted, and
setting up actual certificates is difficult enough that I think most
people don't bother.

uWebSockets *does* support HTTPS, and we could glue the existing options
into it, but I'm not convinced it's worthwhile: it works much better to
put HTTPS in a front-end proxy holding the certificate that proxies
requests to the backend (which can then listen in restricted mode on
some localhost port).  One reason this is better is that it is much
easier to reload and/or restart such a front-end server, while
certificate updates with lokid require a full restart.  Another reason
is that you get an error page instead of a timeout if something is wrong
with the backend.  Finally we also save having to generate a temporary
certificate on *every* lokid invocation.

2. HTTP Digest authentication.  Digest authentication is obsolete (and
was already obsolete when it got added to Monero).  HTTP-Digest was
originally an attempt to provide a password authentication mechanism
that does not leak the password in transit, but still required that the
server know the password.  It only has marginal value against replay
attacks, and is made entirely obsolete by sending traffic over HTTPS
instead.  No client out there supports Digest but *not* Basic auth, and
so given the limited usefulness it seems pointless to support more than
Basic auth for HTTP RPC login.

What's worse is that epee's HTTP Digest authentication is a terrible
implementation: it uses boost::spirit -- a recursive descent parser
meant for building complex language grammars -- just to parse a single
HTTP header for Digest auth.  This is a big load of crap that should
never have been accepted upstream, and that we should get rid of (even
if we wanted to support Digest auth it takes less than 100 lines of code
to do it when *not* using a recursive descent parser).
2020-08-07 17:14:02 -03:00