Merge branch 'fix/daemon-report2' into dev
This commit is contained in:
@@ -32,6 +32,15 @@
|
||||
#define CRYPTO555_PUBSECPSTR "038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac"
|
||||
#define CRYPTO555_HUSHADDR "RFetqf8WUfWnwNeXdknkm8ojk7EXnYFzrv"
|
||||
#define CRYPTO555_RMD160STR "deadbeefbadcaca748c4986b240ff7d7bc3fffb0"
|
||||
// DragonX: block time at/after which the inherited CRYPTO555/notary transparent-vout exemption on
|
||||
// the fully-private chain is removed, so those vouts become invalid like any other taddr. Dropping
|
||||
// a previously-accepted output is a consensus change, so it is activated by block time (same
|
||||
// mechanism as HUSH_SAPING_ACTIVATION) to let the whole network upgrade before it bites.
|
||||
// 0xFFFFFFFF is a SENTINEL meaning "never active": the operator sets a real future timestamp once
|
||||
// the upgrade window has passed AND they have confirmed no active dPoW notarization posts
|
||||
// transparent notary vouts on-chain (which this ban would otherwise reject). Until then this commit
|
||||
// is a no-op and changes no validation behavior.
|
||||
#define DRAGONX_NOTARYVOUT_BAN_TIME 0xFFFFFFFF
|
||||
#define HUSH_FIRSTFUNGIBLEID 100
|
||||
#define HUSH_SAPING_ACTIVATION 1544832000 // Dec 15th, 2018
|
||||
#define HUSH_SAPING_DEADLINE 1550188800 // Feb 15th, 2019
|
||||
|
||||
+48
-16
@@ -328,8 +328,12 @@ namespace {
|
||||
bool fBulkHeaderSeen;
|
||||
//! (server side) time (us) we last served a bulk stream to this peer, for flood throttling.
|
||||
int64_t nLastBulkServeTime;
|
||||
//! (#8 IBD header-flood cap) cumulative headers this peer made us process while in IBD.
|
||||
//! (#8 header-flood cap) cumulative headers this peer made us process.
|
||||
int64_t nHeadersProcessed;
|
||||
//! (#8 header-flood cap) newly-stored headers from this peer that did NOT extend the best
|
||||
//! header chain (side-branch/sibling): the real mapBlockIndex-growth vector. Honest sync and
|
||||
//! new-block announcements are best-extending and never increment this.
|
||||
int64_t nSideBranchHeaders;
|
||||
|
||||
CNodeState() {
|
||||
fCurrentlyConnected = false;
|
||||
@@ -351,6 +355,7 @@ namespace {
|
||||
fBulkHeaderSeen = false;
|
||||
nLastBulkServeTime = 0;
|
||||
nHeadersProcessed = 0;
|
||||
nSideBranchHeaders = 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1593,7 +1598,14 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
|
||||
char destaddr[65];
|
||||
Getscriptaddress(destaddr,txout.scriptPubKey);
|
||||
|
||||
if ( hush_isnotaryvout(destaddr,tiptime) == 0 )
|
||||
// The CRYPTO555/notary allowlist exempts those transparent vouts from the private-chain
|
||||
// ban, leaving a public UTXO on a chain users treat as fully shielded. At/after the
|
||||
// activation time that exemption is dropped and such vouts are rejected like any other
|
||||
// taddr (time-gated + default-off via the sentinel so the whole network upgrades first).
|
||||
// The gate is checked first so the allowlist lookup is skipped entirely once active.
|
||||
int32_t isNotaryVout = ( tiptime >= DRAGONX_NOTARYVOUT_BAN_TIME )
|
||||
? 0 : hush_isnotaryvout(destaddr,tiptime);
|
||||
if ( isNotaryVout == 0 )
|
||||
{
|
||||
const bool isburn = (strcmp(destaddr,BURN_ADDRESS) == 0);
|
||||
if ((ASSETCHAINS_BURN == 1) && isburn && tx.vin.empty()) {
|
||||
@@ -7904,6 +7916,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
|
||||
CBlockIndex *pindexLast = NULL;
|
||||
int64_t nSideBranchThisMsg = 0; // newly-stored headers that did NOT extend the best header chain
|
||||
BOOST_FOREACH(const CBlockHeader& header, headers) {
|
||||
if(fDebug) {
|
||||
printf("%s: size.%i, solution size.%i\n", __func__, (int)sizeof(header), (int)header.nSolution.size());
|
||||
@@ -7916,6 +7929,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
return error("non-continuous headers sequence");
|
||||
}
|
||||
int32_t futureblock;
|
||||
const bool fWasNew = (mapBlockIndex.count(header.GetHash()) == 0); // not already stored (duplicates don't grow mapBlockIndex)
|
||||
if (!AcceptBlockHeader(&futureblock,header, state, &pindexLast)) {
|
||||
int nDoS;
|
||||
if (state.IsInvalid(nDoS) && futureblock == 0)
|
||||
@@ -7925,29 +7939,47 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
return error("invalid header received");
|
||||
}
|
||||
}
|
||||
else if (fWasNew && pindexLast != NULL && pindexLast != pindexBestHeader) {
|
||||
// Newly added to mapBlockIndex but NOT the best-known header: a side-branch/sibling,
|
||||
// which is exactly the flood vector. Honest headers-first sync and new-block
|
||||
// announcements extend the best chain, so they are never counted here.
|
||||
nSideBranchThisMsg++;
|
||||
}
|
||||
}
|
||||
|
||||
// SECURITY (#8: IBD header-flood cap): bound how many headers a single peer can make us
|
||||
// store while in IBD. Honest headers-first sync needs at most ~chain-length headers from a
|
||||
// peer; one that floods far past 2x the known chain length is only trying to bloat
|
||||
// mapBlockIndex/leveldb (such headers are never selected -- nMinimumChainWork gates that --
|
||||
// but they still cost memory/disk). Cap per-peer and drop the peer. IBD-only: post-IBD there is
|
||||
// no header-accept PoW check (removed as bug-prone), so a post-IBD flood is bounded only by
|
||||
// nMinimumChainWork gating selection -- memory/disk growth there is accepted as low-severity.
|
||||
if (IsInitialBlockDownload()) {
|
||||
// SECURITY (#8: header-flood cap): bound how many headers a single peer can make us store, in and
|
||||
// after IBD. Header-accept does no PoW check (removed as bug-prone), so without a cap a connected
|
||||
// peer could flood sibling headers of the tip and grow mapBlockIndex linearly (a memory-exhaustion
|
||||
// DoS). Two complementary per-peer caps, both dropping the peer when exceeded:
|
||||
{
|
||||
CNodeState *hstate = State(pfrom->GetId());
|
||||
if (hstate != NULL) {
|
||||
hstate->nHeadersProcessed += (int64_t)nCount;
|
||||
// Cap RELATIVE TO THE VALIDATED ACTIVE-CHAIN HEIGHT (attacker-hard -- advancing it requires
|
||||
// connecting real PoW blocks), NOT pindexBestHeader: a forward-extending header flood advances
|
||||
// pindexBestHeader in lockstep with the attacker, so a pindexBestHeader-relative cap never fires.
|
||||
// The checkpoint height is a fixed floor so honest IBD (blocks still lagging headers) is never capped.
|
||||
hstate->nHeadersProcessed += (int64_t)nCount;
|
||||
hstate->nSideBranchHeaders += nSideBranchThisMsg;
|
||||
|
||||
// (1) Tight cap on newly-stored SIDE-BRANCH headers -- the actual mapBlockIndex-growth
|
||||
// vector. A legitimate competing fork is bounded by the reorg window (MAX_REORG_LENGTH);
|
||||
// this allows many times that for slack while bounding a flood to a few thousand entries
|
||||
// per peer. Honest best-extending sync never increments the counter, so it is safe to
|
||||
// keep small.
|
||||
const int64_t kSideBranchCap = 2000;
|
||||
if (hstate->nSideBranchHeaders > kSideBranchCap) {
|
||||
Misbehaving(pfrom->GetId(), 100);
|
||||
return error("%s: peer=%d flooded %lld side-branch headers (cap %lld)", __func__,
|
||||
pfrom->id, (long long)hstate->nSideBranchHeaders, (long long)kSideBranchCap);
|
||||
}
|
||||
|
||||
// (2) Loose cumulative backstop against an attacker who grinds a long FORWARD chain of
|
||||
// correct-nBits headers (those do extend the best chain, so (1) never sees them). Cap
|
||||
// RELATIVE TO THE VALIDATED ACTIVE-CHAIN HEIGHT (attacker-hard -- advancing it needs real
|
||||
// PoW), NOT pindexBestHeader (a forward flood advances that in lockstep). The checkpoint
|
||||
// height is a fixed floor so honest IBD (blocks lagging headers) is never capped.
|
||||
int knownH = std::max((int)chainActive.Height(),
|
||||
Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints()));
|
||||
int64_t headerCap = 2 * (int64_t)knownH + 200000;
|
||||
if (hstate->nHeadersProcessed > headerCap) {
|
||||
Misbehaving(pfrom->GetId(), 100);
|
||||
return error("%s: peer=%d flooded %lld headers during IBD (cap %lld)", __func__,
|
||||
return error("%s: peer=%d flooded %lld headers (cap %lld)", __func__,
|
||||
pfrom->id, (long long)hstate->nHeadersProcessed, (long long)headerCap);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-8
@@ -1436,13 +1436,19 @@ void static RandomXMiner()
|
||||
}
|
||||
|
||||
CValidationState state;
|
||||
//{ LOCK(cs_main);
|
||||
// Skip RandomX re-validation during TestBlockValidity — we already
|
||||
// computed the correct hash, and re-verifying allocates ~256MB which
|
||||
// can trigger the OOM killer on memory-constrained systems.
|
||||
SetSkipRandomXValidation(true);
|
||||
bool fValid = TestBlockValidity(state,B, chainActive.LastTip(), true, false);
|
||||
SetSkipRandomXValidation(false);
|
||||
bool fValid;
|
||||
{
|
||||
// Hold cs_main across the LastTip() read and TestBlockValidity: the latter
|
||||
// asserts pindexPrev == chainActive.Tip(), so without the lock a tip change
|
||||
// (a block arriving from a peer, or a reorg) between the read and the assert
|
||||
// aborts the node. The lock was previously removed only to avoid a ~256MB
|
||||
// RandomX re-validation alloc; SetSkipRandomXValidation() already skips that
|
||||
// re-validation here, so holding the lock is cheap and safe.
|
||||
LOCK(cs_main);
|
||||
SetSkipRandomXValidation(true);
|
||||
fValid = TestBlockValidity(state, B, chainActive.LastTip(), true, false);
|
||||
SetSkipRandomXValidation(false);
|
||||
}
|
||||
if ( !fValid )
|
||||
{
|
||||
LogPrintf("RandomXMiner: TestBlockValidity FAILED at ht.%d, gotinvalid=1, state=%s\n",
|
||||
@@ -1450,7 +1456,6 @@ void static RandomXMiner()
|
||||
gotinvalid = 1;
|
||||
return(false);
|
||||
}
|
||||
//}
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
LogPrintf("HushRandomXMiner:\n");
|
||||
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", B.GetHash().GetHex(), HASHTarget.GetHex());
|
||||
|
||||
Reference in New Issue
Block a user