This generates a ed25519 keypair (and from it derives a x25519 keypair)
and broadcasts the ed25519 pubkey in HF13 uptime proofs.
This auxiliary key will be used both inside lokid (starting in HF14) in
places like the upcoming quorumnet code where we need a standard
pub/priv keypair that is usable in external tools (e.g. sodium) without
having to reimplement the incompatible (though still 25519-based) Monero
pubkey format.
This pulls it back into HF13 from the quorumnet code because the
generation code is ready now, and because there may be opportunities to
use this outside of lokid (e.g. in the storage server and in lokinet)
before HF14. Broadcasting it earlier also allows us to be ready to go
as soon as HF14 hits rather than having to wait for every node to have
sent a post-HF14 block uptime proof.
For a similar reason this adds a placeholder for the quorumnet port in
the uptime proof: currently the value is just set to 0 and ignored, but
allowing it to be passed will allow upgraded loki 6.x nodes to start
sending it to each other without having to wait for the fork height so
that they can start using it immediately when HF14 begins.
This puts the SN pubkey/privkey into a single struct (which have
ed25519/x25519 keys added to it in the future), which simplifies various
places to just pass the struct rather than storing and passing the
pubkey and privkey separately.
- Replace a bunch of repetitive proof rejection rules with a macro +
HF requirement version loop.
- Remove mostly unused MAX_KEY_IMAGES_PER_CONTRIBUTOR variable. It has
always been set to 1 (and so doesn't actually do anything). If we
wanted to increase it at this point we'd have to add multiple
HF-guarded versions of it and HF-version guard the code anyway, so
seems simpler to just drop it.
- Simplify the max contributor/max contribution logic and merge it in
with the existing contributor code (this is made easier by the above
dropped variable).
Lets you write `memcpy_le(dest, foo, bar, baz)` and memcpy the contents
of foo, bar, and baz sequentially. Additionally, if any of those three
are integers, they are converted to little-endian order.
The system library C++ interface is an ancient version of this; this
vendors an updated copy that we need, and updates a couple existing
places that are using deprecated calls.
This enables various nice things (some of which are used in the
quorumnet code), and C++14 is old enough now that it's supported more or
less everywhere.
Additionally other parts of loki (e.g. lokinet, loki-storage-server)
have required C++14 all along, so this doesn't really change what we
support.
This "class" is a hot mess of uselessness:
- It's defined as a class that has declared constructor/destructor/copy
assignment, but can't be instantiated (because the declared
constructors/destructors/etc. aren't defined anywhere).
- There's a bunch of completely useless `friend` declarations in the
crypto wrappers (public_key, etc.) that do absolutely nothing since
those wrappers don't *have* anything private in them.
- Every (private) static function of crypto_ops is completely duplicated
outside crypto_ops taking exactly the same arguments.
- In order to call all those private static functions the containing
namespace has inlined free functions calling the private static
functions inside crypto_ops with identical arguments.
- Because the above isn't allowed, all of the definitions are repeated
a *third* time with friend function declarations inside crypto_ops.
So basically everything inside crypto_ops is exactly callable outside
crypto_ops with the same name and same arguments, but has this
completely pointless layer of indirection that adds nothing for no
reason.
This commits rips out all this useless crap and just makes the various
previous-crypto_ops static functions plain functions in the `crypto`
namespace (which is the only place they can be used and called anyway).
POD_CLASS is a retarded macro (it is always just `struct`).
The pack pragmas here do nothing because every type defined inside them
only has char array members which are already guaranteed by C++
alignment rules to have byte alignment.
* Add a 1 atomic unit fudge factor on reward calculations
If the thread's rounding mode is different (because RandomX changed it
in the current thread or in the thread that generated the block) then
the reward calculation can be up to 1 atomic unit off. This lets those
pass rather than rejecting the block.
(I tested LOKI's reward calculations up to height 10M to verify that the
maximum error in reward values is never off by more than 1).
* Remove partial_block_reward
This variable is not actually used anywhere.
* Add 1ULP tolerance for SN reward checks
* Rewrite confusing logic and error
- fix the broken error message which was printing "base(base+fees)" instead
of "total(base+fees)".
- improve the error message wording to actually indicate what the values
signify.
- don't use base_reward as a temporary value (the intermediate value
assigned to it is completely replaced later anyway).
- use some better variable names to describe what is happening here
* Add check for overflow
Our testnet IP distribution is far from distributed: the
1-connection-per-IP and skipping duplicate class B IPs are more of a
nuissance rather than anything useful on testnet.
* Don't reorg back too far, otherwise alt chain fails
* Fix faulty soft-forking code rejecting alt blocks too early
* Update core tests to handle unhandled paths
* Make soft fork conditional more obvious??
You don't want to report your node as failing locally if you can't be
voted on in that quorum (i.e. you re-registered quickly after
deregistration and still exist in the old quorums)
This adds the pubkey, current status, and last uptime proof on a second
line of output in the `status` command (if a service node and we can
query the SN info successfully).
This is so that we can validly print an error in quorum_cop on the
heights that are actually not being stored in the daemon VS a service
node network that has insufficient nodes to form the quorum.
Update core test to enforce this constraint
* Add temporary HF12/13 code to switch to validators for checkpointing
* Don't use target height for verifying vote age
You wouldn't have the quorum calculated to verify the vote in the first place.
* Update core tests to use validators for checkpoints