@@ -2146,7 +2146,16 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2146
2146
mapBlockSource.emplace (pblock->GetHash (), std::make_pair (pfrom->GetId (), false ));
2147
2147
}
2148
2148
bool fNewBlock = false ;
2149
- ProcessNewBlock (chainparams, pblock, true , &fNewBlock );
2149
+ // Setting fForceProcessing to true means that we bypass some of
2150
+ // our anti-DoS protections in AcceptBlock, which filters
2151
+ // unrequested blocks that might be trying to waste our resources
2152
+ // (eg disk space). Because we only try to reconstruct blocks when
2153
+ // we're close to caught up (via the CanDirectFetch() requirement
2154
+ // above, combined with the behavior of not requesting blocks until
2155
+ // we have a chain with at least nMinimumChainWork), and we ignore
2156
+ // compact blocks with less work than our tip, it is safe to treat
2157
+ // reconstructed compact blocks as having been requested.
2158
+ ProcessNewBlock (chainparams, pblock, /* fForceProcessing=*/ true , &fNewBlock );
2150
2159
if (fNewBlock ) {
2151
2160
pfrom->nLastBlockTime = GetTime ();
2152
2161
} else {
@@ -2226,7 +2235,11 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2226
2235
bool fNewBlock = false ;
2227
2236
// Since we requested this block (it was in mapBlocksInFlight), force it to be processed,
2228
2237
// even if it would not be a candidate for new tip (missing previous block, chain not long enough, etc)
2229
- ProcessNewBlock (chainparams, pblock, true , &fNewBlock );
2238
+ // This bypasses some anti-DoS logic in AcceptBlock (eg to prevent
2239
+ // disk-space attacks), but this should be safe due to the
2240
+ // protections in the compact block handler -- see related comment
2241
+ // in compact block optimistic reconstruction handling.
2242
+ ProcessNewBlock (chainparams, pblock, /* fForceProcessing=*/ true , &fNewBlock );
2230
2243
if (fNewBlock ) {
2231
2244
pfrom->nLastBlockTime = GetTime ();
2232
2245
} else {
0 commit comments