Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Backports from quorumnet branch for 5.x #872
This backports various additions and cleanups from the quorumnet branch (PR #844) that we can use in 5.x. (The actual quorumnet communication layer itself is not included and will come in Loki 6.x/HF14).
Aside from the miscellaneous code cleanups/fixes/improvements, I've been mulling over whether to include the ed25519 keys for a while, and think we should: lokinet and storage server can potentially make use of them before HF14, so this adds ed25519 key generation and uptime proof broadcast for HF13.
This also (in addition to the ed25519 pubkey) adds a
@Doy-lee - most of the changes here are already reviewed via #844, but there were some small cleanups that are worth including in the
This is going to break the validity of uptime proofs on the testnet, so we should coordinate upgrading testnet nodes with merging this PR.
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.
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).
- removed unused forward declaration - fix class/struct forward declaration mismatch warning
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.
We don't need to convert it to string for anything *except* sending it as log output, so simplify it to match things like txversion.
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.
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.
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.
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.
- 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).