Commit graph

164 commits

Author SHA1 Message Date
Jason Rhinelander 902d7afe55
Use an empty vector instead of optional<vector>
We don't do anything differently for a nullopt versus an empty vector,
so just return an empty vector for both not-at-the-hf and no-payments
cases.

(This also fixes a segfault and/or chainsync bug in the previous commit
because the optional is dereferenced without checking when on hf19).
2022-05-26 15:08:08 -03:00
Jason Rhinelander dfe566480b
Remove cryptonote_config macros
- Replace all cryptonote_config macros with constexpr variables.  Some
  become integer types, some become chrono types.
  - generally this involved removing a "CRYPTONOTE_" prefix since the
    values are now in the `cryptonote` namespace
  - some constants are grouped into sub-namespaces (e.g.
    cryptonote::p2p)
  - deprecated constants (i.e. for old HFs) are in the `cryptonote::old`
    namespace.
  - all the magic hash key domain separating strings are now in
    cryptonote::hashkey::WHATEVER.
- Move some economy-related constants to oxen_economy.h instead
- Replaced the BLOCKS_EXPECTED_IN_DAYS constexpr functions with more
  straightforward `BLOCKS_PER_DAY` value (i.e.  old
  `BLOCKS_EXPECTED_IN_DAYS(10)` is now `BLOCKS_PER_DAY * 10`.
- Replaced `network_version` unscoped enum with a scoped enum
  `cryptonote::hf`, replacing all the raw uint8_t values where it was
  currently accepted with the new `hf` type.
- Made `network_type` a scoped enum so that it now has to be qualified
  (network_type::TESTNET) and can't be arbitrarily/unintentionally
  converted to/from an int.
- HARDFORK_WHATEVER macros have become cryptonote::feature::WHATEVER
  constexpr hf values.
- Add `revision` to rpc hard_fork_info response
- Don't build trezor code at all (previously we were pointlessly
  building an empty dummy lib).
2022-05-16 20:37:07 -03:00
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 4fa12395ef
More epee purging
Remove misc_language.h: Half of it is unused, half of it is crap doesn't
need to be used, and the two useful things (median calculator and a
scope exit caller) were poorly written.

Rewrote median from scratch and moved it out of epee.

Simplified the scope exit handler and moved it to its own small header
in epee.
2022-04-15 13:51:57 -03:00
Sean Darcy 87811fe2ea compiles 2021-01-04 13:09:59 +11:00
Jason Rhinelander 33242dff47 Replace keypair::generate with a keypair constructor taking a hwdev
This makes it a bit nicer, and allows in-place construction rather than
needing to construct-and-copy.
2020-12-08 22:31:54 -04:00
Jason Rhinelander 74db1800ef Annotate and split up ring signature code
We use generate_ring_signature and check_ring_signature somewhat
inappropriately to sign and check a signature of a single key image.
While it works for that, the full ring signature algorithm adds quite a
bit of complexity that we don't need (and simply doesn't run) for the
key image proof included in stake transactions and exported key images
from the wallet.

This splits it up, makes the key image interface considerably simpler,
and adds annotation comments through it (and also adds comments into the
"main" signature code).

This is a necessary step to getting stake transactions and key image
exports working with Ledger, without implementing the full ring
signature (because that is quite involved, and not needed for most of
these cases).

Also remove unused gen/check_ring_signatures interfaces: The raw pointer
code is never called, except through the vector version and one place in
the test suite, so just remove it and make the vector version the main
implementation.
2020-12-03 13:43:07 -04:00
Jason Rhinelander 165d753e87 Remove Borromean generation
Like MLSAG, this code is no longer used (or usable) since HF16.
2020-11-30 00:47:12 -04:00
Jason Rhinelander 67f4e990d2 Remove MLSAG generation
The blockchain only accepts CLSAG txes now, so no need to keep the MLSAG
generation code around.  (MLSAG verification stays, of course).
2020-11-30 00:47:12 -04:00
Jason Rhinelander e8a340e9be Make RingCT and RangeProof types type-safe enum classes 2020-11-30 00:47:12 -04:00
Jason Rhinelander b627b3b4bb Move epee includes under "epee/..."
This ends epee's include pollution.
2020-10-24 12:46:27 -03:00
Jason Rhinelander 78833f9d69 Remove deprecated epee code 2020-10-24 12:46:26 -03:00
Jason Rhinelander 1379825f9f Move test suite timings code out of main src 2020-10-24 12:46:26 -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 caf5e59984 Merge branch 'pulse' into dev 2020-09-18 17:40:25 -03:00
Sarang Noether a23539c984 Added balance check to MLSAG/CLSAG performance tests 2020-09-16 20:43:12 -03:00
Sarang Noether 05900f14d8 Updated MLSAG and CLSAG tests for consistency 2020-09-16 20:43:12 -03:00
Sarang Noether 78401c1606 CLSAG verification performance test 2020-09-16 20:43:12 -03:00
Sarang Noether d14d5544a0 CLSAG optimizations 2020-09-16 20:43:12 -03:00
moneromooo-monero e4b2c3089b Integrate CLSAGs into loki
They are allowed from v16, and MLSAGs are rejected from v16 + 10 blocks.
2020-09-16 20:43:12 -03:00
Sarang Noether c9cd4e7a81 CLSAG signatures 2020-09-16 20:41:39 -03:00
Doyle 9312bedba1 Pulse: Undo merging of payout entries
Merging payout entries can be done when batching is implemented instead
of drilling down too deep in implementation too early before the other
parts of Pulse are fleshed out.
2020-08-18 11:59:53 +10:00
Doyle 8938003027 Pulse: Setup miner_tx to handle pulse/miner block producers 2020-08-18 11:59:53 +10:00
Jason Rhinelander 264477071c Avoid expression-always-false compiler warning
For some obnoxious reason this code passes a bunch of what should be
constructor arguments as template arguments, which makes them compile
time constants and thus induces an impossible condition here.  Guard it
behind an `if constexpr` to silence the warning.
2020-08-17 02:47:46 -03:00
Jason Rhinelander 2be43025c7 Post-merge: std::chrono updates
Replaces reintroduced boost::chronos and posix_times with std::chrono.

