Commit Graph
100 Commits
Author SHA1 Message Date
Duke b200dcb2c7 Update test_antispam 2023-10-10 12:03:41 -04:00
Duke 84a0c2c35e antispam test 2023-10-07 14:16:59 -04:00
Duke b386cd1acf Scripts to test this branch 2023-10-07 14:15:12 -04:00
Duke c8a88e1168 Check null randomx dataset before calling randomx_dataset_item_count 2023-10-07 14:07:34 -04:00
Duke aa5cbee69c Remove dead code 2023-09-18 20:57:47 -04:00
Duke d7cbdcab28 Always log when skipping a zaddr during z_importwallet 2023-09-18 20:44:16 -04:00
Duke 2308db22ee Antispam defenses
This code is inspired by
https://github.com/PirateNetwork/pirate/commit/db292a49ddc13374f43b8c16217e171316be53d7
with various improvements that will be documented below.

The largest improvement is that this code will defend against a spammer using shielded inputs (zins)
or shielded outputs (zouts) while the Pirate code only defends against zout spam.

We wrote a new RPC called z_getstats to study exactly what the distribution of shielded inputs (zins)
and shielded outputs (zouts) look like on HUSH mainnet. Sietch will never make a ztx that contains
more than 9 zouts and so transactions with 10 or more zouts are extremely rare. They correspond to custom
transactions created via code or CLI or mining pool payouts. We allow at most one of these per block. If
there are two, one will remain in the mempool and be mined in the subsequent block. Our code is more strict,
as Pirate will allow up to 6 of these transactions in a single block.

Transactions with many shielded inputs do occur normally when users spend many small shielded unspent outputs
(zutxos) in one transaction, but we determined that a cutoff of 50 zins is quite rare. Between blocks
14000000 and 15000000 only 27 ztxs had 50 or more zins, which is 0.03% . We allow at most one of these
per block and if there are more, they will wait to be mined in a subsequent block.

Also note that a transaction can match both criteria of having large zins and large zouts, so for instance,
if there is a transaction with 50 zins and 10 zouts, it counts towards both requirements and no other
transactions with >=50 zins or >=10 zouts will be mined in that block.

If >=200 transactions with either large zins or large zouts are broadcast to the network it will take at least
200 blocks for them to be mined and so via existing rules for ztx expiration they will expire and be removed
from the mempool, since by default all ztxs expire after 200 blocks. Since normal ztxs that match these
criteria are very rare, the only case when this might happen is during a spam attack and so the attackers
transactions expiring is another part of these defenses.

Other improvements are that we log txids of transactions with large zins or zouts and we do not support a
command line option to turn this protection off. This forces a potential attacker to compile their own custom
code if they want to subvert these protections on their own node and blocks they mine.

Similar to Pirate, these changes are not consensus changes but may be made consensus requirements
in the future.

