<blockquote>
  <p>What is the significance of this last line?</p>
</blockquote>

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

<blockquote>
  <p>How does this impact consensus?</p>
</blockquote>

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

<blockquote>
  <p>Where is the code limiting block size in the most current version of Bitcoin Core?</p>
</blockquote>

<p>It's in <code>CheckBlock()</code>, 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: <a href="https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L3093" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L3093</a></p>

CC BY-SA 4.0
2019-04-21T23:09:04.103Z
also, the variable is defined on src/consensus/consensus.h . /** The maximum allowed size for a serialized block, in bytes (only for buffer size limits) */
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000;
Pedro
CC BY-SA 4.0
2019-04-21T23:15:47.430Z
added here https://github.com/bitcoin/bitcoin/blame/0.14/src/consensus/consensus.h
Pedro
CC BY-SA 4.0
2019-04-21T23:05:15.437Z
2019-04-21T23:05:15.437Z
Ava Chow
<p>In main.h (line 17) we have a constant MAX_SIZE</p>

<p><code>static const unsigned int MAX_SIZE = 0x02000000;
</code></p>

<p>which in decimal format equals to 33554432 (32MB)</p>

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

<pre><code>    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() &gt; MAX_SIZE || ::GetSerializeSize(*this, SER_DISK) &gt; MAX_SIZE)
            return error("CheckBlock() : size limits failed");
        ...
     }
</code></pre>

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

<pre><code>static const unsigned int MAX_BLOCK_SIZE = 1000000;
</code></pre>

<p><a href="https://github.com/bitcoin/bitcoin/blame/9d2174b6f5f3fac2463c7ebc2dbb9004b3740d23/main.h" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blame/9d2174b6f5f3fac2463c7ebc2dbb9004b3740d23/main.h</a></p>

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

<p><a href="https://github.com/bitcoin/bitcoin/blame/9d2174b6f5f3fac2463c7ebc2dbb9004b3740d23/main.cpp#L2613" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blame/9d2174b6f5f3fac2463c7ebc2dbb9004b3740d23/main.cpp#L2613</a></p>

<pre><code> if (nBlockSize + nTxSize &gt;= MAX_BLOCK_SIZE - 10000)
     continue;
</code></pre>

<p>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.</p>

<p>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?</p>

CC BY-SA 4.0
2019-04-21T20:54:35.740Z
if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE) . https://sourceforge.net/p/bitcoin/code/251/tree//trunk/main.cpp
Pedro
<blockchain><block><blocksize>
Block size limit in Bitcoin v0.01
Pedro
# Block size limit in Bitcoin v0.01

(Asked by: username_0 on 2019-04-21)

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?

**Tags:** blockchain, block, blocksize

> **Comments:**
> **username_0**: if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE) . https://sourceforge.net/p/bitcoin/code/251/tree//trunk/main.cpp  

---

## 1 answers

### Answer by username_1 on 2019-04-21. Score: 4 | Accepted answer

> 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>

> **Comments:**
> **username_0**: also, the variable is defined on src/consensus/consensus.h . /** The maximum allowed size for a serialized block, in bytes (only for buffer size limits) */ static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000;  
> **username_0**: added here https://github.com/bitcoin/bitcoin/blame/0.14/src/consensus/consensus.h  

---

