Commit graph

13631 commits

Author SHA1 Message Date
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 be332d3772
Avoid integer truncation in decoy selection
There is a (correct) warning in the calculation that divides by this
value that this code is doing integer division, but then storing in a
float.  This fixes the warning, and the intention.
2022-05-24 16:04:08 -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
Sean dce39ec8ee
Merge branch 'dev' into batching-rpc-endpoints 2022-05-24 11:29:49 +10:00
Sean Darcy 741affa403 Enforce a minimum time period before small contributors can unlock stake
This PR defines contributors to a service node as a small contributor if
they contribute <25% of the nodes locked contributions. If a contributor
is small then they are prevented from unlocking their stake for 30 days
after the node is registered. This was in response to operators getting
frustrated with small contributors immediately unlocking after a node
was registered.

If you imagine the following node contribution structure:

Operator: 25%
Contributor 1: 65%
Contributor 2: 10%
Total: 100%

Node is registered on day 0. On Day 1 both the operator and Contributor
1 will be able to unlock their stake and the node begins its 15 day
unlock period.

Contributor 2 however will be prevented from unlocking until day 30.
At this point they will be able to unlock and begin the nodes 15 day
unlock period.
2022-05-24 10:55:26 +10:00
Sean Darcy f45d0588ae Adds RPC endpoint for accrued batching balances
This allows a user to query the daemon and ask for the accrued balance
of oxen rewards that have been batched but not yet paid out.

The endpoint takes in an array of addresses (Strings) and returns an
array of atomic oxen amounts (integers) that reflect the current
database balances for those requested addresses.

For example an address has accrued 2x batch payments of 16.5 oxen but
has not yet been paid out will show 33000000000 being the atomic amount
in the database.
2022-05-23 08:47:18 +10: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
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 0d266a4e18
Merge pull request #1529 from oxen-io/readme-gutt-2022-04-14
remove old info from readme
2022-04-21 19:58:04 -03:00
Jason Rhinelander 81a1c1e50e
Merge pull request #1535 from jagerman/prepare-reg-dust
Fix prepare_registration dust
2022-04-21 19:57:20 -03:00
Jason Rhinelander 311587adf1
Merge pull request #1537 from jagerman/stake-info
Include SN status info info list_current_stakes()
2022-04-21 19:56:59 -03:00
Jason Rhinelander d9f19ca463
Include SN status info info list_current_stakes()
Adds unlock height, funded, and decommissioned info to returned stake
info.
2022-04-21 18:27:45 -03:00
Jason Rhinelander 711c7462c3
Fix prepare_registration dust
We could get a rounding error in the contributor spots that would make
the registration fail when passed to oxend.  This fixes it by restoring
the missing logic that was accidentally dropped in the
prepare_registration refactor.
2022-04-19 22:48:16 -03:00
Jason Rhinelander a91c491111
Merge pull request #1531 from jagerman/aux-pubkey-checks
Add ed25519_pubkey field to SS & lokinet pings
2022-04-18 21:18:01 -03:00
Jason Rhinelander 0fdaeff95d
Merge pull request #1532 from jagerman/checkpoint-vote-delay
Delay checkpoints by a block
2022-04-18 21:17:46 -03:00
Jason Rhinelander 9a6c4a93a0
Merge pull request #1530 from jagerman/prepare-reg-disp-fix
Prepare registration fixes and improvements
2022-04-18 21:17:07 -03:00
Jason Rhinelander 98de2910ec
Merge pull request #1533 from jagerman/w2api-is-stake
Add is-stake to wallet api
2022-04-18 19:06:45 -03:00
Jason Rhinelander 882ba4820a
Fix StakeUnlockResult non-virtual destructor
We destruct a subclass via base class instance pointer, which requires a
base class virtual destructor.
2022-04-18 15:06:38 -03:00
Jason Rhinelander a73002747a
Add is-stake to wallet api
Mobile wallet needs this to determine when a transaction is a stake
rather than a transfer, otherwise it shows all stakes as outgoing
transfers of 0.
2022-04-18 11:18:12 -03:00
Jason Rhinelander f46884c5f1
Delay checkpoints by a block
Testnet has shown that it is virtually impossible to route around a
checkpoint for a block that had to be rendered unacceptable because it
accepts the future checkpoint which then prevents an alternate block
from being generated at all.

