Commit graph

10158 commits

Author SHA1 Message Date
Howard Chu
6a0d18e102 Fixup sodium darwin
get rid of sodium-darwin.mk special case, unify back with sodium.mk
2019-12-22 22:40:36 -04:00
Howard Chu
e8cc7bfaad Add ARFLAGS
Needed to invoke deterministic mode on some archivers
2019-12-22 22:39:55 -04:00
Howard Chu
200a9efc51 depends: Add FreeBSD support 2019-12-22 22:37:36 -04:00
Howard Chu
2e8cdab270 Add Android support 2019-12-22 22:33:27 -04:00
hyperreality
f768f4e016 Fix Travis build on Windows + Mac
Following 13c0b8c, the unwind package is being attempted to be built on
Windows and Mac when it should only be built on Linux.
2019-12-22 22:24:05 -04:00
TheCharlatan
75fddd37e7 Add depends riscv 64 bit support 2019-12-22 22:24:00 -04:00
Jason Rhinelander
1422139736
Merge pull request #989 from jagerman/lib-fixes
Fix contrib/depends library incompatibilities
2019-12-19 20:41:33 -04:00
Jason Rhinelander
c0a2f0b88c Fix type disagreement (size_t vs uint64_t) 2019-12-19 20:39:59 -04:00
Jason Rhinelander
055b593237 Fix contrib/depends library incompatibilities
sodium and zmq libs weren't using the same variable name which would end
up linking to system libsodium even when we meant to link to the static
one from contrib/depends.
2019-12-19 20:24:38 -04:00
Jason Rhinelander
ac784faeb3 Don't print worker_index when not an obligations vote (#987)
DEBUG is printing:

    Signature accepted for checkpointing voter n/<pubkey> voting  for worker NNNNN at height H

