Commit graph

1510 commits

Author SHA1 Message Date
Calin Culianu
c3711aafe6
Bump version to 1.11.0
Since we are upgrading so many packages in particular rocksdb, which
introduces non-forward compatibility between earlier Fulcrum and latest,
we bump the minor version to mark the change.
2024-05-23 10:20:07 +03:00
Calin Culianu
b160e5fc01
Windows static build: Bump to latest MXE commit, use gcc 13
This means that all of our builds now use gcc 13 which also means we can
use the latest C++20 features unimpeded in Fulcrum, should we choose to.
2024-05-23 10:18:49 +03:00
Calin Culianu
5b43044059 Linux static build: Force use of gcc-13 in docker images
- We install GCC 13.1 from a ppa in all of the docker containers, and use it
- We compile now with -static-libstdc++ to preserve compatibility with
  stock systems.

However, on GCC 13.1 we got some compile warnings & errors so we:

- Updated libzmq to 4.3.5 (and cppzmq to 4.10.0)
- Updated jemalloc to 5.3.0

We also removed support for the linux_ub16 build (since there are no
sufficiently new C++20 capable compilers available for this Ubuntu
version).
2024-05-23 00:04:24 +03:00
Calin Culianu
0618090ec2 Got rid of remaining c++1z from Fulcrum.pro
Oops. Missed a spot.
2024-05-23 00:04:24 +03:00
Calin Culianu
1cf84ff485 Windows: Bumped docker image to Ubuntu 20; mxe GCC to 12.2
For some reason, using gcc 11.2 with rocksdb 9.1.1 for the Windows
build led to a segfault in rocksdb. But bumping to use GCC 12.2
on Windows is ok.

So we updated the mxe commit hash to something newer whereby GCC 12.2
is included. This required a newer host system (Ubuntu 20), however.

Now, the windows build is ok again and works with rocksdb 9.1.1.
2024-05-23 00:04:24 +03:00
Calin Culianu
18359e695e Updated rocksdb to 9.1.1 + updated librocksdb binaries
This is because rocksdb 6.x didn't work ok with C++20
2024-05-23 00:04:23 +03:00
Calin Culianu
e4438c4616 More fixups for C++20
- "c++2a" for Qt 5
- Restrict Fulcrum to Qt 5.15.2 or above
- Fixups to sources to compile ok against C++20
2024-05-23 00:04:23 +03:00
Calin Culianu
e46b0d3468 Bumped Fulcrum.pro to use C++20, still many fixes to be had
- leveldb broke
- various warnings from simdjson
- other source files fail to compile.

Fixes to come...
2024-05-23 00:04:23 +03:00
Calin Culianu
f4e8e9ab4b
Fixed a typo in contrib/build/build.sh
linux_ub20 works with arm64. ub22 is overkill.
2024-05-23 00:03:41 +03:00
Calin Culianu
03bf359a78
Fixed compile warning in simdjson.h when compiling in C++20 mode
This backports https://github.com/simdjson/simdjson/pull/1787 to fix
some compiler warnings related to ambiguous operator== due to changes in
C++20.
2024-05-22 12:56:03 +03:00
Calin Culianu
c6084f0df4
Follow-up nit: Use 1u, not 1
Just to ensure everything remains unsigned.
2024-05-21 23:48:16 +03:00
Calin Culianu
ff985dae77
Fixed assert() in Controller.cpp
As part of the RPA work, this assertion's assumptions changed. Wasn't
detected since I haven't been compiling in Debug mode.

Oops!

