-1

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?

2

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 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: 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.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.