<p>Yes, it does take a miner some amount of computational work to "execute" a script and verify that it allows the transaction to be spent.  In fact, not only miners, but every full node on the Bitcoin network has to execute these scripts.  However, there are measures to limit the cost of this.</p>

<p>Bitcoin scripts <a href="https://bitcoin.stackexchange.com/questions/25427/the-bitcoin-scripting-system-is-purposefully-not-turing-complete-why">have no loops</a> and so the amount of computation needed to execute a script is roughly proportional to its length.  In turn, miners demand transaction fees that are roughly proportional to the transaction's length (or size in bytes), so a long and relatively costly transaction will be more expensive for the creator.  A transaction with a long script would typically be non-standard and thus would not be relayed over the peer-to-peer network (though it could still be included in a block by a miner who received it some other way).  This limits the number of nodes who would ever see the transaction and thus would have to verify the script.</p>

<p>There is a final <a href="https://bitcoin.stackexchange.com/a/35882/5757">upper limit</a>: no single transaction can be larger than the maximum size of a block (currently 1 MB).</p>

<p>(To clarify a semantic disagreement with amaclin's answer: in the case of pool mining, the script verification can be done once by the pool operator on behalf of the individual miners who contribute to the pool; then the individual miners do not have to do it themselves.  My answer here treats a pool conceptually as a single miner, since they are functionally equivalent from the point of view of the Bitcoin protocol.)</p>

CC BY-SA 3.0
2017-04-18T05:07:06.780Z
2017-04-18T14:53:49.790Z
2017-04-18T14:53:49.790Z
Nate Eldredge
<p>I understand that scripts can be written within transactions that make the miners do some work.</p>

<p>How does Bitcoin ensure that scripts that make miners do too much work are prevented?</p>

<transactions><blockchain><proof-of-work>
How are miners prevented from doing too much work?
JustAnotherUser
# How are miners prevented from doing too much work?

(Asked by: username_0 on 2017-04-17)

I understand that scripts can be written within transactions that make the miners do some work.

How does Bitcoin ensure that scripts that make miners do too much work are prevented?

**Tags:** transactions, blockchain, proof-of-work


---

## 1 answers

### Answer by username_1 on 2017-04-18. Score: 2 | Accepted answer

Yes, it does take a miner some amount of computational work to "execute" a script and verify that it allows the transaction to be spent. In fact, not only miners, but every full node on the Bitcoin network has to execute these scripts. However, there are measures to limit the cost of this.

Bitcoin scripts [have no loops](https://bitcoin.stackexchange.com/questions/25427/the-bitcoin-scripting-system-is-purposefully-not-turing-complete-why) and so the amount of computation needed to execute a script is roughly proportional to its length. In turn, miners demand transaction fees that are roughly proportional to the transaction's length (or size in bytes), so a long and relatively costly transaction will be more expensive for the creator. A transaction with a long script would typically be non-standard and thus would not be relayed over the peer-to-peer network (though it could still be included in a block by a miner who received it some other way). This limits the number of nodes who would ever see the transaction and thus would have to verify the script.

There is a final [upper limit](https://bitcoin.stackexchange.com/a/35882/5757): no single transaction can be larger than the maximum size of a block (currently 1 MB).

(To clarify a semantic disagreement with amaclin's answer: in the case of pool mining, the script verification can be done once by the pool operator on behalf of the individual miners who contribute to the pool; then the individual miners do not have to do it themselves. My answer here treats a pool conceptually as a single miner, since they are functionally equivalent from the point of view of the Bitcoin protocol.)


---

