Post
Topic
Board Bitcoin Discussion
Re: BCH, SegWit, SegWit2 - I'm confused, can you help in laymans terms please
by
DannyHamilton
on 30/08/2017, 22:56:36 UTC
the one with the 1 megabyte block size limit "SegWit"

This is really misleading. Search the source code for "MAX_BLOCK_SIZE", or "1000000". You won't find it. Because there is no such limit.

Perhaps you're searching for the wrong thing.  Learn to read code first.  Then tell me what is or isn't in there:

https://github.com/bitcoin/bitcoin/blob/505955052e60e0681865f3064e005ca0d3aa90bf/src/consensus/consensus.h#L15
Code:
/** The maximum allowed weight for a block, see BIP 141 (network rule) */
static const unsigned int MAX_BLOCK_WEIGHT = 4000000;

https://github.com/bitcoin/bitcoin/blob/505955052e60e0681865f3064e005ca0d3aa90bf/src/consensus/consensus.h#L21
Code:
static const int WITNESS_SCALE_FACTOR = 4;


https://github.com/bitcoin/bitcoin/blob/f088a1bb392eaecd912ff9bca6967a8f4765c2b7/src/validation.cpp#L2814
Code:
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");

So, 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 larger than 1 megabyte will be rejected as invalid.