Commit graph

654 commits

Author SHA1 Message Date
Doyle
4cc48ed813 Merge commit 'fe73607' into MergeUpstream3 2020-05-27 14:38:37 +10:00
Doyle
2e42202e94 Merge commit 'dcff02e4c3b1214143b19685361c3c6cffa62be7' into MergeUpstream3 2020-05-26 15:15:25 +10:00
Doyle
6a357fa499 Merge commit '23547e6ed6c9f0dc694d55316540000b030bbb06' into MergeUpstream3 2020-05-20 18:14:48 +10:00
Jason Rhinelander
44d6715d56 Make suspend_readline a (usable) no-op when readline not available
This moves all the conditional HAVE_READLINE into once place rather than
scattering it everywhere we want to suspend readline.  (Since the class
does nothing the compiler can trivially optimize it away when we don't
have readline).
2020-05-20 00:48:59 -03:00
Jason Rhinelander
b1cad5ced9 Simplify readline linking
Link readline directly into epee; having a separate epee_readline
library is not saving anything since we have it widely linked anyway.
Conditionally linking it to epee simplifies a bit of CMake code.

Also simplify how epee detects cmake to just look for a `readline`
target, which we now only set up if we find readline in the top-level
CMakeLists.txt
2020-05-20 00:47:38 -03:00
Jason Rhinelander
0e3f173c7f RPC overhaul
High-level details:

This redesigns the RPC layer to make it much easier to work with,
decouples it from an embedded HTTP server, and gets the vast majority of
the RPC serialization and dispatch code out of a very commonly included
header.

There is unfortunately rather a lot of interconnected code here that
cannot be easily separated out into separate commits.  The full details
of what happens here are as follows:

Major details:
- All of the RPC code is now in a `cryptonote::rpc` namespace; this
  renames quite a bit to be less verbose: e.g. CORE_RPC_STATUS_OK
  becomes `rpc::STATUS_OK`, and `cryptonote::COMMAND_RPC_SOME_LONG_NAME`
  becomes `rpc::SOME_LONG_NAME` (or just SOME_LONG_NAME for code already
  working in the `rpc` namespace).
- `core_rpc_server` is now completely decoupled from providing any
  request protocol: it is now *just* the core RPC call handler.
- The HTTP RPC interface now lives in a new rpc/http_server.h; this code
  handles listening for HTTP requests and dispatching them to
  core_rpc_server, then sending the results back to the caller.
- There is similarly a rpc/lmq_server.h for LMQ RPC code; more details
  on this (and other LMQ specifics) below.
- RPC implementing code now returns the response object and throws when
  things go wrong which simplifies much of the rpc error handling.  They
  can throw anything; generic exceptions get logged and a generic
  "internal error" message gets returned to the caller, but there is
  also an `rpc_error` class to return an error code and message used by
  some json-rpc commands.
- RPC implementing functions now overload `core_rpc_server::invoke`
  following the pattern:

    RPC_BLAH_BLAH::response core_rpc_server::invoke(RPC_BLAH_BLAH::request&& req, rpc_context context);

  This overloading makes the code vastly simpler: all instantiations are
  now done with a small amount of generic instantiation code in a single
  .cpp rather than needing to go to hell and back with a nest of epee
  macros in a core header.
- each RPC endpoint is now defined by the RPC types themselves,
  including its accessible names and permissions, in
  core_rpc_server_commands_defs.h:
  - every RPC structure now has a static `names()` function that returns
    the names by which the end point is accessible.  (The first one is
    the primary, the others are for deprecated aliases).
  - RPC command wrappers define their permissions and type by inheriting
    from special tag classes:
    - rpc::RPC_COMMAND is a basic, admin-only, JSON command, available
      via JSON RPC.  *All* JSON commands are now available via JSON RPC,
      instead of the previous mix of some being at /foo and others at
      /json_rpc.  (Ones that were previously at /foo are still there for
      backwards compatibility; see `rpc::LEGACY` below).
    - rpc::PUBLIC specifies that the command should be available via a
      restricted RPC connection.
    - rpc::BINARY specifies that the command is not JSON, but rather is
      accessible as /name and takes and returns values in the magic epee
      binary "portable storage" (lol) data format.
    - rpc::LEGACY specifies that the command should be available via the
      non-json-rpc interface at `/name` for backwards compatibility (in
      addition to the JSON-RPC interface).
