Commit Graph

50 Commits

Author SHA1 Message Date
TomZ 88028c3c77 Make flags be initialized faster
This fixes a regression which caused the hub on startup to not get any
validation flags until a new block was added to the chain.
2020-09-11 18:54:21 +02:00
TomZ 297a22dfa8 Move and fix partitionCheck()
Small refactor; move the partition check away from main and the obsolete
global variables we used to use, instead now just add it to the DB which
owns the data it works on.

This fixes the bug that in various cases we'd incorrectly get a warning
about no blocks being found in the last N hours.
2020-08-10 10:13:02 +02:00
TomZ 2aa462f8bb Replace SigOps with SigChecks
This is part of the protocol upgrade for 2020-05-15, and in general it
seems to go the direction of "we did this before, lets do this again".

The spec is clear enough, but there is still a lack of questioning and
testing. The problem this attempts to fix has been neutered for years[1].

The spec states:
> The essential idea of SigChecks is to perform counting solely in the
> spending transaction, and count actual executed signature check
> operations.

This, however nobel and logical, ignores that the
check-for-being-too-costly just pulled in a UTXO lookup and the loading
of the output script from the historical chain.
The goal that we protect against CPU over-use may be reached, but the
price is a total system slowdown. You can have multiple CPUs, but the
bus to permanent storage has one, max 2 parallel pipes.

To ensure theHub stays the number one scalable node, I didn't blindly
follow the spec, while making sure that the Hub is correctly going to
follow/reject consensus violations of newly mined blocks.

As a result the implementation in Flowee the Hub:

* does not check sigcheck-counts on historical blocks (more than 1000
  blocks in the past).

  This may increase the risk of chain-splits ever so slightly, but the cost
  of disk-IO would be too high.

* No longer stores the value in the mempool, nor uses it for the
  CPU-miner.

* Ties the sigcheck-limits to the user-set block-size-accept-limit.

  This is contrary to the spec which mistakenly thinks that BCH has a
  max block-size in the consensus rules. The effect is the same, though.

* The per-intput standardness suggestion is not implemented because
  standardness checks don't currently fetch the previous outputs and
  that would be too expensive to add.

* Standardness rules for the whole transaction are moved to the
  mempool-acceptance logic instead. The cost would be too great
  otherwise, similar to the previous point.
  Again, the effect is the same as likely intented.

---
1) since the intro of the CachingTransactionSignatureChecker
2020-04-13 15:57:42 +02: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 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 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 e6df5a8e06 Fix running API test in a dev-test-build
This initializes the hubs random when built using unsafe crypto.
Typically only used when the dev wants to run it in tools like valgrind.
2019-10-20 19:17:18 +02:00
TomZ 0cac942685 Replace boost::bind with std::bind
This is done almost everywhere, I skipped the boost signals since thats
only really used in the GUI part which is just there to do testing.
2019-10-10 16:18:53 +02:00
TomZ 19bbfe4ce0 Add the concept of DoubleSpendProofs
The DSP is owned by the DoubleSpendProofStorage, which in turn
is owned by the mempool.
Each mempool-entry can refer to one proof.
2019-09-02 23:33:12 +02:00
TomZ df7de2ecd2 Clean up the hairy ball of util.cpp
Move some globals and all stuff pulling in crypto to the
server/serverutil.cpp file

Remove dead code.

Move several items that were used in only one place to the respective
files using them.

Move the class WaitUntilFinishedHelper into its own file.

Made sure no header includes utils.h
remove a handfull of files including utils.h for nothing.
2019-08-24 22:25:09 +02:00
TomZ 60195ba472 Change defaults, stop enabling xthin by default. 2019-08-12 11:08:48 +02:00
TomZ 0aff6f6eef Beautify the initial log-line. 2019-08-05 23:00:53 +02:00
TomZ 1aacb3ae52 Vastly simplify mempool-acceptance
This removes the attempt at magic (predicting future) component
called the fee-estimator.
The direct effect is that all transactions have as a mempool acceptance
the same minimum fee. Regardless of how full the mempool or blocks were.

This mempool-acceptance minimum fee is 0 sat/byte. (aka free)

Notice the node-wide free-tx accept-limiter is going to avoid us getting
overloaded.
2019-06-28 14:02:11 +02:00
TomZ 39428f1271 Cleanup the logging at shutdown.
The RPC / HTTP servers were logging about being shutdown even if
they never were started in the first place. This confused people.
Also removed some empty methods.
2019-06-24 21:18:01 +02:00
TomZ 499db27a61 Fix parameter interaction blockmaxsize->maxmempool 2019-06-16 23:04:15 +02:00
TomZ a7f9b9fed5 Remove obsolete code.
Remove txIndex option, its move to Flowee Indexer

Also remove the GUI option for setting the amount
of "script validator threads". :D

