Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YpjcB-0006oy-DB for bitcoin-development@lists.sourceforge.net; Tue, 05 May 2015 20:38:51 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; envelope-from=tier.nolan@gmail.com; helo=mail-qk0-f172.google.com; Received: from mail-qk0-f172.google.com ([209.85.220.172]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YpjcA-0006YO-3V for bitcoin-development@lists.sourceforge.net; Tue, 05 May 2015 20:38:51 +0000 Received: by qku63 with SMTP id 63so114732051qku.3 for ; Tue, 05 May 2015 13:38:44 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.140.38.167 with SMTP id t36mr3572227qgt.69.1430858324709; Tue, 05 May 2015 13:38:44 -0700 (PDT) Received: by 10.140.85.241 with HTTP; Tue, 5 May 2015 13:38:44 -0700 (PDT) In-Reply-To: References: <20141001130826.GM28710@savin.petertodd.org> <55075795.20904@bluematt.me> <20150421075912.GA25282@savin.petertodd.org> <5546D653.4070404@bluematt.me> Date: Tue, 5 May 2015 21:38:44 +0100 Message-ID: From: Tier Nolan Cc: Bitcoin Dev Content-Type: multipart/alternative; boundary=001a11c12ce42b173b05155baaa8 X-Spam-Score: 1.8 (+) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tier.nolan[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 1.2 MISSING_HEADERS Missing To: header 1.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 1.2 MALFORMED_FREEMAIL Bad headers on message from free email service X-Headers-End: 1YpjcA-0006YO-3V Subject: Re: [Bitcoin-development] Relative CHECKLOCKTIMEVERIFY (was CLTV proposal) X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 May 2015 20:38:51 -0000 --001a11c12ce42b173b05155baaa8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think that should be greater than in the comparison? You want it to fail if the the height of the UTXO plus the sequence number is greater than the spending block's height. There should be an exception for final inputs. Otherwise, they will count as relative locktime of 0xFFFFFFFF. Is this check handled elsewhere? if (!tx.vin[i].IsFinal() && nSpendHeight < coins->nHeight + tx.vin[i].nSequence) return state.Invalid(false, REJECT_INVALID, "bad-txns-non-final-input"); Is the intention to let the script check the sequence number? OP_RELATIVELOCKTIMEVERIFY would check if is less than or equal to the sequence number. It does make sequence mean something completely different from before. Invalidating previously valid transactions has the potential to reduce confidence in the currency. A workaround would be to have a way to enable it in the sigScript by extending Peter Todd's suggestion in the other email chain. <1> OP_NOP2 means OP_CHECKLOCKTIMEVERIFY (absolute) <2> OP_NOP2 means OP_RELATIVECHECKLOCKTIMEVERIFY <3> OP_NOP2 means OP_SEQUENCE_AS_RELATIVE_HEIGHT OP_SEQUENCE_AS_RELATIVE_HEIGHT would cause the script to fail unless it was the first opcode in the script. It acts as a flag to enable using the sequence number as for relative block height. This can be achieved using a simple pattern match. bool CScript::IsSequenceAsRelativeHeight() const { // Extra-fast test for pay-to-script-hash CScripts: return (this->size() >=3D 4 && this->at(0) =3D=3D OP_PUSHDATA1 && this->at(1) =3D=3D 1 && this->at(2) =3D=3D 0xFF && this->at(3) =3D=3D OP_NOP2); } if (!tx.vin[i].IsFinal() && tx.vin[i].scriptSig.IsSequenceAsRelativeHeight() && nSpendHeight < coins->nHeight + tx.vin[i].nSequence) return state.Invalid(false, REJECT_INVALID, "bad-txns-non-final-input"); On Mon, May 4, 2015 at 12:24 PM, Jorge Tim=C3=B3n wrote: > for (unsigned int i =3D 0; i < tx.vin.size(); i++) { > // ... > if (coins->nHeight + tx.vin[i].nSequence < nSpendHeight) > return state.Invalid(false, REJECT_INVALID, > "bad-txns-non-final-input"); > // ... > } > --001a11c12ce42b173b05155baaa8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I think that should be greater than in the comparison= ?=C2=A0 You want it to fail if the the height of the UTXO plus the sequence= number is greater than the spending block's height.

= There should be an exception for final inputs.=C2=A0 Otherwise, they will c= ount as relative locktime of 0xFFFFFFFF.=C2=A0 Is this check handled elsewh= ere?

if (!tx.vin[i].IsFinal() && nSpendHeight < coins-&g= t;nHeight + tx.vin[i].nSequence)
=C2=A0 =C2=A0 =C2=A0=C2=A0 return state.Invalid(false, REJECT_INVALID, &quo= t;bad-txns-non-final-input");

Is the intention to let the= script check the sequence number?

= <number> OP_RELATIVELOCKTIMEVERIFY

would check if <number> is less than or equal to the sequence n= umber.

It does make sequence mean something completely different from before.= =C2=A0 Invalidating previously valid transactions has the potential to redu= ce confidence in the currency.

A wo= rkaround would be to have a way to enable it in the sigScript by extending = Peter Todd's suggestion in the other email chain.

<1> OP_NOP2 means OP_CHECKLOCKTIMEVERIFY (absolute= )
<2> OP_NOP2 means OP_RELATIVECH= ECKLOCKTIMEVERIFY

<3> OP_NOP= 2 means OP_SEQUENCE_AS_RELATIVE_HEIGHT
=
OP_SEQUENCE_AS_RELATIVE_HEIGHT would cause the script to fail unless it= was the first opcode in the script.=C2=A0 It acts as a flag to enable usin= g the sequence number as for relative block height.

This can be achieved using a simple pattern match.

= bool CScript::IsSequenceAsRelativeHeight() const
{
=C2=A0=C2=A0=C2=A0= // Extra-fast test for pay-to-script-hash CScripts:
=C2=A0=C2=A0=C2=A0 = return (this->size() >=3D 4 &&
=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 this->at(0) =3D=3D OP_PUSHDATA1 &&
=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 this->at(1) =3D=3D 1 &&<= br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 this->at(2) =3D=3D 0xFF &&
=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 this->at(3) =3D=3D OP_NOP2);
}

if (!tx.vin[i].IsFina= l() && tx.vin[i].scriptSig.IsSequenceAsRelativeHeight() && = nSpendHeight < coins->nHeight + tx.vin[i].nSequence)
=C2=A0 =C2=A0 =C2=A0=C2=A0 return state.Invalid(false, REJECT_INVALID, &quo= t;bad-txns-non-final-input");

On Mon, May 4, 2015= at 12:24 PM, Jorge Tim=C3=B3n <jtimon@jtimon.cc> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">for (unsi= gned int i =3D 0; i < tx.vin.size(); i++) {
// ...
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (coins->nHeight + tx= .vin[i].nSequence < nSpendHeight)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return state.Invali= d(false, REJECT_INVALID, "bad-txns-non-final-input");
// ...
}

=C2=A0
--001a11c12ce42b173b05155baaa8--