Commit graph

62 commits

Author SHA1 Message Date
Calin Culianu
f63eea29f4
Added config options for workqueue and worker_threads
These control the number of jobs that may be enqueued before error, and
the number of concurrent threads to process jobs, respectively.

Also renamed 'misc' subdir to 'doc'

Also added some /stats: show all the configured global Options as they
came in from conf file/CLI. ("Config" subdict in /stats JSON).
2020-01-07 10:36:41 +02:00
Calin Culianu
1462717c85
Added max_buffer and max_history config variables, plus some DoS prot.
The DoS protection added is against unlikely and hard-to-pull-off memory
exhaustion attacks whereby clients fill our receive buffers with data
without sending newlines.  If we detect our receive buffer (default 4MB
buffer size) is starting to fill, we time clients out quickly if no
newline arrives within 5 seconds.
2020-01-06 12:32:16 +02:00
Calin Culianu
752818171e
Added per-IP connection limits plus various other nits and tweaks
Per-IP connection limit defaults to 12, but is configurable from the
config file.

Also added exlusion sets for subnets for this (and any future per-IP
limits).

By default localhost-originating connections are excluded.

Also in this commit:

- Replaced some usages of QMap with QHash for data items where order is
not important -- QHash is faster.
- Made the global 'id' type from IdMixin be IdMixin::Id (type alias for
quint4).  This way code using this data item is cleared/easier to read
and more explicit in what it's doing.
2020-01-06 01:26:50 +02:00
Calin Culianu
120f29b68b
Fixed some misplaced call args for callOnTimerSoon
Mistakenly passed a Qt::TimerType for the bool "force" arg.  Luckily
this didn't cause any problems with existing code.
2020-01-05 03:26:40 +02:00
Calin Culianu
4c3f6ca4a0
Properly implemented server.features, added hostname, public_*_port to config
Config variables added:

- hostname
- public_tcp_port
- public_ssl_port

These are used by server.features.  They will also go towards the peer
discovery/peering subsystem when that is implemented.
2020-01-04 22:32:05 +02:00
Calin Culianu
1da2834612 Config file: added support for banner and donation variables.
Banner still needs variable substitution.
2020-01-04 13:26:25 +02:00
Calin Culianu
94e90f25bb
Nits in App.cpp 2020-01-04 00:49:15 +02:00
Calin Culianu
b1c4e13914
Nit to message/warning when env var is ignored.
I didn't like the way the message looked.  Showing the long option in
the message is more informative.
2020-01-04 00:43:52 +02:00
Calin Culianu
bcf91fdd87
Added conf file supports multiple tcp, ssl, stats & debug options
This way the conf file is equivalent to the CLI. We use a multihash for
the name/value pairs. Go Qt with your useful containers.
2020-01-04 00:34:14 +02:00
Calin Culianu
adbf65eed3
Initial impl. of config file mechanism. Works!
Next up: Support multiple tcp, ssl, stats args in the conf file.
2020-01-03 23:28:57 +02:00
Calin Culianu
8209e5b1e5
Nit: Got rid of a dead @ifdef in App.cpp 2020-01-03 09:44:27 +02:00
Calin Culianu
151dc0910e
Fix compile error on Qt 5.12 2020-01-02 01:03:24 +02:00
Calin Culianu
e50c74f9a0
Fixed a typo in app help -h 2020-01-02 00:33:14 +02:00
Calin Culianu
dacc0ae6d2 Added Linux-specific time functions (CLOCK_MONOTONIC) to Util.cpp 2019-12-31 19:42:34 +02:00
Calin Culianu
4ae2b684ca Linux compile fixups and Qt 5.11 fixups 2019-12-31 19:29:48 +02:00
Calin Culianu
7b4514b412
Made poll interval be 2 seconds
Also got rid of some of the debug log spam for GetChainInfoTask and
SynchMempoolTask -- they only print stuff if new stuff is found.

