Subject: Re: [Bitcoin-development] On OP_RETURN in upcoming 0.9 release

From: "Jeremy Spilman" <[email-masked]>
Date: Mon, 24 Feb 2014 14:12:10 -0800

On Mon, 24 Feb 2014 09:10:26 -0800, Jeff Garzik <[email-masked]> wrote:
> This PR reduces the size to 40 bytes:
> https://github.com/bitcoin/bitcoin/pull/3737

Just quickly GLANCED at it, but if I understand correctly how the template  
matching code works, that will change max size of the <data> to 40 bytes  
but does not do anything to enforce most-efficient encoding.

   else if (opcode2 == OP_SMALLDATA)
   {
       // small pushdata, <= MAX_OP_RETURN_RELAY bytes
       if (vch1.size() > MAX_OP_RETURN_RELAY)
          break;
   }

This code was a bit hard for me to parse since it's not actually requiring  
any data, just disallowing more than a certain number of bytes of data. So  
a bare OP_RETURN would be allowed as well, for whatever good that will do.

If you want to strictly require no PUSHDATA, perhaps you could do:

   else if (opcode2 == OP_SMALLDATA)
   {
       // small pushdata, <= MAX_OP_RETURN_RELAY bytes
       if (opcode1 >= OP_PUSHDATA1 || vch1.size() > MAX_OP_RETURN_RELAY)
          break;
   }

Thanks,
Jeremy