where NNNNN is some random 16-bit number.
2019-12-19 09:40:49 +10:00
Jason Rhinelander
19c562f800 Vote serialization compatibility fix (#984)
quorum_vote_t's were serialized as blob data, which is highly
non-portable (probably isn't the same on non-amd64 arches) and broke
between 5.x and 6.x because `signature` is aligned now (which changed
its offset and thus broke 5.x <-> 6.x vote transmission).

This adds a hack to write votes into a block of memory compatible with
AMD64 5.x nodes up until HF14, then switches to a new command that fully
serializes starting at the hard fork (after which we can remove the
backwards compatibility stuff added here).
2019-12-17 10:47:12 +10:00
Jason Rhinelander
5d0b568709 Sort print_sn checkpoint votes (#985)
Checkpoint votes internally use a circular buffer, but that's rather
difficult to read for the `print_sn` output; this changes print_sn to
de-circularize the listed votes.
2019-12-17 10:28:26 +10:00
Jason Rhinelander
fab8ded246 Cleanup on block adding failure (#983)
If a block adding fails (triggering the "Block added hook signalled
failure" error message) the service node list doesn't get reset, which
immediately leads to a bad service node winner (because the winner was
already incremented and not popped off).

This updates it to call the blockchain detached hooks to do the cleanup.

It also changes around loki::defer a little bit to rename the internal
class to `deferred` and make it cancellable (by calling `.cancel()`).
`loki::defer` is repurposed as a free function to get a named `deferred`
object given a lambda, which is needed to be able to call `cancel()` on
it.  (The LOKI_DEFER macro still works as is).
2019-12-16 08:49:35 +10:00
Jason Rhinelander
78ded3af70 Do txn handling via TXN_BLOCK_PREFIX macro (#982)
The macro handles the case where we can be called from either inside or
outside a block batch transaction.
2019-12-16 08:44:53 +10:00
Doyle
01dd6484be
Merge pull request #981 from jagerman/quorumnet-backtalk-guard
Quorumnet backtalk guard
2019-12-13 14:29:58 +10:00
Jason Rhinelander
8ec77ef546 Add is_service_node()
It wasn't immediately obvious why checking `listener` means we're a
service node, so make it more explicit via an abstraction method.
2019-12-12 23:53:08 -04:00
Jason Rhinelander
608cb76d0e register_command: switch arg order; drop std::function
The argument order felt wrong: switch it to (NAME, TYPE, FUNC)

Since register_command is meant to be called statically there is little
purpose in being able to accept a non-function-pointer callback (i.e.
direct function or capture-less lambda), so drop using std::function<>'s
for command callbacks to avoid the virtual call overhead.
2019-12-12 23:36:04 -04:00
Jason Rhinelander
9cd4615b35 Abstract assert + reinterpret_cast 2019-12-12 23:35:05 -04:00
Doyle
85185340f0 Guard against null ptr deref on quorumnet layer
This can be abused by Service Nodes specifying normal daemon IP's not
running in Service Node mode causing a crash.
2019-12-12 23:02:48 -04:00
Jason Rhinelander
a1db78239d SNNetwork: make quorum commands tri-state
Changes commands from two types (quorum & public) to three:
- anyone -> service node (SNNetwork::command_type::public_)
- service node -> anyone (SNNetwork::command_type::response)
- service node -> service node (command_type::quorum)

Previously quorum commands could be issued to non-SN nodes, but that
should not be allowed (and the code would dereference a nullptr if that
happened).
2019-12-12 22:58:53 -04:00
Doyle
54333e5b49
Merge pull request #978 from jagerman/another-deadlock-fix
Another deadlock fix
2019-12-12 16:08:24 +10:00
Jason Rhinelander
7eca201eb5 Admit defeat for now: use boost::lock
macOS's std::lock() is broken in that it internally calls non-namespaced
function `try_lock` leading to an ADL conflict with boost::try_lock when
any of the arguments is a `boost::whatever`.  `boost::lock` will do the
job for now.
2019-12-12 01:35:35 -04:00
Jason Rhinelander
0538f6aa7d Attempted fix to make macOS clang happy 2019-12-12 01:05:42 -04:00
Jason Rhinelander
8b1df0ef4c Fix deadlock
The m_blockchain lock added in #975 was causing deadlocks because we
have ordered `m_blockchain -> ... -> m_sn_mutex` lock sequences but
`proof.store()` was adding a `m_sn_mutex -> ... -> m_blockchain`
sequence when called when receiving an uptime proof.  Fix it by also
taking out an m_blockchain lock where we take out the `m_sn_mutex`.
2019-12-11 23:29:52 -04:00
Jason Rhinelander
55bd5941aa Add helper header/func to obtain unique locks
auto locks = tools::unique_locks(mutex1, mutex2, ...);

gives you a tuple of unique_locks and obtains the locks atomically.

    auto lock = tools::unique_lock(lock1);

is essentially the same as:

    std::unique_lock<decltype(lock1)> lock{lock1};

but less ugly (and extends nicely to the plural version).
2019-12-11 23:28:05 -04:00
Jason Rhinelander
7c3dc58f8c Simplify and avoid uninitialized value warning (#976)
* Simplify and avoid uninitialized value warning

Rearranging/simplifying this code slightly to avoid gcc giving a
possibly-uninitialized value use on the dereference that follows this
changed code.

* More simplification: don't need optional
2019-12-12 11:05:09 +10:00
Doyle
b45d2b825b
Merge pull request #975 from jagerman/db-lock
Work around broken database interface/fix deadlock
2019-12-12 08:57:35 +10:00
Jason Rhinelander
19f59acfd8 Work around broken database interface
Apparently it's not safe to use "transactions" in the LMDB without first
taking out an exclusive lock on the Blockchain class.  Transactions
apparently aren't actually transactions, they are just fatal errors that
forever deadlock the database if you try to take two write transactions
at once.

Work around this terrible design by adding the appropriate magic
incantation.
2019-12-11 11:51:36 -04:00
Doyle
0e690e5394
Merge pull request #973 from Doy-lee/Gcc5.5Fix
Fix GCC 5.5 not being smart about evaluating dead branches
2019-12-11 15:21:30 +10:00
Doyle
0f2f01c43a Fix GCC5.5 not being smart about evaluating dead branches
src/quorumnet/bt_serialize.h: In instantiation of 'void quorumnet::detail::bt_deserialize<T, typename std::enable_if<std::is_integral<_Tp>::value, void>::type>::operator()(std::istream&, T&) [with T = long unsigned int; typename std::enable_if<std::is_integral<_Tp>::value, void>::type = void; std::istream = std::basic_istream<char>]':
src/quorumnet/bt_serialize.cpp:107:17:   required from here
src/quorumnet/bt_serialize.h:161:75: error: logical 'or' of collectively exhaustive tests is always true [-Werror=logical-op]
if (sizeof(T) < sizeof(int64_t) && (read.first.i64 < smin || read.first.i64 > smax))
2019-12-11 16:17:28 +11:00
Doyle
f8875adbb2
Merge pull request #972 from loki-project/dev
Merge 6.0.0 testnet to master
2019-12-11 13:36:16 +10:00
Doyle
37e6060097
Merge pull request #971 from Doy-lee/DebugAssertionFix
Service Node Info debug assertion fix
2019-12-11 13:33:37 +10:00
Doyle
9ea0c136b5 Update service node info to v4, no data conversions necessary 2019-12-11 14:27:59 +11:00
Doyle
6f4ff37902
Merge pull request #970 from loki-project/master
Merge test fix into dev from master
2019-12-11 13:24:57 +10:00
Doyle
b4f74746c4
Merge pull request #969 from Doy-lee/AddMissingTestFunctions
Add new missing relay vote testing functions stubs
2019-12-11 13:17:49 +10:00
Doyle
3d9fedf1c1
Merge pull request #968 from jagerman/blink-balance-fix
Blink wallet balance fix
2019-12-11 13:08:14 +10:00
Doyle
8a549514f2 Add new missing relay vote testing functions 2019-12-11 14:00:05 +11:00
Doyle
6b3b3a615d
Merge pull request #966 from jagerman/p2p-checkpoint-votes
Put checkpoint votes back over P2P
2019-12-11 12:41:38 +10:00
Jason Rhinelander
2d96bc3241 Show mined, but uncheckpointed, blink txes as blinks
Current when a blink gets mined it just looks like an ordinary
transaction, but this isn't right: it's still a blink with special
status until it gets checkpointed.
2019-12-10 19:57:52 -04:00
Jason Rhinelander
5ad70135f0 Don't count unmined blink txes in unlocked balance
It still has to go through unlocking until we have reblinking.
2019-12-10 19:57:43 -04:00
Jason Rhinelander
452bc72ee3 Simplify serialization code and drop unsupported versions
loki started life with transfer details serialization version 9, so we
can drop the stuff to handle earlier versions.  Also this code structure
that repeats a call to `initialize_transfer_details` 100 times is gross,
so fix it.
2019-12-10 19:57:32 -04:00
Doyle
4caafc0177
Merge pull request #967 from jagerman/misc-changes
Misc changes
2019-12-11 09:52:58 +10:00
Jason Rhinelander
9d7a53840e Set minimum version for v14
This will need to be updated with the final mainnet release version.
2019-12-10 16:44:49 -04:00
Jason Rhinelander
013ed68b83 Green alert loudly on first signicant ping
If we've previously printed some alerts about not submitting proofs
because of lokinet/storage server it's nice to print a message as soon
as we get the needed ping.  Also nice to see on startup for the first
one to know things are working.
2019-12-10 16:44:42 -04:00
Jason Rhinelander
bbb72b5c17 Keep checkpoint votes over p2p
Checkpoint votes were only going over quorumnet, which was quite broken
as they need to go out universally: random nodes piece together the
individual checkpoints to create checkpoints on their own, and so need
to see all of the votes.  With the current code only service nodes that
participated in the specific quorum ever saw the checkpoint votes.

This commit returns checkpoint vote distribution to distribution over
p2p.

We could, in theory, do checkpoint vote collection over quorumnet and
then relay the set of votes as a pack to reduce p2p traffic a bit, but
this wouldn't be a huge optimization since we'd still have to distribute
all the votes over p2p at some point anyway, so leaving that as a future
optimization for now.

(Obligations votes, in contrast, don't need to be distributed at all --
if a vote results in a state change, the quorum members themselves can
produce and distribute the state change tx).
2019-12-10 16:29:17 -04:00
Jason Rhinelander
9f68a64cae update_checkpoint logic
`update_checkpoint` was being set to true whenever we don't have enough
signatures, but it really should only be set to true when we don't have
enough signatures *and* we insert one (otherwise we can end up calling
`update_checkpoint` even when we have nothing to update).  It looks like
this was the intention of the inner-loop `update_checkpoints = true`
already, so this removes the outer assignment and keeps the inner loop
assignment.
2019-12-10 16:29:08 -04:00
Jason Rhinelander
773afcaec2 Split up handle_vote
No logic changes.

It was getting too big.
2019-12-10 16:28:25 -04:00
Doyle
70549825d0
Merge pull request #952 from jagerman/sn-startup-key-fix
Store proof info (keys, uptime, version) directly in LMDB
2019-12-10 14:45:20 +10:00
Jason Rhinelander
d0abfdd092 Clear our own proof timestamp when loading
This restores the more aggressive sending of uptime proofs after a
restart.
2019-12-09 22:27:33 -04:00
Jason Rhinelander
ed0adc3b69 Simplify service_node_proof_serialized ctor
Also import boost::endian namespace because the boost::endian's
throughout the file were needlessly verbose (the little_to_native calls
are already obvious).
2019-12-09 22:27:33 -04:00