Also rewrote the time printing parts of the performance_tests code to do
it better use std::chrono types instead of uint64_ts.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 718a9496fb Replace boost chrono & posix_time with stl chrono 2020-07-02 12:52:13 -03:00
Jason Rhinelander 37a341ff6b Remove boost regex dependencies
All boost::regex use is now replaced with std::regex.
2020-07-02 12:52:13 -03:00
Jason Rhinelander e7d056edf1 boost::variant -> std::variant
A huge amount of this is repetitive:

- `boost::get<T>(variant)` becomes `std::get<T>(variant)`
- `boost::get<T>(variant_ptr)` becomes `std::get_if<T>(variant_ptr)`
- `variant.type() == typeid(T)` becomes `std::holds_alternative<T>(variant)`

There are also some simplifications to visitors using simpler stl
visitors, or (simpler still) generic lambdas as visitors.

Also adds boost serialization serializers for std::variant and
std::optional.
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 9c5c1dac50 Replace boost::regex with std::regex 2020-07-02 12:52:12 -03:00
Doyle 00637b2712 Merge commit '4ed60b6' into MergeUpstream3 2020-05-29 13:48:05 +10:00
Doyle f2ebd811d0 Merge commit 'c6430f9' into MergeUpstream3 2020-05-22 12:04:20 +10:00
Doyle 315b6ac869 Merge commit '8501481' into MergeUpstream3 2020-05-18 16:21:45 +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
Sarang Noether 4ed60b626a Bulletproofs: verification speedup 2020-04-14 20:31:30 -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
Doyle 1eb45e523e Build/core test fixes, incoporate staking changes from LNS
- Fix assert to use version_t::_count in service_node_list.cpp
- Incoporate staking changes from LNS which revamp construct tx to
  derive more of the parameters from hf_version and type. This removes
  extraneous parameters that can be derived elsewhere.

  Also delegate setting loki_construct_tx_params into wallet2 atleast,
  so that callers into the wallet logic, like rpc server, simplewallet
  don't need bend backwards to get the HF version whereas the wallet has
  dedicated functions for determining the HF.
2019-12-04 15:17:55 +11:00
Jason Rhinelander d43398efed Fix wallet_rpc and tests for new loki_construct_tx_params usage 2019-11-27 20:51:07 -04:00
luigi1111 c6430f9dd0
Merge pull request #5893
Coverity fixes [3a81639, 1bd962d, 2825f07, d099658, d46f701, cd57a10] (anonimal)
2019-09-30 18:43:48 -05:00
anonimal d46f701515
tests: rct_mlsag: resolve CID 203914 (UNINIT_CTOR) 2019-09-07 00:38:49 +00:00
moneromooo-monero d046ca1db0
difficulty: fix check_hash on big endian 2019-09-04 14:53:53 +00:00
Sarang Noether 3a0451a8be MLSAG speedup and additional checks 2019-08-27 16:22:44 -04:00
moneromooo-monero e980938210
fix wide difficulty conversion with some versions of boost 2019-05-01 19:58:09 +00:00
Doyle 5162a30621 Merge commit 'c3de019f565674fd19b9d5cafba015d9ea7f69f7' into LokiMergeUpstream 2019-04-12 15:10:33 +10:00
Doyle 4926d73bb2 Merge commit 'a28237c9cacb074216b1ee1db40da32acde3acd0' into LokiMergeUpstream 2019-04-10 10:02:15 +10:00
moneromooo-monero 91f4c7f45f
Make difficulty 128 bit instead of 64 bit
Based on Boolberry work by:
  jahrsg <jahr@jahr.me>
  cr.zoidberg <crypto.zoidberg@gmail.com>
2019-03-24 21:03:19 +00:00
Riccardo Spagni c3de019f56
Merge pull request #5192
d0e07b3d performance_tests: fix NetBSD build (moneromooo-monero)
7d88d8f2 discontinue use of alloca (moneromooo-monero)
2019-03-17 17:56:52 +02:00
Doyle dc06a79b7a
Change PoW to CN Turtle Lite V2 on Hardfork 11 (#459)
* Improve parameterising of selectable hashing algorithm

* Add CN turtle light variant 2

* Incorporate cn turtle lite v2 test into loki

* Rename to cn_turtle

* Rename instances of cn_slow_hash including arm targets
2019-03-06 00:16:59 +00:00
binaryFate 1f2930ce0b Update 2019 copyright 2019-03-05 22:05:34 +01:00
Riccardo Spagni a28237c9ca
Merge pull request #5102
1eef0565 performance_tests: better stats, and keep track of timing history (moneromooo-monero)
2019-03-04 21:22:51 +02:00