- some epee serialization got unwrapped and de-templatized so that it
  can be moved into a .cpp file with just declarations in the .h.  (This
  makes a *huge* difference for core_rpc_server_commands_defs.h and for
  every compilation unit that includes it which previously had to
  compile all the serialization code and then throw all by one copy away
  at link time).  This required some new macros so as to not break a ton
  of places that will use the old way putting everything in the headers;
  The RPC code uses this as does a few other places; there are comments
  in contrib/epee/include/serialization/keyvalue_serialization.h as to
  how to use it.
- Detemplatized a bunch of epee/storages code.  Most of it should have
  have been using templates at all (because it can only ever be called
  with one type!), and now it isn't.  This broke some things that didn't
  properly compile because of missing headers or (in one case) a messed
  up circular dependency.
- Significantly simplified a bunch of over-templatized serialization
  code.
- All RPC serialization definitions is now out of
  core_rpc_server_commands_defs.h and into a single .cpp file
  (core_rpc_server_commands_defs.cpp).
- core RPC no longer uses the disgusting
  BEGIN_URI_MAP2/MAP_URI_BLAH_BLAH macros.  This was a terrible design
  that forced slamming tons of code into a common header that didn't
  need to be there.
- epee::struct_init is gone.  It was a horrible hack that instiated
  multiple templates just so the coder could be so lazy and write
  `some_type var;` instead of properly value initializing with
  `some_type var{};`.
- Removed a bunch of useless crap from epee.  In particular, forcing
  extra template instantiations all over the place in order to nest
  return objects inside JSON RPC values is no longer needed, as are a
  bunch of stuff related to the above de-macroization of the code.
- get_all_service_nodes, get_service_nodes, and get_n_service_nodes are
  now combined into a single `get_service_nodes` (with deprecated
  aliases for the others), which eliminates a fair amount of
  duplication.  The biggest obstacle here was getting the requested
  fields reference passed through: this is now done by a new ability to
  stash a context in the serialization object that can be retrieved by a
  sub-serialized type.

LMQ-specifics:

- The LokiMQ instance moves into `cryptonote::core` rather than being
  inside cryptonote_protocol.  Currently the instance is used both for
  qnet and rpc calls (and so needs to be in a common place), but I also
  intend future PRs to use the batching code for job processing
  (replacing the current threaded job queue).
- rpc/lmq_server.h handles the actual LMQ-request-to-core-RPC glue.
  Unlike http_server it isn't technically running the whole LMQ stack
  from here, but the parallel name with http_server seemed appropriate.
- All RPC endpoints are supported by LMQ under the same names as defined
  generically, but prefixed with `rpc.` for public commands and `admin.`
  for restricted ones.
- service node keys are now always available, even when not running in
  `--service-node` mode: this is because we want the x25519 key for
  being able to offer CURVE encryption for lmq RPC end-points, and
  because it doesn't hurt to have them available all the time.  In the
  RPC layer this is now called "get_service_keys" (with
  "get_service_node_key" as an alias) since they aren't strictly only
  for service nodes.  This also means code needs to check
  m_service_node, and not m_service_node_keys, to tell if it is running
  as a service node.  (This is also easier to notice because
  m_service_node_keys got renamed to `m_service_keys`).
- Added block and mempool monitoring LMQ RPC endpoints: `sub.block` and
  `sub.mempool` subscribes the connection for new block and new mempool
  TX notifications.  The latter can notify on just blink txes, or all
  new mempool txes (but only new ones -- txes dumped from a block don't
  trigger it).  The client gets pushed a [`notify.block`, `height`,
  `hash`] or [`notify.tx`, `txhash`, `blob`] message when something
  arrives.