This mitigates it in two ways:

- Don't accept new checkpoint votes before we receive the block
- Delay checkpoint voting & vote distribution by one block (e.g. nodes
  will vote on block 12345 only once 12346 is received).

The first allows a manual pop_blocks to remove checkpoints that won't
get re-added (e.g. if the checkpointed block has become unacceptable, as
occurs sometimes in testnet/devnet, but could theoretically occur on
mainnet if we have to do a block reversal).

The second minimizes the number of rejected votes that will occur since
nodes will almost always have the block now when the checkpoint arrives.
2022-04-17 12:59:36 -03:00
Jason Rhinelander 50a41e63de
Add ed25519_pubkey field to SS & lokinet pings
Allows lokinet & storage server to feed the ed25519 key back to oxend so
that oxend makes sure everyone is on the same key.
2022-04-17 11:16:45 -03:00
Jason Rhinelander d51c4466cf
Overhaul prepare_registration page
Reorders the way questions are asked to flow better.  Previously the way
questions was asked was sort of awkward.

The old order, for instance staking a partially open node:

- entire stake?
- fee?
- reserve more?
- how many more?
- operator address?
- operator stake size?
- contributor address?
- how much for contributor?
- more contributors, if any
- not filled okay?
- confirm everything?

where there are related values (e.g. operator addr & stake) intermingled
with around other things (e.g. fee & number of contributors).

With this commit the order is rewritten to:

- operator address?
- entire stake?
- operator stake size?
- fee?
- reserve more?
- how many more?
- contributor 1 addr
- contributor 1 amnt
- more contributors, if any
- not filled okay?
- confirm everything?

Additional changes:
- substantially DRY out the code.  There was a huge amount of repeated
  code in this section.

- highlight OXEN amounts in cyan.

- I rewrote much of the language to make it clearer and more grammatical

- reformatted the summary table to look a bit better

- the fee in the final summary is highlighted yellow.

- if there are multiple open spots this is now more clearly indicated in
  the output and the final summary screen.

Example:

```
$ oxend prepare_registration
2022-04-15 20:11:29.211	I Oxen 'Audacious Aurochs' (v9.2.0-0b38bd982-dev)
Current staking requirement: 15000 OXEN
Enter the OXEN address of the Service Node operator (C/Cancel):
LDoptfyQB3YHbS9cnt2wHdTTj2wtZGPuM48evCFwZpomVajQw4eJ6mDCpXeUNTxsqbTiYytnqEDQNin3XGwp3nReMooMaWG

Will the operator contribute the entire stake? (Y/Yes/N/No/B/Back/C/Cancel): n

The operator contribution must be between 3750 OXEN and 15000 OXEN to meet the staking requirements.

How much OXEN does the operator want to stake? (B/Back/C/Cancel): 5555

Enter operator fee as a percentage of earned rewards [0-100]% (B/Back/C/Cancel):  4.567

Do you want to reserve stakes for specific contributors? (Y/Yes/N/No/B/Back/C/Cancel): y

Number of additional contributors [1-3] (B/Back/C/Cancel): 2

Enter the OXEN address of contributor 1 (B/Back/C/Cancel):
L6JasonXTGW6juHrJgsXTxXH1Jh9u94H8NQ9m4rMwz5a9SZGr2e1cXw9MqnVH6Qx5bTgL5wf7qfvHeNPdwyC63AzMixU5ad

The next contribution must be between 3148.333333333 OXEN and 9445 OXEN to meet the staking requirements.

How much OXEN does contributor 1 want to stake? (B/Back/C/Cancel): 5555

Enter the OXEN address of contributor 2 (B/Back/C/Cancel):
L7jC35E9MnQZu2dS1n8wCqbvVBFpGHJt7iNHgAuEy5is57dzX2uQZDASv4KvwzruxXARxa4omafN6i19QBY7KAcSH1Xz7ZL

The next contribution must be between 1945 OXEN and 3890 OXEN to meet the staking requirements.

How much OXEN does contributor 2 want to stake? (B/Back/C/Cancel): 3000

Total reserved contributions: 14110 OXEN

The total reserved amount (14110 OXEN) is less than the required full stake (15000 OXEN).
The remaining stake (890 OXEN) will be open to contribution from 1 public contributor.
The Service Node will not activate until the full contribution has been filled.

Is this acceptable? (Y/Yes/N/No/B/Back/C/Cancel): y

Registration Summary:

Operator fee (as % of Service Node rewards): 4.567%

 Contributor       Address          Contribution  Contr. %
_____________   _____________  _________________  ________

   Operator     LDoptfyQB..WG     5555.000000000    37.03%
Contributor 1   L6JasonXT..ad     5555.000000000    37.03%
Contributor 2   L7jC35E9M..ZL     3000.000000000    20.00%
    (open)          (any)          890.000000000     5.93%

Is the staking information above correct? (Y/Yes/N/No/B/Back/C/Cancel):
```

