Commit graph

73 commits

Author SHA1 Message Date
Calin Culianu
409feb1994
Ok, fixed the utxoset bug
Turns out our custom HashX class was doing some funny things when a
HashX had a \0 byte.  Likely QByteArray isn't really intended to be
inherited from.  Rather than investigate what was going on -- I just
decided it's sufficient to do: using HashX = QByteArray and be done with
it.

Now our utxo set is working correctly.

We still need to figure out how to store everything.. but this is
progress.
2019-12-05 12:07:27 +02:00
Calin Culianu
bf5eebaa65 wip -- it's kinda broken still.. :( 2019-12-04 23:53:45 +02:00
Calin Culianu
7f6d025be2 nit: made GetBlockHeaderSize() return int because that's more useful to us 2019-12-03 21:53:32 +02:00
Calin Culianu
b0f1876fde
nits to pct display 2019-12-03 06:52:38 +02:00
Calin Culianu
dfaa36cc13
DB format change: added SerializeScalar/DeserializeScalar
This is to support writing raw ints directly to db keys / db values as a
space saving measure.  QDataStream, while platform neutral, adds its own
marker/size bytes to the serialization which we do not need always.

Our DB format is now endian and architecture-specific, but that's ok.
Users can resynch if they switch machine architectures.
2019-12-03 06:38:19 +02:00
Calin Culianu
b1ff399790
tweaks headers renamed to blocks in mesaging 2019-12-02 16:27:42 +02:00
Calin Culianu
6acf393de9
tweaks and hopefully fixups 2019-12-02 16:21:22 +02:00
Calin Culianu
e82d98d68a tweaks to stop event spam, modified download progress pct to be progress of total blockchain 2019-12-02 14:11:02 +02:00
Calin Culianu
0556caf0f4 wip -- mostly works. task end has some spurious events that need removing but works well 2019-12-02 13:50:18 +02:00
Calin Culianu
26fda19b8d
Got rid of the download task retry mechanism. Hopefully we won't need it
We plan on synching in real time as the download proceeds.. so it won't
be needed.  It also simplified the code significantly to remove it.
2019-12-02 11:46:34 +02:00
Calin Culianu
4f1470fc99 wip 2019-12-02 11:42:10 +02:00
Calin Culianu
4a68eaaeaa
nit 2019-12-02 10:00:22 +02:00
Calin Culianu
7c63bba5d0 nits 2019-12-02 09:43:03 +02:00
Calin Culianu
76d0505323
Nits, refactorings, and tweaks
Cleaned up the code for BlockProc and created the HashX class

Plus made some of the PreProcessedBlock fields be more type-safe (using
std::optional)
2019-12-02 01:29:24 +02:00
Calin Culianu
e9d3991ded
WIP - added PreProcessedBlock
The PreProcessedBlock is intended to be a somewhat munged/mogrified form
of a CBlock which is somewhat ready for a db insert.

This data will get passed onto the Controller thread which will set
everything up to commit the SH history, header, etc to the db.