Remove DBCash command line option too, equally obsolete.
2019-04-22 21:16:10 +02:00
TomZ d20dd6d70a Cleanup; block-pruning
This has been commented out code for some time and its probably best to
remove dead code so as to avoid it rotting.
2019-04-22 20:33:49 +02:00
TomZ f78ff55e8d Parameter interaction; blocksize -> mempool
Can't make a big block if we limit the mempool size.
Experience shows we need 4 X the mempool size vs blocksize.
2019-03-24 21:21:32 +01:00
TomZ e535d39ced Account for rounding errors. 2019-03-21 21:44:14 +01:00
TomZ 05a5af0d34 add parameter interaction max/accept blocksize 2019-03-21 18:43:00 +01:00
TomZ 557c2000f2 Move CKey to live in utils as well 2019-03-13 22:43:25 +01:00
TomZ 7b185570e5 Various cleanups and fixes 2019-02-25 21:35:05 +01:00
TomZ 65fbe65196 Cleanup unused code 2019-02-25 18:41:35 +01:00
TomZ bd9d735a66 Also print the path to the used logs.conf 2019-02-03 19:49:39 +01:00
TomZ 135bbb9a5f Cleanup BOOST_FOREACH -> for(:) 2018-12-30 15:33:11 +01:00
TomZ 4623a07968 Remove some usages of the multi-chain feature
During the BCH fork-off time we allowed the client to be started
as either BCH or BTC and as such there are several code-paths
that behave different based on this user setting.
We remove those as we no longer allow starting as BTC client.

This also removes the check for the min-block-size (rollback protection)
as this is accomplished by the checkpoints on the BCH chain.
2018-12-30 13:33:25 +01:00
TomZ b256676044 Rename debug.log -> hub.log 2018-11-21 12:18:32 +01:00
TomZ d55c7bfed8 Make UTXO write timebased as well
The current system writes based on the amount of changes, which is a bit
risky as long as we have small blocks as the amount of changes may for
hours be below the "lets write" limit.

So also write every 5 minutes, just to make sure we won't keep data in
memory longer than needed. Also this allows pruning to happen for people
that don't run their node all the time.
2018-11-11 16:47:54 +01:00
TomZ fdd693541e Make the UTXO have some limits "configurable"
This change makes the limits be static variables, which means they are
only settable once for a process. The only usecase so far is to use much
smaller limits in testing situations.
2018-10-21 13:21:24 +02:00
TomZ 627a0758a4 fix reindex-required detection 2018-10-11 16:26:47 +02:00
TomZ a22cae12ae Make having open mapped files more smart.
Instead of having a magic 10 open files, we now have a scheduled
run that closes all mapped files 30 seconds after last usage.
This allows many files to be opened with extremely low overhead and
cost (they are not actually loaded until needed, and even then only
per 4K page).
2018-09-25 18:22:57 +02:00
TomZ 9aec9e5eeb Merge branch 'master' into UnspentOutputDB 2018-09-24 21:25:34 +02:00
TomZ 343b0345eb Remove dead code 2018-09-24 21:23:27 +02:00
TomZ 39154aa625 Make startup/shutdown a bit more logical
Actually delete the asio io_service when we are done with it since that
will delete any left over tasks in the queue.
This makes deletion order more predictable.
2018-09-24 21:23:27 +02:00
TomZ d062dbca39 remove dead code 2018-08-17 23:22:13 +02:00
TomZ 82a670787e Merge branch 'master' into UnspentOutputDB
Conflicts:
	testing/prevector/test_prevector.cpp
	testing/test/test_bitcoin.cpp
	testing/utxo/test_utxo.cpp
2018-08-15 20:30:45 +02:00
Tom Zander 69e7cd89f8 Merge branch 'master' into 'master'
Add CuckooCache

See merge request FloweeTheHub/thehub!6
2018-08-15 18:22:22 +00:00
DesWurstes fffc707c74 Remove unneeded void
https://github.com/bitcoin/bitcoin/pull/13774/files
2018-08-10 19:16:35 +03:00
DesWurstes f61e8f698e Add CuckooCache
100% of code from https://github.com/bitcoin/bitcoin/pull/8895/commits/c9e69fb
2018-08-10 11:05:22 +03:00
TomZ 8cca04ff1d Fix oops 2018-08-06 12:00:14 +02:00
TomZ 7e954a7f8c Let people know they need to reindex 2018-08-04 18:30:24 +02:00
TomZ 1600086ede Updates to and start using the UnspentOutputDB
The new UnspentOutputDatabase classes are only very loosly a database, we
purely register and store unspent outputs there. But unline a DB we don't
allow modification (just insert and delete).

This replaces the coin-db (which was based on leveldb) and as first goal
this gives us a higher level of stability. The level-database was known
to give corruption issues.

Notice that users will need to do a manual reindex on first update.
2018-07-23 19:49:32 +02:00
TomZ e7659c2bc4 Rename shutdown-process name to be the hub 2018-07-22 22:20:40 +02:00
TomZ 95ea594bf2 fix typo 2018-04-11 12:19:08 +02:00
TomZ 9514b6f741 Improve logging, use proper loglevels. 2018-03-21 17:56:50 +01:00
TomZ 22b91334b5 Several logging improvements;
* logs.conf now also found directly in the homedir if there is no
$HOME/.config dir
* default filename is now 'hub.log' instead of 'debug.log'
* logs.conf now also detects ALL as a keyword for section
* logs.conf now also supports 'option path [path]'
2018-03-08 19:32:14 +01:00
TomZ 4bf1558f7a Smooth over config file issues.
So, now we install the example config file

Then we follow XDG for retrieving it.
We first check XDG_CONFIG (~/.config/flowee) and if we can't find a confg
file there fall back to the data dir (~/.local/share/flowee).
2018-03-07 23:20:04 +01:00
TomZ 33fe0fccb5 Cleanup ValidationInterface
Get rid of the weird boost signals setup
Move it to a new library 'interfaces' which is
for stuff that has no dependencies and can avoid
creating inter-library or cicular dependencies.
2018-02-16 12:37:13 +01:00
TomZ ace04a5070 Remove debug sections configuration via commandline. 2018-02-16 12:36:11 +01:00
TomZ 14bf96aa3c Start libs/server 2018-02-13 13:27:58 +01:00