Commit graph

13608 commits

Author SHA1 Message Date
Jason Rhinelander
d88d3d0de6
Remove assertion breaking wallet2 on a debug build
wallet2 expects to get back the UINT64_MAX value here for a
fully-reserved service node: if it does, it recognizes the node is full
and goes to look for reserved contribution spots.
2022-05-26 15:08:08 -03:00
Jason Rhinelander
c765081946
This is not C. 2022-05-26 15:08:08 -03:00
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
fd4ca4a57c
Ensure we don't produce a HF block with garbage from the db
Fix edge case where the block producer has garbage in the db: the code
that clears it happens when we *accept* the block, but we can end up
here before then, when we produce the block, so just return empty in
such a case.
2022-05-26 15:08:07 -03:00
Jason Rhinelander
4848cacec8
Fix is-service-node detection 2022-05-26 15:08:07 -03:00
Jason Rhinelander
c54cbb8394
Reset devnet 2022-05-26 15:08:07 -03:00
Jason Rhinelander
a8a3b3dbe6
DEVNET storage port fixes
On devnet we don't have a storage server, and so storage ports are left
uninitialized and effectively become random ports on the network.  This
initializes them to 0, and avoids comparing SS ports for devnet for the
duplicate ip/ports warning.
2022-05-26 15:08:07 -03:00
Jason Rhinelander
acf2942859
Fix bugs in thousandths calculations 2022-05-26 15:08:07 -03:00
Jason Rhinelander
589f66f5a4
Fix thousandths tx verification in service_node_list.cpp 2022-05-26 15:08:07 -03:00
Jason Rhinelander
a2eb8690ba
Reformatting 2022-05-26 15:08:07 -03:00
Jason Rhinelander
e7a6deaf6c
Do more calculations in thousanths
We were converting to thousanths too late; this does it earlier, to
reduce numerical imprecision during reward calculations.
2022-05-26 15:08:07 -03:00
Jason Rhinelander
9584a14b3a
Refactor/DRY reward calculation code
The reward calculation code when adding or subtracting is identical;
this dries it out into a single helper method.
2022-05-26 15:08:05 -03:00
Jason Rhinelander
bbdd91a3bb
const lvalue refs
Avoid copying vector arguments
2022-05-26 15:06:38 -03:00
Jason Rhinelander
ac26747529
Rename a_b_over_c to mul128_div64
Also uses it in various places that were writing out separate mul128 +
div128_64's.
2022-05-26 15:06:38 -03:00
Jason Rhinelander
d3684f6b44
Add iterable prepared_results<T...>
This gives back an iterator that lets you step through results as
tuples without having to executeStep() + get<...> yourself.
2022-05-26 15:06:12 -03:00
Jason Rhinelander
02d8e0aefc
Improve prepared interface; fix test suite bug
Add a `prepared_bind` that lets you get a prepared statement and bind
parameters to it in one shot.

Add comments to the prepared_* methods.

Fix test suite bug in sqlite testing wrapper added in the earlier
prepared statement commit: it was selecting values from the current
(new, empty) database rather than the passed-in one.
2022-05-26 13:57:01 -03:00
Jason Rhinelander
e7c19d29a8
Move test subclass into tests/ 2022-05-25 20:57:31 -03:00
Jason Rhinelander
9a395be641
Make sure we error if given a non-existant payment address 2022-05-24 18:54:52 -03:00
Jason Rhinelander
7b331131d9
Remove debugging 2022-05-24 18:54:52 -03:00
Jason Rhinelander
bf1915bd46
SQLite: use prepared statements
Using SQLite::Statement directly requires sqlite to re-prepare the
statement every time it is executed; going via our `prepared_st` wrapper
caches (per thread) and reuses previously prepared statements for better
performance.

(It also, in some cases, simplifies the code a bit).
2022-05-24 18:54:52 -03:00
Jason Rhinelander
d59ccbf82c
Bump version 2022-05-24 18:54:32 -03:00
Jason Rhinelander
1fa71bcc2c
Rename hf19 -> hf19_reward_batching 2022-05-24 18:54:32 -03:00
Jason Rhinelander
2b94af71a9
Add static_assert for hf numeric values 2022-05-24 17:36:24 -03:00
Jason Rhinelander
6011a9b4e7
Remove debugging 2022-05-24 17:36:24 -03:00
Jason Rhinelander
bac9c05162
Fix debug compilation 2022-05-24 17:36:24 -03:00
Jason Rhinelander
34ef746c95
prepare_registration fixes for multi contributors
Adds two slightly different versions of prepare_registration: one that
works with the existing 4-person registrations (used up to the hard
fork), and one that produces HF19 amount-based registrations.

This also overhauls the questions to be a bit nicer to input;
specifically:

- allow "max" and "min" as stake amount options, and make "max" the
  default.
- eliminate the "do you want to contribute the whole stake?" question
  entirely.  We instantly figure that out if you choose "max" (or enter
  the 15000 manually).
- eliminate the "how many contributors?" question.  Instead we just keep
  taking additional contributors until you stop entering them.
- move the fee to later, after you've provided contributor info (if not
  a full stake).

There is, unfortunately, a *huge* amount of duplication here: I copy and
pasted the entire HF18 registration code and just eliminated the
portions parts of it.  This is temporary: as soon as we are into HF19 we
can eliminate the HF18 version entirely.
2022-05-24 17:36:24 -03:00
Jason Rhinelander
377cfecb09
Atomic staking amounts
This adds a new tx registration interpretation for HF19+ by repurposing
the fields of the registration:

