Commit Graph

472 Commits

Author SHA1 Message Date
0a01ad8bba Fix nBits validation bypass and restore CheckProofOfWork rejection for HACs
Two critical vulnerabilities allowed an attacker to flood the DragonX chain
with minimum-difficulty blocks starting at height 2879907:

1. ContextualCheckBlockHeader only validated nBits for HUSH3 mainnet
   (gated behind `if (ishush3)`), never for HAC/smart chains. An attacker
   could submit blocks claiming any difficulty and the node accepted them.
   Add nBits validation for all non-HUSH3 smart chains, gated above
   daaForkHeight (default 450000) to maintain consensus with early chain
   history that was mined by a different binary.

2. The rebrand commit (85c8d7f7d) commented out the `return false` block
   in CheckProofOfWork that rejects blocks whose hash does not meet the
   claimed target. This made PoW validation a no-op — any hash passed.
   Restore the rejection block and add RANDOMX_VALIDATION height-gated
   logic so blocks after the activation height are always validated even
   during initial block loading.

Vulnerability #1 was inherited from the upstream hush3 codebase.
Vulnerability #2 was introduced by the DragonX rebrand.
2026-03-05 03:09:38 -06:00
85c8d7f7dd Rebrand hush3 to DragonX and share RandomX dataset across mining threads
Minimal rebrand (see compliant-rebrand branch for full rebrand):
- Rename binaries: hushd/hush-cli/hush-tx → dragonxd/dragonx-cli/dragonx-tx
- Default to DRAGONX chain params without -ac_* flags (randomx, blocktime=36, private=1)
- Update configure.ac: AC_INIT([DragonX],[1.0.0])
- Update client version string and user-agent to /DragonX:1.0.0/
- Add chainparams.cpp with DRAGONX network parameters
- Update build.sh, miner.cpp, pow.cpp for DragonX
- Add bootstrap-dragonx.sh utility script
- Update .gitignore for release directory

Share single RandomX dataset across all mining threads:
- Add RandomXDatasetManager with readers-writer lock, reducing RAM from
  ~2GB per thread to ~2GB total plus ~2MB per thread for the VM scratchpad
- Add LogProcessMemory() diagnostic helper for Linux and Windows
2026-03-04 18:42:42 -06:00
d6ba1aed4e Fix RandomX validation exploit: verify nSolution contains valid RandomX hash
- Add CheckRandomXSolution() to validate RandomX PoW in nSolution field
- Add ASSETCHAINS_RANDOMX_VALIDATION activation height per chain
  (DRAGONX: 2838976, TUMIN: 1200, others: height 1)
- Add CRandomXInput serializer for deterministic RandomX hash input
- Fix CheckProofOfWork() to properly reject invalid PoW (was missing
  SMART_CHAIN_SYMBOL check, allowing bypass)
- Call CheckRandomXSolution() in hush_checkPOW and CheckBlockHeader

Without this fix, attackers could submit blocks with invalid RandomX
hashes that passed validation, as CheckProofOfWork returned early
during block loading and the nSolution field was never verified.
2026-03-03 17:28:49 -06:00
Duke
3a8ffe4cff Reject proofs of work that do not match claimed amount 2026-02-02 18:52:43 -05:00
Duke
7e63e2f013 We call them HACs now 2025-06-27 05:32:12 -04:00
Duke
65c4c5c8de They are called Hush Arrakis Chains (HACs) now 2024-03-15 14:06:57 -04:00
onryo
58b65f9670 Update copyrights 2024-02-27 23:59:59 +01:00
Duke
519743f704 Only log to stderr in CalculateNextWorkRequired and GetNextWorkRequired if -debug 2023-04-23 07:03:05 -07:00
Duke
e033a2e6eb Update copyrights to 2023 2023-02-09 18:06:03 -05:00
Duke Leto
01ff5c81f6 Improve some comments and ensure backcompat on HUSH mainnet
Some comments turned out to be wrong and some could be more helpful.
It turns out that when AveragingWindowTimespan was changed to fix a HUSH
mainnet bug long ago, that introduced a bug for HSC's that do not use
a 75s block time. Since the default is 60s that likely means all HSC's that will
be created. There were no production HSC's in use at the time of that bugfix,
so the bug went unnoticed until DRAGONX was launched. The bug then manifested
as the DRAGONX difficulty bug, which cause the difficulty to never correct down,
only up and lead to extremely long block times on DRAGONX mainnet.

This code change ensures that HUSH mainnet uses the same hardcoded AWT as it
did previously and all other HSC's will use params.AveragingWindowTimespan() ,
including DRAGONX mainnet.

