1543 Commits

Author SHA1 Message Date
TomZ 655d9fecb9 Port a log-line. 2020-04-01 20:24:08 +02:00
TomZ 436535647f Add several new features to networkmanager
Allow user to shutdown a connection, making it instantly invalid.
Allow user to register a callback for errors.
And fix pinging to be disabled on legacyP2P style connections.
2020-04-01 20:24:04 +02:00
TomZ 24e557f566 Stop double applying of offset.
We already removed the bytes in Message::header()
2020-04-01 20:22:55 +02:00
TomZ 40cad6112c Pass by reference 2020-04-01 20:22:55 +02:00
TomZ 655179e660 Add EndPoint::from() from a byte-array
This is used on the p2p layer and this allows simple
integration.
2020-04-01 20:22:55 +02:00
TomZ 0c15e877a2 Move arith_uint256 from server to utils lib 2020-04-01 20:22:55 +02:00
TomZ 22e2f3ca7c Make p2p version message mandatory
This was always the intention, but the satoshi code was stupid and buggy.
First, the 'version has been seen' flag was set even if there was a parsing
error in it.
Second, ignoring messages (up to 100) until a version message was seen
makes no sense. Just disconnect instantly.
2020-03-29 12:55:12 +02:00
TomZ 54a07cbdfc Add new log group for future component 2020-03-29 12:55:12 +02:00
TomZ 7b1b742036 Remove workaround for old boost version
The API changes in boost between 1.66 and later was the need
for the boost_compat.h header file.
Its been a long time since Flowee started demanding 1.67 minimum
for boost, making this compat obsolete.
2020-03-29 12:55:12 +02:00
TomZ bf24ed042b Add support for legacy p2p network envelope in networkmanager 2020-03-29 12:55:12 +02:00
TomZ 8b365263de cleanup 2020-03-29 12:55:12 +02:00
TomZ 997e861e93 Add fetch method on mempool for DSPs
Allow the retrieval of a double spend proof based on the transaction-id
it is paired with inside the mempool.
2020-03-19 22:05:11 +01:00
TomZ 5266529f13 Fix potential race condition
Add missing mutex
2020-03-19 22:05:05 +01:00
TomZ 4e0b42d205 Fix BufferPool::forget()
Using the forget() method too many times could lead to an invalid
(negative size) ConstBuffer being created.
This fixes and immediately copies an assert used in many other places in
the code already.
2020-03-19 15:05:54 +01:00
TomZ 6ad8374794 Update testnet seeders 2020-03-19 15:04:28 +01:00
TomZ e9ef907c1f Sync checkpoint save and index-db saveCaches
When the UTXO saved checkpoints this change makes sure we also store the
index-db changes.

Since we stopped saving simple state changes fromt the index-db, the
only real data we save is the 'undo-block-index', as such this will be
relatively cheap to save.
Without an undo block position we will currently fail to verify those
blocks and as such it is useful to save all at the same time to actually
have a state we can start from.
2020-03-05 23:29:53 +01:00
TomZ 4f077da5a6 remove assert(true) 2020-03-05 23:29:53 +01:00
TomZ bd58ac420a Avoid reuse (shadow) of variable 2020-03-05 23:29:53 +01:00
TomZ 8e269a2ea8 Fix initialization order 2020-03-05 23:29:53 +01:00
TomZ 043f496c73 Make scope of variable smaller. 2020-03-05 23:29:53 +01:00
TomZ 579dc67bc2 Remove dead code 2020-03-05 23:29:52 +01:00
TomZ 02258d9dcd Make pruner use the new tags
This allows the pruner to be used on the 'tip' DB file, at which point it
will set the filesize to be the default 2GB one.
Previously pruning the tip would confuse the Hub with a smaller file
size.
2020-03-05 23:29:52 +01:00
TomZ c79be8860a Use VerifyDB as well when finding a functional UTXO state
Allow VerifyDB to disquality a utxo-state so we can find an older one, if
available, and try harder to start without reindex.
2020-03-05 23:29:52 +01:00
TomZ 01ff5ff1db Make writing to blk file not follow symlinks
To share the downloaded blocks between instances on Linux it is common
to sym-link the blk files from read-only storage.
The Hub would fail to write to the last file due to the file being on
read-only storage and the Hub would shut down.
This change makes sure we instead create a new file instead of trying to
write to a symlinked one.
2020-03-05 23:29:52 +01:00
TomZ d9604e3f33 Design a better detection for need of UTXO-GC
Doing a garbage collect of the Sha256 based databases means we remove
all the records that have been deleted from our file.
We also sort the file to have all the jump-tables at the end, making it
much cheaper on memory-locality to find (or not) items in the DB.

The downsides are that this prune step takes time, writes dozens of MBs
and that we lose checkpoints. The latter means we no longer can rollback
to a safe position, simply because we flushed those records.

So we want to do this often enough to avoid fragmentation but not too
often because it creates a greater risk on data consistency.

This algoritm checks the actual data and calculates the fragmentation of
the jump-tables to decide if we want to start a GC.

