<p>Those consensus rules are indeed the same for testnet and mainnet.</p>

<p>However, they do only apply when scripts are <em>executed</em>. So you have to create an input trying to spend it to test this.</p>

CC BY-SA 4.0
2020-03-06T05:45:58.927Z
So practically this means the only limit on PubkeyScript is block size, right?
Coding Enthusiast
CC BY-SA 4.0
2020-03-06T05:47:13.430Z
That is effectively the only consensus limit on outputs, I believe, indeed.
Pieter Wuille
CC BY-SA 4.0
2020-03-06T08:26:12.660Z
This is my understanding too.
Claris
CC BY-SA 4.0
2020-03-06T05:35:27.807Z
2020-03-06T05:35:27.807Z
Pieter Wuille
<p>I'm trying to figure out the limitations that scripts have regarding their size, limits that would make a script invalid (<strong>ignoring</strong> standardness). According to <a href="https://bitcoin.stackexchange.com/questions/35878/is-there-a-maximum-size-of-a-scriptsig-scriptpubkey">this question</a> and also these lines of code in bitcoin core's source code <a href="https://github.com/bitcoin/bitcoin/blob/3f826598a42dcc707b58224e94c394e30a42ceee/src/script/script.h#L31-L32" rel="nofollow noreferrer">1</a> <a href="https://github.com/bitcoin/bitcoin/blob/3f826598a42dcc707b58224e94c394e30a42ceee/src/script/script.h#L22-L23" rel="nofollow noreferrer">2</a> <a href="https://github.com/bitcoin/bitcoin/blob/3f826598a42dcc707b58224e94c394e30a42ceee/src/script/interpreter.cpp#L299-L300" rel="nofollow noreferrer">3</a> it appears that the following rules are in place:  </p>

<pre><code>Maximum script size = 10,000
Maximum data size to be pushed to the stack = 520
</code></pre>

<p>To test these rules I made a bunch of transactions on TestNet, all of which breaking some rule and were included in blocks (all sent from <code>n3eynMTEiGgPTuoKPApnRjE9pAuaAk3gkB</code>)? Example:<br>
Tx ID: <code>88bac1e84c235aa0418345bf430fb43b336875974b6e87dc958de196f9222c35</code><br>
PubkeyScript <code>length=0xfd1527=10,005</code> script=<code>4d11275b2c...394e75</code>or<code>Push_10001_byte&lt;5b2c...394e&gt; OP_DROP</code><br>
As you can see the length of the script is already 10,005 > 10,000 and the first data push is 10,001 > 520. In other words I broke both rules.<br>
Also as far as I know the "consensus" rules are exactly the same on TestNet (with one exception: difficulty adjustment), is that correct? So how is this transactions valid?</p>

<script><consensus>
What are the script size limitations according to consensus rules and are they enforced on TestNet?
Coding Enthusiast
# What are the script size limitations according to consensus rules and are they enforced on TestNet?

(Asked by: username_0 on 2020-03-06)

I'm trying to figure out the limitations that scripts have regarding their size, limits that would make a script invalid (ignoring standardness). According to this question and also these lines of code in bitcoin core's source code 1 2 3 it appears that the following rules are in place:  
Maximum script size = 10,000
Maximum data size to be pushed to the stack = 520

To test these rules I made a bunch of transactions on TestNet, all of which breaking some rule and were included in blocks (all sent from n3eynMTEiGgPTuoKPApnRjE9pAuaAk3gkB)? Example:
Tx ID: 88bac1e84c235aa0418345bf430fb43b336875974b6e87dc958de196f9222c35
PubkeyScript length=0xfd1527=10,005 script=4d11275b2c...394e75orPush_10001_byte<5b2c...394e> OP_DROP
As you can see the length of the script is already 10,005 > 10,000 and the first data push is 10,001 > 520. In other words I broke both rules.
Also as far as I know the "consensus" rules are exactly the same on TestNet (with one exception: difficulty adjustment), is that correct? So how is this transactions valid?

**Tags:** script, consensus


---

## 1 answers

### Answer by username_1 on 2020-03-06. Score: 3 | Accepted answer

Those consensus rules are indeed the same for testnet and mainnet.

However, they do only apply when scripts are *executed*. So you have to create an input trying to spend it to test this.

> **Comments:**
> **username_0**: So practically this means the only limit on PubkeyScript is block size, right?  
> **username_1**: That is effectively the only consensus limit on outputs, I believe, indeed.  
> **username_2**: This is my understanding too.  

---

