Commit graph

13631 commits

Author SHA1 Message Date
Sean Darcy a1814661d5 enforce atomic registrations in HF19 2022-05-27 16:17:58 +10:00
Sean 307e7b933a
Merge pull request #1555 from darcys22/test-portions-to-amounts
change from portions to atomic amounts
2022-05-27 15:34:49 +10:00
Sean Darcy 56504d35de change from portions to atomic amounts 2022-05-27 15:07:28 +10:00
Sean d2db69a675
Merge pull request #1553 from darcys22/conflicts-from-merge
change in name between branchs
2022-05-27 11:43:26 +10:00
Sean Darcy 64d9dcae67 change in name between branchs 2022-05-27 11:42:48 +10:00
Sean 7161f42c64
Merge pull request #1472 from jagerman/avoid-integer-truncation
Avoid integer truncation in decoy selection
2022-05-27 11:16:54 +10:00
Sean c5fbf96b7d
Merge pull request #1539 from darcys22/prevent-unlocks-small-holdings
Prevent unlocks small holdings
2022-05-27 11:15:29 +10:00
Sean e9a69b6a78
Merge pull request #1550 from jagerman/batch1000
Batching thousanths
2022-05-27 11:15:09 +10:00
Sean d77d791d7d
Merge branch 'dev' into batch1000 2022-05-27 11:14:55 +10:00
Sean a65c0c1dbc
Merge pull request #1544 from darcys22/batching-rpc-endpoints
Adds RPC endpoint for accrued batching balances
2022-05-27 11:10:07 +10:00
Sean 5175503098
Merge pull request #1552 from darcys22/coinbase-payouts
Rename miner_reward to coinbase_payouts and fix minor bug
2022-05-27 11:09:20 +10:00
Sean Darcy a218b81bc0 segfault in block_weight due to nullptr sqlite_db 2022-05-27 10:45:15 +10:00
Sean Darcy 5387ca2cf4
test cases for batching 2022-05-26 15:08:32 -03:00
Jason Rhinelander b9f3877ab3
Add hard_fork to get_info rpc request
It's simple to add and saves a call to HARD_FORK_INFO when all you care
about is the hf number (and not the other hard fork details).
2022-05-26 15:08:08 -03:00
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 7d392dad01
Merge pull request #1540 from darcys22/decom-grace-period
Decom grace period
2022-05-26 11:37:19 -03:00
Jason Rhinelander b6e859a104
Merge pull request #1551 from jagerman/add-hf-to-get_info
Add hard_fork to get_info rpc request
2022-05-26 11:30:46 -03:00
Sean Darcy 47a9802f83 Rename miner_reward to coinbase_payouts and fix minor bug
After the batching HF we now have a "reward" field in the block header
which is confusingly different to "miner_reward". This renames
miner_reward to coinbase_payouts to clarify that this amount is the
amount actually paid out in the coinbase vs the reward accumulated into
the batching DB.

Also fixes a minor bug where the reward would only show the reward of
the first vout instead of summing all the vouts.
2022-05-26 13:09:04 +10:00
Jason Rhinelander b6fdd9d90f
Add hard_fork to get_info rpc request
It's simple to add and saves a call to HARD_FORK_INFO when all you care
about is the hf number (and not the other hard fork details).
2022-05-25 23:30:28 -03:00
Jason Rhinelander e7c19d29a8
Move test subclass into tests/ 2022-05-25 20:57:31 -03:00
Sean Darcy 76a585eb41 Add a grace period to deregistrations after a hardfork
It is not uncommon to have nodes get decommissioned after a hardfork,
either due to lack of updating or issues with the release. This
implements a 7 day grace period where nodes that do get decommissioned
will not progress into a deregistration (and being hit with the 30 day
funds locked penalty).
2022-05-25 14:07:55 +10: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