These protections are not specific to HUSH and are enabled for all HSC's, including DragonX.
2023-09-18 13:30:40 -04:00
Duke 09555fbee2 Allow abortrescan during RPC warmup
If we don't, we can get the hilarious error message that the node is Rescanning...
when trying to run abortrescan when the node automatically does a rescan on boot.
2023-09-18 12:43:27 -04:00
Duke 7c45e66fbe Also return start and ending height in z_getstats json 2023-09-08 08:28:14 -04:00
Duke 4aca3493e3 Even more zstats
Example data for the entire history of the current HUSH mainnet :

  ./src/hush-cli z_getstats 1 1487622
{
  "total_ztxs": 414962,
  "total_zins": 798083,
  "total_zouts": 3312131,
  "total_ztxs_10_or_more_zins": 6789,
  "total_ztxs_25_or_more_zins": 1779,
  "total_ztxs_50_or_more_zins": 688,
  "total_ztxs_100_or_more_zins": 174,
  "total_ztxs_10_or_more_zouts": 2855,
  "total_ztxs_25_or_more_zouts": 394,
  "total_ztxs_50_or_more_zouts": 314,
  "total_ztxs_100_or_more_zouts": 208,
  "avg_zins": 1.923267672702561,
  "avg_zouts": 7.981769415030774,
  "largest_zins": 517,
  "largest_zins_txid": "69f126edd5a0189fbbe84b0824eb48e16eddf180e7d5d4f34c4296d0f868ac7f",
  "largest_zouts": 210,
  "largest_zouts_txid": "2a3155f73fab9191978e77e03be8ec7167372c4549113a6eb3f8a9d343f749ba"
}
2023-09-05 11:30:27 -04:00
Duke ff7a597032 Lots of more data for z_getstats 2023-09-05 00:35:11 -04:00
Duke 7ea88bb303 Return total zins+zouts in json 2023-09-04 09:03:06 -04:00
Duke 8eaba566fd Force avg zins/zouts to be a double 2023-09-04 08:57:23 -04:00
Duke 0f4956dcd5 Initialize variables in z_getstats correctly 2023-09-04 08:50:05 -04:00
Duke 96ae2d61ca z_getstats RPC that calculates various stats about ztxs in a block range 2023-09-04 08:22:12 -04:00
Duke 1c45a71b05 Remove dead code 2023-09-03 08:52:28 -04:00
Duke e2521ac2fa Remove unused sproutfunds argument 2023-09-03 08:48:06 -04:00
Duke bd38a12512 Remove useless sprout key from coinsupply RPC 2023-09-03 08:40:06 -04:00
Duke bacc08e817 Remove sprout data from valuePools
This codebase does not support sprout, the data will always be zero/empty
and is essentially useless cruft, so we delete it.
2023-09-03 08:37:19 -04:00
Duke a90f03ce6d Fix build-debian-package.sh docs and document how to make an aarch64 deb 2023-08-16 10:37:23 -04:00
Duke 4d3d880036 Add docs for adding a new PoW algo 2023-08-08 15:40:52 -04:00
Duke 8969a9d8fe Put binaries into a properly named subdirectory, fixes #311 2023-07-04 11:14:56 -04:00
Duke 7017d8e06c Add info about DRAGONX checkpoints to release process 2023-06-30 06:42:33 -04:00
Duke d3cc17e9bd Update relnotes for 3.9.4 2023-06-30 06:37:37 -04:00
Duke 9508095186 Remove unused code 2023-06-29 11:48:30 -04:00
Duke 9d2720d118 Merge branch 'duke' into dev 2023-06-20 05:17:52 -07:00
Duke c933771f85 Merge branch 'danger' into duke 2023-06-17 21:40:36 -04:00
Duke fc69220e78 Remove unused code 2023-06-17 21:38:39 -04:00
Duke b03c8f3108 Remove unused code 2023-06-17 21:31:05 -04:00
Duke 31cc5ee901 Remove unused code 2023-06-17 21:22:41 -04:00
Duke 8f7e53a6fe Merge branch 'duke' into danger 2023-06-17 09:52:34 -04:00
Duke 5abc550af7 Dragonx has a blocktime of 36s not 60s 2023-06-17 09:52:12 -04:00
Duke e608600f07 Merge branch 'duke' into danger 2023-06-17 09:48:31 -04:00
Duke 97c7e814cf Add checkpoints for DRAGONX 2023-06-15 15:47:14 -04:00
Duke 1f0b538540 Take into account ac_name to calculate total txs 2023-06-15 15:43:08 -04:00
Duke f12bfeb7f4 Fix bug where it uses the wrong -ac_name 2023-06-15 15:38:16 -04:00
Duke b8ae39ccc7 Enable the option for dragonx checkpoints 2023-06-15 10:25:59 -04:00
Duke c9f1fe4cf3 Support arbitrary -ac_name in checkpoints.pl 2023-06-15 10:13:01 -04:00
Duke 79f126be43 Use default jobs number when compiling boost
According to current boost docs, not specifying -j parameter will default to using all cores to compile,
so removing these should speed up compiling boost. This code dates back to 2014 when the default
may have been a single core, so it was specified.
2023-06-13 22:43:16 -04:00
Duke 5f9bb80873 Remove unused function 2023-06-12 19:06:50 -04:00
Duke 67c7632062 Remove dead code 2023-06-12 19:06:41 -04:00
Duke 487fff149c Remove dead code related to invalid joinsplit sigs 2023-06-12 07:59:53 -07:00
Duke 18f0689695 Avoid ztx validation during IBD if height is less than latest checkpoint 2023-06-12 07:55:45 -07:00
Duke fc921eba57 Remove dead code 2023-06-09 00:00:42 -04:00
Duke 04c28e3eef Disable run-time asserts in addrman
Run-time asserts are a horrible anti-pattern littered across code
inherited from BTC. One could maybe argue they are the right thing to do
in some situations but not when managing the peer database. Crashing our
full node and potentially corrupting our wallet or block index is INSANE
in the case of some inconsistencies in peers.dat .
2023-05-20 06:12:40 -07:00
Duke 18eea5cb03 Merge branch 'duke' of https://git.hush.is/hush/hush3 into duke 2023-04-27 07:10:08 -04:00
Duke 519743f704 Only log to stderr in CalculateNextWorkRequired and GetNextWorkRequired if -debug 2023-04-23 07:03:05 -07:00
Duke d840a0ec62 Only log nbits in ContextualCheckBlockHeader if -debug 2023-04-23 06:56:19 -07:00
Duke a6924bb061 Give a useful message if autoconf is not installed 2023-04-23 06:29:48 -07:00
Duke fbda7b8dec Fix compile issues 2023-04-22 19:28:24 -04:00
Duke 7102d50a47 Try to prevent #266
We seem to have a bug that we don't find a peer when looking for a peer
in peers.dat . Instead of doing an assertion and crashing the node,
just keep iterating in the loop. The code which computes nId may have an
off-by-one error, such that it looks up an incorrect bucket position and
doesn't find a valid nId.
2023-04-22 15:54:13 -07:00
Duke 053e9156a7 Fix progress estimate for HUSH at startup 2023-04-12 10:08:09 -04:00
Duke 852f747cbf Remove dead code 2023-04-06 13:39:42 -04:00
Duke c1ec1b0e95 Remove dead code 2023-04-06 13:31:07 -04:00
Duke fba0d4136d Remove code for unsupported chains 2023-04-06 13:28:14 -04:00
Duke 533356ce63 Remove more dead code related to interest 2023-04-06 13:22:20 -04:00
Duke c69a47dd61 Remove dead code relating to interest 2023-04-06 13:05:20 -04:00
Duke 15aaf4af44 Remove mempool p2p message #284 2023-04-06 12:59:31 -04:00
Duke f0ee52a94d Remove dead code 2023-04-06 12:44:37 -04:00
Duke 4c5649454b Fix const-ness of ReadTxIndex 2023-04-06 12:44:30 -04:00
Duke 8c8f451be8 Remove dead code from CheckTransaction() 2023-04-06 12:37:10 -04:00
Duke b4be7aa19b malloc_trim does not seem to exist on FreeBSD 2023-04-06 05:40:30 -07:00
Duke 0b68ea2a20 Disable rust docs to speed up build times 2023-04-05 19:31:15 -07:00
Duke 98ee2a6a4f Declare various CBlockTreeDB methods as const
Ported from https://github.com/zcash/zcash/commit/fb66589022df4a0eff6ff244aa6b713c3a2bb2dd
which has some methods we do not yet have.
2023-04-05 19:24:30 -07:00
Duke f3c0cb73bb Merge branch 'dev' into duke 2023-04-05 19:18:18 -07:00
Duke 8126e706c6 Optional OP_RETURN in z_sendmany 2023-03-24 16:20:17 -04:00
Duke d1b649825a Merge branch 'duke' into dev 2023-03-17 14:07:19 -04:00
Duke 63ad87f69b Ensure CNode::addrKnown immediately takes little memory when we disconnect the node 2023-03-17 00:21:00 -04:00
Duke c1baab7b8a Rate limit incoming addr p2p messages 2023-03-16 22:33:25 -04:00
Duke bde7273c9f Remove mapRequest tracking 2023-03-14 15:54:28 -04:00
Duke 560f8e2f41 Remove unused GetRequestCount() 2023-03-14 14:44:14 -04:00
Duke 71928fa228 Randomize order of processing messages from peers 2023-03-14 14:42:39 -04:00
Duke 24b3f1f93b Merge branch 'dev' into duke 2023-03-09 11:17:53 -08:00
Duke a0d02cc3be Batch files for dragonx-cli and dragonxd 2023-02-15 18:06:09 -08:00
Duke 30c919af25 Add dragonx scripts to linux binary releases 2023-02-14 09:14:38 -08:00
Duke f44e44e7df Unify debian package scripts and add dragonx scripts 2023-02-14 08:46:32 -08:00
Duke 5184b4483f Update release process 2023-02-11 19:30:56 -05:00
Duke f271e60e58 Update release process 2023-02-11 19:29:39 -05:00
Duke 4a2361cdf6 Merge branch 'dev' 2023-02-11 19:27:47 -05:00
Duke bec27a85e5 Update relnotes 2023-02-11 19:23:55 -05:00
Duke 94500a6e39 Reduce stderr spam 2023-02-10 11:27:11 -05:00
Duke 47c67e45db checkpoints 2023-02-09 18:22:57 -05:00
Duke a07bf16b20 Merge branch 'dev' of https://git.hush.is/hush/hush3 into dev 2023-02-09 18:06:14 -05:00
Duke e033a2e6eb Update copyrights to 2023 2023-02-09 18:06:03 -05:00
Duke 2c083978e0 update manpages 2023-02-09 17:27:25 -05:00
Duke 1313d39a71 Merge branch 'dev' of https://git.hush.is/hush/hush3 into dev 2023-02-09 17:17:05 -05:00
Duke 2c9bd5dd18 abortrescan 2023-02-09 17:17:00 -05:00
Duke be90d0e324 Merge branch 'dev' of https://git.hush.is/hush/hush3 into dev 2023-02-09 13:54:03 -08:00
Duke 537307a812 Bump version and protocol version 2023-02-09 13:53:55 -08:00
Duke b360a2395a Allow abortrescan to be called via RPC 2023-02-09 13:45:45 -08:00
Duke 890d218180 Merge branch 'dev' of https://git.hush.is/hush/hush3 into dev 2023-02-09 13:43:23 -08:00
Duke 2f8e5f8144 bump year 2023-02-09 13:43:17 -08:00
Duke 794463015a Merge branch 'dev' into duke 2023-02-08 09:15:26 -05:00
Duke a7939139b2 Merge remote-tracking branch 'origin/abortrescan' into dev
Conflicts:
	src/wallet/wallet.cpp