misc other nits.
2019-12-29 00:45:09 +02:00
Calin Culianu
a831cce8ac
Modified license preamble to say "Bitcoin Cash" instead of "Electron Cash"
The hope is maybe people will adopt this with other wallets...
2019-12-28 23:48:24 +02:00
Calin Culianu
405335c173
Added LICENSE preamble to all top-level source files
GPL v3. YAY!
2019-12-28 23:46:05 +02:00
Calin Culianu
20da1f0c8b
Misc odds and ends
Added license to project, and other goodies. Added -T option for poll
timer. Misc other things added.
2019-12-28 23:26:16 +02:00
Calin Culianu
7f2581ba6a
Oops... arg parsing broke
Fixed.
2019-12-24 17:10:01 +02:00
Calin Culianu
090bd16ee7
Initial try at SSL support. Works.. mostly.
Not sure about the cert/key situation.  Seemed fragile on macos.
Hopefully windows works without too much library static linking
insanity.
2019-12-24 16:49:47 +02:00
Calin Culianu
e275767a7b
DB changes, phase 1. Added 'dirty' flag, added utxoct to meta table, ...
We skip the utxo count check at startup unless the new -C (--checkdb)
flag is set, in which case we do a very thorough check of all utxos and
the corresponding scripthash_unspent entries.

We set a dirty flag during block addition / removal and if it's set, we
abort the app immediately and ask the user to do a full resynch.

Since adding/removing blocks isn't 100% ACID, this is needed until we
figure out how to redo the data to make everything ACID.

Also in this commit -- attempted to see if I could make the header
reading faster from the db by using MultiGet.  It turns out it doesn't
help much.
2019-12-22 10:55:24 +02:00
Calin Culianu
15d53f1760
Added Util::ThreadPool::SubmitWork mechanism
This allows for an app-global threadpool to be used for work that may
take a little while to complete.  The intended code that will use this
is the rpc server which will submit work that takes some time to
complete to the ThreadPool, so that the server's thread doesn't block
for very long while servicing client requests.

This ensures that the server remains responsive even if 1 or 2 clients
are issuing costly requests.

We plan on using this for get_history, listunspent, and the
merkle-related functions, to name a few.
2019-12-21 13:24:53 +02:00
Calin Culianu
1c89f60e12
Got scripthash_unspent working .. but block synch is painfully slow
We deleted the non-working merge operator for scripthash_unspent.. and
we do a read-modify-write for each new utxo/spend per scripthash.

It's very slow though.

I may have to defer updating this table until the very end from the utxo
set or something.  This is unacceptably bad...
2019-12-13 00:14:09 +02:00
Calin Culianu
b799dfb2a8
Scripthash history fix. Oops!
we weren't adding the right txidx to the history.  Good thing I also
added debug code to this commit to check history.

Fixed!

Also various other nits and tweaks.  Added the /debug endpoint for
sending params for debugging to the server.
2019-12-12 12:15:06 +02:00
Calin Culianu
608ba22231
added stats for merge calls for debugging 2019-12-12 00:23:19 +02:00
Calin Culianu
bd583bf18b
added code to test concurrent read of recordfile on windows especially 2019-12-11 12:02:41 +02:00
Calin Culianu
01f1ebd62c
Got rid of in-memory utxo set.. will rely on db
RocksDB is super fast. Keeping it in memory was a waste of memory.  This
is much faster and reduced memory consumption significantly.

TODO: Maybe do the same thing for headers as well!

Also: We need to save txNum to DB. We're not saving it now resulting in
correctness errors on subsequent reloads of same db.
2019-12-09 12:10:59 +02:00
Calin Culianu
8b7753fbdf nit 2019-11-29 17:24:16 +02:00
Calin Culianu
c38b7cf5ea
Added --datadir (-D) command-line option
Also added optional RPCUSER and RPCPASSWORD env vars that replace -u and
-p options more securely.
2019-11-28 23:58:24 +02:00
Calin Culianu
b2354111a0
Added print of banner to log every hour 2019-11-27 19:11:57 +02:00
Calin Culianu
6df916565a
Made app only start listening for client connections after initial sync
Also in this commit various nits and subtle bugs prevented.

Refactored the 'Stats' mechanism to return a generic QVariant rather
than QVariantMap, which is more flexible.