For a open node with 3 open spots the summary table looks like this:

```
 Contributor       Address          Contribution  Contr. %
_____________   _____________  _________________  ________

   Operator     L6JasonXT..ad     6789.000000000    45.26%
    (open)          (any)       >=2737.000000000  >=18.25%
    (open)          (any)
    (open)          (any)
```
2022-04-15 17:54:04 -03:00
Jason Rhinelander 44da471153
Remove unused decimal point arg; add format_money()
- The decimal point argument isn't used anywhere.

- change `get_unit()` to return `OXEN` instead of `oxen`

- Add a "strip_zeros" option to print_money that lets you remove
  trailing insignificant 0's from the returned amount.

- Add format_money that does print_money (with 0s stripped by default) +
  get_unit().  E.g. it returns `"45.67 OXEN"`.
2022-04-15 17:54:03 -03:00
Jason Rhinelander 63ede5ec4d
Make cryptonote::parse_amount return an optional
Replace a gross non-const uint64_t& argument + bool return with an
std::optional<uint64_t> return value.
2022-04-15 17:54:03 -03:00
Jason Rhinelander d5551009f9
Fix cursor line overwriting in prepare_registration
When I issue a `prepare_registration` command the cursor gets positioned
at the beginning of the line instead of the end of the line, so typing
things in results in overwriting the text that I was asked.

E.g.:

```
Current staking requirement: 15000.000000000 oxen
yill the operator contribute the entire stake? (Y/Yes/N/No/C/Cancel):
`-- the y I typed replaced the "W"
```
or:
```
Enter the oxen address for the solo staker (B/Back/C/Cancel):
```
and because the cursor is positioned at the beginning, my address
overwrites the prompt as I type/paste it:
```
L6JasonXTGoxen address for the solo staker (B/Back/C/Cancel):
```

This is caused because we were suspending the readline buffer *after*
printing things out, and something (perhaps local config, or perhaps an
update to libreadline) repositions to cursor at column 0.

This commit suspends the readline handler *before* we print the message,
which makes it sane again:
```
Enter the oxen address for the solo staker (B/Back/C/Cancel): L6JasonXTG
```
2022-04-15 17:54:03 -03:00
Jason Rhinelander ef51e5dd63
Merge pull request #1527 from jagerman/dep-updates
Dependency updates & OpenSSL/unbound removal
2022-04-15 17:53:40 -03:00
Jason Rhinelander 0638aea2fb
Fix apple static libs check 2022-04-15 14:32:06 -03:00
Jason Rhinelander 1cf48a28c3
Silence false maybe-unused warning
This variable does always get set via the lvalue parameter in the call
below, but it's far enough away that gcc isn't sure of it.
2022-04-15 13:51:58 -03:00
Jason Rhinelander 5e578069d6
Remove redundant size checks
These were needed with oxenmq::is_hex a long time ago, but have been
redundant for quite a while.
2022-04-15 13:51:58 -03: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
Jason Rhinelander bf5162efdb
Remove now-unused ascii output magic 2022-04-15 13:51:57 -03:00
Jason Rhinelander b0cc711606
Replace stale seed node with new ones 2022-04-15 13:51:57 -03: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
majestrate 26b24fd787
Update README.md
gut old parts of readme.md for tor
2022-04-14 19:50:15 -04:00