Commit Graph

9638 Commits

Author SHA1 Message Date
Jason Rhinelander b309bf8bb6
Merge pull request #1627 from jagerman/hf19-3-stable
Hard spoon 19.3 (stable edition)
2023-01-25 11:34:03 -04:00
Jason Rhinelander c2cfe12fbf
Schedule 19.3 hard spoon
- Scheduled for Feb 9th, 0:00 UTC.
- Bump required lokinet version to latest stable
- Bump SS version to 2.5.0
2023-01-24 11:43:43 -04:00
Jason Rhinelander 876d3dd0c7
Fix HF19.2 timestamp
The timestamp in the file didn't match the comment or the block height
(this doesn't break anything; the timestamp is only used for future
block arrival estimates).
2023-01-24 11:43:04 -04:00
Jason Rhinelander 3ba73ebf18
Fix pubkey parameter name in ping endpoints
Lokinet and SS are actually sending `pubkey_ed25519` for the parameter,
but oxen-core is expecting `ed25519_pubkey`.  Fixes oxen-core to match
what lokinet/ss are actually sending.
2023-01-11 15:02:40 -04:00
Jason Rhinelander ca3fe62367
Bump version, required (local) lokinet version 2022-10-24 21:38:32 -03:00
Jason Rhinelander 77cfa7c340
Merge pull request #1611 from darcys22/archive-batching-stable
Archiving batching
2022-10-24 20:04:31 -03:00
Sean Darcy d6b2333891 Creates archiving for reward batching
This adds a new table to the batching schema to copy the accrued
balances every so often. This means that we can jump back to a
previous point without popping blocks.

The archiving is triggered in sql every 100 blocks and added to the
archive table, then pruned from the archive table at a later time to
ensure the size is kept small. Rebuilding 100 blocks is pretty
reasonable and should be less than 10s.

For longer distance pop_blocks and blockchain detached every 10k blocks
is kept in the archiving table. This takes longer to rebuild but is
better than rebuilding from scratch.

The blockchain detached function is also added to our regular blockchain
detached hooks so that it gets called every time the blockchain
detaches. Which appears to have caused some issues previously when some
of the modules would detach but batching would be stuck in an advanced
state.
2022-10-18 08:12:00 +11:00
Jason Rhinelander 3072aba3e6
Merge pull request #1605 from jagerman/aux-ping-errors
Allow lokinet/ss to send an error ping
2022-10-17 13:38:53 -03:00
Jason Rhinelander 9b812505fa
Merge pull request #1599 from darcys22/exception-throw
change naked throws to throw exceptions
2022-10-17 13:37:20 -03:00
Sean Darcy 4a99dfc36d change naked throws to throw exceptions 2022-10-17 07:25:44 +11:00
Jason Rhinelander b90e2f0e00 Allow lokinet/ss to send an error ping
This lets lokinet or SS signal to oxend that something is known to be
wrong, and so oxend should not send a proof so that, hopefully, the
problem gets noticed and fixed.
2022-10-14 20:38:57 -03:00
Jason Rhinelander c074c21eba Put current info for ourself in service node list
Currently we're putting the last-uptime-received data in the service
node list info, even when we have more updated info that hasn't yet been
accepted by the network.

This causes problems for lokinet, in particular, because it ignores any
SNs in the list without ed25519 pubkeys, including itself, which can
result in lokinet thinking it is deregistered for a while after the SN
becomes registered.