Misc. other nits.
2019-11-27 14:07:09 +02:00
Calin Culianu
31a1ec73f8
moved call to register metatypes asap at App init 2019-11-18 15:10:42 +02:00
Calin Culianu
45e12158db
Added process function to controller, and hooks for bitcoind when ready
Also added the "Fatal" logging class which logs as Error but then
schedules an app exit when invoked.  Only to be used for truly terrible
errors.
2019-11-18 08:29:33 +02:00
Calin Culianu
c0ea7f75a0
Refactored things, added "Controller" class
Controller will manage BitcoinD and perhaps synching to bitcoind. It can
"see" all the servers as well as bitcoind.

Also refactored things a little bit and added some more startup sanity
checks.
2019-11-18 00:21:34 +02:00
Calin Culianu
5e9b659f81
some nits 2019-11-17 11:10:41 +02:00
Calin Culianu
04c4d5d5b7
Squashed commit of the following:
commit 326de9f8e9670ace95d6044e4f2d36a697a78ef9
Author: Calin Culianu <calin.culianu@gmail.com>
Date:   Wed Nov 13 11:27:23 2019 +0200

    fix apple compiler check

commit f794b3df1dda0c8b7df3c587688b8182a0de029d
Author: Calin Culianu <calin.culianu@gmail.com>
Date:   Wed Nov 13 11:12:01 2019 +0200

    added guard for msc_ver which doesn't support #warning

commit 04fbc36bbb40cbcc926e504f2109d766d2335113
Author: Calin Culianu <calin.culianu@gmail.com>
Date:   Wed Nov 13 11:06:12 2019 +0200

    Fix for win32-g++ compilation

commit a79b38b13da03ae741d81ca5a1a7978f9c09d961
Author: Calin Culianu <calin.culianu@gmail.com>
Date:   Wed Nov 13 10:49:33 2019 +0200

    Beat project into sunmission to compile on Linux using clang
2019-11-13 11:32:52 +02:00
Calin Culianu
a34585da1b
Added BitcoinD classes.. lord help me.
Also "upgraded" the universal ID we use for all objects to use quint64
(unsigned) rather than signed, and the "NO_ID" is 0.
2019-11-12 22:14:04 +02:00
Calin Culianu
0d0f41c2f5
Changed the way timestamps are printed in the log 2019-11-11 11:55:10 +02:00
Calin Culianu
b2b2509f25
Got HttpConnection working and talking to bitcoind
It works!  I still haven't figured out how to provoke the dreaded
"Workdepth exceeded" error .. but we pretty much drop the connection
anyway on anything too unexpected from bitcoind.

When the bitcoind manager class is written it will back off and try
again if too many disconnects happen.

For now though, the code we have is fast and works well against
bitcoind.
2019-11-11 00:22:31 +02:00
Calin Culianu
45daaf6e91
some nits 2019-11-09 21:14:07 +02:00
Calin Culianu
cd643e7323
Made Message::Id type a std::variant
I restricted the possible underlying types it can contain down to
qint64, QString, and nullptr_t. This should make it more type safe since
we don't want it to inadvertently end up holding lists or maps
(previously it was a straight up QVariant).

It has a conversion to QVariant so it should work nicely.
2019-11-09 01:55:48 +02:00
Calin Culianu
724d7d3366
Refactorings 2019-11-08 17:11:58 +02:00
Calin Culianu
8898e5c9ba
Fixed /stats endpoint 2019-11-08 03:15:47 +02:00
Calin Culianu
43b7e915c4
Got rid of more ShuffleUp stuff, added CLI args 2019-11-07 23:55:13 +02:00
Calin Culianu
b22f81a463
Minor removal of old references to ShuffleUp 2019-11-04 00:41:47 +02:00
Calin Culianu
01d8d01ccd Added stats HTTP server. Also refactored TcpServer 2019-05-09 02:12:58 +03:00
Calin Culianu
31b891c006 hooked controller object in to app startup 2019-05-04 06:00:01 +03:00
Calin Culianu
113efda25a Added spec rpc command from clients to us.. still need to do listunspent 2019-05-03 17:28:51 +03:00
Calin Culianu
b84bcbd8b5 Added Linux compile fixups. Also a check that the endianness in bitcoin:: is ok. 2019-05-01 18:19:17 +03:00