@@ -2146,7 +2146,16 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
21462146 mapBlockSource.emplace (pblock->GetHash (), std::make_pair (pfrom->GetId (), false ));
21472147 }
21482148 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 );
21502159 if (fNewBlock ) {
21512160 pfrom->nLastBlockTime = GetTime ();
21522161 } else {
@@ -2226,7 +2235,11 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
22262235 bool fNewBlock = false ;
22272236 // Since we requested this block (it was in mapBlocksInFlight), force it to be processed,
22282237 // 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 );
22302243 if (fNewBlock ) {
22312244 pfrom->nLastBlockTime = GetTime ();
22322245 } else {
0 commit comments