Assertion updated to reflect new code.
2024-05-21 23:41:27 +03:00
Calin Culianu
8d1b397ca8
Update Copyright year for all source files 2024-05-21 01:35:13 +03:00
Calin Culianu
7cea2e333c
Fix for compiling against Qt 6.7.1
Qt is now enforcing that QObject::findChild() must match children that
have the Q_OBJECT macro. So we did a little reshuffling of the
Client::PerIPDataHolder_Temp class to move it to namespace scope, so
that we could add the Q_OBJECT macro to this class.
2024-05-21 01:26:46 +03:00
Calin Culianu
9e70052eac
Merge pull request #247 from The00Dustin/typos
Correct typos in example configurations
2024-05-08 08:04:22 +03:00
The00Dustin
3e9ebd30c4
Correct fulcrum-quick-config.conf typos 2024-05-07 09:54:11 -04:00
The00Dustin
20b8ef2c2f
Correct fulcrum-example-config.conf typos 2024-05-07 09:52:59 -04:00
Calin Culianu
41c54c95d6
Updated art/ submodule 2024-05-04 11:40:20 +03:00
Calin Culianu
2b7bc10ef8
Updated contrib/art submodule pointer to lastest. 2024-05-04 11:28:29 +03:00
Calin Culianu
38dc824954
Updated README.md to use better art/graphics/icon for the app.
Also added sumbodule in contrib/ that points to Fulcrum-art repo.
2024-05-04 11:08:00 +03:00
Calin Culianu
6dc265af7a
Util.cpp, make RenderHostPortPair check for ret.isEmpty()
Rather than .isNull(), which may be false even for an empty string.
A string may be empty but not null. :/
2024-05-03 06:28:04 +03:00
Calin Culianu
654e101314
Fix a missing header warning 2024-04-25 18:01:51 +03:00
Calin Culianu
10a3ac237c
Update electrum-cash-protocol module pointer
- Fixed doc bug for blockchain.address.get_first_use
2024-04-20 23:19:30 +03:00
Calin Culianu
3d16caaeec
IPv6: Render "ip6:port" as "[ip6]:port". Also accept this notation from conf file.
This closes #242.

Summary of changes:

- Fulcrum will optionally also be able to parse IPv6 addr:port strings
  from the conf file: "[2001:44b8:315f:bc00:1f7b:dcc3:8823:722d]:60000".
  Note that bracket-less strings e.g. "2001:44b8:315f:bc00:1f7b:dcc3:8823:722d:60000"
  will also continue to work (to preserve backward compat.).
- `FulcrumAdmin clients` (aka `FulcrumAdmin sessions`) will now render
  client host:port pairs in the table with brackets for IPv6.
- /stats HTTP endpoint will also render client IPs in this way for IPv6.
2024-04-17 17:55:23 +03:00
Calin Culianu
171cbee0d5
Small nits to the unit test code for generating random bytes 2024-04-05 19:34:11 +03:00
Calin Culianu
a2592bc041
Tests: Rename BOOST_* macros to TEST_*
Even though they are BOOST-workalikes, we rename them to TEST_ so that
anybody reading this code doesn't mistakenly think we use Boost for unit
tests.
2024-04-05 18:59:48 +03:00
Calin Culianu
66e91bc884
Fixup to tests/Tests.h TEST_SUITE_END macro
No need to pass the name now, making the usage of this jerry-rigger
system match BOOST more closely.
2024-04-05 13:36:11 +03:00
Calin Culianu
ed2d69bbb0
Nits for ByteView 2024-04-05 12:55:07 +03:00
Calin Culianu
c08209490d
Refactor ByteView class & refactor bitcoin tests
ByteView class was inheriting from std::string_view which can cause
problems since its char_type is std::byte (which is not officially
standards-compliant to do). This fixes compile warnings on clang-18.

Also, in this commit we refactor the bitcoin tests and create a
subdirectory called tests/ which has a header "Tests.h" which allows us
to do BCHN-like BOOST_CHECK() and other macros... it emulates the BOOST
test framework, essentially, in a hacky but working way.
2024-04-05 12:38:48 +03:00
Calin Culianu
a158848259
Update README.md, add website link
Added link to the Awesome Website™️
2024-03-29 16:08:21 +02:00
Calin Culianu
57d2d7b37b
Some miscellanous small nits and tweaks
No app behavioral change. Just nits.
2024-03-26 11:05:10 +02:00
Calin Culianu
220c749c58
RPC: Support downloading >1GiB blocks from bitcoind
Requires Qt6 to actually work, but we now can download content-length
larger than 2GiB if on Qt6, since we no longer use "int" for the
content-length on Qt6 (since Qt6 QByteArray uses qsizetype now for
length).