This seems less dangerous than changing AveragingWindowTimespan() on HUSH mainnet.
2022-12-06 14:23:53 -05:00
Duke Leto
81f0c7755e Code to test exact cause of the 'up only' diff bug 2022-11-12 09:22:10 -05:00
Jonathan "Duke" Leto
5d2307a709 Update copyrights to 2022 2022-09-19 15:45:30 -07:00
Duke Leto
05cbc86a00 Fix bug where GetNextWorkRequired did not know about randomx 2022-07-01 13:43:51 -04:00
Duke Leto
085f28a067 Hush does not have elections 2021-09-03 11:44:22 -04:00
Duke Leto
4fecf72ec8 Remove dead code 2021-09-02 15:01:58 -04:00
Duke Leto
59fbcbb541 . 2021-09-01 22:34:21 -04:00
Duke Leto
40853af335 Remove things related to PoS 2021-08-19 19:30:03 -04:00
Duke Leto
dab4126a82 hush_makeopret 2021-07-10 12:30:34 -04:00
Duke Leto
4a536d62dc Update copyrights 2021-04-17 13:03:22 -04:00
Duke Leto
187933077a Require -debug for CalculateNextWorkRequired details 2021-03-31 15:45:24 -04:00
Duke Leto
6e7b44b7c0 daa fork height 2021-03-06 16:32:41 -05:00
Duke Leto
cf57365698 Deletions and cleanups 2021-01-26 08:56:08 -05:00
Duke Leto
2e31b7d2dc lol 2021-01-23 22:18:57 -05:00
Duke Leto
e3a68dfdfb Hush is the extreme future, Komodo is the KYC past 2020-12-16 22:49:58 -05:00
Duke Leto
980350b9b4 Stuck in the grind 2020-12-16 22:10:59 -05:00
Duke Leto
b950a68cda remove dead code 2020-12-15 08:29:49 -05:00
Duke Leto
7aacd3dfce Merge branch 'syncbug' into dev
Conflicts:
	src/metrics.cpp
2020-12-11 00:35:14 -05:00
Duke Leto
5b07e01437 Various things 2020-12-11 00:33:56 -05:00
Duke Leto
b58c15b9fb update copyrights 2020-12-10 07:45:36 -05:00
Duke Leto
310ed2a434 This Shit Seems To Work 2020-12-09 20:49:23 -05:00
Duke Leto
86bd499818 Tweaks 2020-12-09 19:20:26 -05:00
Duke Leto
18ce9a6070 crosschain updates 2020-12-09 18:30:57 -05:00
Duke Leto
6a30b40415 Once men turned their thinking over to machines in the hope that this would set them free.
But that only permitted other men with machines to enslave them.

      --  Reverend Mother Gaius Helen Mohiam
2020-12-09 07:23:08 -05:00
Duke Leto
130325b201 Hush those mindiff bits 2020-12-08 07:06:13 -05:00
Duke Leto
c737c0dfaf We call them Hush Smart Chains around here 2020-11-15 11:54:06 -05:00
Duke Leto
ebf0df633b Define a new season of anon Hush DPoW notaries 2020-11-15 11:13:15 -05:00
Duke Leto
bf9af6ace3 Remove unnecessary call to GetBlockHeader() 2020-11-14 19:45:34 -05:00
Duke Leto
be16f80abc Hush Full Node is now GPLv3
Any projects which want to use Hush code from now on will need to be licensed as
GPLv3 or we will send the lawyers: https://www.softwarefreedom.org/

Notably, Komodo (KMD) is licensed as GPLv2 and is no longer compatible to receive
code changes, without causing legal issues. MIT projects, such as Zcash, also cannot pull
in changes from the Hush Full Node without permission from The Hush Developers,
which may in some circumstances grant an MIT license on a case-by-case basis.
2020-10-21 07:28:10 -04:00
Duke Leto
a7f88a87aa Update copyright URL to be https 2020-09-20 13:17:38 -04:00
Duke Leto
bb6565d966 Block time halving at height 340000 2020-06-24 20:49:53 -04:00
Duke Leto
0ed1b74f2f Cleanup 2019-12-20 23:12:26 -05:00
Duke Leto
b6fa28dfa2 Delete more dead code that causes compile issues 2019-12-11 15:51:40 -05:00
Duke Leto
9a90d4186e pow.cpp changes 2019-12-10 11:31:34 -05:00
Duke Leto
0eaee9dc83 Good riddance 2019-11-04 10:53:36 -05:00
Duke Leto
f39cd2a473 Delete Verus junk, which breaks ARMv8/aarch64 builds 2019-11-04 08:17:27 -05:00
jl777
10199d2765 +zawy constants 2019-08-12 00:14:06 -11:00
jl777
b124da71db Force min target 2019-08-10 21:05:30 -11:00
jl777
2c66d17495 Remove the min target from inner 2019-08-10 09:11:42 -11:00
jl777
2a789f1add Cmpval 2019-08-10 07:57:52 -11:00
jl777
ac4d149b0a Handle W=1 for ranges of T 2019-08-10 00:43:20 -11:00