<p>This limit is long standing and unexplained, but it didn't always have that particular name. It was dubbed <code>MAX_SCRIPT_ELEMENT_SIZE</code> in <a href="https://github.com/bitcoin/bitcoin/commit/192cc910ec7cade1d0dce7f3b111e7fc7720e607.patch" rel="nofollow">this commit</a>, where previously it was just a magic number in <code>script.cpp</code>. The restriction is found throughout the entire history from master until 0.3.22, but is missing from the 0.1.3 source. You could speculate that it was intended to be an anti-DoS restriction, but these releases retained <code>OP_CAT</code> which would have allowed for nearly infinite sized stack elements regardless of the sizes of data pushes.</p>

<p>The 520 byte push size severely stunts Pay to Script Hash, as the entire script is pushed onto the stack it must respect the push limit. For a P2SH multisignature script this sets the upper limit to n-of-15, any larger and it would be unspendable due to 520 byte consensus rule. </p>

<p>Increasing this limit would be a hard forking change. </p>

CC BY-SA 3.0
2015-08-03T07:33:37.880Z
2015-08-03T11:02:27.747Z
2015-08-03T11:02:27.747Z
Claris
<p>The current Bitcoin client filters out any pushes beyond a certain size.</p>

<pre><code>static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
[...]
if (vchPushValue.size() &gt; MAX_SCRIPT_ELEMENT_SIZE)
    return set_error(serror, SCRIPT_ERR_PUSH_SIZE);
</code></pre>

<p>What's the point of doing this? Does it prevent an attack?</p>

<p>How difficult would it be to change this? Would increasing this constant require a soft/hard fork?</p>

<bitcoin-core>
What was the original rationale for limiting the maximum push size?
Nick ODell
# What was the original rationale for limiting the maximum push size?

(Asked by: username_0 on 2015-08-03)

The current Bitcoin client filters out any pushes beyond a certain size.

```
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
[...]
if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE)
    return set_error(serror, SCRIPT_ERR_PUSH_SIZE);

```

What's the point of doing this? Does it prevent an attack?

How difficult would it be to change this? Would increasing this constant require a soft/hard fork?

**Tags:** bitcoin-core


---

## 1 answers

### Answer by username_1 on 2015-08-03. Score: 5 | Accepted answer

This limit is long standing and unexplained, but it didn't always have that particular name. It was dubbed `MAX_SCRIPT_ELEMENT_SIZE` in [this commit](https://github.com/bitcoin/bitcoin/commit/192cc910ec7cade1d0dce7f3b111e7fc7720e607.patch), where previously it was just a magic number in `script.cpp`. The restriction is found throughout the entire history from master until 0.3.22, but is missing from the 0.1.3 source. You could speculate that it was intended to be an anti-DoS restriction, but these releases retained `OP_CAT` which would have allowed for nearly infinite sized stack elements regardless of the sizes of data pushes.

The 520 byte push size severely stunts Pay to Script Hash, as the entire script is pushed onto the stack it must respect the push limit. For a P2SH multisignature script this sets the upper limit to n-of-15, any larger and it would be unspendable due to 520 byte consensus rule.

Increasing this limit would be a hard forking change.


---