Also in this commit: some C++ voodoo to make
HttpConnection::StateMachine "clear" without creating a temporary.
2024-03-25 23:52:23 +02:00
Calin Culianu
a2ae1c093f
Fixed a typo in fulcrum-example-config.conf 2024-03-05 12:14:51 +02:00
Calin Culianu
66b54923a7
Updated copyright year on 2 files and also unix-man-page.md 2024-03-04 11:51:09 +02:00
Calin Culianu
4aa8f841b2
Add RPA Support (#234)
* Start adding RPA files.
* Update Servers.h -- add batchid for rpc methods
* Update Servers.cpp -- add batchId to RPA methods
* Update Servers.cpp - add batchId params to generic async
* Add key 'rpa' to features map to quell client-side warnings
* Code quality fixups and make it compile on latest clang

It wasn't compiling at all on latest clang. Also in this commit some
code quality fixups and nits, and avoid some double-copies.

Also added additional unit testing of prefixSearch & remove functionality.

* fix bug

* add some sloppy testing code for debug of client

Also in this commit: Add files missed by previous merge

* Optimize ReusableBlock::serializeInput to be faster

This should help reduce CPU usage on initial synch and in general.

We added a facility to hash bitcoin objects "in-place", rather than what
we were doing before which was serializing them then hashing the
serialized bytes.

* Refactor

- Move the serialization stuff into the .cpp file to avoid header noise
  and speed up compilation.
- Add the trie map thingie into the headers for Fulcrum.pro
- Misc. other small nits

* Added utility class PackedNumView

We will need this later for our new rpa data storage technique.

* Added the `Rpa` module

This will replace the facilities in `ReusableBlock.cpp` & `.h`.

Also ported over the unit tests from `ReusableBlock` to this `Rpa`
module.

* Tweak to support PackedNumView of 32-bits

* Made Rpa::PrefixTable support a read-only "view" into serialized data

We will need this in order to quickly be able to read from the DB
without too much allocation or other processing to service requests.

Also in this commit:

- Updated unit tests
- Modified GenericVectorReader: added GetPos() and seek() methods

* Rpa::PrefixTable ser/deser error path tweak

Improved exeption messages and added paranoia check(s)

* Some tweaks and additional in-code comments

Small refactoring tweaks to the Rpa namespace classes and some small
amounts of comments added to document the intention behind the code better.

* Small perf. tweak for BTC::Hash2ByteArrayRev

And also added some unit tests for various functions we touched/added
recently.

Also a small nit/refactor in Rpa.h

* Removed Jt's Trie-based implementation, swapped in my own

Also added some tests and other refactorings.

Still TODO:

- Mempool handling
- Options handling to enable/disable this index
- Finish TODOs in comments
- Lots of other stuff like maybe an asynch indexing of RPA in the
  background for servers that are already "up"

* Made Rpa logging less verbose by default

* Allocate DB memory property for RPA (don't exceed db_mem)

Also in this commit, some nits.

TODO: If RPA index is disabled, give the memory back to scripthash_unspent and
utxoset (which is where we took it from).

* Fixed hex parsing bug for blockchain.reusable.* RPCs

Turns out our Prefix(uint16, uint8_t) c'tor was buggy due to misplaced
parens, so RPC was broken. Fixed.

Also added unit tests to test this case as well as others.

Also added some perf logging for dev (to be removed later) to the guts
function that does the work for blockchain.reusable.get_history.

* Nit

* Tweaks to unit tests

* Added better profile printing for debug, plus 1 nit

* Fixed arg parsing for blockchain.reusable.get_history

* Added come conf file args for RPA, renamed RPC methods, raised min prefix to 8 bits

Conf file args to control various RPA aspects (min prefix, max history,
etc) were added.

Also, renamed blockchain.reusable.* -> blockchain.rpa.*. The old
blockchain.reusable names are still supported but are deprecated.

We raised the min prefix to 8 bits because 4 is too small and leads to
heavy-ish server load on some queries.

We also set the number of blocks one can scan with
blockchain.rpa.get_history to a limit of 60 by default (configurable),
to make for small and light queries to the server.

* Removed unused #include

* Added MempoolPrefixTable

Will be used by the mempool. Still needs tests.

* Simplified MempoolPrefixTable (it doesn't need 2 associative containers)

* Hooked RPA into Mempool; works.

Also added "tests" in the mempool bench to use it.

* Added some more MempoolPrefixTable unit tests

* Added more logic to Storage and Controller to handle RPA

- added an "auto" mode that is auto-on for BCH, off for every other coin
- user can override this auto mode (which is the default) with a cli or
  conf file arg
- misc nits and fixups

Still more to do in this regard.

* Added rpa_start_height conf option

Suppress indexing until this height. Defaults to -1 which means
"Automatic" and is height 825,000 for mainnet, 0 for all other nets.

* Tweaks to RPA max history code

- Re-use the history-too-large lambda mechanism we use in getHistory()
- Have rpa_max_history inherit max_history if max_history was specified
  and rpa_max_history was not (since this is what users might expect).

* Refactor and fixups to getRpaHistory()

Made the RPC to blockchain.rpa.get_history take params in the same
from,to way as blockchain.scripthash.get_history.
blockchain.reusable.get_history still works like the old way.

Neither of them return mempool (unlike *.scripthash.get_history).

Also switched the getRpaHistory() function to use a rocksdb iterator to
scan records in sequence, since this should in theory be faster than
individual O(log N) db gets.

Also other minor fixes.

* Tweak to getRpaHistory()

Just forward the iterator 1 item at a time since it should be faster.
Also refine the logic to not append mempool unconditionally if we didn't
hit tipHeight in the confirmed scan (branch not currently used).

* Optimized PackedNumView deserialization

Use built-in byteswap functions rather than looping and doing it
ourselves. Should be faster.

* Optimized PackedNumView::Make

Leverage byteswap calls that are possibly-no-ops is host and destination
byte order match, and even if they don't, should be faster anyway than
our hand-crafted loops that achieve same.

* Added some Rpa stats tracking in Storage.cpp

And also loading the DB now does faster checks.

Still todo: use firstHeight and lastHeight from DB to decide if/how to
(re)synch the index on app startup.

* Fleshed out the initial check of the RPA db more, still more to do.

We need to now have a way to synch the index separately in Controller..
and handle all corner cases that may arise.

* Fixes and nits, mainly in loadCheckRpaDB

* Small nits and header cleanup

* Added method getRpaDBHeightRange to Storage

May be useful later for the Controller.

* wip

* Refactored code that puts RPA data into DB into a function

It's now in Storage::addRpaDataForHeight_nolock, since it does some
defensive sanity checking.

* Added 2 fields to RpaOnlyModeData

* Got RPA index sync independent of block sync working

It needs work in recovering from DL failure and other corner cases but
it basically works.

* Solved the last of the consistency corner cases on RPA index synch

I'm pretty sure we are solid now and the RPA index eventally synchs
separate of the general block download on config change. Meaning users
get a decent experience with the index if they play with enabled/disabled
toggling.

* Bumped version to 1.10.0

This is due to the addition of the RPA index facility.
Also bumped protocol version to 1.5.3 due to addition of new RPA
RPCs.

* Fixed percent display for RPA Index synch

It really should be a percentage of the current download progress and
not a full blockchain percentage as the normal blocks synch is.

Fixed.

* Corrected a debug string message

* Took the bitcoin byte swap functions out of the `bitcoin` namespace

This is because on some platforms they are actually #defines to some
global thing, so eg `bitcoin::htole16` was failing to compile on such
platforms.

* Fixed some compile issue on Ubuntu 22

GCC-11 + Qt5 didn't like some of the stuff we did in recent commits.
Fixed.

* Fixed a failing test: `rpcmsgid` for Linux

* Follow-up

* Disabled the rpa subscribe/unsubscribe RPC methods (for now)

They are unimplemented anyway and no clients use them (for now).

* 2 nits

* Fixed a potential bug

* Renamed a /debug endpoint key

* Some rename rpa_history_blocks_limit -> rpa_history_blocks

And also some other minor tweaks. Mostly a renaming/nit commit.

* A small refactoring of some boilerplate

* Added docs for RPA options to example conf file in docs/ dir.

* Made the rpa.get_history call use [from, to) (exclusive) range

This is more akin to how existing calls operate.

Also updated the electrum-cash-protocol submodule pointer to latest.

* Updated electrum-cash-protocol submodule pointer

* Update to electurm-cash-protocol module copyright

* Got rid of some dead code and updated some comments

* Corrected a comment

---------

Co-authored-by: = <=jonaldfyookball@outlook.com>
Co-authored-by: fyookball <jonaldfyookball@outlook.com>
Co-authored-by: blockparty <hello@blockparty.sh>
2024-03-04 02:16:27 +02:00
Calin Culianu
17dca71ea6
Fixed very rare bug where BitcoinD instances may become unresponsive
The symptom is one of the 3 BitcoinD instances in the app would stop
working and continually attempt to reconnect to the remote bitcoind
daemon, never quite succeeding and never receiving a ping reply.

The way it could be triggered is if the remote daemon drops conn on us
at an inopportune time while we are reading content from its HTTP
response. The internal StateMachine used by this class would end up in a
confused state.

The fix is to implement `on_disconnected` in the HttpConnection class and
be sure to reset the StateMachine for this instance on a connection
drop. This fixes the bug nicely.

The bug was extremely rare but not impossible.
2024-03-02 01:59:51 +02:00
Calin Culianu
d4b3fa1865
Bumped version to 1.9.8
In preparation for release.
2024-01-13 07:26:15 +02:00
Calin Culianu
b5c608e9e0
Fix to use vsize for mempool fee histogram (#225)
* base fix
* Refactored. Also fixed bug where vsize was 4x
* more refactoring
* Added some Txn ser/deser testing
* Improved the frequency of mempool fee histogram updates
  - We now update the mempool fee histogram every 10 seconds, instead of
    every 30
 - Whenever we get a new block, we update it immediately upon the first
    mempool synch after the block arrives

  This should improve the txn estimates in Electrum for BTC users.

* Dont print Storage::refreshMempoolHistogram elapsed time unless >= 10msec

Also do the printing with no locks held, and destruct the swapped-in
hist vec with no locks held.

* Tweak to mempool bench to populate vsize correctly
* Nit
2024-01-07 16:09:41 +02:00
Calin Culianu
b3f090dc9b
Update doc/electrum-cash-protocol module pointer 2024-01-06 09:44:08 +02:00
Calin Culianu
6d4026a4e5
Fix compiler error for some Ubuntu 20.04.6 LTS
Ambiguous overload. See: https://github.com/cculianu/Fulcrum/issues/214#issuecomment-1824044339
2023-11-23 11:24:30 +02:00
Calin Culianu
f27fc28fa2
Bumped verstion to 1.9.7 2023-11-22 20:46:03 +02:00
Calin Culianu
34a825a23f
Fixups to mempool synch code to handle rare corner case (mostly for BTC)
There was a race condition to the SynchMempoolTask. See issue #214. It
could lead to a situation where the prefetcher thread was joined by 2
threads at once (bad!).

This has now been addressed and also failures to read inputs from
mempool and/or DB are now handled much more robustly (due to block-only
txns + new block arriving as we are synching the mempool -- rare corner
case!).

Fixes issue #214.
2023-11-22 20:06:39 +02:00
Calin Culianu
f9942dc2e8
Updated electrum-cash-protocol submodule ref
We updated the docs to fix a formatting issue for
`daemon.passthrough`. Commit the submodule latest HEAD ptr to this
repo.
2023-11-11 07:18:42 +02:00
Calin Culianu
26243681b3
Bumped verion to 1.9.6
In preparation for release.
2023-11-10 21:13:11 +02:00
Calin Culianu
1c2416a17a
Updated documentation to document new methods added for protocol 1.5.2 2023-11-10 20:50:35 +02:00
Calin Culianu
1b8ce7feb0
Added custom RPC method: daemon.passthrough (disabled by default)
This method allows forwarding of RPC commands to bitcoind through
Fulcrum. It is disabled by default, and must be explicitly enabled
from the conf file by defining subnets for which it is enabled (see the
conf file parameter: `daemon_passthrough_subnets`).

The operation of this method is simply to forward requests to bitcoind
and send the reply back to the client.

The JSON-RPC request to Fulcrum should be something like:

    {"id":1, "method": "daemon.passthrough", "params": { "method": "nested_method_to_send_to_bitcoind", "params": [...] } }

So the "params" contains a nested object of 2 keys, "method" and "params"
(again) which define the JSON-RPC request that gets sent to bitcoind.

Replies will come back as a normal JSON-RPC response. Error replies from
bitcoind will yield a JSON-RPC error response send to the client.
2023-11-10 17:56:05 +02:00
Calin Culianu
3d0468dbc3
Made blockchain.*.get_first_use return null on unused addresses
After much discussion, it was agreed this was fine.  Now it works like
most other methods that return empty or `null` results for a valid
address with no history.
2023-11-10 14:59:21 +02:00
Calin Culianu
5ce95cd628
Follow-up: minor nit 2023-11-10 10:41:13 +02:00
Calin Culianu
debb148e5f
Follow-up: Some nits and refactoring applied to previous commit 2023-11-10 10:10:48 +02:00
Calin Culianu
cbed31efd5
Mempool bench: Added optional mechanism to download real coins from bitcoind
For `--bench mempool`, added the ability to specify a bitcoind daemon to
connect to (via env var BITCOIND), in addition to the mempool.dat file (env
var MPDAT). If BITCOIND is specified in env, then we don't synthesize
the confirmed coins being spent, instead we download the real prevTx coins
that are referenced by the mempool.dat.

It is hoped this will lead to a more realistic simulation when benching &
testing the mempool code of Fulcrum.
2023-11-10 09:24:37 +02:00