Did some initial testing and it's pretty fast and also.. I think it's
correct (as in I'm collating the data correctly).

TODO: Some more testing.
2019-12-01 22:36:19 +02:00
Calin Culianu
16a2e195c4
Nits/refactoring for the BTC::Deserialize* functions
I made them all less boilerplatey and use templates.  yay!
2019-12-01 15:22:12 +02:00
Calin Culianu
4c8f5d0f9b tweaks 2019-12-01 01:10:54 +02:00
Calin Culianu
06ab90b157 nits 2019-12-01 00:50:42 +02:00
Calin Culianu
a8e6703c38 tweaks 2019-12-01 00:43:03 +02:00
Calin Culianu
06cbe1321b tweaks / wip 2019-12-01 00:20:15 +02:00
Calin Culianu
c3091c0d99 tweaks 2019-11-30 23:33:30 +02:00
Calin Culianu
cbaea7a276 went back to getblockheader header dl for testing 2019-11-30 22:18:12 +02:00
Calin Culianu
5c9ecd9c08 Implemented different parallelism: stride style breakup of the download space between tasks 2019-11-30 22:07:35 +02:00
Calin Culianu
bea420355b wip 2019-11-30 12:29:32 +02:00
Calin Culianu
a7293a9939
Potential bug fixed: Added protection from connecting to wrong bitcoind
We now save the "chain" variable to the meta table.  We also panic if
the headers we are reading from bitcoind are behind what we have (todo:
handle this elegantly if there actually was a reorg?)
2019-11-30 01:33:27 +02:00
Calin Culianu
5842c44a79
Nits, refactorings + added shared HeaderVerifier that lives in Storage 2019-11-30 00:42:33 +02:00
Calin Culianu
46b670d813 storage wip 2019-11-29 14:42:17 +02:00
Calin Culianu
e9d432f5e7
C++ template magic - newTask factory function
Templates are fun.  Decided to reduce boilerplate by making task
creation inside the Controller class be done by a template member
function which acts like a task factory.  It surrounds the construction
of the task with some boilerplate (namely, inserting the task in the
tasks map, connecting an optional errored signal, and starting the
task).
2019-11-27 20:32:50 +02:00
Calin Culianu
c499e1a1b3
Made the "upToDate" slot that creates srvmgr fire only once
Via shared_ptr tricks, it only fires once in the interests of
efficiency. After the server is created the connection is disconnected.
2019-11-27 14:46:17 +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
0bf3d4e2ae
refactor ChainInfo into its own struct 2019-11-27 12:12:16 +02:00
Calin Culianu
bb1d371d2e
Use getblockchaininfo rather than getblockcount, and more
We now query more information initially when synching, which can be
useful.

We also deal with initial block download by retrying every minute

and other miscellany
2019-11-27 12:03:12 +02:00
Calin Culianu
1743a4728e
Some nits. Use of an unordered_map and static_assert, simplified map.emplace, show hdr dl pct 2019-11-27 02:38:39 +02:00
Calin Culianu
cc8ce73c5a
Made bitcoind communication more efficient by use of ParseHexFast
When reading data from bitcoind, we can assume the hex data it gives us
is good and there is no need to validate on a per-character basis.

Thus, we use ParseHexFast to shave off cpu cycles (it's like 6x faster
than Qt's fromHex()).

This, along with the Util::ToHexFast() (which is 60% faster than
QByteArray::toHex()), will be used in performance critical code.
2019-11-26 22:04:45 +02:00
Calin Culianu
d9f335f1d4
memory/vector usage nits 2019-11-26 12:29:27 +02:00
Calin Culianu
9f2ba890f4
Tuned concurrency even better -- got performane to beat old scheme!
Also in this commit: small nits
2019-11-26 00:18:28 +02:00
Calin Culianu
b41957b811
improved parallelism / bitcoind utilization 2019-11-25 23:34:04 +02:00
Calin Culianu
e6642fa87a
nits 2019-11-25 22:56:46 +02:00
Calin Culianu
0eb50606b9
Added "CtlTask" mechanism to Controller class, plus nits & refactoring
This is more complex than what we had before -- but is more concurrent
and is more production-ready -- it can deal with failures better and now
we also poll bitcoind for new headers.

Still probably can be optimized somehwat -- but getting there!
2019-11-25 22:34:11 +02:00
Calin Culianu
a34681aa31
Added header download to our test code
It's pretty fast. Downloads all headers in 120 seconds or so.  Keeps
them all in memory.
2019-11-24 22:28:26 +02:00
Calin Culianu
b8a507615d
nit 2019-11-24 18:51:22 +02:00
Calin Culianu
7fa213e095
Added "bitcoind is warming up..." messaging
Just a small nit, really.
2019-11-24 18:23:34 +02:00
Calin Culianu
b823f97397
nits 2019-11-19 12:33:50 +02:00
Calin Culianu
abc1aaabd0
tweaks to header dl test code 2019-11-19 10:59:53 +02:00
Calin Culianu
d7e0ba16db
fixup for error parsing integer id: 1000000.. oops. 2019-11-19 10:44:51 +02:00
Calin Culianu
4b59e2233a Increased parallelism for the header sync
Set maxcur to 16, spinning up 3 bitcoind threads.

Seems to have brought header synch down from 170s to 71s on my mainnet
node here locally. Not bad!

Also fixed a bug where selecting bitcoind nodes was failing if >2 nodes.
2019-11-19 01:58:30 +02:00
Calin Culianu
819fa47990 wip 2019-11-18 21:22:30 +02:00
Calin Culianu
9213459817 wip 2019-11-18 21:09:21 +02:00
Calin Culianu
f64def2005
wip 2019-11-18 20:56:12 +02:00
Calin Culianu
0466fcf501
wip 2019-11-18 20:48:22 +02:00