This updates `get_service_nodes` to always include current info (rather
than latest proof info) for itself when querying a service node.
2022-10-14 14:03:20 -03:00
Jason Rhinelander d4d4692a23 Update variant header from oxenmq to oxenc
The latest oxenmq dropped the long-deprecated compat header.
2022-10-13 13:37:23 -03:00
Jason Rhinelander f1ee71a1d4
Merge pull request #1591 from darcys22/atomic-sn-reg-cmd
Atomic values for the get_service_node_registration_cmd endpoint
2022-08-30 23:25:32 -03:00
Sean Darcy 872210608b use new basis points function in rpc_command_executor 2022-08-31 10:02:46 +10:00
Jason Rhinelander 3662cb21fb Remove pre-HF19 registration commands from oxend 2022-08-31 10:01:21 +10:00
Sean Darcy a9c83bd0b2 Atomic values for the get_service_node_registration_cmd endpoint 2022-08-31 09:58:15 +10:00
Jason Rhinelander c3a00f57a2
Oxen 10.2 version bumps & mandatory upgrade date
- 10.2.0 oxend version
- keep lokinet at 0.9.9
- require storage server 2.4.0
- schedule 10.2.0 mandatory date as 14 September 00:00 UTC (10am in
  Australia Eastern Time; 8pm (on the 13th) in US Eastern time.
2022-08-30 19:06:58 -03:00
Jason Rhinelander 2f1e2557ff
Fix pulse not avoiding small contributor unlocks 2022-08-25 11:24:26 -03:00
Jason Rhinelander d955607306
Merge pull request #1588 from darcys22/create-hwdev-file-by-default-for-hw-devices
Create HWDEV file by default for hardware wallets
2022-08-22 17:27:11 -03:00
Jason Rhinelander 5f338c2492
Merge pull request #1585 from jagerman/fix-block-notify-race
Fix block notify race condition, and drain some of the swamp
2022-08-22 17:25:21 -03:00
Jason Rhinelander e730b2fcbb
Merge pull request #1583 from darcys22/small-contributor-atomic-amount-fix
fix for small contributor
2022-08-22 17:24:04 -03:00
Sean Darcy 9ae474eb76 Create HWDEV file by default for hardware wallets
This modifies the current behaviour from only creating the hwdev.txt
file, when a new wallet is created if content is specified as an
argument to always creating the file. This file is used by the GUI
wallet to detect if the device is a hardware device and the CLI wallet
behaviour is kept the same to keep behavious consistent between CLI and
RPC wallets.
2022-08-19 15:28:17 +10:00
Sean Darcy d6b8b2d036 fix for small contributor unlocks
The checking if the service node contributers are small miscalculated
atomic oxen. This brings in the correct figure for HF20 and in the
interim brings measures into the wallet and blink to prevent small
contributors from being to unlock in HF19.
2022-08-11 15:09:04 +10:00
Jason Rhinelander 0bc3c2f880
Rewrite trash tools::Notify
This was nasty.

Remove --block-rate-notify entirely; it's nearly useless on Oxen.

block and reorg notify remain, but now use a post-block hook rather than
shoving toxic Notify crap into cryptonote_core headers.
2022-07-27 17:25:48 -03:00
Jason Rhinelander edbce1bf8c
Add and use post-block-added hooks; fix block notify race
Add hooks that are called *after* a block is successfully added to the
blockchain.

This also fixes a race condition with OMQ notify.block subscriptions:
because the notification was firing during (instead of after) block
addition, the lokinet/storage server receiving the notify would race to
fetch the block info, but that request could happen *before* the block
addition is finished, ending up with lokinet/SS sometimes getting a
stale block.
2022-07-27 17:25:12 -03:00
Jason Rhinelander 59f90dcf75
Rename block_added hook to block_add
This hook *isn't* called after a block is added, but rather it is part
of the block addition process and can abort the whole thing by raising
an exception (or returning false, prior to this PR).

This is unintuitive and causes bugs if using it as a "block has been
added" hook.
2022-07-27 15:20:35 -03:00
Jason Rhinelander 9c9552380d
Make hooks use exceptions on error rather than bool returns
bool returns suck in general, but in most cases here they are also a
pain in the ass because *each* place that returns false is also issuing
a log statement.  If only there were a way to return error information
to the common caller to have the common caller handle it... oh wait,
there is!
2022-07-27 15:10:52 -03:00
Jason Rhinelander f382c1971e
Replace hook virtual calls with std::function
- Instead of inheriting from a pure virtual base class, we know just use
  lambdas for hook callbacks.
- The signature of hooks also changes to take an info struct rather than
  a list of parameters, so that you don't have to change everything to
  ignore unwanted parameters if someone adds something to a hook.
2022-07-27 14:20:29 -03:00
Jason Rhinelander 76908d9d5d
Add missing header
This was previously being included via oaes_lib.h.
2022-07-22 14:18:24 -03:00
Jason Rhinelander d28c24a176
Rename oaes_lib to oaes_lib_expand
Since all it is now is just the key expansion from oaes_lib
2022-07-21 21:16:17 -03:00
Jason Rhinelander b450affb1a
Slim down oaes_lib
The only thing we use from it is the aes key expansion, so just delete
everything else and change the interface to just do key expansion.
2022-07-21 21:11:44 -03:00
Jason Rhinelander 3015683511
Avoid failure if the trigger doesn't exist
I'm not entirely sure how this happens, but I came across a node that
was failing here because the trigger didn't exist -- possibly from a
partial upgrade?

In any case, the `IF EXISTS` makes it more lenient.
2022-07-19 22:47:57 -03:00
Jason Rhinelander f87dfd0d51
Overhaul print_locked_stakes output
The CLI wallets `print_locked_stakes` was buggy, overly verbose, and
missing pertinent information.  This overhauls it.

Details are below; the quick differences:
- show the staking requirement
- make key image output optional with a +key_images flag on the command
- fix various bugs such as just showing the first contribution as the
  "total" contribution
- add the wallet address of extra contributions, rather than just the
  key image with no other info.
- put your own contributions first, and mark them as such
- show totals of other contributors
- sort service nodes to put unlocking nodes first; among unlocking and
  non-unlocking nodes we sort by hex pubkey string.
- sort locked dereg outputs by unlock height
- considerable reformatting of how things are displayed

---

Output now looks like this:

First we have 1-2 lines of general info:

    Service Node: abcdef123456...
    Unlock Height: 1234567         (omitted if not unlocking)

If there are other contributors then we print a total line such as:

    Total Contributions: 15000 OXEN of 15000 OXEN required

For our own contribution, when we have a single contribution, we use one of:

    Your Contribution: 5000 OXEN (Key image: abcdef123...)
    Your Contribution: 5000 OXEN of 15000 OXEN required (Key image: abcdef123...)

(the second one applies if we are the only contributor so far).

If we made multiple contributions then:

    Your Contributions: 5000 OXEN in 2 contributions:
    Your Contributions: 5000 OXEN of 15000 OXEN required in 2 contributions:

(the second one if we are the only contributor so far).

This is followed by the individual contributions:

        ‣ 4000.5 OXEN (Key image: abcdef123...)
        ‣ 999.5 OXEN (Key image: 789cba456...)

If there are other contributors then we also print:

    Other contributions: 10000 OXEN from 2 contributors:
        • 1234.565 OXEN (T6U7YGUcPJffbaF5p8NLC3VidwJyHSdMaGmSxTBV645v33CmLq2ZvMqBdY9AVB2z8uhbHPCZSuZbv68hE6NBXBc51Gg9MGUGr)
          Key image 123456789...
        • 8765.435 OXEN (T6Tpop5RZdwE39iBvoP5xpJVoMpYPUwQpef9zS2tLL8yVgbppBbtGnzZxzkSp53Coi88wbsTHiokr7k8MQU94mGF1zzERqELK)
          ‣ 7530 OXEN (Key image: 23456789a...)
          ‣ 1235.435 OXEN (Key image: 3456789ab...)

If we aren't showing key images then all the key image details get omitted.

---

Locked key images get overhauled too; it wasn't at all clear from the
output *why* these are locked (i.e. these are locked contributions of
failed SNs):

    Locked Stakes due to Service Node Deregistration:
        ‣ 234.567 OXEN (Unlock height 1234567; Key image: abcfed999...)
        ‣ 5000 OXEN (Unlock height 123333; Key image: cbcfef989...)
2022-07-11 17:21:17 -03:00
Jason Rhinelander efebe83225
Fix empty lines in `print_locked_stakes` output
Fixes #1575

We were appending a newline for every locked stake rather than just this
wallet's locked stakes.
2022-07-11 14:38:56 -03:00
Jason Rhinelander bee13a319c
Merge pull request #1569 from darcys22/pop-blocks-investigation
Pop blocks investigation
2022-07-07 18:20:19 -03:00
Jason Rhinelander cd90b1bf0d
Merge pull request #1571 from jagerman/negative-emissions
Fix negative coinbase emissions
2022-07-07 18:20:01 -03:00
Jason Rhinelander 815b7bdc1f
Fix negative coinbase emissions
With batching, individual blocks can have a negative coinbase emission
because the tx fee gets added to the batch rewards database and not paid
out immediately, which then results in an negative overflow to a value
close to 2^64.  Thus a block with no payout and a tx fee will have an
erroneous huge positive coinbase emission when queried via
`get_coinbase_tx_sum`.  For example block 1094068 queried with:

    {"jsonrpc":"2.0","id":"0","method":"get_coinbase_tx_sum","params":{"height": 1094068, "count": 1}}

returns:

    {
      "jsonrpc": "2.0",
      "id": "0",
      "result": {
        "burn_amount": 0,
        "emission_amount": 18446744073699378616,
        "fee_amount": 10173000,
        "status": "OK"
      }
    }

This commit fixes it by making the values signed (and also serves as an
example of why unsigned integers are usually the wrong choice):

    {
      "jsonrpc": "2.0",
      "id": "0",
      "result": {
        "burn_amount": 0,
        "emission_amount": -10173000,
        "fee_amount": 10173000,
        "status": "OK"
      }
    }
2022-07-05 10:24:08 -03:00
Sean Darcy 8566f8b973 nano s plus HID pid 2022-06-29 15:27:22 +10:00
Sean Darcy ed605fc1ac handle big pops 2022-06-23 16:37:21 +10:00
Sean Darcy fa88a104d4 keep add block and pop block for batching database in sync with service node list 2022-06-21 15:14:04 +10:00
Jason Rhinelander b5a5d01b04
Optimization: reuse reward vector
Profiling shows noticeable CPU spend in allocating memory for this
vector (which makes sense, since we are looping through ~1700 nodes and
building a reward vector for each one).  Avoid it by reusing a single
vector that gets cleared (but not reallocated more than a handful of
times).

This reduces batching CPU time in a debug build by about 12%; curiously
I didn't find a noticeable reduction in a release build.
2022-06-19 12:36:40 -03:00
Jason Rhinelander 230b6bdc0d
128 bit optimizations
Use intrinsic 128-bit types when supported by the compiler; the
operations on them are a bit faster than the two-uint64_t
implementations we do not, and this shaves about 7% off the batch
processing time (which makes a lot of mul128_div64 calls).

Also removes a bunch of unused, useless epee crap from int-util.h.
2022-06-19 12:36:40 -03:00
Jason Rhinelander 0f918f46d4
Downgrade upgrade info message 2022-06-19 12:36:40 -03:00
Jason Rhinelander 33a0762563
Batching address string optimizations
Converting between internal addresses and string wallet addresses is
surprisingly expensive (partly because a keccak hash is involved);
normally on the blockchain that doesn't matter because string
conversions are rare, but batching exposed some code paths that do the
conversion a lot.

This makes two optimizations to considerably speed up batching
processing time:

1. Add an address string hash for batch addresses.  We don't see that
   many, but we tend to see the same addresses for *every* block.  By
   caching it we can considerably reduce the time needed to do the
   actual conversions.

2. In many places we don't really need strings at all: we can work just
   with the address_infos (which are cheap).  This eliminates some of
   the places we use addresses and pushes address_infos further through
   the code.

In total, this plus the previous optimization drop batch processing time
by this cuts batch processing CPU time by about 85%, roughly half from
this optimization and roughly half from the store-offsets optimization.

On a debug build, timing mainnet resyncing from just before HF19 to
current:

- neither optimization: 223.60s spent processing batch jobs (of 282s
  total recalculating subsystems).
- just offsets: 131s spent in batch processing
- both optimizations: 33s spent in batch processing (down to 60s total
  recalculating).

On a release build:
- before: 107.35s (4.73s snl; 95.55s batch)
- after: 28.27s (4.66s snl; 0.00s ons; 21.72s batch)
2022-06-19 12:36:40 -03:00
Jason Rhinelander 1ff341a7cf
Store payment_offset in batched_payments_accrued
This drastically increases the speed of processing new blocks because we
can select only the addresses we care about.
2022-06-19 12:36:40 -03:00
Jason Rhinelander 0ed150012e
Fix batch timing reporting; reduce block processing size
Batch timing was being reported as 0s, even though it is taking up the
vast majority of the time as of the HF block.

Reduce the block processing size to 500 blocks at a time rather than
1000.

Change when we print status updates to print once duration passes a 10s
threshold rather than every 10*1000 blocks.

This latter change probably also makes oxend more reliable on
low-powered servers because it also guards the systemd status update
message (which is needed to give us more watchdog time).
2022-06-19 12:34:56 -03:00
Sean Darcy b324193dc3
Keep SNL state correct during resyncing of sqlite submodule
When the sqlite batching database is resyncing it is dependant on the
service node list state being correct at the time the block is added to
the batching database. When syncing a singular module this sometimes is
not the case as the service node list state may be ahead or behind. This
patch simply ensures that when the batching database is behind the
service node list is reset back to that point in time.
2022-06-19 12:34:56 -03:00
Jason Rhinelander 502f88cdc4
Merge pull request #1565 from jagerman/next-height-is-now
Next height is now
2022-06-19 12:34:24 -03:00
Jason Rhinelander f87c9990a2
Merge pull request #1564 from jagerman/remove-log-error
Remove wallet debugging errors
2022-06-19 12:33:57 -03:00