Minor details:
- rpc::version_t is now a {major,minor} pair.  Forcing everyone to pack
  and unpack a uint32_t was gross.
- Changed some macros to constexprs (e.g. CORE_RPC_ERROR_CODE_...).
  (This immediately revealed a couple of bugs in the RPC code that was
  assigning CORE_RPC_ERROR_CODE_... to a string, and it worked because
  the macro allows implicit conversion to a char).
- De-templatizing useless templates in epee (i.e. a bunch of templated
  types that were never invoked with different types) revealed a painful
  circular dependency between epee and non-epee code for tor_address and
  i2p_address.  This crap is now handled in a suitably named
  `net/epee_network_address_hack.cpp` hack because it really isn't
  trivial to extricate this mess.
- Removed `epee/include/serialization/serialize_base.h`.  Amazingly the
  code somehow still all works perfectly with this previously vital
  header removed.
- Removed bitrotted, unused epee "crypted_storage" and
  "gzipped_inmemstorage" code.
- Replaced a bunch of epee::misc_utils::auto_scope_leave_caller with
  LOKI_DEFERs.  The epee version involves quite a bit more instantiation
  and is ugly as sin.  Also made the `loki::defer` class invokable for
  some edge cases that need calling before destruction in particular
  conditions.
- Moved the systemd code around; it makes much more sense to do the
  systemd started notification as in daemon.cpp as late as possible
  rather than in core (when we can still have startup failures, e.g. if
  the RPC layer can't start).
- Made the systemd short status string available in the get_info RPC
  (and no longer require building with systemd).
- during startup, print (only) the x25519 when not in SN mode, and
  continue to print all three when in SN mode.
- DRYed out some RPC implementation code (such as set_limit)
- Made wallet_rpc stop using a raw m_wallet pointer
2020-05-11 18:44:45 -03:00
Jason Rhinelander
52838aa5b2 "Remove namespace pollution" << ENDL
Removes all "using namespace epee;" and "using namespace std;" from the
code and fixes up the various crappy places where unnamespaced types
were being used.

Also removes the ENDL macro (which was defined to be `std::endl`)
because it is retarded, and because even using std::endl instead of a
plain "\n" is usually a mistake (`<< std::endl` is equivalent to `<<
"\n" << std::flush`, and that explicit flush is rarely desirable).
2020-05-11 18:44:45 -03:00
Jason Rhinelander
14fcc7cad1 Make --help support >80 char width terminals 2020-05-11 18:44:45 -03:00
Jason Rhinelander
a46c1a33cb Resort common source code files
The list was *mostly* sorted by newer additions had been inserted in
random places.
2020-05-11 18:44:45 -03: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
Jason Rhinelander
d3098ce023 Simplify/enhance command_line::is_yes etc.
This uses templates to simplify the is_yes (etc.) functions, also
removing a boost dependency and making them more flexible where callers
sometimes want "is_yes or one of these other truthy strings".
2020-05-11 18:44:45 -03:00
luigi1111
9c660e159e
Merge pull request #6278
387fd66 Daemon: Print estimates for time until fully synced (rbrunner7)
2020-04-21 08:19:02 -05:00
Doyle
a8365c9f7e Merge commit '633f14b9766f0aa9786147c0c151322380bb5c18' into MergeUpstream 2020-04-06 15:23:05 +10:00
luigi1111
6c7d928f19
Merge pull request #6336
760ecf2 console_handler: do not let exception past the dor (moneromooo-monero)
09c8111 threadpool: lock mutex in create (moneromooo-monero)
e377977 tx_pool: catch theoretical error in get_block_reward (moneromooo-monero)
2020-03-31 15:14:12 -05:00
Doyle
a188a79981 LNS: Pretty print mapping value, fix base32z::encode bug 2020-03-24 12:21:22 +11: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
Jason Rhinelander
c98688fd84 Convert quorumnet to loki-mq
This adds the loki-mq dependency and replaces SNNetwork with it (along
with some syntax updates for how loki-mq changed a bit from SNNetwork).

This also replaces common/hex.h and common/string_view.h with loki-mq's
faster (hex) and more complete and tested (string_view) implementations.
2020-03-06 00:36:57 -04: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
Alexander Blair
8c2939a7cb
Merge pull request #6058
88b82bef simplewallet: point to "set help" in the lock screen message (moneromooo-monero)
f19c9f23 util: allow newlines in string to be split (moneromooo-monero)
2020-02-28 19:54:37 -08:00
Doyle
df69008d07
Move simple string view out to common/string_view.h (#1049) 2020-02-28 12:00:54 +11:00
Doyle
8aacc33fb1
Rewrite the integration tests to use pipes (#1045) 2020-02-21 14:48:25 +11:00
Doyle
e3a6f20f85 Code review
- constexpr functions in common/loki.h for inlining
- move hex functions out from common/loki.h to common/hex.h
- use and apply prev_txid on LNS TX's to all LNS types (for updating in the future)
- add lns burn type, for custom burn amounts
- accept and validate lokinet addresses via base32z
- return lokinet addresses in RPC LNS calls via base32z
- updated Messenger references to Session
- update documentation to note that only Session LNS entries are allowed currently
- remove raw c-string interface from LNS db
- update multi-SQL queries into single SQL queries
- remove tx estimation backlog in anticipation for 2 priorities only, blink + unimportant
2020-02-13 11:07:47 +11:00
Doyle
9f3c97881e Force all incoming LNS txs to represent values as hex in the name->value mapping 2020-02-13 11:07:46 +11:00
Doyle
658db0c3f1 Add query LNS mappings to the CLI wallet 2020-02-13 11:07:46 +11:00
Doyle
aedd3675e7 Add lokinet domain name validation 2020-02-13 11:07:46 +11:00
moneromooo-monero
09c8111c53
threadpool: lock mutex in create
In some contrived case, it might theoretically be the case that
destroy is called from another thread, which would modify the
threads array from two threads.

Coverity 208372
2020-02-12 21:05:28 +00:00
Alexander Blair
bd4acbf44c
Merge pull request #6183
3813a992 download: catch exceptions checking for size (moneromooo-monero)
2020-02-06 00:34:58 -08:00
Alexander Blair
af27276452
Merge pull request #6178
7ac7d5d3 updates: fix source code URL on _WIN32 (selsta)
2020-02-06 00:33:49 -08:00
Alexander Blair
5558919e56
Merge pull request #6128
9fe8a76c perf_timer: fix pause/resume macros dereferencing too much (moneromooo-monero)
2020-01-24 20:06:12 -08:00
Alexander Blair
c39ea485a0
Merge pull request #6141
b9b5c473 threadpool: use std::move when taking an element off the queue (moneromooo-monero)
2020-01-16 17:45:44 -08:00
Jason Rhinelander
b51fd0c5db --regtest fixes and mine n blocks ability
`--regtest` didn't work in some edge cases, this fixes various things:

- the genesis block wasn't accepted because it needed to be v7, not
  vMax
- reduce initial uptime proof delay to 5s in regtest mode
- add --regtest flag to the wallet so that it can talk to a daemon in
  --regtest mode.

This also adds two new mining options, available via rpc:

- slow_mining - this avoids the RandomX initialization.  It is much
  slower, but for regtest with fixed difficulty of 1 that is perfectly
  fine.
- `num_blocks` - instruct the miner to mine for the given number of
  blocks, then stop.  (This can overmine if mining with multiple
  threads at a low difficulty, but that's fine).
2019-12-26 12:29:05 -04:00
Jason Rhinelander
63b52422f6 macos workaround: use boost::shared_mutex
The MacOSX 10.11 SDK we use is broken AF: it lies about supporting
C++14, but really only upgraded the headers but not the library itself,
so using std::shared_timed_mutex just results in a linking failure.

Upgrading the SDK is a huge pain (I tried, failed, and gave up), so for
now temporarily switch to boost::shared_mutex until we sort out the
macOS build disaster.
2019-12-23 15:02:20 -04:00
Jason Rhinelander
fab8ded246 Cleanup on block adding failure (#983)
If a block adding fails (triggering the "Block added hook signalled
failure" error message) the service node list doesn't get reset, which
immediately leads to a bad service node winner (because the winner was
already incremented and not popped off).

This updates it to call the blockchain detached hooks to do the cleanup.

It also changes around loki::defer a little bit to rename the internal
class to `deferred` and make it cancellable (by calling `.cancel()`).
`loki::defer` is repurposed as a free function to get a named `deferred`
object given a lambda, which is needed to be able to call `cancel()` on
it.  (The LOKI_DEFER macro still works as is).
2019-12-16 08:49:35 +10:00
Jason Rhinelander
7eca201eb5 Admit defeat for now: use boost::lock
macOS's std::lock() is broken in that it internally calls non-namespaced
function `try_lock` leading to an ADL conflict with boost::try_lock when
any of the arguments is a `boost::whatever`.  `boost::lock` will do the
job for now.
2019-12-12 01:35:35 -04:00
Jason Rhinelander
0538f6aa7d Attempted fix to make macOS clang happy 2019-12-12 01:05:42 -04:00
Jason Rhinelander
55bd5941aa Add helper header/func to obtain unique locks
auto locks = tools::unique_locks(mutex1, mutex2, ...);

gives you a tuple of unique_locks and obtains the locks atomically.

    auto lock = tools::unique_lock(lock1);

is essentially the same as:

    std::unique_lock<decltype(lock1)> lock{lock1};

but less ugly (and extends nicely to the plural version).
2019-12-11 23:28:05 -04:00
Doyle
05009ae7c9
Merge pull request #958 from jagerman/timing-fixes
Remove broken timing "optimization"
2019-12-06 16:23:27 +10:00
Jason Rhinelander
9ccdff7b1c Fix variables names in .h to agree with .cpp 2019-12-06 01:46:35 -04:00
Jason Rhinelander
ebffacd66a Remove broken timing "optimization"
This reverts the parts of upstream commit
6cf56682bc related to doing rdtsc timing
on x86-64 because it is incredibly broken:

- rdtsc is not a reliable duration timer on x86-64 on all: among other
  problems, CPU frequencies are not even close to constant, nor are
  returned values reliable across threads.

- As if the unreliability wasn't bad enough, this code also spends a
  **full second** in a busy loop to try to measure the number of rdtsc
  ticks per wallclock nanosecond, and does this during static
  initialization.  Thus every invocation of every binary wastes a full
  second a CPU to calibrate some timer ratio value that isn't even
  remotely reliable in the first place.

The second one is particularly annoying: trying to run `--help` or
invoke an rpc command adds a full second of 100% CPU usage delay.
Before this commit:

    $ time ./bin/lokid --help >/dev/null

    real    0m1.018s
    user    0m1.014s
    sys     0m0.004s

and after:

    $ time ./bin/lokid --help >/dev/null

    real    0m0.013s
    user    0m0.008s
    sys     0m0.004s
2019-12-05 21:35:10 -04:00
Jason Rhinelander
b7d34507a1 __thread -> thread_local (#951)
It is sad that a prominent upstream monero contributor added `__thread`
to C++ code in 2017 when `thread_local` has been standardized since
C++11.

`__thread` isn't even supported by some compilers (like MSVC).
2019-12-05 08:12:03 +10: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
04f614705e Use pkg-config for unbound and miniupnpc
We unnecessarily vendor this much of the time because the existing
search code is primitive; use pkg-config instead which works much
better, and lets us properly depend on particular versions.

This lets us reenable the system miniupnpc for >=2.1, saving an
unnecessary compilation most of the time.  From the git history it
appears that it is built from source always unconditionally in a fit of
rage.
2019-12-03 00:51:18 -04:00
Jason Rhinelander
8090ee3481 Move randomness into new common/random.h
This adds a thread-local, pre-seeded rng at `tools::rng` (to avoid the
multiple places we are creating + seeding such an RNG currently).

This also moves the portable uniform value and generic shuffle code
there as well as neither function is specific to service nodes and this
seems a logical place for them.
2019-11-27 14:07:52 -04: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
4a88b48de5 one_shot_read_buffer to common & accept std::string
But only non-temporary std::string lvalues, *not* temporaries since they
completely defeat the point.

Also beefs up the class documentation.
2019-11-27 14:07:52 -04:00
Jason Rhinelander
34480c6f23 Merge branch 'pk25519-rpc-interfaces' into lokinet-integration 2019-11-26 21:47:07 -04:00
moneromooo-monero
3813a992e4
download: catch exceptions checking for size
Happens on at least one windows box
2019-11-26 18:42:00 +00:00
moneromooo-monero
f19c9f2307
util: allow newlines in string to be split 2019-11-25 13:17:18 +00:00
1point21gigabytes
40946bd92f explicitly specify UTC (#931) 2019-11-25 15:30:12 +11:00
selsta
7ac7d5d32f
updates: fix source code URL on _WIN32 2019-11-25 00:37:54 +01:00
moneromooo-monero
b9b5c473d1
threadpool: use std::move when taking an element off the queue
It has a std::function, which can have a capture context, and
the function runtime might be small
2019-11-15 13:24:34 +00:00
moneromooo-monero
9fe8a76c59
perf_timer: fix pause/resume macros dereferencing too much 2019-11-13 12:08:40 +00:00
moneromooo-monero
27522aaa12
core_tests: reset thread pool between tests
Avoids a DB error (leading to an assert) where a thread uses
a read txn previously created with an environment that was
since closed and reopened. While this usually works since
BlockchainLMDB renews txns if it detects the environment has
changed, this will not work if objects end up being allocated
at the same address as the previous instance, leading to stale
data usage.

Thanks hyc for the LMDB debugging.
2019-11-10 12:58:49 +00:00
Jason Rhinelander
5bde5a701d Remove base32z encoding
With the previous commit we no longer need this conversion (and lokinet
is perfectly happy just getting hex encoded values instead).
2019-11-08 03:03:36 -04:00
moneromooo-monero
2899379791
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.

This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo

This has some advantages:
 - incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
 - incentive to run your own node instead of using a third party's, thereby promoting decentralization
 - decentralized: payment is done between a client and server, with no third party needed
 - private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
 - no payment occurs on the blockchain, so there is no extra transactional load
 - one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
 - no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
 - Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
 - no large credit balance maintained on servers, so they have no incentive to exit scam
 - you can use any/many node(s), since there's little cost in switching servers
 - market based prices: competition between servers to lower costs
 - incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
 - increases network security
 - helps counteract mining pools' share of the network hash rate
 - zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner

And some disadvantages:
 - low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
 - payment is "random", so a server might go a long time without a block before getting one
 - a public node's overall expected payment may be small

Public nodes are expected to compete to find a suitable level for
cost of service.

The daemon can be set up this way to require payment for RPC services:

  monerod --rpc-payment-address 4xxxxxx \
    --rpc-payment-credits 250 --rpc-payment-difficulty 1000

These values are an example only.

The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.

The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).

There are three new settings in the wallet:

 - credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.

 - auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25

 - persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.

To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.

The wallet has a few new commands too:

 - start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
 - stop_mining_for_rpc: stop mining to acquire more credits
 - rpc_payments: display information about current credits with
the currently selected daemon

The node has an extra command:

 - rpc_payments: display information about clients and their
balances

The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2019-10-25 09:34:38 +00: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
Jason Rhinelander
0f06f89b05 Remove POD_CLASS macro and pointless pack pragmas
POD_CLASS is a retarded macro (it is always just `struct`).

The pack pragmas here do nothing because every type defined inside them
only has char array members which are already guaranteed by C++
alignment rules to have byte alignment.
2019-10-07 22:09:17 -03:00
Doyle
16ba84413b Report portential decomission and recommission for your node
When processing a quorum for a block, if you are not in the quorum to
validate other nodes, check if you're a node that is going to be tested.
If you are, check based on your current data if you're potentially
a candidate to be decommissioned/deregistered and if so report it to the
console log.

Note that this is only a heuristic and ultimately the decision lies on
what the the other Service Nodes perceive the current state of your node
is (i.e. if they're acting malicious then you will be deregistered
irrespectively).
2019-09-19 17:46:21 +10:00
moneromooo-monero
32f725d32f
Properly format multiline logs
As a side effect, colouring on Windows should now work
regardless of version
2019-09-16 16:58:01 +00:00
Doyle
add6051a8f
make get_checkpoints_range faster by using lmdb cursor as iterator (#819)
* make get_checkpoints_range faster by using lmdb cursor as iterator

* Update clamp to be more compliant with convention
2019-08-30 13:54:49 +10:00
moneromooo-monero
1a367d6a22
simplewallet: lock console on inactivity 2019-08-28 19:01:48 +00:00
luigi1111
564bb1da3a
Merge pull request #5525
0605406 daemon: sort alt chains by height (moneromooo-monero)
4228ee0  daemon: add optional arguments to alt_chain_info (moneromooo-monero)
880ebfd daemon: add more chain specific info in alt_chain_info (moneromooo-monero)
2019-08-14 15:31:52 -05:00
Doyle
8060f00428
Add progress meter to pop_blocks (#770) 2019-08-07 11:43:39 +10:00
Doyle
e6b5ef558a
Service node checkpointing deregistration (#672)
* Add deregistration of checkpoints by checking how many votes are missed

Move uptime proofs and add checkpoint counts in the service_node_list
because we typically prune uptime proofs by time, but it seems we want
to switch to a model where we persist proof data until the node expires
otherwise currently we would prune uptime entries and potentially our
checkpoint vote counts which would cause premature deregistration as the
expected vote counts start mismatching with the number of received
votes.

* Revise deregistration

* Fix test breakages

* uint16_t for port, remove debug false, min votes to 2 in integration mode

* Fix integration build
2019-06-27 17:05:44 +10:00
Doyle
212b859a66 Merge branch 'dev' into LokiMergeUpstream 2019-06-26 15:46:06 +10:00
Doyle
fdc340b0ee
Service node checkpointing: rebased on relaxed deregistration (#662)
* core: do not commit half constructed batch db txn

* Add defer macro

* Revert dumb extra copy/move change

* Fix pop_blocks not calling hooks, fix BaseTestDB missing prototypes

* Merge ServiceNodeCheckpointing5 branch, syncing and integration fixes

* Update tests to compile with relaxed-registration changes

* Get back to feature parity pre-relaxed registration changes

* Remove debug changes noticed in code review and some small bugs
2019-06-26 14:00:05 +10:00
Doyle
f761ed6345 Merge commit '51766d0' into LokiMergeUpstream 2019-06-26 12:43:21 +10:00
tobtoht
037f94c54e
Remove Xiala.net from the list of dns resolvers
It is down permanently. See: https://xiala.net/
"Ende November 2018 werden alle Dienste von xiala.net abgeschaltet."
2019-06-21 09:40:10 +00:00
moneromooo-monero
880ebfdeea
daemon: add more chain specific info in alt_chain_info 2019-06-01 15:43:52 +00:00
Lee Clagett
3544596f9f Add ssl_options support to monerod's rpc mode. 2019-05-22 00:09:11 -04:00
Doyle
e6c97579df Merge commit '5e80b3c' into LokiMergeUpstream 2019-05-17 04:14:11 +10:00
Doyle
18cb47cd7c Switch to modern bytes format and add missing override 2019-05-16 03:14:37 +10:00
moneromooo-monero
e1016bce14
password: do not use line input on windows
This keeps its builtin command editing away

Thanks iDunk for testing on Windows
2019-05-10 18:56:50 +00:00
Doyle
bd39bc0567 Merge commit '4754819' into LokiMergeUpstream 2019-05-02 13:53:11 +10:00
Doyle
5374632e2f Merge commit '1f809e7' into LokiMergeUpstream 2019-05-01 17:06:47 +10:00
Doyle
8f1e65522e Merge commit '98f4c8a' into LokiMergeUpstream 2019-05-01 17:04:00 +10:00
Doyle
455129c8ca Merge branch 'dev' into LokiMergeUpstream 2019-05-01 16:31:54 +10:00
Doyle
73e8ac0343
Service Node Checkpoint Storage (#579)
* Add functions for storing checkpoints to the DB

* Allocate the DB entry on the stack instead of heap

* Add virtual overrides for new checkpoint functions

* Clean up for pull request, simplify some logic

* Revise API to include height in checkpoint header

* Move log to top of function even if early exit

* Begin moving checkpoints to db

* Allow storing of checkpoints to DB

* Cleanup for code reviewer, fix unit tests

* Fix tests, fix casting issues

* Don't use DUPSORT, use height->checkpoint mapping in DB

* Remove if 0 disabling checkpoint vote, we already check HF12

* Fix unit test infinite loop

* Update db schemas to match blk_checkpoint_header

* Code review
2019-05-01 15:57:41 +10:00
iDunk5400
b414b69f5c
Windows: fix a build error in MSYS2 with boost 1.70.0 2019-04-18 17:00:13 +02:00
Riccardo Spagni
64a4aa4f60
Merge pull request #5408
c4f8a8a6 build fix: combinator.h stdexcept missing include (Dusan Klinec)
2019-04-15 09:21:00 +02:00
Riccardo Spagni
89b8ecfc7c
Merge pull request #5392
a2195b9b crypto: replace rand<T>()%N idiom with unbiased rand_idx(N) (stoffu)
2019-04-15 09:14:28 +02:00
Doyle
4778d862c9 Merge commit 'bd42903' into LokiMergeUpstream 2019-04-12 18:37:56 +10:00
Doyle
ba0cd9afcf Merge commit '7e5651c' into LokiMergeUpstream 2019-04-12 18:12:04 +10:00
Doyle
aded2cef69 Merge commit '1ed6441' into LokiMergeUpstream 2019-04-12 17:44:20 +10:00
Doyle
9f2e091280 Merge commit 'e4b049d' into LokiMergeUpstream 2019-04-12 16:45:24 +10:00
Doyle
8f292af653 Don't query moneropulse in DNS code 2019-04-12 15:37:23 +10:00
Doyle
2fe5ddb2ca Merge commit 'f2f725d8db3535055d1c7e102c0bba75b22a3409' into LokiMergeUpstream 2019-04-12 15:23:01 +10:00
Doyle
5162a30621 Merge commit 'c3de019f565674fd19b9d5cafba015d9ea7f69f7' into LokiMergeUpstream 2019-04-12 15:10:33 +10:00
Doyle
f9a6b06771 Merge commit '09b3b061bc4913b805a1207eb64f2bee6c1d0894' into LokiMergeUpstream 2019-04-12 14:53:01 +10:00
Doyle
78acf90805 Merge commit 'e063615a0ef026ae5b83f59b7916881229df0b6b' into LokiMergeUpstream 2019-04-12 14:38:43 +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
Doyle
cdd8243d48 Merge commit 'c83e80c2634f2c14fbd9fe4dbfb6a0abc2eb20ea' into LokiMergeUpstream 2019-04-10 15:36:02 +10:00
Doyle
a41bed8a32 Merge branch 'dev' into LokiMergeUpstream 2019-04-10 13:55:30 +10:00
Doyle
4926d73bb2 Merge commit 'a28237c9cacb074216b1ee1db40da32acde3acd0' into LokiMergeUpstream 2019-04-10 10:02:15 +10:00
Doyle
4f0a729533 Merge commit '4466f4504e8bc41d353a6becce0526df8272bc1d' into LokiMergeUpstream 2019-04-10 09:59:38 +10:00
Doyle
b1c92fd216 Add helper functions to facilitate more reliable integration tests 2019-04-09 15:47:23 +10:00