Note that there is also a:
static const int WITNESS_SCALE_FACTOR = 4;
https://github.com/bitcoin/bitcoin/blob/505955052e60e0681865f3064e005ca0d3aa90bf/src/consensus/consensus.h#L21And when validating the size of a received block, the following code is used:
bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW, bool fCheckMerkleRoot)
{
// These are checks that are independent of context.
. . .
// Size limits
if (block.vtx.empty() || block.vtx.size() * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT)
return state.DoS(100, false, REJECT_INVALID, "bad-blk-length", false, "size limits failed");
https://github.com/bitcoin/bitcoin/blob/f088a1bb392eaecd912ff9bca6967a8f4765c2b7/src/validation.cpp#L2814So, if
block.vtx.size() is greater than 1000000
then
block.vtx.size() * WITNESS_SCALE_FACTOR will be greater than 4000000
which is the value of MAX_BLOCK_WEIGHT
As such, any block such that block.vtx.size() is larger than
1 megabyte will be rejected as invalid.