user5406: The file src/script/script.h defines a MAX_SCRIPT_SIZE of 10,000 B. Among other instances, the MAX_SCRIPT_SIZE is used in the IsUnspendable() check, which allows us to avoid adding outputs with excessively long scriptPubKeys to the UTXO set. It also causes input validation to fail if a scriptSig exceeds the permitted length.

In the context of talking about this limit, I was asked and didn't know: "When was the MAX_SCRIPT_SIZE introduced?"

user208: It was introduced in v0.3.7, dated July 31 2010, in commit 73aa262647, titled "fixed segfault in bignum.h, additional security limits, refactoring -- version 0.3.7":
     vector<valtype> altstack;
-    if (pvStackRet)
-        pvStackRet->clear();
-    if (script.size() > 20000)
+    if (script.size() > 10000)
         return false;
+    int nOpCount = 0;

It apparently replaced an older 20000-byte limit (TIL!), which was introduced in v0.3.6, dated a day earlier, in commit a75560d828, titled "reverted makefile.unix wx-config -- version 0.3.6":
     if (pvStackRet)
         pvStackRet->clear();
+    if (script.size() > 20000)
+        return false;


5406: <p>The file <code>src/script/script.h</code> defines a <code>MAX_SCRIPT_SIZE</code> of 10,000 B. Among other instances, the <code>MAX_SCRIPT_SIZE</code> is used in the <code>IsUnspendable()</code> check, which allows us to avoid adding outputs with excessively long <code>scriptPubKeys</code> to the UTXO set. It also causes input validation to fail if a <code>scriptSig</code> exceeds the permitted length.</p>
<p><a href="https://i.stack.imgur.com/AgRV6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AgRV6.png" alt="A code snippet from the Bitcoin Core code base showing the use of MAX_SCRIPT_SIZE in IsUnspendable()" /></a></p>
<p>In the context of talking about this limit, I was asked and didn't know: &quot;When was the <code>MAX_SCRIPT_SIZE</code> introduced?&quot;</p>
 208: <p>It was introduced in v0.3.7, dated July 31 2010, in commit <a href="https://github.com/bitcoin/bitcoin/commit/73aa262647ff9948eaf95e83236ec323347e95d0" rel="nofollow noreferrer">73aa262647</a>, titled &quot;fixed segfault in bignum.h, additional security limits, refactoring -- version 0.3.7&quot;:</p>
<pre><code>     vector&lt;valtype&gt; altstack;
-    if (pvStackRet)
-        pvStackRet-&gt;clear();
-    if (script.size() &gt; 20000)
+    if (script.size() &gt; 10000)
         return false;
+    int nOpCount = 0;
</code></pre>
<p>It apparently replaced an older 20000-byte limit (TIL!), which was introduced in v0.3.6, dated a day earlier, in commit <a href="https://github.com/bitcoin/bitcoin/commit/a75560d828464c3f1138f52cf247e956fc8f937d" rel="nofollow noreferrer">a75560d828</a>, titled &quot;reverted makefile.unix wx-config -- version 0.3.6&quot;:</p>
<pre><code>     if (pvStackRet)
         pvStackRet-&gt;clear();
+    if (script.size() &gt; 20000)
+        return false;
</code></pre>
