1

In main.h (line 17) we have a constant MAX_SIZE

static const unsigned int MAX_SIZE = 0x02000000;

which in decimal format equals to 33554432 (32MB)

This constant is used to verify if the block passes the size limit in main.cpp (line 1154)

    bool CBlock::CheckBlock() const
    {
        // These are checks that are independent of context
        // that can be verified before saving an orphan block.

        // Size limits
        if (vtx.empty() || vtx.size() > MAX_SIZE || ::GetSerializeSize(*this, SER_DISK) > MAX_SIZE)
            return error("CheckBlock() : size limits failed");
        ...
     }

According to the git pull request history line 18 was added to main.h by Gavin Andresen:

static const unsigned int MAX_BLOCK_SIZE = 1000000;

https://github.com/bitcoin/bitcoin/blame/9d2174b6f5f3fac2463c7ebc2dbb9004b3740d23/main.h

this new constant appears to only be used on the BitcoinMiner() function on main.cpp

https://github.com/bitcoin/bitcoin/blame/9d2174b6f5f3fac2463c7ebc2dbb9004b3740d23/main.cpp#L2613

 if (nBlockSize + nTxSize >= MAX_BLOCK_SIZE - 10000)
     continue;

Apparently Satoshi believed that this would split the chain but this is only established on the mining node, not on a node that is just collecting new block and adding them to their chain.

What is the significance of this last line? How does this impact consensus? Where is the code limiting block size in the most current version of Bitcoin Core?

1

What is the significance of this last line?

It ensures that the built-in miner does not create blocks that are larger than MAX_BLOCK_SIZE. It checks whether the transaction selected be larger than the limit. The reason there is a - 10000 is to ensure that there is enough space for the coinbase transaction and the block header.

How does this impact consensus?

It's effectively a soft fork. Miners won't make blocks larger than MAX_BLOCK_SIZE. Otherwise there is no effect on consensus.

Where is the code limiting block size in the most current version of Bitcoin Core?

It's in CheckBlock(), the same function the size check was since a size check has existed. Of course the location of this function has moved. Currently it is here: https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L3093

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.