When we do GC, we try to do as many files as makes sense, to make sure we
can wait quite a long time before we need to do a new GC.
2020-03-05 23:29:52 +01:00
TomZ a5a2aef53e Increase the amount of checkpoints from 5 to 15.
Now we can revert much cheaper to an earlier checkpoint it becomes much
more important that we actually keep them around to be usable.
2020-03-05 23:18:42 +01:00
TomZ a790b26133 Just warn about failing to write to a legacy blk
Boost throws an exception when the resize fails, which would cause
a total shutdown of the client. So make sure we catch it in the
scheduled task to avoid this problem.
2020-03-01 18:27:28 +01:00
TomZ 0e6231e636 Add a check to only write when not loaded
In some unit tests I noticed that we write a block that was just loaded
from disk, this check avoids this overhead.
Not sure how relevant this is for normal operations.
2020-02-28 12:55:16 +01:00
TomZ 7e7f42e8ec Make de-orphaning code no longer recursive.
The recovering of orphans was recursive and that meant there was a max
length of headers we could process with a gap in the chain due to normal
stack-depth for recursivity (approx 50k).
As headers are being provided to us from external peers this could be a
DOS vector.

This implementation avoids this problem by not being recursive.
2020-02-28 00:34:12 +01:00
TomZ 1141de5c13 Cleanups 2020-02-28 00:34:12 +01:00
TomZ 9a3dde8400 Make sure the UTXO doesn't write a new info file when there are no changes 2020-02-28 00:34:12 +01:00
TomZ 60d371afa7 Make loading find a functional UTXO state
When, on loading, the blockindex and the UTXO don't agree then try to find an older UTXO
state where they do agree.
The most typical state issue is where a block stored in the blocksdb is not available in
the index due to corruption or similar.
2020-02-28 00:34:08 +01:00
TomZ f0e93708e1 Minor cleanups 2020-02-28 00:33:11 +01:00
TomZ 30927fe0b2 Fix reindexing sometimes failing due to read-only blocks
When reindexing we now always first try to open a file read-write because
the algo to only open the last file in a sequence as RW failed in such
situations where we don't know the amount of files yet.
2020-02-28 00:33:11 +01:00
TomZ 489a9a4859 Move nStatus of blockindex into the UTXO
To allow the UTXO to actually use the power of checkpoints we need to
make sure that the block-validation state is not stored separately from
it.
The goal is that when we have some curruption we can just go back to an
earlier state of the UTXO and re-validate the blocks to get to the
current tip. The often seen problem is that corruption will instead
leave the block-index (leveldb) with an incorrect state so the replay
fails.

This change solves that by no longer reading the block-validation-state
and no longer writing it on a state change.
2020-02-28 00:33:04 +01:00
TomZ a1b4c0416d Avoid clearing an empty bloom filter 2020-02-27 23:26:20 +01:00
TomZ 99a78eb60a remove dead code 2020-02-27 13:51:21 +01:00
TomZ 8057429dfa Re-do the UTXO garbage collect planning algo
The UTXO keeps outdated records around in an append-only file, which
means we need to do a garbage collect regularly.
This new algo uses the commulatative amount of changes since last GC
(aka prune) as an indicator to plan a new one.

The effect should be much smaller files to keep in memory and the data and
jump tables being much more localized which should result in higher
throughput.
2020-02-23 11:15:55 +01:00
TomZ 86d580463a Make selection of UTXO info files better
This avoids some cornercases.
2020-02-22 13:43:16 +01:00
TomZ 00d4905db2 Provide another convenience method for making messages
THe builder now allows you to create a message with the
serviceId, the messageId and the requestId pre-set.

This benefits code that just takes the output from the
builder and calls 'send' on it immediately saving several
lines of code.
2020-02-19 16:55:46 +01:00
TomZ 05048a2109 make non-debug builds more useful for unit tests in debug build 2020-02-19 16:55:46 +01:00
TomZ 999772a748 Allow usage of the logger outside of Flowee
Ship unit-testing functionality in the releease builds too,
external users may want to compile their apps in debug mode while
flowee is a release build.
2020-01-30 15:29:03 +01:00
TomZ 4bea1f55c4 use QElapsedTimer 2020-01-30 15:29:03 +01:00
TomZ 11d16001c6 Indexer: add get for current sync-height 2020-01-20 12:17:55 +01:00
TomZ a01fbab2b7 Update tests and fixes in bitcore-proxy
this fixes mixups when more than one output of a transaction was used in
our search.
2020-01-17 19:44:29 +01:00
TomZ cb5d9d16f6 Fix usage of exceptions
Throwing an exception instead of returning false means we blacklist the
txid from being downloaded multiple times.
2020-01-15 17:11:27 +01:00
TomZ c672f80374 Catch exception from DSP::create() 2020-01-14 12:36:19 +01:00
TomZ c0ba4e49fb RPC getrawtransaction allow 'true' for bool
This allows fulcrum to work with this old API method.
2020-01-13 23:23:49 +01:00
TomZ 58299fcd70 Add 'initialblockdownload' bool to RPC getbclockchaininfo 2020-01-13 17:42:50 +01:00
TomZ 2e3f59716f Add claimOrphan() 2020-01-13 11:27:47 +01:00