2023-02-05 18:16:36 -08:00
Duke 9977e12acf Merge branch 'dragonx' into dev 2023-02-05 18:08:40 -08:00
Duke 0d79d11a95 Use Tor v3 .onion in qa tests 2023-01-28 08:44:36 -08:00
Duke 9519e3a6cd Merge branch 'bip155' of https://git.hush.is/hush/hush3 into bip155 2023-01-18 23:24:38 -05:00
Duke d5e9ef763d Prevent coredump when -proxy=... -externalip=... is used
Replace an assert() in Unserialize() with the actual behavior we want,
i.e. making sure that vRandom is empty. Before the assert() was added,
the code called Clear() which ensured vRandom was empty. Clear() was
changed to the assert() in BTC commit b138973a8b4bbe061ad97011f278a21e08ea79e6
to prevent recursive locks but risks crashing the node. Instead, we
just empty out vRandom.

The addition of EXCLUSIVE_LOCKS_REQUIRED is not needed to fix
this but seems prudent since Serialize() has it and the original code
from BTC has EXCLUSIVE_LOCKS_REQUIRED on all the methods of this class.

As a side note, crashing a full node with an assert() and possibly
corrupting the wallet.dat, block files and other data is REALLY
FUCKING DUMB. Instead, code should be written to prevent the
possibility of crashing or throw an exception with a useful error.
2023-01-18 23:02:41 -05:00
Duke 176a9e1c7a Add 'make seeds' to make it easy to add seeds 2023-01-17 08:01:14 -05:00
Duke 6f8bce9b3a Fix bug where setban banned a node for 0 seconds 2023-01-12 23:59:11 -05:00