- `expiration` becomes `hf_or_expiration`; for "new" registrations it
  contains the hardfork number (e.g. 19 for HF19), but the data layout
  on chain doesn't change: essentially we determine whether it's a new
  registration based on whether the field is <= 255 (interpret as HF) or
  not (interpret as expiration).

Changes in "new" registrations:
- stake amounts are atomic OXEN rather than portions.  This lets us skip
  a whole bunch of fiddling around with amounts that was necessary to
  deal with integer truncation when converting between amounts and
  portions.

- the fee in the registration data is now a value out of 10000 instead
  of a portion (i.e. value out of 2^64-4).  This limits fee precision to
  a percentage with two decimal places instead of ~17 decimal places.
  Internally we still convert this to a portion when processing the
  registration for service_node_states, but this makes the registration
  itself much simpler and easier to work with (as a human).

- HF19+ registrations no longer have an expiry timestamp (though they do
  depend on the hardfork, so they "expire" whenever the next hard fork).
  The expiry timestamp was really only there to avoid a registration
  amount decreasing too much from the dropping staking requirement.

- Both types are registration are still permitted for HF19, but because
  registrations with more than 4 contributors expose bugs in the portion
  transfer code (that results in registrations become invalid),
  old-style registrations are still limited to 4 contributors.

- HF19 will allow both old and new registrations, so that registrations
  generated before the HF will still work, and so that we don't break
  testnet which has various "old" registrations on it.
2022-05-24 17:36:24 -03:00
Jason Rhinelander
5b25671c4f
Split up sqlitedb into a compiled unit
Lessens the compilation load of various things that include the header,
and lets us avoid having to include all of fmt when we include it.
2022-05-24 17:36:24 -03:00
Jason Rhinelander
636ee3f622
Replace boost::endian conversion with oxenc 1.0.3
1.0.3 got some endian fixes that lets us avoid boost::endian everywhere.
2022-05-24 17:35:59 -03:00
Jason Rhinelander
6f6505278c
Merge pull request #1548 from jagerman/skipping-cn-variant2-sqrt
Speed up test_variant2_int_sqrt tests by skipping most values
2022-05-24 17:33:29 -03:00
Jason Rhinelander
6bb83316dd
Merge pull request #1546 from jagerman/remove-major-ge-minor
Remove minor >= major block requirement for HF19+
2022-05-24 16:04:48 -03:00
Jason Rhinelander
1e41a55542
Merge pull request #1547 from jagerman/remove-ftime
Remove use of deprecated ftime
2022-05-24 16:04:36 -03:00
Jason Rhinelander
0b722fbd8a
Skip most stupidly test_variant2_int_sqrt values
This test uses 3.5 billion iterations, and takes multiple minutes --
effectively just as long as all other test suite tests combined.

This is dumb.

Reduce the "optimized" version to increment by 83 instead of 1, the same
as the "reference" version, but add a V2_INT_SQRT_FULL_TEST=1
environment variable you can set if you really want to test your CPU
cooler.
2022-05-24 15:56:37 -03:00
Jason Rhinelander
1bfa4e64d4
Remove use of deprecated ftime 2022-05-24 11:14:35 -03:00
Jason Rhinelander
c3759c67de
Remove minor >= major block requirement for HF19+
Monero perverted the minor version many forks ago; this returns it to
being a minor version, making the blocks reflect our actual minor
version.
2022-05-24 11:07:06 -03:00
Jason Rhinelander
c7deef4ac3
Merge pull request #1545 from jagerman/deblobdata
Remove stupid typedef
2022-05-21 10:36:05 -03:00
Jason Rhinelander
26869869aa
Remove stupid typedef 2022-05-20 18:30:55 -03:00
majestrate
1dccbcd8c9
Merge pull request #1541 from jagerman/remove-config-macros
Remove cryptonote_config.h macros
2022-05-20 16:43:27 -04: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
Jason Rhinelander
c8d5dfa597
Remove unused macros 2022-05-16 15:16:26 -03:00
Jason Rhinelander
8014cf6a6c
Undo 19.1 version for Session testing 2022-05-13 01:25:11 -03:00
Jason Rhinelander
dd814da1ad
Reword registration command to include the operator wallet 2022-05-12 15:32:45 -03:00
Jason Rhinelander
4dad19fb7d
Add pubkey to prepare_registration summary 2022-05-12 15:20:58 -03:00
Jason Rhinelander
fd020fcd83
Fix min operator amount, rejigger math
A fixed 3750 amount won't work on testnet (and also was set to 3750
atomic units instead of 3750 coins).

This refactor the math a bit so that the amount falls out of the portion
constant when making a registration.
2022-05-12 13:47:49 -03:00
Sean Darcy
f652aa09bc review notes 2022-05-12 10:32:57 +10:00
Sean
73e0a9eb61
Update src/cryptonote_core/service_node_list.cpp
Co-authored-by: Jason Rhinelander <jason@imaginary.ca>
2022-05-12 09:29:08 +10:00
Sean Darcy
9edc2bb52d
Increase max number of contributors to 10
This requires the operator to still contribute 25% of the service node
but another 9 nodes will be allowed to stake to the node makeing 10
contributors total rather than our previous 4.
2022-05-10 18:48:20 -03:00
Jason Rhinelander
3ac7e55056
Merge pull request #1450 from darcys22/batch-sn-payments
Batch sn payments
2022-05-10 18:42:41 -03:00
Sean Darcy
f82be89478 hardfork 19.1 2022-05-10 13:52:19 +10:00
Sean Darcy
8bafaea9a1 bump iOS deployment target to iOS 13 2022-05-02 08:51:34 +10:00