3
1
Is there any part of the Bitcoin protocol that established a limit on the maximum number of op_codes in a script.
Recently I have hit the limit for the bitcoin core client. In: https://github.com/bitcoin/bitcoin/blob/ce56f5621a94dcc2159ebe57e43da727eab18e6c/src/script/interpreter.cpp in line 276 you find:
if (opcode > OP_16 && ++nOpCount > 201)
return set_error(serror, SCRIPT_ERR_OP_COUNT);*
I interpret this line as saying that, outside standard type of transactions, there is a limit to 201 operations beside pushing a number from 0 to 16 to the stack.
Is this defined in any part of the protocol or discussed in any BIP?
I know there are limits for multiscript transactions: https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki#520byte_limitation_on_serialized_script_size and that the number of signatures should be limited to avoid certain attacks, but for lightweight operations (OP_ADD and the like) I cannot find any explanation on the limit and the exact 201 value.
P.S: I found the error when trying to spend the offending script. Curiously, I was allowed to send the transaction. It is when the client tries to verify the data for the next transaction when there is a problem.
It's all testnet3 testing. In fact I managed to push the transaction to the mempool of a particular relay node: http://test.webbtc.com/mempool_tx/4114ff60040c60158e21bba9391af3798af49a56c9f918596b8419622bfa8fdb They use a different Ruby implementation of Bitcoin. It seems, nevertheless, that most nodes use Bitcoin Core and the transaction will remain in a limbo for some time and then disappear. If it got relayed by Ruby clients, would the block be rejected by the network and create a fork or become part of the blockchain? Once in block is included there is less checking...
– halftimepad – 2015-06-24T14:58:58.090Your transaction is rejected by Bitcoin Core (-25), so Bitcoin Ruby accepting it would be erroneous. Your transaction is effectively nonsense and is trying to spend an OP_RETURN (unspendable) output so this isn't particularly surprising. Block validation is no less strict than transaction validation, in fact the validation is cached and reused in both.
– Anonymous – 2015-06-24T17:38:54.107@halftimepad re http://test.webbtc.com/mempool_tx/ .... What is that exactly? I knew of the relay or pushTx of the API, but I'm interested what you mean here. Are you pushing to this node via REST POST or BTC Core?
– Wizard Of Ozzie – 2015-06-25T02:02:48.917It's the output of http://webbtc.com/relay_tx .
– Anonymous – 2015-06-25T02:23:12.540