Commit graph

9808 commits

Author SHA1 Message Date
Jason Rhinelander c00e8221cc Add SN ed25519/x25519 pubkeys + quorumnet port in proofs
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.
2019-10-07 22:09:17 -03:00
Jason Rhinelander 2c52c1c020 Add unified key container
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.
2019-10-07 22:09:17 -03:00
Jason Rhinelander 45d62f1763 Code cleanup & minor reorganization
- 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).
2019-10-07 22:09:17 -03:00
Jason Rhinelander f32e910d41 Add helper function to memcpy multiple variables
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.
2019-10-07 22:09:17 -03:00
Jason Rhinelander ba7efa21fe Add updated zmq c++ library
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.
2019-10-07 22:09:17 -03:00
Jason Rhinelander c2f2c8306e Remove useless method.
Five years into the future this pointless method is still not used.
Time to go.
2019-10-07 22:09:17 -03:00
Jason Rhinelander dd6de52378 Add --dev-allow-local-ip flag for allowing local network public-ip
This is very useful for testing.  Also adds a suitable scary warning at
startup when used.
2019-10-07 22:09:17 -03:00
Jason Rhinelander a53e86a627 Make quorum_type directly printable
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.
2019-10-07 22:09:17 -03:00
Jason Rhinelander 36e37c12bb Switch loki core to C++14
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.
2019-10-07 22:09:17 -03:00
Jason Rhinelander bea636a619 Forward declaration updates
- removed unused forward declaration
- fix class/struct forward declaration mismatch warning
2019-10-07 22:09:17 -03:00
Jason Rhinelander 0b384f5f52 Use perfect forwarding to set default serialize value
Avoids an extra copy plus also allows move assignment where available.
2019-10-07 22:09:17 -03:00
Jason Rhinelander 0202b865ed Remove crypto::crypto_ops
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).
2019-10-07 22:09:17 -03:00
Jason Rhinelander 0f06f89b05 Remove POD_CLASS macro and pointless pack pragmas
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.
2019-10-07 22:09:17 -03:00
Doyle 11e6f7affe
Fix the overflow test for fee and block_reward in blocks (#869) 2019-10-04 15:01:03 +10:00
Jason Rhinelander a3ebf5eba6 Reward fudge factor (#867)
* 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
2019-10-04 13:57:14 +10:00
Doyle c3f71c8841
Merge pull request #868 from jagerman/rx-pow-fix
Fix randomx cache selection
2019-10-04 11:38:09 +10:00
Howard Chu 9213574434 Fix randomx cache selection for RPCs
Was using the wrong cache slot, and returning invalid PoW hashes to RPC clients
2019-10-03 17:16:06 -03:00
Doyle 18b0aedcdc
Merge pull request #866 from Doy-lee/CheckpointRPCCallsForExchanges
Changes to show checkpointedness of transactions
2019-10-03 14:49:04 +10:00
Doyle 7acd639e41 Merge transfer_view and transfer_entry together 2019-10-03 12:12:25 +10:00
Jason Rhinelander d3b15318f2 Relax p2p connection restrictions for testnet/stagenet (#864)
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.
2019-10-03 09:32:32 +10:00
Doyle dded026a3a Display checkpointedness of transactions in wallet 2019-10-02 17:48:24 +10:00
Doyle 918a92c8fa Add immutable_height to get_info call 2019-10-02 17:46:13 +10:00
Doyle c74811b703
Update checkpoints votes UI earlier, tweak how we count votes (#860)
* Update checkpoints votes UI earlier, tweak how we count votes

* Code review
2019-09-26 11:28:53 +10:00
Doyle f539108d28
2 checkpointing fixes (#861)
* 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??
2019-09-26 11:14:58 +10:00
Doyle 209113c072
Merge pull request #862 from jagerman/randomx-integration-update
Randomx integration update
2019-09-26 10:27:51 +10:00
Howard Chu 3b8dd4b25b Updated RandomX integration from upstream
Support RandomX PoW algorithm
2019-09-25 17:12:23 -03:00
Jason Rhinelander f0ab90e99e Update randomx external repository 2019-09-25 14:46:53 -03:00
moneromooo-monero 9fc266df58 epee: misc_log_ex.h can now be used in C code
use mfatal/merror/mwarning/minfo/mdebug/mtrace
2019-09-25 14:46:53 -03:00
Doyle 73d4821ea8
Clarify some error message wording, don't print quorum failures early (#858)
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)
2019-09-25 14:08:19 +10:00
Doyle fca5bfb22d
Merge pull request #857 from jagerman/fix-zero-time
Show "(never)" instead of 18163.1 days ago
2019-09-24 15:01:36 +10:00
Jason Rhinelander 9ae112ab48 Show "(never)" instead of 18163.1 days ago
The uptime proof time in `status` wasn't handling a 0 value propery.
2019-09-23 23:39:03 -03:00
Doyle 07c9a2dda6
Merge pull request #856 from jagerman/status-add-sn
Show one-line SN summary in `status`
2019-09-24 10:34:38 +10:00
Doyle a5e17f2f1e
Merge pull request #855 from Doy-lee/CherryPickP2PFixes
Cherry pick p2p revert commits
2019-09-24 10:34:31 +10:00
Doyle ae64dd6497
Merge pull request #854 from Doy-lee/GenerateEmptyQuorumOnInsuffcientNodes
Make empty quorum if height is checkpointable but insufficient nodes
2019-09-24 10:34:24 +10:00
Doyle 0bd84e99a7
Merge pull request #853 from Doy-lee/PrintCorrectHeightInCheckpointQuorumErr
Print correct height in checkpoint quorum error
2019-09-24 10:34:07 +10:00
Doyle 1cda71f809
Merge pull request #852 from Doy-lee/DontFormInvalidBEIs
Dont form invalid block_extended_infos
2019-09-24 10:33:51 +10:00
Jason Rhinelander ccaff4268a Show one-line SN summary in status
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).
2019-09-23 18:47:59 -03:00
moneromooo-monero a1398f3152 Revert "cryptonote_protocol: drop peers we can't download from when syncing"
This reverts commit a96c1a46d4.
2019-09-23 16:18:10 +10:00
moneromooo-monero f7f6a4971a Revert "Fix check for disconnecting peers when syncing"
This reverts commit adc16d2504.
2019-09-23 16:17:56 +10:00
Doyle 127b505558 Make empty quorum if height is checkpointable but insufficient nodes
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
2019-09-23 14:42:29 +10:00
Doyle 1267a23fdb Print the correct height in checkpoint quorum error 2019-09-23 12:58:16 +10:00
Doyle 64d5322b55 Don't form invalid BEI's by passing in empty checkpoints if not checkpointed 2019-09-23 11:10:55 +10:00
Doyle 663f946d08 Only store block hashes for invalid blocks
We only need this information to instantly reject blocks again from the
P2P network.
2019-09-23 11:09:19 +10:00
Doyle 705885af1b
Add testnet checkpoint & enable checkpoints from json (#851) 2019-09-20 17:06:12 +10:00
Doyle f94328bf37
Switch to using validators for checkpoints (#850)
* 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
2019-09-20 15:54:00 +10:00
Doyle bcbaaeef93
Enforce checkpoint quorums min size and soft fork it for testnet (#842)
* Enforce checkpoint quorums min size from HF13 onwards

* Add core_test for checkpoint quorum min size
2019-09-20 12:46:34 +10:00
Doyle c3e257c118
Merge pull request #849 from Doy-lee/CherryPickBanFix
p2p: fix bans taking port into account
2019-09-20 12:43:05 +10:00
moneromooo-monero 2153aba136 p2p: fix bans taking port into account 2019-09-20 10:12:36 +10:00
Doyle ee737e4919
Merge pull request #848 from Doy-lee/SNGovFeesCoreTest
Service Node + Governance derived from unpenalized reward core test
2019-09-20 09:33:21 +10:00
Doyle 416cf17ac3 Add core test for service node reward dervied from unpenalized reward 2019-09-20 09:32:59 +10:00